Commit 53e63e95 authored by Paul Durrant's avatar Paul Durrant Committed by Sean Christopherson

KVM: pfncache: stop open-coding offset_in_page()

Some code in pfncache uses offset_in_page() but in other places it is open-
coded. Use offset_in_page() consistently everywhere.
Signed-off-by: default avatarPaul Durrant <pdurrant@amazon.com>
Reviewed-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Link: https://lore.kernel.org/r/20240215152916.1158-7-paul@xen.orgSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
parent a4bff3df
...@@ -48,7 +48,7 @@ bool kvm_gpc_check(struct gfn_to_pfn_cache *gpc, unsigned long len) ...@@ -48,7 +48,7 @@ bool kvm_gpc_check(struct gfn_to_pfn_cache *gpc, unsigned long len)
if (!gpc->active) if (!gpc->active)
return false; return false;
if ((gpc->gpa & ~PAGE_MASK) + len > PAGE_SIZE) if (offset_in_page(gpc->gpa) + len > PAGE_SIZE)
return false; return false;
if (gpc->generation != slots->generation || kvm_is_error_hva(gpc->uhva)) if (gpc->generation != slots->generation || kvm_is_error_hva(gpc->uhva))
...@@ -192,7 +192,7 @@ static kvm_pfn_t hva_to_pfn_retry(struct gfn_to_pfn_cache *gpc) ...@@ -192,7 +192,7 @@ static kvm_pfn_t hva_to_pfn_retry(struct gfn_to_pfn_cache *gpc)
gpc->valid = true; gpc->valid = true;
gpc->pfn = new_pfn; gpc->pfn = new_pfn;
gpc->khva = new_khva + (gpc->gpa & ~PAGE_MASK); gpc->khva = new_khva + offset_in_page(gpc->gpa);
/* /*
* Put the reference to the _new_ pfn. The pfn is now tracked by the * Put the reference to the _new_ pfn. The pfn is now tracked by the
...@@ -213,7 +213,7 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *gpc, gpa_t gpa, ...@@ -213,7 +213,7 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *gpc, gpa_t gpa,
unsigned long len) unsigned long len)
{ {
struct kvm_memslots *slots = kvm_memslots(gpc->kvm); struct kvm_memslots *slots = kvm_memslots(gpc->kvm);
unsigned long page_offset = gpa & ~PAGE_MASK; unsigned long page_offset = offset_in_page(gpa);
bool unmap_old = false; bool unmap_old = false;
unsigned long old_uhva; unsigned long old_uhva;
kvm_pfn_t old_pfn; kvm_pfn_t old_pfn;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment