Commit Graph

1329232 Commits

Author SHA1 Message Date
Stephen Rothwell
dfc7a55ee6 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git 2024-12-20 13:12:26 +11:00
Stephen Rothwell
6e16033768 Merge branch 'for-mfd-next' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git
# Conflicts:
#	drivers/mfd/cs42l43.c
2024-12-20 13:12:25 +11:00
Stephen Rothwell
d03fc22c60 Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc.git 2024-12-20 13:12:22 +11:00
Stephen Rothwell
33a06a7297 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux 2024-12-20 13:12:21 +11:00
Stephen Rothwell
88b8c4e246 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git 2024-12-20 13:12:19 +11:00
Stephen Rothwell
8eaf5c20fb Merge branch 'for-next' of git://git.kernel.dk/linux-block.git 2024-12-20 13:10:04 +11:00
Sean Christopherson
13e98294d7 Merge branches 'fixes', 'misc', 'mmu', 'svm', 'vcpu_array' and 'vmx'
* fixes:
  KVM: x86/mmu: Treat TDP MMU faults as spurious if access is already allowed
  KVM: SVM: Allow guest writes to set MSR_AMD64_DE_CFG bits
  KVM: x86: Play nice with protected guests in complete_hypercall_exit()
  KVM: SVM: Disable AVIC on SNP-enabled system without HvInUseWrAllowed feature

* misc: (66 commits)
  KVM: x86: Add information about pending requests to kvm_exit tracepoint
  KVM: x86: Add interrupt injection information to the kvm_entry tracepoint
  KVM: selftests: Add test case for MMIO during vectoring on x86
  KVM: selftests: Add and use a helper function for x86's LIDT
  KVM: SVM: Handle event vectoring error in check_emulate_instruction()
  KVM: VMX: Handle event vectoring error in check_emulate_instruction()
  KVM: x86: Try to unprotect and retry on unhandleable emulation failure
  KVM: x86: Add emulation status for unhandleable exception vectoring
  KVM: x86: Add function for vectoring error generation
  KVM: x86: Use only local variables (no bitmask) to init kvm_cpu_caps
  KVM: x86: Explicitly track feature flags that are enabled at runtime
  KVM: x86: Explicitly track feature flags that require vendor enabling
  KVM: x86: Rename "SF" macro to "SCATTERED_F"
  KVM: x86: Pull CPUID capabilities from boot_cpu_data only as needed
  KVM: x86: Add a macro for features that are synthesized into boot_cpu_data
  KVM: x86: Drop superfluous host XSAVE check when adjusting guest XSAVES caps
  KVM: x86: Replace (almost) all guest CPUID feature queries with cpu_caps
  KVM: x86: Shuffle code to prepare for dropping guest_cpuid_has()
  KVM: x86: Update guest cpu_caps at runtime for dynamic CPUID-based features
  KVM: x86: Update OS{XSAVE,PKE} bits in guest CPUID irrespective of host support
  ...

* mmu:
  KVM/x86: add comment to kvm_mmu_do_page_fault()

* svm:
  KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change
  KVM: SVM: Macrofy SEV=n versions of sev_xxx_guest()

* vcpu_array:
  KVM: Drop hack that "manually" informs lockdep of kvm->lock vs. vcpu->mutex
  KVM: Don't BUG() the kernel if xa_insert() fails with -EBUSY
  Revert "KVM: Fix vcpu_array[0] races"
  KVM: Grab vcpu->mutex across installing the vCPU's fd and bumping online_vcpus
  KVM: Verify there's at least one online vCPU when iterating over all vCPUs
  KVM: Explicitly verify target vCPU is online in kvm_get_vcpu()

* vmx:
  KVM: x86: Remove hwapic_irr_update() from kvm_x86_ops
  KVM: nVMX: Honor event priority when emulating PI delivery during VM-Enter
  KVM: nVMX: Use vmcs01's controls shadow to check for IRQ/NMI windows at VM-Enter
  KVM: nVMX: Drop manual vmcs01.GUEST_INTERRUPT_STATUS.RVI check at VM-Enter
  KVM: nVMX: Check for pending INIT/SIPI after entering non-root mode
  KVM: nVMX: Explicitly update vPPR on successful nested VM-Enter
  KVM: VMX: Allow toggling bits in MSR_IA32_RTIT_CTL when enable bit is cleared
  KVM: nVMX: Defer SVI update to vmcs01 on EOI when L2 is active w/o VID
  KVM: x86: Plumb in the vCPU to kvm_x86_ops.hwapic_isr_update()
2024-12-20 01:56:00 +00:00
Sean Christopherson
386d69f9f2 KVM: x86/mmu: Treat TDP MMU faults as spurious if access is already allowed
Treat slow-path TDP MMU faults as spurious if the access is allowed given
the existing SPTE to fix a benign warning (other than the WARN itself)
due to replacing a writable SPTE with a read-only SPTE, and to avoid the
unnecessary LOCK CMPXCHG and subsequent TLB flush.

If a read fault races with a write fault, fast GUP fails for any reason
when trying to "promote" the read fault to a writable mapping, and KVM
resolves the write fault first, then KVM will end up trying to install a
read-only SPTE (for a !map_writable fault) overtop a writable SPTE.

Note, it's not entirely clear why fast GUP fails, or if that's even how
KVM ends up with a !map_writable fault with a writable SPTE.  If something
else is going awry, e.g. due to a bug in mmu_notifiers, then treating read
faults as spurious in this scenario could effectively mask the underlying
problem.

However, retrying the faulting access instead of overwriting an existing
SPTE is functionally correct and desirable irrespective of the WARN, and
fast GUP _can_ legitimately fail with a writable VMA, e.g. if the Accessed
bit in primary MMU's PTE is toggled and causes a PTE value mismatch.  The
WARN was also recently added, specifically to track down scenarios where
KVM is unnecessarily overwrites SPTEs, i.e. treating the fault as spurious
doesn't regress KVM's bug-finding capabilities in any way.  In short,
letting the WARN linger because there's a tiny chance it's due to a bug
elsewhere would be excessively paranoid.

Fixes: 1a175082b1 ("KVM: x86/mmu: WARN and flush if resolving a TDP MMU fault clears MMU-writable")
Reported-by: Lei Yang <leiyang@redhat.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219588
Tested-by: Lei Yang <leiyang@redhat.com>
Link: https://lore.kernel.org/r/20241218213611.3181643-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-12-19 17:47:52 -08:00
Sean Christopherson
4d5163cba4 KVM: SVM: Allow guest writes to set MSR_AMD64_DE_CFG bits
Drop KVM's arbitrary behavior of making DE_CFG.LFENCE_SERIALIZE read-only
for the guest, as rejecting writes can lead to guest crashes, e.g. Windows
in particular doesn't gracefully handle unexpected #GPs on the WRMSR, and
nothing in the AMD manuals suggests that LFENCE_SERIALIZE is read-only _if
it exists_.

KVM only allows LFENCE_SERIALIZE to be set, by the guest or host, if the
underlying CPU has X86_FEATURE_LFENCE_RDTSC, i.e. if LFENCE is guaranteed
to be serializing.  So if the guest sets LFENCE_SERIALIZE, KVM will provide
the desired/correct behavior without any additional action (the guest's
value is never stuffed into hardware).  And having LFENCE be serializing
even when it's not _required_ to be is a-ok from a functional perspective.

Fixes: 74a0e79df6 ("KVM: SVM: Disallow guest from changing userspace's MSR_AMD64_DE_CFG value")
Fixes: d1d93fa90f ("KVM: SVM: Add MSR-based feature support for serializing LFENCE")
Reported-by: Simon Pilkington <simonp.git@mailbox.org>
Closes: https://lore.kernel.org/all/52914da7-a97b-45ad-86a0-affdf8266c61@mailbox.org
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: stable@vger.kernel.org
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20241211172952.1477605-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-12-19 17:47:52 -08:00
Sean Christopherson
9b42d1e8e4 KVM: x86: Play nice with protected guests in complete_hypercall_exit()
Use is_64_bit_hypercall() instead of is_64_bit_mode() to detect a 64-bit
hypercall when completing said hypercall.  For guests with protected state,
e.g. SEV-ES and SEV-SNP, KVM must assume the hypercall was made in 64-bit
mode as the vCPU state needed to detect 64-bit mode is unavailable.

Hacking the sev_smoke_test selftest to generate a KVM_HC_MAP_GPA_RANGE
hypercall via VMGEXIT trips the WARN:

  ------------[ cut here ]------------
  WARNING: CPU: 273 PID: 326626 at arch/x86/kvm/x86.h:180 complete_hypercall_exit+0x44/0xe0 [kvm]
  Modules linked in: kvm_amd kvm ... [last unloaded: kvm]
  CPU: 273 UID: 0 PID: 326626 Comm: sev_smoke_test Not tainted 6.12.0-smp--392e932fa0f3-feat #470
  Hardware name: Google Astoria/astoria, BIOS 0.20240617.0-0 06/17/2024
  RIP: 0010:complete_hypercall_exit+0x44/0xe0 [kvm]
  Call Trace:
   <TASK>
   kvm_arch_vcpu_ioctl_run+0x2400/0x2720 [kvm]
   kvm_vcpu_ioctl+0x54f/0x630 [kvm]
   __se_sys_ioctl+0x6b/0xc0
   do_syscall_64+0x83/0x160
   entry_SYSCALL_64_after_hwframe+0x76/0x7e
   </TASK>
  ---[ end trace 0000000000000000 ]---

Fixes: b5aead0064 ("KVM: x86: Assume a 64-bit hypercall for guests with protected state")
Cc: stable@vger.kernel.org
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Link: https://lore.kernel.org/r/20241128004344.4072099-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-12-19 17:47:51 -08:00
Suravee Suthikulpanit
d81cadbe16 KVM: SVM: Disable AVIC on SNP-enabled system without HvInUseWrAllowed feature
On SNP-enabled system, VMRUN marks AVIC Backing Page as in-use while
the guest is running for both secure and non-secure guest. Any hypervisor
write to the in-use vCPU's AVIC backing page (e.g. to inject an interrupt)
will generate unexpected #PF in the host.

Currently, attempt to run AVIC guest would result in the following error:

    BUG: unable to handle page fault for address: ff3a442e549cc270
    #PF: supervisor write access in kernel mode
    #PF: error_code(0x80000003) - RMP violation
    PGD b6ee01067 P4D b6ee02067 PUD 10096d063 PMD 11c540063 PTE 80000001149cc163
    SEV-SNP: PFN 0x1149cc unassigned, dumping non-zero entries in 2M PFN region: [0x114800 - 0x114a00]
    ...

Newer AMD system is enhanced to allow hypervisor to modify the backing page
for non-secure guest on SNP-enabled system. This enhancement is available
when the CPUID Fn8000_001F_EAX bit 30 is set (HvInUseWrAllowed).

This table describes AVIC support matrix w.r.t. SNP enablement:

               | Non-SNP system |     SNP system
-----------------------------------------------------
 Non-SNP guest |  AVIC Activate | AVIC Activate iff
               |                | HvInuseWrAllowed=1
-----------------------------------------------------
     SNP guest |      N/A       |    Secure AVIC

Therefore, check and disable AVIC in kvm_amd driver when the feature is not
available on SNP-enabled system.

See the AMD64 Architecture Programmer’s Manual (APM) Volume 2 for detail.
(https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/
programmer-references/40332.pdf)

Fixes: 216d106c7f ("x86/sev: Add SEV-SNP host initialization support")
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20241104075845.7583-1-suravee.suthikulpanit@amd.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-12-19 17:47:51 -08:00
Stephen Rothwell
d8617a3ba0 Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git 2024-12-20 12:26:57 +11:00
Stephen Rothwell
bfb2b1bbdb Merge branch 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux.git 2024-12-20 12:26:56 +11:00
Stephen Rothwell
dca381d2cc Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 2024-12-20 12:23:25 +11:00
Stephen Rothwell
c9b816ca98 Merge branch 'for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git 2024-12-20 12:23:24 +11:00
Stephen Rothwell
8316cb8f20 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git 2024-12-20 12:23:22 +11:00
Stephen Rothwell
a360114dfc Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 2024-12-20 12:18:57 +11:00
Stephen Rothwell
75ff0b4c3d Merge branch 'etnaviv/next' of https://git.pengutronix.de/git/lst/linux 2024-12-20 12:14:10 +11:00
Stephen Rothwell
735f67ad36 Merge branch 'drm-xe-next' of https://gitlab.freedesktop.org/drm/xe/kernel 2024-12-20 12:14:09 +11:00
Stephen Rothwell
39772e3ec9 Merge branch 'msm-next-lumag' of https://gitlab.freedesktop.org/lumag/msm.git 2024-12-20 12:14:06 +11:00
Stephen Rothwell
e069bb813f Merge branch 'for-linux-next' of https://gitlab.freedesktop.org/drm/i915/kernel
# Conflicts:
#	drivers/gpu/drm/i915/display/intel_dp_mst.c
#	drivers/gpu/drm/i915/display/intel_dsb.c
2024-12-20 12:14:03 +11:00
Stephen Rothwell
00a6ef30ae Merge branch 'drm-next' of https://gitlab.freedesktop.org/agd5f/linux 2024-12-20 12:14:00 +11:00
Stephen Rothwell
cecc27b364 Merge branch 'for-linux-next' of https://gitlab.freedesktop.org/drm/misc/kernel.git 2024-12-20 12:13:59 +11:00
Stephen Rothwell
d3a1699e63 Merge branch 'for-linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git 2024-12-20 12:13:57 +11:00
Stephen Rothwell
6d7a3c76c5 Merge branch 'drm-next' of https://gitlab.freedesktop.org/drm/kernel.git 2024-12-20 12:13:56 +11:00
Stephen Rothwell
a682817489 Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git 2024-12-20 12:10:57 +11:00
Stephen Rothwell
25d313f34d Merge branch 'spi-nor/next' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git 2024-12-20 12:10:56 +11:00
Stephen Rothwell
a7acb58ac1 Merge branch 'nand/next' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git 2024-12-20 12:10:55 +11:00
Stephen Rothwell
06a622defc Merge branch 'mtd/next' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git 2024-12-20 12:10:53 +11:00
Stephen Rothwell
e58c8fbfaa Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/wpan/wpan-next.git 2024-12-20 11:48:50 +11:00
Stephen Rothwell
350a5ae97e Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git 2024-12-20 11:48:47 +11:00
Stephen Rothwell
b806b8e127 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git 2024-12-20 11:48:46 +11:00
Stephen Rothwell
d711d1b348 Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git 2024-12-20 11:48:45 +11:00
Stephen Rothwell
31f61fbd8c Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next.git 2024-12-20 11:48:42 +11:00
Stephen Rothwell
49e3ee1413 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git 2024-12-20 11:48:40 +11:00
Stephen Rothwell
0b744f9e35 Merge branch 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git 2024-12-20 11:48:38 +11:00
Stephen Rothwell
eb65cde519 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git 2024-12-20 11:48:37 +11:00
Stephen Rothwell
be01032c8c Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git 2024-12-20 11:29:47 +11:00
Stephen Rothwell
4f5e1cc179 Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm.git 2024-12-20 11:29:44 +11:00
Stephen Rothwell
299285bf13 Merge branch 'devfreq-next' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git
# Conflicts:
#	drivers/devfreq/event/exynos-nocp.c
#	drivers/devfreq/event/exynos-ppmu.c
#	drivers/devfreq/mtk-cci-devfreq.c
#	drivers/devfreq/rk3399_dmc.c
#	drivers/devfreq/sun8i-a33-mbus.c
2024-12-20 11:29:43 +11:00
Stephen Rothwell
1bf9511444 Merge branch 'cpupower' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git 2024-12-20 11:29:42 +11:00
Stephen Rothwell
baf1197b35 Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git 2024-12-20 11:29:40 +11:00
Stephen Rothwell
1dae1421fa Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 2024-12-20 11:29:38 +11:00
Stephen Rothwell
7bb5219654 Merge branch 'next' of git://linuxtv.org/media-ci/media-pending.git 2024-12-20 11:07:40 +11:00
Stephen Rothwell
a4b7d49533 Merge branch 'docs-next' of git://git.lwn.net/linux.git 2024-12-20 11:07:39 +11:00
Stephen Rothwell
e24a64840a Merge branch 'hwmon-next' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git 2024-12-20 11:07:37 +11:00
Stephen Rothwell
2f19d7a812 Merge branch 'i2c/i2c-host' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git 2024-12-20 11:07:36 +11:00
Stephen Rothwell
2d144c87f2 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git 2024-12-20 11:07:35 +11:00
Stephen Rothwell
ecc935f512 Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git 2024-12-20 11:07:33 +11:00
Stephen Rothwell
23b66e8e8b Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/printk/linux.git 2024-12-20 11:07:32 +11:00