On 2025-07-02 04:12, Juergen Gross wrote:
When initializing the memory allocator, don't add memory pages of
modules and the initial boot info structure to the free memory.
This is relevant only when running in PVH mode, as in PV mode only
memory above the initial page tables is added to free memory, and the
module and start_info pages are below the page tables.
Signed-off-by: Juergen Gross <jgr...@suse.com>
+/* Reserved memory ranges not added to free memory. */
+#define MAX_RSV_RANGES 1
+static struct {
+ unsigned long start;
+ unsigned long size;
+} reserved_range[MAX_RSV_RANGES];
+
+void check_memory_range(unsigned long *from, unsigned long *to)
+{
+ unsigned int m;
+ struct hvm_modlist_entry *mod;
+
+ for ( m = 0; m < MAX_RSV_RANGES && reserved_range[m].size; m++ )
+ check_memory_range_conflict(from, to, reserved_range[m].start,
+ reserved_range[m].size);
reserved_range[] isn't updated, so this is dead code. I guess that is
fine for now.
+
+ mod = (struct hvm_modlist_entry *)(unsigned long)
+ hvm_start_info_ptr->modlist_paddr;
+ for ( m = 0; m < hvm_start_info_ptr->nr_modules; m++ )
+ check_memory_range_conflict(from, to, mod[m].paddr, mod[m].size);
+}
+
static const struct {
@@ -888,6 +964,10 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned
long* max_pfn_p)
if ( max_pfn >= MAX_MEM_SIZE / PAGE_SIZE )
max_pfn = MAX_MEM_SIZE / PAGE_SIZE - 1;
+#ifndef CONFIG_PARAVIRT
+ pvh_reserve_start_info(&start_pfn);
+#endif
Maybe this ifdef can be removed and arch_mm_preinit() can call
pvh_reserve_start_info() and update first_free_pfn (which is assigned to
start_pfn)?
Regards,
Jason