|
29 | 29 | #include <linux/hyperv.h>
|
30 | 30 | #include <linux/uio.h>
|
31 | 31 | #include <linux/interrupt.h>
|
| 32 | +#include <asm/page.h> |
32 | 33 |
|
33 | 34 | #include "hyperv_vmbus.h"
|
34 | 35 |
|
35 | 36 | #define NUM_PAGES_SPANNED(addr, len) \
|
36 | 37 | ((PAGE_ALIGN(addr + len) >> PAGE_SHIFT) - (addr >> PAGE_SHIFT))
|
37 | 38 |
|
| 39 | +static unsigned long virt_to_hvpfn(void *addr) |
| 40 | +{ |
| 41 | + unsigned long paddr; |
| 42 | + |
| 43 | + if (is_vmalloc_addr(addr)) |
| 44 | + paddr = page_to_phys(vmalloc_to_page(addr)) + |
| 45 | + offset_in_page(addr); |
| 46 | + else |
| 47 | + paddr = __pa(addr); |
| 48 | + |
| 49 | + return paddr >> PAGE_SHIFT; |
| 50 | +} |
| 51 | + |
38 | 52 | /*
|
39 | 53 | * vmbus_setevent- Trigger an event notification on the specified
|
40 | 54 | * channel.
|
@@ -298,8 +312,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
|
298 | 312 | gpadl_header->range[0].byte_offset = 0;
|
299 | 313 | gpadl_header->range[0].byte_count = size;
|
300 | 314 | for (i = 0; i < pfncount; i++)
|
301 |
| - gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( |
302 |
| - kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; |
| 315 | + gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn( |
| 316 | + kbuffer + PAGE_SIZE * i); |
303 | 317 | *msginfo = msgheader;
|
304 | 318 |
|
305 | 319 | pfnsum = pfncount;
|
@@ -350,9 +364,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
|
350 | 364 | * so the hypervisor guarantees that this is ok.
|
351 | 365 | */
|
352 | 366 | for (i = 0; i < pfncurr; i++)
|
353 |
| - gpadl_body->pfn[i] = slow_virt_to_phys( |
354 |
| - kbuffer + PAGE_SIZE * (pfnsum + i)) >> |
355 |
| - PAGE_SHIFT; |
| 367 | + gpadl_body->pfn[i] = virt_to_hvpfn( |
| 368 | + kbuffer + PAGE_SIZE * (pfnsum + i)); |
356 | 369 |
|
357 | 370 | /* add to msg header */
|
358 | 371 | list_add_tail(&msgbody->msglistentry,
|
@@ -380,8 +393,8 @@ static int create_gpadl_header(void *kbuffer, u32 size,
|
380 | 393 | gpadl_header->range[0].byte_offset = 0;
|
381 | 394 | gpadl_header->range[0].byte_count = size;
|
382 | 395 | for (i = 0; i < pagecount; i++)
|
383 |
| - gpadl_header->range[0].pfn_array[i] = slow_virt_to_phys( |
384 |
| - kbuffer + PAGE_SIZE * i) >> PAGE_SHIFT; |
| 396 | + gpadl_header->range[0].pfn_array[i] = virt_to_hvpfn( |
| 397 | + kbuffer + PAGE_SIZE * i); |
385 | 398 |
|
386 | 399 | *msginfo = msgheader;
|
387 | 400 | }
|
|
0 commit comments