Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4429194pxb; Mon, 21 Feb 2022 21:20:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJybESf7jnt4+pa4Y2GDXa7omSFVDU6M5pJHWV678JPDOXRdR2tHxYlfq7zFhYUvQI0/e1p1 X-Received: by 2002:a05:6a00:2389:b0:4c9:f19c:1e52 with SMTP id f9-20020a056a00238900b004c9f19c1e52mr23388977pfc.35.1645507241820; Mon, 21 Feb 2022 21:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645507241; cv=none; d=google.com; s=arc-20160816; b=RFcSI9IcUMrpHi4bWJ5v0S/eiytUuqj8Uamiq2mGFt4nMlSwVy6lmkynwsqqo0V+nK V+KlaVxMiI3P/LxHYXcEVH5g6ibd6+MuYaWJF7HOGgLkLNWTidq/rxR53/Jm7elzeuzG LeUE/0G5iE8zqPQzhI9RxBZs+c2N00IAwwGYcWM7imCxjIrKrPhi04jUhge0jpyM2xg4 Hxnvyk2W0Eh0Yplmao7oK7NOoI94NOkUQM8NMPWO8PluQkYlVo2/GLmjFzj6Ur19gRQK AH9RyLR5g1askSxxOT0Xiw00GI2vDo2eCzRK55fpaPwzrghEacDaU2UEvWbjbQ48LhsF nvRA== 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=ziuW27yYUNc9AJAsMDe/3C2eMM0Eh56w0WceWniYUEA=; b=SgICvFi0ODqVPibYbXBVHXeXIVMrQ2p1kbn/G94W+CYRcEEWY0Pcwo0fE8XT4XihJa ozshsHrJ2SV8x7sme4enTSJnQN5VfCMDo9i67/06WUOJ0lBal92ih8kpjmV7b5GxypkL sZoUmHUfGL1T8Mdw5sduXYr5o2pVhqqwasFgyI5TphJh9S4PRL2KmNJtfs/4zZDo1Rgu 21E1AgRnNHkNJkicmkIzPMr30uencyXdbzzO3N/azxIhFAYTZEAEyBUupfmA4n10Qyxh C9u4JqEvdXoGDmshL5w5X0CI+cvO9HYawW2f5D/bcBV8kR8U20i98GueMSseOIbq6pe3 0fKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=owbHnX+e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 30si22116956pgz.762.2022.02.21.21.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:20:41 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=owbHnX+e; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27856888EA; Mon, 21 Feb 2022 20:51:57 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355804AbiBULUh (ORCPT + 99 others); Mon, 21 Feb 2022 06:20:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356167AbiBULTi (ORCPT ); Mon, 21 Feb 2022 06:19:38 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD6F13CF1 for ; Mon, 21 Feb 2022 03:07:17 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (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 BED141EC0528; Mon, 21 Feb 2022 12:07:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1645441632; 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=ziuW27yYUNc9AJAsMDe/3C2eMM0Eh56w0WceWniYUEA=; b=owbHnX+e9o6E6pdr17ZxfjAdsBCRDkz5nzPfLu1IV+Q6/FgkGBzC/l1EtmSAuXb6/OqFxE FeIzrfOYiwEpB++IbcvPuUyfz2c0O0q59Gve2toifYktwkm6RAQO/lDk4X6p/IXa2HR1dO wAt60tBOMB0WHhDZtNTydlPIvwtONfA= Date: Mon, 21 Feb 2022 12:07:15 +0100 From: Borislav Petkov To: "Kirill A. Shutemov" Cc: aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, dave.hansen@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, kirill.shutemov@linux.intel.com, knsathya@kernel.org, linux-kernel@vger.kernel.org, luto@kernel.org, mingo@redhat.com, pbonzini@redhat.com, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, sdeep@vmware.com, seanjc@google.com, tglx@linutronix.de, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-hyperv@vger.kernel.org, Brijesh Singh , Tom Lendacky Subject: Re: [PATCHv3.1 2/32] x86/coco: Explicitly declare type of confidential computing platform Message-ID: References: <20220219001305.22883-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220219001305.22883-1-kirill.shutemov@linux.intel.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 19, 2022 at 03:13:04AM +0300, Kirill A. Shutemov wrote: > Kernel derives type of confidential computing platform from sme_me_mask > value and hv_is_isolation_supported(). This detection process will be > more complicated as more platforms get added. > > Declare confidential computing vendor explicitly via cc_init(). > > Signed-off-by: Kirill A. Shutemov > --- > arch/x86/include/asm/coco.h | 16 ++++++++++++++++ > arch/x86/kernel/cc_platform.c | 29 +++++++++++++++++------------ > arch/x86/kernel/cpu/mshyperv.c | 3 +++ > arch/x86/mm/mem_encrypt_identity.c | 8 +++++--- > 4 files changed, 41 insertions(+), 15 deletions(-) > create mode 100644 arch/x86/include/asm/coco.h > > diff --git a/arch/x86/include/asm/coco.h b/arch/x86/include/asm/coco.h > new file mode 100644 > index 000000000000..6e770e0dd683 > --- /dev/null > +++ b/arch/x86/include/asm/coco.h > @@ -0,0 +1,16 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_X86_COCO_H > +#define _ASM_X86_COCO_H > + > +#include > + > +enum cc_vendor { > + CC_VENDOR_NONE, > + CC_VENDOR_AMD, > + CC_VENDOR_HYPERV, > + CC_VENDOR_INTEL, > +}; > + > +void cc_init(enum cc_vendor); > + > +#endif /* _ASM_X86_COCO_H */ > diff --git a/arch/x86/kernel/cc_platform.c b/arch/x86/kernel/cc_platform.c > index 6a6ffcd978f6..891d3074a16e 100644 > --- a/arch/x86/kernel/cc_platform.c > +++ b/arch/x86/kernel/cc_platform.c > @@ -9,18 +9,15 @@ > > #include > #include > -#include > > -#include > +#include > #include > > -static bool __maybe_unused intel_cc_platform_has(enum cc_attr attr) > +static enum cc_vendor cc_vendor; static enum cc_vendor vendor __ro_after_init; > + > +static bool intel_cc_platform_has(enum cc_attr attr) > { > -#ifdef CONFIG_INTEL_TDX_GUEST > - return false; > -#else > return false; > -#endif > } > > /* > @@ -74,12 +71,20 @@ static bool hyperv_cc_platform_has(enum cc_attr attr) > > bool cc_platform_has(enum cc_attr attr) > { > - if (sme_me_mask) > + switch (cc_vendor) { > + case CC_VENDOR_AMD: > return amd_cc_platform_has(attr); > - > - if (hv_is_isolation_supported()) > + case CC_VENDOR_INTEL: > + return intel_cc_platform_has(attr); > + case CC_VENDOR_HYPERV: > return hyperv_cc_platform_has(attr); > - > - return false; > + default: > + return false; > + } > } > EXPORT_SYMBOL_GPL(cc_platform_has); > + > +__init void cc_init(enum cc_vendor vendor) > +{ > + cc_vendor = vendor; > +} > diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c > index 5a99f993e639..d77cf3a31f07 100644 > --- a/arch/x86/kernel/cpu/mshyperv.c > +++ b/arch/x86/kernel/cpu/mshyperv.c > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > > /* Is Linux running as the root partition? */ > bool hv_root_partition; > @@ -344,6 +345,8 @@ static void __init ms_hyperv_init_platform(void) > */ > swiotlb_force = SWIOTLB_FORCE; > #endif > + if (hv_get_isolation_type() != HV_ISOLATION_TYPE_NONE) > + cc_init(CC_VENDOR_HYPERV); Isn't that supposed to test HV_ISOLATION_TYPE_SNP instead? I mean, I have no clue what HV_ISOLATION_TYPE_VBS is. It is not used anywhere in the tree either. a6c76bb08dc7 ("x86/hyperv: Load/save the Isolation Configuration leaf") calls it "'VBS' (software-based isolation)" - whatever that means - so I'm not sure that is going to need the cc-facilities. For stuff like that you need to use get_maintainers.pl and Cc them folks: $ git log -p -1 | ./scripts/get_maintainer.pl | grep -i hyper "K. Y. Srinivasan" (supporter:Hyper-V/Azure CORE AND DRIVERS) Haiyang Zhang (supporter:Hyper-V/Azure CORE AND DRIVERS) Stephen Hemminger (supporter:Hyper-V/Azure CORE AND DRIVERS) Wei Liu (supporter:Hyper-V/Azure CORE AND DRIVERS,commit_signer:1/4=25%) Dexuan Cui (supporter:Hyper-V/Azure CORE AND DRIVERS) linux-hyperv@vger.kernel.org (open list:Hyper-V/Azure CORE AND DRIVERS) /me adds the ML to Cc. > if (hv_max_functions_eax >= HYPERV_CPUID_NESTED_FEATURES) { > diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c > index 3f0abb403340..eb7fbd85b77e 100644 > --- a/arch/x86/mm/mem_encrypt_identity.c > +++ b/arch/x86/mm/mem_encrypt_identity.c > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > > #include "mm_internal.h" > > @@ -565,8 +566,7 @@ void __init sme_enable(struct boot_params *bp) > } else { > /* SEV state cannot be controlled by a command line option */ > sme_me_mask = me_mask; > - physical_mask &= ~sme_me_mask; > - return; > + goto out; > } > > /* > @@ -600,6 +600,8 @@ void __init sme_enable(struct boot_params *bp) > sme_me_mask = 0; > else > sme_me_mask = active_by_default ? me_mask : 0; > - > +out: > physical_mask &= ~sme_me_mask; > + if (sme_me_mask) > + cc_init(CC_VENDOR_AMD); > } I guess. Adding SEV folks to Cc too. Please use get_maintainer.pl - you should know that - you're not some newbie who started doing kernel work two weeks ago. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette