From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33C98C433EF for ; Tue, 2 Nov 2021 16:53:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C255D60F45 for ; Tue, 2 Nov 2021 16:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C255D60F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3224294000A; Tue, 2 Nov 2021 12:53:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D263940008; Tue, 2 Nov 2021 12:53:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A2094000A; Tue, 2 Nov 2021 12:53:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 0C782940008 for ; Tue, 2 Nov 2021 12:53:27 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B4CCF14D3A for ; Tue, 2 Nov 2021 16:53:26 +0000 (UTC) X-FDA: 78764586012.14.27F3853 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf06.hostedemail.com (Postfix) with ESMTP id 489AA801A8A3 for ; Tue, 2 Nov 2021 16:53:22 +0000 (UTC) Received: from zn.tnic (p200300ec2f0f6200599060f0a067c463.dip0.t-ipconnect.de [IPv6:2003:ec:2f0f:6200:5990:60f0:a067:c463]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id F2C4D1EC0532; Tue, 2 Nov 2021 17:53:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1635872001; 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:in-reply-to:in-reply-to: references:references; bh=edrm3R3EEsBQR1D6gAzpHHTA03yLJ3qMQOUPmrVmSFM=; b=eEDc+58iPJ1KEK5RLv3j8dCETvgVFTaSsrzR7pOdy3VmF7evYjnsJqxOiUibHXeetZf9IZ xeLB0+L9Ka9uKeIjLpvQCSEWbp5E+bOJzk6g31SWdUqzALJiSOaft2W9zfN90hdCFQZWU8 VlrsoegkGI4LYkNqaMdK2ReBGgMAbQo= Date: Tue, 2 Nov 2021 17:53:15 +0100 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , "Dr . David Alan Gilbert" , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH v6 14/42] x86/sev: Register GHCB memory when SEV-SNP is active Message-ID: References: <20211008180453.462291-1-brijesh.singh@amd.com> <20211008180453.462291-15-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211008180453.462291-15-brijesh.singh@amd.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 489AA801A8A3 X-Stat-Signature: z17b4cjtstixwwi6ikqdoqni4rqxri1t Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b=eEDc+58i; dmarc=pass (policy=none) header.from=alien8.de; spf=temperror (imf06.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de X-HE-Tag: 1635872002-189032 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 08, 2021 at 01:04:25PM -0500, Brijesh Singh wrote: > + /* SEV-SNP guest requires that GHCB must be registered. */ > + if (cc_platform_has(CC_ATTR_SEV_SNP)) > + snp_register_ghcb(data, __pa(ghcb)); This looks like more of that "let's register a GHCB at the time the first #VC fires". And there already is setup_ghcb() which is called in the #VC handler. And that thing registers a GHCB GPA. But then you have to do it here again. I think this should be changed together with the CPUID page detection stuff we talked about earlier, where, after you've established that this is an SNP guest, you call setup_ghcb() *once* and after that you have everything set up, including the GHCB GPA. And then the #VC exceptions can come. Right? Or is there a chicken-and-an-egg issue here which I'm not thinking about? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette