Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1099626iob; Wed, 18 May 2022 22:15:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUKRJ9f3mfIH8kbCuqxYFyH66SJ2Ach/JqIIJScJFr5e1glGKDQ8keQxeG/2N+uiX7slkL X-Received: by 2002:a17:907:948d:b0:6fa:7f00:ed57 with SMTP id dm13-20020a170907948d00b006fa7f00ed57mr2525203ejc.761.1652937358106; Wed, 18 May 2022 22:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652937358; cv=none; d=google.com; s=arc-20160816; b=irY7ldcQUakjBsVAWCw089AGy+Xg57uN+dnjYKcpHKa4iQ1xefjXCfy+WeBx3nMeKv ij9rWTxZi26KPPCY16wkZOP8+QdntaKRPahUl/ekf/29kuzRd6sl01ZnesKrUsUT8a2R 0zE1K2fvZzhYLEhfsvAHfLge199+5QoPOgDvG4xauCd5g2uQOB3wtg72cyIvReR9V2Ga xVE1bV1VB6qwx39PyqN0+mLnGwpQjU687LFGZSO6n/RERhf8nLEhZtuLZ7Bsrp7HhvHt zOEOoAkqVLOdogYAP9tIEb+Dq7KSghiwcVW6i/ka/VeJHQXeJKYIYRkx0KXI1ChCjATM Y8pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=m7n3v+HOZxrjMWCKPsPRR9EK+ZSKC7uN9n9CmABp5NQ=; b=g+czOCRxFNNSBNZT2tNzLajc9azSbbcOFhly2NF87S3hC1eHtsh/6608lK3HCXazsH jg4xBQ7CpC/+tRtAYDpUZsZDNph59HpIxmxLTVvPATB+3txJpK7rTRsUgsphEWk8jSUp Lr7p8722OH5OoC6YmECdclkogYH6cujM55Ht3dfK2bp8Lqomh4Gq48G0amo+r+qzc3Iu oQvyerJpI44nna+g8XUbsH6evRLYLgD6RpMlEEcNoovvCQCxq1XjeaofYfH0xLKoHfrd gkNXoGwLwJ7J3YF6wdQf05QHu28BZsN5CaqMZsusxUEc0REYljhdmVuk+Tkd/IuOoIJq so+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fCwjRVja; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a05640242d400b0042ac8e2e67fsi5247183edc.579.2022.05.18.22.15.32; Wed, 18 May 2022 22:15:58 -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=@intel.com header.s=Intel header.b=fCwjRVja; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbiERXwC (ORCPT + 99 others); Wed, 18 May 2022 19:52:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbiERXwA (ORCPT ); Wed, 18 May 2022 19:52:00 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D6DF7938F; Wed, 18 May 2022 16:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652917919; x=1684453919; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=mJ+odFwUEFZ8/mBRx5MLyfUxqVB0HbjzNjmsEFcZYgI=; b=fCwjRVja+MoYYbfhe+A3QrE3zFk/9DR6+uyMSDDPXXTV9ZwK6GntLxJ/ 2VR3zEVGNlILUvtIt44hxnoZK82uPnfBcOy38rAOQqPtv/Ydf17JTRoAV kzDVHFmPGCVsDq5qRIeIh9ToftQ0QIxkwwK9Ee+spy1sP78lEgwRkA0K9 s29UZirKM5b3i0OJSFb6UOdg7ekJjdr1olDO/C+FqdV+JYVlcwWeHazGK TnNr/guEycfB/l02On0tFdAv62qqinbW6Dv3jUeWLkFg1Hn2q1hWFfy9b OqvcBh4j9y5w6C9Ahy+xMlJ+uR9qdJQuzqN2pacxXCburZ5wKptf8bQUy A==; X-IronPort-AV: E=McAfee;i="6400,9594,10351"; a="272072636" X-IronPort-AV: E=Sophos;i="5.91,235,1647327600"; d="scan'208";a="272072636" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2022 16:51:59 -0700 X-IronPort-AV: E=Sophos;i="5.91,235,1647327600"; d="scan'208";a="569820102" Received: from ppamkunt-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.33.252]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2022 16:51:55 -0700 Message-ID: <6b9d89e1bd4d9991b0cdb778224474696e8e6b67.camel@intel.com> Subject: Re: [PATCH v3 06/21] x86/virt/tdx: Shut down TDX module in case of error From: Kai Huang To: Sagi Shahar Cc: Dave Hansen , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Sean Christopherson , Paolo Bonzini , len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, "Yamahata, Isaku" Date: Thu, 19 May 2022 11:51:52 +1200 In-Reply-To: References: <3f19ac995d184e52107e7117a82376cb7ecb35e7.1649219184.git.kai.huang@intel.com> <345753e50e4c113b1dfb71bba1ed841eee55aed3.camel@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Wed, 2022-05-18 at 09:19 -0700, Sagi Shahar wrote: > On Tue, Apr 26, 2022 at 5:06 PM Kai Huang wrote: > > > > On Tue, 2022-04-26 at 13:59 -0700, Dave Hansen wrote: > > > On 4/5/22 21:49, Kai Huang wrote: > > > > TDX supports shutting down the TDX module at any time during its > > > > lifetime. After TDX module is shut down, no further SEAMCALL can be > > > > made on any logical cpu. > > > > > > Is this strictly true? > > > > > > I thought SEAMCALLs were used for the P-SEAMLDR too. > > > > Sorry will change to no TDX module SEAMCALL can be made on any logical cpu. > > > > [...] > > > > > > > > > > +/* Data structure to make SEAMCALL on multiple CPUs concurrently */ > > > > +struct seamcall_ctx { > > > > + u64 fn; > > > > + u64 rcx; > > > > + u64 rdx; > > > > + u64 r8; > > > > + u64 r9; > > > > + atomic_t err; > > > > + u64 seamcall_ret; > > > > + struct tdx_module_output out; > > > > +}; > > > > + > > > > +static void seamcall_smp_call_function(void *data) > > > > +{ > > > > + struct seamcall_ctx *sc = data; > > > > + int ret; > > > > + > > > > + ret = seamcall(sc->fn, sc->rcx, sc->rdx, sc->r8, sc->r9, > > > > + &sc->seamcall_ret, &sc->out); > > Are the seamcall_ret and out fields in seamcall_ctx going to be used? > Right now it looks like no one is going to read them. > If they are going to be used then this is going to cause a race since > the different CPUs are going to write concurrently to the same address > inside seamcall(). > We should either use local memory and write using atomic_set like the > case for the err field or hard code NULL at the call site if they are > not going to be used. > > > > Thanks for catching this. Both 'seamcall_ret' and 'out' are actually not used in this series, but this needs to be improved for sure. I think I can just remove them from the 'seamcall_ctx' for now, since they are not used at all. -- Thanks, -Kai