linux/arch/x86/kvm
Sean Christopherson 7bdbb820fe KVM: x86/mmu: WARN if upper 32 bits of legacy #PF error code are non-zero
WARN if bits 63:32 are non-zero when handling an intercepted legacy #PF,
as the error code for #PF is limited to 32 bits (and in practice, 16 bits
on Intel CPUS).  This behavior is architectural, is part of KVM's ABI
(see kvm_vcpu_events.error_code), and is explicitly documented as being
preserved for intecerpted #PF in both the APM:

  The error code saved in EXITINFO1 is the same as would be pushed onto
  the stack by a non-intercepted #PF exception in protected mode.

and even more explicitly in the SDM as VMCS.VM_EXIT_INTR_ERROR_CODE is a
32-bit field.

Simply drop the upper bits if hardware provides garbage, as spurious
information should do no harm (though in all likelihood hardware is buggy
and the kernel is doomed).

Handling all upper 32 bits in the #PF path will allow moving the sanity
check on synthetic checks from kvm_mmu_page_fault() to npf_interception(),
which in turn will allow deriving PFERR_PRIVATE_ACCESS from AMD's
PFERR_GUEST_ENC_MASK without running afoul of the sanity check.

Note, this is also why Intel uses bit 15 for SGX (highest bit on Intel CPUs)
and AMD uses bit 31 for RMP (highest bit on AMD CPUs); using the highest
bit minimizes the probability of a collision with the "other" vendor,
without needing to plumb more bits through microcode.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Message-ID: <20240228024147.41573-7-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2024-05-07 11:59:19 -04:00
..
mmu KVM: x86/mmu: WARN if upper 32 bits of legacy #PF error code are non-zero 2024-05-07 11:59:19 -04:00
svm KVM: x86: Move synthetic PFERR_* sanity checks to SVM's #NPF handler 2024-05-07 11:59:18 -04:00
vmx KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument 2024-04-12 04:42:24 -04:00
.gitignore KVM: x86: use a separate asm-offsets.c file 2022-11-09 12:10:17 -05:00
cpuid.c KVM: SVM: Invert handling of SEV and SEV_ES feature flags 2024-04-11 13:08:21 -04:00
cpuid.h KVM: x86: Use KVM-governed feature framework to track "LAM enabled" 2023-11-28 17:54:09 -08:00
debugfs.c KVM: Get rid of return value from kvm_arch_create_vm_debugfs() 2024-02-23 21:44:58 +00:00
emulate.c KVM x86 PMU changes for 6.9: 2024-03-11 10:41:09 -04:00
fpu.h KVM: x86: Move FPU register accessors into fpu.h 2021-06-17 13:09:24 -04:00
governed_features.h KVM: x86: Use KVM-governed feature framework to track "LAM enabled" 2023-11-28 17:54:09 -08:00
hyperv.c KVM: x86: Give a hint when Win2016 might fail to boot due to XSAVES erratum 2024-01-31 16:21:00 -05:00
hyperv.h KVM: x86: Give a hint when Win2016 might fail to boot due to XSAVES erratum 2024-01-31 16:21:00 -05:00
i8254.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
i8254.h KVM: x86: PIT: Preserve state of speaker port data bit 2022-06-08 13:06:20 -04:00
i8259.c KVM: x86: Fix poll command 2023-06-01 13:44:13 -07:00
ioapic.c KVM: x86/ioapic: Resample the pending state of an IRQ when unmasking 2023-03-27 10:13:28 -04:00
ioapic.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq_comm.c KVM: x86: Make Hyper-V emulation optional 2023-12-07 09:34:57 -08:00
irq.c KVM: x86/xen: Remove unneeded xen context from kvm_arch when !CONFIG_KVM_XEN 2023-12-07 09:33:42 -08:00
irq.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
Kconfig x86/kvm/Kconfig: Have KVM_AMD_SEV select ARCH_HAS_CC_PLATFORM 2024-04-04 10:40:23 +02:00
kvm_cache_regs.h KVM: x86: Add helpers to query individual CR0/CR4 bits 2023-03-22 10:10:53 -07:00
kvm_emulate.h KVM x86 PMU changes for 6.9: 2024-03-11 10:41:09 -04:00
kvm_onhyperv.c KVM: x86/mmu: Move filling of Hyper-V's TLB range struct into Hyper-V code 2023-04-10 15:17:29 -07:00
kvm_onhyperv.h KVM: x86: Move Hyper-V partition assist page out of Hyper-V emulation context 2023-12-07 09:34:01 -08:00
kvm-asm-offsets.c KVM: SVM: move MSR_IA32_SPEC_CTRL save/restore to assembly 2022-11-09 12:25:53 -05:00
lapic.c S390: 2024-03-15 13:03:13 -07:00
lapic.h KVM: x86: Split out logic to generate "readable" APIC regs mask to helper 2023-01-24 10:04:35 -08:00
Makefile KVM: VMX: Move out vmx_x86_ops to 'main.c' to dispatch VMX and TDX 2024-04-12 04:42:24 -04:00
mmu.h KVM: x86: Remove separate "bit" defines for page fault error code masks 2024-05-07 11:59:17 -04:00
mtrr.c KVM: x86/mmu: Zap SPTEs on MTRR update iff guest MTRRs are honored 2023-10-09 14:35:14 -07:00
pmu.c KVM: x86/pmu: Avoid CPL lookup if PMC enabline for USER and KERNEL is the same 2024-02-01 09:35:48 -08:00
pmu.h KVM: x86/pmu: Snapshot event selectors that KVM emulates in software 2024-02-01 09:35:48 -08:00
reverse_cpuid.h x86/cpufeatures: Add CPUID_LNX_5 to track recently added Linux-defined word 2024-04-04 17:42:19 -07:00
smm.c KVM: x86: Open code all direct reads to guest DR6 and DR7 2024-02-22 16:14:47 -08:00
smm.h KVM: x86: smm: preserve interrupt shadow in SMRAM 2022-11-09 12:31:26 -05:00
trace.h KVM SVM changes for 6.9: 2024-03-18 19:03:26 -04:00
tss.h
x86.c KVM: x86: Split core of hypercall emulation to helper function 2024-04-12 04:42:23 -04:00
x86.h KVM: x86: Add supported_vm_types to kvm_caps 2024-04-11 13:08:24 -04:00
xen.c KVM: x86/xen: fix recursive deadlock in timer injection 2024-03-04 16:22:39 -08:00
xen.h KVM: x86/xen: inject vCPU upcall vector when local APIC is enabled 2024-03-04 16:22:36 -08:00