Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7451337rwd; Tue, 20 Jun 2023 01:09:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Fkvme9zMi1D9e0vuhprF6khU0EnyNlA9af+rNbEs0o9KBtXwMX42VP2Ddw6BewcfYVS80 X-Received: by 2002:a17:902:ed41:b0:1b3:d6c8:7008 with SMTP id y1-20020a170902ed4100b001b3d6c87008mr6877961plb.57.1687248587704; Tue, 20 Jun 2023 01:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687248587; cv=none; d=google.com; s=arc-20160816; b=s8bjOamdi7h1pzQfPNaBaZ1YwEIUcrcGQAiUmbxLWyXByLa5MTPUdR/jBH8hdQQNP+ 1gkKnkqwgJ5H7U7aIsmlqKeIFgCAowicjJah7dRrn9pja1cx+j7HMbtpeb/ibNI8jVmR CJ3Q4jjO3agyMyKjKEkcn1JWYi+zmwV34ECRL0O44g9Yi8cv6PALm4BlmKLoqaR1u5Bz qtxof7NaheIcGGeCASVj/DuqajSHRfiZsiGgNRuwO2SRSuQROEpU4lAL6yIV8MmFBS1y Lmkf0qeowwLfOkHk+YaegqetTZ3fIyjwk6aC0Gjkk77zyjLr5Kh9TH5w4011ELoLWUpe T3Pg== 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=tDwACWsZWyvQQ7KO5OXodC3aVuzBmZwAsrzP9VHieio=; b=OnTWIl2IgrtkX56+/bHnD4NlOJ9RI2TAJFBP5H7+lgTzlauQWSnz95xOIS7t/0Ae4f UkvMjUl06pjfTLxrAeIvb4ZH1YaPGsMOe4B8JEsZ6OSUtsHss09H4uPVQc8zlbHPY1w3 tFWwykiZQ3BgpexGohrsGNmw/G62QSd3Z3+XZtTecIS69Na2rDaYRQUnqNE5VERY3/2J NJ38GzHblm2DmFr5WM2uE1Bi+2q3zxIAnAhCQuoJ7Ru0MX6NDaStkn3x6+u+zOIQnJnd /3OQfere2TdLxAAdUh4nA0rXxOBos4W1R2zcVI1aDUeKJFukLi+md94rzPdfCLBKs7wD Oulg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=pjkEIqNA; 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 t1-20020a170902e84100b0019926d9c734si1491035plg.602.2023.06.20.01.09.35; Tue, 20 Jun 2023 01:09:47 -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=pjkEIqNA; 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 S231338AbjFTHtR (ORCPT + 99 others); Tue, 20 Jun 2023 03:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231449AbjFTHs7 (ORCPT ); Tue, 20 Jun 2023 03:48:59 -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 9E1BF199A; Tue, 20 Jun 2023 00:48: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=tDwACWsZWyvQQ7KO5OXodC3aVuzBmZwAsrzP9VHieio=; b=pjkEIqNAZVkLNrHA0rYEme4LqJ 95b/SIiPlio8YOMhBRCW8VyOFKLb6nZ6K9wC9OtgcZa0kU4BXJLJf4W164EPMu/FbzjVxrDWYWkkv LrjiKSqbtYt7ViPqo45PVjlQBxCvQzrPqr+rxhcNpPQ3DozUrKQhY2NhEoXxmpLVMC0jzQuYCo76s je2w+weJT3MlR6shRDoT6R8biQLtMxiRva/z6P+k4UkZAapX7zZxwJ4APYDyntWjQwEwSUoRWU5f4 TQxJ+jek5OwM4rGBcRLfd4TVkASJRaim3Z4qDEDIxPmfbnMsxe3xQP73GIbfG0McQstvN8D5aI38R z+lhkQcA==; 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 1qBW5u-00Fyhm-2p; Tue, 20 Jun 2023 07:48:07 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C0DFF300322; Tue, 20 Jun 2023 09:48:05 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A143D23BE1E49; Tue, 20 Jun 2023 09:48:05 +0200 (CEST) Date: Tue, 20 Jun 2023 09:48:05 +0200 From: Peter Zijlstra To: Dave Hansen Cc: "kirill.shutemov@linux.intel.com" , "Huang, Kai" , "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: <20230620074805.GT4253@hirez.programming.kicks-ass.net> References: <5aa7506d4fedbf625e3fe8ceeb88af3be1ce97ea.1685887183.git.kai.huang@intel.com> <20230609132301.uvvp27yr5kpenl6f@box.shutemov.name> <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <63477d22-26ef-dd08-a3b0-93931b7d1d16@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 04:41:13PM -0700, Dave Hansen wrote: > On 6/19/23 07:46, kirill.shutemov@linux.intel.com wrote: > >>> > >>> Using atomic_set() requires changing tdmr->pamt_4k_base to atomic_t, which is a > >>> little bit silly or overkill IMHO. Looking at the code, it seems > >>> arch_atomic_set() simply uses __WRITE_ONCE(): > >> How about _adding_ a variable that protects tdmr->pamt_4k_base? > >> Wouldn't that be more straightforward than mucking around with existing > >> types? > > What's wrong with simple global spinlock that protects all tdmr->pamt_*? > > It is much easier to follow than a custom serialization scheme. > > Quick, what prevents a: > > spin_lock() => #MC => spin_lock() > > deadlock? > > Plain old test/sets don't deadlock ever. Depends on what you mean; anything that spin-waits will deadlock, doesn't matter if its a test-and-set or not. The thing with these non-maskable exceptions/interrupts is that they must be wait-free. If serialization is required it needs to be try based and accept failure without waiting.