All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized
@ 2019-01-02 20:56 David Rientjes
  2019-01-02 21:44 ` Singh, Brijesh
  2019-01-11 13:50 ` Radim Krčmář
  0 siblings, 2 replies; 3+ messages in thread
From: David Rientjes @ 2019-01-02 20:56 UTC (permalink / raw)
  To: Brijesh Singh, Joerg Roedel, Paolo Bonzini, Radim Krčmář
  Cc: Thomas Lendacky, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	x86, kvm, linux-kernel

By code inspection, it was found that multiple calls to KVM_SEV_INIT
could deplete asid bits and overwrite kvm_sev_info's regions_list.

Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
should likely be fixed anyway.

This code is serialized by kvm->lock.

Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
 arch/x86/kvm/svm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6278,6 +6278,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
 	int asid, ret;
 
 	ret = -EBUSY;
+	if (unlikely(sev->active))
+		return ret;
+
 	asid = sev_asid_new();
 	if (asid < 0)
 		return ret;

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

* Re: [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized
  2019-01-02 20:56 [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized David Rientjes
@ 2019-01-02 21:44 ` Singh, Brijesh
  2019-01-11 13:50 ` Radim Krčmář
  1 sibling, 0 replies; 3+ messages in thread
From: Singh, Brijesh @ 2019-01-02 21:44 UTC (permalink / raw)
  To: David Rientjes, Joerg Roedel, Paolo Bonzini, Radim Krčmář
  Cc: Singh, Brijesh, Lendacky, Thomas, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, x86, kvm, linux-kernel



On 1/2/19 2:56 PM, David Rientjes wrote:
> By code inspection, it was found that multiple calls to KVM_SEV_INIT
> could deplete asid bits and overwrite kvm_sev_info's regions_list.
> 
> Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
> should likely be fixed anyway.
> 
> This code is serialized by kvm->lock.
> 
> Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
> Reported-by: Cfir Cohen <cfir@google.com>
> Signed-off-by: David Rientjes <rientjes@google.com>

Thanks for the patch. Looks good.

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


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

* Re: [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized
  2019-01-02 20:56 [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized David Rientjes
  2019-01-02 21:44 ` Singh, Brijesh
@ 2019-01-11 13:50 ` Radim Krčmář
  1 sibling, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2019-01-11 13:50 UTC (permalink / raw)
  To: David Rientjes
  Cc: Brijesh Singh, Joerg Roedel, Paolo Bonzini, Thomas Lendacky,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, kvm,
	linux-kernel

2019-01-02 12:56-0800, David Rientjes:
> By code inspection, it was found that multiple calls to KVM_SEV_INIT
> could deplete asid bits and overwrite kvm_sev_info's regions_list.
> 
> Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
> should likely be fixed anyway.
> 
> This code is serialized by kvm->lock.
> 
> Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
> Reported-by: Cfir Cohen <cfir@google.com>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---

Applied, thanks.

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

end of thread, other threads:[~2019-01-11 13:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-02 20:56 [patch] kvm: sev: Fail KVM_SEV_INIT if already initialized David Rientjes
2019-01-02 21:44 ` Singh, Brijesh
2019-01-11 13:50 ` Radim Krčmář

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.