Skip to content

Commit

Permalink
x86/xen: fix set_phys_range_identity() if pfn_e > MAX_P2M_PFN
Browse files Browse the repository at this point in the history
Allow set_phys_range_identity() to work with a range that overlaps
MAX_P2M_PFN by clamping pfn_e to MAX_P2M_PFN.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
David Vrabel committed May 15, 2014
1 parent fcca2e3 commit a9b5bff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arch/x86/xen/p2m.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,
{
unsigned long pfn;

if (unlikely(pfn_s >= MAX_P2M_PFN || pfn_e >= MAX_P2M_PFN))
if (unlikely(pfn_s >= MAX_P2M_PFN))
return 0;

if (unlikely(xen_feature(XENFEAT_auto_translated_physmap)))
Expand All @@ -783,6 +783,9 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,
if (pfn_s > pfn_e)
return 0;

if (pfn_e > MAX_P2M_PFN)
pfn_e = MAX_P2M_PFN;

for (pfn = (pfn_s & ~(P2M_MID_PER_PAGE * P2M_PER_PAGE - 1));
pfn < ALIGN(pfn_e, (P2M_MID_PER_PAGE * P2M_PER_PAGE));
pfn += P2M_MID_PER_PAGE * P2M_PER_PAGE)
Expand Down

0 comments on commit a9b5bff

Please sign in to comment.