x86: consider modules when cutting off memory
PATCH 1/1 x86: consider modules when cutting off memory
The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account.
Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages.
xen/arch/x86/setup.c +10 -2
@@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mbASSERT (j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; -if ( (map_e >>PAGE_SHIFT ) < max_page ) +for ( j =0 ; j < mbi->mods_count; ++j ) { - max_page = map_e >>PAGE_SHIFT ; +uint64_t end =pfn_to_paddr (mod[j].mod_start) + + mod[j].mod_end; + +if ( map_e < end ) + map_e = end; + } +if (PFN_UP (map_e) < max_page ) + { + max_page =PFN_UP (map_e); max_pdx =pfn_to_pdx (max_page -1 ) +1 ; } printk(XENLOG_WARNING "Ignoring inaccessible memory range"
x86: consider modules when cutting off memory
The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account.
Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages.
xen/arch/x86/setup.c +10 -2
@@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mbASSERT (j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; -if ( (map_e >>PAGE_SHIFT ) < max_page ) +for ( j =0 ; j < mbi->mods_count; ++j ) { - max_page = map_e >>PAGE_SHIFT ; +uint64_t end =pfn_to_paddr (mod[j].mod_start) + + mod[j].mod_end; + +if ( map_e < end ) + map_e = end; + } +if (PFN_UP (map_e) < max_page ) + { + max_page =PFN_UP (map_e); max_pdx =pfn_to_pdx (max_page -1 ) +1 ; } printk(XENLOG_WARNING "Ignoring inaccessible memory range"
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account.
Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages.
Is rounding up the right thing to do? We round down in find_max_pfn()?
Quoted 27 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/setup.c +10
-2@@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mbASSERT (j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; -if ( (map_e >>PAGE_SHIFT ) < max_page ) +for ( j =0 ; j < mbi->mods_count; ++j ) { - max_page = map_e >>PAGE_SHIFT ; +uint64_t end =pfn_to_paddr (mod[j].mod_start) + + mod[j].mod_end; + +if ( map_e < end ) + map_e = end; + } +if (PFN_UP (map_e) < max_page ) + { + max_page =PFN_UP (map_e); max_pdx =pfn_to_pdx (max_page -1 ) +1 ; } printk(XENLOG_WARNING "Ignoring inaccessible memory range"
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 6 lines · Jan Beulich
The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account.
Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages.
Is rounding up the right thing to do? We round down in
find_max_pfn()?
Yes, it is - we're trying to determine a new max_page/max_pdx here, so we should include the trailing part of a partial page. This is particularly necessary for the modules, as otherwise the last few bytes of a module may end up being in memory not satisfying mfn_valid().
If anything, we'd need to round down after the E820 loop, and round up after the modules one. But I don't think the two max_p* being one too big here would matter much, so uniformly rounding up seems sufficient.
Jan
Quoted 27 lines
Quoted 27 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/setup.c +10
-2@@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mbASSERT (j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; -if ( (map_e >>PAGE_SHIFT ) < max_page ) +for ( j =0 ; j < mbi->mods_count; ++j ) { - max_page = map_e >>PAGE_SHIFT ; +uint64_t end =pfn_to_paddr (mod[j].mod_start) + + mod[j].mod_end; + +if ( map_e < end ) + map_e = end; + } +if (PFN_UP (map_e) < max_page ) + { + max_page =PFN_UP (map_e); max_pdx =pfn_to_pdx (max_page -1 ) +1 ; } printk(XENLOG_WARNING "Ignoring inaccessible memory range"
Keir Fraser
Acked-byQuoted 18 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 6 lines · Jan Beulich
The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account.
Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages.
Is rounding up the right thing to do? We round down in
find_max_pfn()?Yes, it is - we're trying to determine a new max_page/max_pdx here, so we should include the trailing part of a partial page. This is particularly necessary for the modules, as otherwise the last few bytes of a module may end up being in memory not satisfying
mfn_valid().
Quoted 4 lines
If anything, we'd need to round down after the E820 loop, and round up after the modules one. But I don't think the two max_p* being one too big here would matter much, so uniformly rounding up seems sufficient.
Okay makes sense.
Quoted 32 lines
Jan
Quoted 27 lines
Quoted 27 lines
Signed-off-by Jan Beulich <[email protected]>xen/arch/x86/setup.c +10
-2@@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mbASSERT (j); } map_e = boot_e820.map[j].addr + boot_e820.map[j].size; -if ( (map_e >>PAGE_SHIFT ) < max_page ) +for ( j =0 ; j < mbi->mods_count; ++j ) { - max_page = map_e >>PAGE_SHIFT ; +uint64_t end =pfn_to_paddr (mod[j].mod_start) + + mod[j].mod_end; + +if ( map_e < end ) + map_e = end; + } +if (PFN_UP (map_e) < max_page ) + { + max_page =PFN_UP (map_e); max_pdx =pfn_to_pdx (max_page -1 ) +1 ; } printk(XENLOG_WARNING "Ignoring inaccessible memory range"