[v4,4/4] KVM: SVM: Return -EINVAL instead of -EBUSY on attempt to re-init SEV/SEV-ES
Message ID | 20240131235609.4161407-5-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp100801dyc; Wed, 31 Jan 2024 15:58:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/KSnBCeoJe2P5C4j0cBYSf0RlZy7uAk9/UgxQ8vUkafPK+VJncMZ+yTvqIkYfYdzdKSmh X-Received: by 2002:a05:6402:c10:b0:55f:aed2:1c49 with SMTP id co16-20020a0564020c1000b0055faed21c49mr255494edb.21.1706745502991; Wed, 31 Jan 2024 15:58:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706745502; cv=pass; d=google.com; s=arc-20160816; b=mA2Vw8ehvrWUJmor/c++9Nm9CX8SBUd2LleMpgyTgbtx3/1w0cJ+0RL5tFHgIw5W+B IGqgaMR9Tqw1NxZ8kZv0Mv5YvR6oKg3dwdjUVJmvh6jxAjtxHDceEpn2H/2MLeTLp+LK yFoJwTUSSQNAq1KLvLYmmILGnDnCGv3PkV469u4V9KdbZ42BXysGveWCExtyiNKebNk3 CM5Y7gHljzMu3xNYOw0+gds1CeySLo+sx4JDCffbfWOJhgYBwaue/93RLk366QbAslj+ ju7iPxB3BoQ6uohA2UZSN/GAMSQUtk9Hnkwvj5lq2b3CRmABN+2b9JrDMeoQfzUYSXMH bFdA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=yNChpOdBDlQ0ccn6PmbEc8ewiIrWgLKikwCTAZH7kF8=; fh=MvJiXdvYe6MQ8FgXyMu+AlP/UASyk3qIdFdQzGcEVJA=; b=FM2sKhHo3nYM5deppPJlqFPhP6XEPZZMp6DRK4SDrlQuNzlYnsLRyF6yKlGW30zTWu Zr+OewbYipZJgF9cpyZorIjbEUEvKlNvbFNzGUQOh7ciQzwQnTdvOT/c9bt0SLmGLCde E7ayTSl7MxtAuX6e0mZQDx97D5ubUfBcM/bWWM6/lTLPDDcj7h0cTjxe6dmNEsiW3YpA ycqGR7jCkbJlY23CJQojc6wRIAflCuM1qUKuaixQ/rqI6Re6o4sqpSE7m6gt1WwiWG2L Dlo0CQrxdldxPi7Kn/HLNSaYEwq6Mq1cG+Yz3QIU72SNTAFMa4/hJ1sATonqSxaS66o/ UFaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jCj4pBkI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVfNCQQQ+fy3WWbEm0XqfoQ8H+o0iT16ECHqBjvNBPLz6FZjw7Qw7qQzdQk80TBwLIdBuEU0kdTuVLOSlOaA18ve8KFKw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bl17-20020a056402211100b0055f3d5e1c90si2490886edb.489.2024.01.31.15.58.22 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:58:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=jCj4pBkI; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47403-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A7FC1F25C05 for <ouuuleilei@gmail.com>; Wed, 31 Jan 2024 23:58:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4859A405DF; Wed, 31 Jan 2024 23:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="jCj4pBkI" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3772C3D0A3 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 23:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706745381; cv=none; b=mjKQ8fRnw3l00MzK1XDaeznLmAB33jSSesWJogSQqwyFeXEZ1yLeyfEpcdR4YOMTV9gvs08yeYY5dK1kZqAH+KmhAMBdUe7Dn5Qd/yV1zvWIoyQg3RyX2x7c2AhsI7Yv3ycramz0+W7WWVYiOYUHrvgN8yUbBYd1Jd7BY0LClbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706745381; c=relaxed/simple; bh=dJzDRHZ4lvHqnCEXSzwyrLR5DGIflpjXQoxReg/o7XY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gNIDZeO7ZRETGoXlrmbC+Nx9LEVR4rr+5noUnNZsnjge4dwKd3aiTU5UkDj+wUUPS8DGtjAQOSsTylkwW07wtdPqXVQpZVFHYrE/CuKydLO5yqN0eHcFIHQPxhb9f+Fz6GxREszEhR9vFUaIzjnr6y4TrtiSPRJyBZcovkP/GfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=jCj4pBkI; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5cf2714e392so232044a12.0 for <linux-kernel@vger.kernel.org>; Wed, 31 Jan 2024 15:56:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706745379; x=1707350179; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=yNChpOdBDlQ0ccn6PmbEc8ewiIrWgLKikwCTAZH7kF8=; b=jCj4pBkI9HgR+IeJsNF9dobIM76elCbTIgKk4h/ayPUdl0+FYpXwmVuUfJ5PzF8A8J CBoHx5a/kZTBxoVcnqcGg/G8QDOjsMQcpwPo0grIF5KUG0GjPbTgF29R6NIQbBcnKX7H LEK31rmIqNscZOrex+6NzOcgs+Eidca+ZTFRHdEuFaU+9uwsi7hIAUia2cUHr1R7+myb gEHeAQ+s9SpIiDoLRI3NBUHKMJ7Q8oD1JB1c5ju0jA2irn2jmzz3FFv4HOTvX5TRju01 L68CkRgBJel/SnhCVkJ/MQoyoTkzxnrX/4zwgusRuArJB3Nnpigr5ZttMDLSlcE/mE19 oDWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706745379; x=1707350179; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yNChpOdBDlQ0ccn6PmbEc8ewiIrWgLKikwCTAZH7kF8=; b=uf3MR4ytf+nmyk6TWHcCeiP+uALFPS30R9R6/dqMDh+eJTLNOhxYo5M2f9kIzka7Ig dF+QZEeIKDKalYvVU1B9XnBwRAgJyLNbHvdUAtQ3UdLjiiW07RYjyjatIgpKYk1UD+H7 gSNH4zLqvufB1XvRYdPTg6qQie5lqeiG6UoBlQkLLMJtRerJZlpzoPHpkQryvYxzoVhF 3wBwocI/Ud07Im8/htyDDvFG3xh0qOqnN4iKZtNpr2jVy3iJQrJ3OwbKSf36rrxjOnAv zjt1ENoARo+mMyHU7muxW+CJ9/cmWGlJPP3gu4waSKfVDboCum5qHs681x10UsM73Gpi RvOg== X-Gm-Message-State: AOJu0Yzp4c2pstcSO7ZNUhSeVLz5o/1wWn0Mb+Cis0OOU+6pQ9PayHfW zwwcZCryONyKpntH8PzTC2C+3DZDTUIg9tNQThJgom1vM8r3VFAGK2P4PCnDe1wXQ05jN5xwgah 4uA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:8849:0:b0:5cd:c9af:ff21 with SMTP id l70-20020a638849000000b005cdc9afff21mr191194pgd.3.1706745379511; Wed, 31 Jan 2024 15:56:19 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Wed, 31 Jan 2024 15:56:09 -0800 In-Reply-To: <20240131235609.4161407-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240131235609.4161407-1-seanjc@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240131235609.4161407-5-seanjc@google.com> Subject: [PATCH v4 4/4] KVM: SVM: Return -EINVAL instead of -EBUSY on attempt to re-init SEV/SEV-ES From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ashish Kalra <ashish.kalra@amd.com>, Tom Lendacky <thomas.lendacky@amd.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789652372708158318 X-GMAIL-MSGID: 1789652372708158318 |
Series |
Add support for allowing zero SEV ASIDs
|
|
Commit Message
Sean Christopherson
Jan. 31, 2024, 11:56 p.m. UTC
Return -EINVAL instead of -EBUSY if userspace attempts KVM_SEV{,ES}_INIT
on a VM that already has SEV active. Returning -EBUSY is nonsencial as
it's impossible to deactivate SEV without destroying the VM, i.e. the VM
isn't "busy" in any sane sense of the word, and the odds of any userspace
wanting exactly -EBUSY on a userspace bug are minuscule.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/sev.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
On 1/31/24 17:56, Sean Christopherson wrote: > Return -EINVAL instead of -EBUSY if userspace attempts KVM_SEV{,ES}_INIT > on a VM that already has SEV active. Returning -EBUSY is nonsencial as > it's impossible to deactivate SEV without destroying the VM, i.e. the VM > isn't "busy" in any sane sense of the word, and the odds of any userspace > wanting exactly -EBUSY on a userspace bug are minuscule. > > Signed-off-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> > --- > arch/x86/kvm/svm/sev.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index 38e40fbc7ea0..cb19b57e1031 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -259,9 +259,8 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) > if (kvm->created_vcpus) > return -EINVAL; > > - ret = -EBUSY; > if (unlikely(sev->active)) > - return ret; > + return -EINVAL; > > sev->active = true; > sev->es_active = argp->id == KVM_SEV_ES_INIT;
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 38e40fbc7ea0..cb19b57e1031 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -259,9 +259,8 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) if (kvm->created_vcpus) return -EINVAL; - ret = -EBUSY; if (unlikely(sev->active)) - return ret; + return -EINVAL; sev->active = true; sev->es_active = argp->id == KVM_SEV_ES_INIT;