linux/Documentation/virt/kvm
Xiaoyao Li ccb2280ec2 x86/kvm: Use separate percpu variable to track the enabling of asyncpf
Refer to commit fd10cde929 ("KVM paravirt: Add async PF initialization
to PV guest") and commit 344d9588a9 ("KVM: Add PV MSR to enable
asynchronous page faults delivery"). It turns out that at the time when
asyncpf was introduced, the purpose was defining the shared PV data 'struct
kvm_vcpu_pv_apf_data' with the size of 64 bytes. However, it made a mistake
and defined the size to 68 bytes, which failed to make fit in a cache line
and made the code inconsistent with the documentation.

Below justification quoted from Sean[*]

  KVM (the host side) has *never* read kvm_vcpu_pv_apf_data.enabled, and
  the documentation clearly states that enabling is based solely on the
  bit in the synthetic MSR.

  So rather than update the documentation, fix the goof by removing the
  enabled filed and use the separate percpu variable instread.
  KVM-as-a-host obviously doesn't enforce anything or consume the size,
  and changing the header will only affect guests that are rebuilt against
  the new header, so there's no chance of ABI breakage between KVM and its
  guests. The only possible breakage is if some other hypervisor is
  emulating KVM's async #PF (LOL) and relies on the guest to set
  kvm_vcpu_pv_apf_data.enabled. But (a) I highly doubt such a hypervisor
  exists, (b) that would arguably be a violation of KVM's "spec", and
  (c) the worst case scenario is that the guest would simply lose async
  #PF functionality.

[*] https://lore.kernel.org/all/ZS7ERnnRqs8Fl0ZF@google.com/T/#u

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20231025055914.1201792-2-xiaoyao.li@intel.com
[sean: use true/false instead of 1/0 for booleans]
Signed-off-by: Sean Christopherson <seanjc@google.com>
2024-02-06 10:58:56 -08:00
..
arm KVM: arm64: Document vCPU feature selection UAPIs 2023-10-04 17:11:51 +00:00
devices KVM: arm64: Clarify the ordering requirements for vcpu/RD creation 2023-09-30 18:15:44 +00:00
s390 ARM: 2022-08-04 14:59:54 -07:00
x86 x86/kvm: Use separate percpu variable to track the enabling of asyncpf 2024-02-06 10:58:56 -08:00
api.rst KVM Xen change for 6.8: 2024-01-08 08:10:20 -05:00
halt-polling.rst Documentation: Fix typos 2023-08-18 11:29:03 -06:00
index.rst KVM: Move halt-polling documentation into common directory 2022-12-02 13:20:30 -05:00
locking.rst KVM: x86/mmu: always take tdp_mmu_pages_lock 2023-12-01 07:52:08 -08:00
ppc-pv.rst Documentation: KVM: make corrections to ppc-pv.rst 2023-06-16 08:20:53 -06:00
review-checklist.rst docs: fix broken references for ReST files that moved around 2020-04-20 15:45:03 -06:00
vcpu-requests.rst Documentation: KVM: make corrections to vcpu-requests.rst 2023-06-16 08:20:53 -06:00