Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3847048pxy; Mon, 26 Apr 2021 11:08:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7QNYXn4v4+SV4JPQ/9Cjf6tx4Gn2175qaz1gWSXe1plQd0ERRCUXOzGGwn4NIfSq9beqc X-Received: by 2002:a05:6402:4388:: with SMTP id o8mr22506779edc.262.1619460485588; Mon, 26 Apr 2021 11:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619460485; cv=none; d=google.com; s=arc-20160816; b=BWycnrgoicdTvbsJ8OH+gx+PZbaiDYcwY31gf+rjzq8/i7e7t3j8K6TNpnUivBhtaG 9CGIzsBulLt1TAWqGJXqVCB94Bi+gK8J3w7PjuGpvPyub5tdNguHgriSGjnd8kDqeUQX Z+RGeTHQfiSE2xi9ts9Q4+AAXR41KimHwmIfqnV0VuZ9vu5H4GCOJVlvxt4Z+BOX8KRX mtc4DVoOkrCbojfZhKoZHNBeozzolOJIo2NQQzcK1aNrBkQRmXt3uxBUzu52aSRDvb3F PClPkrz+fuNo39n6FB1AiTW3JyKKwXMavHi4+T3vdUKzOq2XvEJsRdVcFqIQPpEtI72e bZxA== 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 :ironport-sdr:ironport-sdr; bh=iYuFp4hcFm9VS/DYfkBauVPGaOFcDn9RA3U1HON5MEM=; b=ZoFKRJNe/wOQArU9YMMXdl3FOsJE5zpqcFvS8n5F+CiP5GUp5ZqRlBg4/qxlGj0nST 4NLjHpEU4+Hvt1LDKk/31R8xgWni0bzGCukk8LsxKFNxZlV7CRfRFSOkdllVypY+5eRb uhaLc0sxgY+7E6rgjNKAL9TLTLUnvBkqo6v1JTKFVkyud1IrjgeB1OtAUCrkDgjwkKUE tLefab/pfFYHqbUkd8KkzZkSElIWUDc/6D8JV7mrdecvV9w3OP+vpyGpTLrtajHs/YTX 3eapmyTMua1F678coZYriX2ukaOXhNAhqoRZYiexzG8JXzwwW9HyGjpbceKO0a9XJIGN i0Hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si440169edc.284.2021.04.26.11.07.41; Mon, 26 Apr 2021 11:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235178AbhDZSEr (ORCPT + 99 others); Mon, 26 Apr 2021 14:04:47 -0400 Received: from mga03.intel.com ([134.134.136.65]:51109 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234229AbhDZSDh (ORCPT ); Mon, 26 Apr 2021 14:03:37 -0400 IronPort-SDR: CYJ1pl1JvseSgS+8b0s+pdARu9s2ZbXdMD2GzyB+S/aFeC584C6uGHFzP6XBwwSObx/QvQ9lAm /VHoF7E3J/YA== X-IronPort-AV: E=McAfee;i="6200,9189,9966"; a="196440430" X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="196440430" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 11:02:54 -0700 IronPort-SDR: /d8RFcZ9QatFRQrElpSTNu71bWHEzpbuVEHaBrjvs18AWw2naHZarkJYheSvXCpZr87O0Oynp3 IB35osaCJvKw== X-IronPort-AV: E=Sophos;i="5.82,252,1613462400"; d="scan'208";a="447353431" Received: from ssumanpx-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.254.34.197]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2021 11:02:54 -0700 From: Kuppuswamy Sathyanarayanan To: Peter Zijlstra , Andy Lutomirski , Dave Hansen , Dan Williams , Tony Luck Cc: Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , Sean Christopherson , linux-kernel@vger.kernel.org, Kuppuswamy Sathyanarayanan Subject: [RFC v2 24/32] x86/topology: Disable CPU online/offline control for TDX guest Date: Mon, 26 Apr 2021 11:01:51 -0700 Message-Id: <8c859476363d43b0e5c3fd6ea3f7c250068b24d5.1619458733.git.sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As per Intel TDX Virtual Firmware Design Guide, sec 4.3.5 and sec 9.4, all unused CPUs are put in spinning state by TDVF until OS requests for CPU bring-up via mailbox address passed by ACPI MADT table. Since by default all unused CPUs are always in spinning state, there is no point in supporting dynamic CPU online/offline feature. So current generation of TDVF does not support CPU hotplug feature. It may be supported in next generation. Signed-off-by: Kuppuswamy Sathyanarayanan Reviewed-by: Andi Kleen Reviewed-by: Tony Luck --- arch/x86/kernel/tdx.c | 14 ++++++++++++++ arch/x86/kernel/topology.c | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c index 294dda5bf3f6..ab1efa4d10e9 100644 --- a/arch/x86/kernel/tdx.c +++ b/arch/x86/kernel/tdx.c @@ -316,6 +316,17 @@ static int tdg_handle_mmio(struct pt_regs *regs, struct ve_info *ve) return insn.length; } +static int tdg_cpu_offline_prepare(unsigned int cpu) +{ + /* + * Per Intel TDX Virtual Firmware Design Guide, + * sec 4.3.5 and sec 9.4, Hotplug is not supported + * in TDX platforms. So don't support CPU + * offline feature once its turned on. + */ + return -EOPNOTSUPP; +} + unsigned long tdg_get_ve_info(struct ve_info *ve) { u64 ret; @@ -410,5 +421,8 @@ void __init tdx_early_init(void) pv_ops.irq.safe_halt = tdg_safe_halt; pv_ops.irq.halt = tdg_halt; + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "tdg:cpu_hotplug", + NULL, tdg_cpu_offline_prepare); + pr_info("TDX guest is initialized\n"); } diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index f5477eab5692..d879ea96d79c 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -34,6 +34,7 @@ #include #include #include +#include static DEFINE_PER_CPU(struct x86_cpu, cpu_devices); @@ -130,7 +131,7 @@ int arch_register_cpu(int num) } } } - if (num || cpu0_hotpluggable) + if ((num || cpu0_hotpluggable) && !is_tdx_guest()) per_cpu(cpu_devices, num).cpu.hotpluggable = 1; return register_cpu(&per_cpu(cpu_devices, num).cpu, num); -- 2.25.1