Skip to content

Commit 75f2d3a

Browse files
jgross1Boris Ostrovsky
authored andcommitted
x86/xen: enable early use of set_fixmap in 32-bit Xen PV guest
Commit 7b25b9c ("x86/xen/time: Initialize pv xen time in init_hypervisor_platform()") moved the mapping of the shared info area before pagetable_init(). This breaks booting as 32-bit PV guest as the use of set_fixmap isn't possible at this time on 32-bit. This can be worked around by populating the needed PMD on 32-bit kernel earlier. In order not to reimplement populate_extra_pte() using extend_brk() for allocating new page tables extend alloc_low_pages() to do that in case the early page table pool is not yet available. Fixes: 7b25b9c ("x86/xen/time: Initialize pv xen time in init_hypervisor_platform()") Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent 00f53f7 commit 75f2d3a

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

arch/x86/mm/init.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,22 @@ __ref void *alloc_low_pages(unsigned int num)
9999
}
100100

101101
if ((pgt_buf_end + num) > pgt_buf_top || !can_use_brk_pgt) {
102-
unsigned long ret;
103-
if (min_pfn_mapped >= max_pfn_mapped)
104-
panic("alloc_low_pages: ran out of memory");
105-
ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
102+
unsigned long ret = 0;
103+
104+
if (min_pfn_mapped < max_pfn_mapped) {
105+
ret = memblock_find_in_range(
106+
min_pfn_mapped << PAGE_SHIFT,
106107
max_pfn_mapped << PAGE_SHIFT,
107108
PAGE_SIZE * num , PAGE_SIZE);
109+
}
110+
if (ret)
111+
memblock_reserve(ret, PAGE_SIZE * num);
112+
else if (can_use_brk_pgt)
113+
ret = __pa(extend_brk(PAGE_SIZE * num, PAGE_SIZE));
114+
108115
if (!ret)
109116
panic("alloc_low_pages: can not alloc memory");
110-
memblock_reserve(ret, PAGE_SIZE * num);
117+
111118
pfn = ret >> PAGE_SHIFT;
112119
} else {
113120
pfn = pgt_buf_end;

arch/x86/xen/enlighten_pv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ static void __init xen_banner(void)
122122

123123
static void __init xen_pv_init_platform(void)
124124
{
125+
populate_extra_pte(fix_to_virt(FIX_PARAVIRT_BOOTMAP));
126+
125127
set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_start_info->shared_info);
126128
HYPERVISOR_shared_info = (void *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
127129

arch/x86/xen/mmu_pv.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,8 @@ void __init xen_relocate_p2m(void)
21712171
#else /* !CONFIG_X86_64 */
21722172
static RESERVE_BRK_ARRAY(pmd_t, initial_kernel_pmd, PTRS_PER_PMD);
21732173
static RESERVE_BRK_ARRAY(pmd_t, swapper_kernel_pmd, PTRS_PER_PMD);
2174+
RESERVE_BRK(fixup_kernel_pmd, PAGE_SIZE);
2175+
RESERVE_BRK(fixup_kernel_pte, PAGE_SIZE);
21742176

21752177
static void __init xen_write_cr3_init(unsigned long cr3)
21762178
{

0 commit comments

Comments
 (0)