Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2224620rwl; Sun, 26 Mar 2023 18:45:02 -0700 (PDT) X-Google-Smtp-Source: AKy350YEz5Pu4Q32/DBMZxheV8m36LqEvSFbv8VtRXaRK8L1gbDORSn1S2RDvN19reiYCQeOKXcY X-Received: by 2002:a17:906:6816:b0:92f:abff:b4cc with SMTP id k22-20020a170906681600b0092fabffb4ccmr10350909ejr.77.1679881502304; Sun, 26 Mar 2023 18:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679881502; cv=none; d=google.com; s=arc-20160816; b=aQfr1Sr0wIYubuI9mu8aMtyyFoy+Gx4m/VRpZOX/svcF8ZnhAh7deLDTtZmL9ACvlX K54pws4+aNdlY4qmS/EIgEXpt9Idcjf8cS22YOLnH1+WKg+/KycfBNugtB1512hmgAGo hwCSAF4V0jzS4QmKxErUWQwlPv34b08f2B+EKuvnsMYrkADBj/ACtsvKe982UxiNl3pH RMRszoDodGbN71NOp9Gw5cjfoSWV/0YLO0xdExScncC8nUm8u6mDazl0sgNqy4e8AE70 NBo2MlfQwzqryJbtmeI80tKO3WUKJ3otfHn9e0SnTGGNeGB8DNYdnjbeGZuIrtXhPOvR 5Q9g== 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:dkim-signature; bh=IktNct0hYpmTWd/fwL1kpmhcQhHYgYPZqfJwKXiT4HI=; b=d8t/X8Nvh8HXoOvUVFu4UIgdzeWNkJ+T29kn2DkHvGUi8PvIK8FBTCK8bRmpDXBtYa 0rsGh3mHIWJsO4gUerT38ntTFUNabt2MgxhWU0FomDQA7yPexP67ePidrT+nuudwHBbO F/pn9RbyPKOp8CyfQzA5IWDIslT+DuWWCOqGfQMVp3v7EpkJZzDsqCZ7UuwhRks1B+Ah 92WW4c3x5UtvBb47hRexFHaMaoJsbHXTw8IjbOTlvPqYW+PTBswgd4NxASiqLmVjl0ir F9EAJ0dTC2nDOxV4Frw5olLIzoxL4foBJZ6wHb2bOiwKQGOlm5D4B843ZTYYh8Sznom9 JaFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YcShOyo7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a170906825100b00934d983a240si18780372ejx.280.2023.03.26.18.44.38; Sun, 26 Mar 2023 18:45:02 -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=@redhat.com header.s=mimecast20190719 header.b=YcShOyo7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229971AbjC0Bgy (ORCPT + 99 others); Sun, 26 Mar 2023 21:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbjC0Bgx (ORCPT ); Sun, 26 Mar 2023 21:36:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EBB94687 for ; Sun, 26 Mar 2023 18:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679880965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IktNct0hYpmTWd/fwL1kpmhcQhHYgYPZqfJwKXiT4HI=; b=YcShOyo73GhqJR0G7rn5i8pvTlxyU7/6PKZltqoYSewCrcrSfmfgU7vzK+EwAvZGQaVYD5 rP7tSlWMLFVKf77GWXF6UXLxj3YCrcXRAW3q0nZ5EsDxq+gYZNHjXXimc688lt7fbZddXu 57eEW+6fUeRC2x0mqhDWRvK5qTzNqRI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-573-ynQ_l6U9NCWBMxerBON6IA-1; Sun, 26 Mar 2023 21:36:01 -0400 X-MC-Unique: ynQ_l6U9NCWBMxerBON6IA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37A291C05149; Mon, 27 Mar 2023 01:36:00 +0000 (UTC) Received: from localhost (ovpn-12-88.pek2.redhat.com [10.72.12.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E5F62166B26; Mon, 27 Mar 2023 01:35:58 +0000 (UTC) Date: Mon, 27 Mar 2023 09:35:54 +0800 From: Baoquan He To: Dave Hansen Cc: "Kirill A. Shutemov" , "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: 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-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 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. So I think Kirill's idea looks good. Means on TDX guest kexec reboot will be forbid, while crash dumping will function normally. Thanks Baoquan