aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen/p2m.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-03-30 11:45:01 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-04-06 17:02:59 -0400
commit3f3aaea29ff7ee2d43b430338427f30ba7f60ff9 (patch)
tree476d2c406d376f80e8ce725a7e4e4c98e18aece1 /arch/x86/xen/p2m.c
parentf09d8432e39797abf39531f41ac8a46a3fbf442a (diff)
xen/p2m: Move code around to allow for better re-usage.
We are going to be using the early_alloc_p2m (and early_alloc_p2m_middle) code in follow up patches which are not related to setting identity pages. Hence lets move the code out in its own function and rename them as appropiate. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'arch/x86/xen/p2m.c')
-rw-r--r--arch/x86/xen/p2m.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 1b267e75158d..3cc3afeb09a1 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -499,7 +499,7 @@ static bool alloc_p2m(unsigned long pfn)
499 return true; 499 return true;
500} 500}
501 501
502static bool __init __early_alloc_p2m(unsigned long pfn) 502static bool __init early_alloc_p2m_middle(unsigned long pfn)
503{ 503{
504 unsigned topidx, mididx, idx; 504 unsigned topidx, mididx, idx;
505 505
@@ -541,6 +541,36 @@ static bool __init __early_alloc_p2m(unsigned long pfn)
541 } 541 }
542 return idx != 0; 542 return idx != 0;
543} 543}
544
545static bool __init early_alloc_p2m(unsigned long pfn)
546{
547 unsigned topidx = p2m_top_index(pfn);
548 unsigned long *mid_mfn_p;
549 unsigned long **mid;
550
551 mid = p2m_top[topidx];
552 mid_mfn_p = p2m_top_mfn_p[topidx];
553 if (mid == p2m_mid_missing) {
554 mid = extend_brk(PAGE_SIZE, PAGE_SIZE);
555
556 p2m_mid_init(mid);
557
558 p2m_top[topidx] = mid;
559
560 BUG_ON(mid_mfn_p != p2m_mid_missing_mfn);
561 }
562 /* And the save/restore P2M tables.. */
563 if (mid_mfn_p == p2m_mid_missing_mfn) {
564 mid_mfn_p = extend_brk(PAGE_SIZE, PAGE_SIZE);
565 p2m_mid_mfn_init(mid_mfn_p);
566
567 p2m_top_mfn_p[topidx] = mid_mfn_p;
568 p2m_top_mfn[topidx] = virt_to_mfn(mid_mfn_p);
569 /* Note: we don't set mid_mfn_p[midix] here,
570 * look in early_alloc_p2m_middle */
571 }
572 return true;
573}
544unsigned long __init set_phys_range_identity(unsigned long pfn_s, 574unsigned long __init set_phys_range_identity(unsigned long pfn_s,
545 unsigned long pfn_e) 575 unsigned long pfn_e)
546{ 576{
@@ -559,35 +589,11 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,
559 pfn < ALIGN(pfn_e, (P2M_MID_PER_PAGE * P2M_PER_PAGE)); 589 pfn < ALIGN(pfn_e, (P2M_MID_PER_PAGE * P2M_PER_PAGE));
560 pfn += P2M_MID_PER_PAGE * P2M_PER_PAGE) 590 pfn += P2M_MID_PER_PAGE * P2M_PER_PAGE)
561 { 591 {
562 unsigned topidx = p2m_top_index(pfn); 592 WARN_ON(!early_alloc_p2m(pfn));
563 unsigned long *mid_mfn_p;
564 unsigned long **mid;
565
566 mid = p2m_top[topidx];
567 mid_mfn_p = p2m_top_mfn_p[topidx];
568 if (mid == p2m_mid_missing) {
569 mid = extend_brk(PAGE_SIZE, PAGE_SIZE);
570
571 p2m_mid_init(mid);
572
573 p2m_top[topidx] = mid;
574
575 BUG_ON(mid_mfn_p != p2m_mid_missing_mfn);
576 }
577 /* And the save/restore P2M tables.. */
578 if (mid_mfn_p == p2m_mid_missing_mfn) {
579 mid_mfn_p = extend_brk(PAGE_SIZE, PAGE_SIZE);
580 p2m_mid_mfn_init(mid_mfn_p);
581
582 p2m_top_mfn_p[topidx] = mid_mfn_p;
583 p2m_top_mfn[topidx] = virt_to_mfn(mid_mfn_p);
584 /* Note: we don't set mid_mfn_p[midix] here,
585 * look in __early_alloc_p2m */
586 }
587 } 593 }
588 594
589 __early_alloc_p2m(pfn_s); 595 early_alloc_p2m_middle(pfn_s);
590 __early_alloc_p2m(pfn_e); 596 early_alloc_p2m_middle(pfn_e);
591 597
592 for (pfn = pfn_s; pfn < pfn_e; pfn++) 598 for (pfn = pfn_s; pfn < pfn_e; pfn++)
593 if (!__set_phys_to_machine(pfn, IDENTITY_FRAME(pfn))) 599 if (!__set_phys_to_machine(pfn, IDENTITY_FRAME(pfn)))