Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2700367rwl; Mon, 27 Mar 2023 04:12:29 -0700 (PDT) X-Google-Smtp-Source: AKy350aH7zlVJkcvV1qRt6TXRg471Bg2Sb+14w023uCshxksN6vggsTNJmC3LJFlpLAvFL8Cxed0 X-Received: by 2002:a17:907:8c83:b0:939:a610:fc32 with SMTP id td3-20020a1709078c8300b00939a610fc32mr13082401ejc.53.1679915549051; Mon, 27 Mar 2023 04:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679915549; cv=none; d=google.com; s=arc-20160816; b=nMkeXFrfur1egCC4LDHbt8cgFMi6XTiASt77Cp7wGVUJNprF7kRp0jzuDGkkbD3Alw 8J76T3zLRR8QHgqUuZMHMzoH1MeI/sdDshvFUlmyhJmzFZFQbiWJWzY2xfSuBpuz3Abv FwuC9MTLPFZHUQ0O8ps3Z/Kr76+ju9Oo7VKfDs3rjfkIbUqmaefsUCCpfTpxYOcaRuUb wamnN6y9VsEiZR0IsMAH45Hn9ljki/Zv2cMUQ+KQwQPtH8sGlImEfWDuf9N/b2Y0Lv8J y7v8AidX8MqLQ3VKlo3eJ+Gv2YKyJzWEfnp38THjzQJXfLja0pL5Jli4MZe9LJ2d9Hk4 yb9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=zuQVwgWzdxxG6OjMCmHkNo6kbIdD+LHMQN/MYMfDnfI=; b=noE2TAdNdBprUc4v20FmYKx4tlHw3kEqHFecYTeUfHvXHsMKmgCXxM8Ou/R/+h6ibT lfCEDo5kT9obt0GOcLzu9m5mfjbT94G+tDujkXNLaynoymp8f1tCJ/ctYnzWFekWAzJ6 hu1ZDnHUH8WKts3pf27kOfZeaMGjG+saFa528XtDKG9ChMYNP35s4BsyiRM9LgZy3Fkh Ip3VcEAr1n9LZ1rW+JywmLulDRgOO4wwUjoZ+obuFsoXJea78Gu+H1v9NRV/n4cN+Ef/ 07wcoMJEBVQJoWFuF4msPyRn7PddizOcpueh9v1s8Tf7O6liaALBT6Fn5AI1YGvSWLWl 0q+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=Hm8R6xPI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=l1U9RT21; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo9-20020a170906d04900b008b19eb4252csi28297107ejb.511.2023.03.27.04.12.04; Mon, 27 Mar 2023 04:12:29 -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=@shutemov.name header.s=fm3 header.b=Hm8R6xPI; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=l1U9RT21; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232199AbjC0LJm (ORCPT + 99 others); Mon, 27 Mar 2023 07:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbjC0LJl (ORCPT ); Mon, 27 Mar 2023 07:09:41 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A44AA46A6 for ; Mon, 27 Mar 2023 04:09:35 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 164BC5C00D2; Mon, 27 Mar 2023 07:09:35 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 27 Mar 2023 07:09:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1679915375; x= 1680001775; bh=zuQVwgWzdxxG6OjMCmHkNo6kbIdD+LHMQN/MYMfDnfI=; b=H m8R6xPILIfJfAPKhshVfzFX/gsc6lcgoXxfJ1Sshiw7BaNEMKl0UoblsIyECaU3g K/dYOV3LcZEAsCvKyt54Dech9daqJ0oj4nsY8RPxbilJrcz+UBgMB7LWq5cjS8+G ghGnAy8roY4t+PmX87LqbRAm3XUUPbiu1K5BpUjkRQRYd7o1eI/WiYpPJrYBqBrb Z+J751Sx09GjnGgeRELdEGS2k8T11F5jY7dMh/inBFTKjVMqLWEhnNm18pvMTJBA RrIvj5dyVMyQbnxTnoghXhAfZbLVaQi8piAfpJ6UEsMesCGw7gcKMZ+9L6er5NaY 52jv7Y9sN0JPHVg18+GxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1679915375; x=1680001775; bh=zuQVwgWzdxxG6 OjMCmHkNo6kbIdD+LHMQN/MYMfDnfI=; b=l1U9RT21ubrfotWDtweeWbt9jMx/9 InYi7kUThBSBCuVvResq9UiqT6Z6JInNRZuF96huKKqf8xlHqxI7TjSHew/CRNhj Y9SuvYcr1saIFHtQXL3027/iTNuOsrmXBwlRR90LYZxhoBRk1xgTyCAahyp2OimB 3sZp4Ok480/SyqQ45VC7n2aXcY9C9vhQTiryt3SvzzTWDU/HDlPVEdmf9UCZ11fw 1D5G8yEvUgiT/cliZYvtvTZkslTK4iqwV2JnzyhMp57DDsW/HUqa7Xy7U/DDH7Jw /saHZT7Os23LSUodgF57l0KUbKoeGk3Sdf8qjVlwLRtn7aaEG+ZG4KNew== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehvddgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Mar 2023 07:09:34 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 99789109BD6; Mon, 27 Mar 2023 14:09:32 +0300 (+03) Date: Mon, 27 Mar 2023 14:09:32 +0300 From: "Kirill A. Shutemov" To: Baoquan He Cc: Dave Hansen , "Kirill A. Shutemov" , Dave Hansen , Borislav Petkov , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Eric Biederman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86: Disable kexec for TDX guests Message-ID: <20230327110932.z3wjdgfuay5dd2or@box.shutemov.name> References: <20230325160128.21857-1-kirill.shutemov@linux.intel.com> <20230325192524.wetlbycbcsxc4plk@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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, Mar 27, 2023 at 09:35:54AM +0800, Baoquan He wrote: > On 03/26/23 at 10:01am, Dave Hansen wrote: > > On 3/25/23 12:25, Kirill A. Shutemov wrote: > > > On Sat, Mar 25, 2023 at 09:25:36AM -0700, Dave Hansen wrote: > > >> On 3/25/23 09:01, Kirill A. Shutemov wrote: > > >>> The last item is tricky. TDX guests use ACPI MADT MPWK to bring up > > >>> secondary CPUs. The mechanism doesn't allow to put a CPU back offline if > > >>> it has woken up. > > >> ... > > >>> +int arch_kexec_load(void) > > >>> +{ > > >>> + if (cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) { > > >>> + pr_warn_once("Disable kexec: not yet supported in TDX guest\n"); > > >>> + return -EOPNOTSUPP; > > >>> + } > > >>> + > > >>> + return 0; > > >>> +} > > >> > > >> So, let's put all this together: > > >> > > >> 1. TDX implementations use MADT for wakeup exclusively right now (but > > >> are not necessarily _required_ to do so forever) > > >> 2. MADT doesn't support CPU offlining > > >> 3. kexec() requires offlining > > >> > > >> Thus, current TDX implementations can't support TDX guests. This > > >> *doesn't* say that TDX will always use the MADT for wakeups. > > >> > > >> Yet, the check you have here is for TDX and *not* for the MADT. > > > > > > As I described in the commit message there are more than MADT that is > > > required to get kexec in TDX guest. > > > > I kinda think we should do both. > > > > Let's make sure that all systems that depend on MADT wakeups can't > > kexec() until the ACPI folks work out what to do there. > > > > Separately, let's either fix or *mark* the kexec()-incompatible pieces > > that *ARE* specific to TDX. > > > > >> That seems wrong. > > >> > > >> Let's say SEV or arm64 comes along and uses the MADT for their guests. > > >> They'll add another arch_kexec_load(), with a check for *their* feature. > > >> > > >> This all seems like you should be disabling kexec() the moment the MADT > > >> CPU wakeup is used instead of making it based on TDX. > > > > > > I guess we can go this path if you are fine with taking CR4.MCE and shared > > > memory reverting patches (they require some rework, but I can get them > > > into shape quickly). After that we can forbid kexec on machines with MADT > > > if nr_cpus > 1. > > > > This goes back to what I asked before: is anyone actually going to *use* > > a single-processor system that wants to kexec()? If not, let's not > > waste the time to introduce code that is just going to bitrot. Just > > mark it broken and move on with life. > > Now we have two API for kexec: kexec_load and kexec_file_load. They can > be used to do kexec reboot, or crash dumping. For crash dumping, we > usually only use one cpu to do the vmcore dumping. At least on our > Fedora/centos-stream/RHEL, we do like this with kernel parameter > 'nr_cpus=1' added by default. Unless people explicitly remove the > 'nr_cpus=1' restriction or set nr_cpus= to other number to persue > multithread dumping in kdump kernel. Hm. I'm not sure how to determine if the target kernel wants to use >1 CPU. Scanning cmdline looks fragile. And who said the target kernel is Linux. I guess we can park all CPUs, but CPU0 and target kernel will just fail to bring them up which is non-fatal issue (at least for Linux). I admit that all looks hackish. -- Kiryl Shutsemau / Kirill A. Shutemov