Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp520428lqt; Mon, 18 Mar 2024 15:11:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqk4cNMYkcvFjiS4irBjUnKTwjSlcsH53Q2Y35h5ys1gx+9bLXhIlqbLBVIeH6Hq2YC0x6CO7ANXTq+DT1N7cN495n0TZF6xRTEhvKSA== X-Google-Smtp-Source: AGHT+IHINADHq833EV+WHYUBJc8wWuCF6rEaieLKVGjFYg5aN7otM6Wn5EP+46eF8p20N+IYbJp5 X-Received: by 2002:a05:6a00:4fc4:b0:6e7:3216:52a8 with SMTP id le4-20020a056a004fc400b006e7321652a8mr1181380pfb.19.1710799879575; Mon, 18 Mar 2024 15:11:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710799879; cv=pass; d=google.com; s=arc-20160816; b=tH7vPKMPY6Oh32fUGqKl1uyrVan61bMPdIDRGF4wCjtZ07Q1YzGK1/2NZmwa2Nkr6s KolxK/dAJ1DbprKtgUAmUBQMsfdv5fhSejduXfJvBgOEDPH2ihMa15bfAaEVg1K7oD+N SVv+oBwRWUUzNAMwvh6hpUA3Hg5vsjuSeMzNLrm21hiYVqcOoyOj57LirO/WTh/5M/m8 Gs4tM8jZcyaLGk0p3XgLh62LC/WAGIisici3GErXOTBhJ97t2pvDjBhr1eQKMXMn2gHk /EwFdfp9ssbMVEBT7bo4V6co0qMpC+dSfYQxDwdHrNZJQYgm4h4rg0mzFaaF2UwtzVs/ +58w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=jIk57Yw9TtyXvEW7JA55T78f0IPlsLYi8PGmRhytf78=; fh=4eueTA11t7yu/yyH3ZVNNBqoPdb6x1KIf37qpLRuDEI=; b=OjbbWLi7he9Hev9kdH5GUAcQWd5xf5jm2WT/MGvX17BRddfoPNNV+FS5SIC82pclEO cb2ZEg/5vNyhx+MZI3rKd26dyHdtJkKzfTo7M1Nd59Mfwxmf8+nWzVzLqP++FCQKM6Wk 9/4hs4yVYkOpLDXUTdKw8bXomGoGfjIK2CGKS7NuOZUsWT6mnKFbEUaHw18Q6mnMMHbf TXDoOOCMLhYQQuVcyKtlzqx6LuRfFIxfijmQRS9go+e4BZEi2q6LfJB2S7VuGvhR1Cet Pn3vY3lNnK33lbqEHyK6XmOmzKZDVM8rbY6+RJ4oorPWzUIyYz7J7orIndFvUhvG768q +XQw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TJ+druJ4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q124-20020a632a82000000b005e49f54a865si8618092pgq.29.2024.03.18.15.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 15:11:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TJ+druJ4; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106739-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106739-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 84305B21ED3 for ; Mon, 18 Mar 2024 22:10:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D61E15A4D4; Mon, 18 Mar 2024 22:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TJ+druJ4" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2325A5A102 for ; Mon, 18 Mar 2024 22:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710799810; cv=none; b=mLuG597vmkAeazts66n42coAFKdjl+N6VYqPVgRB+dGcxrLQl8KDj45lpthfxWW/Pe+VkmR2WElqWBfYCDdunBXgxQ+uVTHL0JwkkmnSdVAtiLQcLBKfsER6D5sSQDAiGvhnZZNNnvm5Xq2DChYCqKTBLAY7ljujh56Gmn6v9/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710799810; c=relaxed/simple; bh=pUDyVdDIhWF+AxxFzQPbcKbrYmlXF2FtVHpKnNJHuHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MHB/5fsgd2VFOP9CVVk87pkzOpic6vFMrFobcAusuZEY+mU3qevj9N1Xu+BU8ul6YVxYOoFLMWM9voWxKNNOByI9dhM+sQJ9dICOVcpdUthSsJYVtLfjImZVHZfhJbjRfiT16cfX+L+3elJumli8VwN5ITY5X5juYU7V9FUKmPI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TJ+druJ4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710799808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jIk57Yw9TtyXvEW7JA55T78f0IPlsLYi8PGmRhytf78=; b=TJ+druJ4T2bRtEBGJr6B2mGfJuWYB8ZEpdfoODMc8GJ1GGnG648inWL2xPdGsMKkqMfGjT BTwi4qxyOeNlVd8V5gsbvt9O8w8NzK7wWvty9UVxmX1EFLM16iEqrrzCYyvSOrDv0caX3r KFciJCAShsIf+DYlgIzcl+1/wQQ5u9Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-3C53FmV2MF685amG0XGf_A-1; Mon, 18 Mar 2024 18:10:04 -0400 X-MC-Unique: 3C53FmV2MF685amG0XGf_A-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C500C185A781; Mon, 18 Mar 2024 22:10:03 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A31DD492BD6; Mon, 18 Mar 2024 22:10:03 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, Tom Lendacky Subject: [PATCH 1/7] KVM: SVM: Set sev->asid in sev_asid_new() instead of overloading the return Date: Mon, 18 Mar 2024 18:09:56 -0400 Message-ID: <20240318221002.2712738-2-pbonzini@redhat.com> In-Reply-To: <20240318221002.2712738-1-pbonzini@redhat.com> References: <20240318221002.2712738-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 From: Sean Christopherson Explicitly set sev->asid in sev_asid_new() when a new ASID is successfully allocated, and return '0' to indicate success instead of overloading the return value to multiplex the ASID with error codes. There is exactly one caller of sev_asid_new(), and sev_asid_free() already consumes sev->asid, i.e. returning the ASID isn't necessary for flexibility, nor does it provide symmetry between related APIs. Reviewed-by: Tom Lendacky Link: https://lore.kernel.org/r/20240131235609.4161407-2-seanjc@google.com Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/sev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index f760106c31f8..7c000088bca6 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -179,7 +179,8 @@ static int sev_asid_new(struct kvm_sev_info *sev) mutex_unlock(&sev_bitmap_lock); - return asid; + sev->asid = asid; + return 0; e_uncharge: sev_misc_cg_uncharge(sev); put_misc_cg(sev->misc_cg); @@ -246,7 +247,7 @@ static void sev_unbind_asid(struct kvm *kvm, unsigned int handle) static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) { struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; - int asid, ret; + int ret; if (kvm->created_vcpus) return -EINVAL; @@ -257,10 +258,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) sev->active = true; sev->es_active = argp->id == KVM_SEV_ES_INIT; - asid = sev_asid_new(sev); - if (asid < 0) + ret = sev_asid_new(sev); + if (ret) goto e_no_asid; - sev->asid = asid; ret = sev_platform_init(&argp->error); if (ret) -- 2.43.0