Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4449792pxb; Tue, 2 Nov 2021 09:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx7X+xzo9xP06D8zEGDrGyKAPhBLz9Vv66rNTr4xV0WAw24eDeyfkuhr3NkqJz8xkohc/S X-Received: by 2002:a05:6638:3787:: with SMTP id w7mr6279192jal.126.1635872094505; Tue, 02 Nov 2021 09:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635872094; cv=none; d=google.com; s=arc-20160816; b=G9OlaXaEeNM9ExzdTPfP0XV7+Xseik9nIqVhhiw5n4Xha27/zivJE1xmG7AndmG+qn /Th+yCT9NvS6Um038Ngz2iAxY2JXbhZZ8Fj+OpIXuQORj19ENAdbOo0CItQ/GhvK4Ahl 7/qF4hC9jJeE/KY4A97XF8FtF8DfSZv/EzsSGKpO7WnJ4bzN3zIOz/POLHlxo3VR/w9t f5U3PXEhbAl1ghabLLUBKMOi9DiL7EMhX7obNa/eJN6eQL5B2EqCmPUWcysKvEmXyeAY f8ZN9pk1EMrUL7Q7XvOI5nbajkEqBA66ShFgPt5k3XFDZbNf68OwMBGDnr1tBGX1fryI bl2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=edrm3R3EEsBQR1D6gAzpHHTA03yLJ3qMQOUPmrVmSFM=; b=xjhfcaQp8JFmbOOd2wjTxGQXWFEh+VuVgbPXS0PX1NhpQJa/t9dMqG/1zX3Q8wVZLM Pd8yUHJPAeGttw23X4lP4NZktV8AH9PnkHiznGPKwcBKkkN+coXTW3ynI3zMq4wMT3rj PjbKKbo5lPK0095ke3EJPJeriv/6BA96CpBQ5oq7oENYX+clK3yzK5htivhzxSOv5Dih Z1ouei16cpE6n7myf63Y1ApYJe+ky/18Z5DkqMD5U7bX9tjOrl/voFyt2GDxTz/xqNiI huNb508YUCSqEnz7/BnG01aRWJK0CDra3lDKCArNNga9jZrlu2TMN70GDrBn53CKoS6B dphg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=eEDc+58i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 1si21783657iln.66.2021.11.02.09.54.42; Tue, 02 Nov 2021 09:54:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=eEDc+58i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235262AbhKBQ4Q (ORCPT + 99 others); Tue, 2 Nov 2021 12:56:16 -0400 Received: from mail.skyhub.de ([5.9.137.197]:52004 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhKBQz5 (ORCPT ); Tue, 2 Nov 2021 12:55:57 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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