diff mbox series

[PATCHv2,6/7] configs: add new qemu defconfig 'x86_multilib'

Message ID 20220115200306.14037-7-patrickdepinguin@gmail.com
State Rejected
Headers show
Series Basic support for 64-bit kernel and 32-bit userland | expand

Commit Message

Thomas De Schampheleire Jan. 15, 2022, 8:03 p.m. UTC
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel
but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---

Note that the defconfig refers to a toolchain at
autobuild.buildroot.org, but is not yet present at that location.
I uploaded the toolchain temporarily to:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
md5sum:b085c0d8f137c078f8f09d116d8364f8
sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2



 board/qemu/x86_multilib/linux.config  | 57 +++++++++++++++++++++++++++
 board/qemu/x86_multilib/post-build.sh | 11 ++++++
 board/qemu/x86_multilib/readme.txt    |  7 ++++
 configs/qemu_x86_multilib_defconfig   | 26 ++++++++++++
 4 files changed, 101 insertions(+)
 create mode 100644 board/qemu/x86_multilib/linux.config
 create mode 100755 board/qemu/x86_multilib/post-build.sh
 create mode 100644 board/qemu/x86_multilib/readme.txt
 create mode 100644 configs/qemu_x86_multilib_defconfig

Comments

Thomas De Schampheleire Jan. 18, 2022, 11:19 a.m. UTC | #1
Hi,

El sáb, 15 ene 2022 a las 21:03, Thomas De Schampheleire
(<patrickdepinguin@gmail.com>) escribió:
>
> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>
> Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel
> but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.
>
> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> ---
>
> Note that the defconfig refers to a toolchain at
> autobuild.buildroot.org, but is not yet present at that location.
> I uploaded the toolchain temporarily to:
> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
> md5sum:b085c0d8f137c078f8f09d116d8364f8
> sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
>
>

Romain Naour notified me that this toolchain does not run on the GCC
Farm (Illegal instruction) so I made a new version, currently uploaded
at:
http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
md5sum:  3cee64f82675446ad255f6c165786eb5
sha256sum: 6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1

Best regards,
Thomas
Romain Naour Jan. 18, 2022, 11:51 a.m. UTC | #2
Hello Thomas,

Le 18/01/2022 à 12:19, Thomas De Schampheleire a écrit :
> Hi,
> 
> El sáb, 15 ene 2022 a las 21:03, Thomas De Schampheleire
> (<patrickdepinguin@gmail.com>) escribió:
>>
>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>
>> Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel
>> but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.
>>
>> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>> ---
>>
>> Note that the defconfig refers to a toolchain at
>> autobuild.buildroot.org, but is not yet present at that location.
>> I uploaded the toolchain temporarily to:
>> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
>> md5sum:b085c0d8f137c078f8f09d116d8364f8
>> sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
>>
>>
> 
> Romain Naour notified me that this toolchain does not run on the GCC
> Farm (Illegal instruction) so I made a new version, currently uploaded
> at:
> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
> md5sum:  3cee64f82675446ad255f6c165786eb5
> sha256sum: 6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1

This toolchain doesn't work either.

Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ?
With CT_EXTRA_CXXFLAGS_FOR_BUILD maybe or both.

Also, building with a Debian jessie docker container would allow to run the
toolchain with old Glibc.

Best regards,
Romain


> 
> Best regards,
> Thomas
>
Thomas De Schampheleire Jan. 18, 2022, 12:02 p.m. UTC | #3
Hi Romain,

El mar, 18 ene 2022 a las 12:51, Romain Naour
(<romain.naour@gmail.com>) escribió:
>
> Hello Thomas,
>
> Le 18/01/2022 à 12:19, Thomas De Schampheleire a écrit :
> > Hi,
> >
> > El sáb, 15 ene 2022 a las 21:03, Thomas De Schampheleire
> > (<patrickdepinguin@gmail.com>) escribió:
> >>
> >> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >>
> >> Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel
> >> but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.
> >>
> >> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
> >> ---
> >>
> >> Note that the defconfig refers to a toolchain at
> >> autobuild.buildroot.org, but is not yet present at that location.
> >> I uploaded the toolchain temporarily to:
> >> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
> >> md5sum:b085c0d8f137c078f8f09d116d8364f8
> >> sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
> >>
> >>
> >
> > Romain Naour notified me that this toolchain does not run on the GCC
> > Farm (Illegal instruction) so I made a new version, currently uploaded
> > at:
> > http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
> > md5sum:  3cee64f82675446ad255f6c165786eb5
> > sha256sum: 6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1
>
> This toolchain doesn't work either.
>
> Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ?
> With CT_EXTRA_CXXFLAGS_FOR_BUILD maybe or both.

So you get the same error of 'Illegal instruction' ?

Following config was used (both the config as the build log are part
of the archive):

CT_CONFIG_VERSION="3"
# CT_PREFIX_DIR_RO is not set
CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64"
CT_EXTRA_CXXFLAGS_FOR_BUILD="-march=x86-64"
CT_ARCH_X86=y
CT_MULTILIB=y
CT_ARCH_64=y
CT_STATIC_TOOLCHAIN=y
CT_TARGET_VENDOR="multilib"
CT_KERNEL_LINUX=y
CT_GLIBC_KERNEL_VERSION_NONE=y
# CT_CREATE_LDSO_CONF is not set
CT_CC_GCC_MULTILIB_LIST="m64,m32"
CT_CC_GCC_LNK_HASH_STYLE_BOTH=y
CT_CC_LANG_CXX=y
CT_DEBUG_GDB=y
CT_ZLIB_NEEDED=y



>
> Also, building with a Debian jessie docker container would allow to run the
> toolchain with old Glibc.

The toolchain is built statically, so the glibc version on the host
does not matter.
Perhaps I misunderstand the problem you are referring to?

Thanks,
Thomas
Romain Naour Jan. 19, 2022, 8:54 p.m. UTC | #4
Hi Thomas,

Le 18/01/2022 à 13:02, Thomas De Schampheleire a écrit :
> Hi Romain,
> 
> El mar, 18 ene 2022 a las 12:51, Romain Naour
> (<romain.naour@gmail.com>) escribió:
>>
>> Hello Thomas,
>>
>> Le 18/01/2022 à 12:19, Thomas De Schampheleire a écrit :
>>> Hi,
>>>
>>> El sáb, 15 ene 2022 a las 21:03, Thomas De Schampheleire
>>> (<patrickdepinguin@gmail.com>) escribió:
>>>>
>>>> From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>>>
>>>> Add a new qemu defconfig for an x86_64 target that will run an x86_64 kernel
>>>> but userspace in 32-bit (x86) mode, using BR2_KERNEL_ARCH_OVERRIDE.
>>>>
>>>> Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
>>>> ---
>>>>
>>>> Note that the defconfig refers to a toolchain at
>>>> autobuild.buildroot.org, but is not yet present at that location.
>>>> I uploaded the toolchain temporarily to:
>>>> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz
>>>> md5sum:b085c0d8f137c078f8f09d116d8364f8
>>>> sha256sum 2a5241d9274239532e44d37c65509931fbc120db5991412f946eb38176db4dc2
>>>>
>>>>
>>>
>>> Romain Naour notified me that this toolchain does not run on the GCC
>>> Farm (Illegal instruction) so I made a new version, currently uploaded
>>> at:
>>> http://patrickdepinguin.com/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11-2.tar.xz
>>> md5sum:  3cee64f82675446ad255f6c165786eb5
>>> sha256sum: 6715bfbc195588b6483d39e9ec6d70611cac3b99bf2dd34fedbed0d4e6c7edc1
>>
>> This toolchain doesn't work either.
>>
>> Did you tried with CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64" ?
>> With CT_EXTRA_CXXFLAGS_FOR_BUILD maybe or both.
> 
> So you get the same error of 'Illegal instruction' ?
> 
> Following config was used (both the config as the build log are part
> of the archive):
> 
> CT_CONFIG_VERSION="3"
> # CT_PREFIX_DIR_RO is not set
> CT_EXTRA_CFLAGS_FOR_BUILD="-march=x86-64"
> CT_EXTRA_CXXFLAGS_FOR_BUILD="-march=x86-64"
> CT_ARCH_X86=y
> CT_MULTILIB=y
> CT_ARCH_64=y
> CT_STATIC_TOOLCHAIN=y

I didn't enabled static toolchain option. Can you try without it.

Notes: All Bootlin toolchain use glibc installed on the host, so we can't use
really old systems.

> CT_TARGET_VENDOR="multilib"
> CT_KERNEL_LINUX=y
> CT_GLIBC_KERNEL_VERSION_NONE=y
> # CT_CREATE_LDSO_CONF is not set
> CT_CC_GCC_MULTILIB_LIST="m64,m32"
> CT_CC_GCC_LNK_HASH_STYLE_BOTH=y
> CT_CC_LANG_CXX=y
> CT_DEBUG_GDB=y
> CT_ZLIB_NEEDED=y
> 
> 
> 
>>
>> Also, building with a Debian jessie docker container would allow to run the
>> toolchain with old Glibc.
> 
> The toolchain is built statically, so the glibc version on the host
> does not matter.
> Perhaps I misunderstand the problem you are referring to?

I missed that your toolchain was build statically.
Usually other prebuilt toolchain are not built statically.

Best regards,
Romain


> 
> Thanks,
> Thomas
>
diff mbox series

Patch

diff --git a/board/qemu/x86_multilib/linux.config b/board/qemu/x86_multilib/linux.config
new file mode 100644
index 0000000000..0ea9e53a06
--- /dev/null
+++ b/board/qemu/x86_multilib/linux.config
@@ -0,0 +1,57 @@ 
+CONFIG_SYSVIPC=y
+# CONFIG_USELIB is not set
+CONFIG_CGROUPS=y
+CONFIG_SMP=y
+CONFIG_HYPERVISOR_GUEST=y
+CONFIG_PARAVIRT=y
+CONFIG_IA32_EMULATION=y
+# CONFIG_COMPAT_32BIT_TIME is not set
+# CONFIG_GCC_PLUGINS is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_WIRELESS is not set
+CONFIG_PCI=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_SCSI_VIRTIO=y
+CONFIG_ATA=y
+CONFIG_ATA_PIIX=y
+CONFIG_NETDEVICES=y
+CONFIG_VIRTIO_NET=y
+CONFIG_NE2K_PCI=y
+CONFIG_8139CP=y
+# CONFIG_WLAN is not set
+CONFIG_INPUT_EVDEV=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_VIRTIO_CONSOLE=y
+CONFIG_HW_RANDOM_VIRTIO=m
+CONFIG_DRM=y
+CONFIG_DRM_QXL=y
+CONFIG_DRM_VIRTIO_GPU=y
+CONFIG_DRM_BOCHS=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_HDA_INTEL=y
+CONFIG_SND_HDA_GENERIC=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_UHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_VIRTIO_BALLOON=y
+CONFIG_VIRTIO_INPUT=y
+CONFIG_VIRTIO_MMIO=y
+CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
+CONFIG_EXT4_FS=y
+CONFIG_AUTOFS4_FS=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_UNWINDER_FRAME_POINTER=y
diff --git a/board/qemu/x86_multilib/post-build.sh b/board/qemu/x86_multilib/post-build.sh
new file mode 100755
index 0000000000..bf83a002c2
--- /dev/null
+++ b/board/qemu/x86_multilib/post-build.sh
@@ -0,0 +1,11 @@ 
+#!/bin/sh
+
+set -u
+set -e
+
+# Add a console on tty1
+if [ -e ${TARGET_DIR}/etc/inittab ]; then
+    grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
+	sed -i '/GENERIC_SERIAL/a\
+tty1::respawn:/sbin/getty -L  tty1 0 vt100 # QEMU graphical window' ${TARGET_DIR}/etc/inittab
+fi
diff --git a/board/qemu/x86_multilib/readme.txt b/board/qemu/x86_multilib/readme.txt
new file mode 100644
index 0000000000..fbc8ae9a6a
--- /dev/null
+++ b/board/qemu/x86_multilib/readme.txt
@@ -0,0 +1,7 @@ 
+Run the emulation with:
+
+  qemu-system-x86_64 -M pc -kernel output/images/bzImage -drive file=output/images/rootfs.ext2,if=virtio,format=raw -append "rootwait root=/dev/vda console=tty1 console=ttyS0" -serial stdio -net nic,model=virtio -net user # qemu_x86_multilib_defconfig
+
+Optionally add -smp N to emulate a SMP system with N CPUs.
+
+The login prompt will appear in the graphical window.
diff --git a/configs/qemu_x86_multilib_defconfig b/configs/qemu_x86_multilib_defconfig
new file mode 100644
index 0000000000..1c3a8179c1
--- /dev/null
+++ b/configs/qemu_x86_multilib_defconfig
@@ -0,0 +1,26 @@ 
+BR2_KERNEL_ARCH_OVERRIDE="x86_64"
+BR2_x86_core2=y
+BR2_TOOLCHAIN_EXTERNAL=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
+BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
+BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/ctng-6737cfaa8ce6-x86_multilib-glibc-gcc11.tar.xz"
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="x86_64-multilib-linux-gnu"
+BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_15=y
+BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
+# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
+BR2_TOOLCHAIN_EXTERNAL_CXX=y
+BR2_TARGET_OPTIMIZATION="-m32"
+BR2_SYSTEM_DHCP="eth0"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/qemu/x86_multilib/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)"
+BR2_LINUX_KERNEL=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.15"
+BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_multilib/linux.config"
+BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
+BR2_TARGET_ROOTFS_EXT2=y
+# BR2_TARGET_ROOTFS_TAR is not set
+BR2_PACKAGE_HOST_QEMU=y
+BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE=y