All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled
@ 2020-07-31 20:51 Sean Christopherson
  2020-08-04 15:16 ` Brijesh Singh
  2020-08-06  1:24 ` Sasha Levin
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-07-31 20:51 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Tom Lendacky, Brijesh Singh

Forcefully turn off SEV if NPT is disabled, e.g. via module param.  SEV
requires NPT as the C-bit only exists if NPT is active.

Fixes: e9df09428996f ("KVM: SVM: Add sev module_param")
Cc: stable@vger.kernel.org
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---

RFC as it's entirely possible that I am completely misunderstanding how
SEV works.  Compile tested only.

 arch/x86/kvm/svm/svm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 783330d0e7b88..e30629593458b 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -860,8 +860,14 @@ static __init int svm_hardware_setup(void)
 		kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
 	}
 
+	if (!boot_cpu_has(X86_FEATURE_NPT))
+		npt_enabled = false;
+
+	if (npt_enabled && !npt)
+		npt_enabled = false;
+
 	if (sev) {
-		if (boot_cpu_has(X86_FEATURE_SEV) &&
+		if (boot_cpu_has(X86_FEATURE_SEV) && npt_enabled &&
 		    IS_ENABLED(CONFIG_KVM_AMD_SEV)) {
 			r = sev_hardware_setup();
 			if (r)
@@ -879,12 +885,6 @@ static __init int svm_hardware_setup(void)
 			goto err;
 	}
 
-	if (!boot_cpu_has(X86_FEATURE_NPT))
-		npt_enabled = false;
-
-	if (npt_enabled && !npt)
-		npt_enabled = false;
-
 	kvm_configure_mmu(npt_enabled, PG_LEVEL_1G);
 	pr_info("kvm: Nested Paging %sabled\n", npt_enabled ? "en" : "dis");
 
-- 
2.28.0


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

* Re: [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled
  2020-07-31 20:51 [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled Sean Christopherson
@ 2020-08-04 15:16 ` Brijesh Singh
  2020-08-06  1:24 ` Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Brijesh Singh @ 2020-08-04 15:16 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: brijesh.singh, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, kvm, linux-kernel, Tom Lendacky


On 7/31/20 3:51 PM, Sean Christopherson wrote:
> Forcefully turn off SEV if NPT is disabled, e.g. via module param.  SEV
> requires NPT as the C-bit only exists if NPT is active.
>
> Fixes: e9df09428996f ("KVM: SVM: Add sev module_param")
> Cc: stable@vger.kernel.org
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Brijesh Singh <brijesh.singh@amd.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>
> RFC as it's entirely possible that I am completely misunderstanding how
> SEV works.  Compile tested only.


Reviewed-By: Brijesh Singh <brijesh.singh@amd.com>


>
>  arch/x86/kvm/svm/svm.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 783330d0e7b88..e30629593458b 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -860,8 +860,14 @@ static __init int svm_hardware_setup(void)
>  		kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE);
>  	}
>  
> +	if (!boot_cpu_has(X86_FEATURE_NPT))
> +		npt_enabled = false;
> +
> +	if (npt_enabled && !npt)
> +		npt_enabled = false;
> +
>  	if (sev) {
> -		if (boot_cpu_has(X86_FEATURE_SEV) &&
> +		if (boot_cpu_has(X86_FEATURE_SEV) && npt_enabled &&
>  		    IS_ENABLED(CONFIG_KVM_AMD_SEV)) {
>  			r = sev_hardware_setup();
>  			if (r)
> @@ -879,12 +885,6 @@ static __init int svm_hardware_setup(void)
>  			goto err;
>  	}
>  
> -	if (!boot_cpu_has(X86_FEATURE_NPT))
> -		npt_enabled = false;
> -
> -	if (npt_enabled && !npt)
> -		npt_enabled = false;
> -
>  	kvm_configure_mmu(npt_enabled, PG_LEVEL_1G);
>  	pr_info("kvm: Nested Paging %sabled\n", npt_enabled ? "en" : "dis");
>  

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

* Re: [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled
  2020-07-31 20:51 [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled Sean Christopherson
  2020-08-04 15:16 ` Brijesh Singh
@ 2020-08-06  1:24 ` Sasha Levin
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2020-08-06  1:24 UTC (permalink / raw)
  To: Sasha Levin, Sean Christopherson, Paolo Bonzini
  Cc: Sean Christopherson, stable, Tom Lendacky, Brijesh Singh, stable

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: e9df09428996 ("KVM: SVM: Add sev module_param").

The bot has tested the following trees: v5.7.11, v5.4.54, v4.19.135.

v5.7.11: Failed to apply! Possible dependencies:
    3bae0459bcd5 ("KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums")
    b2f432f872d9 ("KVM: x86/mmu: Tweak PSE hugepage handling to avoid 2M vs 4M conundrum")
    e662ec3e0705 ("KVM: x86/mmu: Move max hugepage level to a separate #define")

v5.4.54: Failed to apply! Possible dependencies:
    106ee47dc633 ("docs: kvm: Convert api.txt to ReST format")
    213e0e1f500b ("KVM: SVM: Refactor logging of NPT enabled/disabled")
    3bae0459bcd5 ("KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums")
    3c9bd4006bfc ("KVM: x86: enable dirty log gradually in small chunks")
    80b10aa92448 ("Documentation: kvm: Fix mention to number of ioctls classes")
    c726200dd106 ("KVM: arm/arm64: Allow reporting non-ISV data aborts to userspace")
    cb9b88c66939 ("KVM: x86/mmu: Refactor handling of cache consistency with TDP")
    da345174ceca ("KVM: arm/arm64: Allow user injection of external data aborts")
    e662ec3e0705 ("KVM: x86/mmu: Move max hugepage level to a separate #define")

v4.19.135: Failed to apply! Possible dependencies:
    213e0e1f500b ("KVM: SVM: Refactor logging of NPT enabled/disabled")
    3bae0459bcd5 ("KVM: x86/mmu: Drop KVM's hugepage enums in favor of the kernel's enums")
    44dd3ffa7bb3 ("x86/kvm/mmu: make vcpu->mmu a pointer to the current MMU")
    4fef0f491347 ("KVM: x86: move definition PT_MAX_HUGEPAGE_LEVEL and KVM_NR_PAGE_SIZES together")
    91e86d225ef3 ("kvm: x86: Add payload operands to kvm_multiple_exception")
    c851436a34ca ("kvm: x86: Add has_payload and payload to kvm_queued_exception")
    cb9b88c66939 ("KVM: x86/mmu: Refactor handling of cache consistency with TDP")
    d647eb63e671 ("KVM: svm: add nrips module parameter")
    da998b46d244 ("kvm: x86: Defer setting of CR2 until #PF delivery")
    e662ec3e0705 ("KVM: x86/mmu: Move max hugepage level to a separate #define")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

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

end of thread, other threads:[~2020-08-06  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-31 20:51 [RFC PATCH] KVM: SVM: Disallow SEV if NPT is disabled Sean Christopherson
2020-08-04 15:16 ` Brijesh Singh
2020-08-06  1:24 ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.