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

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.org


Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
parent a4bff3df
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ bool kvm_gpc_check(struct gfn_to_pfn_cache *gpc, unsigned long len)
	if (!gpc->active)
		return false;

	if ((gpc->gpa & ~PAGE_MASK) + len > PAGE_SIZE)
	if (offset_in_page(gpc->gpa) + len > PAGE_SIZE)
		return false;

	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)

	gpc->valid = true;
	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
@@ -213,7 +213,7 @@ static int __kvm_gpc_refresh(struct gfn_to_pfn_cache *gpc, gpa_t gpa,
			     unsigned long len)
{
	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;
	unsigned long old_uhva;
	kvm_pfn_t old_pfn;