]> Git Repo - linux.git/commitdiff
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
authorLinus Torvalds <[email protected]>
Sat, 25 Jan 2025 17:55:09 +0000 (09:55 -0800)
committerLinus Torvalds <[email protected]>
Sat, 25 Jan 2025 17:55:09 +0000 (09:55 -0800)
Pull kvm updates from Paolo Bonzini:
 "Loongarch:

   - Clear LLBCTL if secondary mmu mapping changes

   - Add hypercall service support for usermode VMM

  x86:

   - Add a comment to kvm_mmu_do_page_fault() to explain why KVM
     performs a direct call to kvm_tdp_page_fault() when RETPOLINE is
     enabled

   - Ensure that all SEV code is compiled out when disabled in Kconfig,
     even if building with less brilliant compilers

   - Remove a redundant TLB flush on AMD processors when guest CR4.PGE
     changes

   - Use str_enabled_disabled() to replace open coded strings

   - Drop kvm_x86_ops.hwapic_irr_update() as KVM updates hardware's
     APICv cache prior to every VM-Enter

   - Overhaul KVM's CPUID feature infrastructure to track all vCPU
     capabilities instead of just those where KVM needs to manage state
     and/or explicitly enable the feature in hardware. Along the way,
     refactor the code to make it easier to add features, and to make it
     more self-documenting how KVM is handling each feature

   - Rework KVM's handling of VM-Exits during event vectoring; this
     plugs holes where KVM unintentionally puts the vCPU into infinite
     loops in some scenarios (e.g. if emulation is triggered by the
     exit), and brings parity between VMX and SVM

   - Add pending request and interrupt injection information to the
     kvm_exit and kvm_entry tracepoints respectively

   - Fix a relatively benign flaw where KVM would end up redoing RDPKRU
     when loading guest/host PKRU, due to a refactoring of the kernel
     helpers that didn't account for KVM's pre-checking of the need to
     do WRPKRU

   - Make the completion of hypercalls go through the complete_hypercall
     function pointer argument, no matter if the hypercall exits to
     userspace or not.

     Previously, the code assumed that KVM_HC_MAP_GPA_RANGE specifically
     went to userspace, and all the others did not; the new code need
     not special case KVM_HC_MAP_GPA_RANGE and in fact does not care at
     all whether there was an exit to userspace or not

   - As part of enabling TDX virtual machines, support support
     separation of private/shared EPT into separate roots.

     When TDX will be enabled, operations on private pages will need to
     go through the privileged TDX Module via SEAMCALLs; as a result,
     they are limited and relatively slow compared to reading a PTE.

     The patches included in 6.14 allow KVM to keep a mirror of the
     private EPT in host memory, and define entries in kvm_x86_ops to
     operate on external page tables such as the TDX private EPT

   - The recently introduced conversion of the NX-page reclamation
     kthread to vhost_task moved the task under the main process. The
     task is created as soon as KVM_CREATE_VM was invoked and this, of
     course, broke userspace that didn't expect to see any child task of
     the VM process until it started creating its own userspace threads.

     In particular crosvm refuses to fork() if procfs shows any child
     task, so unbreak it by creating the task lazily. This is arguably a
     userspace bug, as there can be other kinds of legitimate worker
     tasks and they wouldn't impede fork(); but it's not like userspace
     has a way to distinguish kernel worker tasks right now. Should they
     show as "Kthread: 1" in proc/.../status?

  x86 - Intel:

   - Fix a bug where KVM updates hardware's APICv cache of the highest
     ISR bit while L2 is active, while ultimately results in a
     hardware-accelerated L1 EOI effectively being lost

   - Honor event priority when emulating Posted Interrupt delivery
     during nested VM-Enter by queueing KVM_REQ_EVENT instead of
     immediately handling the interrupt

   - Rework KVM's processing of the Page-Modification Logging buffer to
     reap entries in the same order they were created, i.e. to mark gfns
     dirty in the same order that hardware marked the page/PTE dirty

   - Misc cleanups

  Generic:

   - Cleanup and harden kvm_set_memory_region(); add proper lockdep
     assertions when setting memory regions and add a dedicated API for
     setting KVM-internal memory regions. The API can then explicitly
     disallow all flags for KVM-internal memory regions

   - Explicitly verify the target vCPU is online in kvm_get_vcpu() to
     fix a bug where KVM would return a pointer to a vCPU prior to it
     being fully online, and give kvm_for_each_vcpu() similar treatment
     to fix a similar flaw

   - Wait for a vCPU to come online prior to executing a vCPU ioctl, to
     fix a bug where userspace could coerce KVM into handling the ioctl
     on a vCPU that isn't yet onlined

   - Gracefully handle xarray insertion failures; even though such
     failures are impossible in practice after xa_reserve(), reserving
     an entry is always followed by xa_store() which does not know (or
     differentiate) whether there was an xa_reserve() before or not

  RISC-V:

   - Zabha, Svvptc, and Ziccrse extension support for guests. None of
     them require anything in KVM except for detecting them and marking
     them as supported; Zabha adds byte and halfword atomic operations,
     while the others are markers for specific operation of the TLB and
     of LL/SC instructions respectively

   - Virtualize SBI system suspend extension for Guest/VM

   - Support firmware counters which can be used by the guests to
     collect statistics about traps that occur in the host

  Selftests:

   - Rework vcpu_get_reg() to return a value instead of using an
     out-param, and update all affected arch code accordingly

   - Convert the max_guest_memory_test into a more generic
     mmu_stress_test. The basic gist of the "conversion" is to have the
     test do mprotect() on guest memory while vCPUs are accessing said
     memory, e.g. to verify KVM and mmu_notifiers are working as
     intended

   - Play nice with treewrite builds of unsupported architectures, e.g.
     arm (32-bit), as KVM selftests' Makefile doesn't do anything to
     ensure the target architecture is actually one KVM selftests
     supports

   - Use the kernel's $(ARCH) definition instead of the target triple
     for arch specific directories, e.g. arm64 instead of aarch64,
     mainly so as not to be different from the rest of the kernel

   - Ensure that format strings for logging statements are checked by
     the compiler even when the logging statement itself is disabled

   - Attempt to whack the last LLC references/misses mole in the Intel
     PMU counters test by adding a data load and doing CLFLUSH{OPT} on
     the data instead of the code being executed. It seems that modern
     Intel CPUs have learned new code prefetching tricks that bypass the
     PMU counters

   - Fix a flaw in the Intel PMU counters test where it asserts that
     events are counting correctly without actually knowing what the
     events count given the underlying hardware; this can happen if
     Intel reuses a formerly microarchitecture-specific event encoding
     as an architectural event, as was the case for Top-Down Slots"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (151 commits)
  kvm: defer huge page recovery vhost task to later
  KVM: x86/mmu: Return RET_PF* instead of 1 in kvm_mmu_page_fault()
  KVM: Disallow all flags for KVM-internal memslots
  KVM: x86: Drop double-underscores from __kvm_set_memory_region()
  KVM: Add a dedicated API for setting KVM-internal memslots
  KVM: Assert slots_lock is held when setting memory regions
  KVM: Open code kvm_set_memory_region() into its sole caller (ioctl() API)
  LoongArch: KVM: Add hypercall service support for usermode VMM
  LoongArch: KVM: Clear LLBCTL if secondary mmu mapping is changed
  KVM: SVM: Use str_enabled_disabled() helper in svm_hardware_setup()
  KVM: VMX: read the PML log in the same order as it was written
  KVM: VMX: refactor PML terminology
  KVM: VMX: Fix comment of handle_vmx_instruction()
  KVM: VMX: Reinstate __exit attribute for vmx_exit()
  KVM: SVM: Use str_enabled_disabled() helper in sev_hardware_setup()
  KVM: x86: Avoid double RDPKRU when loading host/guest PKRU
  KVM: x86: Use LVT_TIMER instead of an open coded literal
  RISC-V: KVM: Add new exit statstics for redirected traps
  RISC-V: KVM: Update firmware counters for various events
  RISC-V: KVM: Redirect instruction access fault trap to guest
  ...

1  2 
Documentation/virt/kvm/api.rst
MAINTAINERS
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/svm/sev.c

index 3514c4018f40ab2e391e7066e87fb49e8052643b,2ba70c1fad51a10222a5a1db718ca10a0056b2da..0d1c3a820ce6ea3c62e6341a0d1cc38b9ff9a75a
@@@ -1825,15 -1825,18 +1825,18 @@@ emulate them efficiently. The fields i
           the values returned by the cpuid instruction for
           this function/index combination
  
- The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
- as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
support.  Instead it is reported via::
+ x2APIC (CPUID leaf 1, ecx[21) and TSC deadline timer (CPUID leaf 1, ecx[24])
+ may be returned as true, but they depend on KVM_CREATE_IRQCHIP for in-kernel
emulation of the local APIC.  TSC deadline timer support is also reported via::
  
    ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
  
  if that returns true and you use KVM_CREATE_IRQCHIP, or if you emulate the
  feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
  
+ Enabling x2APIC in KVM_SET_CPUID2 requires KVM_CREATE_IRQCHIP as KVM doesn't
+ support forwarding x2APIC MSR accesses to userspace, i.e. KVM does not support
+ emulating x2APIC in userspace.
  
  4.47 KVM_PPC_GET_PVINFO
  -----------------------
@@@ -5577,7 -5580,7 +5580,7 @@@ KVM_XEN_ATTR_TYPE_SHARED_INFO_HV
    in guest physical address space. This attribute should be used in
    preference to KVM_XEN_ATTR_TYPE_SHARED_INFO as it avoids
    unnecessary invalidation of an internal cache when the page is
 -  re-mapped in guest physcial address space.
 +  re-mapped in guest physical address space.
  
    Setting the hva to zero will disable the shared_info page.
  
@@@ -7673,6 -7676,7 +7676,7 @@@ branch to guests' 0x200 interrupt vecto
  :Architectures: x86
  :Parameters: args[0] defines which exits are disabled
  :Returns: 0 on success, -EINVAL when args[0] contains invalid exits
+           or if any vCPUs have already been created
  
  Valid bits in args[0] are::
  
diff --combined MAINTAINERS
index 28e8de3a19e58d1e6ed423fdc3135335ce929676,d4f4174a886238f6cdf741e793098910414e030c..70bca3a67d5c59cceb2d1b207ed82239b432e4a9
@@@ -185,14 -185,6 +185,14 @@@ W:       http://www.adaptec.com
  F:    Documentation/scsi/aacraid.rst
  F:    drivers/scsi/aacraid/
  
 +AAEON UPBOARD FPGA MFD DRIVER
 +M:    Thomas Richard <[email protected]>
 +S:    Maintained
 +F:    drivers/leds/leds-upboard.c
 +F:    drivers/mfd/upboard-fpga.c
 +F:    drivers/pinctrl/pinctrl-upboard.c
 +F:    include/linux/mfd/upboard-fpga.h
 +
  AB8500 BATTERY AND CHARGER DRIVERS
  M:    Linus Walleij <[email protected]>
  F:    Documentation/devicetree/bindings/power/supply/*ab8500*
@@@ -959,7 -951,7 +959,7 @@@ M: Arthur Kiyanovski <[email protected]
  R:    David Arinzon <[email protected]>
  R:    Saeed Bishara <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/amazon/ena.rst
  F:    drivers/net/ethernet/amazon/
  
  S:    Supported
  F:    drivers/i2c/busses/i2c-amd-asf-plat.c
  
 +AMD NODE DRIVER
 +M:    Mario Limonciello <[email protected]>
 +M:    Yazen Ghannam <[email protected]>
 +L:    [email protected]
 +S:    Supported
 +F:    arch/x86/include/asm/amd_node.h
 +F:    arch/x86/kernel/amd_node.c
 +
  AMD PDS CORE DRIVER
  M:    Shannon Nelson <[email protected]>
  M:    Brett Creeley <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/amd/pds_core.rst
  F:    drivers/net/ethernet/amd/pds_core/
  F:    include/linux/pds/
  AMD PMC DRIVER
  M:    Shyam Sundar S K <[email protected]>
  L:    [email protected]
 -S:    Maintained
 +S:    Supported
  F:    drivers/platform/x86/amd/pmc/
  
  AMD PMF DRIVER
  S:    Supported
  F:    drivers/spi/spi-amd.c
  
 +AMD XDNA DRIVER
 +M:    Min Ma <[email protected]>
 +M:    Lizhi Hou <[email protected]>
 +L:    [email protected]
 +S:    Supported
 +T:    git https://gitlab.freedesktop.org/drm/misc/kernel.git
 +F:    Documentation/accel/amdxdna/
 +F:    drivers/accel/amdxdna/
 +F:    include/trace/events/amdxdna.h
 +F:    include/uapi/drm/amdxdna_accel.h
 +
  AMD XGBE DRIVER
  M:    "Shyam Sundar S K" <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    arch/arm64/boot/dts/amd/amd-seattle-xgbe*.dtsi
  F:    drivers/net/ethernet/amd/xgbe/
  
@@@ -1252,7 -1225,7 +1252,7 @@@ S:      Maintaine
  F:    Documentation/devicetree/bindings/rtc/amlogic,a4-rtc.yaml
  F:    drivers/rtc/rtc-amlogic-a4.c
  
 -AMPHENOL CHIPCAP 2 HUMIDITY-TEMPERATURE IIO DRIVER
 +AMPHENOL CHIPCAP 2 DRIVER
  M:    Javier Carrasco <[email protected]>
  L:    [email protected]
  S:    Maintained
@@@ -1729,14 -1702,14 +1729,14 @@@ F:   drivers/edac/xgene_edac.
  APPLIED MICRO (APM) X-GENE SOC ETHERNET (V2) DRIVER
  M:    Iyappan Subramanian <[email protected]>
  M:    Keyur Chudgar <[email protected]>
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/apm/xgene-v2/
  
  APPLIED MICRO (APM) X-GENE SOC ETHERNET DRIVER
  M:    Iyappan Subramanian <[email protected]>
  M:    Keyur Chudgar <[email protected]>
  M:    Quan Nguyen <[email protected]>
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/apm-xgene-enet.txt
  F:    Documentation/devicetree/bindings/net/apm-xgene-mdio.txt
  F:    drivers/net/ethernet/apm/xgene/
@@@ -1774,7 -1747,7 +1774,7 @@@ F:      drivers/hwmon/aquacomputer_d5next.
  AQUANTIA ETHERNET DRIVER (atlantic)
  M:    Igor Russkikh <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.marvell.com/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    Documentation/networking/device_drivers/ethernet/aquantia/atlantic.rst
@@@ -1783,7 -1756,7 +1783,7 @@@ F:      drivers/net/ethernet/aquantia/atlant
  AQUANTIA ETHERNET DRIVER PTP SUBSYSTEM
  M:    Egor Pomozov <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.aquantia.com
  F:    drivers/net/ethernet/aquantia/atlantic/aq_ptp*
  
@@@ -1945,7 -1918,6 +1945,7 @@@ ARM PMU PROFILING AND DEBUGGIN
  M:    Will Deacon <[email protected]>
  M:    Mark Rutland <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
 +L:    [email protected]
  S:    Maintained
  F:    Documentation/devicetree/bindings/arm/pmu.yaml
  F:    Documentation/devicetree/bindings/perf/
@@@ -2309,15 -2281,6 +2309,15 @@@ F:    arch/arm64/boot/dts/bitmain
  F:    drivers/clk/clk-bm1880.c
  F:    drivers/pinctrl/pinctrl-bm1880.c
  
 +ARM/BLAIZE ARCHITECTURE
 +M:    James Cowgill <[email protected]>
 +M:    Matt Redfearn <[email protected]>
 +M:    Neil Jones <[email protected]>
 +M:    Nikolaos Pasaloukos <[email protected]>
 +S:    Maintained
 +F:    Documentation/devicetree/bindings/arm/blaize.yaml
 +F:    arch/arm64/boot/dts/blaize/
 +
  ARM/CALXEDA HIGHBANK ARCHITECTURE
  M:    Andre Przywara <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
@@@ -2328,7 -2291,7 +2328,7 @@@ F:      arch/arm/mach-highbank
  ARM/CAVIUM THUNDER NETWORK DRIVER
  M:    Sunil Goutham <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/cavium/thunder/
  
  ARM/CIRRUS LOGIC BK3 MACHINE SUPPORT
@@@ -2870,13 -2833,6 +2870,13 @@@ S:    Maintaine
  F:    arch/arm64/boot/dts/freescale/s32g*.dts*
  F:    drivers/pinctrl/nxp/
  
 +ARM/NXP S32G/S32R DWMAC ETHERNET DRIVER
 +M:    Jan Petrous <[email protected]>
 +L:    NXP S32 Linux Team <[email protected]>
 +S:    Maintained
 +F:    Documentation/devicetree/bindings/net/nxp,s32-dwmac.yaml
 +F:    drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
 +
  ARM/Orion SoC/Technologic Systems TS-78xx platform support
  M:    Alexander Clouter <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
@@@ -3064,7 -3020,6 +3064,7 @@@ F:      drivers/*/*s3c24
  F:    drivers/*/*s3c64xx*
  F:    drivers/*/*s5pv210*
  F:    drivers/clocksource/samsung_pwm_timer.c
 +F:    drivers/mailbox/exynos-mailbox.c
  F:    drivers/memory/samsung/
  F:    drivers/pwm/pwm-samsung.c
  F:    drivers/soc/samsung/
@@@ -3704,7 -3659,7 +3704,7 @@@ F:      include/uapi/linux/sonet.
  ATMEL MACB ETHERNET DRIVER
  M:    Nicolas Ferre <[email protected]>
  M:    Claudiu Beznea <[email protected]>
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/cadence/
  
  ATMEL MAXTOUCH DRIVER
@@@ -3912,9 -3867,9 +3912,9 @@@ S:      Maintaine
  F:    drivers/platform/x86/barco-p50-gpio.c
  
  BATMAN ADVANCED
 -M:    Marek Lindner <marek[email protected]>
 +M:    Marek Lindner <marek[email protected]>
  M:    Simon Wunderlich <[email protected]>
 -M:    Antonio Quartulli <a@unstable.cc>
 +M:    Antonio Quartulli <a[email protected]>
  M:    Sven Eckelmann <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  S:    Maintained
@@@ -4432,7 -4387,7 +4432,7 @@@ F:      drivers/net/ethernet/broadcom/asp2
  BROADCOM B44 10/100 ETHERNET DRIVER
  M:    Michael Chan <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/broadcom/b44.*
  
  BROADCOM B53/SF2 ETHERNET SWITCH DRIVER
@@@ -4616,7 -4571,7 +4616,7 @@@ BROADCOM BNX2 GIGABIT ETHERNET DRIVE
  M:    Rasesh Mody <[email protected]>
  M:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/broadcom/bnx2.*
  F:    drivers/net/ethernet/broadcom/bnx2_*
  
@@@ -4640,14 -4595,13 +4640,14 @@@ BROADCOM BNX2X 10 GIGABIT ETHERNET DRIV
  M:    Sudarsana Kalluru <[email protected]>
  M:    Manish Chopra <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/broadcom/bnx2x/
  
  BROADCOM BNXT_EN 50 GIGABIT ETHERNET DRIVER
  M:    Michael Chan <[email protected]>
 +M:    Pavan Chebbi <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/firmware/broadcom/tee_bnxt_fw.c
  F:    drivers/net/ethernet/broadcom/bnxt/
  F:    include/linux/firmware/broadcom/tee_bnxt_fw.h
@@@ -4743,7 -4697,7 +4743,7 @@@ M:      Doug Berger <[email protected]
  M:    Florian Fainelli <[email protected]>
  R:    Broadcom internal kernel review list <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/brcm,bcmgenet.yaml
  F:    Documentation/devicetree/bindings/net/brcm,unimac-mdio.yaml
  F:    drivers/net/ethernet/broadcom/genet/
@@@ -4810,7 -4764,6 +4810,7 @@@ F:      drivers/scsi/mpi3mr
  
  BROADCOM NETXTREME-E ROCE DRIVER
  M:    Selvin Xavier <[email protected]>
 +M:    Kalesh AP <[email protected]>
  L:    [email protected]
  S:    Supported
  W:    http://www.broadcom.com
@@@ -4896,7 -4849,7 +4896,7 @@@ BROADCOM SYSTEMPORT ETHERNET DRIVE
  M:    Florian Fainelli <[email protected]>
  R:    Broadcom internal kernel review list <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/brcm,systemport.yaml
  F:    drivers/net/ethernet/broadcom/bcmsysport.*
  F:    drivers/net/ethernet/broadcom/unimac.h
@@@ -4905,7 -4858,7 +4905,7 @@@ BROADCOM TG3 GIGABIT ETHERNET DRIVE
  M:    Pavan Chebbi <[email protected]>
  M:    Michael Chan <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/broadcom/tg3.*
  
  BROADCOM VK DRIVER
@@@ -4927,7 -4880,7 +4927,7 @@@ M:      Rasesh Mody <[email protected]
  M:    Sudarsana Kalluru <[email protected]>
  M:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/brocade/bna/
  
  BSG (block layer generic sg v4 driver)
@@@ -5153,7 -5106,6 +5153,7 @@@ F:      include/uapi/linux/can/gw.
  F:    include/uapi/linux/can/isotp.h
  F:    include/uapi/linux/can/raw.h
  F:    net/can/
 +F:    net/sched/em_canid.c
  
  CAN-J1939 NETWORK LAYER
  M:    Robin van der Gracht <[email protected]>
@@@ -5193,7 -5145,6 +5193,7 @@@ M:      Serge Hallyn <[email protected]
  L:    [email protected]
  S:    Supported
  F:    include/linux/capability.h
 +F:    include/trace/events/capability.h
  F:    include/uapi/linux/capability.h
  F:    kernel/capability.c
  F:    security/commoncap.c
@@@ -5514,7 -5465,6 +5514,7 @@@ L:      [email protected]
  L:    [email protected]
  S:    Maintained
  F:    Documentation/devicetree/bindings/sound/cirrus,cs*
 +F:    Documentation/sound/codecs/cs*
  F:    drivers/mfd/cs42l43*
  F:    drivers/pinctrl/cirrus/pinctrl-cs42l43*
  F:    drivers/spi/spi-cs42l43*
@@@ -5547,8 -5497,8 +5547,8 @@@ L:      [email protected]
  S:    Supported
  W:    https://github.com/CirrusLogic/linux-drivers/wiki
  T:    git https://github.com/CirrusLogic/linux-drivers.git
 -F:    drivers/firmware/cirrus/*
 -F:    include/linux/firmware/cirrus/*
 +F:    drivers/firmware/cirrus/
 +F:    include/linux/firmware/cirrus/
  
  CIRRUS LOGIC EP93XX ETHERNET DRIVER
  M:    Hartley Sweeten <[email protected]>
@@@ -5618,7 -5568,7 +5618,7 @@@ F:      drivers/scsi/snic
  CISCO VIC ETHERNET NIC DRIVER
  M:    Christian Benvenuti <[email protected]>
  M:    Satish Kharat <[email protected]>
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/cisco/enic/
  
  CISCO VIC LOW LATENCY NIC DRIVER
@@@ -6104,30 -6054,12 +6104,30 @@@ S:   Maintaine
  F:    Documentation/filesystems/cramfs.rst
  F:    fs/cramfs/
  
 +CRC LIBRARY
 +M:    Eric Biggers <[email protected]>
 +R:    Ard Biesheuvel <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +T:    git https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git crc-next
 +F:    Documentation/staging/crc*
 +F:    arch/*/lib/crc*
 +F:    include/linux/crc*
 +F:    lib/crc*
 +
  CREATIVE SB0540
  M:    Bastien Nocera <[email protected]>
  L:    [email protected]
  S:    Maintained
  F:    drivers/hid/hid-creative-sb0540.c
  
 +INTEL CRPS COMMON REDUNDANT PSU DRIVER
 +M:    Ninad Palsule <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    Documentation/hwmon/crps.rst
 +F:    drivers/hwmon/pmbus/crps.c
 +
  CRYPTO API
  M:    Herbert Xu <[email protected]>
  M:    "David S. Miller" <[email protected]>
@@@ -6234,7 -6166,7 +6234,7 @@@ F:      drivers/media/dvb-frontends/cxd2820r
  CXGB3 ETHERNET DRIVER (CXGB3)
  M:    Potnuri Bharat Teja <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.chelsio.com
  F:    drivers/net/ethernet/chelsio/cxgb3/
  
@@@ -6255,14 -6187,14 +6255,14 @@@ F:   drivers/crypto/chelsi
  CXGB4 ETHERNET DRIVER (CXGB4)
  M:    Potnuri Bharat Teja <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.chelsio.com
  F:    drivers/net/ethernet/chelsio/cxgb4/
  
  CXGB4 INLINE CRYPTO DRIVER
  M:    Ayush Sawal <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.chelsio.com
  F:    drivers/net/ethernet/chelsio/inline_crypto/
  
@@@ -6284,7 -6216,7 +6284,7 @@@ F:      include/uapi/rdma/cxgb4-abi.
  CXGB4VF ETHERNET DRIVER (CXGB4VF)
  M:    Potnuri Bharat Teja <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.chelsio.com
  F:    drivers/net/ethernet/chelsio/cxgb4vf/
  
@@@ -6292,8 -6224,8 +6292,8 @@@ CXL (IBM Coherent Accelerator Processo
  M:    Frederic Barrat <[email protected]>
  M:    Andrew Donnellan <[email protected]>
  L:    [email protected]
 -S:    Supported
 -F:    Documentation/ABI/testing/sysfs-class-cxl
 +S:    Obsolete
 +F:    Documentation/ABI/obsolete/sysfs-class-cxl
  F:    Documentation/arch/powerpc/cxl.rst
  F:    arch/powerpc/platforms/powernv/pci-cxl.c
  F:    drivers/misc/cxl/
  S:    Maintained
  F:    drivers/rtc/rtc-sd2405al.c
  
 -DH ELECTRONICS IMX6 DHCOM/DHCOR BOARD SUPPORT
 +DH ELECTRONICS DHSOM SOM AND BOARD SUPPORT
  M:    Christoph Niedermaier <[email protected]>
 -L:    [email protected]
 -S:    Maintained
 -F:    arch/arm/boot/dts/nxp/imx/imx6*-dhcom-*
 -F:    arch/arm/boot/dts/nxp/imx/imx6*-dhcor-*
 -
 -DH ELECTRONICS STM32MP1 DHCOM/DHCOR BOARD SUPPORT
  M:    Marek Vasut <[email protected]>
  L:    [email protected]
  S:    Maintained
 -F:    arch/arm/boot/dts/st/stm32mp1*-dhcom-*
 -F:    arch/arm/boot/dts/st/stm32mp1*-dhcor-*
 +N:    dhcom
 +N:    dhcor
 +N:    dhsom
  
  DIALOG SEMICONDUCTOR DRIVERS
  M:    Support Opensource <[email protected]>
@@@ -7129,8 -7066,7 +7129,8 @@@ T:      git https://gitlab.freedesktop.org/d
  F:    drivers/gpu/drm/sun4i/sun8i*
  
  DRM DRIVER FOR ARM PL111 CLCD
 -S:    Orphan
 +M:    Linus Walleij <[email protected]>
 +S:    Maintained
  T:    git https://gitlab.freedesktop.org/drm/misc/kernel.git
  F:    drivers/gpu/drm/pl111/
  
@@@ -7445,7 -7381,7 +7445,7 @@@ L:      [email protected]
  S:    Obsolete
  W:    https://www.kraxel.org/blog/2014/10/qemu-using-cirrus-considered-harmful/
  T:    git https://gitlab.freedesktop.org/drm/misc/kernel.git
 -F:    drivers/gpu/drm/tiny/cirrus.c
 +F:    drivers/gpu/drm/tiny/cirrus-qemu.c
  
  DRM DRIVER FOR QXL VIRTUAL GPU
  M:    Dave Airlie <[email protected]>
@@@ -7856,7 -7792,6 +7856,7 @@@ F:      drivers/gpu/drm/rockchip
  
  DRM DRIVERS FOR STI
  M:    Alain Volmat <[email protected]>
 +M:    Raphael Gallais-Pou <[email protected]>
  L:    [email protected]
  S:    Maintained
  T:    git https://gitlab.freedesktop.org/drm/misc/kernel.git
@@@ -8457,7 -8392,7 +8457,7 @@@ M:      Ajit Khaparde <ajit.khaparde@broadco
  M:    Sriharsha Basavapatna <[email protected]>
  M:    Somnath Kotur <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    http://www.emulex.com
  F:    drivers/net/ethernet/emulex/benet/
  
@@@ -8612,8 -8547,8 +8612,8 @@@ F:      rust/kernel/net/phy.r
  F:    rust/kernel/net/phy/reg.rs
  
  EXEC & BINFMT API, ELF
 +M:    Kees Cook <[email protected]>
  R:    Eric Biederman <[email protected]>
 -R:    Kees Cook <[email protected]>
  L:    [email protected]
  S:    Supported
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/execve
@@@ -8625,7 -8560,6 +8625,7 @@@ F:      fs/tests/binfmt_*_kunit.
  F:    fs/tests/exec_kunit.c
  F:    include/linux/binfmts.h
  F:    include/linux/elf.h
 +F:    include/uapi/linux/auxvec.h
  F:    include/uapi/linux/binfmts.h
  F:    include/uapi/linux/elf.h
  F:    tools/testing/selftests/exec/
  S:    Maintained
  F:    drivers/input/joystick/fsia6b.c
  
 -FOCUSRITE SCARLETT2 MIXER DRIVER (Scarlett Gen 2+ and Clarett)
 +FOCUSRITE CONTROL PROTOCOL/SCARLETT2 MIXER DRIVERS (Scarlett Gen 2+, Clarett, and Vocaster)
  M:    Geoffrey D. Bennett <[email protected]>
  L:    [email protected]
  S:    Maintained
 -W:    https://github.com/geoffreybennett/scarlett-gen2
 -B:    https://github.com/geoffreybennett/scarlett-gen2/issues
 -T:    git https://github.com/geoffreybennett/scarlett-gen2.git
 +W:    https://github.com/geoffreybennett/linux-fcp
 +B:    https://github.com/geoffreybennett/linux-fcp/issues
 +T:    git https://github.com/geoffreybennett/linux-fcp.git
 +F:    include/uapi/sound/fcp.h
  F:    include/uapi/sound/scarlett2.h
 +F:    sound/usb/fcp.c
  F:    sound/usb/mixer_scarlett2.c
  
  FORCEDETH GIGABIT ETHERNET DRIVER
@@@ -9499,7 -9431,7 +9499,7 @@@ F:      samples/ftrac
  FUNGIBLE ETHERNET DRIVERS
  M:    Dimitris Michailidis <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/fungible/
  
  FUSE: FILESYSTEM IN USERSPACE
@@@ -9804,7 -9736,7 +9804,7 @@@ M:      Jeroen de Borst <[email protected]
  M:    Praveen Kaligineedi <[email protected]>
  R:    Shailend Chand <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/google/gve.rst
  F:    drivers/net/ethernet/google
  
@@@ -9819,12 -9751,9 +9819,12 @@@ F:    drivers/firmware/google
  
  GOOGLE TENSOR SoC SUPPORT
  M:    Peter Griffin <[email protected]>
 +R:    André Draszik <[email protected]>
 +R:    Tudor Ambarus <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  L:    [email protected]
  S:    Maintained
 +C:    irc://irc.oftc.net/pixel6-kernel-dev
  F:    Documentation/devicetree/bindings/clock/google,gs101-clock.yaml
  F:    arch/arm64/boot/dts/exynos/google/
  F:    drivers/clk/samsung/clk-gs101.c
@@@ -10347,6 -10276,7 +10347,6 @@@ F:   drivers/input/touchscreen/himax_hx83
  
  HIPPI
  M:    Jes Sorensen <[email protected]>
 -L:    [email protected]
  S:    Maintained
  F:    drivers/net/hippi/
  F:    include/linux/hippidevice.h
@@@ -10739,8 -10669,10 +10739,8 @@@ F:  Documentation/devicetree/bindings/bu
  F:    Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst
  F:    Documentation/virt/hyperv
  F:    arch/arm64/hyperv
 -F:    arch/arm64/include/asm/hyperv-tlfs.h
  F:    arch/arm64/include/asm/mshyperv.h
  F:    arch/x86/hyperv
 -F:    arch/x86/include/asm/hyperv-tlfs.h
  F:    arch/x86/include/asm/mshyperv.h
  F:    arch/x86/include/asm/trace/hyperv.h
  F:    arch/x86/kernel/cpu/mshyperv.c
@@@ -10756,13 -10688,9 +10756,13 @@@ F: drivers/pci/controller/pci-hyperv.
  F:    drivers/scsi/storvsc_drv.c
  F:    drivers/uio/uio_hv_generic.c
  F:    drivers/video/fbdev/hyperv_fb.c
 -F:    include/asm-generic/hyperv-tlfs.h
  F:    include/asm-generic/mshyperv.h
  F:    include/clocksource/hyperv_timer.h
 +F:    include/hyperv/hvgdk.h
 +F:    include/hyperv/hvgdk_ext.h
 +F:    include/hyperv/hvgdk_mini.h
 +F:    include/hyperv/hvhdk.h
 +F:    include/hyperv/hvhdk_mini.h
  F:    include/linux/hyperv.h
  F:    include/net/mana
  F:    include/uapi/linux/hyperv.h
@@@ -11030,7 -10958,7 +11030,7 @@@ M:   Rick Lindsley <[email protected]
  R:    Nick Child <[email protected]>
  R:    Thomas Falcon <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/ibm/ibmvnic.*
  
  IBM Power VFIO Support
@@@ -11041,7 -10969,7 +11041,7 @@@ F:   drivers/vfio/vfio_iommu_spapr_tce.
  IBM Power Virtual Ethernet Device Driver
  M:    Nick Child <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/ibm/ibmveth.*
  
  IBM Power Virtual FC Device Drivers
@@@ -11574,7 -11502,7 +11574,7 @@@ INTEL ETHERNET DRIVER
  M:    Tony Nguyen <[email protected]>
  M:    Przemek Kitszel <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
 -S:    Supported
 +S:    Maintained
  W:    https://www.intel.com/content/www/us/en/support.html
  Q:    https://patchwork.ozlabs.org/project/intel-wired-lan/list/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue.git
@@@ -11943,12 -11871,6 +11943,12 @@@ S: Maintaine
  F:    arch/x86/include/asm/intel_telemetry.h
  F:    drivers/platform/x86/intel/telemetry/
  
 +INTEL TOUCH HOST CONTROLLER (THC) DRIVER
 +M:    Even Xu <[email protected]>
 +M:    Xinpeng Sun <[email protected]>
 +S:    Maintained
 +F:    drivers/hid/intel-thc-hid/
 +
  INTEL TPMI DRIVER
  M:    Srinivas Pandruvada <[email protected]>
  L:    [email protected]
@@@ -12149,7 -12071,7 +12149,7 @@@ F:   include/uapi/linux/io_uring.
  F:    io_uring/
  
  IPMI SUBSYSTEM
 -M:    Corey Minyard <[email protected]>
 +M:    Corey Minyard <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  S:    Supported
  W:    http://openipmi.sourceforge.net/
@@@ -12461,13 -12383,6 +12461,13 @@@ F: Documentation/kbuild/kconfig
  F:    scripts/Kconfig.include
  F:    scripts/kconfig/
  
 +KCORE
 +M:    Omar Sandoval <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    fs/proc/kcore.c
 +F:    include/linux/kcore.h
 +
  KCOV
  R:    Dmitry Vyukov <[email protected]>
  R:    Andrey Konovalov <[email protected]>
@@@ -12686,8 -12601,8 +12686,8 @@@ F:   arch/arm64/include/asm/kvm
  F:    arch/arm64/include/uapi/asm/kvm*
  F:    arch/arm64/kvm/
  F:    include/kvm/arm_*
- F:    tools/testing/selftests/kvm/*/aarch64/
- F:    tools/testing/selftests/kvm/aarch64/
+ F:    tools/testing/selftests/kvm/*/arm64/
+ F:    tools/testing/selftests/kvm/arm64/
  
  KERNEL VIRTUAL MACHINE FOR LOONGARCH (KVM/LoongArch)
  M:    Tianrui Zhao <[email protected]>
@@@ -12758,8 -12673,8 +12758,8 @@@ F:   arch/s390/kvm
  F:    arch/s390/mm/gmap.c
  F:    drivers/s390/char/uvdevice.c
  F:    tools/testing/selftests/drivers/s390x/uvdevice/
- F:    tools/testing/selftests/kvm/*/s390x/
- F:    tools/testing/selftests/kvm/s390x/
+ F:    tools/testing/selftests/kvm/*/s390/
+ F:    tools/testing/selftests/kvm/s390/
  
  KERNEL VIRTUAL MACHINE FOR X86 (KVM/x86)
  M:    Sean Christopherson <[email protected]>
@@@ -12776,8 -12691,8 +12776,8 @@@ F:   arch/x86/include/uapi/asm/svm.
  F:    arch/x86/include/uapi/asm/vmx.h
  F:    arch/x86/kvm/
  F:    arch/x86/kvm/*/
- F:    tools/testing/selftests/kvm/*/x86_64/
- F:    tools/testing/selftests/kvm/x86_64/
+ F:    tools/testing/selftests/kvm/*/x86/
+ F:    tools/testing/selftests/kvm/x86/
  
  KERNFS
  M:    Greg Kroah-Hartman <[email protected]>
  S:    Maintained
  W:    http://kgdb.wiki.kernel.org/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb.git
 -F:    Documentation/dev-tools/kgdb.rst
 +F:    Documentation/process/debugging/kgdb.rst
  F:    drivers/misc/kgdbts.c
  F:    drivers/tty/serial/kgdboc.c
  F:    include/linux/kdb.h
@@@ -13195,7 -13110,7 +13195,7 @@@ LIBETH COMMON ETHERNET LIBRAR
  M:    Alexander Lobakin <[email protected]>
  L:    [email protected]
  L:    [email protected] (moderated for non-subscribers)
 -S:    Supported
 +S:    Maintained
  T:    git https://github.com/alobakin/linux.git
  F:    drivers/net/ethernet/intel/libeth/
  F:    include/net/libeth/
@@@ -13205,7 -13120,7 +13205,7 @@@ LIBIE COMMON INTEL ETHERNET LIBRAR
  M:    Alexander Lobakin <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  T:    git https://github.com/alobakin/linux.git
  F:    drivers/net/ethernet/intel/libie/
  F:    include/linux/net/intel/libie/
  L:    [email protected]
  L:    [email protected]
  S:    Supported
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
  F:    Documentation/atomic_bitops.txt
  F:    Documentation/atomic_t.txt
  F:    Documentation/core-api/refcount-vs-atomic.rst
@@@ -13506,8 -13421,8 +13506,8 @@@ LOCKING PRIMITIVE
  M:    Peter Zijlstra <[email protected]>
  M:    Ingo Molnar <[email protected]>
  M:    Will Deacon <[email protected]>
 +M:    Boqun Feng <[email protected]> (LOCKDEP & RUST)
  R:    Waiman Long <[email protected]>
 -R:    Boqun Feng <[email protected]> (LOCKDEP)
  L:    [email protected]
  S:    Maintained
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
@@@ -13521,11 -13436,6 +13521,11 @@@ F: include/linux/seqlock.
  F:    include/linux/spinlock*.h
  F:    kernel/locking/
  F:    lib/locking*.[ch]
 +F:    rust/helpers/mutex.c
 +F:    rust/helpers/spinlock.c
 +F:    rust/kernel/sync/lock.rs
 +F:    rust/kernel/sync/lock/
 +F:    rust/kernel/sync/locked_by.rs
  X:    kernel/locking/locktorture.c
  
  LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP/Vista Dynamic Disks)
@@@ -13630,12 -13540,6 +13630,12 @@@ S: Maintaine
  F:    Documentation/devicetree/bindings/thermal/loongson,ls2k-thermal.yaml
  F:    drivers/thermal/loongson2_thermal.c
  
 +LOONGSON EDAC DRIVER
 +M:    Zhao Qunqin <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    drivers/edac/loongson_edac.c
 +
  LSILOGIC MPT FUSION DRIVERS (FC/SAS/SPI)
  M:    Sathya Prakash <[email protected]>
  M:    Sreekanth Reddy <[email protected]>
@@@ -14019,7 -13923,7 +14019,7 @@@ MARVELL OCTEON ENDPOINT DRIVE
  M:    Veerasenareddy Burru <[email protected]>
  M:    Sathesh Edara <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/marvell/octeon_ep
  
  MARVELL OCTEON ENDPOINT VF DRIVER
@@@ -14028,7 -13932,7 +14028,7 @@@ M:   Sathesh Edara <[email protected]
  M:    Shinas Rasheed <[email protected]>
  M:    Satananda Burla <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/marvell/octeon_ep_vf
  
  MARVELL OCTEONTX2 PHYSICAL FUNCTION DRIVER
@@@ -14036,9 -13940,8 +14036,9 @@@ M:   Sunil Goutham <[email protected]
  M:    Geetha sowjanya <[email protected]>
  M:    Subbaraya Sundeep <[email protected]>
  M:    hariprasad <[email protected]>
 +M:    Bharat Bhushan <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/marvell/octeontx2/nic/
  F:    include/linux/soc/marvell/octeontx2/
  
@@@ -14050,7 -13953,7 +14050,7 @@@ M:   Jerin Jacob <[email protected]
  M:    hariprasad <[email protected]>
  M:    Subbaraya Sundeep <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
  F:    drivers/net/ethernet/marvell/octeontx2/af/
  
@@@ -14938,7 -14841,7 +14938,7 @@@ F:   drivers/i2c/busses/i2c-mlxbf.
  MELLANOX ETHERNET DRIVER (mlx4_en)
  M:    Tariq Toukan <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.nvidia.com/networking/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    drivers/net/ethernet/mellanox/mlx4/en_*
@@@ -14947,7 -14850,7 +14947,7 @@@ MELLANOX ETHERNET DRIVER (mlx5e
  M:    Saeed Mahameed <[email protected]>
  M:    Tariq Toukan <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.nvidia.com/networking/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    drivers/net/ethernet/mellanox/mlx5/core/en_*
  MELLANOX ETHERNET INNOVA DRIVERS
  R:    Boris Pismenny <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.nvidia.com/networking/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    drivers/net/ethernet/mellanox/mlx5/core/en_accel/*
@@@ -14994,7 -14897,7 +14994,7 @@@ MELLANOX MLX4 core VPI drive
  M:    Tariq Toukan <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.nvidia.com/networking/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    drivers/net/ethernet/mellanox/mlx4/
@@@ -15016,7 -14919,7 +15016,7 @@@ M:   Leon Romanovsky <[email protected]
  M:    Tariq Toukan <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  W:    https://www.nvidia.com/networking/
  Q:    https://patchwork.kernel.org/project/netdevbpf/list/
  F:    Documentation/networking/device_drivers/ethernet/mellanox/
@@@ -15250,7 -15153,7 +15250,7 @@@ META ETHERNET DRIVER
  M:    Alexander Duyck <[email protected]>
  M:    Jakub Kicinski <[email protected]>
  R:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/meta/
  F:    drivers/net/ethernet/meta/
  
@@@ -16258,8 -16161,7 +16258,8 @@@ M:   Breno Leitao <[email protected]
  S:    Maintained
  F:    Documentation/networking/netconsole.rst
  F:    drivers/net/netconsole.c
 -F:    tools/testing/selftests/drivers/net/netcons_basic.sh
 +F:    tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
 +F:    tools/testing/selftests/drivers/net/netcons\*
  
  NETDEVSIM
  M:    Jakub Kicinski <[email protected]>
@@@ -16276,7 -16178,7 +16276,7 @@@ F:   net/sched/sch_netem.
  NETERION 10GbE DRIVERS (s2io)
  M:    Jon Mason <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/neterion/s2io.rst
  F:    drivers/net/ethernet/neterion/
  
@@@ -16375,7 -16277,7 +16375,7 @@@ F:   include/linux/inetdevice.
  F:    include/linux/netdev*
  F:    include/linux/platform_data/wiznet.h
  F:    include/uapi/linux/cn_proc.h
 -F:    include/uapi/linux/ethtool_netlink.h
 +F:    include/uapi/linux/ethtool_netlink*
  F:    include/uapi/linux/if_*
  F:    include/uapi/linux/net_shaper.h
  F:    include/uapi/linux/netdev*
@@@ -16601,7 -16503,7 +16601,7 @@@ M:   Manish Chopra <[email protected]
  M:    Rahul Verma <[email protected]>
  M:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/qlogic/netxen/
  
  NET_FAILOVER MODULE
@@@ -17733,7 -17635,6 +17733,7 @@@ F:   Documentation/core-api/packing.rs
  F:    include/linux/packing.h
  F:    lib/packing.c
  F:    lib/packing_test.c
 +F:    scripts/gen_packed_field_checks.c
  
  PADATA PARALLEL EXECUTION MECHANISM
  M:    Steffen Klassert <[email protected]>
@@@ -18378,7 -18279,7 +18378,7 @@@ PENSANDO ETHERNET DRIVER
  M:    Shannon Nelson <[email protected]>
  M:    Brett Creeley <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/device_drivers/ethernet/pensando/ionic.rst
  F:    drivers/net/ethernet/pensando/
  
@@@ -19145,7 -19046,7 +19145,7 @@@ F:   drivers/scsi/qedi
  QLOGIC QL4xxx ETHERNET DRIVER
  M:    Manish Chopra <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/qlogic/qed/
  F:    drivers/net/ethernet/qlogic/qede/
  F:    include/linux/qed/
@@@ -19173,7 -19074,7 +19173,7 @@@ F:   drivers/scsi/qla2xxx
  QLOGIC QLA3XXX NETWORK DRIVER
  M:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/qlogic/qla3xxx.*
  
  QLOGIC QLA4XXX iSCSI DRIVER
@@@ -19189,7 -19090,7 +19189,7 @@@ M:   Shahed Shaikh <[email protected]
  M:    Manish Chopra <[email protected]>
  M:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/qlogic/qlcnic/
  
  QM1D1B0004 MEDIA DRIVER
  S:    Odd Fixes
  F:    drivers/media/tuners/qm1d1c0042*
  
 +QNAP MCU DRIVER
 +M:    Heiko Stuebner <[email protected]>
 +S:    Maintained
 +F:    drivers/hwmon/qnap-mcu-hwmon.c
 +F:    drivers/input/misc/qnap-mcu-input.c
 +F:    drivers/leds/leds-qnap-mcu.c
 +F:    drivers/mfd/qnap-mcu.c
 +F:    include/linux/mfd/qnap-mcu.h
 +
  QNX4 FILESYSTEM
  M:    Anders Larsen <[email protected]>
  S:    Maintained
@@@ -19708,7 -19600,7 +19708,7 @@@ R:   Mathieu Desnoyers <mathieu.desnoyers
  R:    Lai Jiangshan <[email protected]>
  L:    [email protected]
  S:    Supported
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
  F:    tools/testing/selftests/rcutorture
  
  RDACM20 Camera Sensor
@@@ -19787,7 -19679,7 +19787,7 @@@ R:   Zqiang <[email protected]
  L:    [email protected]
  S:    Supported
  W:    http://www.rdrop.com/users/paulmck/RCU/
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
  F:    Documentation/RCU/
  F:    include/linux/rcu*
  F:    kernel/rcu/
@@@ -19939,7 -19831,7 +19939,7 @@@ M:   Paul Barker <[email protected]
  M:    Niklas Söderlund <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/renesas,etheravb.yaml
  F:    drivers/net/ethernet/renesas/Kconfig
  F:    drivers/net/ethernet/renesas/Makefile
@@@ -19959,7 -19851,7 +19959,7 @@@ RENESAS ETHERNET TSN DRIVE
  M:    Niklas Söderlund <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/renesas,ethertsn.yaml
  F:    drivers/net/ethernet/renesas/rtsn.*
  
@@@ -20109,7 -20001,7 +20109,7 @@@ RENESAS SUPERH ETHERNET DRIVE
  M:    Niklas Söderlund <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/devicetree/bindings/net/renesas,ether.yaml
  F:    drivers/net/ethernet/renesas/Kconfig
  F:    drivers/net/ethernet/renesas/Makefile
@@@ -20177,7 -20069,7 +20177,7 @@@ F:   net/rfkill
  RHASHTABLE
  M:    Thomas Graf <[email protected]>
  M:    Herbert Xu <[email protected]>
 -L:    netdev@vger.kernel.org
 +L:    linux-crypto@vger.kernel.org
  S:    Maintained
  F:    include/linux/rhashtable-types.h
  F:    include/linux/rhashtable.h
@@@ -20284,15 -20176,6 +20284,15 @@@ F: drivers/perf/riscv_pmu.
  F:    drivers/perf/riscv_pmu_legacy.c
  F:    drivers/perf/riscv_pmu_sbi.c
  
 +RISC-V SPACEMIT SoC Support
 +M:    Yixun Lan <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +T:    git https://github.com/spacemit-com/linux
 +F:    arch/riscv/boot/dts/spacemit/
 +N:    spacemit
 +K:    spacemit
 +
  RISC-V THEAD SoC SUPPORT
  M:    Drew Fustini <[email protected]>
  M:    Guo Ren <[email protected]>
@@@ -20829,15 -20712,6 +20829,15 @@@ F: arch/arm64/boot/dts/exynos/exynos850
  F:    drivers/clk/samsung/clk-exynos850.c
  F:    include/dt-bindings/clock/exynos850.h
  
 +SAMSUNG EXYNOS MAILBOX DRIVER
 +M:    Tudor Ambarus <[email protected]>
 +L:    [email protected]
 +L:    [email protected]
 +S:    Supported
 +F:    Documentation/devicetree/bindings/mailbox/google,gs101-mbox.yaml
 +F:    drivers/mailbox/exynos-mailbox.c
 +F:    include/linux/mailbox/exynos-message.h
 +
  SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER
  M:    Krzysztof Kozlowski <[email protected]>
  L:    [email protected]
@@@ -20970,7 -20844,7 +20970,7 @@@ F:   include/linux/platform_data/spi-s3c6
  SAMSUNG SXGBE DRIVERS
  M:    Byungho An <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/samsung/sxgbe/
  
  SAMSUNG THERMAL DRIVER
@@@ -21372,7 -21246,7 +21372,7 @@@ M:   Edward Cree <[email protected]
  M:    Martin Habets <[email protected]>
  L:    [email protected]
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    Documentation/networking/devlink/sfc.rst
  F:    drivers/net/ethernet/sfc/
  
@@@ -21703,7 -21577,7 +21703,7 @@@ R:   Mathieu Desnoyers <mathieu.desnoyers
  L:    [email protected]
  S:    Supported
  W:    http://www.rdrop.com/users/paulmck/RCU/
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
  F:    include/linux/srcu*.h
  F:    kernel/rcu/srcu*.c
  
@@@ -22114,7 -21988,6 +22114,7 @@@ W:   https://github.com/thesofproject/lin
  F:    sound/soc/sof/
  
  SOUND - GENERIC SOUND CARD (Simple-Audio-Card, Audio-Graph-Card)
 +M:    Mark Brown <[email protected]>
  M:    Kuninori Morimoto <[email protected]>
  S:    Supported
  L:    [email protected]
@@@ -22569,7 -22442,7 +22569,7 @@@ F:   arch/*/kernel/static_call.
  F:    include/linux/jump_label*.h
  F:    include/linux/static_call*.h
  F:    kernel/jump_label.c
 -F:    kernel/static_call.c
 +F:    kernel/static_call*.c
  
  STI AUDIO (ASoC) DRIVERS
  M:    Arnaud Pouliquen <[email protected]>
@@@ -22854,7 -22727,7 +22854,7 @@@ F:   include/linux/platform_data/dma-dw.
  SYNOPSYS DESIGNWARE ENTERPRISE ETHERNET DRIVER
  M:    Jose Abreu <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/synopsys/
  
  SYNOPSYS DESIGNWARE ETHERNET XPCS DRIVER
@@@ -23254,7 -23127,7 +23254,7 @@@ F:   drivers/phy/tegra/xusb
  TEHUTI ETHERNET DRIVER
  M:    Andy Gospodarek <[email protected]>
  L:    [email protected]
 -S:    Supported
 +S:    Maintained
  F:    drivers/net/ethernet/tehuti/tehuti.*
  
  TEHUTI TN40XX ETHERNET DRIVER
@@@ -23340,8 -23213,6 +23340,8 @@@ M:   Jerome Brunet <[email protected]
  L:    [email protected]
  S:    Maintained
  F:    Documentation/devicetree/bindings/hwmon/pmbus/ti,tps25990.yaml
 +F:    Documentation/hwmon/tps25990.rst
 +F:    drivers/hwmon/pmbus/tps25990.c
  
  TEXAS INSTRUMENTS TPS23861 PoE PSE DRIVER
  M:    Robert Marko <[email protected]>
@@@ -23359,13 -23230,6 +23359,13 @@@ S: Supporte
  F:    Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml
  F:    drivers/iio/dac/ti-dac7612.c
  
 +TEXAS INSTRUMENTS' LB8864 LED BACKLIGHT DRIVER
 +M:    Alexander Sverdlin <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    Documentation/devicetree/bindings/leds/backlight/ti,lp8864.yaml
 +F:    drivers/leds/leds-lp8864.c
 +
  TEXAS INSTRUMENTS' SYSTEM CONTROL INTERFACE (TISCI) PROTOCOL DRIVER
  M:    Nishanth Menon <[email protected]>
  M:    Tero Kristo <[email protected]>
@@@ -23673,7 -23537,6 +23673,7 @@@ T:   git git://git.kernel.org/pub/scm/lin
  F:    Documentation/devicetree/bindings/soc/ti/ti,pruss.yaml
  F:    drivers/pmdomain/ti/omap_prm.c
  F:    drivers/soc/ti/*
 +F:    include/linux/pruss_driver.h
  
  TI LM49xxx FAMILY ASoC CODEC DRIVERS
  M:    M R Swami Reddy <[email protected]>
@@@ -23838,7 -23701,7 +23838,7 @@@ M:   "Paul E. McKenney" <[email protected]
  M:    Josh Triplett <[email protected]>
  L:    [email protected]
  S:    Supported
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rcu/linux.git rcu/dev
  F:    Documentation/RCU/torture.rst
  F:    kernel/locking/locktorture.c
  F:    kernel/rcu/rcuscale.c
index e8aeb4b4f868e87ff00e02277d4600133c2ac228,f378cd43241c6570411e2452ddbdbc060d3a41ba..b15cde0a9b5ca7ae2c90b15fed4a4debd34f825c
  #include <linux/pvclock_gtod.h>
  #include <linux/clocksource.h>
  #include <linux/irqbypass.h>
 -#include <linux/hyperv.h>
  #include <linux/kfifo.h>
  #include <linux/sched/vhost_task.h>
+ #include <linux/call_once.h>
  
  #include <asm/apic.h>
  #include <asm/pvclock-abi.h>
@@@ -35,8 -37,8 +36,8 @@@
  #include <asm/asm.h>
  #include <asm/kvm_page_track.h>
  #include <asm/kvm_vcpu_regs.h>
 -#include <asm/hyperv-tlfs.h>
  #include <asm/reboot.h>
 +#include <hyperv/hvhdk.h>
  
  #define __KVM_HAVE_ARCH_VCPU_DEBUGFS
  
@@@ -312,10 -314,11 +313,11 @@@ struct kvm_kernel_irq_routing_entry
   * the number of unique SPs that can theoretically be created is 2^n, where n
   * is the number of bits that are used to compute the role.
   *
-  * But, even though there are 19 bits in the mask below, not all combinations
+  * But, even though there are 20 bits in the mask below, not all combinations
   * of modes and flags are possible:
   *
-  *   - invalid shadow pages are not accounted, so the bits are effectively 18
+  *   - invalid shadow pages are not accounted, mirror pages are not shadowed,
+  *     so the bits are effectively 18.
   *
   *   - quadrant will only be used if has_4_byte_gpte=1 (non-PAE paging);
   *     execonly and ad_disabled are only used for nested EPT which has
@@@ -348,7 -351,8 +350,8 @@@ union kvm_mmu_page_role 
                unsigned ad_disabled:1;
                unsigned guest_mode:1;
                unsigned passthrough:1;
-               unsigned :5;
+               unsigned is_mirror:1;
+               unsigned :4;
  
                /*
                 * This is left at the top of the word so that
@@@ -456,6 -460,7 +459,7 @@@ struct kvm_mmu 
        int (*sync_spte)(struct kvm_vcpu *vcpu,
                         struct kvm_mmu_page *sp, int i);
        struct kvm_mmu_root_info root;
+       hpa_t mirror_root_hpa;
        union kvm_cpu_role cpu_role;
        union kvm_mmu_page_role root_role;
  
@@@ -738,6 -743,23 +742,23 @@@ struct kvm_queued_exception 
        bool has_payload;
  };
  
+ /*
+  * Hardware-defined CPUID leafs that are either scattered by the kernel or are
+  * unknown to the kernel, but need to be directly used by KVM.  Note, these
+  * word values conflict with the kernel's "bug" caps, but KVM doesn't use those.
+  */
+ enum kvm_only_cpuid_leafs {
+       CPUID_12_EAX     = NCAPINTS,
+       CPUID_7_1_EDX,
+       CPUID_8000_0007_EDX,
+       CPUID_8000_0022_EAX,
+       CPUID_7_2_EDX,
+       CPUID_24_0_EBX,
+       NR_KVM_CPU_CAPS,
+       NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS,
+ };
  struct kvm_vcpu_arch {
        /*
         * rip and regs accesses must go through
        struct kvm_mmu_memory_cache mmu_shadow_page_cache;
        struct kvm_mmu_memory_cache mmu_shadowed_info_cache;
        struct kvm_mmu_memory_cache mmu_page_header_cache;
+       /*
+        * This cache is to allocate external page table. E.g. private EPT used
+        * by the TDX module.
+        */
+       struct kvm_mmu_memory_cache mmu_external_spt_cache;
  
        /*
         * QEMU userspace and the guest each have their own FPU state.
  
        int cpuid_nent;
        struct kvm_cpuid_entry2 *cpuid_entries;
-       struct kvm_hypervisor_cpuid kvm_cpuid;
        bool is_amd_compatible;
  
        /*
-        * FIXME: Drop this macro and use KVM_NR_GOVERNED_FEATURES directly
-        * when "struct kvm_vcpu_arch" is no longer defined in an
-        * arch/x86/include/asm header.  The max is mostly arbitrary, i.e.
-        * can be increased as necessary.
-        */
- #define KVM_MAX_NR_GOVERNED_FEATURES BITS_PER_LONG
-       /*
-        * Track whether or not the guest is allowed to use features that are
-        * governed by KVM, where "governed" means KVM needs to manage state
-        * and/or explicitly enable the feature in hardware.  Typically, but
-        * not always, governed features can be used by the guest if and only
-        * if both KVM and userspace want to expose the feature to the guest.
+        * cpu_caps holds the effective guest capabilities, i.e. the features
+        * the vCPU is allowed to use.  Typically, but not always, features can
+        * be used by the guest if and only if both KVM and userspace want to
+        * expose the feature to the guest.
+        *
+        * A common exception is for virtualization holes, i.e. when KVM can't
+        * prevent the guest from using a feature, in which case the vCPU "has"
+        * the feature regardless of what KVM or userspace desires.
+        *
+        * Note, features that don't require KVM involvement in any way are
+        * NOT enforced/sanitized by KVM, i.e. are taken verbatim from the
+        * guest CPUID provided by userspace.
         */
-       struct {
-               DECLARE_BITMAP(enabled, KVM_MAX_NR_GOVERNED_FEATURES);
-       } governed_features;
+       u32 cpu_caps[NR_KVM_CPU_CAPS];
  
        u64 reserved_gpa_bits;
        int maxphyaddr;
@@@ -1444,6 -1467,7 +1466,7 @@@ struct kvm_arch 
        struct kvm_x86_pmu_event_filter __rcu *pmu_event_filter;
        struct vhost_task *nx_huge_page_recovery_thread;
        u64 nx_huge_page_last;
+       struct once nx_once;
  
  #ifdef CONFIG_X86_64
        /* The number of TDP MMU pages across all roots. */
         */
  #define SPLIT_DESC_CACHE_MIN_NR_OBJECTS (SPTE_ENT_PER_PAGE + 1)
        struct kvm_mmu_memory_cache split_desc_cache;
+       gfn_t gfn_direct_bits;
  };
  
  struct kvm_vm_stat {
@@@ -1733,8 -1759,7 +1758,7 @@@ struct kvm_x86_ops 
        const unsigned long required_apicv_inhibits;
        bool allow_apicv_in_x2apic_without_x2apic_virtualization;
        void (*refresh_apicv_exec_ctrl)(struct kvm_vcpu *vcpu);
-       void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
-       void (*hwapic_isr_update)(int isr);
+       void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr);
        void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
        void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);
        void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu);
        void (*load_mmu_pgd)(struct kvm_vcpu *vcpu, hpa_t root_hpa,
                             int root_level);
  
+       /* Update external mapping with page table link. */
+       int (*link_external_spt)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
+                               void *external_spt);
+       /* Update the external page table from spte getting set. */
+       int (*set_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
+                                kvm_pfn_t pfn_for_gfn);
+       /* Update external page tables for page table about to be freed. */
+       int (*free_external_spt)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
+                                void *external_spt);
+       /* Update external page table from spte getting removed, and flush TLB. */
+       int (*remove_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
+                                   kvm_pfn_t pfn_for_gfn);
        bool (*has_wbinvd_exit)(void);
  
        u64 (*get_l2_tsc_offset)(struct kvm_vcpu *vcpu);
        void (*write_tsc_multiplier)(struct kvm_vcpu *vcpu);
  
        /*
-        * Retrieve somewhat arbitrary exit information.  Intended to
+        * Retrieve somewhat arbitrary exit/entry information.  Intended to
         * be used only from within tracepoints or error paths.
         */
        void (*get_exit_info)(struct kvm_vcpu *vcpu, u32 *reason,
                              u64 *info1, u64 *info2,
-                             u32 *exit_int_info, u32 *exit_int_info_err_code);
+                             u32 *intr_info, u32 *error_code);
+       void (*get_entry_info)(struct kvm_vcpu *vcpu,
+                              u32 *intr_info, u32 *error_code);
  
        int (*check_intercept)(struct kvm_vcpu *vcpu,
                               struct x86_instruction_info *info,
@@@ -2018,8 -2061,8 +2060,8 @@@ u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu)
   *                    VMware backdoor emulation handles select instructions
   *                    and reinjects the #GP for all other cases.
   *
-  * EMULTYPE_PF - Set when emulating MMIO by way of an intercepted #PF, in which
-  *             case the CR2/GPA value pass on the stack is valid.
+  * EMULTYPE_PF - Set when an intercepted #PF triggers the emulation, in which case
+  *             the CR2/GPA value pass on the stack is valid.
   *
   * EMULTYPE_COMPLETE_USER_EXIT - Set when the emulator should update interruptibility
   *                             state and inject single-step #DBs after skipping
  #define EMULTYPE_COMPLETE_USER_EXIT (1 << 7)
  #define EMULTYPE_WRITE_PF_TO_SP           (1 << 8)
  
+ static inline bool kvm_can_emulate_event_vectoring(int emul_type)
+ {
+       return !(emul_type & EMULTYPE_PF);
+ }
  int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type);
  int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
                                        void *insn, int insn_len);
@@@ -2061,6 -2109,8 +2108,8 @@@ void __kvm_prepare_emulation_failure_ex
                                          u64 *data, u8 ndata);
  void kvm_prepare_emulation_failure_exit(struct kvm_vcpu *vcpu);
  
+ void kvm_prepare_event_vectoring_exit(struct kvm_vcpu *vcpu, gpa_t gpa);
  void kvm_enable_efer_bits(u64);
  bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer);
  int kvm_get_msr_with_filter(struct kvm_vcpu *vcpu, u32 index, u64 *data);
@@@ -2180,12 -2230,6 +2229,6 @@@ static inline void kvm_clear_apicv_inhi
        kvm_set_or_clear_apicv_inhibit(kvm, reason, false);
  }
  
- unsigned long __kvm_emulate_hypercall(struct kvm_vcpu *vcpu, unsigned long nr,
-                                     unsigned long a0, unsigned long a1,
-                                     unsigned long a2, unsigned long a3,
-                                     int op_64_bit, int cpl);
- int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
  int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code,
                       void *insn, int insn_len);
  void kvm_mmu_print_sptes(struct kvm_vcpu *vcpu, gpa_t gpa, const char *msg);
diff --combined arch/x86/kvm/cpuid.c
index f7e222953cab766da585988ba73392f139b04a9e,edef30359c198d28556c140f1043ab282c6f801b..2cbb3874ad3984d53c92b06eb1983f62c7d8aef6
@@@ -82,15 -82,6 +82,6 @@@ u32 xstate_required_size(u64 xstate_bv
        return ret;
  }
  
- #define F feature_bit
- /* Scattered Flag - For features that are scattered by cpufeatures.h. */
- #define SF(name)                                              \
- ({                                                            \
-       BUILD_BUG_ON(X86_FEATURE_##name >= MAX_CPU_FEATURES);   \
-       (boot_cpu_has(X86_FEATURE_##name) ? F(name) : 0);       \
- })
  /*
   * Magic value used by KVM when querying userspace-provided CPUID entries and
   * doesn't care about the CPIUD index because the index of the function in
   */
  #define KVM_CPUID_INDEX_NOT_SIGNIFICANT -1ull
  
- static inline struct kvm_cpuid_entry2 *cpuid_entry2_find(
-       struct kvm_cpuid_entry2 *entries, int nent, u32 function, u64 index)
+ static struct kvm_cpuid_entry2 *cpuid_entry2_find(struct kvm_vcpu *vcpu,
+                                                 u32 function, u64 index)
  {
        struct kvm_cpuid_entry2 *e;
        int i;
         */
        lockdep_assert_irqs_enabled();
  
-       for (i = 0; i < nent; i++) {
-               e = &entries[i];
+       for (i = 0; i < vcpu->arch.cpuid_nent; i++) {
+               e = &vcpu->arch.cpuid_entries[i];
  
                if (e->function != function)
                        continue;
        return NULL;
  }
  
- static int kvm_check_cpuid(struct kvm_vcpu *vcpu,
-                          struct kvm_cpuid_entry2 *entries,
-                          int nent)
+ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry_index(struct kvm_vcpu *vcpu,
+                                                   u32 function, u32 index)
+ {
+       return cpuid_entry2_find(vcpu, function, index);
+ }
+ EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry_index);
+ struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
+                                             u32 function)
+ {
+       return cpuid_entry2_find(vcpu, function, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
+ }
+ EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry);
+ /*
+  * cpuid_entry2_find() and KVM_CPUID_INDEX_NOT_SIGNIFICANT should never be used
+  * directly outside of kvm_find_cpuid_entry() and kvm_find_cpuid_entry_index().
+  */
+ #undef KVM_CPUID_INDEX_NOT_SIGNIFICANT
+ static int kvm_check_cpuid(struct kvm_vcpu *vcpu)
  {
        struct kvm_cpuid_entry2 *best;
        u64 xfeatures;
         * The existing code assumes virtual address is 48-bit or 57-bit in the
         * canonical address checks; exit if it is ever changed.
         */
-       best = cpuid_entry2_find(entries, nent, 0x80000008,
-                                KVM_CPUID_INDEX_NOT_SIGNIFICANT);
+       best = kvm_find_cpuid_entry(vcpu, 0x80000008);
        if (best) {
                int vaddr_bits = (best->eax & 0xff00) >> 8;
  
         * Exposing dynamic xfeatures to the guest requires additional
         * enabling in the FPU, e.g. to expand the guest XSAVE state size.
         */
-       best = cpuid_entry2_find(entries, nent, 0xd, 0);
+       best = kvm_find_cpuid_entry_index(vcpu, 0xd, 0);
        if (!best)
                return 0;
  
        return fpu_enable_guest_xfd_features(&vcpu->arch.guest_fpu, xfeatures);
  }
  
+ static u32 kvm_apply_cpuid_pv_features_quirk(struct kvm_vcpu *vcpu);
  /* Check whether the supplied CPUID data is equal to what is already set for the vCPU. */
  static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *e2,
                                 int nent)
        struct kvm_cpuid_entry2 *orig;
        int i;
  
+       /*
+        * Apply runtime CPUID updates to the incoming CPUID entries to avoid
+        * false positives due mismatches on KVM-owned feature flags.
+        *
+        * Note!  @e2 and @nent track the _old_ CPUID entries!
+        */
+       kvm_update_cpuid_runtime(vcpu);
+       kvm_apply_cpuid_pv_features_quirk(vcpu);
        if (nent != vcpu->arch.cpuid_nent)
                return -EINVAL;
  
        return 0;
  }
  
- static struct kvm_hypervisor_cpuid __kvm_get_hypervisor_cpuid(struct kvm_cpuid_entry2 *entries,
-                                                             int nent, const char *sig)
+ static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcpu,
+                                                           const char *sig)
  {
        struct kvm_hypervisor_cpuid cpuid = {};
        struct kvm_cpuid_entry2 *entry;
        u32 base;
  
        for_each_possible_hypervisor_cpuid_base(base) {
-               entry = cpuid_entry2_find(entries, nent, base, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
+               entry = kvm_find_cpuid_entry(vcpu, base);
  
                if (entry) {
                        u32 signature[3];
        return cpuid;
  }
  
- static struct kvm_hypervisor_cpuid kvm_get_hypervisor_cpuid(struct kvm_vcpu *vcpu,
-                                                           const char *sig)
+ static u32 kvm_apply_cpuid_pv_features_quirk(struct kvm_vcpu *vcpu)
  {
-       return __kvm_get_hypervisor_cpuid(vcpu->arch.cpuid_entries,
-                                         vcpu->arch.cpuid_nent, sig);
- }
- static struct kvm_cpuid_entry2 *__kvm_find_kvm_cpuid_features(struct kvm_cpuid_entry2 *entries,
-                                                             int nent, u32 kvm_cpuid_base)
- {
-       return cpuid_entry2_find(entries, nent, kvm_cpuid_base | KVM_CPUID_FEATURES,
-                                KVM_CPUID_INDEX_NOT_SIGNIFICANT);
- }
- static struct kvm_cpuid_entry2 *kvm_find_kvm_cpuid_features(struct kvm_vcpu *vcpu)
- {
-       u32 base = vcpu->arch.kvm_cpuid.base;
+       struct kvm_hypervisor_cpuid kvm_cpuid;
+       struct kvm_cpuid_entry2 *best;
  
-       if (!base)
-               return NULL;
+       kvm_cpuid = kvm_get_hypervisor_cpuid(vcpu, KVM_SIGNATURE);
+       if (!kvm_cpuid.base)
+               return 0;
  
-       return __kvm_find_kvm_cpuid_features(vcpu->arch.cpuid_entries,
-                                            vcpu->arch.cpuid_nent, base);
- }
+       best = kvm_find_cpuid_entry(vcpu, kvm_cpuid.base | KVM_CPUID_FEATURES);
+       if (!best)
+               return 0;
  
- void kvm_update_pv_runtime(struct kvm_vcpu *vcpu)
- {
-       struct kvm_cpuid_entry2 *best = kvm_find_kvm_cpuid_features(vcpu);
+       if (kvm_hlt_in_guest(vcpu->kvm))
+               best->eax &= ~(1 << KVM_FEATURE_PV_UNHALT);
  
-       /*
-        * save the feature bitmap to avoid cpuid lookup for every PV
-        * operation
-        */
-       if (best)
-               vcpu->arch.pv_cpuid.features = best->eax;
+       return best->eax;
  }
  
  /*
   * Calculate guest's supported XCR0 taking into account guest CPUID data and
   * KVM's supported XCR0 (comprised of host's XCR0 and KVM_SUPPORTED_XCR0).
   */
- static u64 cpuid_get_supported_xcr0(struct kvm_cpuid_entry2 *entries, int nent)
+ static u64 cpuid_get_supported_xcr0(struct kvm_vcpu *vcpu)
  {
        struct kvm_cpuid_entry2 *best;
  
-       best = cpuid_entry2_find(entries, nent, 0xd, 0);
+       best = kvm_find_cpuid_entry_index(vcpu, 0xd, 0);
        if (!best)
                return 0;
  
        return (best->eax | ((u64)best->edx << 32)) & kvm_caps.supported_xcr0;
  }
  
- static void __kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *entries,
-                                      int nent)
+ static __always_inline void kvm_update_feature_runtime(struct kvm_vcpu *vcpu,
+                                                      struct kvm_cpuid_entry2 *entry,
+                                                      unsigned int x86_feature,
+                                                      bool has_feature)
+ {
+       cpuid_entry_change(entry, x86_feature, has_feature);
+       guest_cpu_cap_change(vcpu, x86_feature, has_feature);
+ }
+ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
  {
        struct kvm_cpuid_entry2 *best;
-       struct kvm_hypervisor_cpuid kvm_cpuid;
  
-       best = cpuid_entry2_find(entries, nent, 1, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
+       best = kvm_find_cpuid_entry(vcpu, 1);
        if (best) {
-               /* Update OSXSAVE bit */
-               if (boot_cpu_has(X86_FEATURE_XSAVE))
-                       cpuid_entry_change(best, X86_FEATURE_OSXSAVE,
+               kvm_update_feature_runtime(vcpu, best, X86_FEATURE_OSXSAVE,
                                           kvm_is_cr4_bit_set(vcpu, X86_CR4_OSXSAVE));
  
-               cpuid_entry_change(best, X86_FEATURE_APIC,
-                          vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE);
+               kvm_update_feature_runtime(vcpu, best, X86_FEATURE_APIC,
+                                          vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE);
+               if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT))
+                       kvm_update_feature_runtime(vcpu, best, X86_FEATURE_MWAIT,
+                                                  vcpu->arch.ia32_misc_enable_msr &
+                                                  MSR_IA32_MISC_ENABLE_MWAIT);
        }
  
-       best = cpuid_entry2_find(entries, nent, 7, 0);
-       if (best && boot_cpu_has(X86_FEATURE_PKU) && best->function == 0x7)
-               cpuid_entry_change(best, X86_FEATURE_OSPKE,
-                                  kvm_is_cr4_bit_set(vcpu, X86_CR4_PKE));
+       best = kvm_find_cpuid_entry_index(vcpu, 7, 0);
+       if (best)
+               kvm_update_feature_runtime(vcpu, best, X86_FEATURE_OSPKE,
+                                          kvm_is_cr4_bit_set(vcpu, X86_CR4_PKE));
  
-       best = cpuid_entry2_find(entries, nent, 0xD, 0);
+       best = kvm_find_cpuid_entry_index(vcpu, 0xD, 0);
        if (best)
                best->ebx = xstate_required_size(vcpu->arch.xcr0, false);
  
-       best = cpuid_entry2_find(entries, nent, 0xD, 1);
+       best = kvm_find_cpuid_entry_index(vcpu, 0xD, 1);
        if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) ||
                     cpuid_entry_has(best, X86_FEATURE_XSAVEC)))
                best->ebx = xstate_required_size(vcpu->arch.xcr0, true);
-       kvm_cpuid = __kvm_get_hypervisor_cpuid(entries, nent, KVM_SIGNATURE);
-       if (kvm_cpuid.base) {
-               best = __kvm_find_kvm_cpuid_features(entries, nent, kvm_cpuid.base);
-               if (kvm_hlt_in_guest(vcpu->kvm) && best)
-                       best->eax &= ~(1 << KVM_FEATURE_PV_UNHALT);
-       }
-       if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) {
-               best = cpuid_entry2_find(entries, nent, 0x1, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
-               if (best)
-                       cpuid_entry_change(best, X86_FEATURE_MWAIT,
-                                          vcpu->arch.ia32_misc_enable_msr &
-                                          MSR_IA32_MISC_ENABLE_MWAIT);
-       }
- }
- void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
- {
-       __kvm_update_cpuid_runtime(vcpu, vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent);
  }
  EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime);
  
- static bool kvm_cpuid_has_hyperv(struct kvm_cpuid_entry2 *entries, int nent)
+ static bool kvm_cpuid_has_hyperv(struct kvm_vcpu *vcpu)
  {
  #ifdef CONFIG_KVM_HYPERV
        struct kvm_cpuid_entry2 *entry;
  
-       entry = cpuid_entry2_find(entries, nent, HYPERV_CPUID_INTERFACE,
-                                 KVM_CPUID_INDEX_NOT_SIGNIFICANT);
+       entry = kvm_find_cpuid_entry(vcpu, HYPERV_CPUID_INTERFACE);
        return entry && entry->eax == HYPERV_CPUID_SIGNATURE_EAX;
  #else
        return false;
@@@ -368,15 -359,71 +359,71 @@@ static bool guest_cpuid_is_amd_or_hygon
               is_guest_vendor_hygon(entry->ebx, entry->ecx, entry->edx);
  }
  
- static void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
+ /*
+  * This isn't truly "unsafe", but except for the cpu_caps initialization code,
+  * all register lookups should use __cpuid_entry_get_reg(), which provides
+  * compile-time validation of the input.
+  */
+ static u32 cpuid_get_reg_unsafe(struct kvm_cpuid_entry2 *entry, u32 reg)
+ {
+       switch (reg) {
+       case CPUID_EAX:
+               return entry->eax;
+       case CPUID_EBX:
+               return entry->ebx;
+       case CPUID_ECX:
+               return entry->ecx;
+       case CPUID_EDX:
+               return entry->edx;
+       default:
+               WARN_ON_ONCE(1);
+               return 0;
+       }
+ }
+ static int cpuid_func_emulated(struct kvm_cpuid_entry2 *entry, u32 func,
+                              bool include_partially_emulated);
+ void kvm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu)
  {
        struct kvm_lapic *apic = vcpu->arch.apic;
        struct kvm_cpuid_entry2 *best;
+       struct kvm_cpuid_entry2 *entry;
        bool allow_gbpages;
+       int i;
  
-       BUILD_BUG_ON(KVM_NR_GOVERNED_FEATURES > KVM_MAX_NR_GOVERNED_FEATURES);
-       bitmap_zero(vcpu->arch.governed_features.enabled,
-                   KVM_MAX_NR_GOVERNED_FEATURES);
+       memset(vcpu->arch.cpu_caps, 0, sizeof(vcpu->arch.cpu_caps));
+       BUILD_BUG_ON(ARRAY_SIZE(reverse_cpuid) != NR_KVM_CPU_CAPS);
+       /*
+        * Reset guest capabilities to userspace's guest CPUID definition, i.e.
+        * honor userspace's definition for features that don't require KVM or
+        * hardware management/support (or that KVM simply doesn't care about).
+        */
+       for (i = 0; i < NR_KVM_CPU_CAPS; i++) {
+               const struct cpuid_reg cpuid = reverse_cpuid[i];
+               struct kvm_cpuid_entry2 emulated;
+               if (!cpuid.function)
+                       continue;
+               entry = kvm_find_cpuid_entry_index(vcpu, cpuid.function, cpuid.index);
+               if (!entry)
+                       continue;
+               cpuid_func_emulated(&emulated, cpuid.function, true);
+               /*
+                * A vCPU has a feature if it's supported by KVM and is enabled
+                * in guest CPUID.  Note, this includes features that are
+                * supported by KVM but aren't advertised to userspace!
+                */
+               vcpu->arch.cpu_caps[i] = kvm_cpu_caps[i] |
+                                        cpuid_get_reg_unsafe(&emulated, cpuid.reg);
+               vcpu->arch.cpu_caps[i] &= cpuid_get_reg_unsafe(entry, cpuid.reg);
+       }
+       kvm_update_cpuid_runtime(vcpu);
  
        /*
         * If TDP is enabled, let the guest use GBPAGES if they're supported in
         * and can install smaller shadow pages if the host lacks 1GiB support.
         */
        allow_gbpages = tdp_enabled ? boot_cpu_has(X86_FEATURE_GBPAGES) :
-                                     guest_cpuid_has(vcpu, X86_FEATURE_GBPAGES);
-       if (allow_gbpages)
-               kvm_governed_feature_set(vcpu, X86_FEATURE_GBPAGES);
+                                     guest_cpu_cap_has(vcpu, X86_FEATURE_GBPAGES);
+       guest_cpu_cap_change(vcpu, X86_FEATURE_GBPAGES, allow_gbpages);
  
        best = kvm_find_cpuid_entry(vcpu, 1);
        if (best && apic) {
                kvm_apic_set_version(vcpu);
        }
  
-       vcpu->arch.guest_supported_xcr0 =
-               cpuid_get_supported_xcr0(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent);
+       vcpu->arch.guest_supported_xcr0 = cpuid_get_supported_xcr0(vcpu);
  
-       kvm_update_pv_runtime(vcpu);
+       vcpu->arch.pv_cpuid.features = kvm_apply_cpuid_pv_features_quirk(vcpu);
  
        vcpu->arch.is_amd_compatible = guest_cpuid_is_amd_or_hygon(vcpu);
        vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu);
        vcpu->arch.reserved_gpa_bits = kvm_vcpu_reserved_gpa_bits_raw(vcpu);
  
        kvm_pmu_refresh(vcpu);
-       vcpu->arch.cr4_guest_rsvd_bits =
-           __cr4_reserved_bits(guest_cpuid_has, vcpu);
  
-       kvm_hv_set_cpuid(vcpu, kvm_cpuid_has_hyperv(vcpu->arch.cpuid_entries,
-                                                   vcpu->arch.cpuid_nent));
+ #define __kvm_cpu_cap_has(UNUSED_, f) kvm_cpu_cap_has(f)
+       vcpu->arch.cr4_guest_rsvd_bits = __cr4_reserved_bits(__kvm_cpu_cap_has, UNUSED_) |
+                                        __cr4_reserved_bits(guest_cpu_cap_has, vcpu);
+ #undef __kvm_cpu_cap_has
+       kvm_hv_set_cpuid(vcpu, kvm_cpuid_has_hyperv(vcpu));
  
        /* Invoke the vendor callback only after the above state is updated. */
        kvm_x86_call(vcpu_after_set_cpuid)(vcpu);
@@@ -457,9 -504,25 +504,25 @@@ u64 kvm_vcpu_reserved_gpa_bits_raw(stru
  static int kvm_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2 *e2,
                          int nent)
  {
+       u32 vcpu_caps[NR_KVM_CPU_CAPS];
        int r;
  
-       __kvm_update_cpuid_runtime(vcpu, e2, nent);
+       /*
+        * Swap the existing (old) entries with the incoming (new) entries in
+        * order to massage the new entries, e.g. to account for dynamic bits
+        * that KVM controls, without clobbering the current guest CPUID, which
+        * KVM needs to preserve in order to unwind on failure.
+        *
+        * Similarly, save the vCPU's current cpu_caps so that the capabilities
+        * can be updated alongside the CPUID entries when performing runtime
+        * updates.  Full initialization is done if and only if the vCPU hasn't
+        * run, i.e. only if userspace is potentially changing CPUID features.
+        */
+       swap(vcpu->arch.cpuid_entries, e2);
+       swap(vcpu->arch.cpuid_nent, nent);
+       memcpy(vcpu_caps, vcpu->arch.cpu_caps, sizeof(vcpu_caps));
+       BUILD_BUG_ON(sizeof(vcpu_caps) != sizeof(vcpu->arch.cpu_caps));
  
        /*
         * KVM does not correctly handle changing guest CPUID after KVM_RUN, as
        if (kvm_vcpu_has_run(vcpu)) {
                r = kvm_cpuid_check_equal(vcpu, e2, nent);
                if (r)
-                       return r;
-               kvfree(e2);
-               return 0;
+                       goto err;
+               goto success;
        }
  
  #ifdef CONFIG_KVM_HYPERV
-       if (kvm_cpuid_has_hyperv(e2, nent)) {
+       if (kvm_cpuid_has_hyperv(vcpu)) {
                r = kvm_hv_vcpu_init(vcpu);
                if (r)
-                       return r;
+                       goto err;
        }
  #endif
  
-       r = kvm_check_cpuid(vcpu, e2, nent);
+       r = kvm_check_cpuid(vcpu);
        if (r)
-               return r;
-       kvfree(vcpu->arch.cpuid_entries);
-       vcpu->arch.cpuid_entries = e2;
-       vcpu->arch.cpuid_nent = nent;
+               goto err;
  
-       vcpu->arch.kvm_cpuid = kvm_get_hypervisor_cpuid(vcpu, KVM_SIGNATURE);
  #ifdef CONFIG_KVM_XEN
        vcpu->arch.xen.cpuid = kvm_get_hypervisor_cpuid(vcpu, XEN_SIGNATURE);
  #endif
        kvm_vcpu_after_set_cpuid(vcpu);
  
+ success:
+       kvfree(e2);
        return 0;
+ err:
+       memcpy(vcpu->arch.cpu_caps, vcpu_caps, sizeof(vcpu_caps));
+       swap(vcpu->arch.cpuid_entries, e2);
+       swap(vcpu->arch.cpuid_nent, nent);
+       return r;
  }
  
  /* when an old userspace process fills a new kernel module */
@@@ -590,107 -654,294 +654,294 @@@ int kvm_vcpu_ioctl_get_cpuid2(struct kv
        return 0;
  }
  
- /* Mask kvm_cpu_caps for @leaf with the raw CPUID capabilities of this CPU. */
- static __always_inline void __kvm_cpu_cap_mask(unsigned int leaf)
+ static __always_inline u32 raw_cpuid_get(struct cpuid_reg cpuid)
  {
-       const struct cpuid_reg cpuid = x86_feature_cpuid(leaf * 32);
        struct kvm_cpuid_entry2 entry;
+       u32 base;
  
-       reverse_cpuid_check(leaf);
+       /*
+        * KVM only supports features defined by Intel (0x0), AMD (0x80000000),
+        * and Centaur (0xc0000000).  WARN if a feature for new vendor base is
+        * defined, as this and other code would need to be updated.
+        */
+       base = cpuid.function & 0xffff0000;
+       if (WARN_ON_ONCE(base && base != 0x80000000 && base != 0xc0000000))
+               return 0;
+       if (cpuid_eax(base) < cpuid.function)
+               return 0;
  
        cpuid_count(cpuid.function, cpuid.index,
                    &entry.eax, &entry.ebx, &entry.ecx, &entry.edx);
  
-       kvm_cpu_caps[leaf] &= *__cpuid_entry_get_reg(&entry, cpuid.reg);
+       return *__cpuid_entry_get_reg(&entry, cpuid.reg);
  }
  
- static __always_inline
- void kvm_cpu_cap_init_kvm_defined(enum kvm_only_cpuid_leafs leaf, u32 mask)
- {
-       /* Use kvm_cpu_cap_mask for leafs that aren't KVM-only. */
-       BUILD_BUG_ON(leaf < NCAPINTS);
+ /*
+  * For kernel-defined leafs, mask KVM's supported feature set with the kernel's
+  * capabilities as well as raw CPUID.  For KVM-defined leafs, consult only raw
+  * CPUID, as KVM is the one and only authority (in the kernel).
+  */
+ #define kvm_cpu_cap_init(leaf, feature_initializers...)                       \
+ do {                                                                  \
+       const struct cpuid_reg cpuid = x86_feature_cpuid(leaf * 32);    \
+       const u32 __maybe_unused kvm_cpu_cap_init_in_progress = leaf;   \
+       const u32 *kernel_cpu_caps = boot_cpu_data.x86_capability;      \
+       u32 kvm_cpu_cap_passthrough = 0;                                \
+       u32 kvm_cpu_cap_synthesized = 0;                                \
+       u32 kvm_cpu_cap_emulated = 0;                                   \
+       u32 kvm_cpu_cap_features = 0;                                   \
+                                                                       \
+       feature_initializers                                            \
+                                                                       \
+       kvm_cpu_caps[leaf] = kvm_cpu_cap_features;                      \
+                                                                       \
+       if (leaf < NCAPINTS)                                            \
+               kvm_cpu_caps[leaf] &= kernel_cpu_caps[leaf];            \
+                                                                       \
+       kvm_cpu_caps[leaf] |= kvm_cpu_cap_passthrough;                  \
+       kvm_cpu_caps[leaf] &= (raw_cpuid_get(cpuid) |                   \
+                              kvm_cpu_cap_synthesized);                \
+       kvm_cpu_caps[leaf] |= kvm_cpu_cap_emulated;                     \
+ } while (0)
  
-       kvm_cpu_caps[leaf] = mask;
+ /*
+  * Assert that the feature bit being declared, e.g. via F(), is in the CPUID
+  * word that's being initialized.  Exempt 0x8000_0001.EDX usage of 0x1.EDX
+  * features, as AMD duplicated many 0x1.EDX features into 0x8000_0001.EDX.
+  */
+ #define KVM_VALIDATE_CPU_CAP_USAGE(name)                              \
+ do {                                                                  \
+       u32 __leaf = __feature_leaf(X86_FEATURE_##name);                \
+                                                                       \
+       BUILD_BUG_ON(__leaf != kvm_cpu_cap_init_in_progress);           \
+ } while (0)
+ #define F(name)                                                       \
+ ({                                                            \
+       KVM_VALIDATE_CPU_CAP_USAGE(name);                       \
+       kvm_cpu_cap_features |= feature_bit(name);              \
+ })
  
-       __kvm_cpu_cap_mask(leaf);
- }
+ /* Scattered Flag - For features that are scattered by cpufeatures.h. */
+ #define SCATTERED_F(name)                                     \
+ ({                                                            \
+       BUILD_BUG_ON(X86_FEATURE_##name >= MAX_CPU_FEATURES);   \
+       KVM_VALIDATE_CPU_CAP_USAGE(name);                       \
+       if (boot_cpu_has(X86_FEATURE_##name))                   \
+               F(name);                                        \
+ })
  
- static __always_inline void kvm_cpu_cap_mask(enum cpuid_leafs leaf, u32 mask)
- {
-       /* Use kvm_cpu_cap_init_kvm_defined for KVM-only leafs. */
-       BUILD_BUG_ON(leaf >= NCAPINTS);
+ /* Features that KVM supports only on 64-bit kernels. */
+ #define X86_64_F(name)                                                \
+ ({                                                            \
+       KVM_VALIDATE_CPU_CAP_USAGE(name);                       \
+       if (IS_ENABLED(CONFIG_X86_64))                          \
+               F(name);                                        \
+ })
  
-       kvm_cpu_caps[leaf] &= mask;
+ /*
+  * Emulated Feature - For features that KVM emulates in software irrespective
+  * of host CPU/kernel support.
+  */
+ #define EMULATED_F(name)                                      \
+ ({                                                            \
+       kvm_cpu_cap_emulated |= feature_bit(name);              \
+       F(name);                                                \
+ })
  
-       __kvm_cpu_cap_mask(leaf);
- }
+ /*
+  * Synthesized Feature - For features that are synthesized into boot_cpu_data,
+  * i.e. may not be present in the raw CPUID, but can still be advertised to
+  * userspace.  Primarily used for mitigation related feature flags.
+  */
+ #define SYNTHESIZED_F(name)                                   \
+ ({                                                            \
+       kvm_cpu_cap_synthesized |= feature_bit(name);           \
+       F(name);                                                \
+ })
+ /*
+  * Passthrough Feature - For features that KVM supports based purely on raw
+  * hardware CPUID, i.e. that KVM virtualizes even if the host kernel doesn't
+  * use the feature.  Simply force set the feature in KVM's capabilities, raw
+  * CPUID support will be factored in by kvm_cpu_cap_mask().
+  */
+ #define PASSTHROUGH_F(name)                                   \
+ ({                                                            \
+       kvm_cpu_cap_passthrough |= feature_bit(name);           \
+       F(name);                                                \
+ })
+ /*
+  * Aliased Features - For features in 0x8000_0001.EDX that are duplicates of
+  * identical 0x1.EDX features, and thus are aliased from 0x1 to 0x8000_0001.
+  */
+ #define ALIASED_1_EDX_F(name)                                                 \
+ ({                                                                            \
+       BUILD_BUG_ON(__feature_leaf(X86_FEATURE_##name) != CPUID_1_EDX);        \
+       BUILD_BUG_ON(kvm_cpu_cap_init_in_progress != CPUID_8000_0001_EDX);      \
+       kvm_cpu_cap_features |= feature_bit(name);                              \
+ })
+ /*
+  * Vendor Features - For features that KVM supports, but are added in later
+  * because they require additional vendor enabling.
+  */
+ #define VENDOR_F(name)                                                \
+ ({                                                            \
+       KVM_VALIDATE_CPU_CAP_USAGE(name);                       \
+ })
+ /*
+  * Runtime Features - For features that KVM dynamically sets/clears at runtime,
+  * e.g. when CR4 changes, but which are never advertised to userspace.
+  */
+ #define RUNTIME_F(name)                                               \
+ ({                                                            \
+       KVM_VALIDATE_CPU_CAP_USAGE(name);                       \
+ })
+ /*
+  * Undefine the MSR bit macro to avoid token concatenation issues when
+  * processing X86_FEATURE_SPEC_CTRL_SSBD.
+  */
+ #undef SPEC_CTRL_SSBD
+ /* DS is defined by ptrace-abi.h on 32-bit builds. */
+ #undef DS
  
  void kvm_set_cpu_caps(void)
  {
- #ifdef CONFIG_X86_64
-       unsigned int f_gbpages = F(GBPAGES);
-       unsigned int f_lm = F(LM);
-       unsigned int f_xfd = F(XFD);
- #else
-       unsigned int f_gbpages = 0;
-       unsigned int f_lm = 0;
-       unsigned int f_xfd = 0;
- #endif
        memset(kvm_cpu_caps, 0, sizeof(kvm_cpu_caps));
  
        BUILD_BUG_ON(sizeof(kvm_cpu_caps) - (NKVMCAPINTS * sizeof(*kvm_cpu_caps)) >
                     sizeof(boot_cpu_data.x86_capability));
  
-       memcpy(&kvm_cpu_caps, &boot_cpu_data.x86_capability,
-              sizeof(kvm_cpu_caps) - (NKVMCAPINTS * sizeof(*kvm_cpu_caps)));
-       kvm_cpu_cap_mask(CPUID_1_ECX,
+       kvm_cpu_cap_init(CPUID_1_ECX,
+               F(XMM3),
+               F(PCLMULQDQ),
+               VENDOR_F(DTES64),
                /*
                 * NOTE: MONITOR (and MWAIT) are emulated as NOP, but *not*
-                * advertised to guests via CPUID!
+                * advertised to guests via CPUID!  MWAIT is also technically a
+                * runtime flag thanks to IA32_MISC_ENABLES; mark it as such so
+                * that KVM is aware that it's a known, unadvertised flag.
                 */
-               F(XMM3) | F(PCLMULQDQ) | 0 /* DTES64, MONITOR */ |
-               0 /* DS-CPL, VMX, SMX, EST */ |
-               0 /* TM2 */ | F(SSSE3) | 0 /* CNXT-ID */ | 0 /* Reserved */ |
-               F(FMA) | F(CX16) | 0 /* xTPR Update */ | F(PDCM) |
-               F(PCID) | 0 /* Reserved, DCA */ | F(XMM4_1) |
-               F(XMM4_2) | F(X2APIC) | F(MOVBE) | F(POPCNT) |
-               0 /* Reserved*/ | F(AES) | F(XSAVE) | 0 /* OSXSAVE */ | F(AVX) |
-               F(F16C) | F(RDRAND)
+               RUNTIME_F(MWAIT),
+               /* DS-CPL */
+               VENDOR_F(VMX),
+               /* SMX, EST */
+               /* TM2 */
+               F(SSSE3),
+               /* CNXT-ID */
+               /* Reserved */
+               F(FMA),
+               F(CX16),
+               /* xTPR Update */
+               F(PDCM),
+               F(PCID),
+               /* Reserved, DCA */
+               F(XMM4_1),
+               F(XMM4_2),
+               EMULATED_F(X2APIC),
+               F(MOVBE),
+               F(POPCNT),
+               EMULATED_F(TSC_DEADLINE_TIMER),
+               F(AES),
+               F(XSAVE),
+               RUNTIME_F(OSXSAVE),
+               F(AVX),
+               F(F16C),
+               F(RDRAND),
+               EMULATED_F(HYPERVISOR),
        );
-       /* KVM emulates x2apic in software irrespective of host support. */
-       kvm_cpu_cap_set(X86_FEATURE_X2APIC);
-       kvm_cpu_cap_mask(CPUID_1_EDX,
-               F(FPU) | F(VME) | F(DE) | F(PSE) |
-               F(TSC) | F(MSR) | F(PAE) | F(MCE) |
-               F(CX8) | F(APIC) | 0 /* Reserved */ | F(SEP) |
-               F(MTRR) | F(PGE) | F(MCA) | F(CMOV) |
-               F(PAT) | F(PSE36) | 0 /* PSN */ | F(CLFLUSH) |
-               0 /* Reserved, DS, ACPI */ | F(MMX) |
-               F(FXSR) | F(XMM) | F(XMM2) | F(SELFSNOOP) |
-               0 /* HTT, TM, Reserved, PBE */
+       kvm_cpu_cap_init(CPUID_1_EDX,
+               F(FPU),
+               F(VME),
+               F(DE),
+               F(PSE),
+               F(TSC),
+               F(MSR),
+               F(PAE),
+               F(MCE),
+               F(CX8),
+               F(APIC),
+               /* Reserved */
+               F(SEP),
+               F(MTRR),
+               F(PGE),
+               F(MCA),
+               F(CMOV),
+               F(PAT),
+               F(PSE36),
+               /* PSN */
+               F(CLFLUSH),
+               /* Reserved */
+               VENDOR_F(DS),
+               /* ACPI */
+               F(MMX),
+               F(FXSR),
+               F(XMM),
+               F(XMM2),
+               F(SELFSNOOP),
+               /* HTT, TM, Reserved, PBE */
        );
  
-       kvm_cpu_cap_mask(CPUID_7_0_EBX,
-               F(FSGSBASE) | F(SGX) | F(BMI1) | F(HLE) | F(AVX2) |
-               F(FDP_EXCPTN_ONLY) | F(SMEP) | F(BMI2) | F(ERMS) | F(INVPCID) |
-               F(RTM) | F(ZERO_FCS_FDS) | 0 /*MPX*/ | F(AVX512F) |
-               F(AVX512DQ) | F(RDSEED) | F(ADX) | F(SMAP) | F(AVX512IFMA) |
-               F(CLFLUSHOPT) | F(CLWB) | 0 /*INTEL_PT*/ | F(AVX512PF) |
-               F(AVX512ER) | F(AVX512CD) | F(SHA_NI) | F(AVX512BW) |
-               F(AVX512VL));
-       kvm_cpu_cap_mask(CPUID_7_ECX,
-               F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ | F(RDPID) |
-               F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) |
-               F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) |
-               F(CLDEMOTE) | F(MOVDIRI) | F(MOVDIR64B) | 0 /*WAITPKG*/ |
-               F(SGX_LC) | F(BUS_LOCK_DETECT)
+       kvm_cpu_cap_init(CPUID_7_0_EBX,
+               F(FSGSBASE),
+               EMULATED_F(TSC_ADJUST),
+               F(SGX),
+               F(BMI1),
+               F(HLE),
+               F(AVX2),
+               F(FDP_EXCPTN_ONLY),
+               F(SMEP),
+               F(BMI2),
+               F(ERMS),
+               F(INVPCID),
+               F(RTM),
+               F(ZERO_FCS_FDS),
+               VENDOR_F(MPX),
+               F(AVX512F),
+               F(AVX512DQ),
+               F(RDSEED),
+               F(ADX),
+               F(SMAP),
+               F(AVX512IFMA),
+               F(CLFLUSHOPT),
+               F(CLWB),
+               VENDOR_F(INTEL_PT),
+               F(AVX512PF),
+               F(AVX512ER),
+               F(AVX512CD),
+               F(SHA_NI),
+               F(AVX512BW),
+               F(AVX512VL),
+       );
+       kvm_cpu_cap_init(CPUID_7_ECX,
+               F(AVX512VBMI),
+               PASSTHROUGH_F(LA57),
+               F(PKU),
+               RUNTIME_F(OSPKE),
+               F(RDPID),
+               F(AVX512_VPOPCNTDQ),
+               F(UMIP),
+               F(AVX512_VBMI2),
+               F(GFNI),
+               F(VAES),
+               F(VPCLMULQDQ),
+               F(AVX512_VNNI),
+               F(AVX512_BITALG),
+               F(CLDEMOTE),
+               F(MOVDIRI),
+               F(MOVDIR64B),
+               VENDOR_F(WAITPKG),
+               F(SGX_LC),
+               F(BUS_LOCK_DETECT),
        );
-       /* Set LA57 based on hardware capability. */
-       if (cpuid_ecx(7) & F(LA57))
-               kvm_cpu_cap_set(X86_FEATURE_LA57);
  
        /*
         * PKU not yet implemented for shadow paging and requires OSPKE
        if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE))
                kvm_cpu_cap_clear(X86_FEATURE_PKU);
  
-       kvm_cpu_cap_mask(CPUID_7_EDX,
-               F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
-               F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) |
-               F(MD_CLEAR) | F(AVX512_VP2INTERSECT) | F(FSRM) |
-               F(SERIALIZE) | F(TSXLDTRK) | F(AVX512_FP16) |
-               F(AMX_TILE) | F(AMX_INT8) | F(AMX_BF16) | F(FLUSH_L1D)
+       kvm_cpu_cap_init(CPUID_7_EDX,
+               F(AVX512_4VNNIW),
+               F(AVX512_4FMAPS),
+               F(SPEC_CTRL),
+               F(SPEC_CTRL_SSBD),
+               EMULATED_F(ARCH_CAPABILITIES),
+               F(INTEL_STIBP),
+               F(MD_CLEAR),
+               F(AVX512_VP2INTERSECT),
+               F(FSRM),
+               F(SERIALIZE),
+               F(TSXLDTRK),
+               F(AVX512_FP16),
+               F(AMX_TILE),
+               F(AMX_INT8),
+               F(AMX_BF16),
+               F(FLUSH_L1D),
        );
  
-       /* TSC_ADJUST and ARCH_CAPABILITIES are emulated in software. */
-       kvm_cpu_cap_set(X86_FEATURE_TSC_ADJUST);
-       kvm_cpu_cap_set(X86_FEATURE_ARCH_CAPABILITIES);
        if (boot_cpu_has(X86_FEATURE_AMD_IBPB_RET) &&
            boot_cpu_has(X86_FEATURE_AMD_IBPB) &&
            boot_cpu_has(X86_FEATURE_AMD_IBRS))
        if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
                kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
  
-       kvm_cpu_cap_mask(CPUID_7_1_EAX,
-               F(SHA512) | F(SM3) | F(SM4) | F(AVX_VNNI) | F(AVX512_BF16) |
-               F(CMPCCXADD) | F(FZRM) | F(FSRS) | F(FSRC) | F(AMX_FP16) |
-               F(AVX_IFMA) | F(LAM)
+       kvm_cpu_cap_init(CPUID_7_1_EAX,
+               F(SHA512),
+               F(SM3),
+               F(SM4),
+               F(AVX_VNNI),
+               F(AVX512_BF16),
+               F(CMPCCXADD),
+               F(FZRM),
+               F(FSRS),
+               F(FSRC),
+               F(AMX_FP16),
+               F(AVX_IFMA),
+               F(LAM),
        );
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_7_1_EDX,
-               F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) | F(AMX_COMPLEX) |
-               F(AVX_VNNI_INT16) | F(PREFETCHITI) | F(AVX10)
+       kvm_cpu_cap_init(CPUID_7_1_EDX,
+               F(AVX_VNNI_INT8),
+               F(AVX_NE_CONVERT),
+               F(AMX_COMPLEX),
+               F(AVX_VNNI_INT16),
+               F(PREFETCHITI),
+               F(AVX10),
        );
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_7_2_EDX,
-               F(INTEL_PSFD) | F(IPRED_CTRL) | F(RRSBA_CTRL) | F(DDPD_U) |
-               F(BHI_CTRL) | F(MCDT_NO)
+       kvm_cpu_cap_init(CPUID_7_2_EDX,
+               F(INTEL_PSFD),
+               F(IPRED_CTRL),
+               F(RRSBA_CTRL),
+               F(DDPD_U),
+               F(BHI_CTRL),
+               F(MCDT_NO),
        );
  
-       kvm_cpu_cap_mask(CPUID_D_1_EAX,
-               F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd
+       kvm_cpu_cap_init(CPUID_D_1_EAX,
+               F(XSAVEOPT),
+               F(XSAVEC),
+               F(XGETBV1),
+               F(XSAVES),
+               X86_64_F(XFD),
        );
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_12_EAX,
-               SF(SGX1) | SF(SGX2) | SF(SGX_EDECCSSA)
+       kvm_cpu_cap_init(CPUID_12_EAX,
+               SCATTERED_F(SGX1),
+               SCATTERED_F(SGX2),
+               SCATTERED_F(SGX_EDECCSSA),
        );
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_24_0_EBX,
-               F(AVX10_128) | F(AVX10_256) | F(AVX10_512)
+       kvm_cpu_cap_init(CPUID_24_0_EBX,
+               F(AVX10_128),
+               F(AVX10_256),
+               F(AVX10_512),
        );
  
-       kvm_cpu_cap_mask(CPUID_8000_0001_ECX,
-               F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
-               F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
-               F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
-               0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM) |
-               F(TOPOEXT) | 0 /* PERFCTR_CORE */
+       kvm_cpu_cap_init(CPUID_8000_0001_ECX,
+               F(LAHF_LM),
+               F(CMP_LEGACY),
+               VENDOR_F(SVM),
+               /* ExtApicSpace */
+               F(CR8_LEGACY),
+               F(ABM),
+               F(SSE4A),
+               F(MISALIGNSSE),
+               F(3DNOWPREFETCH),
+               F(OSVW),
+               /* IBS */
+               F(XOP),
+               /* SKINIT, WDT, LWP */
+               F(FMA4),
+               F(TBM),
+               F(TOPOEXT),
+               VENDOR_F(PERFCTR_CORE),
        );
  
-       kvm_cpu_cap_mask(CPUID_8000_0001_EDX,
-               F(FPU) | F(VME) | F(DE) | F(PSE) |
-               F(TSC) | F(MSR) | F(PAE) | F(MCE) |
-               F(CX8) | F(APIC) | 0 /* Reserved */ | F(SYSCALL) |
-               F(MTRR) | F(PGE) | F(MCA) | F(CMOV) |
-               F(PAT) | F(PSE36) | 0 /* Reserved */ |
-               F(NX) | 0 /* Reserved */ | F(MMXEXT) | F(MMX) |
-               F(FXSR) | F(FXSR_OPT) | f_gbpages | F(RDTSCP) |
-               0 /* Reserved */ | f_lm | F(3DNOWEXT) | F(3DNOW)
+       kvm_cpu_cap_init(CPUID_8000_0001_EDX,
+               ALIASED_1_EDX_F(FPU),
+               ALIASED_1_EDX_F(VME),
+               ALIASED_1_EDX_F(DE),
+               ALIASED_1_EDX_F(PSE),
+               ALIASED_1_EDX_F(TSC),
+               ALIASED_1_EDX_F(MSR),
+               ALIASED_1_EDX_F(PAE),
+               ALIASED_1_EDX_F(MCE),
+               ALIASED_1_EDX_F(CX8),
+               ALIASED_1_EDX_F(APIC),
+               /* Reserved */
+               F(SYSCALL),
+               ALIASED_1_EDX_F(MTRR),
+               ALIASED_1_EDX_F(PGE),
+               ALIASED_1_EDX_F(MCA),
+               ALIASED_1_EDX_F(CMOV),
+               ALIASED_1_EDX_F(PAT),
+               ALIASED_1_EDX_F(PSE36),
+               /* Reserved */
+               F(NX),
+               /* Reserved */
+               F(MMXEXT),
+               ALIASED_1_EDX_F(MMX),
+               ALIASED_1_EDX_F(FXSR),
+               F(FXSR_OPT),
+               X86_64_F(GBPAGES),
+               F(RDTSCP),
+               /* Reserved */
+               X86_64_F(LM),
+               F(3DNOWEXT),
+               F(3DNOW),
        );
  
        if (!tdp_enabled && IS_ENABLED(CONFIG_X86_64))
                kvm_cpu_cap_set(X86_FEATURE_GBPAGES);
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_8000_0007_EDX,
-               SF(CONSTANT_TSC)
+       kvm_cpu_cap_init(CPUID_8000_0007_EDX,
+               SCATTERED_F(CONSTANT_TSC),
        );
  
-       kvm_cpu_cap_mask(CPUID_8000_0008_EBX,
-               F(CLZERO) | F(XSAVEERPTR) |
-               F(WBNOINVD) | F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
-               F(AMD_SSB_NO) | F(AMD_STIBP) | F(AMD_STIBP_ALWAYS_ON) |
-               F(AMD_PSFD) | F(AMD_IBPB_RET)
+       kvm_cpu_cap_init(CPUID_8000_0008_EBX,
+               F(CLZERO),
+               F(XSAVEERPTR),
+               F(WBNOINVD),
+               F(AMD_IBPB),
+               F(AMD_IBRS),
+               F(AMD_SSBD),
+               F(VIRT_SSBD),
+               F(AMD_SSB_NO),
+               F(AMD_STIBP),
+               F(AMD_STIBP_ALWAYS_ON),
+               F(AMD_PSFD),
+               F(AMD_IBPB_RET),
        );
  
        /*
            !boot_cpu_has(X86_FEATURE_AMD_SSBD))
                kvm_cpu_cap_set(X86_FEATURE_VIRT_SSBD);
  
-       /*
-        * Hide all SVM features by default, SVM will set the cap bits for
-        * features it emulates and/or exposes for L1.
-        */
-       kvm_cpu_cap_mask(CPUID_8000_000A_EDX, 0);
-       kvm_cpu_cap_mask(CPUID_8000_001F_EAX,
-               0 /* SME */ | 0 /* SEV */ | 0 /* VM_PAGE_FLUSH */ | 0 /* SEV_ES */ |
-               F(SME_COHERENT));
+       /* All SVM features required additional vendor module enabling. */
+       kvm_cpu_cap_init(CPUID_8000_000A_EDX,
+               VENDOR_F(NPT),
+               VENDOR_F(VMCBCLEAN),
+               VENDOR_F(FLUSHBYASID),
+               VENDOR_F(NRIPS),
+               VENDOR_F(TSCRATEMSR),
+               VENDOR_F(V_VMSAVE_VMLOAD),
+               VENDOR_F(LBRV),
+               VENDOR_F(PAUSEFILTER),
+               VENDOR_F(PFTHRESHOLD),
+               VENDOR_F(VGIF),
+               VENDOR_F(VNMI),
+               VENDOR_F(SVME_ADDR_CHK),
+       );
  
-       kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
-               F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
-               F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */ |
-               F(WRMSR_XX_BASE_NS) | F(SRSO_USER_KERNEL_NO)
+       kvm_cpu_cap_init(CPUID_8000_001F_EAX,
+               VENDOR_F(SME),
+               VENDOR_F(SEV),
+               /* VM_PAGE_FLUSH */
+               VENDOR_F(SEV_ES),
+               F(SME_COHERENT),
        );
  
-       kvm_cpu_cap_check_and_set(X86_FEATURE_SBPB);
-       kvm_cpu_cap_check_and_set(X86_FEATURE_IBPB_BRTYPE);
-       kvm_cpu_cap_check_and_set(X86_FEATURE_SRSO_NO);
+       kvm_cpu_cap_init(CPUID_8000_0021_EAX,
+               F(NO_NESTED_DATA_BP),
+               /*
+                * Synthesize "LFENCE is serializing" into the AMD-defined entry
+                * in KVM's supported CPUID, i.e. if the feature is reported as
+                * supported by the kernel.  LFENCE_RDTSC was a Linux-defined
+                * synthetic feature long before AMD joined the bandwagon, e.g.
+                * LFENCE is serializing on most CPUs that support SSE2.  On
+                * CPUs that don't support AMD's leaf, ANDing with the raw host
+                * CPUID will drop the flags, and reporting support in AMD's
+                * leaf can make it easier for userspace to detect the feature.
+                */
+               SYNTHESIZED_F(LFENCE_RDTSC),
+               /* SmmPgCfgLock */
+               F(NULL_SEL_CLR_BASE),
+               F(AUTOIBRS),
+               EMULATED_F(NO_SMM_CTL_MSR),
+               /* PrefetchCtlMsr */
+               F(WRMSR_XX_BASE_NS),
+               SYNTHESIZED_F(SBPB),
+               SYNTHESIZED_F(IBPB_BRTYPE),
+               SYNTHESIZED_F(SRSO_NO),
++              SYNTHESIZED_F(SRSO_USER_KERNEL_NO),
+       );
  
-       kvm_cpu_cap_init_kvm_defined(CPUID_8000_0022_EAX,
-               F(PERFMON_V2)
+       kvm_cpu_cap_init(CPUID_8000_0022_EAX,
+               F(PERFMON_V2),
        );
  
-       /*
-        * Synthesize "LFENCE is serializing" into the AMD-defined entry in
-        * KVM's supported CPUID if the feature is reported as supported by the
-        * kernel.  LFENCE_RDTSC was a Linux-defined synthetic feature long
-        * before AMD joined the bandwagon, e.g. LFENCE is serializing on most
-        * CPUs that support SSE2.  On CPUs that don't support AMD's leaf,
-        * kvm_cpu_cap_mask() will unfortunately drop the flag due to ANDing
-        * the mask with the raw host CPUID, and reporting support in AMD's
-        * leaf can make it easier for userspace to detect the feature.
-        */
-       if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC))
-               kvm_cpu_cap_set(X86_FEATURE_LFENCE_RDTSC);
        if (!static_cpu_has_bug(X86_BUG_NULL_SEG))
                kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE);
-       kvm_cpu_cap_set(X86_FEATURE_NO_SMM_CTL_MSR);
  
-       kvm_cpu_cap_mask(CPUID_C000_0001_EDX,
-               F(XSTORE) | F(XSTORE_EN) | F(XCRYPT) | F(XCRYPT_EN) |
-               F(ACE2) | F(ACE2_EN) | F(PHE) | F(PHE_EN) |
-               F(PMM) | F(PMM_EN)
+       kvm_cpu_cap_init(CPUID_C000_0001_EDX,
+               F(XSTORE),
+               F(XSTORE_EN),
+               F(XCRYPT),
+               F(XCRYPT_EN),
+               F(ACE2),
+               F(ACE2_EN),
+               F(PHE),
+               F(PHE_EN),
+               F(PMM),
+               F(PMM_EN),
        );
  
        /*
  }
  EXPORT_SYMBOL_GPL(kvm_set_cpu_caps);
  
+ #undef F
+ #undef SCATTERED_F
+ #undef X86_64_F
+ #undef EMULATED_F
+ #undef SYNTHESIZED_F
+ #undef PASSTHROUGH_F
+ #undef ALIASED_1_EDX_F
+ #undef VENDOR_F
+ #undef RUNTIME_F
  struct kvm_cpuid_array {
        struct kvm_cpuid_entry2 *entries;
        int maxnent;
@@@ -928,14 -1286,11 +1287,11 @@@ static struct kvm_cpuid_entry2 *do_host
        return entry;
  }
  
- static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func)
+ static int cpuid_func_emulated(struct kvm_cpuid_entry2 *entry, u32 func,
+                              bool include_partially_emulated)
  {
-       struct kvm_cpuid_entry2 *entry;
-       if (array->nent >= array->maxnent)
-               return -E2BIG;
+       memset(entry, 0, sizeof(*entry));
  
-       entry = &array->entries[array->nent];
        entry->function = func;
        entry->index = 0;
        entry->flags = 0;
        switch (func) {
        case 0:
                entry->eax = 7;
-               ++array->nent;
-               break;
+               return 1;
        case 1:
-               entry->ecx = F(MOVBE);
-               ++array->nent;
-               break;
+               entry->ecx = feature_bit(MOVBE);
+               /*
+                * KVM allows userspace to enumerate MONITOR+MWAIT support to
+                * the guest, but the MWAIT feature flag is never advertised
+                * to userspace because MONITOR+MWAIT aren't virtualized by
+                * hardware, can't be faithfully emulated in software (KVM
+                * emulates them as NOPs), and allowing the guest to execute
+                * them natively requires enabling a per-VM capability.
+                */
+               if (include_partially_emulated)
+                       entry->ecx |= feature_bit(MWAIT);
+               return 1;
        case 7:
                entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
                entry->eax = 0;
                if (kvm_cpu_cap_has(X86_FEATURE_RDTSCP))
-                       entry->ecx = F(RDPID);
-               ++array->nent;
-               break;
+                       entry->ecx = feature_bit(RDPID);
+               return 1;
        default:
-               break;
+               return 0;
        }
+ }
+ static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func)
+ {
+       if (array->nent >= array->maxnent)
+               return -E2BIG;
  
+       array->nent += cpuid_func_emulated(&array->entries[array->nent], func, false);
        return 0;
  }
  
@@@ -1103,7 -1472,7 +1473,7 @@@ static inline int __do_cpuid_func(struc
                        goto out;
  
                cpuid_entry_override(entry, CPUID_D_1_EAX);
-               if (entry->eax & (F(XSAVES)|F(XSAVEC)))
+               if (entry->eax & (feature_bit(XSAVES) | feature_bit(XSAVEC)))
                        entry->ebx = xstate_required_size(permitted_xcr0 | permitted_xss,
                                                          true);
                else {
@@@ -1540,22 -1909,6 +1910,6 @@@ out_free
        return r;
  }
  
- struct kvm_cpuid_entry2 *kvm_find_cpuid_entry_index(struct kvm_vcpu *vcpu,
-                                                   u32 function, u32 index)
- {
-       return cpuid_entry2_find(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent,
-                                function, index);
- }
- EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry_index);
- struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
-                                             u32 function)
- {
-       return cpuid_entry2_find(vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent,
-                                function, KVM_CPUID_INDEX_NOT_SIGNIFICANT);
- }
- EXPORT_SYMBOL_GPL(kvm_find_cpuid_entry);
  /*
   * Intel CPUID semantics treats any query for an out-of-range leaf as if the
   * highest basic leaf (i.e. CPUID.0H:EAX) were requested.  AMD CPUID semantics
@@@ -1648,10 -2001,10 +2002,10 @@@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u
                        u64 data;
                        if (!__kvm_get_msr(vcpu, MSR_IA32_TSX_CTRL, &data, true) &&
                            (data & TSX_CTRL_CPUID_CLEAR))
-                               *ebx &= ~(F(RTM) | F(HLE));
+                               *ebx &= ~(feature_bit(RTM) | feature_bit(HLE));
                } else if (function == 0x80000007) {
                        if (kvm_hv_invtsc_suppressed(vcpu))
-                               *edx &= ~SF(CONSTANT_TSC);
+                               *edx &= ~feature_bit(CONSTANT_TSC);
                }
        } else {
                *eax = *ebx = *ecx = *edx = 0;
diff --combined arch/x86/kvm/svm/sev.c
index fe6cc763fd518949fa107e531a8988c0af30b68c,0f04f365885c98eccf4fcc1a0015893b39365f11..a2a794c320503f008c5dd3ff332bdfb064533a8e
                        min_sev_asid, max_sev_asid);
        if (boot_cpu_has(X86_FEATURE_SEV_ES))
                pr_info("SEV-ES %s (ASIDs %u - %u)\n",
-                       sev_es_supported ? "enabled" : "disabled",
+                       str_enabled_disabled(sev_es_supported),
                        min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
        if (boot_cpu_has(X86_FEATURE_SEV_SNP))
                pr_info("SEV-SNP %s (ASIDs %u - %u)\n",
-                       sev_snp_supported ? "enabled" : "disabled",
+                       str_enabled_disabled(sev_snp_supported),
                        min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
  
        sev_enabled = sev_supported;
@@@ -3627,13 -3627,20 +3627,20 @@@ static int snp_begin_psc_msr(struct vcp
                return 1; /* resume guest */
        }
  
-       if (!(vcpu->kvm->arch.hypercall_exit_enabled & (1 << KVM_HC_MAP_GPA_RANGE))) {
+       if (!user_exit_on_hypercall(vcpu->kvm, KVM_HC_MAP_GPA_RANGE)) {
                set_ghcb_msr(svm, GHCB_MSR_PSC_RESP_ERROR);
                return 1; /* resume guest */
        }
  
        vcpu->run->exit_reason = KVM_EXIT_HYPERCALL;
        vcpu->run->hypercall.nr = KVM_HC_MAP_GPA_RANGE;
+       /*
+        * In principle this should have been -KVM_ENOSYS, but userspace (QEMU <=9.2)
+        * assumed that vcpu->run->hypercall.ret is never changed by KVM and thus that
+        * it was always zero on KVM_EXIT_HYPERCALL.  Since KVM is now overwriting
+        * vcpu->run->hypercall.ret, ensuring that it is zero to not break QEMU.
+        */
+       vcpu->run->hypercall.ret = 0;
        vcpu->run->hypercall.args[0] = gpa;
        vcpu->run->hypercall.args[1] = 1;
        vcpu->run->hypercall.args[2] = (op == SNP_PAGE_STATE_PRIVATE)
@@@ -3710,7 -3717,7 +3717,7 @@@ static int snp_begin_psc(struct vcpu_sv
        bool huge;
        u64 gfn;
  
-       if (!(vcpu->kvm->arch.hypercall_exit_enabled & (1 << KVM_HC_MAP_GPA_RANGE))) {
+       if (!user_exit_on_hypercall(vcpu->kvm, KVM_HC_MAP_GPA_RANGE)) {
                snp_complete_psc(svm, VMGEXIT_PSC_ERROR_GENERIC);
                return 1;
        }
@@@ -3797,6 -3804,13 +3804,13 @@@ next_range
        case VMGEXIT_PSC_OP_SHARED:
                vcpu->run->exit_reason = KVM_EXIT_HYPERCALL;
                vcpu->run->hypercall.nr = KVM_HC_MAP_GPA_RANGE;
+               /*
+                * In principle this should have been -KVM_ENOSYS, but userspace (QEMU <=9.2)
+                * assumed that vcpu->run->hypercall.ret is never changed by KVM and thus that
+                * it was always zero on KVM_EXIT_HYPERCALL.  Since KVM is now overwriting
+                * vcpu->run->hypercall.ret, ensuring that it is zero to not break QEMU.
+                */
+               vcpu->run->hypercall.ret = 0;
                vcpu->run->hypercall.args[0] = gfn_to_gpa(gfn);
                vcpu->run->hypercall.args[1] = npages;
                vcpu->run->hypercall.args[2] = entry_start.operation == VMGEXIT_PSC_OP_PRIVATE
                goto next_range;
        }
  
 -      unreachable();
 +      BUG();
  }
  
  static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)
@@@ -4435,8 -4449,8 +4449,8 @@@ static void sev_es_vcpu_after_set_cpuid
        struct kvm_vcpu *vcpu = &svm->vcpu;
  
        if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) {
-               bool v_tsc_aux = guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP) ||
-                                guest_cpuid_has(vcpu, X86_FEATURE_RDPID);
+               bool v_tsc_aux = guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP) ||
+                                guest_cpu_cap_has(vcpu, X86_FEATURE_RDPID);
  
                set_msr_interception(vcpu, svm->msrpm, MSR_TSC_AUX, v_tsc_aux, v_tsc_aux);
        }
         * For SEV-ES, accesses to MSR_IA32_XSS should not be intercepted if
         * the host/guest supports its use.
         *
-        * guest_can_use() checks a number of requirements on the host/guest to
-        * ensure that MSR_IA32_XSS is available, but it might report true even
-        * if X86_FEATURE_XSAVES isn't configured in the guest to ensure host
-        * MSR_IA32_XSS is always properly restored. For SEV-ES, it is better
-        * to further check that the guest CPUID actually supports
-        * X86_FEATURE_XSAVES so that accesses to MSR_IA32_XSS by misbehaved
-        * guests will still get intercepted and caught in the normal
-        * kvm_emulate_rdmsr()/kvm_emulated_wrmsr() paths.
+        * KVM treats the guest as being capable of using XSAVES even if XSAVES
+        * isn't enabled in guest CPUID as there is no intercept for XSAVES,
+        * i.e. the guest can use XSAVES/XRSTOR to read/write XSS if XSAVE is
+        * exposed to the guest and XSAVES is supported in hardware.  Condition
+        * full XSS passthrough on the guest being able to use XSAVES *and*
+        * XSAVES being exposed to the guest so that KVM can at least honor
+        * guest CPUID for RDMSR and WRMSR.
         */
-       if (guest_can_use(vcpu, X86_FEATURE_XSAVES) &&
+       if (guest_cpu_cap_has(vcpu, X86_FEATURE_XSAVES) &&
            guest_cpuid_has(vcpu, X86_FEATURE_XSAVES))
                set_msr_interception(vcpu, svm->msrpm, MSR_IA32_XSS, 1, 1);
        else
This page took 0.348631 seconds and 4 git commands to generate.