lkml.org 
[lkml]   [2020]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 07/14] KVM: x86/mmu: Walk host page tables to find THP mappings
From
Date
On 08/01/20 21:24, Sean Christopherson wrote:
> +
> + /*
> + * Manually do the equivalent of kvm_vcpu_gfn_to_hva() to avoid the
> + * "writable" check in __gfn_to_hva_many(), which will always fail on
> + * read-only memslots due to gfn_to_hva() assuming writes. Earlier
> + * page fault steps have already verified the guest isn't writing a
> + * read-only memslot.
> + */
> + slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
> + if (!memslot_valid_for_gpte(slot, true))
> + return PT_PAGE_TABLE_LEVEL;
> +
> + hva = __gfn_to_hva_memslot(slot, gfn);
> +

Using gfn_to_memslot_dirty_bitmap is also a good excuse to avoid
kvm_vcpu_gfn_to_hva.

+ slot = gfn_to_memslot_dirty_bitmap(vcpu, gfn, true);
+ if (!slot)
+ return PT_PAGE_TABLE_LEVEL;
+
+ hva = __gfn_to_hva_memslot(slot, gfn);

(I am planning to remove gfn_to_hva_memslot so that __gfn_to_hva_memslot
can lose the annoying underscores).

Paolo

\
 
 \ /
  Last update: 2020-01-21 15:40    [W:0.168 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site