It was discovered that hyperv_cpuid test now fails on AMD as it tries to
enable KVM_CAP_HYPERV_ENLIGHTENED_VMCS which is (wrongfully) reported as
available.
Changes since v1:
- This is a v2 for '[PATCH 0/3] KVM: x86: fix a couple of issues with
Enlightened VMCS enablement' renamed as the first patch of the series
was already merged.
- Added Jim's Reviewed-by: to PATCH1
- Added missing break in PATCH2 [Jim Mattson, Sean Christopherson]
Vitaly Kuznetsov (2):
KVM: x86: svm: remove unneeded nested_enable_evmcs() hook
KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when
it is available
arch/x86/kvm/svm.c | 9 +--------
arch/x86/kvm/x86.c | 4 +++-
2 files changed, 4 insertions(+), 9 deletions(-)
--
2.20.1
It was discovered that after commit 65efa61dc0d5 ("selftests: kvm: provide
common function to enable eVMCS") hyperv_cpuid selftest is failing on AMD.
The reason is that the commit changed _vcpu_ioctl() to vcpu_ioctl() in the
test and this one can't fail.
Instead of fixing the test is seems to make more sense to not announce
KVM_CAP_HYPERV_ENLIGHTENED_VMCS support if it is definitely missing
(on svm and in case kvm_intel.nested=0).
Signed-off-by: Vitaly Kuznetsov <[email protected]>
---
arch/x86/kvm/x86.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d1cd0fcff9e7..149511f47377 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3106,7 +3106,6 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
case KVM_CAP_HYPERV_EVENTFD:
case KVM_CAP_HYPERV_TLBFLUSH:
case KVM_CAP_HYPERV_SEND_IPI:
- case KVM_CAP_HYPERV_ENLIGHTENED_VMCS:
case KVM_CAP_HYPERV_CPUID:
case KVM_CAP_PCI_SEGMENT:
case KVM_CAP_DEBUGREGS:
@@ -3183,6 +3182,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
r = kvm_x86_ops->get_nested_state ?
kvm_x86_ops->get_nested_state(NULL, NULL, 0) : 0;
break;
+ case KVM_CAP_HYPERV_ENLIGHTENED_VMCS:
+ r = kvm_x86_ops->nested_enable_evmcs != NULL;
+ break;
default:
break;
}
--
2.20.1
Since commit 5158917c7b019 ("KVM: x86: nVMX: Allow nested_enable_evmcs to
be NULL") the code in x86.c is prepared to see nested_enable_evmcs being
NULL and in VMX case it actually is when nesting is disabled. Remove the
unneeded stub from SVM code.
Signed-off-by: Vitaly Kuznetsov <[email protected]>
Reviewed-by: Jim Mattson <[email protected]>
---
arch/x86/kvm/svm.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 40175c42f116..6d52c65d625b 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -7122,13 +7122,6 @@ static int svm_unregister_enc_region(struct kvm *kvm,
return ret;
}
-static int nested_enable_evmcs(struct kvm_vcpu *vcpu,
- uint16_t *vmcs_version)
-{
- /* Intel-only feature */
- return -ENODEV;
-}
-
static bool svm_need_emulation_on_page_fault(struct kvm_vcpu *vcpu)
{
unsigned long cr4 = kvm_read_cr4(vcpu);
@@ -7337,7 +7330,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
.mem_enc_reg_region = svm_register_enc_region,
.mem_enc_unreg_region = svm_unregister_enc_region,
- .nested_enable_evmcs = nested_enable_evmcs,
+ .nested_enable_evmcs = NULL,
.nested_get_evmcs_version = NULL,
.need_emulation_on_page_fault = svm_need_emulation_on_page_fault,
--
2.20.1
On Wed, Aug 28, 2019 at 12:59 AM Vitaly Kuznetsov <[email protected]> wrote:
>
> It was discovered that after commit 65efa61dc0d5 ("selftests: kvm: provide
> common function to enable eVMCS") hyperv_cpuid selftest is failing on AMD.
> The reason is that the commit changed _vcpu_ioctl() to vcpu_ioctl() in the
> test and this one can't fail.
>
> Instead of fixing the test is seems to make more sense to not announce
> KVM_CAP_HYPERV_ENLIGHTENED_VMCS support if it is definitely missing
> (on svm and in case kvm_intel.nested=0).
>
> Signed-off-by: Vitaly Kuznetsov <[email protected]>
Reviewed-by: Jim Mattson <[email protected]>
On 28/08/19 09:59, Vitaly Kuznetsov wrote:
> It was discovered that hyperv_cpuid test now fails on AMD as it tries to
> enable KVM_CAP_HYPERV_ENLIGHTENED_VMCS which is (wrongfully) reported as
> available.
>
> Changes since v1:
> - This is a v2 for '[PATCH 0/3] KVM: x86: fix a couple of issues with
> Enlightened VMCS enablement' renamed as the first patch of the series
> was already merged.
> - Added Jim's Reviewed-by: to PATCH1
> - Added missing break in PATCH2 [Jim Mattson, Sean Christopherson]
>
> Vitaly Kuznetsov (2):
> KVM: x86: svm: remove unneeded nested_enable_evmcs() hook
> KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when
> it is available
>
> arch/x86/kvm/svm.c | 9 +--------
> arch/x86/kvm/x86.c | 4 +++-
> 2 files changed, 4 insertions(+), 9 deletions(-)
>
Queued, thanks.
Paolo