Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp340715rdb; Tue, 5 Dec 2023 07:01:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrtrL34DltFSp7AId7p7I8qf/70c1V+h/gCf4Ei1bcQfcazcPA4BziXQUwm4sxjIQ+BOxE X-Received: by 2002:a05:6a20:9785:b0:18f:97c:824b with SMTP id hx5-20020a056a20978500b0018f097c824bmr3537659pzc.85.1701788488101; Tue, 05 Dec 2023 07:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701788488; cv=none; d=google.com; s=arc-20160816; b=pi2aIVrrmiJDEJxU3OQrdZsSQF9nAIEDcGd8Krc72soIRbER/cDeDAv9+9XJ5kb3AH nsL2ZIM5HawEQvh2tC24kVixubrsSqnI5TnnRR0805Mgr43wLoThIMVvUTHAbIofQ+uR q5pQUvT06CJCKcUjTDCEiB7NsCl+3Avj0Pp5KbWC7AQaiKlYOfiwzOq57vyNC1+/MnwF ARmxOkUHA8tdfkvWm2ibKq3cuQpxYsLpkKYOcj9GNtsehjKM1mbt8DSH9qDNNseFAs8K M24qRyGrL45vE60s1gOx0AmLuY4fBvFugChKfF3O+FSQ6m36b1O+7XLhiel6tEiZ30xo PFfg== 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=beWc5KpmKIN47StJeDOg72CV4YsKimpaISxEKfJLOBg=; fh=mypGTL4gp7XugDmSg13w/lo2s65Hd0jynOduH/Ep6FQ=; b=0fLCboSFHu9ia8mX99lBAm+GQTT/F2L4jtg00W2mZZuPja39hEzaWNJocGfpqQRalx 9mIgAoANfAZjvPE2eVSatBAeJoDr3xqRwaRtJyylXAPYK0wzyL2XUCi+3uvLFdG6vTvt eFA+85PezjEu202XryJI+L53oOkEjTk41/1fIwAb3OQwwXRmjn4hvPSCcVuUmNvd+nL8 9LwUHwkdrlZS6CjIUB3yEk37GiDEp19oZDsIbPuCZOlC2AB/3zJaOl9xEp3uDSgGIIEj uPPn50Z8h0Vz1lfOYgZXXBjl2nKs4LW6S18C0BkftKrbV6XIEZsF3CjewrO0E9TNSNoB 3s/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=av5WQ51a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 5-20020a630005000000b005bd66bfc256si9812565pga.869.2023.12.05.07.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 07:01:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=av5WQ51a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CF2E4807C556; Tue, 5 Dec 2023 07:00:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346007AbjLEPAN (ORCPT + 99 others); Tue, 5 Dec 2023 10:00:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345810AbjLEPAM (ORCPT ); Tue, 5 Dec 2023 10:00:12 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFDAA9 for ; Tue, 5 Dec 2023 07:00:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701788418; x=1733324418; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=MnPLBQgc9Jr4eHHjTeEgqwSFgYc46mDEnA2okGxhpj0=; b=av5WQ51aDaGvlHviOFgzNviTxUMNRFEDwQliR1sOfCvcnIVBMlaN26gB R0Y8yLRLcStU0sgLhlAA+J8jtMrrJEk7smOgR7a3L9gZ4ukUfGNif8f3s mZHPk6x5cNWem28vOOz4vjq7QQ5+B+MXtlNGuRowRsYkHs7P4ALjkhMG2 chqIxpP2waV6iAvgaKSjde/hGLHVjxmjSmGXocY/93VIz+bfTUK2zLqnO jdroV36NjeAh+YA1t0TNwMGmTmb81kpWj8Z+MvyLp6Lpmc4btmY60ZPo/ iPEbB4SqJGc3HJRUGXHMAdMw5g8Cq5wLh0HlsGyyBlk2ymk2y4ehRPepR Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10915"; a="15452977" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="15452977" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 07:00:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="12354420" Received: from rjongalo-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.46.235]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 07:00:15 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 86EC110A43A; Tue, 5 Dec 2023 18:00:12 +0300 (+03) Date: Tue, 5 Dec 2023 18:00:12 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: Tom Lendacky , Thomas Gleixner , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/coco, x86/sev: Use cpu_feature_enabled() to detect SEV guest flavor Message-ID: <20231205150012.6lma2wzcellr7pz7@box.shutemov.name> References: <20231205143738.2875-1-kirill.shutemov@linux.intel.com> <20231205144619.GCZW83uzAomKmupn7j@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231205144619.GCZW83uzAomKmupn7j@fat_crate.local> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 07:00:30 -0800 (PST) On Tue, Dec 05, 2023 at 03:46:19PM +0100, Borislav Petkov wrote: > On Tue, Dec 05, 2023 at 05:37:38PM +0300, Kirill A. Shutemov wrote: > > The SEV code uses cc_platform_has() checks to detect the SEV flavor. > > However, these checks can sometimes produce false positives depending on > > the context. > > > > For example, sev_map_percpu_data() uses CC_ATTR_GUEST_MEM_ENCRYPT to > > detect SEV guest, but this check will also pass for TDX guests. > > Well, a function prefixed with "sev_" should check cc_vendor first... I don't think cc_platform_has() is the right check. On TDX side we use X86_FEATURE_TDX_GUEST for this and it works better than stretching CC_ATTRs beyond their meaning. -- Kiryl Shutsemau / Kirill A. Shutemov