From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4C8DEB64D7 for ; Fri, 30 Jun 2023 09:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EF948D0009; Fri, 30 Jun 2023 05:25:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39F8B8D0001; Fri, 30 Jun 2023 05:25:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 267D98D0009; Fri, 30 Jun 2023 05:25:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 142D78D0001 for ; Fri, 30 Jun 2023 05:25:16 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DBF251A0E29 for ; Fri, 30 Jun 2023 09:25:15 +0000 (UTC) X-FDA: 80958880590.06.0AEEA6B Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf21.hostedemail.com (Postfix) with ESMTP id E1FC01C0007 for ; Fri, 30 Jun 2023 09:25:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=WU9yNRdi; dmarc=none; spf=none (imf21.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688117114; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5kMR4RZMpRfqpCS+yssLHYk+vsmGpmykrhyTHw3S//Q=; b=zeTu3jCyBC8s6GSmylOoxGJte55De50VZcM14p2dSv082+KFIgDUjT+f0YETevW3/fIhf3 0MvCRrElMLqwPfD/Eq4+wY9ersdx0QXsBKho5v469pIOnpf7+7VDgaVe96ikMg5dcoPPTx CZc1U1mfBS/EiSbvSx9jFu1TMNinaZA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=WU9yNRdi; dmarc=none; spf=none (imf21.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688117114; a=rsa-sha256; cv=none; b=sAqpWqEYesMtN4GM3Q2lz4EBxwfOklDKUuLRn2JWzAKB1INzwkrbF06jCly650Z8ioZ9nq GZLYVH8sXC93u6RHVYF0sD32HtaXlGCZ7yhPWmMq7WVcwvGgh6qxCMeS04YgSn/H62I5lP oR7VCpsvtXhpYHtwaKzFkc6MBPEcLHI= 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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E1FC01C0007 X-Stat-Signature: fjw3h6rhs68bj5mpt195usyhdgsnu8uj X-HE-Tag: 1688117113-12395 X-HE-Meta: U2FsdGVkX192q/ygepMnMvCWhDvfs102V3umAf/oC/NkOfcrtWpVxfabjHJX6B0p+hVt1DgQiMhqWxxldjTvbVPPhWmzvKExvwjReehYqMoN8jeHz2bGWkxLPquDWlf5s399kU1eEjDK+P3OrDOR3Grb83xfA39OvKy/pD/1X6vCvokNhbyo2cCbyUofyGYu2MqIrSzHdboKrfoq+oudv9AHq2YaWaRI8MXmIY3cvrslOgszDVoniwdOA/jDHSP4IMX58d1gs0AhnaYnfHzFuwdZF5XMIiL1Uk2MceBu+/g9FH+SPA10fsFuQVvZVHQhLNTWK63ZcNkcmSLtiPZkgQvtkfBPU70nEsj/74B6AXCemkj9ScS8RQ3DL5qqsgSqt7I0C9dlZmD82fdcrABlZIlLHE91RtiaLxm4HUul/KtMJZJNYM1AebOw7UvJ8w2R6LT3LrFzQ7NfW+8Hn2xBxVCPgQjcdl367h7SQpgSUMOgd0qflZDcsSjkfS1m3PIbXp419++Dj/IMa9Ss62ik2QW51LvDsQfTyiVlWjWrSLSTGWEXzDZSqkqCQKYaVpshWvOtiFN9K7EciLSQ8HFiypd+HCIhE8Qn3DrGQSsDv+vVzDKAssIyOovnkVxQMa4KCJ3h8NNA4/RRs/RwVbTqHRSa0J3YTlI0QCBBRW6QVnv42SHKLFMKhJDRZXbNOV/JpqIFlwyERs2cJquInl2rIdOp/8KraRbgD//oYPAtHhUHIBG28l/19SigvXRinZmTzDNLyQ46kH4B93uPmRiuILEY6a+ZSXX8GtSq4dZmlUzuVS2DDqaqwzTxxA6bdyC4k/FDbRahv0zyR+Dq1qpwDB9OgWr0OZeOT7rv0AbYaIuR71DjYJIJ9ucc1EXE3cGKiq+iVZqD4/BWNaVhMk4qXC3u/2LQeoScMP+M0MeQJuHya2XJpgh/C3eSpu/Ty8rB5Y/Rt6y+Kj541KSmm5a G2hMa/6p YOsF967b1lZ6RczpTRUUf0rCJaj0xWJBYAloqN9m2ojHThqaWEK3NlIy6LeWkjf59FPGZwv8LvcZEj1EJdrUepOJyeaMDq2NtcWlnlMWp9oOMDQEnA9ALbpaHy8VHWByDM04PhZ5QE42xhaYyYGxqDQlxgGhEh0gM901fPI5hIU7tp6juZJXFE7x29w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000154, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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?