Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5571382rwb; Tue, 22 Nov 2022 01:43:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CBQlrYaToB/TPIikFYoAYYFWCfBbJxa2dsbI3m2suFSo5R5N9DWrBqQTO7KABVk26X+9y X-Received: by 2002:a17:906:34d5:b0:7ae:b9fc:8668 with SMTP id h21-20020a17090634d500b007aeb9fc8668mr17763812ejb.257.1669110183046; Tue, 22 Nov 2022 01:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669110183; cv=none; d=google.com; s=arc-20160816; b=FiheEB2PSgxkzhz42rnGSlS4M/eMAwnwt3I7phyk/tjotg91+q0ehe3By//6LTtljs iMgFTptXU7F3+NZgNN5g1zftaA/Qkk/j0KqrWDr4C3AyIqWGT4OPHBml/myMF/AUTMEh OHlG7VwXaEaL/NsyVRRD/YEgi33xJBVnmnTBPCOalcCZXCyI3MtHhpuE2ISoZcV3G++n kLBfAGRYsagWThjKkfto8QWNcNITIjqN/BlMq9tU915eXVlG0xynybTIdQy02wZ6ui/7 g304Me/PJ2zitSd9gLJtBPHYqruYrpnYLfW12fINy7W+86wXtg3ED2Sn0C3cRfUNRuDN yamA== 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=aBITBJ1p295wuNeBBhm/B8LW9oNFY5gamj55K4mKePw=; b=lA3lEp2QlFEzum0oaLNttXoa9rNqJjD+trimZ3b541FmSyOCl8qKvUeeVN76pteq1D cQKvBN1FbUsIcKRahFluuX3w0vpoAJwqDzUO27aThBrKn1q53lMohQnJy+v/WGiF3yw4 7lckrchPMbQO3zB20ttnNK7t9NtPPMQb1YWI7rSvilTpG2ZfcZcfN+8OEhvFYrv8kIxD BXI4g5h2/ulXj7VKUh9Ly4b/0j39t860TTx3O65VW7itwJNglwLPT5vbvG5MSFCcJmON N3qCpyHWS3bnw7RgueGcLTnAEf9ZdRy9240gkC5sH6Gh68r0cLAZO3nju1U0bzWMEuHj xWzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=AQF66lES; 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 hb17-20020a170907161100b007b790c183d5si3560848ejc.260.2022.11.22.01.42.39; Tue, 22 Nov 2022 01:43:03 -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=@infradead.org header.s=desiato.20200630 header.b=AQF66lES; 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 S232715AbiKVJVK (ORCPT + 91 others); Tue, 22 Nov 2022 04:21:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbiKVJVH (ORCPT ); Tue, 22 Nov 2022 04:21:07 -0500 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 7C22924BE9; Tue, 22 Nov 2022 01:21:05 -0800 (PST) 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> 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 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 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().