[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <fcab24b9-0573-9165-20e9-683586e86bdf@redhat.com>
Date: Mon, 2 Aug 2021 15:40:08 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Hamza Mahfooz <someguy@...ective-light.com>,
linux-kernel@...r.kernel.org
Cc: Peter Xu <peterx@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
kvm@...r.kernel.org
Subject: Re: [PATCH v2] KVM: const-ify all relevant uses of struct
kvm_memory_slot
On 31/07/21 00:27, Hamza Mahfooz wrote:
> @@ -1440,7 +1440,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
>
> struct slot_rmap_walk_iterator {
> /* input fields. */
> - struct kvm_memory_slot *slot;
> + const struct kvm_memory_slot *slot;
> gfn_t start_gfn;
> gfn_t end_gfn;
> int start_level;
> @@ -1467,16 +1467,20 @@ rmap_walk_init_level(struct slot_rmap_walk_iterator *iterator, int level)
>
> static void
> slot_rmap_walk_init(struct slot_rmap_walk_iterator *iterator,
> - struct kvm_memory_slot *slot, int start_level,
> + const struct kvm_memory_slot *slot, int start_level,
> int end_level, gfn_t start_gfn, gfn_t end_gfn)
> {
> - iterator->slot = slot;
> - iterator->start_level = start_level;
> - iterator->end_level = end_level;
> - iterator->start_gfn = start_gfn;
> - iterator->end_gfn = end_gfn;
> + struct slot_rmap_walk_iterator iter = {
> + .slot = slot,
> + .start_gfn = start_gfn,
> + .end_gfn = end_gfn,
> + .start_level = start_level,
> + .end_level = end_level
> + };
> +
> + rmap_walk_init_level(&iter, start_level);
>
> - rmap_walk_init_level(iterator, iterator->start_level);
> + memcpy(iterator, &iter, sizeof(struct slot_rmap_walk_iterator));
> }
>
> static bool slot_rmap_walk_okay(struct slot_rmap_walk_iterator *iterator)
I don't understand, just changing the argument works. There is no need
to change the body of the function.
Paolo
Powered by blists - more mailing lists