Re: [PATCH v19 058/130] KVM: x86/mmu: Add a private pointer to struct kvm_mmu_page
From: Isaku Yamahata
Date: Mon Apr 22 2024 - 13:30:26 EST
On Mon, Apr 22, 2024 at 11:34:18AM +0800,
Yan Zhao <yan.y.zhao@xxxxxxxxx> wrote:
> On Mon, Feb 26, 2024 at 12:26:00AM -0800, isaku.yamahata@xxxxxxxxx wrote:
> > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx>
> > +static inline void *kvm_mmu_private_spt(struct kvm_mmu_page *sp)
> > +{
> > + return sp->private_spt;
> > +}
> > +
> > +static inline void kvm_mmu_init_private_spt(struct kvm_mmu_page *sp, void *private_spt)
> > +{
> > + sp->private_spt = private_spt;
> > +}
> This function is actually not used for initialization.
> Instead, it's only called after failure of free_private_spt() in order to
> intentionally leak the page to prevent kernel from accessing the encrypted page.
>
> So to avoid confusion, how about renaming it to kvm_mmu_leak_private_spt() and
> always resetting the pointer to NULL?
>
> static inline void kvm_mmu_leak_private_spt(struct kvm_mmu_page *sp)
> {
> sp->private_spt = NULL;
> }
The older version had a config to disable TDX TDP MMU at a compile time. Now
we dropped the config so that we don't necessarily need wrapper function with
#ifdef. Now we have only single caller, I'll eliminate this wrapper function
(and related wrapper functions) by open code.
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>