linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable
@ 2019-08-28  7:59 Vitaly Kuznetsov
  2019-08-28  7:59 ` [PATCH v2 1/2] KVM: x86: svm: remove unneeded nested_enable_evmcs() hook Vitaly Kuznetsov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2019-08-28  7:59 UTC (permalink / raw)
  To: kvm
  Cc: linux-kernel, Paolo Bonzini, Radim Krčmář,
	Joerg Roedel, Jim Mattson, Sean Christopherson, Roman Kagan

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] KVM: x86: svm: remove unneeded nested_enable_evmcs() hook
  2019-08-28  7:59 [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Vitaly Kuznetsov
@ 2019-08-28  7:59 ` Vitaly Kuznetsov
  2019-08-28  7:59 ` [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available Vitaly Kuznetsov
  2019-09-17 13:29 ` [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Vitaly Kuznetsov @ 2019-08-28  7:59 UTC (permalink / raw)
  To: kvm
  Cc: linux-kernel, Paolo Bonzini, Radim Krčmář,
	Joerg Roedel, Jim Mattson, Sean Christopherson, Roman Kagan

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 <vkuznets@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available
  2019-08-28  7:59 [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Vitaly Kuznetsov
  2019-08-28  7:59 ` [PATCH v2 1/2] KVM: x86: svm: remove unneeded nested_enable_evmcs() hook Vitaly Kuznetsov
@ 2019-08-28  7:59 ` Vitaly Kuznetsov
  2019-08-28 16:24   ` Jim Mattson
  2019-09-17 13:29 ` [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Paolo Bonzini
  2 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2019-08-28  7:59 UTC (permalink / raw)
  To: kvm
  Cc: linux-kernel, Paolo Bonzini, Radim Krčmář,
	Joerg Roedel, Jim Mattson, Sean Christopherson, Roman Kagan

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 <vkuznets@redhat.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available
  2019-08-28  7:59 ` [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available Vitaly Kuznetsov
@ 2019-08-28 16:24   ` Jim Mattson
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Mattson @ 2019-08-28 16:24 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: kvm list, LKML, Paolo Bonzini, Radim Krčmář,
	Joerg Roedel, Sean Christopherson, Roman Kagan

On Wed, Aug 28, 2019 at 12:59 AM Vitaly Kuznetsov <vkuznets@redhat.com> 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 <vkuznets@redhat.com>
Reviewed-by: Jim Mattson <jmattson@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable
  2019-08-28  7:59 [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Vitaly Kuznetsov
  2019-08-28  7:59 ` [PATCH v2 1/2] KVM: x86: svm: remove unneeded nested_enable_evmcs() hook Vitaly Kuznetsov
  2019-08-28  7:59 ` [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available Vitaly Kuznetsov
@ 2019-09-17 13:29 ` Paolo Bonzini
  2 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2019-09-17 13:29 UTC (permalink / raw)
  To: Vitaly Kuznetsov, kvm
  Cc: linux-kernel, Radim Krčmář,
	Joerg Roedel, Jim Mattson, Sean Christopherson, Roman Kagan

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-17 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28  7:59 [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Vitaly Kuznetsov
2019-08-28  7:59 ` [PATCH v2 1/2] KVM: x86: svm: remove unneeded nested_enable_evmcs() hook Vitaly Kuznetsov
2019-08-28  7:59 ` [PATCH v2 2/2] KVM: x86: announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS support only when it is available Vitaly Kuznetsov
2019-08-28 16:24   ` Jim Mattson
2019-09-17 13:29 ` [PATCH v2 0/2] KVM: x86: don't announce KVM_CAP_HYPERV_ENLIGHTENED_VMCS when it is unavailable Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).