[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f04c7b69fe539a8065c24f766455c0bec3cdf877.camel@intel.com>
Date: Thu, 29 Jun 2023 00:27:50 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>
CC: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Raj, Ashok" <ashok.raj@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>,
"david@...hat.com" <david@...hat.com>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"Luck, Tony" <tony.luck@...el.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"mingo@...hat.com" <mingo@...hat.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"nik.borisov@...e.com" <nik.borisov@...e.com>,
"hpa@...or.com" <hpa@...or.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>, "Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Huang, Ying" <ying.huang@...el.com>,
"x86@...nel.org" <x86@...nel.org>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v12 19/22] x86/kexec(): Reset TDX private memory on
platforms with TDX erratum
On Wed, 2023-06-28 at 15:29 +0300, kirill.shutemov@...ux.intel.com wrote:
> On Tue, Jun 27, 2023 at 02:12:49AM +1200, Kai Huang wrote:
> > @@ -1113,6 +1115,17 @@ static int init_tdx_module(void)
> > */
> > wbinvd_on_all_cpus();
> >
> > + /*
> > + * Starting from this point the system may have TDX private
> > + * memory. Make it globally visible so tdx_reset_memory() only
> > + * reads TDMRs/PAMTs when they are stable.
> > + *
> > + * Note using atomic_inc_return() to provide the explicit memory
> > + * ordering isn't mandatory here as the WBINVD above already
> > + * does that. Compiler barrier isn't needed here either.
> > + */
> > + atomic_inc_return(&tdx_may_has_private_mem);
>
> Why do we need atomics at all here? Writers seems serialized with
> tdx_module_lock and reader accesses the variable when all CPUs, but one is
> down and cannot race.
>
In kexec() the reader reads this when all remote cpus are dead w/o holding
module lock. All remote cpus can be stopped at _ANY_ time, meaning they can be
stopped right in any place in middle of init_tdx_module(). IIUC the module lock
doesn't help here.
Powered by blists - more mailing lists