On Thu, Jul 6, 2023 at 10:34 AM Isaku Yamahata <isaku.yamahata@xxxxxxxxx> wrote: > > On Tue, Jul 04, 2023 at 04:50:47PM +0900, > David Stevens <stevensd@xxxxxxxxxxxx> wrote: > > > From: David Stevens <stevensd@xxxxxxxxxxxx> > > > > Introduce __kvm_follow_pfn, which will replace __gfn_to_pfn_memslot. > > __kvm_follow_pfn refactors the old API's arguments into a struct and, > > where possible, combines the boolean arguments into a single flags > > argument. > > > > Signed-off-by: David Stevens <stevensd@xxxxxxxxxxxx> > > --- > > include/linux/kvm_host.h | 16 ++++ > > virt/kvm/kvm_main.c | 171 ++++++++++++++++++++++----------------- > > virt/kvm/kvm_mm.h | 3 +- > > virt/kvm/pfncache.c | 8 +- > > 4 files changed, 122 insertions(+), 76 deletions(-) > > > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 9d3ac7720da9..ef2763c2b12e 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -97,6 +97,7 @@ > > #define KVM_PFN_ERR_HWPOISON (KVM_PFN_ERR_MASK + 1) > > #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) > > #define KVM_PFN_ERR_SIGPENDING (KVM_PFN_ERR_MASK + 3) > > +#define KVM_PFN_ERR_NEEDS_IO (KVM_PFN_ERR_MASK + 4) > > > > /* > > * error pfns indicate that the gfn is in slot but faild to > > @@ -1156,6 +1157,21 @@ unsigned long gfn_to_hva_memslot_prot(struct kvm_memory_slot *slot, gfn_t gfn, > > void kvm_release_page_clean(struct page *page); > > void kvm_release_page_dirty(struct page *page); > > > > +struct kvm_follow_pfn { > > + const struct kvm_memory_slot *slot; > > + gfn_t gfn; > > + unsigned int flags; > > + bool atomic; > > + /* Allow a read fault to create a writeable mapping. */ > > + bool allow_write_mapping; > > Maybe, make them const for input arguments? Unfortunately using const isn't straightforward as long as the kernel continues to use -Wdeclaration-after-statement. If these fields were const, then they would need to be specified in the initializer when declaring the variable, but that's not necessarily always possible. -David