Hello community, here is the log from the commit of package qemu.857 for openSUSE:12.2:Update checked in at 2012-09-14 13:31:36 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:12.2:Update/qemu.857 (Old) and /work/SRC/openSUSE:12.2:Update/.qemu.857.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "qemu.857", Maintainer is "" Changes: -------- New Changes file: --- /dev/null 2012-08-23 02:41:28.555381587 +0200 +++ /work/SRC/openSUSE:12.2:Update/.qemu.857.new/qemu.changes 2012-09-14 13:31:38.000000000 +0200 @@ -0,0 +1,1015 @@ +------------------------------------------------------------------- +Wed Sep 5 12:35:44 UTC 2012 - afaerber@suse.de + +- update to v1.1.1: see http://wiki.qemu.org/ChangeLog/1.1 +* adapt update_git.sh script, use qemu-stable-1.1.git for v1.1.1 +- add bounds checks for console VT100 emulation (bnc#777084, + CVE-2012-3515) + +------------------------------------------------------------------- +Wed Jul 11 21:16:34 UTC 2012 - agraf@suse.com + +- fix segfault even better + +------------------------------------------------------------------- +Wed Jul 11 14:52:02 UTC 2012 - agraf@suse.com + +- linux-user: improve locking even across tb flushes + +------------------------------------------------------------------- +Tue Jul 10 18:43:31 UTC 2012 - agraf@suse.com + +- linux-user: pin multi-threaded applications to a single host cpu + +------------------------------------------------------------------- +Tue Jul 10 16:42:54 UTC 2012 - agraf@suse.com + +- linux-user: improve lock + +------------------------------------------------------------------- +Thu Jul 5 15:37:05 UTC 2012 - agraf@suse.com + +- linux-user: add tcg lock for multi-threaded guest programs + +------------------------------------------------------------------- +Wed Jun 25 19:29:05 UTC 2012 - afaerber@suse.de + +- include qemu-img and qemu-nbd in qemu-tools package + +------------------------------------------------------------------- +Wed Jun 25 18:30:54 UTC 2012 - afaerber@suse.de + +- add qemu-guest-agent package + +------------------------------------------------------------------- +Mon Jun 25 17:40:36 UTC 2012 - agraf@suse.com + +- add fix for segv in linux-user (fixes java) + +------------------------------------------------------------------- +Tue Jun 19 16:06:52 UTC 2012 - afaerber@suse.de + +- revert LIBRARY_PATH patch by Alex + +------------------------------------------------------------------- +Mon Jun 18 12:27:56 UTC 2012 - afaerber@suse.de + +- add patch by Alex to force gcc being emulated for LIBRARY_PATH + +------------------------------------------------------------------- +Mon Jun 18 09:06:41 UTC 2012 - dvaleev@suse.com + +- add libfdt1 to buildrequires on ppc + +------------------------------------------------------------------- +Thu Jun 14 14:39:57 UTC 2012 - afaerber@suse.de + +- revert qemu-bridge-helper mode change (cf. BNC#765948) + +------------------------------------------------------------------- +Mon Jun 13 13:44:28 UTC 2012 - brogers@suse.com + +- don't use permissions.d + +------------------------------------------------------------------- +Wed Jun 13 08:19:01 UTC 2012 - agraf@suse.com + +- Add fix for bogus losetup ioctl to not warn us about it + +------------------------------------------------------------------- +Sat Jun 9 19:09:39 UTC 2012 - brogers@suse.com + +- Set up bridge helper as a setuid executable + +------------------------------------------------------------------- +Sat Jun 9 12:17:45 UTC 2012 - afaerber@suse.de + +- Add patch for specifying --libexecdir +* Fixes having to specify the path to qemu-bridge-helper manually +- Drop superfluous `make qemu-img` +- Move qemu-bridge-helper to its own subpackage, to share with KVM + +------------------------------------------------------------------- +Tue Jun 5 13:25:43 UTC 2012 - afaerber@suse.de + +- Update to v1.1.0: see http://wiki.qemu.org/ChangeLog/1.1 +* Adapt update_git.sh script to new tag + +------------------------------------------------------------------- +Fri Jun 1 13:22:09 UTC 2012 - afaerber@suse.de + +- Update to v1.1.0-rc4: see http://wiki.qemu.org/ChangeLog/1.1 +* Adapt update_git.sh script to new tag + +------------------------------------------------------------------- +Thu May 31 17:37:26 UTC 2012 - agraf@suse.com + +- fix /proc/self/maps faking with secondary threads + +------------------------------------------------------------------- +Wed May 30 20:19:05 CEST 2012 - agraf@suse.de + +- revert commit a84fac1426 to fix automoc4 for arm + +------------------------------------------------------------------- +Tue May 29 15:52:47 UTC 2012 - agraf@suse.com + +- remove manual interp prefix, which made all linux-user binaries + point to an i386 LD_PREFIX path + +------------------------------------------------------------------- +Tue May 29 15:34:55 UTC 2012 - agraf@suse.com + +- add patch to fix building of go (swi in thumb ignores imm) + +------------------------------------------------------------------- +Tue May 22 16:39:24 UTC 2012 - afaerber@suse.de + +- Update to v1.1.0-rc3; see http://wiki.qemu.org/ChangeLog/1.1 +* Adapt update_git.sh script to new tag + +------------------------------------------------------------------- +Thu May 17 17:40:19 UTC 2012 - afaerber@suse.de + +- Update to v1.1.0-rc2; see http://wiki.qemu.org/ChangeLog/1.1 +* Adapt update_git.sh script to new tag + +------------------------------------------------------------------- +Wed May 16 01:29:02 UTC 2012 - afaerber@suse.de + +- Remove workaround for forcing cURL detection + +------------------------------------------------------------------- +Sun May 13 15:39:12 UTC 2012 - afaerber@suse.de + +- Update to v1.1-rc1: see http://wiki.qemu.org/ChangeLog/1.1 +* Add workaround for 11.4: add -lrt after -lglib-2.0 +- Adapt update_git.sh script to new tag + +------------------------------------------------------------------- +Tue May 8 00:15:18 UTC 2012 - afaerber@suse.de + +- Update to v1.1-rc0; see http://wiki.qemu.org/ChangeLog/1.1 +* Do not try to mv qemu, the executable is gone, there's a dir now +* Do not try to mv */qemu-*, there's a pc-bios/qemu-icon.bmp +* Be more specific in temporary copying of files to dynamic/ +* Drop duplicate %_bindir/qemu_binfmt_misc.sh, only in sbin now +* Use dynamic version of new executable qemu-bridge-helper +- Update update_git.sh script to pull patches from suse-1.1 branch + +------------------------------------------------------------------- +Mon May 7 19:49:40 UTC 2012 - afaerber@suse.de + +- Update URL to project homepage + +------------------------------------------------------------------- +Mon May 7 10:01:52 UTC 2012 - agraf@suse.com + +- compile fixes for ppc64abi32 +- fix update_fit.sh script if wc -c is 40 +- fix stale tbs after mmap + +------------------------------------------------------------------- +Wed Mar 7 15:16:16 UTC 2012 - agraf@suse.com + +- cut off patch file names after 40 bytes, support older git versions + for update_git.sh + +------------------------------------------------------------------- +Mon Mar 5 01:31:42 UTC 2012 - agraf@suse.com + +- resolve VMAs downwards, fixes arm git build for real + +------------------------------------------------------------------- +Sat Mar 3 23:27:14 UTC 2012 - agraf@suse.com + +- update update_git.sh for 1.0.1 +- add fixes for reserved_va mmap(NULL) case, fixes git build on arm + +------------------------------------------------------------------- +Tue Feb 28 11:49:55 UTC 2012 - idonmez@suse.com + +- Enable spice support + +------------------------------------------------------------------- +Wed Feb 22 23:04:48 UTC 2012 - brogers@suse.com + +- update to latest stable release: 1.0.1. For changes see: ++++ 818 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:12.2:Update/.qemu.857.new/qemu.changes New: ---- 0001-Handle-CPU-interrupts-by-inline-che.patch 0002-XXX-dont-dump-core-on-sigabort.patc.patch 0003-XXX-work-around-SA_RESTART-race-wit.patch 0004-qemu-0.9.0.cvs-binfmt.patch.patch 0005-qemu-cvs-alsa_bitfield.patch.patch 0006-qemu-cvs-alsa_ioctl.patch.patch 0007-qemu-cvs-alsa_mmap.patch.patch 0008-qemu-cvs-gettimeofday.patch.patch 0009-qemu-cvs-ioctl_debug.patch.patch 0010-qemu-cvs-ioctl_nodirection.patch.patch 0011-qemu-img-vmdk-scsi.patch.patch 0012-configure-Enable-mipsn32-linux-user.patch 0013-linux-user-add-binfmt-wrapper-for-a.patch 0014-linux-user-Ignore-timer_create-sysc.patch 0015-linux-user-be-silent-about-capget-f.patch 0016-PPC-KVM-Disable-mmu-notifier-check..patch 0017-linux-user-fix-segfault-deadlock.pa.patch 0018-linux-user-binfmt-support-host-bina.patch 0019-linux-user-ARM-Ignore-immediate-val.patch 0020-linux-user-arm-no-tb_flush-on-reset.patch 0021-linux-user-fix-multi-threaded-proc-.patch 0022-use-libexecdir-instead-of-ignoring-.patch 0023-linux-user-Ignore-broken-loop-ioctl.patch 0024-linux-user-fix-segmentation-fault-p.patch 0025-linux-user-lock-tcg.patch.patch 0026-linux-user-Run-multi-threaded-code-.patch 0027-linux-user-lock-tb-flushing-too.pat.patch 0028-XXX-merge-with-segmentation-fault-p.patch 0029-linux-user-Fake-proc-cpuinfo.patch.patch 0030-Replace-struct-siginfo-with-siginfo.patch 0031-console-bounds-check-whenever-chang.patch bridge.conf qemu-1.1.1-1.tar.bz2 qemu.changes qemu.spec qemu.spec.in rpmlintrc update_git.sh ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qemu.spec ++++++ # # spec file for package qemu # # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: qemu Url: http://www.qemu.org/ Summary: Universal CPU emulator License: BSD-3-Clause ; GPL-2.0+ ; LGPL-2.1+ ; MIT Group: System/Emulators/PC Version: 1.1.1 Release: 0 Source: %name-%version-1.tar.bz2 Patch0001: 0001-Handle-CPU-interrupts-by-inline-che.patch Patch0002: 0002-XXX-dont-dump-core-on-sigabort.patc.patch Patch0003: 0003-XXX-work-around-SA_RESTART-race-wit.patch Patch0004: 0004-qemu-0.9.0.cvs-binfmt.patch.patch Patch0005: 0005-qemu-cvs-alsa_bitfield.patch.patch Patch0006: 0006-qemu-cvs-alsa_ioctl.patch.patch Patch0007: 0007-qemu-cvs-alsa_mmap.patch.patch Patch0008: 0008-qemu-cvs-gettimeofday.patch.patch Patch0009: 0009-qemu-cvs-ioctl_debug.patch.patch Patch0010: 0010-qemu-cvs-ioctl_nodirection.patch.patch Patch0011: 0011-qemu-img-vmdk-scsi.patch.patch Patch0012: 0012-configure-Enable-mipsn32-linux-user.patch Patch0013: 0013-linux-user-add-binfmt-wrapper-for-a.patch Patch0014: 0014-linux-user-Ignore-timer_create-sysc.patch Patch0015: 0015-linux-user-be-silent-about-capget-f.patch Patch0016: 0016-PPC-KVM-Disable-mmu-notifier-check..patch Patch0017: 0017-linux-user-fix-segfault-deadlock.pa.patch Patch0018: 0018-linux-user-binfmt-support-host-bina.patch Patch0019: 0019-linux-user-ARM-Ignore-immediate-val.patch Patch0020: 0020-linux-user-arm-no-tb_flush-on-reset.patch Patch0021: 0021-linux-user-fix-multi-threaded-proc-.patch Patch0022: 0022-use-libexecdir-instead-of-ignoring-.patch Patch0023: 0023-linux-user-Ignore-broken-loop-ioctl.patch Patch0024: 0024-linux-user-fix-segmentation-fault-p.patch Patch0025: 0025-linux-user-lock-tcg.patch.patch Patch0026: 0026-linux-user-Run-multi-threaded-code-.patch Patch0027: 0027-linux-user-lock-tb-flushing-too.pat.patch Patch0028: 0028-XXX-merge-with-segmentation-fault-p.patch Patch0029: 0029-linux-user-Fake-proc-cpuinfo.patch.patch Patch0030: 0030-Replace-struct-siginfo-with-siginfo.patch Patch0031: 0031-console-bounds-check-whenever-chang.patch # this is to make lint happy Source300: rpmlintrc Source302: bridge.conf Source400: update_git.sh BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: SDL-devel BuildRequires: bison BuildRequires: bluez-devel BuildRequires: curl-devel BuildRequires: cyrus-sasl-devel BuildRequires: e2fsprogs-devel BuildRequires: libaio BuildRequires: libaio-devel BuildRequires: libattr-devel BuildRequires: libgnutls-devel BuildRequires: libpcap-devel BuildRequires: ncurses-devel %if 0%{?suse_version} >= 1120 BuildRequires: zlib-devel-static %else BuildRequires: zlib-devel %endif %if 0%{?suse_version} >= 1210 BuildRequires: glibc-devel-static BuildRequires: libattr-devel-static BuildRequires: libfdt1-devel %endif %if 0%{?suse_version} >= 1140 BuildRequires: glib2-devel-static %endif %if 0%{?suse_version} >= 1220 BuildRequires: pcre-devel-static %endif %if 0%{?suse_version} >= 1130 %ifarch %ix86 x86_64 BuildRequires: libspice-server-devel BuildRequires: spice-protocol-devel %endif %endif %ifarch ppc ppc64 #we need that for -M pseries support in SLES BuildRequires: libfdt1-devel %endif BuildRequires: fdupes BuildRequires: glib2-devel BuildRequires: libvdeplug3-devel BuildRequires: pwdutils BuildRequires: python Requires: /usr/sbin/groupadd Requires: pwdutils Requires: timezone Recommends: qemu-tools %description QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. %package tools Summary: Universal CPU emulator -- Tools Group: System/Emulators/PC Provides: qemu:%_libexecdir/qemu-bridge-helper PreReq: permissions %description tools QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains various tools, including a bridge helper. %package guest-agent Summary: Universal CPU emulator -- Guest agent Group: System/Emulators/PC Provides: qemu:%_bindir/qemu-ga %description guest-agent QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains the guest agent. %package linux-user Summary: Universal CPU emulator -- Linux User binaries Group: System/Emulators/PC Provides: qemu:%_bindir/qemu-arm %description linux-user QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains statically linked binaries for running linux-user emulations. This can be used together with the OBS build script to run cross-architecture builds. %prep %setup -q %patch0001 -p1 %patch0002 -p1 %patch0003 -p1 %patch0004 -p1 %patch0005 -p1 %patch0006 -p1 %patch0007 -p1 %patch0008 -p1 %patch0009 -p1 %patch0010 -p1 %patch0011 -p1 %patch0012 -p1 %patch0013 -p1 %patch0014 -p1 %patch0015 -p1 %patch0016 -p1 %patch0017 -p1 %patch0018 -p1 %patch0019 -p1 %patch0020 -p1 %patch0021 -p1 %patch0022 -p1 %patch0023 -p1 %patch0024 -p1 %patch0025 -p1 %patch0026 -p1 %patch0027 -p1 %patch0028 -p1 %patch0029 -p1 %patch0030 -p1 %patch0031 -p1 %build # build QEMU mkdir -p dynamic # build qemu-system ./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \ --libexecdir=%_libexecdir \ --audio-card-list="ac97 es1370 sb16 cs4231a adlib gus" \ --audio-drv-list="alsa sdl" --enable-mixemu --enable-vde \ --enable-curl \ --extra-cflags="$QEMU_OPT_FLAGS" --enable-system --disable-linux-user \ %if 0%{?suse_version} >= 1130 %ifarch %ix86 x86_64 --enable-spice %else --disable-spice %endif %else --disable-spice %endif make %{?jobs:-j%jobs} V=1 mv *-softmmu/qemu-system-* dynamic mv qemu-io qemu-img qemu-nbd qemu-bridge-helper dynamic mv qemu-img.1 qemu-nbd.8 dynamic mv qemu-ga dynamic make clean # build userland emus ./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \ --libexecdir=%_libexecdir \ --enable-linux-user \ --disable-system \ --static --disable-linux-aio \ --extra-cflags="$QEMU_OPT_FLAGS" %if 0%{?suse_version} == 1140 # -lrt needs to come after -lglib-2.0 to avoid undefined clock_gettime sed -i "s/-lglib-2.0/-lglib-2.0 -lrt/" config-host.mak %endif make %{?jobs:-j%jobs} V=1 %install make install DESTDIR=$RPM_BUILD_ROOT rm -fr $RPM_BUILD_ROOT/%_datadir/doc install -m 755 dynamic/qemu-system-* $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-io $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-img $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-nbd $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-ga $RPM_BUILD_ROOT/%_bindir install -d -m 755 $RPM_BUILD_ROOT/%_sbindir install -m 755 scripts/qemu-binfmt-conf.sh $RPM_BUILD_ROOT/%_sbindir install -d -m 755 $RPM_BUILD_ROOT/%_libexecdir install -m 755 dynamic/qemu-bridge-helper $RPM_BUILD_ROOT/%_libexecdir install -d -m 755 $RPM_BUILD_ROOT/%_mandir/man1 install -m 644 dynamic/qemu-img.1 $RPM_BUILD_ROOT/%_mandir/man1 install -d -m 755 $RPM_BUILD_ROOT/%_mandir/man8 install -m 644 dynamic/qemu-nbd.8 $RPM_BUILD_ROOT/%_mandir/man8 install -D -m 644 %{SOURCE302} $RPM_BUILD_ROOT/%{_sysconfdir}/qemu/bridge.conf %ifnarch %ix86 x86_64 ln -sf ../../../emul/ia32-linux $RPM_BUILD_ROOT/usr/share/qemu/qemu-i386 %endif %ifnarch ia64 mkdir -p $RPM_BUILD_ROOT/emul/ia32-linux %endif %fdupes -s $RPM_BUILD_ROOT %clean rm -rf ${RPM_BUILD_ROOT} %pre %{_bindir}/getent group kvm >/dev/null || %{_sbindir}/groupadd -r kvm 2>/dev/null %{_bindir}/getent group qemu >/dev/null || %{_sbindir}/groupadd -r qemu 2>/dev/null %{_bindir}/getent passwd qemu >/dev/null || \ %{_sbindir}/useradd -r -g qemu -G kvm -d / -s /sbin/nologin \ -c "qemu user" qemu %if 0%{?suse_version} >= 1130 %post tools %set_permissions %_libexecdir/qemu-bridge-helper %verifyscript tools %verify_permissions %_libexecdir/qemu-bridge-helper %endif %files %defattr(-, root, root) %doc COPYING COPYING.LIB Changelog README TODO VERSION qemu-doc.html qemu-tech.html %_bindir/qemu-system-* %doc %_mandir/man1/qemu.1.gz %_datadir/%name %ifnarch %ix86 x86_64 ia64 %dir /emul/ia32-linux %endif %dir %_sysconfdir/%name %config %_sysconfdir/%name/target-x86_64.conf %files tools %defattr(-, root, root) %doc %_mandir/man1/qemu-img.1.gz %doc %_mandir/man8/qemu-nbd.8.gz %_bindir/qemu-io %_bindir/qemu-img %_bindir/qemu-nbd %verify(not mode) %_libexecdir/qemu-bridge-helper %dir %_sysconfdir/%name %config %_sysconfdir/%name/bridge.conf %files guest-agent %defattr(-, root, root) %attr(755,root,kvm) %_bindir/qemu-ga %files linux-user %defattr(-, root, root) %_bindir/qemu-alpha %_bindir/qemu-arm %_bindir/qemu-armeb %_bindir/qemu-cris %_bindir/qemu-i386 %_bindir/qemu-m68k %_bindir/qemu-microblaze %_bindir/qemu-microblazeel %_bindir/qemu-mips %_bindir/qemu-mipsel %_bindir/qemu-mipsn32 %_bindir/qemu-mipsn32el %_bindir/qemu-ppc64abi32 %_bindir/qemu-ppc64 %_bindir/qemu-ppc %_bindir/qemu-s390x %_bindir/qemu-sh4 %_bindir/qemu-sh4eb %_bindir/qemu-sparc32plus %_bindir/qemu-sparc64 %_bindir/qemu-sparc %_bindir/qemu-unicore32 %_bindir/qemu-x86_64 %_bindir/qemu-*-binfmt %_sbindir/qemu-binfmt-conf.sh %changelog ++++++ 0001-Handle-CPU-interrupts-by-inline-che.patch ++++++
From cdfaf128d360fb015e8befcf5f4c551c0011a776 Mon Sep 17 00:00:00 2001 From: Peter Maydell <peter.maydell@linaro.org> Date: Wed, 5 Oct 2011 10:04:02 +0100 Subject: [PATCH] Handle CPU interrupts by inline checking of a flag
Fix the nasty TCG race conditions and crashes by implementing cpu_exit as setting a flag which is checked at the start of each TB. This is slightly slower than the attempt to have cpu_exit alter the graph of TBs, but it doesn't crash if a thread or signal handler calls cpu_exit while the execution thread is itself modifying the TB graph. This version of the patch includes command line option "-no-stopflag" which reverts to the previous racy behaviour. This is intended for convenience in testing and comparative benchmarking and won't be in the final patch. It's probably worth experimenting with whether the flag-testing code has the branch in a sense which confuses branch-prediction and thus whether flipping it might change performance. Mostly this needs benchmarking to determine what the actual speed hit is, which I never got round to. Feel free to do some :-) [AF: CPUState -> CPUArchState] --- cpu-exec.c | 11 ++++++++++- exec.c | 14 ++++++++++++-- gen-icount.h | 16 ++++++++++++++++ linux-user/main.c | 8 ++++++++ qemu-options.hx | 9 +++++++++ vl.c | 5 +++++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 0344cd5..0547f2d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -563,7 +563,16 @@ int cpu_exec(CPUArchState *env) tc_ptr = tb->tc_ptr; /* execute the generated code */ next_tb = tcg_qemu_tb_exec(env, tc_ptr); - if ((next_tb & 3) == 2) { + if ((next_tb & 3) == 3) { + /* hit stopflag check */ + tb = (TranslationBlock *)(long)(next_tb & ~3); + /* Restore PC. */ + cpu_pc_from_tb(env, tb); + next_tb = 0; + env->exit_request = 0; + env->exception_index = EXCP_INTERRUPT; + cpu_loop_exit(env); + } else if ((next_tb & 3) == 2) { /* Instruction counter expired. */ int insns_left; tb = (TranslationBlock *)(next_tb & ~3); diff --git a/exec.c b/exec.c index 0a67f07..8eda655 100644 --- a/exec.c +++ b/exec.c @@ -130,6 +130,8 @@ DEFINE_TLS(CPUArchState *,cpu_single_env); 1 = Precise instruction counting. 2 = Adaptive rate instruction counting. */ int use_icount = 0; +/* 1 to do cpu_exit by inline flag check rather than tb link breaking */ +int use_stopflag = 1; typedef struct PageDesc { /* list of TBs intersecting this ram page */ @@ -1756,7 +1758,13 @@ static void tcg_handle_interrupt(CPUArchState *env, int mask) cpu_abort(env, "Raised interrupt while not in I/O function"); } } else { - cpu_unlink_tb(env); + // XXX just call cpu_exit ? + if (use_stopflag) { + // XXX is this OK? + env->exit_request = 1; + } else { + cpu_unlink_tb(env); + } } } @@ -1779,7 +1787,9 @@ void cpu_reset_interrupt(CPUArchState *env, int mask) void cpu_exit(CPUArchState *env) { env->exit_request = 1; - cpu_unlink_tb(env); + if (!use_stopflag) { + cpu_unlink_tb(env); + } } const CPULogItem cpu_log_items[] = { diff --git a/gen-icount.h b/gen-icount.h index 430cb44..65a75d9 100644 --- a/gen-icount.h +++ b/gen-icount.h @@ -2,13 +2,25 @@ /* Helpers for instruction counting code generation. */ +extern int use_stopflag; + static TCGArg *icount_arg; static int icount_label; +static int stopflag_label; static inline void gen_icount_start(void) { TCGv_i32 count; + if (use_stopflag) { + TCGv_i32 flag; + stopflag_label = gen_new_label(); + flag = tcg_temp_local_new_i32(); + tcg_gen_ld_i32(flag, cpu_env, offsetof(CPUArchState, exit_request)); + tcg_gen_brcondi_i32(TCG_COND_NE, flag, 0, stopflag_label); + tcg_temp_free_i32(flag); + } + if (!use_icount) return; @@ -26,6 +38,10 @@ static inline void gen_icount_start(void) static void gen_icount_end(TranslationBlock *tb, int num_insns) { + if (use_stopflag) { + gen_set_label(stopflag_label); + tcg_gen_exit_tb((long)tb + 3); // XXX + } if (use_icount) { *icount_arg = num_insns; gen_set_label(icount_label); diff --git a/linux-user/main.c b/linux-user/main.c index 191b750..dd340b2 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -64,6 +64,7 @@ unsigned long reserved_va; #endif static void usage(void); +extern int use_stopflag; static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release = CONFIG_UNAME_RELEASE; @@ -3107,6 +3108,11 @@ static void handle_arg_reserved_va(const char *arg) } #endif +static void handle_arg_nostopflag(const char *arg) +{ + use_stopflag = 0; +} + static void handle_arg_singlestep(const char *arg) { singlestep = 1; @@ -3162,6 +3168,8 @@ struct qemu_argument arg_table[] = { "options", "activate log"}, {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "override default logfile location"}, + {"no-stopflag", "QEMU_NOSTOPFLAG", false, handle_arg_nostopflag, + "", "run in singlestep mode"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, "pagesize", "set the host page size to 'pagesize'"}, {"singlestep", "QEMU_SINGLESTEP", false, handle_arg_singlestep, diff --git a/qemu-options.hx b/qemu-options.hx index 8b66264..6d66113 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1176,6 +1176,15 @@ STEXI Disable HPET support. ETEXI +DEF("no-stopflag", 0, QEMU_OPTION_no_stopflag, + "-no-stopflag use old behaviour, not inline stopflag checks\n", QEMU_ARCH_ALL) +STEXI +@item -no-stopflag +@findex -no-stopflag +Implement cpu-exit by the old tb link breaking method rather than inline checks +(this is slightly faster but racy!) +ETEXI + DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable, "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,{data|file}=file1[:file2]...]\n" " ACPI table description\n", QEMU_ARCH_I386) diff --git a/vl.c b/vl.c index 23ab3a3..a33c28e 100644 --- a/vl.c +++ b/vl.c @@ -175,6 +175,8 @@ int main(int argc, char **argv) #define MAX_VIRTIO_CONSOLES 1 +extern int use_stopflag; + static const char *data_dir; const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; @@ -2958,6 +2960,9 @@ int main(int argc, char **argv, char **envp) qdev_prop_register_global_list(slew_lost_ticks); break; } + case QEMU_OPTION_no_stopflag: + use_stopflag = 0; + break; case QEMU_OPTION_acpitable: do_acpitable_option(optarg); break; ++++++ 0002-XXX-dont-dump-core-on-sigabort.patc.patch ++++++
From 9b1a5a53364711caa0aece7986784c0741c9e53d Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Mon, 21 Nov 2011 23:50:36 +0100 Subject: [PATCH] XXX dont dump core on sigabort
--- linux-user/signal.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index b1e139d..0d6cb7b 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -373,6 +373,10 @@ static void QEMU_NORETURN force_sig(int target_sig) host_sig = target_to_host_signal(target_sig); gdb_signalled(thread_env, target_sig); + if (target_sig == 6) { + goto no_core; + } + /* dump core if supported by target binary format */ if (core_dump_signal(target_sig) && (ts->bprm->core_dump != NULL)) { stop_all_tasks(); @@ -390,6 +394,8 @@ static void QEMU_NORETURN force_sig(int target_sig) target_sig, strsignal(host_sig), "core dumped" ); } +no_core: + /* The proper exit code for dying from an uncaught signal is * -<signal>. The kernel doesn't allow exit() or _exit() to pass * a negative value. To get the proper exit code we need to ++++++ 0003-XXX-work-around-SA_RESTART-race-wit.patch ++++++
From 2713af72b18bbbc17b54a875db8d06b6e11d035f Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Thu, 1 Dec 2011 19:00:01 +0100 Subject: [PATCH] XXX work around SA_RESTART race with boehm-gc (ARM only)
[AF: CPUState -> CPUArchState, adapt to reindentation] --- linux-user/main.c | 25 +++++++++----- linux-user/qemu.h | 3 ++ linux-user/signal.c | 22 ++++++++++++ linux-user/syscall.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 130 insertions(+), 10 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index dd340b2..503ecfa 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -848,15 +848,22 @@ void cpu_loop(CPUARMState *env) break; } } else { - env->regs[0] = do_syscall(env, - n, - env->regs[0], - env->regs[1], - env->regs[2], - env->regs[3], - env->regs[4], - env->regs[5], - 0, 0); + TaskState *ts = ((CPUArchState*)env)->opaque; + target_ulong r; + r = do_syscall(env, n, env->regs[0], env->regs[1], + env->regs[2], env->regs[3], env->regs[4], + env->regs[5], 0, 0); + if ((r == -EINTR) && ts->signal_restart && + syscall_restartable(n)) { + if (env->thumb) { + env->regs[15] -= 2; + } else { + env->regs[15] -= 4; + } + } else { + env->regs[0] = r; + } + ts->signal_restart = 0; } } else { goto error; diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 7b299b7..dc12b23 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -137,6 +137,8 @@ typedef struct TaskState { struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */ struct sigqueue *first_free; /* first free siginfo queue entry */ int signal_pending; /* non zero if a signal may be pending */ + int signal_in_syscall; /* non zero if we are in do_syscall() */ + int signal_restart; /* non zero if we need to restart a syscall */ } __attribute__((aligned(16))) TaskState; extern char *exec_path; @@ -203,6 +205,7 @@ char *target_strerror(int err); int get_osversion(void); void fork_start(void); void fork_end(int child); +int syscall_restartable(int syscall_nr); /* Return true if the proposed guest_base is suitable for the guest. * The guest code may leave a page mapped and populate it if the diff --git a/linux-user/signal.c b/linux-user/signal.c index 0d6cb7b..c00cf75 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -25,6 +25,7 @@ #include <assert.h> #include <sys/ucontext.h> #include <sys/resource.h> +#include <sched.h> #include "qemu.h" #include "qemu-common.h" @@ -481,6 +482,11 @@ int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) k->pending = 1; /* signal that a new signal is pending */ ts->signal_pending = 1; + /* check if we have to restart the current syscall */ + if ((sigact_table[sig - 1].sa_flags & SA_RESTART) && + ts->signal_in_syscall) { + ts->signal_restart = 1; + } return 1; /* indicates that the signal was queued */ } } @@ -621,8 +627,24 @@ int do_sigaction(int sig, const struct target_sigaction *act, if (host_sig != SIGSEGV && host_sig != SIGBUS) { sigfillset(&act1.sa_mask); act1.sa_flags = SA_SIGINFO; +#ifdef TARGET_ARM + /* Breaks boehm-gc, we have to do this manually */ + /* + * Unfortunately our hacks only work as long as we don't do parallel + * signal delivery and futexes, so let's do a dirty hack here to + * pin our guest process to a single host CPU if we're using the + * boehm-gc. + */ + if ((k->sa_flags & TARGET_SA_RESTART) && host_sig == SIGPWR) { + cpu_set_t mask; + CPU_ZERO(&mask); + CPU_SET(0, &mask); + sched_setaffinity(0, sizeof(mask), &mask); + } +#else if (k->sa_flags & TARGET_SA_RESTART) act1.sa_flags |= SA_RESTART; +#endif /* NOTE: it is important to update the host kernel signal ignore state to avoid getting unexpected interrupted syscalls */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 20d2a74..2a210e7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5031,6 +5031,87 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) return get_errno(open(path(pathname), flags, mode)); } +int syscall_restartable(int syscall_nr) +{ + switch (syscall_nr) { +#ifdef TARGET_NR_sigsuspend + case TARGET_NR_sigsuspend: +#endif +#ifdef TARGET_NR_pause + case TARGET_NR_pause: +#endif +#ifdef TARGET_NR_setsockopt + case TARGET_NR_setsockopt: +#endif +#ifdef TARGET_NR_accept + case TARGET_NR_accept: +#endif +#ifdef TARGET_NR_recv + case TARGET_NR_recv: +#endif +#ifdef TARGET_NR_recvfrom + case TARGET_NR_recvfrom: +#endif +#ifdef TARGET_NR_recvmsg + case TARGET_NR_recvmsg: +#endif +#ifdef TARGET_NR_socketcall + case TARGET_NR_socketcall: +#endif +#ifdef TARGET_NR_connect + case TARGET_NR_connect: +#endif +#ifdef TARGET_NR_send + case TARGET_NR_send: +#endif +#ifdef TARGET_NR_sendmsg + case TARGET_NR_sendmsg: +#endif +#ifdef TARGET_NR_sendto + case TARGET_NR_sendto: +#endif +#ifdef TARGET_NR_poll + case TARGET_NR_poll: +#endif +#ifdef TARGET_NR_ppoll + case TARGET_NR_ppoll: +#endif +#if defined(TARGET_NR_select) + case TARGET_NR_select: +#endif +#ifdef TARGET_NR_pselect6 + case TARGET_NR_pselect6: +#endif +#ifdef TARGET_NR__newselect + case TARGET_NR__newselect: +#endif +#ifdef TARGET_NR_msgrcv + case TARGET_NR_msgrcv: +#endif +#ifdef TARGET_NR_msgsnd + case TARGET_NR_msgsnd: +#endif +#ifdef TARGET_NR_semop + case TARGET_NR_semop: +#endif +#ifdef TARGET_NR_ipc + case TARGET_NR_ipc: +#endif +#ifdef TARGET_NR_clock_nanosleep + case TARGET_NR_clock_nanosleep: +#endif + case TARGET_NR_rt_sigsuspend: + case TARGET_NR_rt_sigtimedwait: + case TARGET_NR_nanosleep: + case TARGET_NR_close: + /* can not be restarted */ + return 0; + } + + /* every other syscall can be restarted */ + return 1; +} + /* do_syscall() should always have a single exit point at the end so that actions, such as logging of syscall results, can be performed. All errnos that do_syscall() returns must be -TARGET_<errcode>. */ @@ -5043,6 +5124,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, struct stat st; struct statfs stfs; void *p; + TaskState *ts = ((CPUArchState*)cpu_env)->opaque; + + if (!ts->signal_restart) { + /* remember syscall info for restart */ + ts->signal_in_syscall = 1; + } #ifdef DEBUG gemu_log("syscall %d", num); @@ -7988,7 +8075,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, cmd = target_to_host_fcntl_cmd(arg2); if (cmd == -TARGET_EINVAL) { ret = cmd; - break; + goto fail; } switch(arg2) { @@ -8733,6 +8820,7 @@ fail: #endif if(do_strace) print_syscall_ret(num, ret); + ts->signal_in_syscall = 0; return ret; efault: ret = -TARGET_EFAULT; ++++++ 0004-qemu-0.9.0.cvs-binfmt.patch.patch ++++++
From ab367b4cc4151fa41715102987ae71dabfc551a3 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht <uli@suse.de> Date: Tue, 14 Apr 2009 16:18:44 +0200 Subject: [PATCH] qemu-0.9.0.cvs-binfmt
Fixes binfmt_misc setup script: - x86_64 is i386-compatible - m68k signature fixed - path to QEMU Signed-off-by: Ulrich Hecht <uli@suse.de> --- scripts/qemu-binfmt-conf.sh | 37 ++++++++++++++++++++----------------- 1 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index 0da2618..dc652f0 100644 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -27,43 +27,46 @@ case "$cpu" in armv[4-9]*) cpu="arm" ;; + sparc*) + cpu="sparc" + ;; esac # register the interpreter for each cpu except for the native one if [ $cpu != "i386" ] ; then - echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register - echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register + echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register + echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "alpha" ] ; then - echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register + echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "arm" ] ; then - echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register - echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register + echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register + echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "sparc" ] ; then - echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register + echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "ppc" ] ; then - echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register + echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "m68k" ] ; then echo 'Please check cpu value and header information for m68k!' - echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-m68k:' > /proc/sys/fs/binfmt_misc/register + echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-m68k:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "mips" ] ; then # FIXME: We could use the other endianness on a MIPS host. - echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mipsn32:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsn32el:' > /proc/sys/fs/binfmt_misc/register - echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips64:' > /proc/sys/fs/binfmt_misc/register - echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mips64el:' > /proc/sys/fs/binfmt_misc/register + echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register + echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register + echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mipsn32:' > /proc/sys/fs/binfmt_misc/register + echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsn32el:' > /proc/sys/fs/binfmt_misc/register + echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips64:' > /proc/sys/fs/binfmt_misc/register + echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mips64el:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "sh" ] ; then - echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-sh4:' > /proc/sys/fs/binfmt_misc/register - echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sh4eb:' > /proc/sys/fs/binfmt_misc/register + echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-sh4:' > /proc/sys/fs/binfmt_misc/register + echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sh4eb:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "s390x" ] ; then - echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register + echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register fi ++++++ 0005-qemu-cvs-alsa_bitfield.patch.patch ++++++
From 8f245aa1b93ab088b569d4644ab431ce2faeac50 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 14 Apr 2009 16:20:50 +0200 Subject: [PATCH] qemu-cvs-alsa_bitfield
Implements TYPE_INTBITFIELD partially. (required for ALSA support) Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulrich Hecht <uli@suse.de> --- thunk.c | 21 +++++++++++++++++++++ thunk.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/thunk.c b/thunk.c index 8ebbbb4..bf43985 100644 --- a/thunk.c +++ b/thunk.c @@ -41,6 +41,7 @@ static inline const argtype *thunk_type_next(const argtype *type_ptr) case TYPE_CHAR: case TYPE_SHORT: case TYPE_INT: + case TYPE_INTBITFIELD: case TYPE_LONGLONG: case TYPE_ULONGLONG: case TYPE_LONG: @@ -140,6 +141,26 @@ const argtype *thunk_convert(void *dst, const void *src, case TYPE_INT: *(uint32_t *)dst = tswap32(*(uint32_t *)src); break; + case TYPE_INTBITFIELD: +#if defined(TARGET_I386) && defined(__powerpc__) + /* powerpc uses the MSB, whereas i386 uses the LSB + * to store the first bit in a field */ + { + unsigned char byte = *(uint8_t *)src; + *(uint8_t *)dst = ((byte >> 7) & 1) + | ((byte >> 5) & 2) + | ((byte >> 3) & 4) + | ((byte >> 1) & 8) + | ((byte << 1) & 16) + | ((byte << 3) & 32) + | ((byte << 5) & 64) + | ((byte << 7) & 128); + /* FIXME: implement for bitfields > 1 byte and other archs */ + } +#else + *(uint32_t *)dst = tswap32(*(uint32_t *)src); +#endif + break; case TYPE_LONGLONG: case TYPE_ULONGLONG: *(uint64_t *)dst = tswap64(*(uint64_t *)src); diff --git a/thunk.h b/thunk.h index 87025c3..6c35e64 100644 --- a/thunk.h +++ b/thunk.h @@ -38,6 +38,7 @@ typedef enum argtype { TYPE_ARRAY, TYPE_STRUCT, TYPE_OLDDEVT, + TYPE_INTBITFIELD, } argtype; #define MK_PTR(type) TYPE_PTR, type @@ -91,6 +92,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host) case TYPE_SHORT: return 2; case TYPE_INT: + case TYPE_INTBITFIELD: return 4; case TYPE_LONGLONG: case TYPE_ULONGLONG: @@ -153,6 +155,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) case TYPE_SHORT: return 2; case TYPE_INT: + case TYPE_INTBITFIELD: return 4; case TYPE_LONGLONG: case TYPE_ULONGLONG: ++++++ 0006-qemu-cvs-alsa_ioctl.patch.patch ++++++ ++++ 3624 lines (skipped) ++++++ 0007-qemu-cvs-alsa_mmap.patch.patch ++++++
From ffeef7fd9d54eae6e9701b7a30d5cda54a3e5ba5 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 14 Apr 2009 16:24:15 +0200 Subject: [PATCH] qemu-cvs-alsa_mmap
Hack to prevent ALSA from using mmap() interface to simplify emulation. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulrich Hecht <uli@suse.de> --- linux-user/mmap.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d9468fe..3f5e1d7 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -377,6 +377,9 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) } } +#define SNDRV_PCM_MMAP_OFFSET_STATUS 0x80000000 +#define SNDRV_PCM_MMAP_OFFSET_CONTROL 0x81000000 + /* NOTE: all the constants are the HOST ones */ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, int flags, int fd, abi_ulong offset) @@ -412,6 +415,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, } #endif + /* Alsa tries to communcate with the kernel via mmap. This usually + * is a good idea when user- and kernelspace are running on the + * same architecture but does not work out when not. To make alsa + * not to use mmap, we can just have it fail on the mmap calls that + * would initiate this. + */ + if(offset == SNDRV_PCM_MMAP_OFFSET_STATUS || offset == SNDRV_PCM_MMAP_OFFSET_CONTROL) { + errno = EINVAL; + return -1; + } + if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; goto fail; ++++++ 0008-qemu-cvs-gettimeofday.patch.patch ++++++
From 20c78030d74586875bb61540c9e5682b5f338f93 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht <uli@suse.de> Date: Tue, 14 Apr 2009 16:25:41 +0200 Subject: [PATCH] qemu-cvs-gettimeofday
No clue what this is for. --- linux-user/syscall.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2a210e7..13721c5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6182,6 +6182,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_gettimeofday: { struct timeval tv; + if(copy_from_user_timeval(&tv, arg1)) + goto efault; ret = get_errno(gettimeofday(&tv, NULL)); if (!is_error(ret)) { if (copy_to_user_timeval(arg1, &tv)) ++++++ 0009-qemu-cvs-ioctl_debug.patch.patch ++++++
From f6c516a70a6df3c5213b975671da73084ac879cb Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 14 Apr 2009 16:26:33 +0200 Subject: [PATCH] qemu-cvs-ioctl_debug
Extends unsupported ioctl debug output. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulrich Hecht <uli@suse.de> --- linux-user/syscall.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 13721c5..c16c11a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3603,7 +3603,12 @@ static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) ie = ioctl_entries; for(;;) { if (ie->target_cmd == 0) { - gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd); + int i; + gemu_log("Unsupported ioctl: cmd=0x%04lx (%x)\n", (unsigned long)cmd, (unsigned int)(cmd & (TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) >> TARGET_IOC_SIZESHIFT); + for (i = 0; ioctl_entries[i].target_cmd; i++) { + if ((ioctl_entries[i].target_cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) == (cmd & ~(TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT))) + gemu_log("%p\t->\t%s (%x)\n", (void *)(unsigned long)ioctl_entries[i].host_cmd, ioctl_entries[i].name, (ioctl_entries[i].target_cmd & (TARGET_IOC_SIZEMASK << TARGET_IOC_SIZESHIFT)) >> TARGET_IOC_SIZESHIFT); + } return -TARGET_ENOSYS; } if (ie->target_cmd == cmd) ++++++ 0010-qemu-cvs-ioctl_nodirection.patch.patch ++++++
From d1750f98c3a864b21fc97faad999971e24f7250f Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 14 Apr 2009 16:27:36 +0200 Subject: [PATCH] qemu-cvs-ioctl_nodirection
the direction given in the ioctl should be correct so we can assume the communication is uni-directional. The alsa developers did not like this concept though and declared ioctls IOC_R and IOC_W even though they were IOC_RW. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Ulrich Hecht <uli@suse.de> --- linux-user/syscall.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c16c11a..5c6e303 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3637,6 +3637,11 @@ static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) arg_type++; target_size = thunk_type_size(arg_type, 0); switch(ie->access) { + /* FIXME: actually the direction given in the ioctl should be + * correct so we can assume the communication is uni-directional. + * The alsa developers did not like this concept though and + * declared ioctls IOC_R and IOC_W even though they were IOC_RW.*/ +/* case IOC_R: ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp)); if (!is_error(ret)) { @@ -3655,6 +3660,7 @@ static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) unlock_user(argptr, arg, 0); ret = get_errno(ioctl(fd, ie->host_cmd, buf_temp)); break; +*/ default: case IOC_RW: argptr = lock_user(VERIFY_READ, arg, target_size, 1); ++++++ 0011-qemu-img-vmdk-scsi.patch.patch ++++++
From e418f53ffea4b28bafae516b1d77d63595bc06be Mon Sep 17 00:00:00 2001 From: Ulrich Hecht <uli@suse.de> Date: Tue, 14 Apr 2009 16:37:42 +0200 Subject: [PATCH] qemu-img-vmdk-scsi
Support creation of SCSI VMDK images in qemu-img. Signed-off-by: Ulrich Hecht <uli@suse.de> --- block.c | 5 ++++- block/vmdk.c | 12 ++++++++++-- block_int.h | 2 ++ qemu-img.c | 8 +++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index 7547051..6a68221 100644 --- a/block.c +++ b/block.c @@ -4039,7 +4039,7 @@ int bdrv_img_create(const char *filename, const char *fmt, char *options, uint64_t img_size, int flags) { QEMUOptionParameter *param = NULL, *create_options = NULL; - QEMUOptionParameter *backing_fmt, *backing_file, *size; + QEMUOptionParameter *backing_fmt, *backing_file, *size, *scsi; BlockDriverState *bs = NULL; BlockDriver *drv, *proto_drv; BlockDriver *backing_drv = NULL; @@ -4154,6 +4154,9 @@ int bdrv_img_create(const char *filename, const char *fmt, printf("Formatting '%s', fmt=%s ", filename, fmt); print_option_parameters(param); + scsi = get_option_parameter(param, BLOCK_OPT_SCSI); + if (scsi && scsi->value.n) + printf(", SCSI"); puts(""); ret = bdrv_create(drv, filename, param); diff --git a/block/vmdk.c b/block/vmdk.c index 18e9b4c..c153617 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1377,7 +1377,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) "ddb.geometry.cylinders = \"%" PRId64 "\"\n" "ddb.geometry.heads = \"16\"\n" "ddb.geometry.sectors = \"63\"\n" - "ddb.adapterType = \"ide\"\n"; + "ddb.adapterType = \"%s\"\n"; if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) { return -EINVAL; @@ -1392,6 +1392,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) flags |= options->value.n ? BLOCK_FLAG_COMPAT6 : 0; } else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) { fmt = options->value.s; + } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) { + flags |= options->value.n ? BLOCK_FLAG_SCSI: 0; } options++; } @@ -1482,7 +1484,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) parent_desc_line, ext_desc_lines, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), - total_size / (int64_t)(63 * 16 * 512)); + total_size / (int64_t)(63 * 16 * 512), + flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide"); if (split || flat) { fd = open( filename, @@ -1585,6 +1588,11 @@ static QEMUOptionParameter vmdk_create_options[] = { "VMDK flat extent format, can be one of " "{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} " }, + { + .name = BLOCK_OPT_SCSI, + .type = OPT_FLAG, + .help = "SCSI image" + }, { NULL } }; diff --git a/block_int.h b/block_int.h index 3d4abc6..3d5a855 100644 --- a/block_int.h +++ b/block_int.h @@ -33,6 +33,7 @@ #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 +#define BLOCK_FLAG_SCSI 8 #define BLOCK_IO_LIMIT_READ 0 #define BLOCK_IO_LIMIT_WRITE 1 @@ -44,6 +45,7 @@ #define BLOCK_OPT_SIZE "size" #define BLOCK_OPT_ENCRYPT "encryption" #define BLOCK_OPT_COMPAT6 "compat6" +#define BLOCK_OPT_SCSI "scsi" #define BLOCK_OPT_BACKING_FILE "backing_file" #define BLOCK_OPT_BACKING_FMT "backing_fmt" #define BLOCK_OPT_CLUSTER_SIZE "cluster_size" diff --git a/qemu-img.c b/qemu-img.c index c8a70ff..00e3471 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -636,7 +636,7 @@ static int img_convert(int argc, char **argv) const uint8_t *buf1; BlockDriverInfo bdi; QEMUOptionParameter *param = NULL, *create_options = NULL; - QEMUOptionParameter *out_baseimg_param; + QEMUOptionParameter *out_baseimg_param, *scsi; char *options = NULL; const char *snapshot_name = NULL; float local_progress; @@ -829,6 +829,12 @@ static int img_convert(int argc, char **argv) } } + if ((scsi = get_option_parameter(param, BLOCK_OPT_SCSI)) && scsi->value.n && strcmp(drv->format_name, "vmdk")) { + error_report("SCSI devices not supported for this file format"); + ret = -1; + goto out; + } + /* Create the new image */ ret = bdrv_create(drv, out_filename, param); if (ret < 0) { ++++++ 0012-configure-Enable-mipsn32-linux-user.patch ++++++
From 3058c6153cf69063a225d234cb6985a602899a68 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht <uli@suse.de> Date: Wed, 25 Aug 2010 14:23:43 +0200 Subject: [PATCH] configure: Enable mipsn32*-linux-user builds
Signed-off-by: Ulrich Hecht <uli@suse.de> [AF: Merged default-configs upstream] --- configure | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 72d16a4..52b35f3 100755 --- a/configure +++ b/configure @@ -950,6 +950,8 @@ microblaze-linux-user \ microblazeel-linux-user \ mips-linux-user \ mipsel-linux-user \ +mipsn32-linux-user \ +mipsn32el-linux-user \ ppc-linux-user \ ppc64-linux-user \ ppc64abi32-linux-user \ ++++++ 0013-linux-user-add-binfmt-wrapper-for-a.patch ++++++
From c99a6d7f8fee3fe74718cddc61f0d13914c03f64 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Fri, 30 Sep 2011 19:40:36 +0200 Subject: [PATCH] linux-user: add binfmt wrapper for argv[0] handling
When using qemu's linux-user binaries through binfmt, argv[0] gets lost along the execution because qemu only gets passed in the full file name to the executable while argv[0] can be something completely different. This breaks in some subtile situations, such as the grep and make test suites. This patch adds a wrapper binary called qemu-$TARGET-binfmt that can be used with binfmt's P flag which passes the full path _and_ argv[0] to the binfmt handler. The binary would be smart enough to be versatile and only exist in the system once, creating the qemu binary path names from its own argv[0]. However, this seemed like it didn't fit the make system too well, so we're currently creating a new binary for each target archictecture. CC: Reinhard Max <max@suse.de> Signed-off-by: Alexander Graf <agraf@suse.de> --- Makefile.target | 9 +++++++++ linux-user/binfmt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/qemu-binfmt-conf.sh | 34 +++++++++++++++++----------------- 3 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 linux-user/binfmt.c diff --git a/Makefile.target b/Makefile.target index 1582904..101c0d6 100644 --- a/Makefile.target +++ b/Makefile.target @@ -42,6 +42,10 @@ PROGS+=$(QEMU_PROGW) endif STPFILES= +ifdef CONFIG_LINUX_USER +PROGS+=$(QEMU_PROG)-binfmt +endif + ifndef CONFIG_HAIKU LIBS+=-lm endif @@ -150,6 +154,8 @@ obj-y += $(addprefix ../libuser/, $(user-obj-y)) obj-y += $(addprefix ../libdis-user/, $(libdis-y)) obj-y += $(libobj-y) +obj-binfmt-y += binfmt.o + endif #CONFIG_LINUX_USER ######################################################### @@ -423,6 +429,9 @@ $(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(call LINK,$^) endif +$(QEMU_PROG)-binfmt: $(obj-binfmt-y) + $(call LINK,$^) + gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@") diff --git a/linux-user/binfmt.c b/linux-user/binfmt.c new file mode 100644 index 0000000..cd1f513 --- /dev/null +++ b/linux-user/binfmt.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <stdarg.h> +#include <unistd.h> +#include <libgen.h> +#include <string.h> +#include <stdlib.h> + + +int main(int argc, char **argv, char **envp) +{ + char *binfmt; + char **new_argv; + + /* + * Check if our file name ends with -binfmt + */ + binfmt = argv[0] + strlen(argv[0]) - strlen("-binfmt"); + if (strcmp(binfmt, "-binfmt")) { + fprintf(stderr, "%s: Invalid executable name\n", argv[0]); + exit(1); + } + if (argc < 3) { + fprintf(stderr, "%s: Please use me through binfmt with P flag\n", + argv[0]); + exit(1); + } + + binfmt[0] = '\0'; + /* Now argv[0] is the real qemu binary name */ + + new_argv = (char **)malloc((argc + 2) * sizeof(*new_argv)); + if (argc > 3) { + memcpy(&new_argv[4], &argv[3], (argc - 3) * sizeof(*new_argv)); + } + new_argv[0] = argv[0]; + new_argv[1] = (char *)"-0"; + new_argv[2] = argv[2]; + new_argv[3] = argv[1]; + new_argv[argc + 1] = NULL; + + return execve(new_argv[0], new_argv, envp); +} diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh index dc652f0..37d03f3 100644 --- a/scripts/qemu-binfmt-conf.sh +++ b/scripts/qemu-binfmt-conf.sh @@ -34,39 +34,39 @@ esac # register the interpreter for each cpu except for the native one if [ $cpu != "i386" ] ; then - echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register - echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register + echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "alpha" ] ; then - echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register + echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-alpha-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "arm" ] ; then - echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register - echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register + echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "sparc" ] ; then - echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register + echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "ppc" ] ; then - echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register + echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "m68k" ] ; then echo 'Please check cpu value and header information for m68k!' - echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-m68k:' > /proc/sys/fs/binfmt_misc/register + echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-m68k-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "mips" ] ; then # FIXME: We could use the other endianness on a MIPS host. - echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mipsn32:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsn32el:' > /proc/sys/fs/binfmt_misc/register - echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips64:' > /proc/sys/fs/binfmt_misc/register - echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mips64el:' > /proc/sys/fs/binfmt_misc/register + echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mipsn32-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsn32el-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips64-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mips64el-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "sh" ] ; then - echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-sh4:' > /proc/sys/fs/binfmt_misc/register - echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sh4eb:' > /proc/sys/fs/binfmt_misc/register + echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-sh4-binfmt:P' > /proc/sys/fs/binfmt_misc/register + echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sh4eb-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "s390x" ] ; then - echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register + echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-s390x-binfmt:P' > /proc/sys/fs/binfmt_misc/register fi ++++++ 0014-linux-user-Ignore-timer_create-sysc.patch ++++++
From 6c5378ba057751b19872ef4b3d20ef6418dbab35 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Sun, 11 Dec 2011 01:19:24 +0100 Subject: [PATCH] linux-user: Ignore timer_create syscall
We don't implement the timer_create syscall, but shouting out loud about it breaks some %check tests in OBS, so better ignore it silently. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/syscall.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5c6e303..403f943 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8449,6 +8449,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #endif +#if defined(TARGET_NR_timer_create) + case TARGET_NR_timer_create: + goto unimplemented_nowarn; +#endif + #if defined(TARGET_NR_tkill) && defined(__NR_tkill) case TARGET_NR_tkill: ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2))); ++++++ 0015-linux-user-be-silent-about-capget-f.patch ++++++
From c4fb71bf7b326382d6aaa592d2ffdfbfdcba7acd Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Sun, 11 Dec 2011 01:21:51 +0100 Subject: [PATCH] linux-user: be silent about capget failures
Complaining about capget doesn't buy us anything, but makes %check fail in certain builds. So better not complain about its missing implementation and go on with life :) Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/syscall.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 403f943..39d02f8 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7471,7 +7471,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, ret); break; case TARGET_NR_capget: - goto unimplemented; + goto unimplemented_nowarn; case TARGET_NR_capset: goto unimplemented; case TARGET_NR_sigaltstack: ++++++ 0016-PPC-KVM-Disable-mmu-notifier-check..patch ++++++
From 300922ff3172690a80455b9c9f37fe7af8066845 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Fri, 6 Jan 2012 01:05:55 +0100 Subject: [PATCH] PPC: KVM: Disable mmu notifier check
When using hugetlbfs (which is required for HV mode KVM on 970), we check for MMU notifiers that on 970 can not be implemented properly. So disable the check for mmu notifiers on PowerPC guests, making KVM guests work there, even if possibly racy in some odd circumstances. --- exec.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index 8eda655..6995b48 100644 --- a/exec.c +++ b/exec.c @@ -2504,10 +2504,12 @@ static void *file_ram_alloc(RAMBlock *block, return NULL; } +#ifndef TARGET_PPC if (kvm_enabled() && !kvm_has_sync_mmu()) { fprintf(stderr, "host lacks kvm mmu notifiers, -mem-path unsupported\n"); return NULL; } +#endif if (asprintf(&filename, "%s/qemu_back_mem.XXXXXX", path) == -1) { return NULL; ++++++ 0017-linux-user-fix-segfault-deadlock.pa.patch ++++++
From bc9dfeb8d22d0ac71781d850da32d3443a9819a5 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Fri, 13 Jan 2012 17:05:41 +0100 Subject: [PATCH] linux-user: fix segfault deadlock
When entering the guest we take a lock to ensure that nobody else messes with our TB chaining while we're doing it. If we get a segfault inside that code, we manage to work on, but will not unlock the lock. This patch forces unlocking of that lock in the segv handler. I'm not sure this is the right approach though. Maybe we should rather make sure we don't segfault in the code? I would greatly appreciate someone more intelligible than me to look at this :). Example code to trigger this is at: http://csgraf.de/tmp/conftest.c Reported-by: Fabio Erculiani <lxnay@sabayon.org> Signed-off-by: Alexander Graf <agraf@suse.de> --- qemu-lock.h | 10 ++++++++++ user-exec.c | 4 ++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/qemu-lock.h b/qemu-lock.h index a72edda..e460e12 100644 --- a/qemu-lock.h +++ b/qemu-lock.h @@ -24,6 +24,12 @@ #include <pthread.h> #define spin_lock pthread_mutex_lock #define spin_unlock pthread_mutex_unlock +static inline void spin_unlock_safe(pthread_mutex_t *lock) +{ + /* unlocking an unlocked mutex results in undefined behavior */ + pthread_mutex_trylock(lock); + pthread_mutex_unlock(lock); +} #define spinlock_t pthread_mutex_t #define SPIN_LOCK_UNLOCKED PTHREAD_MUTEX_INITIALIZER @@ -46,4 +52,8 @@ static inline void spin_unlock(spinlock_t *lock) { } +static inline void spin_unlock_safe(spinlock_t *lock) +{ +} + #endif diff --git a/user-exec.c b/user-exec.c index d8c2ad9..36d29b4 100644 --- a/user-exec.c +++ b/user-exec.c @@ -96,6 +96,10 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", pc, address, is_write, *(unsigned long *)old_set); #endif + + /* Maybe we're still holding the TB fiddling lock? */ + spin_unlock_safe(&tb_lock); + /* XXX: locking issue */ if (is_write && h2g_valid(address) && page_unprotect(h2g(address), pc, puc)) { ++++++ 0018-linux-user-binfmt-support-host-bina.patch ++++++
From 7e6191d2f4b00c6b5decde0485b4e4970387c158 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Thu, 2 Feb 2012 18:02:33 +0100 Subject: [PATCH] linux-user: binfmt: support host binaries
When we have a working host binary equivalent for the guest binary we're trying to run, let's just use that instead as it will be a lot faster. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/binfmt.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/linux-user/binfmt.c b/linux-user/binfmt.c index cd1f513..87dc4c6 100644 --- a/linux-user/binfmt.c +++ b/linux-user/binfmt.c @@ -5,6 +5,9 @@ #include <string.h> #include <stdlib.h> +#ifdef __x86_64__ +#define ARCH_NAME "x86_64" +#endif int main(int argc, char **argv, char **envp) { @@ -28,6 +31,28 @@ int main(int argc, char **argv, char **envp) binfmt[0] = '\0'; /* Now argv[0] is the real qemu binary name */ +#ifdef ARCH_NAME + { + char *hostbin; + char *guestarch; + + guestarch = strrchr(argv[0], '-') ; + if (!guestarch) { + goto skip; + } + guestarch++; + asprintf(&hostbin, "/emul/" ARCH_NAME "-for-%s/%s", guestarch, argv[1]); + if (!access(hostbin, X_OK)) { + /* + * We found a host binary replacement for the non-host binary. Let's + * use that instead! + */ + return execve(hostbin, &argv[2], envp); + } + } +skip: +#endif + new_argv = (char **)malloc((argc + 2) * sizeof(*new_argv)); if (argc > 3) { memcpy(&new_argv[4], &argv[3], (argc - 3) * sizeof(*new_argv)); ++++++ 0019-linux-user-ARM-Ignore-immediate-val.patch ++++++
From fd2566a03dbc2ea80654d233bdbe8d829dc6d3ab Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 29 May 2012 17:28:07 +0200 Subject: [PATCH] linux-user: ARM: Ignore immediate value for svc in thumb mode
When running in thumb mode, Linux doesn't evaluate the immediate value of the svc instruction, but instead just always assumes the syscall number to be in r7. This fixes executing go_bootstrap while building go for me. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/main.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 503ecfa..ed48276 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -823,8 +823,7 @@ void cpu_loop(CPUARMState *env) } else if (n == ARM_NR_semihosting || n == ARM_NR_thumb_semihosting) { env->regs[0] = do_arm_semihosting (env); - } else if (n == 0 || n >= ARM_SYSCALL_BASE - || (env->thumb && n == ARM_THUMB_SYSCALL)) { + } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) { /* linux syscall */ if (env->thumb || n == 0) { n = env->regs[7]; ++++++ 0020-linux-user-arm-no-tb_flush-on-reset.patch ++++++
From f5e427ca62c0d77b3e006aeb1336ecd6045b7a86 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 29 May 2012 15:30:01 +0200 Subject: [PATCH] linux-user: arm: no tb_flush on reset
When running automoc4 as linux-user guest program, it segfaults right after it creates a thread. Bisecting pointed to commit a84fac1426 which introduces tb_flush on reset. So something in our thread creation is broken. But for now, let's revert the change to at least get a working build again. --- target-arm/cpu.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 7eb323a..2e90e56 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -117,7 +117,11 @@ static void arm_cpu_reset(CPUState *s) * bake assumptions about into translated code, so we need to * tb_flush(). */ +#if !defined(CONFIG_USER_ONLY) + /* XXX hack alert! automoc4 segaults after spawning a new thread with this + flush enabled */ tb_flush(env); +#endif } static inline void set_feature(CPUARMState *env, int feature) ++++++ 0021-linux-user-fix-multi-threaded-proc-.patch ++++++
From 2cb078cf0ee74c53ffc5c22e63e79f5ffe6f66b4 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Wed, 30 May 2012 14:40:47 +0200 Subject: [PATCH] linux-user: fix multi-threaded /proc/self/maps
When reading our faked /proc/self/maps from a secondary thread, we get an invalid stack entry. This is because ts->stack_base is not initialized in non-primary threads. However, ts->info is, and the stack layout information we're looking for is there too. So let's use that one instead! Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/syscall.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 39d02f8..06408bd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4920,8 +4920,8 @@ static int open_self_maps(void *cpu_env, int fd) #if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32) dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n", (unsigned long long)ts->info->stack_limit, - (unsigned long long)(ts->stack_base + (TARGET_PAGE_SIZE - 1)) - & TARGET_PAGE_MASK, + (unsigned long long)(ts->info->start_stack + + (TARGET_PAGE_SIZE - 1)) & TARGET_PAGE_MASK, (unsigned long long)0); #endif ++++++ 0022-use-libexecdir-instead-of-ignoring-.patch ++++++
From 8d6579e17201831963df352fe2c93fc8752e0103 Mon Sep 17 00:00:00 2001 From: Michael Tokarev <mjt@tls.msk.ru> Date: Thu, 7 Jun 2012 01:11:00 +0400 Subject: [PATCH] use --libexecdir instead of ignoring it first and reinventing it later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
Commit 7b93fadf3a38d1ed65ea5536a52efc2772c6e3b8 "Add basic version of bridge helper" put the bridge helper executable into a fixed ${prefix}/libexec/ location, instead of using ${libexecdir} for this. At the same time, --libexecdir is being happily ignored by ./configure. Even more, the same patch sets unused $libexecdir variable in the generated config-host.mak, and uses fixed string (\${prefix}/libexecdir) for the bridge helper binary. Fix this braindamage by introducing $libexecdir variable, using it for the bridge helper binary, and recognizing --libexecdir. This patch is applicable to stable-1.1. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Andreas Färber <afaerber@suse.de> --- configure | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 52b35f3..faa9d51 100755 --- a/configure +++ b/configure @@ -159,6 +159,7 @@ datadir="\${prefix}/share" qemu_docdir="\${prefix}/share/doc/qemu" bindir="\${prefix}/bin" libdir="\${prefix}/lib" +libexecdir="\${prefix}/libexec" includedir="\${prefix}/include" sysconfdir="\${prefix}/etc" confsuffix="/qemu" @@ -587,6 +588,8 @@ for opt do ;; --libdir=*) libdir="$optarg" ;; + --libexecdir=*) libexecdir="$optarg" + ;; --includedir=*) includedir="$optarg" ;; --datadir=*) datadir="$optarg" @@ -597,7 +600,7 @@ for opt do ;; --sysconfdir=*) sysconfdir="$optarg" ;; - --sbindir=*|--libexecdir=*|--sharedstatedir=*|--localstatedir=*|\ + --sbindir=*|--sharedstatedir=*|--localstatedir=*|\ --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\ --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*) # These switches are silently ignored, for compatibility with @@ -2950,6 +2953,7 @@ echo "Install prefix $prefix" echo "BIOS directory `eval echo $qemu_datadir`" echo "binary directory `eval echo $bindir`" echo "library directory `eval echo $libdir`" +echo "libexec directory `eval echo $libexecdir`" echo "include directory `eval echo $includedir`" echo "config directory `eval echo $sysconfdir`" if test "$mingw32" = "no" ; then @@ -3053,14 +3057,14 @@ echo all: >> $config_host_mak echo "prefix=$prefix" >> $config_host_mak echo "bindir=$bindir" >> $config_host_mak echo "libdir=$libdir" >> $config_host_mak +echo "libexecdir=$libexecdir" >> $config_host_mak echo "includedir=$includedir" >> $config_host_mak echo "mandir=$mandir" >> $config_host_mak echo "sysconfdir=$sysconfdir" >> $config_host_mak echo "qemu_confdir=$qemu_confdir" >> $config_host_mak echo "qemu_datadir=$qemu_datadir" >> $config_host_mak echo "qemu_docdir=$qemu_docdir" >> $config_host_mak -echo "libexecdir=\${prefix}/libexec" >> $config_host_mak -echo "CONFIG_QEMU_HELPERDIR=\"$prefix/libexec\"" >> $config_host_mak +echo "CONFIG_QEMU_HELPERDIR=\"$libexecdir\"" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak if test "$debug_tcg" = "yes" ; then ++++++ 0023-linux-user-Ignore-broken-loop-ioctl.patch ++++++
From 22544b65e4f50aad918f2ebc6ca3830b8cce52dd Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 12 Jun 2012 04:41:10 +0200 Subject: [PATCH] linux-user: Ignore broken loop ioctl
During invocations of losetup, we run into an ioctl that doesn't exist. However, because of that we output an error, which then screws up the kiwi logic around that call. So let's silently ignore that bogus ioctl. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/ioctls.h | 1 + linux-user/linux_loop.h | 1 + linux-user/syscall.c | 7 +++++++ linux-user/syscall_defs.h | 1 + 4 files changed, 10 insertions(+), 0 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index e8c1c69..97c3f10 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -328,6 +328,7 @@ IOCTL(LOOP_SET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64))) IOCTL(LOOP_GET_STATUS64, IOC_W, MK_PTR(MK_STRUCT(STRUCT_loop_info64))) IOCTL(LOOP_CHANGE_FD, 0, TYPE_INT) + IOCTL_SPECIAL(LOOP_BOGUS_CMD, 0, do_ioctl_fail, TYPE_INT) IOCTL(MTIOCTOP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_mtop))) IOCTL(MTIOCGET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_mtget))) diff --git a/linux-user/linux_loop.h b/linux-user/linux_loop.h index 8974caa..810ae61 100644 --- a/linux-user/linux_loop.h +++ b/linux-user/linux_loop.h @@ -91,5 +91,6 @@ struct loop_info64 { #define LOOP_SET_STATUS64 0x4C04 #define LOOP_GET_STATUS64 0x4C05 #define LOOP_CHANGE_FD 0x4C06 +#define LOOP_BOGUS_CMD 0x4C82 #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 06408bd..46e964b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3580,6 +3580,13 @@ out: return ret; } +static abi_long do_ioctl_fail(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, + abi_long cmd, abi_long arg) +{ + /* Fail silently */ + return -EINVAL; +} + static IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index be8760c..b76f64a 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -968,6 +968,7 @@ struct target_pollfd { #define TARGET_LOOP_SET_STATUS64 0x4C04 #define TARGET_LOOP_GET_STATUS64 0x4C05 #define TARGET_LOOP_CHANGE_FD 0x4C06 +#define TARGET_LOOP_BOGUS_CMD 0x4C82 /* fb ioctls */ #define TARGET_FBIOGET_VSCREENINFO 0x4600 ++++++ 0024-linux-user-fix-segmentation-fault-p.patch ++++++
From 9a982f5a78921dbe808a8306cd164290783c0c66 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Mon, 25 Jun 2012 19:02:32 +0200 Subject: [PATCH] linux-user: fix segmentation fault passing with g2h(x) != x
When forwarding a segmentation fault into the guest process, we were passing the host's address directly into the guest process's signal descriptor. That obviously confused the guest process, since it didn't know what to make of the (usually 32-bit truncated) address. Passing in g2h(address) makes the guest process a lot happier. This fixes java running in arm-linux-user for me. Signed-off-by: Alexander Graf <agraf@suse.de> --- user-exec.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/user-exec.c b/user-exec.c index 36d29b4..83d2d44 100644 --- a/user-exec.c +++ b/user-exec.c @@ -100,19 +100,20 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, /* Maybe we're still holding the TB fiddling lock? */ spin_unlock_safe(&tb_lock); - /* XXX: locking issue */ - if (is_write && h2g_valid(address) - && page_unprotect(h2g(address), pc, puc)) { - return 1; - } + if (h2g_valid(address)) { + /* XXX: locking issue */ + if (is_write && page_unprotect(h2g(address), pc, puc)) { + return 1; + } - /* see if it is an MMU fault */ - ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); - if (ret < 0) { - return 0; /* not an MMU fault */ - } - if (ret == 0) { - return 1; /* the MMU fault was handled without causing real CPU fault */ + /* see if it is an MMU fault */ + ret = cpu_handle_mmu_fault(env, h2g(address), is_write, MMU_USER_IDX); + if (ret < 0) { + return 0; /* not an MMU fault */ + } + if (ret == 0) { + return 1; /* the MMU fault was handled without causing real CPU fault */ + } } /* now we have a real cpu fault */ tb = tb_find_pc(pc); ++++++ 0025-linux-user-lock-tcg.patch.patch ++++++
From adb47708775abea8e3aa64e76f6961fef856ef49 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Thu, 5 Jul 2012 17:31:39 +0200 Subject: [PATCH] linux-user: lock tcg
The tcg code generator is not thread safe. Lock its generation between different threads. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/mmap.c | 3 +++ tcg/tcg.c | 36 ++++++++++++++++++++++++++++++++++-- tcg/tcg.h | 6 ++++++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 3f5e1d7..83e9eda 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -30,6 +30,7 @@ #include "qemu.h" #include "qemu-common.h" +#include "tcg.h" //#define DEBUG_MMAP @@ -41,6 +42,7 @@ void mmap_lock(void) { if (mmap_lock_count++ == 0) { pthread_mutex_lock(&mmap_mutex); + tcg_lock(); } } @@ -48,6 +50,7 @@ void mmap_unlock(void) { if (--mmap_lock_count == 0) { pthread_mutex_unlock(&mmap_mutex); + tcg_unlock(); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index ab589c7..4c93acb 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -40,6 +40,8 @@ #include "cache-utils.h" #include "host-utils.h" #include "qemu-timer.h" +#include "config-host.h" +#include "qemu-thread.h" /* Note: the long term plan is to reduce the dependancies on the QEMU CPU definitions. Currently they are used for qemu_ld/st @@ -105,6 +107,29 @@ static TCGRegSet tcg_target_call_clobber_regs; uint16_t *gen_opc_ptr; TCGArg *gen_opparam_ptr; +#ifdef CONFIG_USER_ONLY +static __thread int tcg_lock_count; +#endif +void tcg_lock(void) +{ +#ifdef CONFIG_USER_ONLY + TCGContext *s = &tcg_ctx; + if (tcg_lock_count++ == 0) { + qemu_mutex_lock(&s->lock); + } +#endif +} + +void tcg_unlock(void) +{ +#ifdef CONFIG_USER_ONLY + TCGContext *s = &tcg_ctx; + if (--tcg_lock_count == 0) { + qemu_mutex_unlock(&s->lock); + } +#endif +} + static inline void tcg_out8(TCGContext *s, uint8_t v) { *s->code_ptr++ = v; @@ -245,7 +270,8 @@ void tcg_context_init(TCGContext *s) memset(s, 0, sizeof(*s)); s->temps = s->static_temps; s->nb_globals = 0; - + qemu_mutex_init(&s->lock); + /* Count total number of arguments and allocate the corresponding space */ total_args = 0; @@ -2182,11 +2208,13 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf) } #endif + tcg_lock(); tcg_gen_code_common(s, gen_code_buf, -1); /* flush instruction cache */ flush_icache_range((tcg_target_ulong)gen_code_buf, (tcg_target_ulong)s->code_ptr); + tcg_unlock(); return s->code_ptr - gen_code_buf; } @@ -2197,7 +2225,11 @@ int tcg_gen_code(TCGContext *s, uint8_t *gen_code_buf) Return -1 if not found. */ int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset) { - return tcg_gen_code_common(s, gen_code_buf, offset); + int r; + tcg_lock(); + r = tcg_gen_code_common(s, gen_code_buf, offset); + tcg_unlock(); + return r; } #ifdef CONFIG_PROFILER diff --git a/tcg/tcg.h b/tcg/tcg.h index a83bddd..e20fc82 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -46,6 +46,8 @@ typedef uint64_t tcg_target_ulong; #error unsupported #endif +#include "config-host.h" +#include "qemu-thread.h" #include "tcg-target.h" #include "tcg-runtime.h" @@ -389,6 +391,7 @@ struct TCGContext { #ifdef CONFIG_DEBUG_TCG int temps_in_use; #endif + QemuMutex lock; }; extern TCGContext tcg_ctx; @@ -568,6 +571,9 @@ void tcg_gen_shifti_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGArg *tcg_optimize(TCGContext *s, uint16_t *tcg_opc_ptr, TCGArg *args, TCGOpDef *tcg_op_def); +extern void tcg_lock(void); +extern void tcg_unlock(void); + /* only used for debugging purposes */ void tcg_register_helper(void *func, const char *name); const char *tcg_helper_get_name(TCGContext *s, void *func); ++++++ 0026-linux-user-Run-multi-threaded-code-.patch ++++++
From 078dd7c177f7234de75aec24d8513e06fd4f586b Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Tue, 10 Jul 2012 20:40:55 +0200 Subject: [PATCH] linux-user: Run multi-threaded code on a single core
Running multi-threaded code can easily expose some of the fundamental breakages in QEMU's design. It's just not a well supported scenario. So if we pin the whole process to a single host CPU, we guarantee that we will never have concurrent memory access actually happen. We can still get scheduled away at any time, so it's no complete guarantee, but apparently it reduces the odds well enough to get my test cases to pass. This gets Java 1.7 working for me again on my test box. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/syscall.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 46e964b..b0566cd 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4298,6 +4298,15 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, if (nptl_flags & CLONE_SETTLS) cpu_set_tls (new_env, newtls); + /* agraf: Pin ourselves to a single CPU when running multi-threaded. + This turned out to improve stability for me. */ + { + cpu_set_t mask; + CPU_ZERO(&mask); + CPU_SET(0, &mask); + sched_setaffinity(0, sizeof(mask), &mask); + } + /* Grab a mutex so that thread setup appears atomic. */ pthread_mutex_lock(&clone_lock); ++++++ 0027-linux-user-lock-tb-flushing-too.pat.patch ++++++
From 207d71410ee153423b0bf4f6c8a2f2fd450a3581 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Wed, 11 Jul 2012 16:47:42 +0200 Subject: [PATCH] linux-user: lock tb flushing too
Signed-off-by: Alexander Graf <agraf@suse.de> --- exec.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/exec.c b/exec.c index 6995b48..c898fbb 100644 --- a/exec.c +++ b/exec.c @@ -732,17 +732,22 @@ static TranslationBlock *tb_alloc(target_ulong pc) { TranslationBlock *tb; + tcg_lock(); if (nb_tbs >= code_gen_max_blocks || - (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size) + (code_gen_ptr - code_gen_buffer) >= code_gen_buffer_max_size) { + tcg_unlock(); return NULL; + } tb = &tbs[nb_tbs++]; tb->pc = pc; tb->cflags = 0; + tcg_unlock(); return tb; } void tb_free(TranslationBlock *tb) { + tcg_lock(); /* In practice this is mostly used for single use temporary TB Ignore the hard cases and just back up if this TB happens to be the last one generated. */ @@ -750,6 +755,7 @@ void tb_free(TranslationBlock *tb) code_gen_ptr = tb->tc_ptr; nb_tbs--; } + tcg_unlock(); } static inline void invalidate_page_bitmap(PageDesc *p) @@ -803,6 +809,7 @@ void tb_flush(CPUArchState *env1) nb_tbs, nb_tbs > 0 ? ((unsigned long)(code_gen_ptr - code_gen_buffer)) / nb_tbs : 0); #endif + tcg_lock(); if ((unsigned long)(code_gen_ptr - code_gen_buffer) > code_gen_buffer_size) cpu_abort(env1, "Internal error: code buffer overflow\n"); @@ -819,6 +826,7 @@ void tb_flush(CPUArchState *env1) /* XXX: flush processor icache at this point if cache flush is expensive */ tb_flush_count++; + tcg_unlock(); } #ifdef DEBUG_TB_CHECK @@ -1116,9 +1124,12 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, int current_flags = 0; #endif /* TARGET_HAS_PRECISE_SMC */ + tcg_lock(); p = page_find(start >> TARGET_PAGE_BITS); - if (!p) + if (!p) { + tcg_unlock(); return; + } if (!p->code_bitmap && ++p->code_write_count >= SMC_BITMAP_USE_THRESHOLD && is_cpu_write_access) { @@ -1202,6 +1213,7 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, cpu_resume_from_signal(env, NULL); } #endif + tcg_unlock(); } /* len must be <= 8 and start must be a multiple of len */ @@ -1397,12 +1409,16 @@ TranslationBlock *tb_find_pc(uintptr_t tc_ptr) { int m_min, m_max, m; uintptr_t v; - TranslationBlock *tb; + TranslationBlock *tb, *r; - if (nb_tbs <= 0) + tcg_lock(); + if (nb_tbs <= 0) { + tcg_unlock(); return NULL; + } if (tc_ptr < (uintptr_t)code_gen_buffer || tc_ptr >= (uintptr_t)code_gen_ptr) { + tcg_unlock(); return NULL; } /* binary search (cf Knuth) */ @@ -1412,15 +1428,18 @@ TranslationBlock *tb_find_pc(uintptr_t tc_ptr) m = (m_min + m_max) >> 1; tb = &tbs[m]; v = (uintptr_t)tb->tc_ptr; - if (v == tc_ptr) + if (v == tc_ptr) { + tcg_unlock(); return tb; - else if (tc_ptr < v) { + } else if (tc_ptr < v) { m_max = m - 1; } else { m_min = m + 1; } } - return &tbs[m_max]; + r = &tbs[m_max]; + tcg_unlock(); + return r; } static void tb_reset_jump_recursive(TranslationBlock *tb); ++++++ 0028-XXX-merge-with-segmentation-fault-p.patch ++++++
From c5369ea1311df4da3183a4b6031454fb7e7bc434 Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Wed, 11 Jul 2012 23:15:47 +0200 Subject: [PATCH] XXX merge with segmentation fault passing patch
--- user-exec.c | 32 +++++++++++++++++++------------- 1 files changed, 19 insertions(+), 13 deletions(-) diff --git a/user-exec.c b/user-exec.c index 83d2d44..cc57bde 100644 --- a/user-exec.c +++ b/user-exec.c @@ -100,21 +100,27 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address, /* Maybe we're still holding the TB fiddling lock? */ spin_unlock_safe(&tb_lock); - if (h2g_valid(address)) { - /* XXX: locking issue */ - if (is_write && page_unprotect(h2g(address), pc, puc)) { - return 1; - } + /* XXX: locking issue */ + if (h2g_valid(address) && is_write && + page_unprotect(h2g(address), pc, puc)) { + return 1; + } - /* see if it is an MMU fault */ - ret = cpu_handle_mmu_fault(env, h2g(address), is_write, MMU_USER_IDX); - if (ret < 0) { - return 0; /* not an MMU fault */ - } - if (ret == 0) { - return 1; /* the MMU fault was handled without causing real CPU fault */ - } + if (RESERVED_VA) { + /* Convert forcefully to guest address space, invalid addresses + are still valid segv ones */ + address = address - GUEST_BASE; } + + /* see if it is an MMU fault */ + ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX); + if (ret < 0) { + return 0; /* not an MMU fault */ + } + if (ret == 0) { + return 1; /* the MMU fault was handled without causing real CPU fault */ + } + /* now we have a real cpu fault */ tb = tb_find_pc(pc); if (tb) { ++++++ 0029-linux-user-Fake-proc-cpuinfo.patch.patch ++++++
From 5cb71e9f96a095517e87c451c6438ff1108064bc Mon Sep 17 00:00:00 2001 From: Alexander Graf <agraf@suse.de> Date: Mon, 23 Jul 2012 10:24:14 +0200 Subject: [PATCH] linux-user: Fake /proc/cpuinfo
Fedora 17 for ARM reads /proc/cpuinfo and fails if it doesn't contain ARM related contents. This patch implements a quick hack to expose real /proc/cpuinfo data taken from a real world machine. The real fix would be to generate at least the flags automatically based on the selected CPU. Please do not submit this patch upstream until this has happened. Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/syscall.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b0566cd..2efd7f4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4980,6 +4980,25 @@ static int open_self_stat(void *cpu_env, int fd) return 0; } +static int open_cpuinfo(void *cpu_env, int fd) +{ + dprintf(fd, +"Processor : ARMv7 Processor rev 5 (v7l)\n" +"BogoMIPS : 799.53\n" +"Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3\n" +"CPU implementer : 0x41\n" +"CPU architecture: 7\n" +"CPU variant : 0x2\n" +"CPU part : 0xc08\n" +"CPU revision : 5\n" +"\n" +"Hardware : Genesi Efika MX (Smarttop)\n" +"Revision : 51030\n" +"Serial : 0000000000000000\n"); + + return 0; +} + static int open_self_auxv(void *cpu_env, int fd) { TaskState *ts = ((CPUArchState *)cpu_env)->opaque; @@ -5020,6 +5039,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) { "/proc/self/maps", open_self_maps }, { "/proc/self/stat", open_self_stat }, { "/proc/self/auxv", open_self_auxv }, + { "/proc/cpuinfo", open_cpuinfo }, { NULL, NULL } }; ++++++ 0030-Replace-struct-siginfo-with-siginfo.patch ++++++
From 2504daf747d63571d47269b0725e2d2d0fc026e1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" <rjones@redhat.com> Date: Thu, 5 Jul 2012 03:32:44 +0000 Subject: [PATCH] Replace 'struct siginfo' with 'siginfo_t'.
glibc 2.16 will remove the undocumented definition of 'struct siginfo' from <bits/siginfo.h>. This change is already present in glibc 2.15.90, so qemu compilation of certain targets (eg. cris-user) breaks. This struct was always typedef'd to be the same as 'siginfo_t' which is what POSIX documents, so use that instead. Signed-off-by: Richard W.M. Jones <rjones@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de> --- linux-user/signal.c | 8 ++++---- user-exec.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index c00cf75..f33ea70 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2877,7 +2877,7 @@ static void setup_rt_frame(int sig, struct target_sigaction *ka, * Arguments to signal handler: * * a0 = signal number - * a1 = pointer to struct siginfo + * a1 = pointer to siginfo_t * a2 = pointer to struct ucontext * * $25 and PC point to the signal handler, $29 points to the @@ -3283,7 +3283,7 @@ struct target_signal_frame { }; struct rt_signal_frame { - struct siginfo info; + siginfo_t info; struct ucontext uc; uint32_t tramp[2]; }; @@ -3502,9 +3502,9 @@ struct target_signal_frame { }; struct rt_signal_frame { - struct siginfo *pinfo; + siginfo_t *pinfo; void *puc; - struct siginfo info; + siginfo_t info; struct ucontext uc; uint8_t retcode[8]; /* Trampoline code. */ }; diff --git a/user-exec.c b/user-exec.c index cc57bde..2d7f6c9 100644 --- a/user-exec.c +++ b/user-exec.c @@ -599,7 +599,7 @@ int cpu_signal_handler(int host_signum, void *pinfo, int cpu_signal_handler(int host_signum, void *pinfo, void *puc) { - struct siginfo *info = pinfo; + siginfo_t *info = pinfo; struct ucontext *uc = puc; unsigned long pc = uc->uc_mcontext.sc_iaoq[0]; uint32_t insn = *(uint32_t *)pc; ++++++ 0031-console-bounds-check-whenever-chang.patch ++++++
From e75d5b57ec6e28b9e4da7896eef0ab5d43d5b26f Mon Sep 17 00:00:00 2001 From: Ian Campbell <ian.campbell@citrix.com> Date: Wed, 5 Sep 2012 12:19:51 +0200 Subject: [PATCH] console: bounds check whenever changing the cursor due to an escape code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit
This is XSA-17 / CVE-2012-3515 Signed-off-by: Ian Campbell <ian.campbell@citrix.com> [AF: fixed Coding Style; bnc#777084] [AF: cherry-picked from suse-1.2 branch] Signed-off-by: Andreas Färber <afaerber@suse.de> --- console.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 29 insertions(+), 29 deletions(-) diff --git a/console.c b/console.c index 6a463f5..0cbb9dd 100644 --- a/console.c +++ b/console.c @@ -847,6 +847,26 @@ static void console_clear_xy(TextConsole *s, int x, int y) update_xy(s, x, y); } +/* set cursor, checking bounds */ +static void set_cursor(TextConsole *s, int x, int y) +{ + if (x < 0) { + x = 0; + } + if (y < 0) { + y = 0; + } + if (y >= s->height) { + y = s->height - 1; + } + if (x >= s->width) { + x = s->width - 1; + } + + s->x = x; + s->y = y; +} + static void console_putchar(TextConsole *s, int ch) { TextCell *c; @@ -918,7 +938,9 @@ static void console_putchar(TextConsole *s, int ch) s->esc_params[s->nb_esc_params] * 10 + ch - '0'; } } else { - s->nb_esc_params++; + if (s->nb_esc_params < MAX_ESC_PARAMS) { + s->nb_esc_params++; + } if (ch == ';') break; #ifdef DEBUG_CONSOLE @@ -932,59 +954,37 @@ static void console_putchar(TextConsole *s, int ch) if (s->esc_params[0] == 0) { s->esc_params[0] = 1; } - s->y -= s->esc_params[0]; - if (s->y < 0) { - s->y = 0; - } + set_cursor(s, s->x, s->y - s->esc_params[0]); break; case 'B': /* move cursor down */ if (s->esc_params[0] == 0) { s->esc_params[0] = 1; } - s->y += s->esc_params[0]; - if (s->y >= s->height) { - s->y = s->height - 1; - } + set_cursor(s, s->x, s->y + s->esc_params[0]); break; case 'C': /* move cursor right */ if (s->esc_params[0] == 0) { s->esc_params[0] = 1; } - s->x += s->esc_params[0]; - if (s->x >= s->width) { - s->x = s->width - 1; - } + set_cursor(s, s->x + s->esc_params[0], s->y); break; case 'D': /* move cursor left */ if (s->esc_params[0] == 0) { s->esc_params[0] = 1; } - s->x -= s->esc_params[0]; - if (s->x < 0) { - s->x = 0; - } + set_cursor(s, s->x - s->esc_params[0], s->y); break; case 'G': /* move cursor to column */ - s->x = s->esc_params[0] - 1; - if (s->x < 0) { - s->x = 0; - } + set_cursor(s, s->esc_params[0] - 1, s->y); break; case 'f': case 'H': /* move cursor to row, column */ - s->x = s->esc_params[1] - 1; - if (s->x < 0) { - s->x = 0; - } - s->y = s->esc_params[0] - 1; - if (s->y < 0) { - s->y = 0; - } + set_cursor(s, s->esc_params[1] - 1, s->esc_params[0] - 1); break; case 'J': switch (s->esc_params[0]) { ++++++ bridge.conf ++++++ # Access control file for qemu bridge helper # Syntax consists of: # # comment (ignored) # allow all # allow <bridge_name> # deny all # deny <bridge_name> # include /path/to/additional/ACL/file # Users are blacklisted by default and 'deny' takes precedence over 'allow'. # Including additional ACL files allows file access permissions to be used as # a component of the policy to allow access or deny access to specific bridges. ++++++ qemu.spec.in ++++++ # # spec file for package qemu # # Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: qemu Url: http://www.qemu.org/ Summary: Universal CPU emulator License: BSD-3-Clause ; GPL-2.0+ ; LGPL-2.1+ ; MIT Group: System/Emulators/PC Version: 1.1.1 Release: 0 Source: %name-%version-1.tar.bz2 PATCH_FILES # this is to make lint happy Source300: rpmlintrc Source302: bridge.conf Source400: update_git.sh BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: SDL-devel BuildRequires: bison BuildRequires: bluez-devel BuildRequires: curl-devel BuildRequires: cyrus-sasl-devel BuildRequires: e2fsprogs-devel BuildRequires: libaio BuildRequires: libaio-devel BuildRequires: libattr-devel BuildRequires: libgnutls-devel BuildRequires: libpcap-devel BuildRequires: ncurses-devel %if 0%{?suse_version} >= 1120 BuildRequires: zlib-devel-static %else BuildRequires: zlib-devel %endif %if 0%{?suse_version} >= 1210 BuildRequires: glibc-devel-static BuildRequires: libattr-devel-static BuildRequires: libfdt1-devel %endif %if 0%{?suse_version} >= 1140 BuildRequires: glib2-devel-static %endif %if 0%{?suse_version} >= 1220 BuildRequires: pcre-devel-static %endif %if 0%{?suse_version} >= 1130 %ifarch %ix86 x86_64 BuildRequires: libspice-server-devel BuildRequires: spice-protocol-devel %endif %endif %ifarch ppc ppc64 #we need that for -M pseries support in SLES BuildRequires: libfdt1-devel %endif BuildRequires: fdupes BuildRequires: glib2-devel BuildRequires: libvdeplug3-devel BuildRequires: pwdutils BuildRequires: python Requires: pwdutils Requires: timezone Requires: /usr/sbin/groupadd Recommends: qemu-tools %description QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. %package tools Summary: Universal CPU emulator -- Tools Group: System/Emulators/PC Provides: qemu:%_libexecdir/qemu-bridge-helper PreReq: permissions %description tools QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains various tools, including a bridge helper. %package guest-agent Summary: Universal CPU emulator -- Guest agent Group: System/Emulators/PC Provides: qemu:%_bindir/qemu-ga %description guest-agent QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains the guest agent. %package linux-user Summary: Universal CPU emulator -- Linux User binaries Group: System/Emulators/PC Provides: qemu:%_bindir/qemu-arm %description linux-user QEMU is an extremely well-performing CPU emulator that allows you to choose between simulating an entire system and running userspace binaries for different architectures under your native operating system. It currently emulates x86, ARM, PowerPC and SPARC CPUs as well as PC and PowerMac systems. This sub-package contains statically linked binaries for running linux-user emulations. This can be used together with the OBS build script to run cross-architecture builds. %prep %setup -q PATCH_EXEC %build # build QEMU mkdir -p dynamic # build qemu-system ./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \ --libexecdir=%_libexecdir \ --audio-card-list="ac97 es1370 sb16 cs4231a adlib gus" \ --audio-drv-list="alsa sdl" --enable-mixemu --enable-vde \ --enable-curl \ --extra-cflags="$QEMU_OPT_FLAGS" --enable-system --disable-linux-user \ %if 0%{?suse_version} >= 1130 %ifarch %ix86 x86_64 --enable-spice %else --disable-spice %endif %else --disable-spice %endif make %{?jobs:-j%jobs} V=1 mv *-softmmu/qemu-system-* dynamic mv qemu-io qemu-img qemu-nbd qemu-bridge-helper dynamic mv qemu-img.1 qemu-nbd.8 dynamic mv qemu-ga dynamic make clean # build userland emus ./configure --prefix=%_prefix --sysconfdir=%_sysconfdir \ --libexecdir=%_libexecdir \ --enable-linux-user \ --disable-system \ --static --disable-linux-aio \ --extra-cflags="$QEMU_OPT_FLAGS" %if 0%{?suse_version} == 1140 # -lrt needs to come after -lglib-2.0 to avoid undefined clock_gettime sed -i "s/-lglib-2.0/-lglib-2.0 -lrt/" config-host.mak %endif make %{?jobs:-j%jobs} V=1 %install make install DESTDIR=$RPM_BUILD_ROOT rm -fr $RPM_BUILD_ROOT/%_datadir/doc install -m 755 dynamic/qemu-system-* $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-io $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-img $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-nbd $RPM_BUILD_ROOT/%_bindir install -m 755 dynamic/qemu-ga $RPM_BUILD_ROOT/%_bindir install -d -m 755 $RPM_BUILD_ROOT/%_sbindir install -m 755 scripts/qemu-binfmt-conf.sh $RPM_BUILD_ROOT/%_sbindir install -d -m 755 $RPM_BUILD_ROOT/%_libexecdir install -m 755 dynamic/qemu-bridge-helper $RPM_BUILD_ROOT/%_libexecdir install -d -m 755 $RPM_BUILD_ROOT/%_mandir/man1 install -m 644 dynamic/qemu-img.1 $RPM_BUILD_ROOT/%_mandir/man1 install -d -m 755 $RPM_BUILD_ROOT/%_mandir/man8 install -m 644 dynamic/qemu-nbd.8 $RPM_BUILD_ROOT/%_mandir/man8 install -D -m 644 %{SOURCE302} $RPM_BUILD_ROOT/%{_sysconfdir}/qemu/bridge.conf %ifnarch %ix86 x86_64 ln -sf ../../../emul/ia32-linux $RPM_BUILD_ROOT/usr/share/qemu/qemu-i386 %endif %ifnarch ia64 mkdir -p $RPM_BUILD_ROOT/emul/ia32-linux %endif %fdupes -s $RPM_BUILD_ROOT %clean rm -rf ${RPM_BUILD_ROOT} %pre %{_bindir}/getent group kvm >/dev/null || %{_sbindir}/groupadd -r kvm 2>/dev/null %{_bindir}/getent group qemu >/dev/null || %{_sbindir}/groupadd -r qemu 2>/dev/null %{_bindir}/getent passwd qemu >/dev/null || \ %{_sbindir}/useradd -r -g qemu -G kvm -d / -s /sbin/nologin \ -c "qemu user" qemu %if 0%{?suse_version} >= 1130 %post tools %set_permissions %_libexecdir/qemu-bridge-helper %verifyscript tools %verify_permissions %_libexecdir/qemu-bridge-helper %endif %files %defattr(-, root, root) %doc COPYING COPYING.LIB Changelog README TODO VERSION qemu-doc.html qemu-tech.html %_bindir/qemu-system-* %doc %_mandir/man1/qemu.1.gz %_datadir/%name %ifnarch %ix86 x86_64 ia64 %dir /emul/ia32-linux %endif %dir %_sysconfdir/%name %config %_sysconfdir/%name/target-x86_64.conf %files tools %defattr(-, root, root) %doc %_mandir/man1/qemu-img.1.gz %doc %_mandir/man8/qemu-nbd.8.gz %_bindir/qemu-io %_bindir/qemu-img %_bindir/qemu-nbd %verify(not mode) %_libexecdir/qemu-bridge-helper %dir %_sysconfdir/%name %config %_sysconfdir/%name/bridge.conf %files guest-agent %defattr(-, root, root) %attr(755,root,kvm) %_bindir/qemu-ga %files linux-user %defattr(-, root, root) %_bindir/qemu-alpha %_bindir/qemu-arm %_bindir/qemu-armeb %_bindir/qemu-cris %_bindir/qemu-i386 %_bindir/qemu-m68k %_bindir/qemu-microblaze %_bindir/qemu-microblazeel %_bindir/qemu-mips %_bindir/qemu-mipsel %_bindir/qemu-mipsn32 %_bindir/qemu-mipsn32el %_bindir/qemu-ppc64abi32 %_bindir/qemu-ppc64 %_bindir/qemu-ppc %_bindir/qemu-s390x %_bindir/qemu-sh4 %_bindir/qemu-sh4eb %_bindir/qemu-sparc32plus %_bindir/qemu-sparc64 %_bindir/qemu-sparc %_bindir/qemu-unicore32 %_bindir/qemu-x86_64 %_bindir/qemu-*-binfmt %_sbindir/qemu-binfmt-conf.sh %changelog ++++++ rpmlintrc ++++++ # This line is mandatory to access the configuration functions from Config import * addFilter("arch-dependent-file-in-usr-share") ++++++ update_git.sh ++++++ #!/bin/bash -e # # While updating versions of QEMU to 1.0 I got fed up with the # quilt workflow and just put up a git tree that contains all # the commits on top of a stable tarball. # # When updating this package, just either update the git tree # below (use rebase!) or change the tree path and use your own # # That way we can easily rebase against the next stable release # when it comes. GIT_TREE=git://repo.or.cz/qemu/agraf.git GIT_LOCAL_TREE=/suse/agraf/git/qemu GIT_BRANCH=suse-1.1 GIT_UPSTREAM_TAG=v1.1.1 QEMU_TMP=/dev/shm/qemu-tmp # clean up if [ -e 0001-* ]; then osc rm --force 0* fi rm -f qemu.spec # fetch all patches rm -rf $QEMU_TMP OSCDIR="$(pwd)" if [ -d "$GIT_LOCAL_TREE" ]; then git clone -ls $GIT_LOCAL_TREE $QEMU_TMP cd $QEMU_TMP else git clone $GIT_TREE $QEMU_TMP cd $QEMU_TMP git remote add upstream git://git.qemu.org/qemu-stable-1.1.git git remote update fi git checkout $GIT_BRANCH git format-patch -N $GIT_UPSTREAM_TAG -o "$OSCDIR" cd "$OSCDIR" rm -rf $QEMU_TMP # cut off file name after 40 bytes, so we work around git version differences # while at it, also remove the signature for i in 0*; do PATCHNAME=${i%.patch} PATCHNAME=${i:0:40}.patch head -n $(expr $(wc -l $i | cut -d ' ' -f 1) - 3) $i > "$PATCHNAME.tmp" rm "$i" mv "$PATCHNAME.tmp" "$PATCHNAME" done # we have all patches as files now - generate the spec file! while IFS= read -r line; do if [ "$line" = "PATCH_FILES" ]; then for i in 0*; do NUM=${i%%-*} echo -e "Patch$NUM: $i" done elif [ "$line" = "PATCH_EXEC" ]; then for i in 0*; do NUM=${i%%-*} echo "%patch$NUM -p1" done else echo "$line" fi done < qemu.spec.in > qemu.spec osc add 0* -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de