Skip to content

Commit

Permalink
Drivers: hv: vmbus: Always use HV_HYP_PAGE_SIZE for gpadl
Browse files Browse the repository at this point in the history
Since the hypervisor always uses 4K as its page size, the size of PFNs
used for gpadl should be HV_HYP_PAGE_SIZE rather than PAGE_SIZE, so
adjust this accordingly as the preparation for supporting 16K/64K page
size guests. No functional changes on x86, since PAGE_SIZE is always 4k
(equals to HV_HYP_PAGE_SIZE).

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20200916034817.30282-2-boqun.feng@gmail.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
  • Loading branch information
Boqun Feng authored and Wei Liu committed Sep 28, 2020
1 parent 49971e6 commit a5dda20
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions drivers/hv/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

#include "hyperv_vmbus.h"

#define NUM_PAGES_SPANNED(addr, len) \
((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT))

static unsigned long virt_to_hvpfn(void *addr)
{
phys_addr_t paddr;
Expand All @@ -35,7 +32,7 @@ static unsigned long virt_to_hvpfn(void *addr)
else
paddr = __pa(addr);

return paddr >> PAGE_SHIFT;
return paddr >> HV_HYP_PAGE_SHIFT;
}

/*
Expand Down Expand Up @@ -330,7 +327,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,

int pfnsum, pfncount, pfnleft, pfncurr, pfnsize;

pagecount = size >> PAGE_SHIFT;
pagecount = size >> HV_HYP_PAGE_SHIFT;

/* do we need a gpadl body msg */
pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
Expand Down Expand Up @@ -360,7 +357,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
gpadl_header->range[0].byte_count = size;
for (i = 0; i < pfncount; i++)
gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn(
kbuffer + PAGE_SIZE * i);
kbuffer + HV_HYP_PAGE_SIZE * i);
*msginfo = msgheader;

pfnsum = pfncount;
Expand Down Expand Up @@ -412,7 +409,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
*/
for (i = 0; i < pfncurr; i++)
gpadl_body->pfn[i] = virt_to_hvpfn(
kbuffer + PAGE_SIZE * (pfnsum + i));
kbuffer + HV_HYP_PAGE_SIZE * (pfnsum + i));

/* add to msg header */
list_add_tail(&msgbody->msglistentry,
Expand Down Expand Up @@ -441,7 +438,7 @@ static int create_gpadl_header(void *kbuffer, u32 size,
gpadl_header->range[0].byte_count = size;
for (i = 0; i < pagecount; i++)
gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn(
kbuffer + PAGE_SIZE * i);
kbuffer + HV_HYP_PAGE_SIZE * i);

*msginfo = msgheader;
}
Expand Down

0 comments on commit a5dda20

Please sign in to comment.