Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp869430rwl; Sat, 25 Mar 2023 12:36:55 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/1kMpF5fiqMc1gcIrkUD1LZOYUTF/7Mo1ROzZPHhV4h3kWBP2CwUFzDUVUzYeqfFRaGfH X-Received: by 2002:a17:906:6d09:b0:934:2fe4:4921 with SMTP id m9-20020a1709066d0900b009342fe44921mr6773753ejr.19.1679773014811; Sat, 25 Mar 2023 12:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679773014; cv=none; d=google.com; s=arc-20160816; b=eXfqOK+EiaBsUf2IXMISbGqih3c/iPy+GcWSpMubXc7DoUHyvYIKpeHfPH5ShR4B0F 5raVNd4qwXOx+xUcWkA32hPXATdKIrU8aMZHRSblVkJT8yJ+bWxGCFOqr/WwIexbyAUD Zf6Vv8zVMONVa7PH3GtD2IllRKpuLjsPM4OVLFidAQj1Rhjx5DeBVUd/qPlne6CyIOnj cKH49Ae+FwtV477Lv4pDaJBtqhLGQEK6wuWDdj9dzwC/m20rszJc7hnWgb7abcn6ay5O NMmJ0Gx2O6y7tGvZNBsxKfZ7Smr+qcfmUzfFUfIBgd4+Tgu8dWQbgY4NIF3zJd0EBQGN RbFg== 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=F20hN5cmoUb7ZMiQCIUcAf557ZHjOrjpfezAUz/+nzY=; b=q+rTD6MVkHJbWmXbMByoS9Af9mbIh6YUroR4b3q96I3GHQAxnomQNZdwWNtgeoIowS 8FxkDW5w4QR8PjEtEFS+FS1ZY5w0zGbULZ591zp8CITJJYIZr1l9OJKJlypjTiXyKPSi oMVV7NEYE840y0rIf7unGi5ZRLZcEdirDLoeW8H8vyEN/cuEgyD63VqVRrG34fumU1eb PQPXn4kFHYEg/WoubOcBqSv4JdyoDNB0s/g8FT25r809JXQ1IT/zi+pG1PZ8lnubYhWJ si57+bQQ5u+uTE+T+puFwqx0NWkfNCGcEiiOlOXqfZxFE/rv1iQUeVHzymL3cEkWkQ8U Lyvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm3 header.b=CGmc+c3g; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=EeoXI1Yz; 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 xd3-20020a170907078300b0093397c2c553si21574578ejb.289.2023.03.25.12.36.29; Sat, 25 Mar 2023 12:36:54 -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=CGmc+c3g; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=EeoXI1Yz; 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 S231196AbjCYTZe (ORCPT + 99 others); Sat, 25 Mar 2023 15:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjCYTZc (ORCPT ); Sat, 25 Mar 2023 15:25:32 -0400 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B715430C0 for ; Sat, 25 Mar 2023 12:25:31 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 401EC5C0054; Sat, 25 Mar 2023 15:25:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 25 Mar 2023 15:25:29 -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=1679772329; x= 1679858729; bh=F20hN5cmoUb7ZMiQCIUcAf557ZHjOrjpfezAUz/+nzY=; b=C Gmc+c3g2DEkoY4krwTCYYXVNEm+SGdPUafJ/YisY5tj9vOW/nG8lJeb8ujJmXhgt WaFn1p3ENyvGzc7a+Agl7amh4dxpKoh9fXmL9QgMxiwL0XdWlGh1PHZnInZVzYrV k7h6ZuY9q8KVdN+0aZUbUSGs7JacG1oqxuUDpoDaUcY5YmBovRT4GrWeaW+k3KJN Kys82rcorrTbJb4KWv2elly7uN4w/JQzuycfp3H4YfWJeBQnq63qXtVZbvNgAYmk mx16ervjNfDHp0Kv/Jzsyrm5WAEjPwd8iezXDVVbswidLnooTW2NiNa3QM0pg0cW q/ylnuCpIXoc0b2znYjRA== 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=1679772329; x=1679858729; bh=F20hN5cmoUb7Z MiQCIUcAf557ZHjOrjpfezAUz/+nzY=; b=EeoXI1YzVWVTVkWRPBhlqMVKiYj1m OEO7NioGTasn/v6KcdceRJfqBWBs8iSQTYgCxKTfYDDn4FHh+HsENI/nqSBc0aqA kNMYWigMUqg//mXOHhOY4QcHMCbg36mNpw9yQFHRz696PZP5pTqqkFxg1JwCindz ohCO+8650NTj22LgHZCujr1+NT5Ua/HQPw/TpBVCtqQuwvEkP8O3W0nvNhLOb+Ib d8UVHgMLiq9wbAJ+pSiu8YdF9m3Mib9uyIioFqB+LDjHLiWzdUwoxto0MtP+jp1A Y0sZouOYrXSFNITmxhVdlQVeydyU0w9lN+8BnH0fQn7OhQxWLhCwVQD6w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdegkedguddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpedfmfhi rhhilhhlucetrdcuufhhuhhtvghmohhvfdcuoehkihhrihhllhesshhhuhhtvghmohhvrd hnrghmvgeqnecuggftrfgrthhtvghrnhepkedvvdejffehteegtddvgfeijeeivdegjeei teejheeiheevffeukeefheffvdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhirhhilhhlsehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 25 Mar 2023 15:25:27 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 3965210A607; Sat, 25 Mar 2023 22:25:24 +0300 (+03) Date: Sat, 25 Mar 2023 22:25:24 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: "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: <20230325192524.wetlbycbcsxc4plk@box> References: <20230325160128.21857-1-kirill.shutemov@linux.intel.com> 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_H2, 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 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. > 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. Sounds good? -- Kiryl Shutsemau / Kirill A. Shutemov