Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22005755rwd; Fri, 30 Jun 2023 02:36:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFbxek4oEYY0tqgzTlbXNIVgMaHvOYYYTAHhi+jMKX8q7fso5YY2m18abrspunSz57FjV+ X-Received: by 2002:a17:903:24e:b0:1b7:f73d:524 with SMTP id j14-20020a170903024e00b001b7f73d0524mr1952511plh.43.1688117767839; Fri, 30 Jun 2023 02:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688117767; cv=none; d=google.com; s=arc-20160816; b=cUf6OG8cfJqOS6vB5b8tuMExfbe4WljbmnRhOfZNv6MoS9DKt0QnkglWei4PpM0vBE /56VDakOuYAHZu43uuXcw1Ez3IpbPp43ak/vcr8LTjrfymmmDXRv+fLMq7J4/F+O1x7T VIla7Q3qyv8n3HqIVCMu7+20rbmV/dnJBSuYRfHMhAK6diNwzWjHNpm031Ghs9eG63rw Q9qN9wZQLFP6D/jZwyvLCfhY1JputtxiG9wgdOUmKFwvJC4f1fe6aIWIKKNVRwbMIpzU h80sO0YUOW9Egvhwf6abaoLt2aXj6BB9HIVWsP6FnYvf5xHCG+cVE+3G1121fDAHWiXp 5vhA== 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=5kMR4RZMpRfqpCS+yssLHYk+vsmGpmykrhyTHw3S//Q=; fh=fOk9OZUSMbB51fwCyVJ/Xtma0ffyyGr1tqaCo5fi3/8=; b=iUnI1jvha7l0fmDY9VKGYPndqjOHhQieY9h5c0OU9bUEL3ECyXmhHVjc1zP7kwXD7Q GDux1ovbmGM7t8dsouyELXoZVtI9WSlj/B3/hqwDNhCOdFGJJhiIVYbWQRsDWnezklVP QvqzBrnjcVCRO0nrGRlAx9v1xO33cGGx2Zaoy+wD+5K+ps4NFCd7ekmkEgr5V5UfeD9K HW4dYxpjnCKbUnELxSuXB4ncJfqKfm6cdW1KsS79Zt0P/azodi+4BmHWDEecp6wGDsbu k9qzhuXcbv1Vjp4mApSdx2LCvW1ZYPewaO5uQ9KFihpojw4gi5yuDw2G0ajwPaPnaBbj I3Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=WU9yNRdi; 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 i8-20020a17090332c800b001ac62935789si5793001plr.468.2023.06.30.02.35.55; Fri, 30 Jun 2023 02:36:07 -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=@infradead.org header.s=desiato.20200630 header.b=WU9yNRdi; 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 S232760AbjF3JZ3 (ORCPT + 99 others); Fri, 30 Jun 2023 05:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232700AbjF3JZ0 (ORCPT ); Fri, 30 Jun 2023 05:25:26 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23D7919C; Fri, 30 Jun 2023 02:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5kMR4RZMpRfqpCS+yssLHYk+vsmGpmykrhyTHw3S//Q=; b=WU9yNRdiaTprqK+nmhNcQr86y2 7wrYieC7gE7WxRIyGhL54/cCim7FbFza5Ycv6dCs+7x832Jq8OVnUyy1r4LvbYij4InFAadiUUWRH YtgDtSw64N5rH4Qk9WCEpPWsZjroMrgw9mTxG41eCZ6sYzVAYIqdWHq2b6/Ez7FV47ORJ31MEd0Pk o6M37G9TOfsiaKXYgwrzHFjhg+m2CFKmCthDTC5f+Q/2zLSdtss26+rU3b/9kSEJ/LRiQ6jCvMR6l RKvtQCVvODSNvoS82FrHwP0LpaY7rw2MHUqWrNBjl+WEr7WaBWohscBgiQdE4675MGkPQYImgVSxG dIKo4nsA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qFANE-007wLX-0U; Fri, 30 Jun 2023 09:25:04 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id BCCC4300118; Fri, 30 Jun 2023 11:25:03 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A4606245D3645; Fri, 30 Jun 2023 11:25:03 +0200 (CEST) Date: Fri, 30 Jun 2023 11:25:03 +0200 From: Peter Zijlstra To: "Huang, Kai" Cc: "kvm@vger.kernel.org" , "Raj, Ashok" , "Hansen, Dave" , "david@redhat.com" , "bagasdotme@gmail.com" , "Luck, Tony" , "ak@linux.intel.com" , "Wysocki, Rafael J" , "linux-kernel@vger.kernel.org" , "Christopherson,, Sean" , "mingo@redhat.com" , "pbonzini@redhat.com" , "linux-mm@kvack.org" , "tglx@linutronix.de" , "kirill.shutemov@linux.intel.com" , "Chatre, Reinette" , "Yamahata, Isaku" , "nik.borisov@suse.com" , "hpa@zytor.com" , "Shahar, Sagi" , "imammedo@redhat.com" , "bp@alien8.de" , "Gao, Chao" , "Brown, Len" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Huang, Ying" , "Williams, Dan J" , "x86@kernel.org" Subject: Re: [PATCH v12 07/22] x86/virt/tdx: Add skeleton to enable TDX on demand Message-ID: <20230630092503.GC2533791@hirez.programming.kicks-ass.net> References: <104d324cd68b12e14722ee5d85a660cccccd8892.1687784645.git.kai.huang@intel.com> <20230628130419.GC2438817@hirez.programming.kicks-ass.net> <20322f0432e418eaacfe397aa9363f94ada0b902.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20322f0432e418eaacfe397aa9363f94ada0b902.camel@intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Thu, Jun 29, 2023 at 12:00:44AM +0000, Huang, Kai wrote: > The spec says it doesn't have a latency requirement, so theoretically it could > be long. SEAMCALL is a VMEXIT so it would at least cost thousands of cycles. :-( > If raw_spinlock isn't desired, I think I can introduce another function to do > this and let the caller to call it before calling tdx_cpu_enable(). E.g., we > can have below functions: > > 1) tdx_global_init() -> TDH_SYS_INIT > 2) tdx_cpu_init() -> TDH_SYS_LP_INIT > 3) tdx_enable() -> actual module initialization > > How does this sound? Ah, wait, I hadn't had enough wake-up juice, it's tdx_global_init() that did the raw_spinlock_t, but that isn't the IPI thing. Then perhaps just use a mutex to serialize things?