Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp694422lqs; Fri, 14 Jun 2024 03:00:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSixc/QF2XIimrB64Nhi8wCs8MQFqjInaitRM919m8E4dPuC/zE+GX6JYCsfXv/1E2HEy8xI7VspdiCDBu1SXScZPuQkISkEMrTDUPdw== X-Google-Smtp-Source: AGHT+IFfDbb1cT49uNdSs/ZKYNPEXGLjz7QdBwV5qkLQchoiufCP9FQET/0hJoAUJgCyRetv9gS6 X-Received: by 2002:a50:8a8b:0:b0:57c:9da5:fc09 with SMTP id 4fb4d7f45d1cf-57cbd6a8266mr1405215a12.23.1718359214787; Fri, 14 Jun 2024 03:00:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718359214; cv=pass; d=google.com; s=arc-20160816; b=VZjDA7m89UQqDxcz/jDpWhOg9TOU2zdaY719+eUAdbGAXkodWvwDo8M4HQE2dVgHvB X42/BnW5OKCGS+unY24GGibQ0UjC2/qezssr7HtUSiqrEHhkt3HgqX9XtN8t6Mr5m4qR FsPnELaps8IABrW0Af085evGquQ8sSeHSgwGdWqEqpEr3r2HQy01+HTyFOlz9QDLCGUr f3Dw1R4nv1Eq/ZOWVkpBKJQCyHbrq013Xi9YTjlVTE+bAQ/iv2LL0PxE8HwqQVtDzxOO Tm7Az77EMdwEEISjShAcRgF3WpxOCf28WAAPiwzU2/3G6uzUD3yJkfDeeJpIbfij6iRh BYkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WWTMyVLxWcqmZk9ZWCbHLYAdS9heaYotdEat33gSms8=; fh=jKzY+IJTxktZ685R93VhJUbGF0rvTl3iTwtLazyIugI=; b=y4QAAG5p1n7qwqCT9KO4O13u6d67Fd1FkfhLlv5fBA1FFJ+NxoSE0qDl6ZDIpabVT+ 7dCwOOyDocL0Z6/haMv5QH4dJT909ddh2tcsz6CWoDaDCUHlMl0ojIaJoimDGSr8upSa YhGjrxSF5AQzwjecTRzkT5T3Z/IGV2BT65T0hJsZjV3Rdj7LhvkQpvtqypemaSmVuCjD LPsk7RZ1N9ozNPnxkr/Ro8IMNJj6mr0PX+EHf+me2NrHu+4kb6yWnG5QI3PHyY9xbEYD ACi5k4mem16pSs0rC0c3f4Xn9uIlfnDPYHQ6i+k7MKUG0t9qimHHv8q/S29G6tsvSTXA HN6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IJ9s11HB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb745fb62si1626815a12.532.2024.06.14.03.00.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 03:00:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IJ9s11HB; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-214705-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214705-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 52B331F27992 for ; Fri, 14 Jun 2024 10:00:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DA1419308A; Fri, 14 Jun 2024 09:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IJ9s11HB" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9F8519149D; Fri, 14 Jun 2024 09:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718359158; cv=none; b=sXmwOG/O+0kaZqWtQK4l25/WyBfTSvA1toGFhaePosg+JLT0A+STG4azpJEbyf/ck35/cAz10i7j0Ad4NCSdibM6aDxspFqhCBNYZVZDC6tLCn/J7xy0oMWbniWE5RbkbsprDa0nBrro6gMyyo/ltMBQ9vAW6ZhMSXVi8jELbgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718359158; c=relaxed/simple; bh=MJUnStgs7sAhex0i0cDRuo1xCulV5yq1EpwC7e9PzHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B7mTVwCzcMVHnpyaokrLIp/smgjTcXIPE5GZQ0uwxC97tazseZJQU2TE3TYQJ9csztbslwxzFq4JHRvnVvXmkEa1eAiy72laEqmvnfda+HgCpHQ80qbnCl49wpg7HUUe1JHrH960z6be1xbV4ARC7U+InBSrf+XUG317r4o0+sI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IJ9s11HB; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718359156; x=1749895156; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MJUnStgs7sAhex0i0cDRuo1xCulV5yq1EpwC7e9PzHA=; b=IJ9s11HBRlWmGEkRtw6O9E/nsXMzE42fBSlHqM9cxJos5o1pIJjvKJbr Zt7taXucY8/o4ZlQaH4aIjzoHpR7vrY6Ghfzl4RttHUeSX44JRDxrfk6x vBRjC7JtjIYnwTo69DTKJqv8q1Rdjk86VNIJgoMrBeh3lruwxzz1ddfRi s6Lv5d7obuG8gLHDx13Ofx0pLXNc04GSGf7QLp9+HmbgwuV3YbIxqPajW /BeIbNk4rQN1qaJmeQC6r3Zi0K4CPTojstNC+mC20plTd7I2zzE/EDuuM RaX6voC87RctDvB6cQdpx9kUZJTvR689oEwSWhlbyiDXUifZjhuMLvgcS g==; X-CSE-ConnectionGUID: NEEE5PPqRwm6gi04ZGgHSQ== X-CSE-MsgGUID: v5fxDrNNSR+x3YS1crYyzw== X-IronPort-AV: E=McAfee;i="6700,10204,11102"; a="12072317" X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="12072317" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2024 02:59:15 -0700 X-CSE-ConnectionGUID: A3N93szQQk2jx95DeddBWw== X-CSE-MsgGUID: MwpewbGNQ52+ME65r03WiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,237,1712646000"; d="scan'208";a="44995802" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa004.fm.intel.com with ESMTP; 14 Jun 2024 02:59:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 9B024277B; Fri, 14 Jun 2024 12:59:08 +0300 (EEST) 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" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "Kirill A. Shutemov" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Tao Liu Subject: [PATCHv12 03/19] cpu/hotplug: Add support for declaring CPU offlining not supported Date: Fri, 14 Jun 2024 12:58:48 +0300 Message-ID: <20240614095904.1345461-4-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240614095904.1345461-1-kirill.shutemov@linux.intel.com> References: <20240614095904.1345461-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_disable_offlining() 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 wakeup method. Signed-off-by: Kirill A. Shutemov Reviewed-by: Thomas Gleixner Tested-by: Tao Liu --- include/linux/cpuhplock.h | 2 ++ kernel/cpu.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/cpuhplock.h b/include/linux/cpuhplock.h index 431560bbd045..f7aa20f62b87 100644 --- a/include/linux/cpuhplock.h +++ b/include/linux/cpuhplock.h @@ -21,6 +21,7 @@ void cpus_read_lock(void); void cpus_read_unlock(void); int cpus_read_trylock(void); void lockdep_assert_cpus_held(void); +void cpu_hotplug_disable_offlining(void); void cpu_hotplug_disable(void); void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); @@ -36,6 +37,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 563877d6c28b..4c15b478e2bc 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -483,6 +483,8 @@ static int cpu_hotplug_disabled; DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock); +static bool cpu_hotplug_offline_disabled __ro_after_init; + void cpus_read_lock(void) { percpu_down_read(&cpu_hotplug_lock); @@ -542,6 +544,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 @@ -1471,7 +1481,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.43.0