Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3830512iog; Tue, 28 Jun 2022 03:47:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sMAo8L62vn3tMAWTxxT4EZ4AYO7ue60f5IJXqGmX5+wkhqQn4eSd5OLo7T/WNdjAwlJVnl X-Received: by 2002:a05:6402:3685:b0:435:8069:e44 with SMTP id ej5-20020a056402368500b0043580690e44mr22380665edb.202.1656413248502; Tue, 28 Jun 2022 03:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656413248; cv=none; d=google.com; s=arc-20160816; b=L7piyX2iuRhpopYJUTePWj76g/Q1FS/veAFjFFor4lg+zTReiOelUgQPEnEVXa96z1 rD4yd/ygn6SevH4juqgUU/kQDAiIX5xVSz6YnmWGEWGFhMyhAhIx499Pzsp7jCFaJFM8 EIpOtgSbWXPM4u4nIXXG3sD2iV+9uoSqKbSX++OXJ0klse4d8hsfRTY5y015E0YzvNWm pn/zlsSkJzMA4GMQ8AG3tcFxMqe4XuAsYOdDqFajRWAOXE1l7+7FjAWWs7bKvEKK9ojE JdcgtZm0Z7RUS1NhPTu8ZfypvGU7B8frq/HsxzWSPOgLyghmvPHMEvekTFSt60GGwbUY 6okw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=pu45Sau/od8P643LaW2aVsLPQiLDPoCeLK06b84Wvco=; b=ecgdTMtLkljk0wZbWRlT/T8LgB6yPwQLyi67qoHkY7pV+OTu/YJYRfH+WlmwxlMgd+ pFQXFtw2kjzr15Zo7CzjzX2C/n2POwdYOM+ihikxE8xvP9/EhANXKfPpOFs7AY0SYdrc Ezzpseq51jS3q/Hfgw1v91z9mDMKO3qd3CAsI+c8Wbosifn6IKxHSdLrR03mmSS4dj25 MFiOsdKG1vJUmaVoM9k7BPizHLF08PqN8eUnh9Q1Xs5V/1pby99WrAQ5za07H1v094MD RYMNpAIkhjALeYnTCxGT+HvjnV7yNn/VJ0uPW47N99qtSe82rqS1j2C7ZLxNEOK8W+tm aSCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GkEH+FWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a056402274400b0042b5724a3bcsi20570097edd.21.2022.06.28.03.46.59; Tue, 28 Jun 2022 03:47:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GkEH+FWb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344516AbiF1KEz (ORCPT + 99 others); Tue, 28 Jun 2022 06:04:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344169AbiF1KEx (ORCPT ); Tue, 28 Jun 2022 06:04:53 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2B22D1C9; Tue, 28 Jun 2022 03:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656410692; x=1687946692; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=V8xmQPHT1mCLQeDpG45Uq0txHRzx1XRmzSSIhRmQbPE=; b=GkEH+FWbUO+5DRLixED9hMGJit7an5JnpC03J0SDxipRWxYCAQel6D1v f1Ijs3R9g/NwuezbYLQ3vK1pFqqucR6qDp0gPZuCGCL/F18mR5qcTY20I 7uSPZdcr4xBOojFR7cQsUYMgZ59pgBCAmWrdWaEZ2cIMmBqnq3BNOizO2 OYQOLuXgHuasHg5qmahzEpz+ZyLumVSy6fIC0PB03gzXyYJQxjfHlyrt/ k6eyZwo2NiBX1aWKnsDDDWrVo5gKTdzZhoyLyBRzgpOxN26AD93IzZbI+ qQcYuDOhP+XP2glq6Z7kL9pg09aGyXMrYwTP1tSaKEQMRXS3nZ0bmtwT+ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="345695538" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="345695538" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 03:04:51 -0700 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="617134907" Received: from nherzalx-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.212.96.221]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 03:04:45 -0700 Message-ID: <2b676b19db423b995a21c7f215ed117c345c60d9.camel@intel.com> Subject: Re: [PATCH v5 02/22] cc_platform: Add new attribute to prevent ACPI CPU hotplug From: Kai Huang To: Igor Mammedov Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , kvm-devel , ACPI Devel Maling List , Sean Christopherson , Paolo Bonzini , Dave Hansen , Len Brown , Tony Luck , Rafael Wysocki , Reinette Chatre , Dan Williams , Peter Zijlstra , Andi Kleen , "Kirill A. Shutemov" , Kuppuswamy Sathyanarayanan , isaku.yamahata@intel.com, Tom Lendacky , Tianyu.Lan@microsoft.com, Randy Dunlap , "Jason A. Donenfeld" , Juri Lelli , Mark Rutland , Frederic Weisbecker , Yue Haibing , dongli.zhang@oracle.com Date: Tue, 28 Jun 2022 22:04:43 +1200 In-Reply-To: <20220627100155.71a7b34c@redhat.com> References: <20220627100155.71a7b34c@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, 2022-06-27 at 10:01 +0200, Igor Mammedov wrote: > On Thu, 23 Jun 2022 12:01:48 +1200 > Kai Huang wrote: >=20 > > On Wed, 2022-06-22 at 13:42 +0200, Rafael J. Wysocki wrote: > > > On Wed, Jun 22, 2022 at 1:16 PM Kai Huang wrote= : =20 > > > >=20 > > > > Platforms with confidential computing technology may not support AC= PI > > > > CPU hotplug when such technology is enabled by the BIOS. Examples > > > > include Intel platforms which support Intel Trust Domain Extensions > > > > (TDX). > > > >=20 > > > > If the kernel ever receives ACPI CPU hotplug event, it is likely a = BIOS > > > > bug. For ACPI CPU hot-add, the kernel should speak out this is a B= IOS > > > > bug and reject the new CPU. For hot-removal, for simplicity just a= ssume > > > > the kernel cannot continue to work normally, and BUG(). > > > >=20 > > > > Add a new attribute CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED to indicate t= he > > > > platform doesn't support ACPI CPU hotplug, so that kernel can handl= e > > > > ACPI CPU hotplug events for such platform. The existing attribute > > > > CC_ATTR_HOTPLUG_DISABLED is for software CPU hotplug thus doesn't f= it. > > > >=20 > > > > In acpi_processor_{add|remove}(), add early check against this attr= ibute > > > > and handle accordingly if it is set. > > > >=20 > > > > Also take this chance to rename existing CC_ATTR_HOTPLUG_DISABLED t= o > > > > CC_ATTR_CPU_HOTPLUG_DISABLED as it is for software CPU hotplug. > > > >=20 > > > > Signed-off-by: Kai Huang > > > > --- > > > > arch/x86/coco/core.c | 2 +- > > > > drivers/acpi/acpi_processor.c | 23 +++++++++++++++++++++++ > > > > include/linux/cc_platform.h | 15 +++++++++++++-- > > > > kernel/cpu.c | 2 +- > > > > 4 files changed, 38 insertions(+), 4 deletions(-) > > > >=20 > > > > diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c > > > > index 4320fadae716..1bde1af75296 100644 > > > > --- a/arch/x86/coco/core.c > > > > +++ b/arch/x86/coco/core.c > > > > @@ -20,7 +20,7 @@ static bool intel_cc_platform_has(enum cc_attr at= tr) > > > > { > > > > switch (attr) { > > > > case CC_ATTR_GUEST_UNROLL_STRING_IO: > > > > - case CC_ATTR_HOTPLUG_DISABLED: > > > > + case CC_ATTR_CPU_HOTPLUG_DISABLED: > > > > case CC_ATTR_GUEST_MEM_ENCRYPT: > > > > case CC_ATTR_MEM_ENCRYPT: > > > > return true; > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_proc= essor.c > > > > index 6737b1cbf6d6..b960db864cd4 100644 > > > > --- a/drivers/acpi/acpi_processor.c > > > > +++ b/drivers/acpi/acpi_processor.c > > > > @@ -15,6 +15,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > >=20 > > > > #include > > > >=20 > > > > @@ -357,6 +358,17 @@ static int acpi_processor_add(struct acpi_devi= ce *device, > > > > struct device *dev; > > > > int result =3D 0; > > > >=20 > > > > + /* > > > > + * If the confidential computing platform doesn't support A= CPI > > > > + * memory hotplug, the BIOS should never deliver such event= to > > > > + * the kernel. Report ACPI CPU hot-add as a BIOS bug and i= gnore > > > > + * the new CPU. > > > > + */ > > > > + if (cc_platform_has(CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED)) { = =20 > > >=20 > > > This will affect initialization, not just hotplug AFAICS. > > >=20 > > > You should reset the .hotplug.enabled flag in processor_handler to > > > false instead. =20 > >=20 > > Hi Rafael, > >=20 > > Thanks for the review. By "affect initialization" did you mean this > > acpi_processor_add() is also called during kernel boot when any logical= cpu is > > brought up? Or do you mean ACPI CPU hotplug can also happen during ker= nel boot > > (after acpi_processor_init())? > >=20 > > I see acpi_processor_init() calls acpi_processor_check_duplicates() whi= ch calls > > acpi_evaluate_object() but I don't know details of ACPI so I don't know= whether > > this would trigger acpi_processor_add(). > >=20 > > One thing is TDX doesn't support ACPI CPU hotplug is an architectural t= hing, so > > it is illegal even if it happens during kernel boot. Dave's idea is th= e kernel > > should speak out loudly if physical CPU hotplug indeed happened on (BI= OS) TDX- > > enabled platforms. Otherwise perhaps we can just give up initializing = the ACPI > > CPU hotplug in acpi_processor_init(), something like below? >=20 > The thing is that by the time ACPI machinery kicks in, physical hotplug > has already happened and in case of (kvm+qemu+ovmf hypervisor combo) > firmware has already handled it somehow and handed it over to ACPI. > If you say it's architectural thing then cpu hotplug is platform/firmware > bug and should be disabled there instead of working around it in the kern= el. >=20 > Perhaps instead of 'preventing' hotplug, complain/panic and be done with = it. Hi Igor, Thanks for feedback. Yes the current implementation actually reports CPU h= ot- add as BIOS bug. I think I can report BIOS bug for hot-removal too. And currently I actually used BUG() for the hot-removal case. For hot-add I di= dn't use BUG() but rejected the new CPU as the latter is more conservative.=20 Hi Rafael, I am not sure I got what you mean by "This will affect initialization, not = just hotplug AFAICS", could you elaborate a little bit? Thanks. --=20 Thanks, -Kai