Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2125079iob; Thu, 5 May 2022 16:35:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYabGcTiw8CCufEP8V1W2Ysg+3JIPIXd4U76ZalJbIVxSQFH3KGIFozoGMMFIEkykCopJd X-Received: by 2002:a17:90b:11d1:b0:1db:d99f:62cc with SMTP id gv17-20020a17090b11d100b001dbd99f62ccmr845250pjb.200.1651793740007; Thu, 05 May 2022 16:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651793739; cv=none; d=google.com; s=arc-20160816; b=LpBkXCrBqgMXKko8C8amJ5oAmltHtGPafjy/ViLtA/wqfTtpCjAWcQEZnCQCUsxhqW WhOe9bbHuUDh2hdDwHFyUX1kAH9YHZhgXiivpemKol7n+LAA7ocLoQ6hWPX5I6Gnp4h5 VNlVPO6r6F+Qf5KCq0z+mc2v2KeKtOPMGyNcV8bCZVfVwo7t007hob4Cekce/az4MrYn 8x7wnp8mTBH4Oen0JsL8sVduNW2A83bGm9lb6CD+LghexMfDg/j1dgv/8AqgEar6TCbJ J/wIIwCtj4zp9wyUAV7fk1Qj6g5aYQxb2OBzCVBzNj6TFWnLoE8YVnZj+ZvE61AhxRpE slHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9iUGkhKiiAT2T4Pc3rEXAuHxa9x6mx+IUETLy182GSI=; b=hszxX5dBm07FWc0mSKP86C6YuQfLum+5LdCRgKiwF4HMbg8BmW40jy38+kEs9N5oQl jJ6s/aQBK57KswkSjfmBkNpNSZR6sIQl7KlzA1PZh6Hq8R58BWSaax+vKH2rpD/bbXhl CFguDorKKWW3LP/bpjPzCwEQR1c5Osj1pZC5xvWDAupfh7uOkbn1NRtUSrZ0q7FY1HHU tcaYXtMou18qbzfuQeBtpup1zcZVQoUPQDXtRCSziXqrQHNF+E0yi6Z4Xp/rm7s0JV2s +s3ChlEKL1D1zVskWP1dtjY2/8aQQ0Mcj2gXvC62Il674V12VLjz3PHkyjix200lMEOe YzmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=FbxnqeiT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l26-20020a63701a000000b003993007c4basi2966284pgc.626.2022.05.05.16.35.25; Thu, 05 May 2022 16:35:39 -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=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=FbxnqeiT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351339AbiEDOfC (ORCPT + 99 others); Wed, 4 May 2022 10:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351313AbiEDOfB (ORCPT ); Wed, 4 May 2022 10:35:01 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBDC19291 for ; Wed, 4 May 2022 07:31:25 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id j6so1256646pfe.13 for ; Wed, 04 May 2022 07:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9iUGkhKiiAT2T4Pc3rEXAuHxa9x6mx+IUETLy182GSI=; b=FbxnqeiT9svwA2BU90ix2G4zW8IBbMDfv4x2lDk4YzSK38lXtu1MRv6PtcttUZ/08+ YZz6u+it2BCSK4ZNcwGWhYjrJwkq4Rs9FJlqKMxjV3iZYNUdFKYq/rp4SOJX3DHAIqZJ +ke29wZw6f4MvRPg4UuSOi7Nl79L9SjphOdiTMY+pEQkg0PChlsuKwGlGr086wO+LMX5 MC9LEVK66YfZw00e97YnfL4ONz2UnESwqME3QPR8BZfxwvq2aFj0CK3wv8dyf+nybt+1 lpmQg40MoWatBcyaPwNbmF2bd0yZZpxy4uISSnC4cCUC7xDqEwjYJs9xdljVgbp4AvhB YlTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9iUGkhKiiAT2T4Pc3rEXAuHxa9x6mx+IUETLy182GSI=; b=XJCWWSPyWliKhyCVjmI51hDjknTVQnG8366yHH5dKnTdRFZaCL87w79oC1UnMiUeqh +HgdVzxd+leygIofyuL01neJ3OxkWT57H+f4wjroOf57u4Bvp4vSW693l10qKgvqsRt4 EtPTecQJUwW1iSYV5Xt/IGLNmT7Agqbf1s87dQMQSujqDwz21zII/EMCTsP1R1ELrZuv H+YCE+k8hbyutyFI7KZ1X4ChLW/qStr3lB2kwx25+Wd+0ZEV1XYvSjtwRRfslM9N8l5a wQZJ3nVgfeC6SAbLSwtAvFFheK0bPXtCFA7YqpjLgwlAsKwDa1hLovCPyfTRmu3ljREN xdQQ== X-Gm-Message-State: AOAM531Mp8NT+kU81Q6SwBnHsj8TSGgezSgku7V8nhTGDV48l1ecVSKd wltYnoQg+PYzZc5Cp0yNUAxn5s8VG5WiJdycv/1E/g== X-Received: by 2002:a05:6a02:283:b0:342:703e:1434 with SMTP id bk3-20020a056a02028300b00342703e1434mr17693010pgb.74.1651674684552; Wed, 04 May 2022 07:31:24 -0700 (PDT) MIME-Version: 1.0 References: <522e37eb-68fc-35db-44d5-479d0088e43f@intel.com> <9b388f54f13b34fe684ef77603fc878952e48f87.camel@intel.com> <664f8adeb56ba61774f3c845041f016c54e0f96e.camel@intel.com> In-Reply-To: <664f8adeb56ba61774f3c845041f016c54e0f96e.camel@intel.com> From: Dan Williams Date: Wed, 4 May 2022 07:31:13 -0700 Message-ID: Subject: Re: [PATCH v3 00/21] TDX host kernel support To: Kai Huang Cc: Dave Hansen , Linux Kernel Mailing List , KVM list , Sean Christopherson , Paolo Bonzini , "Brown, Len" , "Luck, Tony" , Rafael J Wysocki , Reinette Chatre , Peter Zijlstra , Andi Kleen , "Kirill A. Shutemov" , Kuppuswamy Sathyanarayanan , Isaku Yamahata Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, May 3, 2022 at 4:59 PM Kai Huang wrote: > > On Fri, 2022-04-29 at 13:40 +1200, Kai Huang wrote: > > On Thu, 2022-04-28 at 12:58 +1200, Kai Huang wrote: > > > On Wed, 2022-04-27 at 17:50 -0700, Dave Hansen wrote: > > > > On 4/27/22 17:37, Kai Huang wrote: > > > > > On Wed, 2022-04-27 at 14:59 -0700, Dave Hansen wrote: > > > > > > In 5 years, if someone takes this code and runs it on Intel hardware > > > > > > with memory hotplug, CPU hotplug, NVDIMMs *AND* TDX support, what happens? > > > > > > > > > > I thought we could document this in the documentation saying that this code can > > > > > only work on TDX machines that don't have above capabilities (SPR for now). We > > > > > can change the code and the documentation when we add the support of those > > > > > features in the future, and update the documentation. > > > > > > > > > > If 5 years later someone takes this code, he/she should take a look at the > > > > > documentation and figure out that he/she should choose a newer kernel if the > > > > > machine support those features. > > > > > > > > > > I'll think about design solutions if above doesn't look good for you. > > > > > > > > No, it doesn't look good to me. > > > > > > > > You can't just say: > > > > > > > > /* > > > > * This code will eat puppies if used on systems with hotplug. > > > > */ > > > > > > > > and merrily await the puppy bloodbath. > > > > > > > > If it's not compatible, then you have to *MAKE* it not compatible in a > > > > safe, controlled way. > > > > > > > > > > You can't just ignore the problems because they're not present on one > > > > > > version of the hardware. > > > > > > > > Please, please read this again ^^ > > > > > > OK. I'll think about solutions and come back later. > > > > > > > > Hi Dave, > > > > I think we have two approaches to handle memory hotplug interaction with the TDX > > module initialization. > > > > The first approach is simple. We just block memory from being added as system > > RAM managed by page allocator when the platform supports TDX [1]. It seems we > > can add some arch-specific-check to __add_memory_resource() and reject the new > > memory resource if platform supports TDX. __add_memory_resource() is called by > > both __add_memory() and add_memory_driver_managed() so it prevents from adding > > NVDIMM as system RAM and normal ACPI memory hotplug [2]. > > Hi Dave, > > Try to close how to handle memory hotplug. Any comments to below? > > For the first approach, I forgot to think about memory hot-remove case. If we > just reject adding new memory resource when TDX is capable on the platform, then > if the memory is hot-removed, we won't be able to add it back. My thinking is > we still want to support memory online/offline because it is purely in software > but has nothing to do with TDX. But if one memory resource can be put to > offline, it seems we don't have any way to prevent it from being removed. > > So if we do above, on the future platforms when memory hotplug can co-exist with > TDX, ACPI hot-add and kmem-hot-add memory will be prevented. However if some > memory is hot-removed, it won't be able to be added back (even it is included in > CMR, or TDMRs after TDX module is initialized). > > Is this behavior acceptable? Or perhaps I have misunderstanding? Memory online at boot uses similar kernel paths as memory-online at run time, so it sounds like your question is confusing physical vs logical remove. Consider the case of logical offline then re-online where the proposed TDX sanity check blocks the memory online, but then a new kernel is kexec'd and that kernel again trusts the memory as TD convertible again just because it onlines the memory in the boot path. For physical memory remove it seems up to the platform to block that if it conflicts with TDX, not for the kernel to add extra assumptions that logical offline / online is incompatible with TDX.