Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5751851pxb; Thu, 20 Jan 2022 04:00:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqzwfFcYK3AR8BOJ2nPi5tDVckXo/Jt4eXJFtJxG28o4oGaMVvY5lDoo7MushpXzPg4BVG X-Received: by 2002:a17:902:ce8f:b0:14b:87c:8932 with SMTP id f15-20020a170902ce8f00b0014b087c8932mr1761379plg.3.1642680001822; Thu, 20 Jan 2022 04:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642680001; cv=none; d=google.com; s=arc-20160816; b=kl7xnBsDFCLZn5FCM92M7See76fhGxqVENWwvrMciNea2DBbl0JnW0NsZ5MB1d8TBk jOJmn2ACW4sbE28GgZ1SDfFRA88sK7sfxohF4vKpCumApMZsYOiYXQXVpJX1AcJqky/B acTFB07FAG3nmjoKo3tL42vSSQDyuiaCZbZKoe0k9UkffEk86R1ARhQ3VS49Y/uihDVo CrJjjSTUH3mnyKV8yhvJ7y1Opdd+/GMGnE4s9kRv0HAmmPeranAA8O9LF6sk97X5dXhT yICYX+NxP2H8f/oP1OJL44Pfa/7nOFVZw2HQRe0gIEIBav+XZxVb/yFrLuHYretYhmF+ BqLg== 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=4JA023Sy7F48GbJHjrrwIoXYzwKYqGQtCBAMqfyQANo=; b=dwjlPJH2PQTg7NdxSXt/7yIlBSDljQ0VEIH2feS5k6vvOFtcvDwIc+mjHk6LZyySbz C0jxm7GYUfG7E/qrGUcalo9zWnbUBqcVtezxouNC7+R4fBYEVm7YnSg1M20tfHIq9Kej 6jAFXB8C78KKrynJ2Kbhb4b+0ieHOQ+imi6ZKj/Pw43biLVrGfNWWyUOXJnokxjkdIab ErZC56jOH/P9Da8Ge6YM+PupsnC49lrUIRh6bUXcHNP9L/YPlBHx0sFj58UV9eBzgTz8 f9OTBkrHCM9lNWNhm0CpMspFcCoHro4Bij8MjFKlYkkR+iYtPN3mbzM8IDJ9+xw2cQuJ vyHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=QVgvfx98; 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 qe8si9224865pjb.41.2022.01.20.03.59.49; Thu, 20 Jan 2022 04:00:01 -0800 (PST) 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=QVgvfx98; 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 S244754AbiAROCx (ORCPT + 99 others); Tue, 18 Jan 2022 09:02:53 -0500 Received: from mail.skyhub.de ([5.9.137.197]:43026 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243400AbiAROCw (ORCPT ); Tue, 18 Jan 2022 09:02:52 -0500 Received: from zn.tnic (dslb-088-067-202-008.088.067.pools.vodafone-ip.de [88.67.202.8]) (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 AA99D1EC0441; Tue, 18 Jan 2022 15:02:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1642514566; 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=4JA023Sy7F48GbJHjrrwIoXYzwKYqGQtCBAMqfyQANo=; b=QVgvfx98+X2IoAfXGC2QEREdXtSvoWS83vhZnsrxrNqdtbkWGX89kMM+eosJlcDhEsUXdI ovazPq/TSnRzTvdcDj+JT/tDuSwcPDIefvr7iyfUHTVM1Q3uisxxkT09LrHgwbVK5RuAnd BCpcpQC1lExp3P6caPQtNf+qU5CDYMU= Date: Tue, 18 Jan 2022 15:02:48 +0100 From: Borislav Petkov To: Michael Roth Cc: Brijesh Singh , 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 , 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 v8 29/40] x86/compressed/64: add support for SEV-SNP CPUID table in #VC handlers Message-ID: References: <20211210154332.11526-1-brijesh.singh@amd.com> <20211210154332.11526-30-brijesh.singh@amd.com> <20220113163913.phpu4klrmrnedgic@amd.com> <20220118043521.exgma53qrzrbalpd@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220118043521.exgma53qrzrbalpd@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 17, 2022 at 10:35:21PM -0600, Michael Roth wrote: > Unfortunately, in sev_enable(), between the point where snp_init() is > called, and sev_status is actually set, there are a number of cpuid > intructions which will make use of do_vc_no_ghcb() prior to sev_status > being set (and it needs to happen in that order to set sev_status > appropriately). After that point, snp_cpuid_active() would no longer be > necessary, but during that span some indicator is needed in case this > is just an SEV-ES guest trigger cpuid #VCs. You mean testing what snp_cpuid_info_create() set up is not enough? diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c index 7bc7e297f88c..17cfe804bad3 100644 --- a/arch/x86/kernel/sev-shared.c +++ b/arch/x86/kernel/sev-shared.c @@ -523,7 +523,9 @@ static int snp_cpuid_postprocess(u32 func, u32 subfunc, u32 *eax, u32 *ebx, static int snp_cpuid(u32 func, u32 subfunc, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx) { - if (!snp_cpuid_active()) + const struct snp_cpuid_info *c = snp_cpuid_info_get_ptr(); + + if (!c->count) return -EOPNOTSUPP; if (!snp_cpuid_find_validated_func(func, subfunc, eax, ebx, ecx, edx)) { --- Btw, all those /* SEV-SNP CPUID table should be set up now. */ if (!snp_cpuid_active()) sev_es_terminate(1, GHCB_TERM_CPUID); after snp_cpuid_info_create() has returned are useless either. If that function returns, you know you're good to go wrt SNP. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette