Re: [PATCH v7 2/8] KVM: Introduce __kvm_follow_pfn function

2023-07-06 Thread Yu Zhang
On Thu, Jul 06, 2023 at 02:29:24PM +0900, David Stevens wrote: > On Wed, Jul 5, 2023 at 7:53 PM Yu Zhang wrote: > > > > On Wed, Jul 05, 2023 at 06:22:59PM +0900, David Stevens wrote: > > > On Wed, Jul 5, 2023 at 12:10 PM Yu Zhang > > > wrote: > > >

Re: [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn

2023-07-06 Thread Yu Zhang
On Thu, Jul 06, 2023 at 01:52:08PM +0900, David Stevens wrote: > On Wed, Jul 5, 2023 at 7:17 PM Yu Zhang wrote: > > > > On Tue, Jul 04, 2023 at 04:50:50PM +0900, David Stevens wrote: > > > From: David Stevens > > > > > > Stop passing FOLL_GET to __k

Re: [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn

2023-07-05 Thread Yu Zhang
> > @@ -883,7 +884,7 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, > > struct kvm_mmu *mmu, > > */ > > static int FNAME(sync_spte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page > > *sp, int i) > > { > > - bool host_writable; > > + bool host_writable, is_refcounted; > > gpa_t f

Re: [PATCH v7 3/8] KVM: Make __kvm_follow_pfn not imply FOLL_GET

2023-07-05 Thread Yu Zhang
On Tue, Jul 04, 2023 at 04:50:48PM +0900, David Stevens wrote: > From: David Stevens > > Make it so that __kvm_follow_pfn does not imply FOLL_GET. This allows > callers to resolve a gfn when the associated pfn has a valid struct page > that isn't being actively refcounted (e.g. tail pages of non-

Re: [PATCH v7 2/8] KVM: Introduce __kvm_follow_pfn function

2023-07-05 Thread Yu Zhang
On Wed, Jul 05, 2023 at 06:22:59PM +0900, David Stevens wrote: > On Wed, Jul 5, 2023 at 12:10 PM Yu Zhang wrote: > > > > > @@ -2514,35 +2512,26 @@ static bool hva_to_pfn_fast(unsigned long addr, > > > bool write_fault, > > > * The slow path to get the pfn o

Re: [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn

2023-07-05 Thread Yu Zhang
On Tue, Jul 04, 2023 at 04:50:50PM +0900, David Stevens wrote: > From: David Stevens > > Stop passing FOLL_GET to __kvm_follow_pfn. This allows the host to map > memory into the guest that is backed by un-refcounted struct pages - for > example, higher order non-compound pages allocated by the am

Re: [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn

2023-07-05 Thread Yu Zhang
On Tue, Jul 04, 2023 at 04:50:50PM +0900, David Stevens wrote: > From: David Stevens > > Stop passing FOLL_GET to __kvm_follow_pfn. This allows the host to map > memory into the guest that is backed by un-refcounted struct pages - for > example, higher order non-compound pages allocated by the am

Re: [PATCH v7 4/8] KVM: x86/mmu: Migrate to __kvm_follow_pfn

2023-07-05 Thread Yu Zhang
On Tue, Jul 04, 2023 at 04:50:49PM +0900, David Stevens wrote: > From: David Stevens > > Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. > > Signed-off-by: David Stevens > --- > arch/x86/kvm/mmu/mmu.c | 35 +-- > 1 file changed, 25 insertions(+), 10 delet

Re: [PATCH v7 3/8] KVM: Make __kvm_follow_pfn not imply FOLL_GET

2023-07-05 Thread Yu Zhang
> > +void kvm_set_page_accessed(struct page *page); > +void kvm_set_page_dirty(struct page *page); > + No one calls these 2 routines in this patch. How about move this change to [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn ? ... > @@ -2930,17 +2933,19 @@ static bool kvm_

Re: [PATCH v7 2/8] KVM: Introduce __kvm_follow_pfn function

2023-07-04 Thread Yu Zhang
> @@ -2514,35 +2512,26 @@ static bool hva_to_pfn_fast(unsigned long addr, bool > write_fault, > * The slow path to get the pfn of the specified host virtual address, > * 1 indicates success, -errno is returned if error is detected. > */ > -static int hva_to_pfn_slow(unsigned long addr, bool