KVM: x86: Add "governed" X86_FEATURE framework
From: | Sean Christopherson <seanjc-AT-google.com> | |
To: | Sean Christopherson <seanjc-AT-google.com>, Paolo Bonzini <pbonzini-AT-redhat.com>, Vitaly Kuznetsov <vkuznets-AT-redhat.com> | |
Subject: | [PATCH 00/12] KVM: x86: Add "governed" X86_FEATURE framework | |
Date: | Fri, 17 Feb 2023 15:10:10 -0800 | |
Message-ID: | <20230217231022.816138-1-seanjc@google.com> | |
Cc: | kvm-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org | |
Archive-link: | Article |
Add a framework to manage and cache KVM-governed features, i.e. CPUID based features that require explicit KVM enabling and/or need to be queried semi-frequently by KVM. The idea originally came up in the context of the architectural LBRs series as a way to avoid querying guest CPUID in hot paths without needing a dedicated flag, but as evidenced by the shortlog, the most common usage is to handle the ever- growing list of SVM features that are exposed to L1. Note, I don't like the name "governed", but it was the least awful thing I could come up with. Suggestions most definitely welcome. This series is lightly tested. I am posting somewhat speculatively to get early feedback on the idea. Sean Christopherson (12): KVM: x86: Add a framework for enabling KVM-governed x86 features KVM: x86/mmu: Use KVM-governed feature framework to track "GBPAGES enabled" KVM: VMX: Recompute "XSAVES enabled" only after CPUID update KVM: VMX: Rename XSAVES control to follow KVM's preferred "ENABLE_XYZ" KVM: x86: Use KVM-governed feature framework to track "XSAVES enabled" KVM: nSVM: Use KVM-governed feature framework to track "NRIPS enabled" KVM: nSVM: Use KVM-governed feature framework to track "TSC scaling enabled" KVM: nSVM: Use KVM-governed feature framework to track "vVM{SAVE,LOAD} enabled" KVM: nSVM: Use KVM-governed feature framework to track "LBRv enabled" KVM: nSVM: Use KVM-governed feature framework to track "Pause Filter enabled" KVM: nSVM: Use KVM-governed feature framework to track "vGIF enabled" KVM: x86: Disallow guest CPUID lookups when IRQs are disabled arch/x86/include/asm/kvm_host.h | 11 ++++++ arch/x86/include/asm/vmx.h | 2 +- arch/x86/kvm/cpuid.c | 31 +++++++++++++++++ arch/x86/kvm/cpuid.h | 51 ++++++++++++++++++++++++++++ arch/x86/kvm/governed_features.h | 19 +++++++++++ arch/x86/kvm/mmu/mmu.c | 20 ++--------- arch/x86/kvm/svm/nested.c | 48 ++++++++++++++++----------- arch/x86/kvm/svm/svm.c | 57 +++++++++++++++++++++----------- arch/x86/kvm/svm/svm.h | 13 ++------ arch/x86/kvm/vmx/capabilities.h | 2 +- arch/x86/kvm/vmx/hyperv.h | 2 +- arch/x86/kvm/vmx/nested.c | 6 ++-- arch/x86/kvm/vmx/nested.h | 2 +- arch/x86/kvm/vmx/vmx.c | 48 +++++++++++++-------------- arch/x86/kvm/vmx/vmx.h | 2 +- arch/x86/kvm/x86.c | 4 +-- 16 files changed, 217 insertions(+), 101 deletions(-) create mode 100644 arch/x86/kvm/governed_features.h base-commit: 62ef199250cd46fb66fe98267137b7f64e0b41b4 -- 2.39.2.637.g21b0678d19-goog