Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp441818rdb; Tue, 5 Dec 2023 09:28:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjCLZKxO3GWUSwQloIU+gBGu7RFboazn1lCDOS9l+x472FrL2YNhmW6lRXnFfYTF5C0L/8 X-Received: by 2002:a17:90b:4ad0:b0:286:55be:1248 with SMTP id mh16-20020a17090b4ad000b0028655be1248mr1150090pjb.20.1701797289257; Tue, 05 Dec 2023 09:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701797289; cv=none; d=google.com; s=arc-20160816; b=e/kZ4Cnn7u1tpNkxvkSy3m8oJCnkr/1rwKuachPWQmHyWS56yqFs/TlJnza7vZJ3E0 eOyzgOdI08wih25NIc1LJbhHa3hqNf84QbHafuDeMJFv+757XxdsCkIxqa1N/NPDmf3D hHnD5zldFsTshNtxfRafCQZ3v9YwK+7an7jmu+RlOWu43l/+yRo03Sak8HhhRzN2z3sx cvlPuisa4PCxuVWD4Un5JmLycBUGgpr+tVMrwhG9GaLBJ5c19NIDhhp0aBZatovt0Ohh nbJevNHjLq/PpuvKkzNPgSem57Cjxh+ECmLqiSDt08EYMCb59rpj8KSfk78xlgGcHQWi 3BCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=R4EPJuqe1SbTGVkqEXJdX4TmDi8/mFk2BAKrvXRHNG8=; fh=Emka8H0Yqg5wJ83xBiIi+dpWMEoJHuubiB3fQL+abeA=; b=J2OPB4CbA/Fclt774hBVg/VStsvE5bRAf3nfVD9ktzbETvuO0rMVcRx9TFfcN+W8Im jX2eJg7HJCXlfKmV3Tj3D6twmjKkeQSdeyBrJ4+lLeR4I6d63okwuLPMvmB02GXKbfKt WxalrqzABX1sKXhQzuA3/TUIwXjkvQpdhM7N48Eu1oR1TwCPfF2GAZUV0dpuZxh8GdPG 0kfHJ0xs/tjBAPujM8eWpg5ZrQKoibqxdlCro65V4ClGg25ZBlAQTC8Agmvb8qAGFdl8 BBXo0+haoA5SsZrbtd4JFItXxUDRSYi7J6rMN0xlTmWTgPlKdY5nG+RZSYfTLNNa/5wh 5D6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XoNJqJ0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id w12-20020a17090aad4c00b002869aab8f55si4309115pjv.52.2023.12.05.09.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 09:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XoNJqJ0c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7CDF280A8DAF; Tue, 5 Dec 2023 09:28:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbjLER1u (ORCPT + 99 others); Tue, 5 Dec 2023 12:27:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345246AbjLER1s (ORCPT ); Tue, 5 Dec 2023 12:27:48 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 38A161BC for ; Tue, 5 Dec 2023 09:27:54 -0800 (PST) Received: from [192.168.178.49] (dynamic-adsl-84-220-28-122.clienti.tiscali.it [84.220.28.122]) by linux.microsoft.com (Postfix) with ESMTPSA id 16D9520B74C0; Tue, 5 Dec 2023 09:27:50 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 16D9520B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1701797273; bh=R4EPJuqe1SbTGVkqEXJdX4TmDi8/mFk2BAKrvXRHNG8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XoNJqJ0cK69JkasM3Je2NOzz4cni22BY8X4jQjuB/1+6qUC9XgVkQpRx3ZUnIckjL 4YZTISmOLxBed5Hal2ZpVzfLfbFQT0KaMjAPFnGpoZ2Ubw+YY6uiRfdxqvwK1tJUtJ TrebrHoCG++xDJVyixfpKcLH1lCfPbsbarCFP/kg= Message-ID: Date: Tue, 5 Dec 2023 18:27:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86/coco, x86/sev: Use cpu_feature_enabled() to detect SEV guest flavor To: Borislav Petkov , "Kirill A. Shutemov" 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 References: <20231205143738.2875-1-kirill.shutemov@linux.intel.com> <20231205144619.GCZW83uzAomKmupn7j@fat_crate.local> <20231205150012.6lma2wzcellr7pz7@box.shutemov.name> <20231205150648.GDZW88iAjBzYoIJ0+o@fat_crate.local> <20231205151437.aqmuydosfmnq3zr4@box.shutemov.name> <20231205160035.GEZW9JI8eKENXBo6EO@fat_crate.local> Content-Language: en-US From: Jeremi Piotrowski In-Reply-To: <20231205160035.GEZW9JI8eKENXBo6EO@fat_crate.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 09:28:04 -0800 (PST) On 05/12/2023 17:00, Borislav Petkov wrote: > On Tue, Dec 05, 2023 at 06:14:37PM +0300, Kirill A. Shutemov wrote: >> My point is that if you need to check for SEV you need to check SEV, not >> CC_ATTR. CC_ATTRs only make sense in generic code that deals with multiple >> CoCo environments. > > That makes more sense. So given this series, what is the canonical way to expose sub-features of TDX/SNP going forward? X86_FEATURE_xxx for every one that needs to be queried in TDX/SNP specific code? I see that in [1] X86_FEATURE_SNP_SECURE_TSC is being proposed. How about the CC_ATTR_TDX_MODULE_CALLS (perhaps better called TDX_TDCALL or something) that I'm proposing in the other thread [2]? VTOM? SVSM? We can also export amd_cc_platform_has() and intel_cc_platform_has() for such cases. But we really need is to agree which to use when (X86_FEATURE vs CC_ATTR). [1]: https://lore.kernel.org/lkml/20231128125959.1810039-10-nikunj@amd.com/ [2]: https://lore.kernel.org/lkml/20231122170106.270266-2-jpiotrowski@linux.microsoft.com/ Jeremi > > So that commit already says "If future support is added for other > memory encryption technologies, the use of CC_ATTR_GUEST_MEM_ENCRYPT > can be updated, as required." > > And what this test needs to do is to check: > > if (guest type >= SEV) > > meaning SEV and -ES and -SNP. > > I'm wondering if we should export amd_cc_platform_has() for such > cases... > > The logic being, we're calling a SEV-specific function so using > cc_platform_has() in there is the wrong layer. > > Tom? >