Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2541693rdb; Wed, 15 Nov 2023 04:03:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1yGOBofFhojntOojlNbDNqPXT2Y2Jh/JrQAEaJsE4R0GFUYOWkuo9kuGYQ6iq+lIwmJwZ X-Received: by 2002:a17:902:ea11:b0:1cc:5ce4:f657 with SMTP id s17-20020a170902ea1100b001cc5ce4f657mr7351349plg.29.1700049793533; Wed, 15 Nov 2023 04:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700049793; cv=none; d=google.com; s=arc-20160816; b=M+Nqnmr8jm78152NaGJsTjSaPsaWzYk1m+LCIFFMxtqxyIUR1OaTdbACeDFbYUuQtK ALH9OED4bgPYlxUg2Ctw9+iao9kVfMRS8B57nq8mxGxzDLvN8+nXr/3Xnf//MjqUBq7i 26usqmTa5uvSZe3BLgWNNpIgNeJ2MQKKOBayF/VYcv084YVcQ8nDjzW6yX4OMmkk02cL vYEHXeMKD6cQzBqQ45ZpDFoSj0pv1dd0+xmTbZXqH7SonEvjP3Lo6XuIh5tNiWajEV/K u2iNE+CQTAXmy+J98ta30sBjHHeKRRX6gHr/txKF65wVuMMwuWvvrOi6DYnp57ET57zm NybQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hNIjiUifJYI8rVQx2Hj/DiZva3g/JIIom+qV42hc9K8=; fh=OvJRnOqsMTm9XoNmEwebcqh9Ud7yh1CTeKAP84ols98=; b=FOQQHZcQKcBU0XVMdJ8gTWDEXRa873PXSR+emjCB4AaE4KWS5dl043E4gC9DWtwE4j eQNXdIfhfUcTkGKcKGLfmfwxZLR50dtSpr9LG0YJ7I+aoISWiVzBRiZsyalK07cIoOq4 csMgiePyQKgwgWNi+if8ob2LX0dWCInUm5KoAtwai/KY+d7wwXlo5dDIF6tJ8mzR979/ PbQA2MRT4fARr/XG9qaH0T1H2nOdhM/KnP1ykWseb8FEyK040seX4VyRuCSga69r8PMz hPwzrSECNF1atuxu/DA46awXyMfxBUODfRiEe80x9m0DeS/2BxghKWcdxbOcOeATlwfy SCnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GLHpGEF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z9-20020a655a49000000b005b90af1943asi10303851pgs.807.2023.11.15.04.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 04:03:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GLHpGEF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 0A85280657C9; Wed, 15 Nov 2023 04:01:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343720AbjKOMBg (ORCPT + 99 others); Wed, 15 Nov 2023 07:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343703AbjKOMBY (ORCPT ); Wed, 15 Nov 2023 07:01:24 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B23DCC for ; Wed, 15 Nov 2023 04:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700049681; x=1731585681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rVDdAYq1Ch/guP+3CGD6S7ZzZZb7LGAbyXgUV4HgkN0=; b=GLHpGEF5RniPwMyM5FpUKjmOwWJTXv7rwUSbuAUtIgzWaj8asi+2W7WC CNjgl7Vzku/y98mI9kviDSKTdrkcWP3oKjcAhpeLkzKOSOMXiv/dgZIVl 9EOawzBsIjFLd9WZPXlE/ImcRQUlpq9Z90i210DVvyj4Jzh2x5IYWkYck 0kcw6riVoK+qTuY9aMCI6JHu6czwu89gAJ6lgDie26pGyUoNrbVx6yoxN oJP6J9RbLK5SPqHRnlft9NEidrhJY+6nM5dtRYt+9huESpAXEqXmOl8I1 d6RIfsqMqxmN8LJEpROlcP1ghr7+/m2WOEDjzCSHRO88ClpbOrRgO6qjW g==; X-IronPort-AV: E=McAfee;i="6600,9927,10894"; a="12411897" X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="12411897" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 04:01:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,304,1694761200"; d="scan'208";a="6377679" Received: from mituomis-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.44.135]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 04:01:15 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 5088E10A0F9; Wed, 15 Nov 2023 15:01:12 +0300 (+03) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Baoquan He , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv3 03/14] cpu/hotplug: Add support for declaring CPU offlining not supported Date: Wed, 15 Nov 2023 15:00:33 +0300 Message-ID: <20231115120044.8034-4-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231115120044.8034-1-kirill.shutemov@linux.intel.com> References: <20231115120044.8034-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 04:01:57 -0800 (PST) The ACPI MADT mailbox wakeup method doesn't allow to offline CPU after it got woke up. Currently offlining hotplug is prevented based on the confidential computing attribute which is set for Intel TDX. But TDX is not the only possible user of the wake up method. The MADT wakeup can be implemented outside of a confidential computing environment. Offline support is a property of the wakeup method, not the CoCo implementation. Introduce cpu_hotplug_not_supported() that can be called to indicate that CPU offlining should be disabled. This function is going to replace CC_ATTR_HOTPLUG_DISABLED for ACPI MADT. Signed-off-by: Kirill A. Shutemov --- include/linux/cpu.h | 2 ++ kernel/cpu.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index fc8094419084..46f2e34a0c5e 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -134,6 +134,7 @@ extern void cpus_read_lock(void); extern void cpus_read_unlock(void); extern int cpus_read_trylock(void); extern void lockdep_assert_cpus_held(void); +extern void cpu_hotplug_disable_offlining(void); extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); @@ -149,6 +150,7 @@ static inline void cpus_read_lock(void) { } static inline void cpus_read_unlock(void) { } static inline int cpus_read_trylock(void) { return true; } static inline void lockdep_assert_cpus_held(void) { } +static inline void cpu_hotplug_disable_offlining(void) { } static inline void cpu_hotplug_disable(void) { } static inline void cpu_hotplug_enable(void) { } static inline int remove_cpu(unsigned int cpu) { return -EPERM; } diff --git a/kernel/cpu.c b/kernel/cpu.c index a86972a91991..af8034ccda8e 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -484,6 +484,8 @@ static int cpu_hotplug_disabled; DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock); +static bool cpu_hotplug_offline_disabled; + void cpus_read_lock(void) { percpu_down_read(&cpu_hotplug_lock); @@ -543,6 +545,14 @@ static void lockdep_release_cpus_lock(void) rwsem_release(&cpu_hotplug_lock.dep_map, _THIS_IP_); } +/* Declare CPU offlining not supported */ +void cpu_hotplug_disable_offlining(void) +{ + cpu_maps_update_begin(); + cpu_hotplug_offline_disabled = true; + cpu_maps_update_done(); +} + /* * Wait for currently running CPU hotplug operations to complete (if any) and * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects @@ -1522,7 +1532,8 @@ static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target) * If the platform does not support hotplug, report it explicitly to * differentiate it from a transient offlining failure. */ - if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED)) + if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED) || + cpu_hotplug_offline_disabled) return -EOPNOTSUPP; if (cpu_hotplug_disabled) return -EBUSY; -- 2.41.0