Re: [PATCH v7 5/8] KVM: x86/mmu: Don't pass FOLL_GET to __kvm_follow_pfn
From: David Stevens <hidden>
Date: 2023-07-11 02:59:34
Also in:
kvm, kvmarm, linuxppc-dev, lkml
On Tue, Jul 11, 2023 at 1:34 AM Isaku Yamahata [off-list ref] wrote:
On Fri, Jul 07, 2023 at 10:35:02AM +0900, David Stevens [off-list ref] wrote:quoted
quoted
quoted
quoted
quoted
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index e44ab512c3a1..b1607e314497 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c...quoted
@@ -2937,6 +2943,7 @@ static int mmu_set_spte(struct kvm_vcpu *vcpu, struct kvm_memory_slot *slot, bool host_writable = !fault || fault->map_writable; bool prefetch = !fault || fault->prefetch; bool write_fault = fault && fault->write; + bool is_refcounted = !fault || fault->is_refcounted_page;Just wonder, what if a non-refcounted page is prefetched? Or is it possible in practice?Prefetching is still done via gfn_to_page_many_atomic, which sets FOLL_GET. That's fixable, but it's not something this series currently does.So if we prefetch a page, REFCOUNTED bit is cleared unconditionally with this hunk. kvm_set_page_{dirty, accessed} won't be called as expected for prefetched spte. If I read the patch correctly, REFCOUNTED bit in SPTE should represent whether the corresponding page is ref-countable or not, right? Because direct_pte_prefetch_many() is for legacy KVM MMU and FNAME(prefetch_pte) is shadow paging, we need to test it with legacy KVM MMU or shadow paging to hit the issue, though.direct_pte_prefetch_many and prefetch_gpte both pass NULL for the fault parameter, so is_refcounted will evaluate to true. So the spte's refcounted bit will get set in that case.Oops, my bad. My point is "unconditionally". Is the bit always set for non-refcountable pages? Or non-refcountable pages are not prefeched?
The bit is never set for non-refcounted pages, and is always set for refcounted pages. The current series never prefetches non-refcounted pages, since it continues to use the gfn_to_page_many_atomic API. -David _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel