Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull x86 kvm fixes from Paolo Bonzini:
"Many small fixes that accumulated while I was on vacation...

- Fixup missed comments from the REMOVED_SPTE => FROZEN_SPTE rename

- Ensure a root is successfully loaded when pre-faulting SPTEs

- Grab kvm->srcu when handling KVM_SET_VCPU_EVENTS to guard against
accessing memslots if toggling SMM happens to force a VM-Exit

- Emulate MSR_{FS,GS}_BASE on SVM even though interception is always
disabled, so that KVM does the right thing if KVM's emulator
encounters {RD,WR}MSR

- Explicitly clear BUS_LOCK_DETECT from KVM's caps on AMD, as KVM
doesn't yet virtualize BUS_LOCK_DETECT on AMD

- Cleanup the help message for CONFIG_KVM_AMD_SEV, and call out that
KVM now supports SEV-SNP too

- Specialize return value of
KVM_CHECK_EXTENSION(KVM_CAP_READONLY_MEM), based on VM type

- Remove unnecessary dependency on CONFIG_HIGH_RES_TIMERS

- Note an RCU quiescent state on guest exit. This avoids a call to
rcu_core() if there was a grace period request while guest was
running"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: Remove HIGH_RES_TIMERS dependency
kvm: Note an RCU quiescent state on guest exit
KVM: x86: Only advertise KVM_CAP_READONLY_MEM when supported by VM
KVM: SEV: Update KVM_AMD_SEV Kconfig entry and mention SEV-SNP
KVM: SVM: Don't advertise Bus Lock Detect to guest if SVM support is missing
KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and MSR_GS_BASE
KVM: x86: Acquire kvm->srcu when handling KVM_SET_VCPU_EVENTS
KVM: x86/mmu: Check that root is valid/loaded when pre-faulting SPTEs
KVM: x86/mmu: Fixup comments missed by the REMOVED_SPTE=>FROZEN_SPTE rename

+47 -16
+4 -3
arch/x86/kvm/Kconfig
··· 19 19 20 20 config KVM 21 21 tristate "Kernel-based Virtual Machine (KVM) support" 22 - depends on HIGH_RES_TIMERS 23 22 depends on X86_LOCAL_APIC 24 23 select KVM_COMMON 25 24 select KVM_GENERIC_MMU_NOTIFIER ··· 143 144 select HAVE_KVM_ARCH_GMEM_PREPARE 144 145 select HAVE_KVM_ARCH_GMEM_INVALIDATE 145 146 help 146 - Provides support for launching Encrypted VMs (SEV) and Encrypted VMs 147 - with Encrypted State (SEV-ES) on AMD processors. 147 + Provides support for launching encrypted VMs which use Secure 148 + Encrypted Virtualization (SEV), Secure Encrypted Virtualization with 149 + Encrypted State (SEV-ES), and Secure Encrypted Virtualization with 150 + Secure Nested Paging (SEV-SNP) technologies on AMD processors. 148 151 149 152 config KVM_SMM 150 153 bool "System Management Mode emulation"
+3 -1
arch/x86/kvm/mmu/mmu.c
··· 4750 4750 * reload is efficient when called repeatedly, so we can do it on 4751 4751 * every iteration. 4752 4752 */ 4753 - kvm_mmu_reload(vcpu); 4753 + r = kvm_mmu_reload(vcpu); 4754 + if (r) 4755 + return r; 4754 4756 4755 4757 if (kvm_arch_has_private_mem(vcpu->kvm) && 4756 4758 kvm_mem_is_private(vcpu->kvm, gpa_to_gfn(range->gpa)))
+3 -3
arch/x86/kvm/mmu/spte.c
··· 391 391 mmio_value = 0; 392 392 393 393 /* 394 - * The masked MMIO value must obviously match itself and a removed SPTE 395 - * must not get a false positive. Removed SPTEs and MMIO SPTEs should 396 - * never collide as MMIO must set some RWX bits, and removed SPTEs must 394 + * The masked MMIO value must obviously match itself and a frozen SPTE 395 + * must not get a false positive. Frozen SPTEs and MMIO SPTEs should 396 + * never collide as MMIO must set some RWX bits, and frozen SPTEs must 397 397 * not set any RWX bits. 398 398 */ 399 399 if (WARN_ON((mmio_value & mmio_mask) != mmio_value) ||
+1 -1
arch/x86/kvm/mmu/spte.h
··· 214 214 */ 215 215 #define FROZEN_SPTE (SHADOW_NONPRESENT_VALUE | 0x5a0ULL) 216 216 217 - /* Removed SPTEs must not be misconstrued as shadow present PTEs. */ 217 + /* Frozen SPTEs must not be misconstrued as shadow present PTEs. */ 218 218 static_assert(!(FROZEN_SPTE & SPTE_MMU_PRESENT_MASK)); 219 219 220 220 static inline bool is_frozen_spte(u64 spte)
+4 -4
arch/x86/kvm/mmu/tdp_mmu.c
··· 359 359 /* 360 360 * Set the SPTE to a nonpresent value that other 361 361 * threads will not overwrite. If the SPTE was 362 - * already marked as removed then another thread 362 + * already marked as frozen then another thread 363 363 * handling a page fault could overwrite it, so 364 364 * set the SPTE until it is set from some other 365 - * value to the removed SPTE value. 365 + * value to the frozen SPTE value. 366 366 */ 367 367 for (;;) { 368 368 old_spte = kvm_tdp_mmu_write_spte_atomic(sptep, FROZEN_SPTE); ··· 536 536 u64 *sptep = rcu_dereference(iter->sptep); 537 537 538 538 /* 539 - * The caller is responsible for ensuring the old SPTE is not a REMOVED 540 - * SPTE. KVM should never attempt to zap or manipulate a REMOVED SPTE, 539 + * The caller is responsible for ensuring the old SPTE is not a FROZEN 540 + * SPTE. KVM should never attempt to zap or manipulate a FROZEN SPTE, 541 541 * and pre-checking before inserting a new SPTE is advantageous as it 542 542 * avoids unnecessary work. 543 543 */
+15
arch/x86/kvm/svm/svm.c
··· 2876 2876 case MSR_CSTAR: 2877 2877 msr_info->data = svm->vmcb01.ptr->save.cstar; 2878 2878 break; 2879 + case MSR_GS_BASE: 2880 + msr_info->data = svm->vmcb01.ptr->save.gs.base; 2881 + break; 2882 + case MSR_FS_BASE: 2883 + msr_info->data = svm->vmcb01.ptr->save.fs.base; 2884 + break; 2879 2885 case MSR_KERNEL_GS_BASE: 2880 2886 msr_info->data = svm->vmcb01.ptr->save.kernel_gs_base; 2881 2887 break; ··· 3106 3100 break; 3107 3101 case MSR_CSTAR: 3108 3102 svm->vmcb01.ptr->save.cstar = data; 3103 + break; 3104 + case MSR_GS_BASE: 3105 + svm->vmcb01.ptr->save.gs.base = data; 3106 + break; 3107 + case MSR_FS_BASE: 3108 + svm->vmcb01.ptr->save.fs.base = data; 3109 3109 break; 3110 3110 case MSR_KERNEL_GS_BASE: 3111 3111 svm->vmcb01.ptr->save.kernel_gs_base = data; ··· 5236 5224 5237 5225 /* CPUID 0x8000001F (SME/SEV features) */ 5238 5226 sev_set_cpu_caps(); 5227 + 5228 + /* Don't advertise Bus Lock Detect to guest if SVM support is absent */ 5229 + kvm_cpu_cap_clear(X86_FEATURE_BUS_LOCK_DETECT); 5239 5230 } 5240 5231 5241 5232 static __init int svm_hardware_setup(void)
+4 -1
arch/x86/kvm/x86.c
··· 4656 4656 case KVM_CAP_ASYNC_PF_INT: 4657 4657 case KVM_CAP_GET_TSC_KHZ: 4658 4658 case KVM_CAP_KVMCLOCK_CTRL: 4659 - case KVM_CAP_READONLY_MEM: 4660 4659 case KVM_CAP_IOAPIC_POLARITY_IGNORED: 4661 4660 case KVM_CAP_TSC_DEADLINE_TIMER: 4662 4661 case KVM_CAP_DISABLE_QUIRKS: ··· 4814 4815 case KVM_CAP_VM_TYPES: 4815 4816 r = kvm_caps.supported_vm_types; 4816 4817 break; 4818 + case KVM_CAP_READONLY_MEM: 4819 + r = kvm ? kvm_arch_has_readonly_mem(kvm) : 1; 4817 4820 default: 4818 4821 break; 4819 4822 } ··· 6041 6040 if (copy_from_user(&events, argp, sizeof(struct kvm_vcpu_events))) 6042 6041 break; 6043 6042 6043 + kvm_vcpu_srcu_read_lock(vcpu); 6044 6044 r = kvm_vcpu_ioctl_x86_set_vcpu_events(vcpu, &events); 6045 + kvm_vcpu_srcu_read_unlock(vcpu); 6045 6046 break; 6046 6047 } 6047 6048 case KVM_GET_DEBUGREGS: {
+4 -2
include/linux/context_tracking.h
··· 80 80 return context_tracking_enabled_this_cpu(); 81 81 } 82 82 83 - static __always_inline void context_tracking_guest_exit(void) 83 + static __always_inline bool context_tracking_guest_exit(void) 84 84 { 85 85 if (context_tracking_enabled()) 86 86 __ct_user_exit(CONTEXT_GUEST); 87 + 88 + return context_tracking_enabled_this_cpu(); 87 89 } 88 90 89 91 #define CT_WARN_ON(cond) WARN_ON(context_tracking_enabled() && (cond)) ··· 100 98 static inline int ct_state(void) { return -1; } 101 99 static inline int __ct_state(void) { return -1; } 102 100 static __always_inline bool context_tracking_guest_enter(void) { return false; } 103 - static __always_inline void context_tracking_guest_exit(void) { } 101 + static __always_inline bool context_tracking_guest_exit(void) { return false; } 104 102 #define CT_WARN_ON(cond) do { } while (0) 105 103 #endif /* !CONFIG_CONTEXT_TRACKING_USER */ 106 104
+9 -1
include/linux/kvm_host.h
··· 485 485 */ 486 486 static __always_inline void guest_context_exit_irqoff(void) 487 487 { 488 - context_tracking_guest_exit(); 488 + /* 489 + * Guest mode is treated as a quiescent state, see 490 + * guest_context_enter_irqoff() for more details. 491 + */ 492 + if (!context_tracking_guest_exit()) { 493 + instrumentation_begin(); 494 + rcu_virt_note_context_switch(); 495 + instrumentation_end(); 496 + } 489 497 } 490 498 491 499 /*