Re: [RFC PATCH v5 020/104] KVM: TDX: allocate per-package mutex

From: Isaku Yamahata
Date: Thu Apr 07 2022 - 20:44:44 EST


On Tue, Apr 05, 2022 at 02:39:51PM +0200,
Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:

> On 3/4/22 20:48, isaku.yamahata@xxxxxxxxx wrote:
> > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> >
> > Several TDX SEAMCALLs are per-package scope (concretely per memory
> > controller) and they need to be serialized per-package. Allocate mutex for
> > it.
> >
> > Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> > ---
> > arch/x86/kvm/vmx/main.c | 8 +++++++-
> > arch/x86/kvm/vmx/tdx.c | 18 ++++++++++++++++++
> > arch/x86/kvm/vmx/x86_ops.h | 2 ++
> > 3 files changed, 27 insertions(+), 1 deletion(-)
>
> Please define here the lock/unlock functions as well:
>
> static inline int tdx_mng_key_lock(void)
> {
> int cpu = get_cpu();
> cur_pkg = topology_physical_package_id(cpu);
>
> mutex_lock(&tdx_mng_key_config_lock[cur_pkg]);
> return cur_pkg;
> }
>
> static inline void tdx_mng_key_unlock(int cur_pkg)
> {
> mutex_unlock(&tdx_mng_key_config_lock[cur_pkg]);
> put_cpu();
> }

Sure, will do in the next respoin.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>