Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7491354rwd; Tue, 20 Jun 2023 01:52:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YlPtgjIeSikXbxFDPRP2pzI2YlRn7SANgx6whVyYNFucLYpNb9Rdk+n1AnvNduir+Ulja X-Received: by 2002:a17:902:ab18:b0:1ac:6d4c:c24b with SMTP id ik24-20020a170902ab1800b001ac6d4cc24bmr6535770plb.3.1687251148679; Tue, 20 Jun 2023 01:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687251148; cv=none; d=google.com; s=arc-20160816; b=ggr5mHEiMaqN8XSdCTAMO+GfhGGs1/wTPVJnICqauMr0Qg4vTPEGCHBsJWg//lti3w DTnC4WnzHeebWctM2m70cjVxAn4JCO1FmM6YRa9RFgXVqhnwrraueNH3l2Tw8kZI2JIW KwY17QAUbMTCzItmw0UFyqNCiQguW0M7JMDrf9ItWH93vTZax1PpBvd74Kla+YGKNNM2 piTCfp0snDWyFTM52U5DnrJgn5WfbkqYsh/Cd0wTvb72BiUnAlazzLfeZiaeonZJeFAs 3RDTHcJlcb1bGmikAAjV3ZX4mtFBUhIaqZ6BSO839o24LLn4+MG0DTAHdWgglLPSIt7X ey+Q== 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=BZECT2dbtdQzJxRKjUga30Xmntvvyra9f2PegQf5YA4=; b=xiq0j7nSIlEF0YvmL8RdjjFO0XfaqelrlkNFQ++Mx3VdSI8ovJUzOB3hstWas5sDO0 dv9/OpFWaux3KzdIQXKFLcsVE/WjKDnBHGJDH138Whq9Mu1PEZOd8bLUq9yZpW9y228H v/ZhTrrXGoBOhjq1l2WmoIdj9+sM9Qq1c0IQ3zcS64tIg1ZGw7vfKBR10rokHacgYjLM aK4DvW5NyqJsxn7YimNmpRruE0ArJxHa5uhXATD3CpLzLtREEkbteQOnuzNEjspvIhPF rubAoWb4ee/wwDYZM5r6N90LmynzmFDKxtLlRRpl8CDEJizzZ6BZTHqeflegPneRRank PubQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=de+bOqx9; 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 w15-20020a170902a70f00b001b53b6d8ebfsi1436018plq.56.2023.06.20.01.52.14; Tue, 20 Jun 2023 01:52:28 -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=casper.20170209 header.b=de+bOqx9; 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 S231790AbjFTH7o (ORCPT + 99 others); Tue, 20 Jun 2023 03:59:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbjFTH7L (ORCPT ); Tue, 20 Jun 2023 03:59:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE461729; Tue, 20 Jun 2023 00:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=BZECT2dbtdQzJxRKjUga30Xmntvvyra9f2PegQf5YA4=; b=de+bOqx9/anW6oVh6YmJvCVeRR cYjE9B4blJW5E8eOr/pwAy/iz6GLAI9SJ6i2rNJlNTKQIiM9cHnB0K8OA0mU4bFO1Jk06PWASYn8P SkD1gZN4oKesbZpa4qAReA45F4ruvysyYc9AdwskypURpGcSd/9mjE9VezWYFlnH9wNP6qPP5MH+4 p1LyFzVLLaFyz1lLBcsehIq/aGPiNV556lTvkjb6N8cMgYGwgvFzGhle4157+xORsSlDilkCIfN5S UIvKqIK2Iw9qf/PzBNxrrFZWN+oqj2Yl1bF27J6i9XKaCR75QgH/LkXyl2Rme8RXEHwSdfHCtLia0 0cBxtrSw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qBWG0-00Cphv-05; Tue, 20 Jun 2023 07:58:32 +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 2C12B30020B; Tue, 20 Jun 2023 09:58:31 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0802123BE1E49; Tue, 20 Jun 2023 09:58:30 +0200 (CEST) Date: Tue, 20 Jun 2023 09:58:30 +0200 From: Peter Zijlstra To: Dave Hansen Cc: "Huang, Kai" , "kirill.shutemov@linux.intel.com" , "kvm@vger.kernel.org" , "Luck, Tony" , "david@redhat.com" , "bagasdotme@gmail.com" , "ak@linux.intel.com" , "Wysocki, Rafael J" , "linux-kernel@vger.kernel.org" , "Chatre, Reinette" , "Christopherson,, Sean" , "pbonzini@redhat.com" , "tglx@linutronix.de" , "linux-mm@kvack.org" , "Yamahata, Isaku" , "Shahar, Sagi" , "imammedo@redhat.com" , "Gao, Chao" , "Brown, Len" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Huang, Ying" , "Williams, Dan J" Subject: Re: [PATCH v11 18/20] x86: Handle TDX erratum to reset TDX private memory during kexec() and reboot Message-ID: <20230620075830.GU4253@hirez.programming.kicks-ass.net> References: <58f34b4b81b6d6b37d3386dec0f073e6eb7a97ff.camel@intel.com> <20230612075830.jbrdd6ysz4qq7wdf@box.shutemov.name> <4c7effc3abe71aa1cbee41f3bd46b97aed40be26.camel@intel.com> <48d5a29a-878c-665d-6ac2-6f0563bf6f3c@intel.com> <5782c8c2bb3e76a802e4a81c553a21edbaee7c47.camel@intel.com> <20230619144651.kvmscndienyfr3my@box.shutemov.name> <63477d22-26ef-dd08-a3b0-93931b7d1d16@intel.com> <0be5634f390015ee6badb3f2b2154ad90eb70434.camel@intel.com> <4069285d-1653-4cbf-a3b3-24727697754b@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4069285d-1653-4cbf-a3b3-24727697754b@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 Mon, Jun 19, 2023 at 06:06:30PM -0700, Dave Hansen wrote: > On 6/19/23 17:56, Huang, Kai wrote: > > Any comments to below? > > Nothing that I haven't already said in this thread: > > > Just use a normal old atomic_t or set_bit()/test_bit(). They have > > built-in memory barriers are are less likely to get botched. > > I kinda made a point of literally suggesting "atomic_t or > set_bit()/test_bit()". I even told you why: "built-in memory barriers". > > Guess what READ/WRITE_ONCE() *don't* have. Memory barriers. x86 has built-in memory barriers for being TSO :-) Specifically all barriers provided by spinlock (acquire/release) are no-ops on x86. (strictly speaking locks imply stronger order than they have to because TSO atomic ops imply stronger ordering than required) There is one (and only the one) re-ordering possible on TSO and that is the store-buffer, later loads can fail to observe prior stores. If that is a concern, you need explicit barriers. This is #MC, much care and explicit open-coded crap is expected. Also, this is #MC, much broken is also expected :-( As in, the current #MC handler is a know pile of shit. Basically the whole of #MC should be noinstr -- it isn't and that's a significant problem. Also we still very much suffer the NMI <- #MC problem and the #MC latch is known broken garbage. Whatever you do, do it very carefully, double check and be more careful.