projects/linux·commit 752272f1

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

752272f1 · Linus Torvalds <[email protected]> · 2019-11-25 18:02:36 -08:00

Pull KVM updates from Paolo Bonzini:
 "ARM:
   - data abort report and injection
   - steal time support
   - GICv4 performance improvements
   - vgic ITS emulation fixes
   - simplify FWB handling
   - enable halt polling counters
   - make the emulated timer PREEMPT_RT compliant

  s390:
   - small fixes and cleanups
   - selftest improvements
   - yield improvements

  PPC:
   - add capability to tell userspace whether we can single-step the
     guest
   - improve the allocation of XIVE virtual processor IDs
   - rewrite interrupt synthesis code to deliver interrupts in virtual
     mode when appropriate.
   - minor cleanups and improvements.

  x86:
   - XSAVES support for AMD
   - more accurate report of nested guest TSC to the nested hypervisor
   - retpoline optimizations
   - support for nested 5-level page tables
   - PMU virtualization optimizations, and improved support for nested
     PMU virtualization
   - correct latching of INITs for nested virtualization
   - IOAPIC optimization
   - TSX_CTRL virtualization for more TAA happiness
   - improved allocation and flushing of SEV ASIDs
   - many bugfixes and cleanups"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (127 commits)
  kvm: nVMX: Relax guest IA32_FEATURE_CONTROL constraints
  KVM: x86: Grab KVM's srcu lock when setting nested state
  KVM: x86: Open code shared_msr_update() in its only caller
  KVM: Fix jump label out_free_* in kvm_init()
  KVM: x86: Remove a spurious export of a static function
  KVM: x86: create mmu/ subdirectory
  KVM: nVMX: Remove unnecessary TLB flushes on L1<->L2 switches when L1 use apic-access-page
  KVM: x86: remove set but not used variable 'called'
  KVM: nVMX: Do not mark vmcs02->apic_access_page as dirty when unpinning
  KVM: vmx: use MSR_IA32_TSX_CTRL to hard-disable TSX on guest that lack it
  KVM: vmx: implement MSR_IA32_TSX_CTRL disable RTM functionality
  KVM: x86: implement MSR_IA32_TSX_CTRL effect on CPUID
  KVM: x86: do not modify masked bits of shared MSRs
  KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES
  KVM: PPC: Book3S HV: XIVE: Fix potential page leak on error path
  KVM: PPC: Book3S HV: XIVE: Free previous EQ page when setting up a new one
  KVM: nVMX: Assume TLB entries of L1 and L2 are tagged differently if L0 use EPT
  KVM: x86: Unexport kvm_vcpu_reload_apic_access_page()
  KVM: nVMX: add CR4_LA57 bit to nested CR4_FIXED1
  KVM: nVMX: Use semi-colon instead of comma for exit-handlers initialization
  ...
Commit
752272f16dd18f2cac58a583a8673c8e2fb93abb
Parents
3f3c8be9 · 96710247

Merge commit. Changes below are compared with the first parent: 3f3c8be9.

Changes

110 files changed · +2593 −924

FileStatusAddDelContent
Documentation/admin-guide/kernel-parameters.txtmodified+3−3View file
Documentation/virt/kvm/api.txtmodified+57−1View file
Documentation/virt/kvm/arm/pvtime.rstadded+80−0View file
Documentation/virt/kvm/devices/vcpu.txtmodified+14−0View file
Documentation/virt/kvm/devices/xics.txtmodified+12−2View file
Documentation/virt/kvm/devices/xive.txtmodified+8−0View file
arch/arm/include/asm/kvm_arm.hmodified+1−0View file
arch/arm/include/asm/kvm_emulate.hmodified+7−2View file
arch/arm/include/asm/kvm_host.hmodified+33−0View file
arch/arm/include/uapi/asm/kvm.hmodified+2−1View file
arch/arm/kvm/Makefilemodified+1−1View file
arch/arm/kvm/guest.cmodified+14−0View file
arch/arm/kvm/handle_exit.cmodified+1−1View file
arch/arm/mm/proc-v7-bugs.cmodified+5−8View file
arch/arm64/include/asm/kvm_arm.hmodified+1−2View file
arch/arm64/include/asm/kvm_emulate.hmodified+23−3View file
arch/arm64/include/asm/kvm_host.hmodified+37−0View file
arch/arm64/include/asm/paravirt.hmodified+8−1View file
arch/arm64/include/asm/pvclock-abi.hadded+17−0View file
arch/arm64/include/uapi/asm/kvm.hmodified+4−1View file
arch/arm64/kernel/cpu_errata.cmodified+29−52View file
arch/arm64/kernel/paravirt.cmodified+140−0View file
arch/arm64/kernel/time.cmodified+3−0View file
arch/arm64/kvm/Kconfigmodified+4−0View file
arch/arm64/kvm/Makefilemodified+2−0View file
arch/arm64/kvm/guest.cmodified+23−0View file
arch/arm64/kvm/handle_exit.cmodified+2−2View file
arch/arm64/kvm/inject_fault.cmodified+2−2View file
arch/powerpc/include/asm/kvm_host.hmodified+0−1View file
arch/powerpc/include/asm/kvm_ppc.hmodified+1−0View file
arch/powerpc/include/asm/reg.hmodified+12−0View file
arch/powerpc/include/uapi/asm/kvm.hmodified+3−0View file
arch/powerpc/kvm/book3s.cmodified+1−26View file
arch/powerpc/kvm/book3s.hmodified+3−0View file
arch/powerpc/kvm/book3s_32_mmu.cmodified+0−6View file
arch/powerpc/kvm/book3s_64_mmu.cmodified+0−15View file
arch/powerpc/kvm/book3s_64_mmu_hv.cmodified+7−19View file
arch/powerpc/kvm/book3s_64_vio.cmodified+1−1View file
arch/powerpc/kvm/book3s_hv.cmodified+6−22View file
arch/powerpc/kvm/book3s_hv_builtin.cmodified+68−14View file
arch/powerpc/kvm/book3s_hv_nested.cmodified+1−1View file
arch/powerpc/kvm/book3s_pr.cmodified+39−1View file
arch/powerpc/kvm/book3s_xive.cmodified+101−27View file
arch/powerpc/kvm/book3s_xive.hmodified+5−0View file
arch/powerpc/kvm/book3s_xive_native.cmodified+42−40View file
arch/powerpc/kvm/e500_mmu_host.cmodified+3−3View file
arch/powerpc/kvm/powerpc.cmodified+2−0View file
arch/s390/include/asm/kvm_host.hmodified+1−0View file
arch/s390/kvm/diag.cmodified+18−4View file
arch/s390/kvm/interrupt.cmodified+2−3View file
arch/s390/kvm/kvm-s390.cmodified+8−11View file
arch/x86/events/intel/core.cmodified+11−0View file
arch/x86/include/asm/kvm_host.hmodified+26−6View file
arch/x86/kernel/kvm.cmodified+1−0View file
arch/x86/kvm/Makefilemodified+2−2View file
arch/x86/kvm/cpuid.cmodified+6−2View file
arch/x86/kvm/emulate.cmodified+2−4View file
arch/x86/kvm/ioapic.cmodified+32−2View file
arch/x86/kvm/kvm_cache_regs.hmodified+39−12View file
arch/x86/kvm/lapic.cmodified+74−37View file
arch/x86/kvm/lapic.hmodified+3−0View file
arch/x86/kvm/mmu.c → arch/x86/kvm/mmu/mmu.crenamed+1−1View file
arch/x86/kvm/page_track.c → arch/x86/kvm/mmu/page_track.crenamed+0−0View file
arch/x86/kvm/paging_tmpl.h → arch/x86/kvm/mmu/paging_tmpl.hrenamed+0−0View file
arch/x86/kvm/pmu.cmodified+108−16View file
arch/x86/kvm/pmu.hmodified+23−6View file
arch/x86/kvm/pmu_amd.cmodified+17−7View file
arch/x86/kvm/svm.cmodified+105−35View file
arch/x86/kvm/vmx/nested.cmodified+203−49View file
arch/x86/kvm/vmx/nested.hmodified+5−4View file
arch/x86/kvm/vmx/pmu_intel.cmodified+29−5View file
arch/x86/kvm/vmx/vmx.cmodified+182−157View file
arch/x86/kvm/vmx/vmx.hmodified+10−2View file
arch/x86/kvm/x86.cmodified+145−99View file
arch/x86/kvm/x86.hmodified+9−6View file
drivers/crypto/ccp/psp-dev.cmodified+9−0View file
drivers/irqchip/irq-gic-v4.cmodified+6−1View file
include/Kbuildmodified+2−0View file
include/kvm/arm_hypercalls.hadded+43−0View file
include/kvm/arm_psci.hmodified+1−1View file
include/kvm/arm_vgic.hmodified+3−5View file
include/linux/arm-smccc.hmodified+59−0View file
include/linux/cpuhotplug.hmodified+1−0View file
include/linux/irqchip/arm-gic-v4.hmodified+4−0View file
include/linux/kvm_host.hmodified+30−11View file
include/linux/kvm_types.hmodified+2−0View file
include/linux/perf_event.hmodified+10−0View file
include/uapi/linux/kvm.hmodified+11−0View file
kernel/events/core.cmodified+39−7View file
tools/testing/selftests/kvm/.gitignoremodified+1−0View file
tools/testing/selftests/kvm/Makefilemodified+1−0View file
tools/testing/selftests/kvm/include/x86_64/processor.hmodified+6−1View file
tools/testing/selftests/kvm/kvm_create_max_vcpus.cmodified+2−5View file
tools/testing/selftests/kvm/lib/x86_64/processor.cmodified+63−9View file
tools/testing/selftests/kvm/s390x/sync_regs_test.cmodified+9−6View file
tools/testing/selftests/kvm/x86_64/xss_msr_test.cadded+76−0View file
virt/kvm/arm/arch_timer.cmodified+4−4View file
virt/kvm/arm/arm.cmodified+43−6View file
virt/kvm/arm/hypercalls.cadded+71−0View file
virt/kvm/arm/mmio.cmodified+8−1View file
virt/kvm/arm/psci.cmodified+2−82View file
virt/kvm/arm/pvtime.cadded+131−0View file
virt/kvm/arm/vgic/vgic-init.cmodified+1−0View file
virt/kvm/arm/vgic/vgic-its.cmodified+3−0View file
virt/kvm/arm/vgic/vgic-v3.cmodified+8−4View file
virt/kvm/arm/vgic/vgic-v4.cmodified+29−30View file
virt/kvm/arm/vgic/vgic.cmodified+0−4View file
virt/kvm/arm/vgic/vgic.hmodified+0−2View file
virt/kvm/coalesced_mmio.cmodified+2−6View file
virt/kvm/kvm_main.cmodified+23−11View file

Only the first 600 diff lines are shown. Download the complete patch.

Documentation/admin-guide/kernel-parameters.txt

View file
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 8dee8f6..9b847f0 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3110,9 +3110,9 @@
[X86,PV_OPS] Disable paravirtualized VMware scheduler
clock and use the default one.
- no-steal-acc [X86,KVM] Disable paravirtualized steal time accounting.
- steal time is computed, but won't influence scheduler
- behaviour
+ no-steal-acc [X86,KVM,ARM64] Disable paravirtualized steal time
+ accounting. steal time is computed, but won't
+ influence scheduler behaviour
nolapic [X86-32,APIC] Do not enable or use the local APIC.

Documentation/virt/kvm/api.txt

View file
diff --git a/Documentation/virt/kvm/api.txt b/Documentation/virt/kvm/api.txt
index 4833904..49183ad 100644
--- a/Documentation/virt/kvm/api.txt
+++ b/Documentation/virt/kvm/api.txt
@@ -1002,12 +1002,18 @@ Specifying exception.has_esr on a system that does not support it will return
-EINVAL. Setting anything other than the lower 24bits of exception.serror_esr
will return -EINVAL.
+It is not possible to read back a pending external abort (injected via
+KVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered
+directly to the virtual CPU).
+
+
struct kvm_vcpu_events {
struct {
__u8 serror_pending;
__u8 serror_has_esr;
+ __u8 ext_dabt_pending;
/* Align it to 8 bytes */
- __u8 pad[6];
+ __u8 pad[5];
__u64 serror_esr;
} exception;
__u32 reserved[12];
@@ -1051,9 +1057,23 @@ contain a valid state and shall be written into the VCPU.
ARM/ARM64:
+User space may need to inject several types of events to the guest.
+
Set the pending SError exception state for this VCPU. It is not possible to
'cancel' an Serror that has been made pending.
+If the guest performed an access to I/O memory which could not be handled by
+userspace, for example because of missing instruction syndrome decode
+information or because there is no device mapped at the accessed IPA, then
+userspace can ask the kernel to inject an external abort using the address
+from the exiting fault on the VCPU. It is a programming error to set
+ext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or
+KVM_EXIT_ARM_NISV. This feature is only available if the system supports
+KVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in
+how userspace reports accesses for the above cases to guests, across different
+userspace implementations. Nevertheless, userspace can still emulate all Arm
+exceptions by manipulating individual registers using the KVM_SET_ONE_REG API.
+
See KVM_GET_VCPU_EVENTS for the data structure.
@@ -2982,6 +3002,9 @@ can be determined by querying the KVM_CAP_GUEST_DEBUG_HW_BPS and
KVM_CAP_GUEST_DEBUG_HW_WPS capabilities which return a positive number
indicating the number of supported registers.
+For ppc, the KVM_CAP_PPC_GUEST_DEBUG_SSTEP capability indicates whether
+the single-step debug event (KVM_GUESTDBG_SINGLESTEP) is supported.
+
When debug events exit the main run loop with the reason
KVM_EXIT_DEBUG with the kvm_debug_exit_arch part of the kvm_run
structure containing architecture specific debug information.
@@ -4468,6 +4491,39 @@ Hyper-V SynIC state change. Notification is used to remap SynIC
event/message pages and to enable/disable SynIC messages/events processing
in userspace.
+ /* KVM_EXIT_ARM_NISV */
+ struct {
+ __u64 esr_iss;
+ __u64 fault_ipa;
+ } arm_nisv;
+
+Used on arm and arm64 systems. If a guest accesses memory not in a memslot,
+KVM will typically return to userspace and ask it to do MMIO emulation on its
+behalf. However, for certain classes of instructions, no instruction decode
+(direction, length of memory access) is provided, and fetching and decoding
+the instruction from the VM is overly complicated to live in the kernel.
+
+Historically, when this situation occurred, KVM would print a warning and kill
+the VM. KVM assumed that if the guest accessed non-memslot memory, it was
+trying to do I/O, which just couldn't be emulated, and the warning message was
+phrased accordingly. However, what happened more often was that a guest bug
+caused access outside the guest memory areas which should lead to a more
+meaningful warning message and an external abort in the guest, if the access
+did not fall within an I/O window.
+
+Userspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable
+this capability at VM creation. Once this is done, these types of errors will
+instead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from
+the HSR (arm) and ESR_EL2 (arm64) in the esr_iss field, and the faulting IPA
+in the fault_ipa field. Userspace can either fix up the access if it's
+actually an I/O access by decoding the instruction from guest memory (if it's
+very brave) and continue executing the guest, or it can decide to suspend,
+dump, or restart the guest.
+
+Note that KVM does not skip the faulting instruction as it does for
+KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
+if it decides to decode and emulate the instruction.
+
/* Fix the size of the union. */
char padding[256];
};

Documentation/virt/kvm/arm/pvtime.rst

View file
diff --git a/Documentation/virt/kvm/arm/pvtime.rst b/Documentation/virt/kvm/arm/pvtime.rst
new file mode 100644
index 0000000..2357dd2
--- /dev/null
+++ b/Documentation/virt/kvm/arm/pvtime.rst
@@ -0,0 +1,80 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Paravirtualized time support for arm64
+======================================
+
+Arm specification DEN0057/A defines a standard for paravirtualised time
+support for AArch64 guests:
+
+https://developer.arm.com/docs/den0057/a
+
+KVM/arm64 implements the stolen time part of this specification by providing
+some hypervisor service calls to support a paravirtualized guest obtaining a
+view of the amount of time stolen from its execution.
+
+Two new SMCCC compatible hypercalls are defined:
+
+* PV_TIME_FEATURES: 0xC5000020
+* PV_TIME_ST: 0xC5000021
+
+These are only available in the SMC64/HVC64 calling convention as
+paravirtualized time is not available to 32 bit Arm guests. The existence of
+the PV_FEATURES hypercall should be probed using the SMCCC 1.1 ARCH_FEATURES
+mechanism before calling it.
+
+PV_TIME_FEATURES
+ ============= ======== ==========
+ Function ID: (uint32) 0xC5000020
+ PV_call_id: (uint32) The function to query for support.
+ Currently only PV_TIME_ST is supported.
+ Return value: (int64) NOT_SUPPORTED (-1) or SUCCESS (0) if the relevant
+ PV-time feature is supported by the hypervisor.
+ ============= ======== ==========
+
+PV_TIME_ST
+ ============= ======== ==========
+ Function ID: (uint32) 0xC5000021
+ Return value: (int64) IPA of the stolen time data structure for this
+ VCPU. On failure:
+ NOT_SUPPORTED (-1)
+ ============= ======== ==========
+
+The IPA returned by PV_TIME_ST should be mapped by the guest as normal memory
+with inner and outer write back caching attributes, in the inner shareable
+domain. A total of 16 bytes from the IPA returned are guaranteed to be
+meaningfully filled by the hypervisor (see structure below).
+
+PV_TIME_ST returns the structure for the calling VCPU.
+
+Stolen Time
+-----------
+
+The structure pointed to by the PV_TIME_ST hypercall is as follows:
+
++-------------+-------------+-------------+----------------------------+
+| Field | Byte Length | Byte Offset | Description |
++=============+=============+=============+============================+
+| Revision | 4 | 0 | Must be 0 for version 1.0 |
++-------------+-------------+-------------+----------------------------+
+| Attributes | 4 | 4 | Must be 0 |
++-------------+-------------+-------------+----------------------------+
+| Stolen time | 8 | 8 | Stolen time in unsigned |
+| | | | nanoseconds indicating how |
+| | | | much time this VCPU thread |
+| | | | was involuntarily not |
+| | | | running on a physical CPU. |
++-------------+-------------+-------------+----------------------------+
+
+All values in the structure are stored little-endian.
+
+The structure will be updated by the hypervisor prior to scheduling a VCPU. It
+will be present within a reserved region of the normal memory given to the
+guest. The guest should not attempt to write into this memory. There is a
+structure per VCPU of the guest.
+
+It is advisable that one or more 64k pages are set aside for the purpose of
+these structures and not used for other purposes, this enables the guest to map
+the region using 64k pages and avoids conflicting attributes with other memory.
+
+For the user space interface see Documentation/virt/kvm/devices/vcpu.txt
+section "3. GROUP: KVM_ARM_VCPU_PVTIME_CTRL".

Documentation/virt/kvm/devices/vcpu.txt

View file
diff --git a/Documentation/virt/kvm/devices/vcpu.txt b/Documentation/virt/kvm/devices/vcpu.txt
index 2b5dab1..6f3bd64 100644
--- a/Documentation/virt/kvm/devices/vcpu.txt
+++ b/Documentation/virt/kvm/devices/vcpu.txt
@@ -60,3 +60,17 @@ time to use the number provided for a given timer, overwriting any previously
configured values on other VCPUs. Userspace should configure the interrupt
numbers on at least one VCPU after creating all VCPUs and before running any
VCPUs.
+
+3. GROUP: KVM_ARM_VCPU_PVTIME_CTRL
+Architectures: ARM64
+
+3.1 ATTRIBUTE: KVM_ARM_VCPU_PVTIME_IPA
+Parameters: 64-bit base address
+Returns: -ENXIO: Stolen time not implemented
+ -EEXIST: Base address already set for this VCPU
+ -EINVAL: Base address not 64 byte aligned
+
+Specifies the base address of the stolen time structure for this VCPU. The
+base address must be 64 byte aligned and exist within a valid guest memory
+region. See Documentation/virt/kvm/arm/pvtime.txt for more information
+including the layout of the stolen time structure.

Documentation/virt/kvm/devices/xics.txt

View file
diff --git a/Documentation/virt/kvm/devices/xics.txt b/Documentation/virt/kvm/devices/xics.txt
index 4286493..423332d 100644
--- a/Documentation/virt/kvm/devices/xics.txt
+++ b/Documentation/virt/kvm/devices/xics.txt
@@ -3,9 +3,19 @@ XICS interrupt controller
Device type supported: KVM_DEV_TYPE_XICS
Groups:
- KVM_DEV_XICS_SOURCES
+ 1. KVM_DEV_XICS_GRP_SOURCES
Attributes: One per interrupt source, indexed by the source number.
+ 2. KVM_DEV_XICS_GRP_CTRL
+ Attributes:
+ 2.1 KVM_DEV_XICS_NR_SERVERS (write only)
+ The kvm_device_attr.addr points to a __u32 value which is the number of
+ interrupt server numbers (ie, highest possible vcpu id plus one).
+ Errors:
+ -EINVAL: Value greater than KVM_MAX_VCPU_ID.
+ -EFAULT: Invalid user pointer for attr->addr.
+ -EBUSY: A vcpu is already connected to the device.
+
This device emulates the XICS (eXternal Interrupt Controller
Specification) defined in PAPR. The XICS has a set of interrupt
sources, each identified by a 20-bit source number, and a set of
@@ -38,7 +48,7 @@ least-significant end of the word:
Each source has 64 bits of state that can be read and written using
the KVM_GET_DEVICE_ATTR and KVM_SET_DEVICE_ATTR ioctls, specifying the
-KVM_DEV_XICS_SOURCES attribute group, with the attribute number being
+KVM_DEV_XICS_GRP_SOURCES attribute group, with the attribute number being
the interrupt source number. The 64 bit state word has the following
bitfields, starting from the least-significant end of the word:

Documentation/virt/kvm/devices/xive.txt

View file
diff --git a/Documentation/virt/kvm/devices/xive.txt b/Documentation/virt/kvm/devices/xive.txt
index 9a24a45..f5d1d6b 100644
--- a/Documentation/virt/kvm/devices/xive.txt
+++ b/Documentation/virt/kvm/devices/xive.txt
@@ -78,6 +78,14 @@ the legacy interrupt mode, referred as XICS (POWER7/8).
migrating the VM.
Errors: none
+ 1.3 KVM_DEV_XIVE_NR_SERVERS (write only)
+ The kvm_device_attr.addr points to a __u32 value which is the number of
+ interrupt server numbers (ie, highest possible vcpu id plus one).
+ Errors:
+ -EINVAL: Value greater than KVM_MAX_VCPU_ID.
+ -EFAULT: Invalid user pointer for attr->addr.
+ -EBUSY: A vCPU is already connected to the device.
+
2. KVM_DEV_XIVE_GRP_SOURCE (write only)
Initializes a new source in the XIVE device and mask it.
Attributes:

arch/arm/include/asm/kvm_arm.h

View file
diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h
index 0125aa0..9c04bd8 100644
--- a/arch/arm/include/asm/kvm_arm.h
+++ b/arch/arm/include/asm/kvm_arm.h
@@ -162,6 +162,7 @@
#define HSR_ISV (_AC(1, UL) << HSR_ISV_SHIFT)
#define HSR_SRT_SHIFT (16)
#define HSR_SRT_MASK (0xf << HSR_SRT_SHIFT)
+#define HSR_CM (1 << 8)
#define HSR_FSC (0x3f)
#define HSR_FSC_TYPE (0x3c)
#define HSR_SSE (1 << 21)

arch/arm/include/asm/kvm_emulate.h

View file
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index 4000241..9b11851 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -95,12 +95,12 @@ static inline unsigned long *vcpu_hcr(const struct kvm_vcpu *vcpu)
return (unsigned long *)&vcpu->arch.hcr;
}
-static inline void vcpu_clear_wfe_traps(struct kvm_vcpu *vcpu)
+static inline void vcpu_clear_wfx_traps(struct kvm_vcpu *vcpu)
{
vcpu->arch.hcr &= ~HCR_TWE;
}
-static inline void vcpu_set_wfe_traps(struct kvm_vcpu *vcpu)
+static inline void vcpu_set_wfx_traps(struct kvm_vcpu *vcpu)
{
vcpu->arch.hcr |= HCR_TWE;
}
@@ -167,6 +167,11 @@ static inline bool kvm_vcpu_dabt_isvalid(struct kvm_vcpu *vcpu)
return kvm_vcpu_get_hsr(vcpu) & HSR_ISV;
}
+static inline unsigned long kvm_vcpu_dabt_iss_nisv_sanitized(const struct kvm_vcpu *vcpu)
+{
+ return kvm_vcpu_get_hsr(vcpu) & (HSR_CM | HSR_WNR | HSR_FSC);
+}
+
static inline bool kvm_vcpu_dabt_iswrite(struct kvm_vcpu *vcpu)
{
return kvm_vcpu_get_hsr(vcpu) & HSR_WNR;

arch/arm/include/asm/kvm_host.h

View file
diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 8a37c8e..556cd81 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -7,6 +7,7 @@
#ifndef __ARM_KVM_HOST_H__
#define __ARM_KVM_HOST_H__
+#include <linux/arm-smccc.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/kvm_types.h>
@@ -38,6 +39,7 @@
KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
#define KVM_REQ_IRQ_PENDING KVM_ARCH_REQ(1)
#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(2)
+#define KVM_REQ_RECORD_STEAL KVM_ARCH_REQ(3)
DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use);
@@ -76,6 +78,14 @@ struct kvm_arch {
/* Mandated version of PSCI */
u32 psci_version;
+
+ /*
+ * If we encounter a data abort without valid instruction syndrome
+ * information, report this to user space. User space can (and
+ * should) opt in to this feature if KVM_CAP_ARM_NISV_TO_USER is
+ * supported.
+ */
+ bool return_nisv_io_abort_to_user;
};
#define KVM_NR_MEM_OBJS 40
@@ -323,6 +333,29 @@ static inline int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext)
int kvm_perf_init(void);
int kvm_perf_teardown(void);
+static inline long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
+{
+ return SMCCC_RET_NOT_SUPPORTED;
+}
+
+static inline gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
+{
+ return GPA_INVALID;
+}
+
+static inline void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
+{
+}
+
+static inline void kvm_arm_pvtime_vcpu_init(struct kvm_vcpu_arch *vcpu_arch)
+{
+}
+
+static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch)
+{
+ return false;
+}
+
void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);

arch/arm/include/uapi/asm/kvm.h

View file
diff --git a/arch/arm/include/uapi/asm/kvm.h b/arch/arm/include/uapi/asm/kvm.h
index 2769360..03cd7c1 100644
--- a/arch/arm/include/uapi/asm/kvm.h
+++ b/arch/arm/include/uapi/asm/kvm.h
@@ -131,8 +131,9 @@ struct kvm_vcpu_events {
struct {
__u8 serror_pending;
__u8 serror_has_esr;
+ __u8 ext_dabt_pending;
/* Align it to 8 bytes */
- __u8 pad[6];
+ __u8 pad[5];
__u64 serror_esr;
} exception;
__u32 reserved[12];

arch/arm/kvm/Makefile

View file
diff --git a/arch/arm/kvm/Makefile b/arch/arm/kvm/Makefile
index b76b75b..e442d82 100644
--- a/arch/arm/kvm/Makefile
+++ b/arch/arm/kvm/Makefile
@@ -24,7 +24,7 @@ obj-y += kvm-arm.o init.o interrupts.o
obj-y += handle_exit.o guest.o emulate.o reset.o
obj-y += coproc.o coproc_a15.o coproc_a7.o vgic-v3-coproc.o
obj-y += $(KVM)/arm/arm.o $(KVM)/arm/mmu.o $(KVM)/arm/mmio.o
-obj-y += $(KVM)/arm/psci.o $(KVM)/arm/perf.o
+obj-y += $(KVM)/arm/psci.o $(KVM)/arm/perf.o $(KVM)/arm/hypercalls.o
obj-y += $(KVM)/arm/aarch32.o
obj-y += $(KVM)/arm/vgic/vgic.o

arch/arm/kvm/guest.c

View file
diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c
index 684cf64..0e6f235 100644
--- a/arch/arm/kvm/guest.c
+++ b/arch/arm/kvm/guest.c
@@ -21,6 +21,10 @@
#define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU }
struct kvm_stats_debugfs_item debugfs_entries[] = {
+ VCPU_STAT(halt_successful_poll),
+ VCPU_STAT(halt_attempted_poll),
+ VCPU_STAT(halt_poll_invalid),
+ VCPU_STAT(halt_wakeup),
VCPU_STAT(hvc_exit_stat),
VCPU_STAT(wfe_exit_stat),
VCPU_STAT(wfi_exit_stat),
@@ -255,6 +259,12 @@ int __kvm_arm_vcpu_get_events(struct kvm_vcpu *vcpu,
{
events->exception.serror_pending = !!(*vcpu_hcr(vcpu) & HCR_VA);
+ /*
+ * We never return a pending ext_dabt here because we deliver it to
+ * the virtual CPU directly when setting the event and it's no longer
+ * 'pending' at this point.
+ */
+
return 0;
}
@@ -263,12 +273,16 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
{
bool serror_pending = events->exception.serror_pending;
bool has_esr = events->exception.serror_has_esr;
+ bool ext_dabt_pending = events->exception.ext_dabt_pending;
if (serror_pending && has_esr)
return -EINVAL;
else if (serror_pending)
kvm_inject_vabt(vcpu);
+ if (ext_dabt_pending)
+ kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
+
return 0;
}

arch/arm/kvm/handle_exit.c

View file
diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c
index 2a6a139..e58a89d 100644
--- a/arch/arm/kvm/handle_exit.c
+++ b/arch/arm/kvm/handle_exit.c
@@ -9,7 +9,7 @@
#include <asm/kvm_emulate.h>
#include <asm/kvm_coproc.h>
#include <asm/kvm_mmu.h>
-#include <kvm/arm_psci.h>
+#include <kvm/arm_hypercalls.h>
#include <trace/events/kvm.h>
#include "trace.h"

arch/arm/mm/proc-v7-bugs.c

View file
diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c
index 54d8750..7c90b4c 100644
--- a/arch/arm/mm/proc-v7-bugs.c
+++ b/arch/arm/mm/proc-v7-bugs.c
@@ -74,12 +74,13 @@ static void cpu_v7_spectre_init(void)
case ARM_CPU_PART_CORTEX_A72: {
struct arm_smccc_res res;
+ arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+ ARM_SMCCC_ARCH_WORKAROUND_1, &res);
+ if ((int)res.a0 != 0)
+ return;
+
switch (arm_smccc_1_1_get_conduit()) {
case SMCCC_CONDUIT_HVC:
- arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 != 0)
- break;
per_cpu(harden_branch_predictor_fn, cpu) =
call_hvc_arch_workaround_1;
cpu_do_switch_mm = cpu_v7_hvc_switch_mm;
@@ -87,10 +88,6 @@ static void cpu_v7_spectre_init(void)
break;
case SMCCC_CONDUIT_SMC:
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 != 0)
- break;
per_cpu(harden_branch_predictor_fn, cpu) =
call_smc_arch_workaround_1;
cpu_do_switch_mm = cpu_v7_smc_switch_mm;

arch/arm64/include/asm/kvm_arm.h

View file
diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
index ddf9d76..6e5d839 100644
--- a/arch/arm64/include/asm/kvm_arm.h
+++ b/arch/arm64/include/asm/kvm_arm.h
@@ -61,7 +61,6 @@
* RW: 64bit by default, can be overridden for 32bit VMs
* TAC: Trap ACTLR
* TSC: Trap SMC
- * TVM: Trap VM ops (until M+C set in SCTLR_EL1)
* TSW: Trap cache operations by set/way
* TWE: Trap WFE
* TWI: Trap WFI
@@ -74,7 +73,7 @@
* SWIO: Turn set/way invalidates into set/way clean+invalidate
*/
#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
- HCR_TVM | HCR_BSU_IS | HCR_FB | HCR_TAC | \
+ HCR_BSU_IS | HCR_FB | HCR_TAC | \
HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
HCR_FMO | HCR_IMO)
#define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF)

arch/arm64/include/asm/kvm_emulate.h

View file
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index d69c1ef..5efe5ca 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -53,8 +53,18 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
/* trap error record accesses */
vcpu->arch.hcr_el2 |= HCR_TERR;
}
- if (cpus_have_const_cap(ARM64_HAS_STAGE2_FWB))
+
+ if (cpus_have_const_cap(ARM64_HAS_STAGE2_FWB)) {
vcpu->arch.hcr_el2 |= HCR_FWB;
+ } else {
+ /*
+ * For non-FWB CPUs, we trap VM ops (HCR_EL2.TVM) until M+C
+ * get set in SCTLR_EL1 such that we can detect when the guest
+ * MMU gets turned on and do the necessary cache maintenance
+ * then.
+ */
+ vcpu->arch.hcr_el2 |= HCR_TVM;
+ }
if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features))
vcpu->arch.hcr_el2 &= ~HCR_RW;
@@ -77,14 +87,19 @@ static inline unsigned long *vcpu_hcr(struct kvm_vcpu *vcpu)
return (unsigned long *)&vcpu->arch.hcr_el2;
}
-static inline void vcpu_clear_wfe_traps(struct kvm_vcpu *vcpu)
+static inline void vcpu_clear_wfx_traps(struct kvm_vcpu *vcpu)
{
vcpu->arch.hcr_el2 &= ~HCR_TWE;
+ if (atomic_read(&vcpu->arch.vgic_cpu.vgic_v3.its_vpe.vlpi_count))
+ vcpu->arch.hcr_el2 &= ~HCR_TWI;
+ else
+ vcpu->arch.hcr_el2 |= HCR_TWI;
}
-static inline void vcpu_set_wfe_traps(struct kvm_vcpu *vcpu)
+static inline void vcpu_set_wfx_traps(struct kvm_vcpu *vcpu)
{
vcpu->arch.hcr_el2 |= HCR_TWE;
+ vcpu->arch.hcr_el2 |= HCR_TWI;
}
static inline void vcpu_ptrauth_enable(struct kvm_vcpu *vcpu)
@@ -258,6 +273,11 @@ static inline bool kvm_vcpu_dabt_isvalid(const struct kvm_vcpu *vcpu)
return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_ISV);
}
+static inline unsigned long kvm_vcpu_dabt_iss_nisv_sanitized(const struct kvm_vcpu *vcpu)
+{
+ return kvm_vcpu_get_hsr(vcpu) & (ESR_ELx_CM | ESR_ELx_WNR | ESR_ELx_FSC);
+}
+
static inline bool kvm_vcpu_dabt_issext(const struct kvm_vcpu *vcpu)
{
return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SSE);

arch/arm64/include/asm/kvm_host.h

View file
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 5ecb091..c61260c 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -44,6 +44,7 @@
KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
#define KVM_REQ_IRQ_PENDING KVM_ARCH_REQ(1)
#define KVM_REQ_VCPU_RESET KVM_ARCH_REQ(2)
+#define KVM_REQ_RECORD_STEAL KVM_ARCH_REQ(3)
DECLARE_STATIC_KEY_FALSE(userspace_irqchip_in_use);
@@ -83,6 +84,14 @@ struct kvm_arch {
/* Mandated version of PSCI */
u32 psci_version;
+
+ /*

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/paravirt.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/asm/pvclock-abi.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/include/uapi/asm/kvm.h

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/cpu_errata.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/paravirt.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kernel/time.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/Kconfig

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/guest.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/handle_exit.c

View file

This diff is incomplete. Download the complete patch.

arch/arm64/kvm/inject_fault.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/kvm_ppc.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/asm/reg.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/include/uapi/asm/kvm.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_32_mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_64_mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_64_mmu_hv.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_64_vio.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_builtin.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_hv_nested.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_pr.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_xive.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_xive.h

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/book3s_xive_native.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/e500_mmu_host.c

View file

This diff is incomplete. Download the complete patch.

arch/powerpc/kvm/powerpc.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/diag.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/interrupt.c

View file

This diff is incomplete. Download the complete patch.

arch/s390/kvm/kvm-s390.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/events/intel/core.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/include/asm/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kernel/kvm.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/cpuid.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/emulate.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/ioapic.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/kvm_cache_regs.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/lapic.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/lapic.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/mmu/mmu.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/mmu/page_track.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/mmu/paging_tmpl.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/pmu.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/pmu.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/pmu_amd.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/svm.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx/nested.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx/nested.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx/pmu_intel.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx/vmx.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/vmx/vmx.h

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/x86.c

View file

This diff is incomplete. Download the complete patch.

arch/x86/kvm/x86.h

View file

This diff is incomplete. Download the complete patch.

drivers/crypto/ccp/psp-dev.c

View file

This diff is incomplete. Download the complete patch.

drivers/irqchip/irq-gic-v4.c

View file

This diff is incomplete. Download the complete patch.

include/Kbuild

View file

This diff is incomplete. Download the complete patch.

include/kvm/arm_hypercalls.h

View file

This diff is incomplete. Download the complete patch.

include/kvm/arm_psci.h

View file

This diff is incomplete. Download the complete patch.

include/kvm/arm_vgic.h

View file

This diff is incomplete. Download the complete patch.

include/linux/arm-smccc.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpuhotplug.h

View file

This diff is incomplete. Download the complete patch.

include/linux/irqchip/arm-gic-v4.h

View file

This diff is incomplete. Download the complete patch.

include/linux/kvm_host.h

View file

This diff is incomplete. Download the complete patch.

include/linux/kvm_types.h

View file

This diff is incomplete. Download the complete patch.

include/linux/perf_event.h

View file

This diff is incomplete. Download the complete patch.

include/uapi/linux/kvm.h

View file

This diff is incomplete. Download the complete patch.

kernel/events/core.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/.gitignore

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/include/x86_64/processor.h

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/kvm_create_max_vcpus.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/lib/x86_64/processor.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/s390x/sync_regs_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/kvm/x86_64/xss_msr_test.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/arch_timer.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/arm.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/hypercalls.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/mmio.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/psci.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/pvtime.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic-init.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic-its.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic-v3.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic-v4.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/arm/vgic/vgic.h

View file

This diff is incomplete. Download the complete patch.

virt/kvm/coalesced_mmio.c

View file

This diff is incomplete. Download the complete patch.

virt/kvm/kvm_main.c

View file

This diff is incomplete. Download the complete patch.