Re: [RFC PATCH v3 09/11] KVM: Add new members to struct kvm_gfn_range to operate on

From: Sean Christopherson
Date: Thu Jul 13 2023 - 18:10:21 EST


+Yu

On Wed, Jun 28, 2023, isaku.yamahata@xxxxxxxxx wrote:
> void kvm_mmu_init_memslot_memory_attributes(struct kvm *kvm,
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 1a47cedae8a1..5ca0c8ee4292 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -260,7 +260,13 @@ struct kvm_gfn_range {
> struct kvm_memory_slot *slot;
> gfn_t start;
> gfn_t end;
> - pte_t pte;
> + union {
> + unsigned long attributes;
> + pte_t pte;
> + unsigned long callback_arg; /* needs a better name */
> + };

Making the union needs to be done in a separate patch. And coming back to this
with fresh eyes, I think it makes sense to give the union a name. I think an
anonymous union is actually worse in the long run, and there aren't _that_ many
instances to update. E.g. that way a single build-time assertion can capture
all uses, and it makes it more obvious that the usage is poking into a union.

I'll post a patch separately so that it can be picked up for the MGLRU series
(and maybe even merged ahead of both).