[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <966b1f45-ba5d-febd-e365-29308a9a59b4@intel.com>
Date: Thu, 28 Apr 2022 17:26:52 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Kai Huang <kai.huang@...el.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: seanjc@...gle.com, pbonzini@...hat.com, len.brown@...el.com,
tony.luck@...el.com, rafael.j.wysocki@...el.com,
reinette.chatre@...el.com, dan.j.williams@...el.com,
peterz@...radead.org, ak@...ux.intel.com,
kirill.shutemov@...ux.intel.com,
sathyanarayanan.kuppuswamy@...ux.intel.com,
isaku.yamahata@...el.com
Subject: Re: [PATCH v3 04/21] x86/virt/tdx: Add skeleton for detecting and
initializing TDX on demand
On 4/28/22 17:11, Kai Huang wrote:
> This is true. So I think w/o taking the lock is also fine, as the TDX module
> initialization is a state machine. If any cpu goes offline during logical-cpu
> level initialization and TDH.SYS.LP.INIT isn't done on that cpu, then later the
> TDH.SYS.CONFIG will fail. Similarly, if any cpu going offline causes
> TDH.SYS.KEY.CONFIG is not done for any package, then TDH.SYS.TDMR.INIT will
> fail.
Right. The worst-case scenario is someone is mucking around with CPU
hotplug during TDX initialization is that TDX initialization will fail.
We *can* fix some of this at least and provide coherent error messages
with a pattern like this:
cpus_read_lock();
// check that all MADT-enumerated CPUs are online
tdx_init();
cpus_read_unlock();
That, of course, *does* prevent CPUs from going offline during
tdx_init(). It also provides a nice place for an error message:
pr_warn("You offlined a CPU then want to use TDX? Sod off.\n");
> A problem (I realized it exists in current implementation too) is shutting down
> the TDX module, which requires calling TDH.SYS.LP.SHUTDOWN on all BIOS-enabled
> cpus. Kernel can do this SEAMCALL at most for all present cpus. However when
> any cpu is offline, this SEAMCALL won't be called on it, and it seems we need to
> add new CPU hotplug callback to call this SEAMCALL when the cpu is online again.
Hold on a sec. If you call TDH.SYS.LP.SHUTDOWN on any CPU, then TDX
stops working everywhere, right? But, if someone offlines one CPU, we
don't want TDX to stop working everywhere.
Powered by blists - more mailing lists