From: Mushahid Hussain <[email protected]>

mcg_cap is per vCPU. kvm_arch_vcpu_create() gives every vCPU the
KVM_MAX_MCE_BANKS default, plane twins included, but KVM_X86_SETUP_MCE
was only accepted on the plane-0 fd: userspace programs plane 0 and a
higher plane keeps running with the default, so the MCG view diverges
across planes. Hyper-V defines the MCG state as shared across Virtual
Trust Levels, so userspace needs to program the same value on every
plane: accept the ioctl on plane vCPUs.

Assisted-by: LLM

[dwmw2: ours gates plane vCPU fd ioctls in kvm_arch_is_vcpu_plane_ioctl()
 in the same shape; same one-line addition.]
(re-done by hand)
Signed-off-by: David Woodhouse <[email protected]>
---
 Documentation/virt/kvm/api.rst | 2 +-
 arch/x86/kvm/x86.c             | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 494600236360..24050c79d95c 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -4594,7 +4594,7 @@ capabilities will have the corresponding bits set.
 
 :Capability: KVM_CAP_MCE
 :Architectures: x86
-:Type: vcpu ioctl
+:Type: vcpu ioctl (all planes)
 :Parameters: u64 mcg_cap (in)
 :Returns: 0 on success,
          -EFAULT if u64 mcg_cap cannot be read,
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index dc6196107c23..e2e54f06b092 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6400,6 +6400,7 @@ bool kvm_arch_is_vcpu_plane_ioctl(unsigned ioctl)
        case KVM_SET_XSAVE:
        case KVM_GET_REG_LIST:
        case KVM_TRANSLATE:
+       case KVM_X86_SETUP_MCE:
                return true;
        default:
                return false;
-- 
2.50.1


Reply via email to