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

2023-09-05 Thread David Stevens
On Wed, Sep 6, 2023 at 9:45 AM Sean Christopherson wrote: > > On Tue, Sep 05, 2023, David Stevens wrote: > > On Wed, Jul 12, 2023 at 7:00 AM Sean Christopherson > > wrote: > > > > > > On Tue, Jul 11, 2023, Zhi Wang wrote: > > > > On Thu, 6 Jul

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

2023-09-05 Thread David Stevens
On Wed, Jul 12, 2023 at 7:00 AM Sean Christopherson wrote: > > On Tue, Jul 11, 2023, Zhi Wang wrote: > > On Thu, 6 Jul 2023 15:49:39 +0900 > > David Stevens wrote: > > > > > On Wed, Jul 5, 2023 at 10:19___PM Zhi Wang > > > wrote: > > > > &g

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

2023-08-24 Thread David Stevens
On Fri, Aug 25, 2023 at 12:15 AM Sean Christopherson wrote: > > On Thu, Aug 24, 2023, David Stevens wrote: > > On Wed, Jul 5, 2023 at 7:25 PM Yu Zhang wrote: > > > > > > On Tue, Jul 04, 2023 at 04:50:50PM +0900, David Stevens wrote: > > > > @@ -4529,7 +4

[PATCH v8 0/8] KVM: allow mapping non-refcounted pages

2023-08-24 Thread David Stevens
From: David Stevens This patch series adds support for mapping VM_IO and VM_PFNMAP memory that is backed by struct pages that aren't currently being refcounted (e.g. tail pages of non-compound higher order allocations) into the guest. Our use case is virtio-gpu blob resources [1], which

[PATCH v8 8/8] KVM: mmu: remove __gfn_to_pfn_memslot

2023-08-24 Thread David Stevens
From: David Stevens All callers have been migrated to __kvm_follow_pfn. Signed-off-by: David Stevens --- virt/kvm/kvm_main.c | 33 - 1 file changed, 33 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index fa1848c6c84f..aebaf4a7340e 100644

[PATCH v8 7/8] KVM: PPC: Migrate to __kvm_follow_pfn

2023-08-24 Thread David Stevens
From: David Stevens Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. As part of the refactoring, remove the redundant calls to get_user_page_fast_only, since the check for !async && !atomic was removed from the KVM generic code in b9b33da2aa74. Also, remove the kvm_ro parameter

[PATCH v8 6/8] KVM: arm64: Migrate to __kvm_follow_pfn

2023-08-24 Thread David Stevens
From: David Stevens Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. Signed-off-by: David Stevens --- arch/arm64/kvm/mmu.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index d3b4feed460c

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

2023-08-24 Thread David Stevens
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, the tail pages of higher order non-compound pages allocated by the amdgpu driver via ttm_pool_alloc_page. The bulk

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

2023-08-24 Thread David Stevens
From: David Stevens Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. Most arguments directly map to the new API. The largest change is replacing the async in/out parameter with FOLL_NOWAIT parameter and the KVM_PFN_ERR_NEEDS_IO return value. Signed-off-by: David Stevens --- arch/x86/kvm

[PATCH v8 3/8] KVM: mmu: Make __kvm_follow_pfn not imply FOLL_GET

2023-08-24 Thread David Stevens
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-compound higher order pages). For a caller to safely omit FOLL_GET, all

[PATCH v8 2/8] KVM: mmu: Introduce __kvm_follow_pfn function

2023-08-24 Thread David Stevens
From: David Stevens 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 --- include/linux/kvm_host.h

[PATCH v8 1/8] KVM: Assert that a page's refcount is elevated when marking accessed/dirty

2023-08-24 Thread David Stevens
From: Sean Christopherson Assert that a page's refcount is elevated, i.e. that _something_ holds a reference to the page, when KVM marks a page as accessed and/or dirty. KVM typically doesn't hold a reference to pages that are mapped into the guest, e.g. to allow page migration, compaction,

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

2023-08-24 Thread David Stevens
On Wed, Jul 5, 2023 at 7:25 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 __kvm_follow_pfn. This allows the host to map > > memory into the guest that is backed

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

2023-08-24 Thread David Stevens
On Thu, Jul 6, 2023 at 10:54 AM Isaku Yamahata wrote: > > 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

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

2023-07-19 Thread David Stevens
On Wed, Jul 19, 2023 at 3:35 PM Yan Zhao wrote: > > On Tue, Jul 04, 2023 at 04:50:50PM +0900, David Stevens wrote: > > @@ -4451,7 +4461,8 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, > > struct kvm_page_fault *fault > > > > out_unlock: > &g

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

2023-07-10 Thread David Stevens
On Tue, Jul 11, 2023 at 1:34 AM Isaku Yamahata wrote: > > On Fri, Jul 07, 2023 at 10:35:02AM +0900, > David Stevens wrote: > > > > > > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > > > > > > index e44ab512c3a1..b1607e314497

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

2023-07-06 Thread David Stevens
On Fri, Jul 7, 2023 at 12:58 AM Isaku Yamahata wrote: > > 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 Steven

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

2023-07-06 Thread David Stevens
On Wed, Jul 5, 2023 at 10:19 PM Zhi Wang wrote: > > On Tue, 4 Jul 2023 16:50:48 +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 as

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

2023-07-06 Thread David Stevens
On Wed, Jul 5, 2023 at 8:56 PM Yu Zhang wrote: > > 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 associat

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

2023-07-05 Thread David Stevens
On Thu, Jul 6, 2023 at 10:34 AM Isaku Yamahata wrote: > > On Tue, Jul 04, 2023 at 04:50:47PM +0900, > David Stevens wrote: > > > From: David Stevens > > > > Introduce __kvm_follow_pfn, which will replace __gfn_to_pfn_memslot. > > __kvm_follow_pfn refactors t

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

2023-07-05 Thread David Stevens
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: > > > > > > > @@ -2514,35 +2512,26 @@ static bool hva_to_pfn_fast(unsigned lon

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

2023-07-05 Thread David Stevens
On Thu, Jul 6, 2023 at 11:10 AM Isaku Yamahata wrote: > > On Tue, Jul 04, 2023 at 04:50:50PM +0900, > David Stevens wrote: > > > diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c > > index cf2c6426a6fc..46c681dc45e6 100644 > > --- a/arch/x86/kvm/mmu/spt

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

2023-07-05 Thread David Stevens
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 __kvm_follow_pfn. This allows the host to map > > memory into the guest that is backed

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

2023-07-05 Thread David Stevens
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 of the specified host virtual address, > > * 1 indicates success, -errno is returned if error is detected. >

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

2023-07-05 Thread David Stevens
On Wed, Jul 5, 2023 at 5:47 PM Zhi Wang wrote: > > On Tue, 4 Jul 2023 16:50:47 +0900 > David Stevens wrote: > > > From: David Stevens > > > > Introduce __kvm_follow_pfn, which will replace __gfn_to_pfn_memslot. > > __kvm_follow_pfn refactors the old API's ar

[PATCH v7 8/8] KVM: remove __gfn_to_pfn_memslot

2023-07-04 Thread David Stevens
From: David Stevens All callers have been migrated to __kvm_follow_pfn. Signed-off-by: David Stevens --- virt/kvm/kvm_main.c | 33 - 1 file changed, 33 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 0f7b41f220b6..5b5afd70f239 100644

[PATCH v7 7/8] KVM: PPC: Migrate to __kvm_follow_pfn

2023-07-04 Thread David Stevens
From: David Stevens Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. As part of the refactoring, remove the redundant calls to get_user_page_fast_only, since the check for !async && !atomic was removed from the KVM generic code in b9b33da2aa74. Also, remove the kvm_ro parameter

[PATCH v7 6/8] KVM: arm64: Migrate to __kvm_follow_pfn

2023-07-04 Thread David Stevens
From: David Stevens Migrate from __gfn_to_pfn_memslot to __kvm_follow_pfn. Signed-off-by: David Stevens --- arch/arm64/kvm/mmu.c | 25 ++--- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 6db9ef288ec3

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

2023-07-04 Thread David Stevens
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 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index

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

2023-07-04 Thread David Stevens
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 amdgpu driver via ttm_pool_alloc_page. The bulk of this change

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

2023-07-04 Thread David Stevens
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-compound higher order pages). For a caller to safely omit FOLL_GET, all

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

2023-07-04 Thread David Stevens
From: David Stevens 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 --- include/linux/kvm_host.h

[PATCH v7 1/8] KVM: Assert that a page's refcount is elevated when marking accessed/dirty

2023-07-04 Thread David Stevens
From: Sean Christopherson Assert that a page's refcount is elevated, i.e. that _something_ holds a reference to the page, when KVM marks a page as accessed and/or dirty. KVM typically doesn't hold a reference to pages that are mapped into the guest, e.g. to allow page migration, compaction,

[PATCH v7 0/8] KVM: allow mapping non-refcounted pages

2023-07-04 Thread David Stevens
From: David Stevens This patch series adds support for mapping VM_IO and VM_PFNMAP memory that is backed by struct pages that aren't currently being refcounted (e.g. tail pages of non-compound higher order allocations) into the guest. Our use case is virtio-gpu blob resources [1], which

[PATCH v2 5/5] KVM: mmu: remove over-aggressive warnings

2021-06-25 Thread David Stevens
From: David Stevens Remove two warnings that require ref counts for pages to be non-zero, as mapped pfns from follow_pfn may not have an initialized ref count. Signed-off-by: David Stevens --- arch/x86/kvm/mmu/mmu.c | 7 --- virt/kvm/kvm_main.c| 2 +- 2 files changed, 1 insertion

[PATCH v2 4/5] KVM: arm64/mmu: use gfn_to_pfn_page

2021-06-25 Thread David Stevens
From: David Stevens Covert usages of the deprecated gfn_to_pfn functions to the new gfn_to_pfn_page functions. Signed-off-by: David Stevens --- arch/arm64/kvm/mmu.c | 26 -- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch

[PATCH v2 3/5] KVM: x86/mmu: use gfn_to_pfn_page

2021-06-25 Thread David Stevens
From: David Stevens Covert usages of the deprecated gfn_to_pfn functions to the new gfn_to_pfn_page functions. Signed-off-by: David Stevens --- arch/x86/kvm/mmu/mmu.c | 43 - arch/x86/kvm/mmu/mmu_internal.h | 3 ++- arch/x86/kvm/mmu/paging_tmpl.h

[PATCH v2 2/5] KVM: mmu: introduce new gfn_to_pfn_page functions

2021-06-25 Thread David Stevens
From: David Stevens Introduce new gfn_to_pfn_page functions that parallel existing gfn_to_pfn functions. The new functions are identical except they take an additional out parameter that is used to return the struct page if the hva was resolved by gup. This allows callers to differentiate

[PATCH v2 1/5] KVM: do not allow mapping valid but non-refcounted pages

2021-06-25 Thread David Stevens
From: Nicholas Piggin It's possible to create a region which maps valid but non-refcounted pages (e.g., tail pages of non-compound higher order allocations). These host pages can then be returned by gfn_to_page, gfn_to_pfn, etc., family of APIs, which take a reference to the page, which takes it

[PATCH v2 0/5] Remove uses of struct page from x86 and arm64 MMU

2021-06-25 Thread David Stevens
ges to mmu_audit.c - Include Nicholas Piggin's patch to avoid corrupting refcount in the follow_pte case, and use it in depreciated gfn_to_pfn functions. - Rebase on kvm/next David Stevens (4): KVM: mmu: introduce new gfn_to_pfn_page functions KVM: x86/mmu: use gfn_to_pfn_page KVM: arm64/

Re: [PATCH 6/6] drm/i915/gvt: use gfn_to_pfn's page instead of pfn

2021-06-23 Thread David Stevens
Please ignore this last patch. It was put together as an afterthought and wasn't properly tested. -David On Thu, Jun 24, 2021 at 12:59 PM David Stevens wrote: > > Return struct page instead of pfn from gfn_to_mfn. This function is only > used to determine if the page is a transparent

[PATCH 6/6] drm/i915/gvt: use gfn_to_pfn's page instead of pfn

2021-06-23 Thread David Stevens
the reference on the page returned by gfn_to_pfn. Signed-off-by: David Stevens --- drivers/gpu/drm/i915/gvt/gtt.c | 12 drivers/gpu/drm/i915/gvt/hypercall.h | 3 ++- drivers/gpu/drm/i915/gvt/kvmgt.c | 12 drivers/gpu/drm/i915/gvt/mpt.h | 8 4 files

[PATCH 5/6] KVM: mmu: remove over-aggressive warnings

2021-06-23 Thread David Stevens
From: David Stevens Remove two warnings that require ref counts for pages to be non-zero, as mapped pfns from follow_pfn may not have an initialized ref count. Signed-off-by: David Stevens --- arch/x86/kvm/mmu/mmu.c | 7 --- virt/kvm/kvm_main.c| 2 +- 2 files changed, 1 insertion

[PATCH 4/6] KVM: arm64/mmu: avoid struct page in MMU

2021-06-23 Thread David Stevens
From: David Stevens Avoid converting pfns returned by follow_fault_pfn to struct pages to transiently take a reference. The reference was originally taken to match the reference taken by gup. However, pfns returned by follow_fault_pfn may not have a struct page set up for reference counting

[PATCH 3/6] KVM: x86/mmu: avoid struct page in MMU

2021-06-23 Thread David Stevens
From: David Stevens Avoid converting pfns returned by follow_fault_pfn to struct pages to transiently take a reference. The reference was originally taken to match the reference taken by gup. However, pfns returned by follow_fault_pfn may not have a struct page set up for reference counting

[PATCH 2/6] KVM: mmu: also return page from gfn_to_pfn

2021-06-23 Thread David Stevens
From: David Stevens Return a struct kvm_pfn_page containing both a pfn and an optional struct page from the gfn_to_pfn family of functions. This differentiates the gup and follow_fault_pfn cases, which allows callers that only need a pfn to avoid touching the page struct in the latter case

[PATCH 1/6] KVM: x86/mmu: release audited pfns

2021-06-23 Thread David Stevens
From: David Stevens Signed-off-by: David Stevens --- arch/x86/kvm/mmu/mmu_audit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu_audit.c b/arch/x86/kvm/mmu/mmu_audit.c index cedc17b2f60e..97ff184084b4 100644 --- a/arch/x86/kvm/mmu/mmu_audit.c +++ b/arch/x86/kvm/mmu

[PATCH 0/6] KVM: Remove uses of struct page from x86 and arm64 MMU

2021-06-23 Thread David Stevens
and arm64. David Stevens (6): KVM: x86/mmu: release audited pfns KVM: mmu: also return page from gfn_to_pfn KVM: x86/mmu: avoid struct page in MMU KVM: arm64/mmu: avoid struct page in MMU KVM: mmu: remove over-aggressive warnings drm/i915/gvt: use gfn_to_pfn's page instead of pfn arch

Re: RFC: issues concerning the next NAPI interface

2007-08-24 Thread David Stevens
Stephen Hemminger [EMAIL PROTECTED] wrote on 08/24/2007 08:52:03 AM: You need hardware support for deferred interrupts. Most devices have it (e1000, sky2, tg3) and it interacts well with NAPI. It is not a generic thing you want done by the stack, you want the hardware to hold off