Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4752649iog; Wed, 22 Jun 2022 05:18:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sWfQ4LOfN7qpcKxtQEEDnBrb5hhm1MlcJH/kj+AsHWiwLJ+CiOV/tsEkcHEjWB3/qbMnbB X-Received: by 2002:a17:907:868b:b0:722:d84f:2c2f with SMTP id qa11-20020a170907868b00b00722d84f2c2fmr2972509ejc.289.1655900315317; Wed, 22 Jun 2022 05:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655900315; cv=none; d=google.com; s=arc-20160816; b=LfR8/xw43V0lixp0MowJzB4xXx0VJLKH3uvtv9+QRv9qiTbb/A1w9ApBaYQD1ljJRH OT9OmqbV+7RSCLSYnUQoiRB1dfCPYSfiz+vky0ud6Hh/WPAiDe0bOz3IuzQDG0kOe7r6 o0Xwmf3NG2OpbE9NAOZ0/kNWY92iB14stPvRjRVbMUNmNZa/zi6Rca/TDFtnpXK7SeHb r0OgIfJYYpTVGNGC6YAZRe3K7jNEP1MhndYl0+hdnxCmW9bQSWWpkVlupPfkFxZv7uOP RjMoI12SkOS+ULr8bONotdG7D5au07xlDntjiLoWsjgvYEFnreD+5arUhgNLdHPCyDeF kJhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=8WTX5K5BXaj2TDhZZlmgXid9tNKs4pj/o6tthvz/low=; b=Hvt2YwS7Da2t29+n1ec1WYiHnodDazCkaSpX6Nf6UJ+K2NXSnwREckZ2aWio5GMAJ3 4gnVK9mPedBVce/UfoP5QH8BMCOVLkG+qd6wsGKoZJqMyrHysAgCJ8YZey7Uj0Zla5Df ZmQdRetms93MmTz48woTHUZAZfgH4rGMfvzVLQO7LIpRN3+UhEn3q1D88Q3XhFOWkjho W46HW1oOTaOyyJua6uUCrsnYxD6bZYi3ZeZRJdneHBjaOddXftaJHLjgD9MdJEQWDbET WysM/lwGxwicIJ4uhe9aASLaAVYh6Rz5kG/PZAdUdmGA6GPpfIY7gQzfqzwSED9GcXTT wefA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d23-20020aa7d5d7000000b0043573321a21si11708166eds.118.2022.06.22.05.18.08; Wed, 22 Jun 2022 05:18:35 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357558AbiFVLpS (ORCPT + 99 others); Wed, 22 Jun 2022 07:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356662AbiFVLpQ (ORCPT ); Wed, 22 Jun 2022 07:45:16 -0400 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C6C2F678; Wed, 22 Jun 2022 04:45:12 -0700 (PDT) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-317741c86fdso158073667b3.2; Wed, 22 Jun 2022 04:45:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8WTX5K5BXaj2TDhZZlmgXid9tNKs4pj/o6tthvz/low=; b=XymGisvmk2hNRg3ICbbGNxV1yO8m5GlNmDZ7gTpUL8RU7jQpkXciak9CbruEiiR3Re BXu0sqowB5ANkoFnqq91WfD7nmDDTytxz0k9PMjFEYEZpwSCKEa0pXd1eDYzmG8pJaoE Xjir3JAupS4v/EU1O7+oUWNmTcsY/+mdVRQiwzMPTzYQ4NRkurkVUO2O6PokZDnCGVJY MymWtQbT0gla99g0+Ayws7kwZkWpWvZTt2ss6dMMt5FkPD5VpSWVfYBGK49jaFLQSOUs os5WerQsg6j9nBojFZQiSRv2xhHFmR7px0Y4YlYDueXvGdVGHwCSaf5LU28cqdwUawnw NwEA== X-Gm-Message-State: AJIora+FecAWgTN5sfQCGYvmku0WEpy1SEfrly8mFRmDJ4NeJ/FSL2lm XOYRlje6IzSfCZQNBtMsAazFBYzX2uNTI3/TfN0= X-Received: by 2002:a81:6c06:0:b0:317:94ff:d1a with SMTP id h6-20020a816c06000000b0031794ff0d1amr3643424ywc.515.1655898311852; Wed, 22 Jun 2022 04:45:11 -0700 (PDT) MIME-Version: 1.0 References: <87dc19c47bad73509359c8e1e3a81d51d1681e4c.1655894131.git.kai.huang@intel.com> In-Reply-To: <87dc19c47bad73509359c8e1e3a81d51d1681e4c.1655894131.git.kai.huang@intel.com> From: "Rafael J. Wysocki" Date: Wed, 22 Jun 2022 13:45:01 +0200 Message-ID: Subject: Re: [PATCH v5 03/22] cc_platform: Add new attribute to prevent ACPI memory hotplug To: Kai Huang Cc: 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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 Wed, Jun 22, 2022 at 1:16 PM Kai Huang wrote: > > Platforms with confidential computing technology may not support ACPI > memory hotplug when such technology is enabled by the BIOS. Examples > include Intel platforms which support Intel Trust Domain Extensions > (TDX). > > If the kernel ever receives ACPI memory hotplug event, it is likely a > BIOS bug. For ACPI memory hot-add, the kernel should speak out this is > a BIOS bug and reject the new memory. For hot-removal, for simplicity > just assume the kernel cannot continue to work normally, and just BUG(). > > Add a new attribute CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED to indicate the > platform doesn't support ACPI memory hotplug, so that kernel can handle > ACPI memory hotplug events for such platform. > > In acpi_memory_device_{add|remove}(), add early check against this > attribute and handle accordingly if it is set. > > Signed-off-by: Kai Huang > --- > drivers/acpi/acpi_memhotplug.c | 23 +++++++++++++++++++++++ > include/linux/cc_platform.h | 10 ++++++++++ > 2 files changed, 33 insertions(+) > > diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c > index 24f662d8bd39..94d6354ea453 100644 > --- a/drivers/acpi/acpi_memhotplug.c > +++ b/drivers/acpi/acpi_memhotplug.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -291,6 +292,17 @@ static int acpi_memory_device_add(struct acpi_device *device, > if (!device) > return -EINVAL; > > + /* > + * If the confidential computing platform doesn't support ACPI > + * memory hotplug, the BIOS should never deliver such event to > + * the kernel. Report ACPI CPU hot-add as a BIOS bug and ignore > + * the memory device. > + */ > + if (cc_platform_has(CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED)) { Same comment as for the acpi_processor driver: this will affect the initialization too and it would be cleaner to reset the .hotplug.enabled flag of the scan handler. > + dev_err(&device->dev, "[BIOS bug]: Platform doesn't support ACPI memory hotplug. New memory device ignored.\n"); > + return -EINVAL; > + } > + > mem_device = kzalloc(sizeof(struct acpi_memory_device), GFP_KERNEL); > if (!mem_device) > return -ENOMEM; > @@ -334,6 +346,17 @@ static void acpi_memory_device_remove(struct acpi_device *device) > if (!device || !acpi_driver_data(device)) > return; > > + /* > + * The confidential computing platform is broken if ACPI memory > + * hot-removal isn't supported but it happened anyway. Assume > + * it is not guaranteed that the kernel can continue to work > + * normally. Just BUG(). > + */ > + if (cc_platform_has(CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED)) { > + dev_err(&device->dev, "Platform doesn't support ACPI memory hotplug. BUG().\n"); > + BUG(); > + } > + > mem_device = acpi_driver_data(device); > acpi_memory_remove_memory(mem_device); > acpi_memory_device_free(mem_device); > diff --git a/include/linux/cc_platform.h b/include/linux/cc_platform.h > index 9ce9256facc8..b831c24bd7f6 100644 > --- a/include/linux/cc_platform.h > +++ b/include/linux/cc_platform.h > @@ -93,6 +93,16 @@ enum cc_attr { > * Examples include TDX platform. > */ > CC_ATTR_ACPI_CPU_HOTPLUG_DISABLED, > + > + /** > + * @CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED: ACPI memory hotplug is > + * not supported. > + * > + * The platform/os does not support ACPI memory hotplug. > + * > + * Examples include TDX platform. > + */ > + CC_ATTR_ACPI_MEMORY_HOTPLUG_DISABLED, > }; > > #ifdef CONFIG_ARCH_HAS_CC_PLATFORM > -- > 2.36.1 >