Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4424862ioa; Wed, 27 Apr 2022 03:41:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIC7FVWJ2WQqwU2pWOHSuXF7jAKIPg8PPNDmGOZHVsEV8wXCsV2boU0n3gbOsQxjFHi/98 X-Received: by 2002:a63:42c4:0:b0:3a2:b7e5:5077 with SMTP id p187-20020a6342c4000000b003a2b7e55077mr23356541pga.427.1651056070979; Wed, 27 Apr 2022 03:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651056070; cv=none; d=google.com; s=arc-20160816; b=CXYiyWOYOphOt+t6TpmYdgRmxt6YytexT+tN3MQhtjWS41YUk+E88BTv3rb5ALc9q7 DiOFwwLr5OpOvetj9kv3CeX4IJHFmUP2bHAHYQAWUlL0kzo7QukOfw5DIksVltgpM8Gl x4NNWxN5LVje/JD4ERj7k3ZDu6HaDJ1Q6Tx/YhJpqhx6jUsU/SYYaasqw8ATVugiSsRW k0DQuLataeMqRi+EQxLUbnoUBlQswrFnH/naE8U5wjb5HuwAPJGspc6SgiL35kxZ/t83 bR2DSpZD9f6a4QCTGf38zYsj8sx1XzcxQSb1tfVW9CgmPi7ILLQHrpJW5K76ZPNTeDD8 opxg== 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=GMnK86N9zvfZa6ZooTBPc14UCSWf+GYoytaYdraf6DM=; b=X6PoWhCr+ZBdiQkTcrBd88tXz0m3EfiH9ZZqL3g6YY3H6kfcT0ES/kniJDyamsZ3o6 i63jYud4GFPdLGruWPD4lG2zMJkOXFlkAn4Mto3hF8qcrfSm6ErMe4Ry/Cc3SQCI4IIF PfCBPw1sQ3HW74F6fTiBtLMRvb9X8B0jx1lN/oVedvnmEaX/1DQ+LZBVeJAqm2y+HYYG kbY9jD1nTsGY6mJzril7EBVL3hWEH6NXs+zMYLTU6nPBtE8Pa7YDZdSXviVvVc1RXORs aurFGcFT/+/JqtDvcQiZQFznDC6/sh2q+cl2efyp571CJ3Qvc/DqJ+om9ngHwnimxElE ktgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H1jbq50h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u18-20020a631412000000b003ab2603395esi1065370pgl.874.2022.04.27.03.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:41:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H1jbq50h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AB12E3F3496; Wed, 27 Apr 2022 02:52:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356292AbiD0AJu (ORCPT + 99 others); Tue, 26 Apr 2022 20:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232385AbiD0AJs (ORCPT ); Tue, 26 Apr 2022 20:09:48 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424462F382; Tue, 26 Apr 2022 17:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651017998; x=1682553998; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=WF0BUOeCUWjXtygZ0fA+ocYyTRB01MF/mxmqK/OFDYg=; b=H1jbq50hw9Me9mg3kFpgKW5OEP7gVVm4g6eN4TPRg3eBmVqkYFLAr9UJ oWUIuwqacAdmNdWTK1uI121j5mmgBlufe3L+/oiOWVyxyjs3vwTrD4zZi 5epcYRYawq5SeeMN35CumMuh+OMOkC2FZUJc6y5GqeAGLjcCaofBTuRxE 47Vvjiie76QAafrBA3rjD4A612VRY0igR3h885xGNNVy3t7hWKlyqTLUD QSUxZrSrcuYEVoAlyhpnko2wEFDtxFig93FipC+CZtMenlVsDxbAALyKK aMMPTtX7iv95KAXT4gOzrd2AL89OfRH7ziiIH31wCV+q1Z9rEfXsipCj0 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10329"; a="245685354" X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="245685354" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 17:06:37 -0700 X-IronPort-AV: E=Sophos;i="5.90,292,1643702400"; d="scan'208";a="558612050" Received: from ssaride-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.0.221]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2022 17:06:34 -0700 Message-ID: <345753e50e4c113b1dfb71bba1ed841eee55aed3.camel@intel.com> Subject: Re: [PATCH v3 06/21] x86/virt/tdx: Shut down TDX module in case of error From: Kai Huang To: Dave Hansen , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, 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, isaku.yamahata@intel.com Date: Wed, 27 Apr 2022 12:06:32 +1200 In-Reply-To: References: <3f19ac995d184e52107e7117a82376cb7ecb35e7.1649219184.git.kai.huang@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 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); > > + if (ret) > > + atomic_set(&sc->err, ret); > > +} > > + > > +/* > > + * Call the SEAMCALL on all online cpus concurrently. > > + * Return error if SEAMCALL fails on any cpu. > > + */ > > +static int seamcall_on_each_cpu(struct seamcall_ctx *sc) > > +{ > > + on_each_cpu(seamcall_smp_call_function, sc, true); > > + return atomic_read(&sc->err); > > +} > > Why bother returning something that's not read? It's not needed. I'll make it void. Caller can check seamcall_ctx::err directly if they want to know whether any error happened. -- Thanks, -Kai