1. 07 6月, 2016 13 次提交
    • P
      linux-user: Fix race between multiple signals · 3d3efba0
      Peter Maydell 提交于
      If multiple host signals are received in quick succession they would
      be queued in TaskState then delivered to the guest in spite of
      signals being supposed to be blocked by the guest signal handler's
      sa_mask. Fix this by decoupling the guest signal mask from the
      host signal mask, so we can have protected sections where all
      host signals are blocked. In particular we block signals from
      when host_signal_handler() queues a signal from the guest until
      process_pending_signals() has unqueued it. We also block signals
      while we are manipulating the guest signal mask in emulation of
      sigprocmask and similar syscalls.
      
      Blocking host signals also ensures the correct behaviour with respect
      to multiple threads and the overrun count of timer related signals.
      Alas blocking and queuing in qemu is still needed because of virtual
      processor exceptions, SIGSEGV and SIGBUS.
      
      Blocking signals inside process_pending_signals() protects against
      concurrency problems that would otherwise happen if host_signal_handler()
      ran and accessed the signal data structures while process_pending_signals()
      was manipulating them.
      
      Since we now track the guest signal mask separately from that
      of the host, the sigsuspend system calls must track the signal
      mask passed to them, because when we process signals as we leave
      the sigsuspend the guest signal mask in force is that passed to
      sigsuspend.
      Signed-off-by: NTimothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
      Message-id: 1441497448-32489-19-git-send-email-T.E.Baldwin99@members.leeds.ac.uk
      [PMM: make signal_pending a simple flag rather than a word with two flag bits;
       ensure we don't call block_signals() twice in sigreturn codepaths;
       document and assert() the guarantee that using do_sigprocmask() to
       get the current mask never fails;  use the qemu atomics.h functions
       rather than raw volatile variable access; add extra commentary and
       documentation; block SIGSEGV/SIGBUS in block_signals() and in
       process_pending_signals() because they can't occur synchronously here;
       check the right do_sigprocmask() call for errors in ssetmask syscall;
       expand commit message; fixed sigsuspend() hanging]
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      3d3efba0
    • P
      linux-user: Use safe_syscall for sigsuspend syscalls · 2fe4fba1
      Peter Maydell 提交于
      Use the safe_syscall wrapper for sigsuspend syscalls. This
      means that we will definitely deliver a signal that arrives
      before we do the sigsuspend call, rather than blocking first
      and delivering afterwards.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      2fe4fba1
    • P
      linux-user: Define macro for size of host kernel sigset_t · b28a1f33
      Peter Maydell 提交于
      Some host syscalls take an argument specifying the size of a
      host kernel's sigset_t (which isn't necessarily the same as
      that of the host libc's type of that name). Instead of hardcoding
      _NSIG / 8 where we do this, define and use a SIGSET_T_SIZE macro.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      b28a1f33
    • P
      linux-user: Factor out uses of do_sigprocmask() from sigreturn code · 9eede5b6
      Peter Maydell 提交于
      All the architecture specific handlers for sigreturn include calls
      to do_sigprocmask(SIGSETMASK, &set, NULL) to set the signal mask
      from the uc_sigmask in the context being restored. Factor these
      out into calls to a set_sigmask() function. The next patch will
      want to add code which is not run when setting the signal mask
      via do_sigreturn, and this change allows us to separate the two
      cases.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      9eede5b6
    • P
      linux-user: Fix stray tab-indent · 7ec87e06
      Peter Maydell 提交于
      Fix a stray tab-indented linux in linux-user/signal.c.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      7ec87e06
    • P
      linux-user: Move handle_pending_signal() to avoid need for declaration · e902d588
      Peter Maydell 提交于
      Move the handle_pending_signal() function above process_pending_signals()
      to avoid the need for a forward declaration. (Whitespace only change.)
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      e902d588
    • P
      linux-user: Factor out handle_signal code from process_pending_signals() · eb552501
      Peter Maydell 提交于
      Factor out the code to handle a single signal from the
      process_pending_signals() function. The use of goto for flow control
      is OK currently, but would get significantly uglier if extended to
      allow running the handle_signal code multiple times.
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      eb552501
    • L
      linux-user: check if NETLINK_ROUTE is available · 575b22b1
      Laurent Vivier 提交于
      Some IFLA_* symbols can be missing in the host linux/if_link.h,
      but as they are enums and not "#defines", check in "configure" if
      last known  (IFLA_PROTO_DOWN) is available and if not, disable
      management of NETLINK_ROUTE protocol.
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      575b22b1
    • L
      linux-user: add netlink audit · 5ce9bb59
      Laurent Vivier 提交于
      This is, for instance, needed to log in a container.
      
      Without this, the user cannot be identified and the console login
      fails with "Login incorrect".
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      5ce9bb59
    • L
      linux-user: support netlink protocol NETLINK_KOBJECT_UEVENT · b265620b
      Laurent Vivier 提交于
      This is the protocol used by udevd to manage kernel events.
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      b265620b
    • L
      linux-user: add rtnetlink(7) support · 6c5b5645
      Laurent Vivier 提交于
      rtnetlink is needed to use iproute package (ip addr, ip route)
      and dhcp client.
      
      Examples:
      
      Without this patch:
          # ip link
          Cannot open netlink socket: Address family not supported by protocol
          # ip addr
          Cannot open netlink socket: Address family not supported by protocol
          # ip route
          Cannot open netlink socket: Address family not supported by protocol
          # dhclient eth0
          Cannot open netlink socket: Address family not supported by protocol
          Cannot open netlink socket: Address family not supported by protocol
      
      With this patch:
          # ip link
          1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
              link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
          51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT qlen 1000
              link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff
          # ip addr show eth0
          51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
              link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff
              inet 192.168.122.197/24 brd 192.168.122.255 scope global eth0
                 valid_lft forever preferred_lft forever
              inet6 fe80::216:3eff:fe89:6bd7/64 scope link
                 valid_lft forever preferred_lft forever
          # ip route
          default via 192.168.122.1 dev eth0
          192.168.122.0/24 dev eth0  proto kernel  scope link  src 192.168.122.197
          # ip addr flush eth0
          # ip addr add 192.168.122.10 dev eth0
          # ip addr show eth0
          51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
              link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff
              inet 192.168.122.10/32 scope global eth0
                 valid_lft forever preferred_lft forever
          # ip route add 192.168.122.0/24 via 192.168.122.10
          # ip route
              192.168.122.0/24 via 192.168.122.10 dev eth0
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      6c5b5645
    • L
      linux-user: Fix qemu-binfmt-conf.sh to store config across reboot · 3bef0451
      Laurent Vivier 提交于
      Original qemu-binfmt-conf.sh is only able to write configuration
      into /proc/sys/fs/binfmt_misc, and the configuration is lost on reboot.
      
      This script can configure debian and systemd services to restore
      configuration on reboot. Moreover, it is able to manage binfmt
      credential and to configure the path of the interpreter.
      
      List of supported CPU is:
      
      i386 i486 alpha arm sparc32plus ppc ppc64 ppc64le
      m68k mips mipsel mipsn32 mipsn32el mips64 mips64el
      sh4 sh4eb s390x aarch64
      
      Usage: qemu-binfmt-conf.sh [--qemu-path PATH][--debian][--systemd CPU]
                                 [--help][--credential yes|no][--exportdir PATH]
      
             Configure binfmt_misc to use qemu interpreter
      
             --help:       display this usage
             --qemu-path:  set path to qemu interpreter (/usr/local/bin)
             --debian:     don't write into /proc,
                           instead generate update-binfmts templates
             --systemd:    don't write into /proc,
                           instead generate file for systemd-binfmt.service
                           for the given CPU
             --exportdir:  define where to write configuration files
                           (default: /etc/binfmt.d or /usr/share/binfmts)
             --credential: if yes, credential an security tokens are
                           calculated according to the binary to interpret
      
          To import templates with update-binfmts, use :
      
              sudo update-binfmts --importdir /usr/share/binfmts --import qemu-CPU
      
          To remove interpreter, use :
      
              sudo update-binfmts --package qemu-CPU --remove qemu-CPU /usr/local/bin
      
          With systemd, binfmt files are loaded by systemd-binfmt.service
      
          The environment variable HOST_ARCH allows to override 'uname' to generate
          configuration files for a different architecture than the current one.
      Signed-off-by: NLaurent Vivier <laurent@vivier.eu>
      Reviewed-by: NAlexander Graf <agraf@suse.de>
      Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      3bef0451
    • P
      Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160606-1' into staging · 76462405
      Peter Maydell 提交于
      target-arm queue:
       * support instruction syndrome info for data aborts from A64 to EL2
       * add HSTR_EL2 register
       * fix incorrect ESR IL bits in various syndrome register cases
       * virt: fix limit of 64-bit ACPI/ECAM PCI MMIO range
       * gicv2: RAZ/WI non-sec access to sec interrupts
       * i2c: add aspeed i2c controller
       * virt: Reject gic-version=host for non-KVM (don't segv on aarch64 host)
       * xlnx-zynqmp: Add a secure prop to en/disable ARM Security Extensions
       * xlnx-zynqmp: Support KVM on AArch64 hosts
       * ptimer: Various fixes for awkward corner cases
       * char: QOMify various ARM UART models
       * char: get rid of qemu_char_get_next_serial
       * target-arm: Fix TTBR selecting logic on AArch32 Stage 2 translation
       * zynqmp: Add the ZCU102 board
      
      # gpg: Signature made Mon 06 Jun 2016 17:01:11 BST
      # gpg:                using RSA key 0x3C2525ED14360CDE
      # gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
      # gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
      # gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
      
      * remotes/pmaydell/tags/pull-target-arm-20160606-1: (25 commits)
        zynqmp: Add the ZCU102 board
        target-arm: Fix TTBR selecting logic on AArch32 Stage 2 translation
        char: get rid of qemu_char_get_next_serial
        hw/char: QOM'ify xilinx_uartlite model
        hw/char: QOM'ify stm32f2xx_usart model
        hw/char: QOM'ify digic-uart model
        hw/char: QOM'ify cadence_uart model
        hw/char: QOM'ify pl011 model
        hw/ptimer: Introduce ptimer_get_limit
        hw/ptimer: Support "on the fly" timer mode switch
        hw/ptimer: Update .delta on period/freq change
        hw/ptimer: Perform counter wrap around if timer already expired
        hw/ptimer: Fix issues caused by the adjusted timer limit value
        xlnx-zynqmp: Use the in kernel GIC model for KVM runs
        xlnx-zynqmp: Delay realization of GIC until post CPU realization
        xlnx-zynqmp: Make the RPU subsystem optional
        xlnx-zynqmp: Add a secure prop to en/disable ARM Security Extensions
        hw/arm/virt: Reject gic-version=host for non-KVM
        i2c: add aspeed i2c controller
        hw/intc/gic: RAZ/WI non-sec access to sec interrupts
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      76462405
  2. 06 6月, 2016 27 次提交