1. 19 4月, 2019 1 次提交
  2. 29 3月, 2019 13 次提交
    • D
      KVM: arm64/sve: Allow userspace to enable SVE for vcpus · 9a3cdf26
      Dave Martin 提交于
      Now that all the pieces are in place, this patch offers a new flag
      KVM_ARM_VCPU_SVE that userspace can pass to KVM_ARM_VCPU_INIT to
      turn on SVE for the guest, on a per-vcpu basis.
      
      As part of this, support for initialisation and reset of the SVE
      vector length set and registers is added in the appropriate places,
      as well as finally setting the KVM_ARM64_GUEST_HAS_SVE vcpu flag,
      to turn on the SVE support code.
      
      Allocation of the SVE register storage in vcpu->arch.sve_state is
      deferred until the SVE configuration is finalized, by which time
      the size of the registers is known.
      
      Setting the vector lengths supported by the vcpu is considered
      configuration of the emulated hardware rather than runtime
      configuration, so no support is offered for changing the vector
      lengths available to an existing vcpu across reset.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      9a3cdf26
    • D
      KVM: arm64/sve: Add pseudo-register for the guest's vector lengths · 9033bba4
      Dave Martin 提交于
      This patch adds a new pseudo-register KVM_REG_ARM64_SVE_VLS to
      allow userspace to set and query the set of vector lengths visible
      to the guest.
      
      In the future, multiple register slices per SVE register may be
      visible through the ioctl interface.  Once the set of slices has
      been determined we would not be able to allow the vector length set
      to be changed any more, in order to avoid userspace seeing
      inconsistent sets of registers.  For this reason, this patch adds
      support for explicit finalization of the SVE configuration via the
      KVM_ARM_VCPU_FINALIZE ioctl.
      
      Finalization is the proper place to allocate the SVE register state
      storage in vcpu->arch.sve_state, so this patch adds that as
      appropriate.  The data is freed via kvm_arch_vcpu_uninit(), which
      was previously a no-op on arm64.
      
      To simplify the logic for determining what vector lengths can be
      supported, some code is added to KVM init to work this out, in the
      kvm_arm_init_arch_resources() hook.
      
      The KVM_REG_ARM64_SVE_VLS pseudo-register is not exposed yet.
      Subsequent patches will allow SVE to be turned on for guest vcpus,
      making it visible.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      9033bba4
    • D
      KVM: arm/arm64: Add KVM_ARM_VCPU_FINALIZE ioctl · 7dd32a0d
      Dave Martin 提交于
      Some aspects of vcpu configuration may be too complex to be
      completed inside KVM_ARM_VCPU_INIT.  Thus, there may be a
      requirement for userspace to do some additional configuration
      before various other ioctls will work in a consistent way.
      
      In particular this will be the case for SVE, where userspace will
      need to negotiate the set of vector lengths to be made available to
      the guest before the vcpu becomes fully usable.
      
      In order to provide an explicit way for userspace to confirm that
      it has finished setting up a particular vcpu feature, this patch
      adds a new ioctl KVM_ARM_VCPU_FINALIZE.
      
      When userspace has opted into a feature that requires finalization,
      typically by means of a feature flag passed to KVM_ARM_VCPU_INIT, a
      matching call to KVM_ARM_VCPU_FINALIZE is now required before
      KVM_RUN or KVM_GET_REG_LIST is allowed.  Individual features may
      impose additional restrictions where appropriate.
      
      No existing vcpu features are affected by this, so current
      userspace implementations will continue to work exactly as before,
      with no need to issue KVM_ARM_VCPU_FINALIZE.
      
      As implemented in this patch, KVM_ARM_VCPU_FINALIZE is currently a
      placeholder: no finalizable features exist yet, so ioctl is not
      required and will always yield EINVAL.  Subsequent patches will add
      the finalization logic to make use of this ioctl for SVE.
      
      No functional change for existing userspace.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      7dd32a0d
    • D
      KVM: arm/arm64: Add hook for arch-specific KVM initialisation · 0f062bfe
      Dave Martin 提交于
      This patch adds a kvm_arm_init_arch_resources() hook to perform
      subarch-specific initialisation when starting up KVM.
      
      This will be used in a subsequent patch for global SVE-related
      setup on arm64.
      
      No functional change.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      0f062bfe
    • D
      arm64/sve: In-kernel vector length availability query interface · ead9e430
      Dave Martin 提交于
      KVM will need to interrogate the set of SVE vector lengths
      available on the system.
      
      This patch exposes the relevant bits to the kernel, along with a
      sve_vq_available() helper to check whether a particular vector
      length is supported.
      
      __vq_to_bit() and __bit_to_vq() are not intended for use outside
      these functions: now that these are exposed outside fpsimd.c, they
      are prefixed with __ in order to provide an extra hint that they
      are not intended for general-purpose use.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      ead9e430
    • D
      KVM: arm64/sve: Add SVE support to register access ioctl interface · e1c9c983
      Dave Martin 提交于
      This patch adds the following registers for access via the
      KVM_{GET,SET}_ONE_REG interface:
      
       * KVM_REG_ARM64_SVE_ZREG(n, i) (n = 0..31) (in 2048-bit slices)
       * KVM_REG_ARM64_SVE_PREG(n, i) (n = 0..15) (in 256-bit slices)
       * KVM_REG_ARM64_SVE_FFR(i) (in 256-bit slices)
      
      In order to adapt gracefully to future architectural extensions,
      the registers are logically divided up into slices as noted above:
      the i parameter denotes the slice index.
      
      This allows us to reserve space in the ABI for future expansion of
      these registers.  However, as of today the architecture does not
      permit registers to be larger than a single slice, so no code is
      needed in the kernel to expose additional slices, for now.  The
      code can be extended later as needed to expose them up to a maximum
      of 32 slices (as carved out in the architecture itself) if they
      really exist someday.
      
      The registers are only visible for vcpus that have SVE enabled.
      They are not enumerated by KVM_GET_REG_LIST on vcpus that do not
      have SVE.
      
      Accesses to the FPSIMD registers via KVM_REG_ARM_CORE is not
      allowed for SVE-enabled vcpus: SVE-aware userspace can use the
      KVM_REG_ARM64_SVE_ZREG() interface instead to access the same
      register state.  This avoids some complex and pointless emulation
      in the kernel to convert between the two views of these aliased
      registers.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      e1c9c983
    • D
      KVM: arm64/sve: Context switch the SVE registers · b43b5dd9
      Dave Martin 提交于
      In order to give each vcpu its own view of the SVE registers, this
      patch adds context storage via a new sve_state pointer in struct
      vcpu_arch.  An additional member sve_max_vl is also added for each
      vcpu, to determine the maximum vector length visible to the guest
      and thus the value to be configured in ZCR_EL2.LEN while the vcpu
      is active.  This also determines the layout and size of the storage
      in sve_state, which is read and written by the same backend
      functions that are used for context-switching the SVE state for
      host tasks.
      
      On SVE-enabled vcpus, SVE access traps are now handled by switching
      in the vcpu's SVE context and disabling the trap before returning
      to the guest.  On other vcpus, the trap is not handled and an exit
      back to the host occurs, where the handle_sve() fallback path
      reflects an undefined instruction exception back to the guest,
      consistently with the behaviour of non-SVE-capable hardware (as was
      done unconditionally prior to this patch).
      
      No SVE handling is added on non-VHE-only paths, since VHE is an
      architectural and Kconfig prerequisite of SVE.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      b43b5dd9
    • D
      KVM: arm64/sve: System register context switch and access support · 73433762
      Dave Martin 提交于
      This patch adds the necessary support for context switching ZCR_EL1
      for each vcpu.
      
      ZCR_EL1 is trapped alongside the FPSIMD/SVE registers, so it makes
      sense for it to be handled as part of the guest FPSIMD/SVE context
      for context switch purposes instead of handling it as a general
      system register.  This means that it can be switched in lazily at
      the appropriate time.  No effort is made to track host context for
      this register, since SVE requires VHE: thus the hosts's value for
      this register lives permanently in ZCR_EL2 and does not alias the
      guest's value at any time.
      
      The Hyp switch and fpsimd context handling code is extended
      appropriately.
      
      Accessors are added in sys_regs.c to expose the SVE system
      registers and ID register fields.  Because these need to be
      conditionally visible based on the guest configuration, they are
      implemented separately for now rather than by use of the generic
      system register helpers.  This may be abstracted better later on
      when/if there are more features requiring this model.
      
      ID_AA64ZFR0_EL1 is RO-RAZ for MRS/MSR when SVE is disabled for the
      guest, but for compatibility with non-SVE aware KVM implementations
      the register should not be enumerated at all for KVM_GET_REG_LIST
      in this case.  For consistency we also reject ioctl access to the
      register.  This ensures that a non-SVE-enabled guest looks the same
      to userspace, irrespective of whether the kernel KVM implementation
      supports SVE.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      73433762
    • D
      KVM: arm64: Add a vcpu flag to control SVE visibility for the guest · 1765edba
      Dave Martin 提交于
      Since SVE will be enabled or disabled on a per-vcpu basis, a flag
      is needed in order to track which vcpus have it enabled.
      
      This patch adds a suitable flag and a helper for checking it.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      1765edba
    • D
      arm64/sve: Enable SVE state tracking for non-task contexts · 04950674
      Dave Martin 提交于
      The current FPSIMD/SVE context handling support for non-task (i.e.,
      KVM vcpu) contexts does not take SVE into account.  This means that
      only task contexts can safely use SVE at present.
      
      In preparation for enabling KVM guests to use SVE, it is necessary
      to keep track of SVE state for non-task contexts too.
      
      This patch adds the necessary support, removing assumptions from
      the context switch code about the location of the SVE context
      storage.
      
      When binding a vcpu context, its vector length is arbitrarily
      specified as SVE_VL_MIN for now.  In any case, because TIF_SVE is
      presently cleared at vcpu context bind time, the specified vector
      length will not be used for anything yet.  In later patches TIF_SVE
      will be set here as appropriate, and the appropriate maximum vector
      length for the vcpu will be passed when binding.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: NJulien Grall <julien.grall@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      04950674
    • D
      arm64/sve: Check SVE virtualisability · d06b76be
      Dave Martin 提交于
      Due to the way the effective SVE vector length is controlled and
      trapped at different exception levels, certain mismatches in the
      sets of vector lengths supported by different physical CPUs in the
      system may prevent straightforward virtualisation of SVE at parity
      with the host.
      
      This patch analyses the extent to which SVE can be virtualised
      safely without interfering with migration of vcpus between physical
      CPUs, and rejects late secondary CPUs that would erode the
      situation further.
      
      It is left up to KVM to decide what to do with this information.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NJulien Thierry <julien.thierry@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      d06b76be
    • D
      KVM: arm64: Add missing #includes to kvm_host.h · 3f61f409
      Dave Martin 提交于
      kvm_host.h uses some declarations from other headers that are
      currently included by accident, without an explicit #include.
      
      This patch adds a few #includes that are clearly missing.  Although
      the header builds without them today, this should help to avoid
      future surprises.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      3f61f409
    • D
      KVM: arm64: Delete orphaned declaration for __fpsimd_enabled() · 38abf22e
      Dave Martin 提交于
      __fpsimd_enabled() no longer exists, but a dangling declaration has
      survived in kvm_hyp.h.
      
      This patch gets rid of it.
      Signed-off-by: NDave Martin <Dave.Martin@arm.com>
      Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
      Tested-by: Nzhang.lei <zhang.lei@jp.fujitsu.com>
      Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
      38abf22e
  3. 19 3月, 2019 2 次提交
  4. 17 3月, 2019 1 次提交
  5. 06 3月, 2019 2 次提交
  6. 05 3月, 2019 1 次提交
    • L
      get rid of legacy 'get_ds()' function · 736706be
      Linus Torvalds 提交于
      Every in-kernel use of this function defined it to KERNEL_DS (either as
      an actual define, or as an inline function).  It's an entirely
      historical artifact, and long long long ago used to actually read the
      segment selector valueof '%ds' on x86.
      
      Which in the kernel is always KERNEL_DS.
      
      Inspired by a patch from Jann Horn that just did this for a very small
      subset of users (the ones in fs/), along with Al who suggested a script.
      I then just took it to the logical extreme and removed all the remaining
      gunk.
      
      Roughly scripted with
      
         git grep -l '(get_ds())' -- :^tools/ | xargs sed -i 's/(get_ds())/(KERNEL_DS)/'
         git grep -lw 'get_ds' -- :^tools/ | xargs sed -i '/^#define get_ds()/d'
      
      plus manual fixups to remove a few unusual usage patterns, the couple of
      inline function cases and to fix up a comment that had become stale.
      
      The 'get_ds()' function remains in an x86 kvm selftest, since in user
      space it actually does something relevant.
      Inspired-by: NJann Horn <jannh@google.com>
      Inspired-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      736706be
  7. 01 3月, 2019 4 次提交
  8. 27 2月, 2019 2 次提交
  9. 20 2月, 2019 11 次提交
  10. 19 2月, 2019 1 次提交
    • Y
      asm-generic: Drop getrlimit and setrlimit syscalls from default list · 80d7da1c
      Yury Norov 提交于
      The newer prlimit64 syscall provides all the functionality of getrlimit
      and setrlimit syscalls and adds the pid of target process, so future
      architectures won't need to include getrlimit and setrlimit.
      
      Therefore drop getrlimit and setrlimit syscalls from the generic syscall
      list unless __ARCH_WANT_SET_GET_RLIMIT is defined by the architecture's
      unistd.h prior to including asm-generic/unistd.h, and adjust all
      architectures using the generic syscall list to define it so that no
      in-tree architectures are affected.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-hexagon@vger.kernel.org
      Cc: uclinux-h8-devel@lists.sourceforge.jp
      Signed-off-by: NYury Norov <ynorov@caviumnetworks.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Acked-by: Mark Salter <msalter@redhat.com> [c6x]
      Acked-by: James Hogan <james.hogan@imgtec.com> [metag]
      Acked-by: Ley Foon Tan <lftan@altera.com> [nios2]
      Acked-by: Stafford Horne <shorne@gmail.com> [openrisc]
      Acked-by: Will Deacon <will.deacon@arm.com> [arm64]
      Acked-by: Vineet Gupta <vgupta@synopsys.com> #arch/arc bits
      Signed-off-by: NYury Norov <ynorov@marvell.com>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      80d7da1c
  11. 18 2月, 2019 1 次提交
    • N
      arm64/neon: Disable -Wincompatible-pointer-types when building with Clang · 0738c8b5
      Nathan Chancellor 提交于
      After commit cc9f8349 ("arm64: crypto: add NEON accelerated XOR
      implementation"), Clang builds for arm64 started failing with the
      following error message.
      
      arch/arm64/lib/xor-neon.c:58:28: error: incompatible pointer types
      assigning to 'const unsigned long *' from 'uint64_t *' (aka 'unsigned
      long long *') [-Werror,-Wincompatible-pointer-types]
                      v3 = veorq_u64(vld1q_u64(dp1 +  6), vld1q_u64(dp2 + 6));
                                               ^~~~~~~~
      /usr/lib/llvm-9/lib/clang/9.0.0/include/arm_neon.h:7538:47: note:
      expanded from macro 'vld1q_u64'
        __ret = (uint64x2_t) __builtin_neon_vld1q_v(__p0, 51); \
                                                    ^~~~
      
      There has been quite a bit of debate and triage that has gone into
      figuring out what the proper fix is, viewable at the link below, which
      is still ongoing. Ard suggested disabling this warning with Clang with a
      pragma so no neon code will have this type of error. While this is not
      at all an ideal solution, this build error is the only thing preventing
      KernelCI from having successful arm64 defconfig and allmodconfig builds
      on linux-next. Getting continuous integration running is more important
      so new warnings/errors or boot failures can be caught and fixed quickly.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/283Suggested-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      0738c8b5
  12. 16 2月, 2019 1 次提交
    • A
      arm64, mm, efi: Account for GICv3 LPI tables in static memblock reserve table · 8a5b403d
      Ard Biesheuvel 提交于
      In the irqchip and EFI code, we have what basically amounts to a quirk
      to work around a peculiarity in the GICv3 architecture, which permits
      the system memory address of LPI tables to be programmable only once
      after a CPU reset. This means kexec kernels must use the same memory
      as the first kernel, and thus ensure that this memory has not been
      given out for other purposes by the time the ITS init code runs, which
      is not very early for secondary CPUs.
      
      On systems with many CPUs, these reservations could overflow the
      memblock reservation table, and this was addressed in commit:
      
        eff89628 ("efi/arm: Defer persistent reservations until after paging_init()")
      
      However, this turns out to have made things worse, since the allocation
      of page tables and heap space for the resized memblock reservation table
      itself may overwrite the regions we are attempting to reserve, which may
      cause all kinds of corruption, also considering that the ITS will still
      be poking bits into that memory in response to incoming MSIs.
      
      So instead, let's grow the static memblock reservation table on such
      systems so it can accommodate these reservations at an earlier time.
      This will permit us to revert the above commit in a subsequent patch.
      
      [ mingo: Minor cleanups. ]
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NMike Rapoport <rppt@linux.ibm.com>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Acked-by: NMarc Zyngier <marc.zyngier@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20190215123333.21209-2-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      8a5b403d