Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3956690rwb; Tue, 8 Nov 2022 10:12:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM7CMKpJa422TrVV7I/xQ1A1nBojOqJj5d2SzBBxQhGTOuuZIACqJoOegezX9/X+f3Jzl6eU X-Received: by 2002:a17:90b:1d90:b0:213:c798:86f6 with SMTP id pf16-20020a17090b1d9000b00213c79886f6mr53462218pjb.84.1667931179036; Tue, 08 Nov 2022 10:12:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667931179; cv=none; d=google.com; s=arc-20160816; b=ldDDgQesh3Mv3Nha3zTsbn7uwp++JjWIIsw5rAcYbKNvR8OJy6MZeJN+BSD7fwktJk EYqphofQbAv/6a4wKjlxhgP3lUjuvHUfTduzLyRWscwmOjWs8Y1FqC2SpUn+eeOXhYdS N8k0xpLeRaZakPIxbOXIUPRUuG2yW+neWtEJ1KvVnlDhO9MoKPi+vMCTxELfFjKnxr2X 3h1Sb326xDTPhmoPUyQEfPNsH/u1NSzRfXmZkN7cT3BCM+7ys3PpgtHtgbOQWAfvZXOg KBLrT1xhdkXPLTU5Wc+CMW69B6S0KVGcNEzn+jRRsIIPKnxeyp5H7w1f/dMpGiNPoYqz KLLQ== 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=cjSjC5m99kmUUHYC704oOlI8KJi6LTudhKVnFW3q+Mo=; b=ehtc7RuwdGzb9QUxcThzTARI0BdoRAiFQzoBo+FEuXrSX8/wg3yAt0iQFfyK3WThWL 7vHSvC07ZG1/p/hQfHKKn755SdnwpK++6NRpyjNVj3tgG6OhrwhfcqV/i8V4AjObA/Io IQsiOAjFbMd0yUlFoyugcAV/Aik/5FK3VA0PUSxFSX/kaGqWu0wGLWJrFZIYzTrzD89N CcwKPps9pu411ZpaqEObL3Ov+6mF5wZNUMU0swRCnHCv1kCvG+O51Z4d6QYc6yTs/cuO iuAaQibSFUGvXNINtFbcm09PAP8aij2pUJiMb+chR+RPEC5NQ0jFBCMJ2JN65Bsx0Lv5 XWuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ftWxPl3+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g12-20020a1709026b4c00b0018862b8c9a2si14133337plt.12.2022.11.08.10.12.46; Tue, 08 Nov 2022 10:12:59 -0800 (PST) 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=@google.com header.s=20210112 header.b=ftWxPl3+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234605AbiKHRqk (ORCPT + 91 others); Tue, 8 Nov 2022 12:46:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234594AbiKHRqh (ORCPT ); Tue, 8 Nov 2022 12:46:37 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D408554FB for ; Tue, 8 Nov 2022 09:46:37 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id l2so14795542pld.13 for ; Tue, 08 Nov 2022 09:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cjSjC5m99kmUUHYC704oOlI8KJi6LTudhKVnFW3q+Mo=; b=ftWxPl3+8IfelsK/irLrvblaLrX6dvTk43ZU1RGb7E7QhEuhpuFGQnZUs1B/6eqA8Y 9uQybJjBJrLcnswih9ZuqdP/IGzw5N1LHsBYZwMjKm4pxbrW1ieLuxCyIbeQvnPHGIX9 KlKI+02Y2PtkvzGrkUCj7EVO4k0DJZDFtOtuUtFMvCioPX+FiFS160StdFwaRhG4AwZY /X/0r60JYMQEe4UtsauftLe+islfrGWTT7n2RWyEhP6x94J5Vb4QTPr7DjEYHP04yepW KF97tjKStfZxjB8uLonmnyGRloE774fNFuZ/STi6vuLRLYYB1EDXjhtfDOqD4TBoTzbU ZVkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cjSjC5m99kmUUHYC704oOlI8KJi6LTudhKVnFW3q+Mo=; b=qvtUhoy4Vszq1gLpUZvE1APBmBRz/p4DsQ98LrqmMhbfUUrpvJI2b3dC1PSwP2cEQg Dxw7OmJYkTv/CWlUeBLlYZblGzz2JJFgdQMLfXQRh8SeShGbgOV3i7+mYwmNcUB9fI4z bxCe/IDlyFQ0jox0aIu6N5vSNXLlBUOmMMdiBnMF74vulxvKbqy9qWAAo0cwiAAMbI84 1u/OpFDWYG2McFWnkiawOPndQdwRnomC9Wq8PQv5d4/OM859ASTMZ9jUJMm3LwclivAt 6ee4sPc6S3+ZR6EacKy2X2UF/zflIgIdsDuFZL4nR5oayYH2Qt4DrhhkOyWLqQ5KSueE Fhyg== X-Gm-Message-State: ACrzQf25P1RvUv50l/QaqVg3r5LkfCItgbhEq8W2m+ThbN18IvZo6fKd yiojvh6xhw5oTP0D5n/MhbeZ8Q== X-Received: by 2002:a17:902:ea04:b0:187:4923:56f4 with SMTP id s4-20020a170902ea0400b00187492356f4mr35142106plg.97.1667929596484; Tue, 08 Nov 2022 09:46:36 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id b9-20020a170902d50900b00185402cfedesm7283578plg.246.2022.11.08.09.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 09:46:35 -0800 (PST) Date: Tue, 8 Nov 2022 17:46:32 +0000 From: Sean Christopherson To: Isaku Yamahata Cc: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Vitaly Kuznetsov , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao Subject: Re: [PATCH 00/44] KVM: Rework kvm_init() and hardware enabling Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221104071749.GC1063309@ls.amr.corp.intel.com> <20221107214634.GE1063309@ls.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221107214634.GE1063309@ls.amr.corp.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Nov 07, 2022, Isaku Yamahata wrote: > On Fri, Nov 04, 2022 at 08:27:14PM +0000, > Sean Christopherson wrote: > > > On Fri, Nov 04, 2022, Isaku Yamahata wrote: > > > Thanks for the patch series. I the rebased TDX KVM patch series and it worked. > > > Since cpu offline needs to be rejected in some cases(To keep at least one cpu > > > on a package), arch hook for cpu offline is needed. > > > > I hate to bring this up because I doubt there's a real use case for SUSPEND with > > TDX, but the CPU offline path isn't just for true offlining of CPUs. When the > > system enters SUSPEND, only the initiating CPU goes through kvm_suspend()+kvm_resume(), > > all responding CPUs go through CPU offline+online. I.e. disallowing all CPUs from > > going "offline" will prevent suspending the system. > > The current TDX KVM implementation disallows CPU package from offline only when > TDs are running. If no TD is running, CPU offline is allowed. So before > SUSPEND, TDs need to be killed via systemd or something. After killing TDs, the > system can enter into SUSPEND state. Ah, I assumed offlining was disallowed if TDX was enabled. > > I don't see anything in the TDX series or the specs that suggests suspend+resume > > is disallowed when TDX is enabled, so blocking that seems just as wrong as > > preventing software from soft-offlining CPUs. > > When it comes to SUSPEND, it means suspend-to-idle, ACPI S1, S3, or S4. > suspend-to-idle doesn't require CPU offline. > > Although CPU related spec doesn't mention about S3, the ACPI spec says > > 7.4.2.2 System _S1 State (Sleeping with Processor Context Maintained) > The processor-complex context is maintained. > > 7.4.2.4 System _S3 State or 7.4.2.5 System _S4 State > The processor-complex context is not maintained. > > It's safe to say the processor context related to TDX is complex, I think. > Let me summarize the situation. What do you think? > > - While no TD running: > No additional limitation on CPU offline. > > - On TD creation: > If any of whole cpu package is software offlined, TD creation fails. > Alternative: forcibly online necessary CPUs, create TD, and offline CPUs The alternative isn't really viable because there's no way the kernel can guarantee a CPU can be onlined, i.e. the kernel would need to fallback of disallowing TD creation anyways. > - TD running: > Although it's not required to keep all CPU packages online, keep CPU package > from offlining for TD destruction. > > - TD destruction: > If any of whole cpu package is software offlined, TD destruction fails. > The current implementation prevents any cpu package from offlinining during > TD running. > Alternative: > - forcibly online necessary CPUs, destruct TD, and offline CPUs again and > allow CPU package to offline > - Stash TDX resources somewhere. When cpu packages are onlined, free those > release. > > - On SUSPEND: > TODO: Allow CPU offline if S1 is requested. Is this actually a TODO? I assume the kernel doesn't actually try to offline CPUs in this case, i.e. it Just Works. > - suspend-to-idle: nothing to do because cpu offline isn't required > - ACPI S1: Need to allow offline CPUs. This can be implemented by referencing > suspend_state_t pm_suspend_target_state is PM_SUSPEND_TO_STANBY. > - ACPI S3/S4: refuse cpu offline. The system needs to kill all TDs before > starting SUSPEND process. This is what is implemented. Looks good, disallowing SUSPEND with active TDs is a reasonable tradeoff. As above, I highly doubt anyone actually cares.