Re: [RFC PATCH v11 08/29] KVM: Introduce per-page memory attributes

From: Sean Christopherson
Date: Thu Jul 20 2023 - 16:21:37 EST


On Thu, Jul 20, 2023, Isaku Yamahata wrote:
> On Thu, Jul 20, 2023 at 04:09:12PM +0800,
> Yuan Yao <yuan.yao@xxxxxxxxxxxxxxx> wrote:
>
> > On Tue, Jul 18, 2023 at 04:44:51PM -0700, Sean Christopherson wrote:
> > > @@ -2301,4 +2305,14 @@ static inline void kvm_account_pgtable_pages(void *virt, int nr)
> > > /* Max number of entries allowed for each kvm dirty ring */
> > > #define KVM_DIRTY_RING_MAX_ENTRIES 65536
> > >
> > > +#ifdef CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES
> > > +static inline unsigned long kvm_get_memory_attributes(struct kvm *kvm, gfn_t gfn)
> > > +{
> > > + return xa_to_value(xa_load(&kvm->mem_attr_array, gfn));
> > > +}
> > > +
> > > +bool kvm_arch_post_set_memory_attributes(struct kvm *kvm,
> > > + struct kvm_gfn_range *range);
> >
> > Used but no definition in this patch, it's defined in next patch 09.
> > How about add weak version in this patch and let ARCHs to overide it ?
>
> It is guarded by CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES.

Yep. I don't love the ordering, e.g. this patch can't even be compile tested
until later in the series, but I wanted to separate x86 usage from the generic
support code.