[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176097601867.439156.11041449627994730588.b4-ty@google.com>
Date: Mon, 20 Oct 2025 09:33:03 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: guest_memfd: Define a CLASS to get+put guest_memfd
file from a memslot
On Tue, 07 Oct 2025 15:23:56 -0700, Sean Christopherson wrote:
> Add a CLASS to handle getting and putting a guest_memfd file given a
> memslot to reduce the amount of related boilerplate, and more importantly
> to minimize the chances of forgetting to put the file (thankfully the bug
> that prompted this didn't escape initial testing).
>
> Define a CLASS instead of using __free(fput) as _free() comes with subtle
> caveats related to FILO ordering (objects are freed in the order in which
> they are declared), and the recommended solution/workaround (declare file
> pointers exactly when they are initialized) is visually jarring relative
> to KVM's (and the kernel's) overall strict adherence to not mixing
> declarations and code. E.g. the use in kvm_gmem_populate() would be:
>
> [...]
Applied to kvm-x86 gmem, thanks!
[1/1] KVM: guest_memfd: Define a CLASS to get+put guest_memfd file from a memslot
https://github.com/kvm-x86/linux/commit/0bb4d9c39b76
--
https://github.com/kvm-x86/linux/tree/next
Powered by blists - more mailing lists