[Qemu-devel] [Bug 604872] Re: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm
qemu-kvm is what's currently in the Ubuntu archive; I'm sure Peter will also arrange for the ubuntu-qemu-omap branch to get these fixes once they are in suitable shape. In any case, these fixes are also going upstream and will eventually bubble up to derived trees -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/604872 Title: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm Status in QEMU: In Progress Status in “qemu-kvm” package in Ubuntu: Triaged Bug description: Binary package hint: qemu-kvm As I'm now implementing the support for creating a rootstock rootfs without requiring root, I need to run the deboostrap' second stage inside a VM, to correctly install the packages into the rootfs. qemu-system-arm fails right after debootstrap finish the second stage, giving a segmentation fault. Command: qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel vmlinuz -no-reboot -nographic -drive file=qemu-armel-201007122016.img,aio=native,cache=none -m 256 -append 'console=ttyAMA0,115200n8 root=/dev/sda rw mem=256M devtmpfs.mount=0 init=/bin/installer' Uncompressing Linux. done, booting the kernel. [0.00] Initializing cgroup subsys cpuset [0.00] Initializing cgroup subsys cpu [0.00] Linux version 2.6.32-21-versatile (bui...@cushaw) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #32-Ubuntu Fri Apr 16 08:14:53 UTC 2010 (Ubuntu 2.6.32-21.32-versatile 2.6.32.11+drm33.2) ... I: Base system installed successfully. I: Starting basic services in VM Segmentation fault (core dumped) [492816.197352] qemu-system-arm[16024]: segfault at cf6ba8fc ip cf6ba8fc sp 7fffd0e68680 error 14 Image: * rootfs: http://rsalveti.net/pub/ubuntu/rootstock/qemu-armel-201007122016.img (md5 1d063ac8a65c798bb004cd1c4c7970c5) * kernel: http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz I'm able to reproduce the bug on Maverick (amd64) and Lucid (x86). Maverick qemu-kvm-extras: 0.12.4+noroms-0ubuntu4 Lucid qemu-kvm-extras: 0.12.3+noroms-0ubuntu9.2 ProblemType: Bug DistroRelease: Ubuntu 10.10 Package: qemu-kvm-extras 0.12.4+noroms-0ubuntu4 ProcVersionSignature: Ubuntu 2.6.35-6.9-generic 2.6.35-rc3 Uname: Linux 2.6.35-6-generic x86_64 Architecture: amd64 Date: Mon Jul 12 18:55:35 2010 InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1) KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UIDPID PPID CSZ RSS PSR STIME TTY TIME CMD MachineType: LENOVO 2764CTO PccardctlIdent: Socket 0: no product info available PccardctlStatus: Socket 0: no card ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.35-6-generic root=/dev/mapper/primary-root ro crashkernel=384M-2G:64M,2G-:128M quiet splash ProcEnviron: LANG=en_US.utf8 SHELL=/bin/bash SourcePackage: qemu-kvm dmi.bios.date: 04/19/2010 dmi.bios.vendor: LENOVO dmi.bios.version: 7UET86WW (3.16 ) dmi.board.name: 2764CTO dmi.board.vendor: LENOVO dmi.board.version: Not Available dmi.chassis.asset.tag: No Asset Information dmi.chassis.type: 10 dmi.chassis.vendor: LENOVO dmi.chassis.version: Not Available dmi.modalias: dmi:bvnLENOVO:bvr7UET86WW(3.16):bd04/19/2010:svnLENOVO:pn2764CTO:pvrThinkPadT400:rvnLENOVO:rn2764CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable: dmi.product.name: 2764CTO dmi.product.version: ThinkPad T400 dmi.sys.vendor: LENOVO
[Qemu-devel] [PATCH] Don't exit with zero in the trap handler
When configure runs "exit 1", the trap handler is run to cleanup any files created by configure, but this trap handler itself calls "exit" with no argument (which means zero exit code): [...] + echo Error: zlib check failed Error: zlib check failed + echo Make sure to have the zlib libs and headers installed. Make sure to have the zlib libs and headers installed. + echo + exit 1 + rm -f /tmp/qemu-conf--2779-.c /tmp/qemu-conf--2779-.o /tmp/qemu-conf--2779-.exe + exit To fix this, remove the call to exit from the trap handler, leaving it to the shell shell to exitafter the trap handler is run (honoring any previously provided exit code). --- configure |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 3bfc5e9..e0147d1 100755 --- a/configure +++ b/configure @@ -15,7 +15,7 @@ TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe" -trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM +trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM compile_object() { $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null -- 1.7.1
Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler
On Sat, Sep 25, 2010, Markus Armbruster wrote: > This suggests the old code screws up the exit code. It doesn't for me. > Unless it does at least on some platforms, it's a cleanup, not a fix, > and the commit message should reflect that. It does screw up the exit code for me; it seems it's because dash is used as /bin/sh. If I call this shell snippet: trap "echo trap; exit" 0 1 2 3 9 11 13 15 exit 2 with dash, e.g. "dash foo.sh; echo $?", I get 0, and with bash I get 2. I'm not sure what POSIX says, but given that calling exit in a trap handler isn't needed here, I recommend including this as a bug fix. -- Loïc Minier
Re: [Qemu-devel] [PATCH] Don't exit with zero in the trap handler
On Sat, Sep 25, 2010, Blue Swirl wrote: > It looks like dash and ksh are not compliant and use the return value > of echo or rm inside trap handler: > dash -c 'trap "sh -c \"exit 4\"; exit" 0 1 2 3 9 11 13 15;exit 3'; echo $? > 4 I've filed https://bugs.launchpad.net/dash/+bug/647450 to track this and forwarded the bug to d...@vger.kernel.org. > ksh -c 'trap "sh -c \"exit 4\"; exit" 0 1 2 3 9 11 13 15;exit 3'; echo $? > 4 On my system, ksh is provided by zsh and zsh gets this right. In the mean time, could you please pull the patch in QEMU? Without "exit" in the trap handler, the correct exit code will be returned. Thanks, -- Loïc Minier
[Qemu-devel] [PATCH] Avoid exit in trap as it breaks with some shells
Don't call exit in the trap handler as it causes the return code to be zero with some buggy shells (dash and pdksh at least) and is useless here anyway. --- configure |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 3bfc5e9..9d3acfc 100755 --- a/configure +++ b/configure @@ -15,7 +15,9 @@ TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" TMPO="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.o" TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe" -trap "rm -f $TMPC $TMPO $TMPE ; exit" EXIT INT QUIT TERM +# NB: do not call "exit" in the trap handler; this is buggy with some shells; +# see <1285349658-3122-1-git-send-email-loic.min...@linaro.org> +trap "rm -f $TMPC $TMPO $TMPE" EXIT INT QUIT TERM compile_object() { $cc $QEMU_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null -- 1.7.1
[Qemu-devel] [Bug 584121] Re: migration always fails on 32bit qemu-kvm-0.12+ (sigsegv)
Hi You're filing bugs against the QEMU project, which is used to track upstream issues (issues in the tarballs released by the QEMU project, or in their git tree). I think you intended to file these against the Ubuntu package of qemu, "qemu-kvm". AFAIK, QEMU doesn't have any upstream bug tracker, they just discuss issues on the mailing-list. Could you please file future bugs using "ubuntu-bug qemu-kvm"? Thanks, -- migration always fails on 32bit qemu-kvm-0.12+ (sigsegv) https://bugs.launchpad.net/bugs/584121 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Bug description: On a 32bit host (or when running 32bit userspace on 64bit host), migration always fails with a crash of qemu-kvm process. See http://marc.info/?l=kvm&m=127351472231666 for more information.
[Qemu-devel] [Bug 584143] Re: qemu fails to set hdd serial number
Patch still applies on top of qemu-kvm.git and qemu.git ** Bug watch added: Debian Bug tracker #573439 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573439 ** Also affects: qemu-kvm (Debian) via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573439 Importance: Unknown Status: Unknown ** Also affects: qemu-kvm (Ubuntu) Importance: Undecided Status: New -- qemu fails to set hdd serial number https://bugs.launchpad.net/bugs/584143 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu-kvm” package in Ubuntu: New Status in “qemu-kvm” package in Debian: Unknown Bug description: The -drive ...,serial=xyz option is broken, at least in 0.12. See Debian bug#573439, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=573439 for details. The proposed fix from the original reporter: --- qemu-kvm-0.12.3+dfsg/vl.c 2010-02-26 11:34:00.0 +0900 +++ qemu-kvm-0.12.3+dfsg.old/vl.c 2010-03-11 02:26:00.134217787 +0900 @@ -2397,7 +2397,7 @@ dinfo->on_write_error = on_write_error; dinfo->opts = opts; if (serial) -strncpy(dinfo->serial, serial, sizeof(serial)); +strncpy(dinfo->serial, serial, sizeof(dinfo->serial)); QTAILQ_INSERT_TAIL(&drives, dinfo, next); if (is_extboot) { extboot_drive = dinfo;
[Qemu-devel] [Bug 584153] Re: no useful error message when tap device open fails
** Bug watch added: Debian Bug tracker #578154 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578154 ** Also affects: qemu-kvm (Debian) via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578154 Importance: Unknown Status: Unknown -- no useful error message when tap device open fails https://bugs.launchpad.net/bugs/584153 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu-kvm” package in Debian: Unknown Bug description: When using tap network devices and it fails, qemu gives no information about what the problem is (permission denied, device busy or other), making debugging of such situations, especially for newbies, very difficult. The proposed patch just adds strerror() around the place, making it more friendly. See also Debian bug#578154, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578154 and a discussion on qemu-devel at http://marc.info/?t=12719287523 .
[Qemu-devel] [Bug 584139] Re: keymapping error for usb keyboard (windows/menu keys)
** Bug watch added: Debian Bug tracker #578846 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578846 ** Also affects: qemu-kvm (Debian) via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578846 Importance: Unknown Status: Unknown -- keymapping error for usb keyboard (windows/menu keys) https://bugs.launchpad.net/bugs/584139 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu-kvm” package in Debian: Unknown Bug description: The windows and menu keys for usb keyboard in qemu are wrong. They're correct for "ps/2" keyboard emulation however. See Debian bug#578846: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=578846. Here's the proposed fix: --- a/hw/usb-hid.c +++ b/hw/usb-hid.c @@ -399,3 +399,3 @@ 0x51, 0x4e, 0x49, 0x4c, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0xe3, 0xe7, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[Qemu-devel] [Bug 584146] Re: Virtual fat breaks with -snapshot
** Bug watch added: Debian Bug tracker #504049 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504049 ** Also affects: qemu-kvm (Debian) via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504049 Importance: Unknown Status: Unknown -- Virtual fat breaks with -snapshot https://bugs.launchpad.net/bugs/584146 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu-kvm” package in Debian: Unknown Bug description: When using fat emulation together with snapshot, qemu fails to find the directory for the fat "filesystem". See Debian bug#504049, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504049 and discussion on qemu-devel with Kevin Wolf, http://marc.info/?t=12685080281 for details. There's a workaround for this bug: when using full path for fat:/dir/name it works.
[Qemu-devel] [Bug 584155] Re: support horisontal mouse wheel
** Bug watch added: Debian Bug tracker #579968 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579968 ** Also affects: qemu-kvm (Debian) via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579968 Importance: Unknown Status: Unknown -- support horisontal mouse wheel https://bugs.launchpad.net/bugs/584155 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in “qemu-kvm” package in Debian: Unknown Bug description: Brad Jorsch provided a series of patches to support horisontal mouse scrolling in qemu-emulated mouse. See Debian bug#579968 -- http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579968 and submission to qemu-devel list at http://www.mail-archive.com/qemu-devel@nongnu.org/msg30991.html .
[Qemu-devel] [Bug 584121] Re: migration always fails on 32bit qemu-kvm-0.12+ (sigsegv)
Sorry, I failed to realize that qemu-kvm uses the qemu project in launchpad to track bugs; so this is the right place to file these. Thanks! -- migration always fails on 32bit qemu-kvm-0.12+ (sigsegv) https://bugs.launchpad.net/bugs/584121 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Bug description: On a 32bit host (or when running 32bit userspace on 64bit host), migration always fails with a crash of qemu-kvm process. See http://marc.info/?l=kvm&m=127351472231666 for more information.
[Qemu-devel] [Bug 584131] Re: some guests hangs after migration (qemu-kvm-0.12)
** Bug watch added: Debian Bug tracker #580649 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580649 ** Also affects: debian via http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580649 Importance: Unknown Status: Unknown -- some guests hangs after migration (qemu-kvm-0.12) https://bugs.launchpad.net/bugs/584131 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Status in Debian GNU/Linux: Unknown Bug description: There's a quite good bugreport in Debian BTS about this, #580649: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=580649 This is not the same as lp#341682, since it's now 0.12. Full initial message from #580649: From: Apollon Oikonomopoulos To: Debian Bug Tracking System Subject: qemu-kvm: Guests hang after live migration Date: Fri, 07 May 2010 16:29:10 +0300 Package: qemu-kvm Version: 0.12.3+dfsg-4 Severity: important Hi, qemu-kvm 0.12.3 causes guests to hang after a live migration. The crash seems to be related to the guest's virtio subsystem, as per the following backtrace obtained _in the guest_: May 7 14:17:32 kot kernel: [ 285.035681] irq 11: nobody cared (try booting with the "irqpoll" option) May 7 14:17:32 kot kernel: [ 285.035681] Pid: 0, comm: swapper Not tainted 2.6.26-2-amd64 #1 May 7 14:17:32 kot kernel: [ 285.035681] May 7 14:17:32 kot kernel: [ 285.035681] Call Trace: May 7 14:17:32 kot kernel: [ 285.035681][] :virtio_pci:vp_interrupt+0x27/0xb8 May 7 14:17:32 kot kernel: [ 285.035681] [] __report_bad_irq+0x30/0x72 May 7 14:17:32 kot kernel: [ 285.035681] [] note_interrupt+0x1fd/0x23b May 7 14:17:32 kot kernel: [ 285.035681] [] handle_fasteoi_irq+0xa5/0xc8 May 7 14:17:32 kot kernel: [ 285.035681] [] do_IRQ+0x6d/0xd9 May 7 14:17:32 kot kernel: [ 285.035681] [] default_idle+0x0/0x49 May 7 14:17:32 kot kernel: [ 285.035681] [] ret_from_intr+0x0/0x19 May 7 14:17:32 kot kernel: [ 285.035681][] lapic_next_event+0x0/0x13 May 7 14:17:32 kot kernel: [ 285.035681] [] native_safe_halt+0x2/0x3 May 7 14:17:32 kot kernel: [ 285.035681] [] native_safe_halt+0x2/0x3 May 7 14:17:32 kot kernel: [ 285.035681] [] default_idle+0x2a/0x49 May 7 14:17:32 kot kernel: [ 285.035681] [] cpu_idle+0x8e/0xb8 May 7 14:17:32 kot kernel: [ 285.035681] May 7 14:17:32 kot kernel: [ 285.035681] handlers: May 7 14:17:32 kot kernel: [ 285.035681] [] (usb_hcd_irq+0x0/0x78) May 7 14:17:32 kot kernel: [ 285.035681] [] (vp_interrupt+0x0/0xb8 [virtio_pci]) May 7 14:17:32 kot kernel: [ 285.035681] Disabling IRQ #11 This happens in a reproducible fashion on a guest with the following setup: * Virtio net + block devices * 8 CPU SMP * 521 MB RAM * Debian Lenny with 2.6.26-2-amd64 Just migrating the guest a couple of times with a bit of I/O activity will cause it to freeze completely. It does *not* seem to impact the following: * Guests with no virtio devices * Guests running 2.6.32-4-amd64 * Guests running under qemu-kvm-0.11.1 Thus, it seems to be virtio-specific and possibly related to the guest kernel, but since qemu-kvm-0.11.1 works fine, I'm filing it as a qemu-kvm regression and not a kernel bug. Thank you
[Qemu-devel] [Bug 604872] Re: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm
** Changed in: qemu-linaro (Ubuntu) Status: Fix Released => Triaged -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/604872 Title: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm Status in QEMU: Fix Committed Status in “qemu-linaro” package in Ubuntu: Triaged Bug description: Binary package hint: qemu-kvm As I'm now implementing the support for creating a rootstock rootfs without requiring root, I need to run the deboostrap' second stage inside a VM, to correctly install the packages into the rootfs. qemu-system-arm fails right after debootstrap finish the second stage, giving a segmentation fault. Command: qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel vmlinuz -no-reboot -nographic -drive file=qemu-armel-201007122016.img,aio=native,cache=none -m 256 -append 'console=ttyAMA0,115200n8 root=/dev/sda rw mem=256M devtmpfs.mount=0 init=/bin/installer' Uncompressing Linux. done, booting the kernel. [0.00] Initializing cgroup subsys cpuset [0.00] Initializing cgroup subsys cpu [0.00] Linux version 2.6.32-21-versatile (buildd@cushaw) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #32-Ubuntu Fri Apr 16 08:14:53 UTC 2010 (Ubuntu 2.6.32-21.32-versatile 2.6.32.11+drm33.2) ... I: Base system installed successfully. I: Starting basic services in VM Segmentation fault (core dumped) [492816.197352] qemu-system-arm[16024]: segfault at cf6ba8fc ip cf6ba8fc sp 7fffd0e68680 error 14 Image: * rootfs: http://rsalveti.net/pub/ubuntu/rootstock/qemu-armel-201007122016.img (md5 1d063ac8a65c798bb004cd1c4c7970c5) * kernel: http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz I'm able to reproduce the bug on Maverick (amd64) and Lucid (x86). Maverick qemu-kvm-extras: 0.12.4+noroms-0ubuntu4 Lucid qemu-kvm-extras: 0.12.3+noroms-0ubuntu9.2 ProblemType: Bug DistroRelease: Ubuntu 10.10 Package: qemu-kvm-extras 0.12.4+noroms-0ubuntu4 ProcVersionSignature: Ubuntu 2.6.35-6.9-generic 2.6.35-rc3 Uname: Linux 2.6.35-6-generic x86_64 Architecture: amd64 Date: Mon Jul 12 18:55:35 2010 InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1) KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UIDPID PPID CSZ RSS PSR STIME TTY TIME CMD MachineType: LENOVO 2764CTO PccardctlIdent: Socket 0: no product info available PccardctlStatus: Socket 0: no card ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.35-6-generic root=/dev/mapper/primary-root ro crashkernel=384M-2G:64M,2G-:128M quiet splash ProcEnviron: LANG=en_US.utf8 SHELL=/bin/bash SourcePackage: qemu-kvm dmi.bios.date: 04/19/2010 dmi.bios.vendor: LENOVO dmi.bios.version: 7UET86WW (3.16 ) dmi.board.name: 2764CTO dmi.board.vendor: LENOVO dmi.board.version: Not Available dmi.chassis.asset.tag: No Asset Information dmi.chassis.type: 10 dmi.chassis.vendor: LENOVO dmi.chassis.version: Not Available dmi.modalias: dmi:bvnLENOVO:bvr7UET86WW(3.16):bd04/19/2010:svnLENOVO:pn2764CTO:pvrThinkPadT400:rvnLENOVO:rn2764CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable: dmi.product.name: 2764CTO dmi.product.version: ThinkPad T400 dmi.sys.vendor: LENOVO
[Qemu-devel] [Bug 604872] Re: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm
Hmm Ubuntu has 2011.02, but I think you had asked me to flip this bug back to Triaged; I'm confused now, is this fixed in Ubuntu? I didn't find http://patchwork.ozlabs.org/patch/77888/ applied in qemu- linaro 0.13.50-2011.02-0-0ubuntu1 which is based of 2011.02. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/604872 Title: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm Status in QEMU: Fix Committed Status in “qemu-linaro” package in Ubuntu: Triaged Bug description: Binary package hint: qemu-kvm As I'm now implementing the support for creating a rootstock rootfs without requiring root, I need to run the deboostrap' second stage inside a VM, to correctly install the packages into the rootfs. qemu-system-arm fails right after debootstrap finish the second stage, giving a segmentation fault. Command: qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel vmlinuz -no-reboot -nographic -drive file=qemu-armel-201007122016.img,aio=native,cache=none -m 256 -append 'console=ttyAMA0,115200n8 root=/dev/sda rw mem=256M devtmpfs.mount=0 init=/bin/installer' Uncompressing Linux. done, booting the kernel. [0.00] Initializing cgroup subsys cpuset [0.00] Initializing cgroup subsys cpu [0.00] Linux version 2.6.32-21-versatile (buildd@cushaw) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #32-Ubuntu Fri Apr 16 08:14:53 UTC 2010 (Ubuntu 2.6.32-21.32-versatile 2.6.32.11+drm33.2) ... I: Base system installed successfully. I: Starting basic services in VM Segmentation fault (core dumped) [492816.197352] qemu-system-arm[16024]: segfault at cf6ba8fc ip cf6ba8fc sp 7fffd0e68680 error 14 Image: * rootfs: http://rsalveti.net/pub/ubuntu/rootstock/qemu-armel-201007122016.img (md5 1d063ac8a65c798bb004cd1c4c7970c5) * kernel: http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz I'm able to reproduce the bug on Maverick (amd64) and Lucid (x86). Maverick qemu-kvm-extras: 0.12.4+noroms-0ubuntu4 Lucid qemu-kvm-extras: 0.12.3+noroms-0ubuntu9.2 ProblemType: Bug DistroRelease: Ubuntu 10.10 Package: qemu-kvm-extras 0.12.4+noroms-0ubuntu4 ProcVersionSignature: Ubuntu 2.6.35-6.9-generic 2.6.35-rc3 Uname: Linux 2.6.35-6-generic x86_64 Architecture: amd64 Date: Mon Jul 12 18:55:35 2010 InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1) KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UIDPID PPID CSZ RSS PSR STIME TTY TIME CMD MachineType: LENOVO 2764CTO PccardctlIdent: Socket 0: no product info available PccardctlStatus: Socket 0: no card ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.35-6-generic root=/dev/mapper/primary-root ro crashkernel=384M-2G:64M,2G-:128M quiet splash ProcEnviron: LANG=en_US.utf8 SHELL=/bin/bash SourcePackage: qemu-kvm dmi.bios.date: 04/19/2010 dmi.bios.vendor: LENOVO dmi.bios.version: 7UET86WW (3.16 ) dmi.board.name: 2764CTO dmi.board.vendor: LENOVO dmi.board.version: Not Available dmi.chassis.asset.tag: No Asset Information dmi.chassis.type: 10 dmi.chassis.vendor: LENOVO dmi.chassis.version: Not Available dmi.modalias: dmi:bvnLENOVO:bvr7UET86WW(3.16):bd04/19/2010:svnLENOVO:pn2764CTO:pvrThinkPadT400:rvnLENOVO:rn2764CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable: dmi.product.name: 2764CTO dmi.product.version: ThinkPad T400 dmi.sys.vendor: LENOVO
[Qemu-devel] [Bug 604872] Re: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm
Ok; the commit you point at is in the current qemu-linaro package Fix released in Ubuntu is when we upload a fixed source package to the Ubuntu development release The usual way to close Ubuntu bugs fixed with an upload is via the debian/changelog, when Launchpad processes the .changes file with the list of fixed bugs, it marks these fix released If we need to track status in stable releases of Ubuntu, we use "Target to series" to flag the ones where we need a different bug state ** Changed in: qemu-linaro (Ubuntu) Status: Triaged => Fix Released -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/604872 Title: qemu-system-arm segfaults emulating versatile machine after running debootstrap --second-stage inside vm Status in QEMU: Fix Committed Status in “qemu-linaro” package in Ubuntu: Fix Released Bug description: Binary package hint: qemu-kvm As I'm now implementing the support for creating a rootstock rootfs without requiring root, I need to run the deboostrap' second stage inside a VM, to correctly install the packages into the rootfs. qemu-system-arm fails right after debootstrap finish the second stage, giving a segmentation fault. Command: qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel vmlinuz -no-reboot -nographic -drive file=qemu-armel-201007122016.img,aio=native,cache=none -m 256 -append 'console=ttyAMA0,115200n8 root=/dev/sda rw mem=256M devtmpfs.mount=0 init=/bin/installer' Uncompressing Linux. done, booting the kernel. [0.00] Initializing cgroup subsys cpuset [0.00] Initializing cgroup subsys cpu [0.00] Linux version 2.6.32-21-versatile (buildd@cushaw) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #32-Ubuntu Fri Apr 16 08:14:53 UTC 2010 (Ubuntu 2.6.32-21.32-versatile 2.6.32.11+drm33.2) ... I: Base system installed successfully. I: Starting basic services in VM Segmentation fault (core dumped) [492816.197352] qemu-system-arm[16024]: segfault at cf6ba8fc ip cf6ba8fc sp 7fffd0e68680 error 14 Image: * rootfs: http://rsalveti.net/pub/ubuntu/rootstock/qemu-armel-201007122016.img (md5 1d063ac8a65c798bb004cd1c4c7970c5) * kernel: http://ports.ubuntu.com/ubuntu-ports/dists/lucid/main/installer-armel/current/images/versatile/netboot/vmlinuz I'm able to reproduce the bug on Maverick (amd64) and Lucid (x86). Maverick qemu-kvm-extras: 0.12.4+noroms-0ubuntu4 Lucid qemu-kvm-extras: 0.12.3+noroms-0ubuntu9.2 ProblemType: Bug DistroRelease: Ubuntu 10.10 Package: qemu-kvm-extras 0.12.4+noroms-0ubuntu4 ProcVersionSignature: Ubuntu 2.6.35-6.9-generic 2.6.35-rc3 Uname: Linux 2.6.35-6-generic x86_64 Architecture: amd64 Date: Mon Jul 12 18:55:35 2010 InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100427.1) KvmCmdLine: Error: command ['ps', '-C', 'kvm', '-F'] failed with exit code 1: UIDPID PPID CSZ RSS PSR STIME TTY TIME CMD MachineType: LENOVO 2764CTO PccardctlIdent: Socket 0: no product info available PccardctlStatus: Socket 0: no card ProcCmdLine: BOOT_IMAGE=/vmlinuz-2.6.35-6-generic root=/dev/mapper/primary-root ro crashkernel=384M-2G:64M,2G-:128M quiet splash ProcEnviron: LANG=en_US.utf8 SHELL=/bin/bash SourcePackage: qemu-kvm dmi.bios.date: 04/19/2010 dmi.bios.vendor: LENOVO dmi.bios.version: 7UET86WW (3.16 ) dmi.board.name: 2764CTO dmi.board.vendor: LENOVO dmi.board.version: Not Available dmi.chassis.asset.tag: No Asset Information dmi.chassis.type: 10 dmi.chassis.vendor: LENOVO dmi.chassis.version: Not Available dmi.modalias: dmi:bvnLENOVO:bvr7UET86WW(3.16):bd04/19/2010:svnLENOVO:pn2764CTO:pvrThinkPadT400:rvnLENOVO:rn2764CTO:rvrNotAvailable:cvnLENOVO:ct10:cvrNotAvailable: dmi.product.name: 2764CTO dmi.product.version: ThinkPad T400 dmi.sys.vendor: LENOVO
[Qemu-devel] [PATCH] Ignore writes of perf reg (cp15 with crm == 12)
On ARMv7, ignore writes to cp15 with crm == 12; these are to setup perf counters which we don't have. --- target-arm/helper.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 2dd64d9..865829f 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1457,6 +1457,8 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val) } break; case 9: +if (arm_feature(env, ARM_FEATURE_V7) && crm == 12) +break; /* Perf counters. */ if (arm_feature(env, ARM_FEATURE_OMAPCP)) break; switch (crm) { -- 1.7.1
Re: [Qemu-devel] [PATCH] Ignore writes of perf reg (cp15 with crm == 12)
I found out Matt Waddel has written a better looking patch, but I didn't test it; reviews welcome -- attached -- Loïc Minier --- Begin Message --- diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 7440163..b5d8a6c 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -130,6 +130,7 @@ typedef struct CPUARMState { uint32_t c6_data; uint32_t c9_insn; /* Cache lockdown registers. */ uint32_t c9_data; +uint32_t c9_pmcr_data; /* Performance Monitor Control Register */ uint32_t c12_vbar; /* secure/nonsecure vector base address register. */ uint32_t c12_mvbar; /* monitor vector base address register. */ uint32_t c13_fcse; /* FCSE PID. */ diff --git a/target-arm/helper.c b/target-arm/helper.c index 1f5f307..2136c07 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -1558,6 +1558,15 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, uint32_t val) case 1: /* TCM memory region registers. */ /* Not implemented. */ goto bad_reg; +case 12: +switch (op2) { +case 0: +env->cp15.c9_pmcr_data = val; +break; +default: +goto bad_reg; +} +break; default: goto bad_reg; } @@ -1897,6 +1906,13 @@ uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn) goto bad_reg; /* L2 Lockdown and Auxiliary control. */ return 0; +case 12: +switch (op2) { +case 0: +return env->cp15.c9_pmcr_data; +default: +goto bad_reg; +} default: goto bad_reg; } diff --git a/target-arm/machine.c b/target-arm/machine.c index 8595549..026776d 100644 --- a/target-arm/machine.c +++ b/target-arm/machine.c @@ -46,6 +46,7 @@ void cpu_save(QEMUFile *f, void *opaque) qemu_put_be32(f, env->cp15.c6_data); qemu_put_be32(f, env->cp15.c9_insn); qemu_put_be32(f, env->cp15.c9_data); +qemu_put_be32(f, env->cp15.c9_pmcr_data); qemu_put_be32(f, env->cp15.c13_fcse); qemu_put_be32(f, env->cp15.c13_context); qemu_put_be32(f, env->cp15.c13_tls1); @@ -156,6 +157,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) env->cp15.c6_data = qemu_get_be32(f); env->cp15.c9_insn = qemu_get_be32(f); env->cp15.c9_data = qemu_get_be32(f); +env->cp15.c9_pmcr_data = qemu_get_be32(f); env->cp15.c13_fcse = qemu_get_be32(f); env->cp15.c13_context = qemu_get_be32(f); env->cp15.c13_tls1 = qemu_get_be32(f); --- End Message ---
Re: [Qemu-devel] qemu cp15 access
On Mon, Jul 26, 2010, Raymes Khoury wrote: > I am having the problem with qemu, as described in the post > http://old.nabble.com/-PATCH:-PR-target-42671--Use-Thumb1-GOT-address-loading-sequence-for--%09Thumb2-td27124497.html > where > accessing cp15 on ARM causes an error: See mid 1280086076-20649-1-git-send-email-loic.min...@linaro.org and thread http://article.gmane.org/gmane.comp.emulators.qemu/77092 -- Loïc Minier
[Qemu-devel] [PATCH] fat_chksum(): fix access above array bounds
Signed-off-by: Loïc Minier --- block/vvfat.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 6d61c2e..365332a 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -512,7 +512,7 @@ static inline uint8_t fat_chksum(const direntry_t* entry) for(i=0;i<11;i++) { unsigned char c; -c = (i <= 8) ? entry->name[i] : entry->extension[i-8]; +c = (i < 8) ? entry->name[i] : entry->extension[i-8]; chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0)) + c; } -- 1.7.1
Re: [Qemu-devel] [PATCH 1/1] Added PMCR support
We've been using a cp15 fix for a while to fix modern ARM kernels (with perf support) from booting. e.g. both the Ubuntu versatile and OMAP kernels fail to boot without this fix (the latter only boots with the OMAP patches too of course). Thanks! On Tue, Aug 03, 2010, Matt Waddel wrote: > From: Matt Waddel > > Added support for the CP15c9-CR12 register(Performance Monitor Control > Register). Calls to this register are being implemented in the ARM Linux > kernel. The register has several bit fields, as described in the ARM > technical reference manual, but right now I only implemented it as a > single register. > > Signed-off-by: Matt Waddel > --- > target-arm/cpu.h |3 ++- > target-arm/helper.c | 20 > target-arm/machine.c |2 ++ > 3 files changed, 24 insertions(+), 1 deletions(-) > > diff --git a/target-arm/cpu.h b/target-arm/cpu.h > index 39c4a0e..a96c512 100644 > --- a/target-arm/cpu.h > +++ b/target-arm/cpu.h > @@ -126,6 +126,7 @@ typedef struct CPUARMState { > uint32_t c6_data; > uint32_t c9_insn; /* Cache lockdown registers. */ > uint32_t c9_data; > +uint32_t c9_pmcr; /* Performance Monitor Control Register */ > uint32_t c13_fcse; /* FCSE PID. */ > uint32_t c13_context; /* Context ID. */ > uint32_t c13_tls1; /* User RW Thread register. */ > @@ -414,7 +415,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum, > #define cpu_signal_handler cpu_arm_signal_handler > #define cpu_list arm_cpu_list > > -#define CPU_SAVE_VERSION 2 > +#define CPU_SAVE_VERSION 3 > > /* MMU modes definitions */ > #define MMU_MODE0_SUFFIX _kernel > diff --git a/target-arm/helper.c b/target-arm/helper.c > index 2dd64d9..2272e8c 100644 > --- a/target-arm/helper.c > +++ b/target-arm/helper.c > @@ -1484,6 +1484,16 @@ void HELPER(set_cp15)(CPUState *env, uint32_t insn, > uint32_t val) > case 1: /* TCM memory region registers. */ > /* Not implemented. */ > goto bad_reg; > +case 12: /* PM control register */ > +switch (op2) { > +case 0: > +/* c9_pmcr register has several bit-fields */ > +env->cp15.c9_pmcr = val; > +break; > +default: > + goto bad_reg; > +} > +break; > default: > goto bad_reg; > } > @@ -1774,6 +1784,16 @@ uint32_t HELPER(get_cp15)(CPUState *env, uint32_t insn) > goto bad_reg; > /* L2 Lockdown and Auxiliary control. */ > return 0; > +case 12: /* PM control register */ > +switch (op2) { > +case 0: > +/* c9_pmcr register has several bit-fields */ > +return env->cp15.c9_pmcr; > +break; > +default: > + goto bad_reg; > +} > +break; > default: > goto bad_reg; > } > diff --git a/target-arm/machine.c b/target-arm/machine.c > index 3925d3a..efe9a02 100644 > --- a/target-arm/machine.c > +++ b/target-arm/machine.c > @@ -43,6 +43,7 @@ void cpu_save(QEMUFile *f, void *opaque) > qemu_put_be32(f, env->cp15.c6_data); > qemu_put_be32(f, env->cp15.c9_insn); > qemu_put_be32(f, env->cp15.c9_data); > +qemu_put_be32(f, env->cp15.c9_pmcr); > qemu_put_be32(f, env->cp15.c13_fcse); > qemu_put_be32(f, env->cp15.c13_context); > qemu_put_be32(f, env->cp15.c13_tls1); > @@ -150,6 +151,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id) > env->cp15.c6_data = qemu_get_be32(f); > env->cp15.c9_insn = qemu_get_be32(f); > env->cp15.c9_data = qemu_get_be32(f); > +env->cp15.c9_pmcr = qemu_get_be32(f); > env->cp15.c13_fcse = qemu_get_be32(f); > env->cp15.c13_context = qemu_get_be32(f); > env->cp15.c13_tls1 = qemu_get_be32(f); > -- > 1.7.0.4 > > -- Loïc Minier
Re: [Qemu-devel] [PATCH] fat_chksum(): fix access above array bounds
On Mon, Aug 23, 2010, Kevin Wolf wrote: > How did you find this one? From a quick look it seems that the pattern > that name is intentionally overflowed to access extension is still there > in some places. So if this caused some real bug, I think we'll have to > fix the other ones, too. Compiler found that one http://launchpadlibrarian.net/54142111/buildlog_ubuntu-maverick-armel.qemu-maemo_0.0~20100806%2Bd7a5eb1-0ubuntu1~linaro2_FAILEDTOBUILD.txt.gz but I didn't quote it because I'm at a loss as to why it detected it now and on armel only. I think I just got one accidental build on a modern gcc-4.4 tree because of the timing of my copy of the packages. I guess I should build them more regularly under a recent gcc. -- Loïc Minier
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 20, 2010, Måns Rullgård wrote: > If you make that IFS=${local_ifs:-$(printf ' \t\n')} it should be safe. > Likewise if you set the value first. Ok; see attached patches -- Loïc Minier >From cccdcaeacc2214390c0c6c198ed875ac59d10669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Jan 2010 11:05:00 +0100 Subject: [PATCH 1/2] Add and use has() and path_of() funcs Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 52 +++- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/configure b/configure index baa2800..eb02de3 100755 --- a/configure +++ b/configure @@ -27,6 +27,42 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +type "$1" >/dev/null 2>&1 +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_ifs="$IFS" +local_dir="" + +# pathname has a dir component? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_command" ]; then +return 1 +fi + +IFS=: +for local_dir in $PATH; do +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +IFS="${local_ifs:-$(printf ' \t\n')}" +return 0 +fi +done +# not found +IFS="${local_ifs:-$(printf ' \t\n')}" +return 1 +} + # default parameters cpu="" prefix="" @@ -763,7 +799,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -776,7 +812,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -969,7 +1005,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -977,7 +1013,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -993,7 +1029,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1424,8 +1460,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1694,8 +1729,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if has texi2html && has pod2man; then docs=yes else if test "$docs" = "yes" ; then -- 1.6.5 >From 430b06dcc84e82987d0146ef92dddbe838d6a117
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Thu, Jan 21, 2010, Måns Rullgård wrote: > I think that entire test is wrong, in fact. It is perfectly possible > for someone on Solaris to install a working "install" command in > /usr/bin. It is better, if possible, to test whatever "install" > command is in the path, and complain only if it actually fails. As I said, I prefer not changing this without access to a Solaris platform; would you mind committing the patch as is, and requesting whoever is interested in the Solaris specific code in qemu to fix the remainder? The patch is a net improvement over what's in ./configure. Thanks -- Loïc Minier
[Qemu-devel] [PATCH 1/3] Check for sdl-config before calling it
Check whether sdl-config is available before calling it, otherwise ./configure triggers a warning: ./configure: 957: sdl-config: not found If neither the .pc file not sdl-config are present, disable SDL support. Signed-off-by: Loïc Minier --- configure |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 1f6de41..27ab724 100755 --- a/configure +++ b/configure @@ -997,9 +997,14 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -else +elif which sdl-config >/dev/null 2>&1; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` +else + if test "$sdl" = "yes" ; then +feature_not_found "sdl" + fi + sdl=no fi sdl_too_old=no -- 1.6.5
[Qemu-devel] [PATCH 2/3] Add and use has() and path_of() funcs
Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 52 +++- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/configure b/configure index 27ab724..6bdd2b7 100755 --- a/configure +++ b/configure @@ -27,6 +27,42 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +type "$1" >/dev/null 2>&1 +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_ifs="$IFS" +local_dir="" + +# pathname has a dir component? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_command" ]; then +return 1 +fi + +IFS=: +for local_dir in $PATH; do +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +IFS="${local_ifs:-$(printf ' \t\n')}" +return 0 +fi +done +# not found +IFS="${local_ifs:-$(printf ' \t\n')}" +return 1 +} + # default parameters cpu="" prefix="" @@ -767,7 +803,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -780,7 +816,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -973,7 +1009,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -981,7 +1017,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -997,7 +1033,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1428,8 +1464,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1698,8 +1733,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if has texi2html && has pod2man; then docs=yes else if test "$docs" = "yes" ; then -- 1.6.5
[Qemu-devel] [PATCH 3/3] Solaris: test for presence of commands with has()
--- configure |8 +++- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 6bdd2b7..1d0915a 100755 --- a/configure +++ b/configure @@ -803,21 +803,19 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`path_of $install` - if test -z "$solinst" ; then + if ! has $install; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" echo "to get ginstall which is used by default (which lives in /opt/csw/bin)" exit 1 fi - if test "$solinst" = "/usr/sbin/install" ; then + if "`path_of $install`" = "/usr/sbin/install" ; then echo "Error: Solaris /usr/sbin/install is not an appropriate install program." echo "try ginstall from the GNU fileutils available from www.blastwave.org" echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`path_of ar` - if test -z "$sol_ar" ; then + if ! has ar; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then echo "Add /usr/ccs/bin to your path and rerun configure" -- 1.6.5
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Tue, Jan 26, 2010, Blue Swirl wrote: > The patches didn't apply. Also please send only one patch per message, > git am can't handle multiple patches. They applied fine here, perhaps you didn't apply the sdl-config patch first? I rebased them and resent them. -- Loïc Minier
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 27, 2010, Blue Swirl wrote: > That must've been it. But I get this on Milax: I didn't know about MilaX; I had a hard time getting gcc/binutils (or event git) to work along with working headers or base libs such as zlib.h or unistd.h. Do you have any instructions on how to get these working? > config-host.mak is out-of-date, running configure > /bin/ginstall: cannot stat `=': No such file or directory Ok; this was a typo in the Solaris patch (note that I was reluctant to touch the Solaris code in the first place); I could reproduce and also noticed that /bin/sh on MilaX doesn't support "if ! foo", so I replaced these with "if foo; then :; else ...; fi" constructs. Please find an attached third patch. -- Loïc Minier >From 6fef73a3b890ec736cdfa1ff817230c8e6d760e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Wed, 20 Jan 2010 12:35:54 +0100 Subject: [PATCH 2/2] Solaris: test for presence of commands with has() --- configure | 12 +++- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 6bdd2b7..42ef628 100755 --- a/configure +++ b/configure @@ -803,21 +803,23 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`path_of $install` - if test -z "$solinst" ; then + if has $install; then +: + else echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" echo "to get ginstall which is used by default (which lives in /opt/csw/bin)" exit 1 fi - if test "$solinst" = "/usr/sbin/install" ; then + if test "`path_of $install`" = "/usr/sbin/install" ; then echo "Error: Solaris /usr/sbin/install is not an appropriate install program." echo "try ginstall from the GNU fileutils available from www.blastwave.org" echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`path_of ar` - if test -z "$sol_ar" ; then + if has ar; then +: + else echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then echo "Add /usr/ccs/bin to your path and rerun configure" -- 1.6.5
[Qemu-devel] [PATCH] Fix missing symbols in .rel/.rela.plt sections
Fix .rel.plt sections in the output to not only include .rel.plt sections from the input but also the .rel.iplt sections and to define the hidden symbols __rel_iplt_start and __rel_iplt_end around .rel.iplt as otherwise we get undefined references to these when linking statically to a multilib libc.a. This fixes the static build under i386. Apply similar logic to rela.plt/.iplt and __rela_iplt/_plt_start/_end to fix the static build under amd64. Signed-off-by: Loïc Minier --- i386.ld | 16 ++-- x86_64.ld | 16 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/i386.ld b/i386.ld index f2dafec..f8df7bf 100644 --- a/i386.ld +++ b/i386.ld @@ -39,8 +39,20 @@ SECTIONS .rela.fini : { *(.rela.fini) } .rel.bss : { *(.rel.bss) } .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rel.plt : + { +*(.rel.plt) +PROVIDE_HIDDEN (__rel_iplt_start = .); +*(.rel.iplt) +PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { *(.init) } =0x47ff041f .text : { diff --git a/x86_64.ld b/x86_64.ld index 24ea77d..46d8d4d 100644 --- a/x86_64.ld +++ b/x86_64.ld @@ -35,8 +35,20 @@ SECTIONS .rela.got : { *(.rela.got) } .rel.bss: { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } - .rel.plt: { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rel.plt : + { +*(.rel.plt) +PROVIDE_HIDDEN (__rel_iplt_start = .); +*(.rel.iplt) +PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { KEEP (*(.init)) -- 1.6.5
[Qemu-devel] [PATCH] Add -static earlier to LDFLAGS for compile_prog()
Add -static to LDFLAGS earlier as to run the compile_prog() tests with this flags, this will avoid turning on features for which a shared library is available but not a static one. Signed-off-by: Loïc Minier --- configure |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 42ef628..ab6bd8e 100755 --- a/configure +++ b/configure @@ -488,7 +488,9 @@ for opt do ;; --enable-gprof) gprof="yes" ;; - --static) static="yes" + --static) +static="yes" +LDFLAGS="-static $LDFLAGS" ;; --sysconfdir) sysconfdir="$optarg" ;; @@ -2025,7 +2027,6 @@ if test "$solaris" = "yes" ; then fi if test "$static" = "yes" ; then echo "CONFIG_STATIC=y" >> $config_host_mak - LDFLAGS="-static $LDFLAGS" fi if test $profiler = "yes" ; then echo "CONFIG_PROFILER=y" >> $config_host_mak -- 1.6.5
Re: [Qemu-devel] [PATCH] fix the static compilation for sdl
On Mon, Feb 08, 2010, TeLeMan wrote: > The static compilation for sdl is broken after > 79427693174a553d62f3da44aacd3f19ba8df3a7. > > Signed-off-by: TeLeMan > --- > configure |7 +-- > 1 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/configure b/configure > index 4c95c27..213dddf 100644 > --- a/configure > +++ b/configure > @@ -1063,7 +1063,11 @@ if test "$sdl" != "no" ; then > int main( void ) { return SDL_Init (SDL_INIT_VIDEO); } > EOF >sdl_cflags=`$sdlconfig --cflags 2> /dev/null` > - sdl_libs=`$sdlconfig --libs 2> /dev/null` > + if test "$static" = "yes" ; then > +sdl_libs=`sdl-config --static-libs 2>/dev/null` > + else > +sdl_libs=`$sdlconfig --libs 2> /dev/null` > + fi >if compile_prog "$sdl_cflags" "$sdl_libs" ; then > if test "$_sdlversion" -lt 121 ; then >sdl_too_old=yes > @@ -1075,7 +1079,6 @@ EOF > > # static link with sdl ? (note: sdl.pc's --static --libs is broken) > if test "$sdl" = "yes" -a "$static" = "yes" ; then > - sdl_libs=`sdl-config --static-libs 2>/dev/null` >if test $? = 0 && echo $sdl_libs | grep -- -laa > /dev/null; then > sdl_libs="$sdl_libs `aalib-config --static-libs >2 /dev/null`" > sdl_cflags="$sdl_cflags `aalib-config --cflags >2 /dev/null`" Signed-off-by: Loïc Minier Ah right, the tests were being run on a shared libsdl no matter actual linking would happen against the static or shared libsdl; thanks for fixing the ordering. -- Loïc Minier
[Qemu-devel] [PATCH 1/2] Detect and use GCC atomic builtins for locking
--- configure | 17 + qemu-lock.h | 13 + 2 files changed, 30 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 0a84b0e..b33f045 100755 --- a/configure +++ b/configure @@ -1823,6 +1823,20 @@ if compile_prog "" ""; then fi ## +# check if we have gcc atomic built-ins +gcc_atomic_builtins=no +cat > $TMPC << EOF +int main(void) { +int i; +__sync_lock_test_and_set(&i, 1); +__sync_lock_release(&i); +} +EOF +if compile_prog "" ""; then +gcc_atomic_builtins=yes +fi + +## # check if we have fdatasync fdatasync=no @@ -2168,6 +2182,9 @@ fi if test "$gcc_attribute_warn_unused_result" = "yes" ; then echo "CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT=y" >> $config_host_mak fi +if test "$gcc_atomic_builtins" = "yes" ; then + echo "CONFIG_GCC_ATOMIC_BUILTINS=y" >> $config_host_mak +fi if test "$fdatasync" = "yes" ; then echo "CONFIG_FDATASYNC=y" >> $config_host_mak fi diff --git a/qemu-lock.h b/qemu-lock.h index 9a3e6ac..5c8eb34 100644 --- a/qemu-lock.h +++ b/qemu-lock.h @@ -33,6 +33,14 @@ #else +#ifdef CONFIG_GCC_ATOMIC_BUILTINS +typedef int spinlock_t; + +#define SPIN_LOCK_UNLOCKED 0 + +#define resetlock(p) __sync_lock_release((p)) +#else /* CONFIG_GCC_ATOMIC_BUILTINS */ + #if defined(__hppa__) typedef int spinlock_t[4]; @@ -56,7 +64,11 @@ static inline void resetlock (spinlock_t *p) } #endif +#endif /* !CONFIG_GCC_ATOMIC_BUILTINS */ +#ifdef CONFIG_GCC_ATOMIC_BUILTINS +#define testandset(p) __sync_lock_test_and_set((p), 1) +#else /* CONFIG_GCC_ATOMIC_BUILTINS */ #if defined(_ARCH_PPC) static inline int testandset (int *p) { @@ -213,6 +225,7 @@ static inline int testandset (int *p) #else #error unimplemented CPU support #endif +#endif /* !CONFIG_GCC_ATOMIC_BUILTINS */ #if defined(CONFIG_USER_ONLY) static inline void spin_lock(spinlock_t *lock) -- 1.7.0
[Qemu-devel] [PATCH 2/2] Make spinlock_t types volatile
--- qemu-lock.h |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu-lock.h b/qemu-lock.h index 5c8eb34..23e3442 100644 --- a/qemu-lock.h +++ b/qemu-lock.h @@ -34,7 +34,7 @@ #else #ifdef CONFIG_GCC_ATOMIC_BUILTINS -typedef int spinlock_t; +typedef volatile int spinlock_t; #define SPIN_LOCK_UNLOCKED 0 @@ -43,7 +43,7 @@ typedef int spinlock_t; #if defined(__hppa__) -typedef int spinlock_t[4]; +typedef volatile int spinlock_t[4]; #define SPIN_LOCK_UNLOCKED { 1, 1, 1, 1 } @@ -54,7 +54,7 @@ static inline void resetlock (spinlock_t *p) #else -typedef int spinlock_t; +typedef volatile int spinlock_t; #define SPIN_LOCK_UNLOCKED 0 -- 1.7.0
Re: [Qemu-devel] [PATCH 1/2] Detect and use GCC atomic builtins for locking
NB: Addition of these builtins was prompted by qemu failing to build on armel in Ubuntu; this is because we default to Thumb 2 mode which doesn't have the assembly instructions in question. http://launchpadlibrarian.net/38837077/buildlog_ubuntu-lucid-armel.qemu-kvm_0.12.2-0ubuntu6_FAILEDTOBUILD.txt.gz [...] CCarm-softmmu/syborg_virtio.o CCarm-softmmu/exec.o /tmp/cc24C9yx.s: Assembler messages: /tmp/cc24C9yx.s:5392: Error: selected processor does not support `swp r4,r4,[r3]' /tmp/cc24C9yx.s:6599: Error: selected processor does not support `swp r6,r6,[r3]' make[2]: *** [exec.o] Error 1 make[1]: *** [subdir-arm-softmmu] Error 2 [...] On Sat, Feb 20, 2010, malc wrote: > Please look up "gcc 4.1 implements compiler builtins for atomic ops" > thread for reasons why this might not be the best idea. I found a very old thred (2005) on libc-alpha with this subject; is this the one you mean? People participating in the libc-alpha were not really constructive and were presenting some bogus arguments; let me try to go over the various arguments (long): - some people wanted atomic builtins to be inline for performance and others wanted them to be library calls to allow changing their behavior later (e.g. to support a new CPU); the implementation actually uses both: inline assembly when supported on the architecture, or calls into libgcc which will call into the kernel otherwise (or direct calls into the kernel when building statically obviously), such as when the ISA doesn't offer sufficient primitives. Because *any* instruction might be gotten wrong in hardware, I don't see a need to special case locking inline assembly. - userspace apps abusing atomic builtins for locking; this is actually the case of qemu, but I think using gcc primitives will actually make it easier to get it right and will allow coverage of more architectures; in my opinion, there's no need to maintain hand-written assembly for locks in 2010. - someone claimed that modern architectures can do these operations in assembly without calling into a library; that's what the atomic builtins do, and actually some modern architectures can't do all operations in assembly. - there were arguments over where such functions belong and the semantics of each call; these are in my eyes purely political and don't relate to qemu. Which are your concerns with atomic builtins and are these in the above list? -- Loïc Minier
Re: [Qemu-devel] [PATCH 1/2] Detect and use GCC atomic builtins for locking
On Sat, Feb 20, 2010, malc wrote: > For instance this: > http://sources.redhat.com/ml/libc-alpha/2005-06/msg00112.html > > The builtins are too coarse grained and will do more stuff than strictly > necessary. Is this the case of the builtins I'm proposing to use? We could ask for new ones without the drawbacks if any. Do you have another option to implement locking on thumb-2? -- Loïc Minier
Re: [Qemu-devel] [PATCH 1/2] Detect and use GCC atomic builtins for locking
On Sat, Feb 20, 2010, malc wrote: > No, i'm against using locking GCC builtins for all the other targets (well > PPC) Do you have benchmarks with/without GCC atomic builtins? -- Loïc Minier
[Qemu-devel] [PATCH] linux-user: adapt uname machine to emulated CPU
Hey there This patch for linux-user adapts the output of the emulated uname() syscall to match the configured CPU. Tested with x86, x86-64 and arm emulation. Thanks, --- Makefile.target|2 +- linux-user/cpu-uname.c | 72 linux-user/cpu-uname.h |1 + linux-user/syscall.c |3 +- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 linux-user/cpu-uname.c create mode 100644 linux-user/cpu-uname.h diff --git a/Makefile.target b/Makefile.target index 7c1f30c..6414472 100644 --- a/Makefile.target +++ b/Makefile.target @@ -90,7 +90,7 @@ ifdef CONFIG_LINUX_USER VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ - elfload.o linuxload.o uaccess.o gdbstub.o + elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c new file mode 100644 index 000..ddc37be --- /dev/null +++ b/linux-user/cpu-uname.c @@ -0,0 +1,72 @@ +/* + * cpu to uname machine name map + * + * Copyright (c) 2009 Loïc Minier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include + +#include "qemu.h" +//#include "qemu-common.h" +#include "cpu-uname.h" + +/* return highest utsname machine name for emulated instruction set + * + * NB: the default emulated CPU ("any") might not match any existing CPU, e.g. + * on ARM it has all features turned on, so there is no perfect arch string to + * return here */ +const char *cpu_to_uname_machine(void *cpu_env) +{ +#ifdef TARGET_ARM +/* utsname machine name on linux arm is CPU arch name + endianness, e.g. + * armv7l; to get a list of CPU arch names from the linux source, use: + * grep arch_name: -A1 linux/arch/arm/mm/proc-*.S + * see arch/arm/kernel/setup.c: setup_processor() + * + * to test by CPU id, compare cpu_env->cp15.c0_cpuid to ARM_CPUID_* + * defines and to test by CPU feature, use arm_feature(cpu_env, + * ARM_FEATURE_*) */ + +/* in theory, endianness is configurable on some ARM CPUs, but this isn't + * used in user mode emulation */ +#ifdef TARGET_WORDS_BIGENDIAN +#define utsname_suffix "b" +#else +#define utsname_suffix "l" +#endif +if (arm_feature(cpu_env, ARM_FEATURE_V7)) +return "armv7" utsname_suffix; +if (arm_feature(cpu_env, ARM_FEATURE_V6)) +return "armv6" utsname_suffix; +/* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its + * Jazelle support */ +return "armv5te" utsname_suffix; +#elif defined(TARGET_X86_64) +return "x86-64"; +#elif defined(TARGET_I386) +/* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */ +uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version; +int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff); +if (family == 4) +return "i486"; +if (family == 5) +return "i586"; +return "i686"; +#else +/* default is #define-d in each arch/ subdir */ +return UNAME_MACHINE; +#endif +} diff --git a/linux-user/cpu-uname.h b/linux-user/cpu-uname.h new file mode 100644 index 000..32492de --- /dev/null +++ b/linux-user/cpu-uname.h @@ -0,0 +1 @@ +const char *cpu_to_uname_machine(void *cpu_env); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1acf1f5..9e2e89a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -82,6 +82,7 @@ #include #include #include "linux_loop.h" +#include "cpu-uname.h" #include "qemu.h" #include "qemu-common.h" @@ -5739,7 +5740,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!is_error(ret)) { /* Overrite the native machine name with whatever is being emulated. */ -strcpy (buf->machine, UNAME_MACHINE); +strcpy (buf->machine, cpu_to_uname_machine(cpu_env)); /* Allow the user to override the reported release. */ if (qemu_uname_release && *qemu_uname_release) strcpy (buf->release, qemu_uname_release); -- 1.6.5 -- Loïc Minier
Re: [Qemu-devel] [PATCH] linux-user: adapt uname machine to emulated CPU
On Thu, Jan 14, 2010, Aurelien Jarno wrote: > This patch look ok, but is missing a Signed-off-by: Attaching a rebased patch with a Signed-off-by. [ I didn't retest, but it applied without any merge issue and there was only two (arch-specific) commits in linux-user since the previous version. ] Thanks, -- Loïc Minier >From c4396cafac0041cfa2fed686f935e9df3636e05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 29 Dec 2009 22:06:13 +0100 Subject: [PATCH] linux-user: adapt uname machine to emulated CPU --- Makefile.target|2 +- linux-user/cpu-uname.c | 72 linux-user/cpu-uname.h |1 + linux-user/syscall.c |3 +- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 linux-user/cpu-uname.c create mode 100644 linux-user/cpu-uname.h diff --git a/Makefile.target b/Makefile.target index e661478..9f5bd17 100644 --- a/Makefile.target +++ b/Makefile.target @@ -95,7 +95,7 @@ $(call set-vpath, $(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) obj-y = main.o syscall.o strace.o mmap.o signal.o thunk.o \ - elfload.o linuxload.o uaccess.o gdbstub.o + elfload.o linuxload.o uaccess.o gdbstub.o cpu-uname.o obj-$(TARGET_HAS_BFLT) += flatload.o obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o diff --git a/linux-user/cpu-uname.c b/linux-user/cpu-uname.c new file mode 100644 index 000..ddc37be --- /dev/null +++ b/linux-user/cpu-uname.c @@ -0,0 +1,72 @@ +/* + * cpu to uname machine name map + * + * Copyright (c) 2009 Loïc Minier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include + +#include "qemu.h" +//#include "qemu-common.h" +#include "cpu-uname.h" + +/* return highest utsname machine name for emulated instruction set + * + * NB: the default emulated CPU ("any") might not match any existing CPU, e.g. + * on ARM it has all features turned on, so there is no perfect arch string to + * return here */ +const char *cpu_to_uname_machine(void *cpu_env) +{ +#ifdef TARGET_ARM +/* utsname machine name on linux arm is CPU arch name + endianness, e.g. + * armv7l; to get a list of CPU arch names from the linux source, use: + * grep arch_name: -A1 linux/arch/arm/mm/proc-*.S + * see arch/arm/kernel/setup.c: setup_processor() + * + * to test by CPU id, compare cpu_env->cp15.c0_cpuid to ARM_CPUID_* + * defines and to test by CPU feature, use arm_feature(cpu_env, + * ARM_FEATURE_*) */ + +/* in theory, endianness is configurable on some ARM CPUs, but this isn't + * used in user mode emulation */ +#ifdef TARGET_WORDS_BIGENDIAN +#define utsname_suffix "b" +#else +#define utsname_suffix "l" +#endif +if (arm_feature(cpu_env, ARM_FEATURE_V7)) +return "armv7" utsname_suffix; +if (arm_feature(cpu_env, ARM_FEATURE_V6)) +return "armv6" utsname_suffix; +/* earliest emulated CPU is ARMv5TE; qemu can emulate the 1026, but not its + * Jazelle support */ +return "armv5te" utsname_suffix; +#elif defined(TARGET_X86_64) +return "x86-64"; +#elif defined(TARGET_I386) +/* see arch/x86/kernel/cpu/bugs.c: check_bugs(), 386, 486, 586, 686 */ +uint32_t cpuid_version = ((CPUX86State *)cpu_env)->cpuid_version; +int family = ((cpuid_version >> 8) & 0x0f) + ((cpuid_version >> 20) & 0xff); +if (family == 4) +return "i486"; +if (family == 5) +return "i586"; +return "i686"; +#else +/* default is #define-d in each arch/ subdir */ +return UNAME_MACHINE; +#endif +} diff --git a/linux-user/cpu-uname.h b/linux-user/cpu-uname.h new file mode 100644 index 000..32492de --- /dev/null +++ b/linux-user/cpu-uname.h @@ -0,0 +1 @@ +const char *cpu_to_uname_machine(void *cpu_env); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f2dd39e..9fb493f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -82,6 +82,7 @@ #include #include #include "linux_loop.h" +#include "cpu-uname.h" #include "qemu.h" #include "qemu-common.h" @@ -5739,7 +5740,7 @@ abi_long
[Qemu-devel] [PATCH] Fix missing symbols in .rela.plt sections
Hi there, Static builds of qemu on x86-64 (and probably i386) fail with: gcc -I/home/lool/git/savannah/qemu/slirp -Werror -m64 -Wold-style-definition -Wold-style-declaration -I. -I/home/lool/git/savannah/qemu -U_FORTIFY_SOURCE -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -I/home/lool/git/savannah/qemu/fpu -I/home/lool/git/savannah/qemu/tcg -I/home/lool/git/savannah/qemu/tcg/x86_64 -I.. -I/home/lool/git/savannah/qemu/target-arm -DNEED_CPU_H -I/home/lool/git/savannah/qemu/linux-user -I/home/lool/git/savannah/qemu/linux-user/arm -O2 -g -static -Wl,--warn-common -m64 -g -Wl,-T../config-host.ld -Wl,-T,/home/lool/git/savannah/qemu/x86_64.ld -o qemu-arm main.o syscall.o strace.o mmap.o signal.o thunk.o elfload.o linuxload.o uaccess.o gdbstub.o flatload.o gdbstub-xml.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o -Wl,--whole-archive ../libuser/libuser.a libqemu.a -Wl,--no-whole-archive -lrt -lpthread -lm /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0xd4): undefined reference to `__rela_iplt_end' /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0xe5): undefined reference to `__rela_iplt_start' /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0x100): undefined reference to `__rela_iplt_start' /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0x10a): undefined reference to `__rela_iplt_start' /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0x10f): undefined reference to `__rela_iplt_start' /usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libc.a(elf-init.o): In function `__libc_csu_irel': (.text+0x114): undefined reference to `__rela_iplt_start' collect2: ld returned 1 exit status This is due to changes in binutils + glibc, qemu's linker script need to be adjusted to include these symbols. qemu's scripts weren't copying the .rela.iplt section at all, so I included this section and the __rela_iplt_start and __rela_iplt_end arount it. Tested by building qemu in static and shared mode for the arm-softmmu,i386-softmmu,x86_64-softmmu,arm-linux-user,i386-linux-user,x86_64-linux-user target-list; I also ran qemu for almost all combinations. Thanks, -- Loïc Minier >From ac0fe6dabaf05bf434e9c57d4f9b61d73f660e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 17 Jan 2010 12:09:38 +0100 Subject: [PATCH] Fix missing symbols in .rela.plt sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix .rela.plt sections in the output to not only include .rela.plt sections from the input but also the .rela.iplt sections and to define the hidden symbols __rela_iplt_start and __rela_iplt_end around .rela.iplt as otherwise we get undefined references to these when linking statically to a multilib libc.a. Signed-off-by: Loïc Minier --- i386.ld |8 +++- x86_64.ld |8 +++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/i386.ld b/i386.ld index f2dafec..bb245a7 100644 --- a/i386.ld +++ b/i386.ld @@ -40,7 +40,13 @@ SECTIONS .rel.bss : { *(.rel.bss) } .rela.bss : { *(.rela.bss) } .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { *(.init) } =0x47ff041f .text : { diff --git a/x86_64.ld b/x86_64.ld index 24ea77d..684d2d7 100644 --- a/x86_64.ld +++ b/x86_64.ld @@ -36,7 +36,13 @@ SECTIONS .rel.bss: { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } .rel.plt: { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { KEEP (*(.init)) -- 1.6.5
[Qemu-devel] [PATCH] Add -static earlier to LDFLAGS for compile_prog()
Hi When configure qemu with --static, it might autodetect support for some features by looking at available shared libraries instead of static libraries. e.g. if you have libbluetooth.so, bluez support will be turned on, but the build will fail at link stage. Setting LDFLAGS earlier to include -static will cause the compile_prog() tests to try to link against static libs. This did disable bluetooth support properly on my system where libbluetooth.a isn't available. Tested by building qemu configured with: ./configure --static --target-list=arm-softmmu,i386-softmmu,x86_64-softmmu,arm-linux-user,i386-linux-user,x86_64-linux-user and again without --static. Thanks, -- Loïc Minier >From 3df135de4babc35849578cde901ef9ffb04a2ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 17 Jan 2010 12:43:21 +0100 Subject: [PATCH] Add -static earlier to LDFLAGS for compile_prog() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add -static to LDFLAGS earlier as to run the compile_prog() tests with this flags, this will avoid turning on features for which a shared library is available but not a static one. Signed-off-by: Loïc Minier --- configure |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 5631bbb..e094111 100755 --- a/configure +++ b/configure @@ -451,7 +451,9 @@ for opt do ;; --enable-gprof) gprof="yes" ;; - --static) static="yes" + --static) +static="yes" +LDFLAGS="-static $LDFLAGS" ;; --disable-sdl) sdl="no" ;; @@ -1968,7 +1970,6 @@ if test "$solaris" = "yes" ; then fi if test "$static" = "yes" ; then echo "CONFIG_STATIC=y" >> $config_host_mak - LDFLAGS="-static $LDFLAGS" fi if test $profiler = "yes" ; then echo "CONFIG_PROFILER=y" >> $config_host_mak -- 1.6.5
[Qemu-devel] [PATCH] Check for sdl-config before calling it
Hi On systems were sdl-config isn't installed, ./configure triggers this warning: ./configure: 957: sdl-config: not found The attached patch fixes the warning for me. Thanks, -- Loïc Minier >From 94876939db7f46cf8d920e289d0d4f929d3b7df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 17 Jan 2010 13:42:04 +0100 Subject: [PATCH] Check for sdl-config before calling it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check whether sdl-config is available before calling it, otherwise ./configure triggers a warning: ./configure: 957: sdl-config: not found If neither the .pc file not sdl-config are present, disable SDL support. Signed-off-by: Loïc Minier --- configure |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 5631bbb..450e1a2 100755 --- a/configure +++ b/configure @@ -993,9 +993,11 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -else +elif which sdl-config >/dev/null 2>&1; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` +else + sdl=no fi sdl_too_old=no -- 1.6.5
Re: [Qemu-devel] [PATCH] Check for sdl-config before calling it
On Sun, Jan 17, 2010, Stefan Weil wrote: > > On systems were sdl-config isn't installed, ./configure triggers this > > warning: > > ./configure: 957: sdl-config: not found > > which version did you test? > Git master has no sdl-config call at configure:957. > > But I get warning messages, too, when pkg-config or > sdl-config are missing. Yes, the line is bogus for me as well; not sure why. I'm using master. > Your patch fixes the warning for sdl-config and sets > sdl=no. If configure was called with --enable-sdl, > this solution is wrong: configure should abort with > an error message (feature_not_found). Ack; how about the attached one instead? -- Loïc Minier >From eb4ba45b0d71d13cb89f6362443ffbe50b65eba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 17 Jan 2010 13:42:04 +0100 Subject: [PATCH] Check for sdl-config before calling it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check whether sdl-config is available before calling it, otherwise ./configure triggers a warning: ./configure: 957: sdl-config: not found If neither the .pc file not sdl-config are present, disable SDL support. Signed-off-by: Loïc Minier --- configure |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 5631bbb..baa2800 100755 --- a/configure +++ b/configure @@ -993,9 +993,14 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -else +elif which sdl-config >/dev/null 2>&1; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` +else + if test "$sdl" = "yes" ; then +feature_not_found "sdl" + fi + sdl=no fi sdl_too_old=no -- 1.6.5
[Qemu-devel] Stop using "which" in ./configure
Hi Following the thread on the sdl-config patch, please find attached a patch to add a couple of portable shell functions which allow testing whehter a command/builtin is available and to find the full pathname of an executable in the PATH. This also replaces all uses of "which" in ./configure. (This should be applied on top of the sdl-config patch.) Thanks, -- Loïc Minier >From 815ca36e9b3e2c56040d7fc7709c95d600ed6496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Jan 2010 11:05:00 +0100 Subject: [PATCH] Add and use has() and path_of() funcs Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 57 - 1 files changed, 48 insertions(+), 9 deletions(-) diff --git a/configure b/configure index baa2800..8d67b9c 100755 --- a/configure +++ b/configure @@ -27,6 +27,47 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +local_command="$1" +type "$local_command" >/dev/null +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_path="$PATH" +local_dir="" +# absolute path? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_path" ] || [ -z "$local_command" ]; then +return 1 +fi +while :; do +local_dir="${local_path%%:*}" +if [ "${local_path#*:}" = "$local_path" ]; then +# last loop +local_path="" +else +local_path="${local_path#*:}" +fi +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +return 0 +fi +if [ -z "$local_path" ]; then +# not found +return 1 +fi +done +} + # default parameters cpu="" prefix="" @@ -763,7 +804,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -776,7 +817,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -969,7 +1010,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -977,7 +1018,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -993,7 +1034,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1424,8 +1465,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1694,8 +1734,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if has texi2html && has pod2man; then docs=yes else if test "$docs" = "yes" ; then -- 1.6.5
Re: [Qemu-devel] Stop using "which" in ./configure
On Tue, Jan 19, 2010, Laurent Vivier wrote: > Why don't you use "type -P" for "path_of" ?" I don't think that's portable enough: $ sh -c 'type -P ls' -P: not found ls is /bin/ls -- Loïc Minier
Re: [Qemu-devel] Stop using "which" in ./configure
On Tue, Jan 19, 2010, Loïc Minier wrote: > Following the thread on the sdl-config patch, please find attached a > patch to add a couple of portable shell functions which allow testing > whehter a command/builtin is available and to find the full pathname of > an executable in the PATH. This also replaces all uses of "which" in > ./configure. (This should be applied on top of the sdl-config patch.) Please find attached a new version of the patch with a simpler version of path_of() which uses IFS instead of the ${foo#bar} and ${foo%%bar} constructs. It also removes the special casing of an empty PATH. -- Loïc Minier >From 5fc05ec61d87049ea0f29b2dd51c16e260698ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Jan 2010 11:05:00 +0100 Subject: [PATCH] Add and use has() and path_of() funcs Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 53 - 1 files changed, 44 insertions(+), 9 deletions(-) diff --git a/configure b/configure index baa2800..711e335 100755 --- a/configure +++ b/configure @@ -27,6 +27,43 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +local_command="$1" +type "$local_command" >/dev/null +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_ifs="$IFS" +local_dir="" + +# pathname has a dir component? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_command" ]; then +return 1 +fi + +IFS=: +for local_dir in $PATH; do +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +IFS="$local_ifs" +return 0 +fi +done +# not found +IFS="$local_ifs" +return 1 +} + # default parameters cpu="" prefix="" @@ -763,7 +800,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -776,7 +813,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -969,7 +1006,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -977,7 +1014,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -993,7 +1030,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1424,8 +1461,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1694,8 +1730,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if has texi2html && has pod2man; then docs=yes else if test "$docs" = "yes" ; then -- 1.6.5
Re: [Qemu-devel] [PATCH] Fix missing symbols in .rela.plt sections
On Sun, Jan 17, 2010, Loïc Minier wrote: > Static builds of qemu on x86-64 (and probably i386) fail After actually checking in an i386 Ubuntu lucid chroot, I found out that ld uses .rel.plt and .rel.iplt instead of .rela.plt and .rela.iplt. I've applied the same fixes to the two .ld scripts and could build static flavors of qemu-linux-user on both with the updated patch in attachment. Thanks, -- Loïc Minier >From a3582e37351596119e947b0606021aedb19b6f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Sun, 17 Jan 2010 12:09:38 +0100 Subject: [PATCH] Fix missing symbols in .rel/.rela.plt sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix .rel.plt sections in the output to not only include .rel.plt sections from the input but also the .rel.iplt sections and to define the hidden symbols __rel_iplt_start and __rel_iplt_end around .rel.iplt as otherwise we get undefined references to these when linking statically to a multilib libc.a. This fixes the static build under i386. Apply similar logic to rela.plt/.iplt and __rela_iplt/_plt_start/_end to fix the static build under amd64. Signed-off-by: Loïc Minier --- i386.ld | 16 ++-- x86_64.ld | 16 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/i386.ld b/i386.ld index f2dafec..f8df7bf 100644 --- a/i386.ld +++ b/i386.ld @@ -39,8 +39,20 @@ SECTIONS .rela.fini : { *(.rela.fini) } .rel.bss : { *(.rel.bss) } .rela.bss : { *(.rela.bss) } - .rel.plt : { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rel.plt : + { +*(.rel.plt) +PROVIDE_HIDDEN (__rel_iplt_start = .); +*(.rel.iplt) +PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { *(.init) } =0x47ff041f .text : { diff --git a/x86_64.ld b/x86_64.ld index 24ea77d..46d8d4d 100644 --- a/x86_64.ld +++ b/x86_64.ld @@ -35,8 +35,20 @@ SECTIONS .rela.got : { *(.rela.got) } .rel.bss: { *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) } .rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) } - .rel.plt: { *(.rel.plt) } - .rela.plt : { *(.rela.plt) } + .rel.plt : + { +*(.rel.plt) +PROVIDE_HIDDEN (__rel_iplt_start = .); +*(.rel.iplt) +PROVIDE_HIDDEN (__rel_iplt_end = .); + } + .rela.plt : + { +*(.rela.plt) +PROVIDE_HIDDEN (__rela_iplt_start = .); +*(.rela.iplt) +PROVIDE_HIDDEN (__rela_iplt_end = .); + } .init : { KEEP (*(.init)) -- 1.6.5
Re: [Qemu-devel] Stop using "which" in ./configure
On Tue, Jan 19, 2010, Stefan Weil wrote: > I did not test the whole patch, but I think this would be better: > +type "$local_command" >/dev/null 2>&1 Attaching an updated patch Thanks -- Loïc Minier >From 1c0b63fb9fc735a6d367a65a6ed1b998942fb6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Jan 2010 11:05:00 +0100 Subject: [PATCH] Add and use has() and path_of() funcs Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 53 - 1 files changed, 44 insertions(+), 9 deletions(-) diff --git a/configure b/configure index baa2800..db97a2c 100755 --- a/configure +++ b/configure @@ -27,6 +27,43 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +local_command="$1" +type "$local_command" >/dev/null 2>&1 +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_ifs="$IFS" +local_dir="" + +# pathname has a dir component? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_command" ]; then +return 1 +fi + +IFS=: +for local_dir in $PATH; do +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +IFS="$local_ifs" +return 0 +fi +done +# not found +IFS="$local_ifs" +return 1 +} + # default parameters cpu="" prefix="" @@ -763,7 +800,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -776,7 +813,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -969,7 +1006,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -977,7 +1014,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -993,7 +1030,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1424,8 +1461,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1694,8 +1730,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`" -a \ - -x "`which pod2man 2>/dev/null`" ; then + if has texi2html && has pod2man; then docs=yes else if test "$docs" = "yes" ; then -- 1.6.5
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Tue, Jan 19, 2010, Måns Rullgård wrote: [...] > Why the extra variable? Using $1 directly seems just as obvious to me. [...] I'm attaching an updated patch which doesn't use this variable. Should be applied after the sdl-config patch. > Is the full path of these tools really important? Doesn't look like > it to me. I'm attaching a new patch which changes the tests a bit; I would prefer if someone with access to a Solaris build environment would do this though. -- Loïc Minier >From 27f151ef7be19fcffbbf9c2d3c6ee50750be854d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Tue, 19 Jan 2010 11:05:00 +0100 Subject: [PATCH 1/2] Add and use has() and path_of() funcs Add has() and path_of() funcs and use them across configure; has() will test whether a command or builtin is available; path_of() will search the PATH for executables and return the full pathname if found. --- configure | 52 +++- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/configure b/configure index baa2800..90b3c18 100755 --- a/configure +++ b/configure @@ -27,6 +27,42 @@ compile_prog() { $cc $QEMU_CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags > /dev/null 2> /dev/null } +# check whether a command is available to this shell (may be either an +# executable or a builtin) +has() { +type "$1" >/dev/null 2>&1 +} + +# search for an executable in PATH +path_of() { +local_command="$1" +local_ifs="$IFS" +local_dir="" + +# pathname has a dir component? +if [ "${local_command#*/}" != "$local_command" ]; then +if [ -x "$local_command" ] && [ ! -d "$local_command" ]; then +echo "$local_command" +return 0 +fi +fi +if [ -z "$local_command" ]; then +return 1 +fi + +IFS=: +for local_dir in $PATH; do +if [ -x "$local_dir/$local_command" ] && [ ! -d "$local_dir/$local_command" ]; then +echo "$local_dir/$local_command" +IFS="$local_ifs" +return 0 +fi +done +# not found +IFS="$local_ifs" +return 1 +} + # default parameters cpu="" prefix="" @@ -763,7 +799,7 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`which $install 2> /dev/null | /usr/bin/grep -v "no $install in"` + solinst=`path_of $install` if test -z "$solinst" ; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" @@ -776,7 +812,7 @@ if test "$solaris" = "yes" ; then echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`which ar 2> /dev/null | /usr/bin/grep -v "no ar in"` + sol_ar=`path_of ar` if test -z "$sol_ar" ; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then @@ -969,7 +1005,7 @@ fi # pkgconfig probe pkgconfig="${cross_prefix}pkg-config" -if ! test -x "$(which $pkgconfig 2>/dev/null)"; then +if ! has $pkgconfig; then # likely not cross compiling, or hope for the best pkgconfig=pkg-config fi @@ -977,7 +1013,7 @@ fi ## # Sparse probe if test "$sparse" != "no" ; then - if test -x "$(which cgcc 2>/dev/null)"; then + if has cgcc; then sparse=yes else if test "$sparse" = "yes" ; then @@ -993,7 +1029,7 @@ fi if $pkgconfig sdl --modversion >/dev/null 2>&1; then sdlconfig="$pkgconfig sdl" _sdlversion=`$sdlconfig --modversion 2>/dev/null | sed 's/[^0-9]//g'` -elif which sdl-config >/dev/null 2>&1; then +elif has sdl-config; then sdlconfig='sdl-config' _sdlversion=`$sdlconfig --version | sed 's/[^0-9]//g'` else @@ -1424,8 +1460,7 @@ EOF fi else if test "$kvm" = "yes" ; then - if [ -x "`which awk 2>/dev/null`" ] && \ - [ -x "`which grep 2>/dev/null`" ]; then + if has awk && has grep; then kvmerr=`LANG=C $cc $QEMU_CFLAGS -o $TMPE $kvm_cflags $TMPC 2>&1 \ | grep "error: " \ | awk -F "error: " '{if (NR>1) printf(", "); printf("%s",$2);}'` @@ -1694,8 +1729,7 @@ fi # Check if tools are available to build documentation. if test "$docs" != "no" ; then - if test -x "`which texi2html 2>/dev/null`"
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 20, 2010, Paolo Bonzini wrote: > On 01/20/2010 12:37 PM, Loïc Minier wrote: > >+# not found > >+IFS="$local_ifs" > If you do this, you should set IFS to space-tab-lf at the beginning of > the script, like this: > > IFS=" "" "" > " Are you saying that I can't backup/restore IFS without setting it first? That would be odd; it works with bash, dash, and zsh here. Pointers to affected shell would help me avoid other issues with them. Alternatively, I could set IFS in a subshell. I checked the autoconf Portable Shell Programming section, but didn't find a similar recommendation: http://www.gnu.org/software/autoconf/manual/autoconf.html#index-IFS-1639 > or this (better because it does not rely on embedding whitespace > characters within the line): > IFS=`printf ' \t'`" > " If we go that route, perhaps IFS="`printf ' \t\n'`" would be more readable? I'm not sure how common printf is though. -- Loïc Minier
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 20, 2010, Juan Quintela wrote: > +prog_exist() { > +prog="$1" > +type $1 > /dev/null 2> /dev/null > +} You set prog but you use $1; also, it seems vars in functions should be prefixed with local_ in qemu's ./configure. I was told not to use a local var here though. > - if test "$solinst" = "/usr/sbin/install" ; then > + if type install2 2> /dev/null | grep /usr/bin/install >/dev/null ; then install2? > + if prog_exist "awk" -a \ > + prog_exist "grep"; then already pointed out, but -a is a feature of "test" and incorrect here; you want && > - if test -x "`which texi2html 2>/dev/null`" -a \ > - -x "`which pod2man 2>/dev/null`" ; then > + if prog_exist "texi2html" -a \ > + prog_exist "pod2man" ; then ditto Perhaps we should avoid work duplication though? -- Loïc Minier
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 20, 2010, Loïc Minier wrote: > I'm attaching a new patch which changes the tests a bit; I would prefer > if someone with access to a Solaris build environment would do this > though. Sorry, there was a typo in the new patch, a test was reversed; updated patch attached. -- Loïc Minier >From 8b17a25e0f16390a6afed3e030a11ad290f413d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Minier?= Date: Wed, 20 Jan 2010 12:35:54 +0100 Subject: [PATCH 2/2] Solaris: test for presence of commands with has() --- configure |8 +++- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 90b3c18..4d48341 100755 --- a/configure +++ b/configure @@ -799,21 +799,19 @@ fi # Solaris specific configure tool chain decisions # if test "$solaris" = "yes" ; then - solinst=`path_of $install` - if test -z "$solinst" ; then + if ! has $install; then echo "Solaris install program not found. Use --install=/usr/ucb/install or" echo "install fileutils from www.blastwave.org using pkg-get -i fileutils" echo "to get ginstall which is used by default (which lives in /opt/csw/bin)" exit 1 fi - if test "$solinst" = "/usr/sbin/install" ; then + if "`path_of $install`" = "/usr/sbin/install" ; then echo "Error: Solaris /usr/sbin/install is not an appropriate install program." echo "try ginstall from the GNU fileutils available from www.blastwave.org" echo "using pkg-get -i fileutils, or use --install=/usr/ucb/install" exit 1 fi - sol_ar=`path_of ar` - if test -z "$sol_ar" ; then + if ! has ar; then echo "Error: No path includes ar" if test -f /usr/ccs/bin/ar ; then echo "Add /usr/ccs/bin to your path and rerun configure" -- 1.6.5
Re: [Qemu-devel] Re: Stop using "which" in ./configure
On Wed, Jan 20, 2010, Paolo Bonzini wrote: > > Are you saying that I can't backup/restore IFS without setting it > > first? > Yes, it affects the behavior of read for example: > $ echo a b c | (read a b c; echo $a; echo $b; echo $c) > a > b > c > $ IFS= > $ echo a b c | (read a b c; echo $a; echo $b; echo $c) > a b c > > $ > (It's not used by QEMU's configure, but it's better to be defensive). I *do* understand that changing IFS will affect the program, but the patch I sent will backup IFS and then restore it; perhaps you missed the backup/restore bits: +local_ifs="$IFS" [...] +IFS=: [...] +IFS="$local_ifs" +return 0 [...] +IFS="$local_ifs" +return 1 Do you have an example of how that breaks if IFS isn't ever set in ./configure at all? -- Loïc Minier