Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6318158rwb; Tue, 22 Nov 2022 11:34:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DVR2RJsbI5ATx64yxR8EDpZ09PjcZYHfrWOfXwV7wPGVsNY9AQ1pvofjHqrVfowzg9zuT X-Received: by 2002:a05:6402:5299:b0:461:7291:79c1 with SMTP id en25-20020a056402529900b00461729179c1mr12861910edb.68.1669145698206; Tue, 22 Nov 2022 11:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669145698; cv=none; d=google.com; s=arc-20160816; b=1IaIv+vtM5o/l+8RrbXj+lvm/Np81/+7itaaNVNcNMn38uIj683AYD8Wy+dJDgS0HO cR0v4DJ+Z3F3UfpWwd7JRORKrvG4B2y2I9Wx5CuFYGyeTvwF9M/ZewFnonPyXRpe/pth aONuVGuHu0830gNDdcLD/ZcPJ8oAz9OLW6mrfZQ8fr8BnDG9wgydCxjOjxEMt0So1xW6 bGvSyspa3DeQYx3Jdti0isybe7UfedwbABr9qsu2OSRLXBuzYu+bkPZilYzHaWGkP4AL JBAJ1gD7KxAH568uCZ9NlAua9hd3+/+jUeLdznLBzuuhD51/OW0KZDk7b1aJhoW/I+1y Dghg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=TQ2oYOCkAVOLLBk0Jc0TMRAsnF9lAP6pDmS4odvrolk=; b=T7NuMi1SMgCRW22DHhIDI03pDoUZ9bzfL0mOWD1xTC2eTRA62XGqT5uXI8acXVWLp4 6CDlP/82wr1edTrQPCwDDZGbZNR3seyL95QhRmJStWHBcUJpsrf81kMixQGfrBBaf43f mwmX34gRYpmGaiUxN6NbyOaSjWlNY43K936cukX2C7/+1gpFeA9C24jhqRdL1IJyFiK8 kNcUNvJ4cUTp9KRkGtv2J5H3A8kcgRazEWOH5ObVEURGCPGFF7K38v5DbzvjturGCFjz rrMNF3MtMOcCUvMP1ohgX5++r1yhivrscBTw8nS5WhKtlgJkSZL1Aa2lMnS0mMjmhA0A 0rcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UKpm2Bq0; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u1-20020a1709064ac100b0078d62ae01c1si10420731ejt.536.2022.11.22.11.34.34; Tue, 22 Nov 2022 11:34:58 -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=@intel.com header.s=Intel header.b=UKpm2Bq0; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbiKVTY6 (ORCPT + 90 others); Tue, 22 Nov 2022 14:24:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234426AbiKVTYz (ORCPT ); Tue, 22 Nov 2022 14:24:55 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A88E7FF21; Tue, 22 Nov 2022 11:24:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669145094; x=1700681094; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=OKm7UJo5SyFqT5YmYkDdQ5nt3mpnIZkSEfunTTVs3qE=; b=UKpm2Bq0PtKiHN2VGC8sSV3IwF8v5Qmu+080Zfb9h3+clw2zNJ1aT6ff rP0oNdIPDKJSGJfoVrAKypuZN63BkyIy9fgETxz1lJaYEOyWsNFLt+pO9 X+K6/D9TfduQF82hOVxNfw1NiwruJi/xfAa0aQGlwH4bdeUX9VjHtzqMn 2lKzqjmhPRjsOI925lwY3r7v6DdAKRaeadNbSQg/F9irQvXfSjb9gujHT l12bfP8vGsK2SbA1nE85KvDJv3MxhQgNyJAIB9lA+/P0vdUFH+upnIwzG liMiqmuf3TQxGKIlVi789IhuYz4LmAQSUTU7JphQC3yyfBhPGyBqgE26K Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="400187018" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="400187018" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 11:24:53 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10539"; a="641525771" X-IronPort-AV: E=Sophos;i="5.96,184,1665471600"; d="scan'208";a="641525771" Received: from coltsavx-mobl1.amr.corp.intel.com (HELO [10.255.0.114]) ([10.255.0.114]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2022 11:24:47 -0800 Message-ID: Date: Tue, 22 Nov 2022 11:24:48 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v7 06/20] x86/virt/tdx: Shut down TDX module in case of error Content-Language: en-US To: Peter Zijlstra Cc: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, kirill.shutemov@linux.intel.com, ying.huang@intel.com, reinette.chatre@intel.com, len.brown@intel.com, tony.luck@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com References: <48505089b645019a734d85c2c29f3c8ae2dbd6bd.1668988357.git.kai.huang@intel.com> <52b2be9b-defd-63ce-4cb2-96cd624a95a6@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 11/22/22 11:13, Peter Zijlstra wrote: > On Tue, Nov 22, 2022 at 07:14:14AM -0800, Dave Hansen wrote: >> On 11/22/22 01:13, Peter Zijlstra wrote: >>> On Mon, Nov 21, 2022 at 01:26:28PM +1300, Kai Huang wrote: >>>> +/* >>>> + * Call the SEAMCALL on all online CPUs concurrently. Caller to check >>>> + * @sc->err to determine whether any SEAMCALL failed on any cpu. >>>> + */ >>>> +static void seamcall_on_each_cpu(struct seamcall_ctx *sc) >>>> +{ >>>> + on_each_cpu(seamcall_smp_call_function, sc, true); >>>> +} >>> >>> Suppose the user has NOHZ_FULL configured, and is already running >>> userspace that will terminate on interrupt (this is desired feature for >>> NOHZ_FULL), guess how happy they'll be if someone, on another parition, >>> manages to tickle this TDX gunk? >> >> Yeah, they'll be none too happy. >> >> But, what do we do? > > Not intialize TDX on busy NOHZ_FULL cpus and hard-limit the cpumask of > all TDX using tasks. I don't think that works. As I mentioned to Thomas elsewhere, you don't just need to initialize TDX on the CPUs where it is used. Before the module will start working you need to initialize it on *all* the CPUs it knows about. The module itself has a little counter where it tracks this and will refuse to start being useful until it gets called thoroughly enough. >> There are technical solutions like detecting if NOHZ_FULL is in play and >> refusing to initialize TDX. There are also non-technical solutions like >> telling folks in the documentation that they better modprobe kvm early >> if they want to do TDX, or their NOHZ_FULL apps will pay. > > Surely modprobe kvm isn't the point where TDX gets loaded? Because > that's on boot for everybody due to all the auto-probing nonsense. > > I was expecting TDX to not get initialized until the first TDX using KVM > instance is created. Am I wrong? I went looking for it in this series to prove you wrong. I failed. :) tdx_enable() is buried in here somewhere: > https://lore.kernel.org/lkml/CAAhR5DFrwP+5K8MOxz5YK7jYShhaK4A+2h1Pi31U_9+Z+cz-0A@mail.gmail.com/T/ I don't have the patience to dig it out today, so I guess we'll have Kai tell us. >> We could also force the TDX module to be loaded early in boot before >> NOHZ_FULL is in play, but that would waste memory on TDX metadata even >> if TDX is never used. > > I'm thikning it makes sense to have a tdx={off,on-demand,force} toggle > anyway. Yep, that makes total sense. Kai had one in an earlier version but I made him throw it out because it wasn't *strictly* required and this set is fat enough. >> How do NOHZ_FULL folks deal with late microcode updates, for example? >> Those are roughly equally disruptive to all CPUs. > > I imagine they don't do that -- in fact I would recommend we make the > whole late loading thing mutually exclusive with nohz_full; can't have > both. So, if we just use schedule_on_cpu() for now and have the TDX code wait, will a NOHZ_FULL task just block the schedule_on_cpu() indefinitely? That doesn't seem like _horrible_ behavior to start off with for a minimal series.