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 53B16C433FE for ; Tue, 22 Nov 2022 09:20:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D521D6B0071; Tue, 22 Nov 2022 04:20:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D02B26B0073; Tue, 22 Nov 2022 04:20:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF0C36B0074; Tue, 22 Nov 2022 04:20:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B0FC16B0071 for ; Tue, 22 Nov 2022 04:20:58 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83218160FB9 for ; Tue, 22 Nov 2022 09:20:58 +0000 (UTC) X-FDA: 80160533796.04.E0403A9 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf03.hostedemail.com (Postfix) with ESMTP id 1B41A2000B for ; Tue, 22 Nov 2022 09:20:57 +0000 (UTC) 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=aBITBJ1p295wuNeBBhm/B8LW9oNFY5gamj55K4mKePw=; b=AQF66lESLP89XmPdshYCszvIfn WbOIiuGmtwycULWx7bZZ953U5szx1+l3A0l87GZx69A6WGl7sPsVxzfJby2q3sIUM+8M3sffvcjyM khzH//RUOQmtynDqMMB1DaZhAvLH42dr3An3dP/1fAvpQ4HNfdmWrmsBjaL3MVHtn5fWIqYYJdvN6 p0UODz+GQ8F4TO93sWLLVAAjoudXK2Q+BbeiOWmxqEUnd/Ku3QNDoY3kphofG8DEp6BYw9K2N3EpT tzHcx4wSbkgZmzCCv9TlG9mSq2eQZZmEIokxtE18tI3s0YKF0LLjG+6zaeRn/bLuYBjhzXWlaV6XR 3Lc1+kIg==; 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.94.2 #2 (Red Hat Linux)) id 1oxPSY-003ODh-2s; Tue, 22 Nov 2022 09:20:54 +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 982B9300322; Tue, 22 Nov 2022 10:20:53 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 808B22D66C42F; Tue, 22 Nov 2022 10:20:53 +0100 (CET) Date: Tue, 22 Nov 2022 10:20:53 +0100 From: Peter Zijlstra To: Kai Huang Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.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 Subject: Re: [PATCH v7 06/20] x86/virt/tdx: Shut down TDX module in case of error Message-ID: References: <48505089b645019a734d85c2c29f3c8ae2dbd6bd.1668988357.git.kai.huang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48505089b645019a734d85c2c29f3c8ae2dbd6bd.1668988357.git.kai.huang@intel.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669108858; a=rsa-sha256; cv=none; b=6wLvmFDPWwnNcxvJzbaNIvqBnUitSK5svowwiPg3NtltjkcLycjEpFPfwUeJtiXwSSG4vS doggU0bIz4LCcsWuk74/77rfXL9wz9+whP7MjcrkI7lQ20aXfSKXmngECqdI9MOjrua2Xm PDRpgjFI9C21LLC+IRxTVc/Gma2FZAw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=AQF66lES; dmarc=none; spf=none (imf03.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=1669108858; 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=aBITBJ1p295wuNeBBhm/B8LW9oNFY5gamj55K4mKePw=; b=jVYPXVCkKYTIIlVUqenXuDR5EBLbW+k05bz5EaGNWKgnGz6C/L3drGcHyGWEzQccMmNClP GG3+Df7Ug6EJa2QmKgGdmyJefLpZ7QIMvnZ9DooH5/aWRDGs8SnXmfEh3/k/Bk1IsSibgz 1+FpqJbdU+Jz4clR3OUMKQg1g5AHxH4= X-Stat-Signature: ckzbbnazrcx9p1qkedgi87n56ynfxzhb X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 1B41A2000B Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=AQF66lES; dmarc=none; spf=none (imf03.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org X-Rspam-User: X-HE-Tag: 1669108857-90309 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002092, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Nov 21, 2022 at 01:26:28PM +1300, Kai Huang wrote: > Shutting down the TDX module requires calling TDH.SYS.LP.SHUTDOWN on all > BIOS-enabled CPUs, and the SEMACALL can run concurrently on different > CPUs. Implement a mechanism to run SEAMCALL concurrently on all online > CPUs and use it to shut down the module. Later logical-cpu scope module > initialization will use it too. Uhh, those requirements ^ are not met by this: > +static void seamcall_on_each_cpu(struct seamcall_ctx *sc) > +{ > + on_each_cpu(seamcall_smp_call_function, sc, true); > +} Consider: CPU0 CPU1 CPU2 local_irq_disable() ... seamcall_on_each_cpu() send-IPIs to 0 and 2 runs local seamcall (seamcall done) waits for 0 and 2 runs seamcall clears CSD_LOCK ... spinning ... local_irq_enable() runs seamcall clears CSD_LOCK *FINALLY* observes CSD_LOCK cleared on all CPU and continues IOW, they all 3 run seamcall at different times. Either the Changelog is broken or this TDX crud is worse crap than I thought possible, because the only way to actually meet that requirement as stated is stop_machine().