1. 30 May, 2019 9 commits
    • Dave Martin's avatar
      arm64: Select SVE vector lengths via the command line · 67d17618
      Dave Martin authored
      
      
      In order to support use cases such as migration, it may be
      important in some situations to restrict the set of SVE vector
      lengths available to the guest.  It can also be useful to observe
      the behaviour of guest OSes with different vector lengths.
      
      To enable testing and experimentation for such configurations, this
      patch adds a command-line option to allow setting of the set of
      vector lengths to be made available to the guest.
      
      For now, the setting is global: no means is offered to configure
      individual guest vcpus independently of each other.
      
      By default all vector lengths that the host can support are given
      to the guest, as before.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      67d17618
    • Dave Martin's avatar
      arm64: Add SVE support · c83e481f
      Dave Martin authored
      
      
      This patch adds --enable-sve/--disable-sve command line options to
      allow the user to control whether the Scalable Vector Extension is
      made available to the guest.
      
      This requires use of the new KVM_ARM_VCPU_FINALIZE ioctl before the
      vcpu is runnable, so a new hook kvm_cpu__configure_features() is
      added to provide an appropriate place to do this work.
      
      By default, SVE is enabled for the guest if the host supports it.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      c83e481f
    • Dave Martin's avatar
      arm64: Make ptrauth enable/disable diagnostics more user-friendly · 748f9382
      Dave Martin authored
      
      
      To help the user understand what is going on, amend ptrauth
      configuration diagnostic messages to refer to command line options
      by the exact name used on the command line.
      
      Also, provide a clean diagnostic when ptrauth is requested, but not
      availble.  The generic "Unable to initialise vcpu" message is
      rather cryptic for this case.
      
      Since we now don't attempt to enable ptrauth at all unless KVM
      reports the relevant capabilities, remove the error message for
      that case too: in any case, we can't diagnose precisely why
      KVM_ARM_VCPU_INIT failed, so the message may be misleading.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      748f9382
    • Dave Martin's avatar
      arm/arm64: Factor out ptrauth vcpu feature setup · 3abc685d
      Dave Martin authored
      
      
      In the interest of readability, factor out the vcpu feature setup
      for ptrauth into a separate function.
      
      Also, because aarch32 doesn't have this feature or the related
      command line options anyway, move the actual code into aarch64/.
      
      Since ARM_VCPU_PTRAUTH_FEATURE is only there to make the ptrauth
      feature setup code compile on arm, it is no longer needed: inline
      and remove it.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      3abc685d
    • Amit Kachhap's avatar
      KVM: arm/arm64: Add a vcpu feature for pointer authentication · 8d953894
      Amit Kachhap authored
      
      
      This patch adds a runtime capabality for KVM tool to enable Arm64 8.3
      Pointer Authentication in guest kernel. Two vcpu features
      KVM_ARM_VCPU_PTRAUTH_[ADDRESS/GENERIC] are supplied together to enable
      Pointer Authentication in KVM guest after checking the capability.
      
      Command line options --enable-ptrauth and --disable-ptrauth are added
      to use this feature. However, if those options are not provided then
      also this feature is enabled if host supports this capability.
      
      The macros defined in the headers are not in sync and should be replaced
      from the upstream.
      Signed-off-by: Amit Kachhap's avatarAmit Daniel Kachhap <amit.kachhap@arm.com>
      Signed-off-by: Dave Martin <Dave.Martin@arm.com> [merge new kernel heaers]
      8d953894
    • Dave Martin's avatar
      update_headers: Sync kvm UAPI headers with linux v5.1-rc1 · 5f77ad1a
      Dave Martin authored
      
      
      Pull in upstream UAPI headers, for subsequent arm64 SVE / ptrauth
      support (among other things).
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      5f77ad1a
    • Dave Martin's avatar
      update_headers.sh: arm64: Copy sve_context.h if available · 92f6f495
      Dave Martin authored
      
      
      The SVE KVM support for arm64 includes the additional backend
      header <asm/sve_context.h> from <asm/kvm.h>.
      
      So update this header if it is available.
      
      To avoid creating a sudden dependency on a specific minimum kernel
      version, ignore the header if the source kernel tree doesn't have
      it.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      92f6f495
    • Dave Martin's avatar
      update_headers.sh: Cleanly report failure on error · 09a06c95
      Dave Martin authored
      
      
      If in intermediate step fails, update_headers.sh blindly continues
      and may return success status.
      
      To avoid errors going unnoticed when driving this script, exit and
      report failure status as soon as something goes wrong.  For good
      measure, also fail on expansion of undefined shell variables to aid
      future maintainers.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      09a06c95
    • Dave Martin's avatar
      update_headers.sh: Add missing shell quoting · 75e890ba
      Dave Martin authored
      
      
      update_headers.sh can break if the current working directory has a
      funny name or if something odd is passed for LINUX_ROOT.
      
      In the interest of cleanliness, quote where appropriate.
      Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
      75e890ba
  2. 29 May, 2019 4 commits
  3. 26 Apr, 2019 15 commits
  4. 11 Feb, 2019 1 commit
    • Andre Przywara's avatar
      arm: Auto-detect guest GIC type · c57e001a
      Andre Przywara authored
      
      
      At the moment kvmtool always tries to instantiate a virtual GICv2
      interrupt controller for the guest, and fails with some scary error
      message if that doesn't work.
      The user has then to manually specify "--irqchip=gicv3", which is not
      really obvious.
      With the advent of more GICv3-only machines, let's try to be more
      clever and implement some auto-detection of the GIC type needed:
      We try gicv3-its, gicv3, gicv2m and gicv2, in that order. The first one
      succeeding wins.
      For GICv2 machines the first two will always fail.
      On GICv3 machines offering GICv2 compatibility we used to prefer a
      virtual GICv2 in the guest, but these days the GICv3 support both in
      guests and in KVM is equally mature and wide-spread, so we should use
      the GICv3 emulation for the guest as well.
      
      This algorithm is in effect is there is no explicit --irqchip parameter
      on the command line. We still allow the GIC type to be set explicitly.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      c57e001a
  5. 08 Feb, 2019 8 commits
    • Andre Przywara's avatar
      net/dhcp: avoid misleading strncpy · 0796825e
      Andre Przywara authored
      
      
      The code for copying an empty IP address into the DHCP opt buffer used
      strncpy, however used the source length as the size argument. GCC 8.x
      complains about it.
      
      Since the source string is actually fixed, just revert to the old
      strcpy, which gives us actually the same level of security in this case,
      but makes the compiler happy.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      0796825e
    • Andre Przywara's avatar
      virtio: use strlcpy · 05755b29
      Andre Przywara authored
      
      
      GCC 8.x complains about improper usage of strncpy in virtio/net.c and
      virtio/scsi.c:
      In function 'virtio_scsi_init_one',
          inlined from 'virtio_scsi_init' at virtio/scsi.c:285:7:
      virtio/scsi.c:247:2: error: 'strncpy' specified bound 224 equals destination size [-Werror=stringop-truncation]
        strncpy((char *)&sdev->target.vhost_wwpn, disk->wwpn, sizeof(sdev->target.vhost_wwpn));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Fix this and the other occurences in virtio/ by using strlcpy instead
      of strncpy.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      05755b29
    • Andre Przywara's avatar
      builtin-run: Replace strncpy calls with strlcpy · 266a0ed4
      Andre Przywara authored
      
      
      There are two uses of strncpy in builtin-run.c, where we don't make
      proper use of strncpy, so that GCC 8.x complains and aborts compilation.
      
      Replace those two calls with strlcpy(), which does the right thing in
      our case.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      266a0ed4
    • Andre Przywara's avatar
      Makefile: support -s switch · 5eb1f27a
      Andre Przywara authored
      
      
      "make -s" suppresses normal output, just shows warnings and errors.
      But since we explicitly override the make output with our fancy concise
      version, we miss out on this feature.
      
      Do as the kernel does and explicitly suppress every normal output when -s
      is given. This helps to spot warnings that scroll out of the terminal
      window too quickly.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      5eb1f27a
    • Andre Przywara's avatar
      arm: fdt: add stdout-path to /chosen node · 56e45ea4
      Andre Przywara authored
      
      
      The DT spec describes the stdout-path property in the /chosen node to
      contain the DT path for a default device usable for outputting characters.
      The Linux kernel uses this for earlycon (without further parameters),
      other DT users might rely on this as well.
      
      Add a stdout-path property pointing to the "serial0" alias, then add an
      aliases node at the end of the FDT, containing the actual path. This
      allows the FDT generation code in hw/serial.c to set this string.
      
      Even when we use the virtio console, the serial console is still there
      and works, so we can expose this unconditionally. Putting the virtio
      console path in there will not work anyway.
      Signed-off-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      56e45ea4
    • Anisse Astier's avatar
      kvmtool: 9p: fix overapping snprintf · 04d604b6
      Anisse Astier authored
      
      
      GCC 8.2 gives this warning:
      
      virtio/9p.c: In function ‘virtio_p9_create’:
      virtio/9p.c:335:21: error: passing argument 1 to restrict-qualified parameter aliases with argument 4 [-Werror=restrict]
        ret = snprintf(dfid->path, size, "%s/%s", dfid->path, name);
                       ~~~~^~~~~~                 ~~~~~~~~~~
      
      Fix it by allocating a temporary string with dfid->path content instead
      of overwriting it in-place, which is limited in glibc snprintf with the
      __restrict qualifier.
      Reviewed-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarAnisse Astier <aastier@freebox.fr>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      04d604b6
    • Anisse Astier's avatar
      virtio: fix warning on strncpy · 16509081
      Anisse Astier authored
      
      
      GCC 8.2 gives this warning:
      
      virtio/net.c: In function ‘virtio_net__tap_init’:
      virtio/net.c:336:47: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
         strncpy(ifr.ifr_name, ndev->tap_name, sizeof(ndev->tap_name));
                                                     ^
      virtio/net.c:348:47: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
         strncpy(ifr.ifr_name, ndev->tap_name, sizeof(ndev->tap_name));
                                                     ^
      
      Fix it by using sizeof of destination instead, even if they're the same
      size in this case.
      Reviewed-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarAnisse Astier <aastier@freebox.fr>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      16509081
    • Anisse Astier's avatar
      builtin-run: Fix warning when resolving path · 96eda741
      Anisse Astier authored
      
      
      GCC 8.2 gives this warning:
      
      builtin-run.c: In function ‘kvm_run_write_sandbox_cmd.isra.1’:
      builtin-run.c:417:28: error: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4091 [-Werror=format-truncation=]
         snprintf(dst, len, "/host%s", resolved_path);
                                  ^~   ~~~~~~~~~~~~~
      
      It's because it understands that len is PATH_MAX, the same as
      resolved_path's size. This patch handles the case where the string is
      truncated, and fixes the warning.
      Reviewed-by: Andre Przywara's avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarAnisse Astier <aastier@freebox.fr>
      Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
      96eda741
  6. 01 Feb, 2019 3 commits