Skip to content

Commit 60901df

Browse files
rosslagerwallDavid Vrabel
authored andcommitted
xen: Fix page <-> pfn conversion on 32 bit systems
Commit 1084b19 (xen: Add Xen specific page definition) caused a regression in 4.4. The xen functions to convert between pages and pfns fail due to an overflow on systems where a physical address may not fit in an unsigned long (e.g. x86 32 bit PAE systems). Rework the conversion to avoid overflow. This should also result in simpler object code. This bug manifested itself as disk corruption with Linux 4.4 when using blkfront in a Xen HVM x86 32 bit guest with more than 4 GiB of memory. Signed-off-by: Ross Lagerwall <[email protected]> Cc: <[email protected]> # 4.4+ Signed-off-by: David Vrabel <[email protected]>
1 parent 101ecde commit 60901df

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/xen/page.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
#define xen_pfn_to_page(xen_pfn) \
18-
((pfn_to_page(((unsigned long)(xen_pfn) << XEN_PAGE_SHIFT) >> PAGE_SHIFT)))
18+
(pfn_to_page((unsigned long)(xen_pfn) >> (PAGE_SHIFT - XEN_PAGE_SHIFT)))
1919
#define page_to_xen_pfn(page) \
20-
(((page_to_pfn(page)) << PAGE_SHIFT) >> XEN_PAGE_SHIFT)
20+
((page_to_pfn(page)) << (PAGE_SHIFT - XEN_PAGE_SHIFT))
2121

2222
#define XEN_PFN_PER_PAGE (PAGE_SIZE / XEN_PAGE_SIZE)
2323

0 commit comments

Comments
 (0)