Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp300297rdb; Mon, 29 Jan 2024 02:41:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQaBnMX6pbet3MOXH6zGm91Lgd26XJT8NTY68zazOHpGfuDdsQFWj8cYZUrvEsh5bFG8aU X-Received: by 2002:a17:907:1044:b0:a31:13ce:d64f with SMTP id oy4-20020a170907104400b00a3113ced64fmr3545300ejb.55.1706524895897; Mon, 29 Jan 2024 02:41:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706524895; cv=pass; d=google.com; s=arc-20160816; b=0LjwmvW58+53fmC4bizh4oG/b7c5SZgNxBs7hBMp4uyTpeIQd2JX+upMzy2pAE6jRw PZVxDF6gnV70xJ1zEvApIRsnV9B5gZJfk2kvNx7esIc18zb9IpanMu0eblvlPoUOmCgX s2l6inrApvMivGfTnIbrFAs5ub5Es7NaxbUDDKMsCvpEOkGqwcnj2g+s7UC8AxOlxLou Uv9tYU+fdL61CqvogORAOjGKic6TUGWLBPFEoNHXy5lWDpdTiuGpUJncrm38Gu2Tmwhi 0HR20pY+Ihk0vgrBtpZyI55VFQeDBBzlXtMqbH9EpxXyTg39yiYAY+i4t8e/Sr4JzSYh Vm6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature:dkim-filter; bh=poMPwNlCA9ASorWGoIcCLj1xsjtr7a7gs6hsW60aNI4=; fh=bMzH5t9AnDsj3773uXN5BcS1NdTw2fRrZSYSlAmpzqQ=; b=duFm4I1nrMeJ3FUreKcgehi4J7s9b0nG9mOFVdDgd9bA4IYyYNP9iYc536vbrGvQOs 23FgIrRwa1fEKOMVsOImN6qPtmD+1jUshb0omDKUDwZekgHdgKR0aBxHKuF6OO3pfLp5 CVQ59VPOU4ORDcMXSDoXd32JlQIarugEXG92azQ/JLtj0KbmjVKjrCRrh/KpnNOpw1zc 0yCwCeMpeY7TtQmaaz5I0Ic1DLraMxVSWIoiLdTN9YvGa3z07mv41QcDSxa/n48LbuAT +jz5lcWn1wNzCwaRLwx84+mDFJL7PGUmyuKjA3PkeGxY2oSwowKvlFEfdUUqb6hCr/aM w+qg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=STCR4vUq; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-42550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ef11-20020a17090697cb00b00a34b006694dsi3267784ejb.318.2024.01.29.02.41.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 02:41:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=STCR4vUq; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-42550-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.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 7C4001F2333A for ; Mon, 29 Jan 2024 10:41:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61BDC54FB5; Mon, 29 Jan 2024 10:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="STCR4vUq" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3423744371 for ; Mon, 29 Jan 2024 10:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524888; cv=none; b=pkkSXxqQ7hcgG5zNvMXB61XZbyRn2GJRD+JFc2xUYnbqCkqUwbI1etvT2/ovzl78tfKWrZ0Vbndcx0KeazlizCI3d5X0QFQF36ChHsJzR2WOpHqG+gSFGBEnuPqeuw4RCtTq7C5MmYjx8a20bmlGZux7ARg3Hjbxevs/drcadV4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524888; c=relaxed/simple; bh=mziL3smNpACHeEVkLl7JlHuipOHyJpTEIIo2FfIWXuQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gyyUVIyAsvotaGObiMf3rh79ElZ3koehj6JcWVfgFRTXSZx6XIGfja0w4JUT2UY6lGE+hs5WkuqPQ+RFiSFd9njLvcGSqDwKHouDnvdPPaU5a//Lkl9LBUYVYAEqJIyvEQ9CRa7ulLeZgU27glwVz1jMYf7bXKlCLB8Mw3MsJG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=STCR4vUq; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: by linux.microsoft.com (Postfix, from userid 1112) id 6E48820E67D1; Mon, 29 Jan 2024 02:41:25 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6E48820E67D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1706524885; bh=poMPwNlCA9ASorWGoIcCLj1xsjtr7a7gs6hsW60aNI4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=STCR4vUqyLhO4ItMg9dbXnXPUlEmkYF6gyp14yscuoLtZTrCQSj4wR0JAliItBFGf iTjjeMxbC+Rm9iTq6PzFtGwSiVnZFo0Uwv6sjiaTrowrStgJ40D5FrKwAqV4155FOH Pc+DWe8upwpS7MAFselbmv8CaIkRfQpzeZK3Dv+c= Date: Mon, 29 Jan 2024 02:41:25 -0800 From: Jeremi Piotrowski To: Tom Lendacky Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Dan Williams , Michael Roth , Ashish Kalra Subject: Re: [PATCH 07/11] x86/sev: Provide SVSM discovery support Message-ID: <20240129104125.GA20729@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <2518c82f24f3e5d7533eea72512cea9ce985704b.1706307364.git.thomas.lendacky@amd.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; charset=us-ascii Content-Disposition: inline In-Reply-To: <2518c82f24f3e5d7533eea72512cea9ce985704b.1706307364.git.thomas.lendacky@amd.com> User-Agent: Mutt/1.5.21 (2010-09-15) On Fri, Jan 26, 2024 at 04:16:00PM -0600, Tom Lendacky wrote: > The SVSM specification documents an alternative method of discovery for > the SVSM using a reserved CPUID bit and a reserved MSR. > > For the CPUID support, the #VC handler of an SEV-SNP guest should modify > the returned value in the EAX register for the 0x8000001f CPUID function > by setting bit 28 when an SVSM is present. > It seems awkward that the guest would have to set the bit in the CPUID response itself. Is there no way for the SVSM to fixup the CPUID page contents, or the CPUID instruction return? Could you also add a definition for the feature to arch/x86/include/asm/cpufeatures.h. > For the MSR support, new reserved MSR 0xc001f000 has been defined. A #VC > should be generated when accessing this MSR. The #VC handler is expected > to ignore writes to this MSR and return the physical calling area address > (CAA) on reads of this MSR. > > Signed-off-by: Tom Lendacky > --- > arch/x86/include/asm/msr-index.h | 2 ++ > arch/x86/kernel/sev-shared.c | 4 ++++ > arch/x86/kernel/sev.c | 17 +++++++++++++++++ > 3 files changed, 23 insertions(+) > > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h > index f1bd7b91b3c6..4746135cbe21 100644 > --- a/arch/x86/include/asm/msr-index.h > +++ b/arch/x86/include/asm/msr-index.h > @@ -622,6 +622,8 @@ > > #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f > > +#define MSR_SVSM_CAA 0xc001f000 > + > /* AMD Collaborative Processor Performance Control MSRs */ > #define MSR_AMD_CPPC_CAP1 0xc00102b0 > #define MSR_AMD_CPPC_ENABLE 0xc00102b1 > diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c > index f26e872bc5d0..9bd7d7e75b31 100644 > --- a/arch/x86/kernel/sev-shared.c > +++ b/arch/x86/kernel/sev-shared.c > @@ -628,6 +628,10 @@ static int snp_cpuid_postprocess(struct ghcb *ghcb, struct es_em_ctxt *ctxt, > /* node ID */ > leaf->ecx = (leaf->ecx & GENMASK(31, 8)) | (leaf_hv.ecx & GENMASK(7, 0)); > break; > + case 0x8000001f: > + if (vmpl) > + leaf->eax |= BIT(28); > + break; > default: > /* No fix-ups needed, use values as-is. */ > break;