* [PATCH v5 0/3] "brk" allocator
@ 2026-11-25 14:35 Jan Beulich
2026-11-25 14:36 ` [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o Jan Beulich
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Jan Beulich @ 2026-11-25 14:35 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
v5 addresses (hopefully) the final bits of feedback that kept trickling in.
1: build: permit .data.ro_after_init in *.init.o
2: common: introduce brk_end
3: x86/EFI: replace ebmalloc()
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o
2026-11-25 14:35 [PATCH v5 0/3] "brk" allocator Jan Beulich
@ 2026-11-25 14:36 ` Jan Beulich
2026-11-25 16:05 ` Andrew Cooper
2026-11-25 14:36 ` [PATCH v5 2/3] common: introduce brk_end Jan Beulich
2026-11-25 14:36 ` [PATCH v5 3/3] x86/EFI: replace ebmalloc() Jan Beulich
2 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2026-11-25 14:36 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
Setting __ro_after_init variables is one of the purposes of __init code.
Permit such data to be present in objects to be converted to *.init.o.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v5: New.
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -263,7 +263,7 @@ quiet_cmd_obj_init_o = INIT_O $@
define cmd_obj_init_o
$(OBJDUMP) -h $< | while read idx name sz rest; do \
case "$$name" in \
- .*.local|.data.rel.ro|.data.rel.ro.*) ;; \
+ .*.local|.data.rel.ro|.data.rel.ro.*|.data.ro_after_init) ;; \
.text|.text.*|.data|.data.*|.bss|.bss.*) \
test $$(echo $$sz | sed 's,00*,0,') != 0 || continue; \
echo "Error: size of $<:$$name is 0x$$sz" >&2; \
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 2/3] common: introduce brk_end
2026-11-25 14:35 [PATCH v5 0/3] "brk" allocator Jan Beulich
2026-11-25 14:36 ` [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o Jan Beulich
@ 2026-11-25 14:36 ` Jan Beulich
2026-11-25 16:12 ` Andrew Cooper
2026-11-25 14:36 ` [PATCH v5 3/3] x86/EFI: replace ebmalloc() Jan Beulich
2 siblings, 1 reply; 9+ messages in thread
From: Jan Beulich @ 2026-11-25 14:36 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
It is anticipated that all architectures meaning to use the BRK allocator
will have a need for this variable. With this there's then also no need
for brk_cease() to have a return value; it simply sets the variable.
Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Looks like "finished" could then be dropped.
---
v5: New.
--- a/xen/common/brk.c
+++ b/xen/common/brk.c
@@ -18,6 +18,8 @@ static inline unsigned long brk_adjust_s
extern char __brk_start[];
extern const char __bss_end[];
+unsigned long __ro_after_init brk_end;
+
static unsigned long __initdata allocated;
static bool __initdata finished;
@@ -52,20 +54,22 @@ void *__init brk_alloc(size_t size)
return ptr;
}
-unsigned long __init brk_cease(void)
+void __init brk_cease(void)
{
finished = true;
allocated = ROUNDUP(allocated, PAGE_SIZE);
- return (unsigned long)__brk_start + allocated;
+ brk_end = (unsigned long)__brk_start + allocated;
}
void __init brk_free_unused(void)
{
- unsigned long start = brk_cease(), end = (unsigned long)__bss_end;
+ unsigned long start, end = (unsigned long)__bss_end;
+
+ brk_cease();
- start = brk_adjust_start(start);
+ start = brk_adjust_start(brk_end);
if ( start >= end )
return;
--- a/xen/include/xen/brk.h
+++ b/xen/include/xen/brk.h
@@ -24,8 +24,10 @@
static char __section(".bss..brk.page_aligned") __aligned(PAGE_SIZE) \
__used var ## _brk_[size]
+extern unsigned long brk_end;
+
void *brk_alloc(size_t size);
-unsigned long brk_cease(void);
+void brk_cease(void);
void brk_free_unused(void);
#endif /* XEN_BRK_H */
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 3/3] x86/EFI: replace ebmalloc()
2026-11-25 14:35 [PATCH v5 0/3] "brk" allocator Jan Beulich
2026-11-25 14:36 ` [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o Jan Beulich
2026-11-25 14:36 ` [PATCH v5 2/3] common: introduce brk_end Jan Beulich
@ 2026-11-25 14:36 ` Jan Beulich
2026-11-25 16:12 ` Andrew Cooper
2026-11-27 0:42 ` Andrew Cooper
2 siblings, 2 replies; 9+ messages in thread
From: Jan Beulich @ 2026-11-25 14:36 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Marek Marczykowski,
Teddy Astie
Use the new brk_alloc() instead, with ebmalloc() merely being a thin
wrapper.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
I'm not quite certain whether we ought to permit non-page-granular
reservations. The in-memory image being somewhat larger due to possibly
excessive padding isn't really a big problem, I think.
---
v5: Re-base over changes earlier in the series.
v4: Also adjust is_xen_fixed_mfn().
v3: Re-base, in particular over moving of brk.c to common/.
v2: Re-base.
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -263,7 +263,7 @@ quiet_cmd_obj_init_o = INIT_O $@
define cmd_obj_init_o
$(OBJDUMP) -h $< | while read idx name sz rest; do \
case "$$name" in \
- .*.local|.data.rel.ro|.data.rel.ro.*|.data.ro_after_init) ;; \
+ .*.local|.data.rel.ro|.data.rel.ro.*|.data.ro_after_init|.bss..brk*) ;; \
.text|.text.*|.data|.data.*|.bss|.bss.*) \
test $$(echo $$sz | sed 's,00*,0,') != 0 || continue; \
echo "Error: size of $<:$$name is 0x$$sz" >&2; \
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -7,6 +7,7 @@
#ifndef X86_EFI_EFI_BOOT_H
#define X86_EFI_EFI_BOOT_H
+#include <xen/brk.h>
#include <xen/vga.h>
#include <asm/boot-helpers.h>
@@ -119,6 +120,18 @@ static void __init relocate_trampoline(u
reloc_trampoline64();
}
+DEFINE_BRK(efi, MB(1));
+
+static void *__init ebmalloc(size_t size)
+{
+ void *ptr = brk_alloc(size);
+
+ if ( !ptr )
+ blexit(L"Out of BRK memory\r\n");
+
+ return ptr;
+}
+
static void __init place_string(u32 *addr, const char *s)
{
char *alloc = NULL;
--- a/xen/arch/x86/efi/stub.c
+++ b/xen/arch/x86/efi/stub.c
@@ -41,12 +41,4 @@ void __init noreturn efi_multiboot2(EFI_
void __init efi_init_memory(void) { }
-bool efi_boot_mem_unused(unsigned long *start, unsigned long *end)
-{
- /* FIXME: Simplify once the call here with two NULLs goes away. */
- if ( start || end )
- *start = *end = (unsigned long)_end;
- return false;
-}
-
void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e) { }
--- a/xen/arch/x86/include/asm/mm.h
+++ b/xen/arch/x86/include/asm/mm.h
@@ -313,7 +313,7 @@ struct page_info
(mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
#define is_xen_fixed_mfn(mfn) \
(((mfn_to_maddr(mfn)) >= virt_to_maddr((unsigned long)_stext)) && \
- ((mfn_to_maddr(mfn)) <= virt_to_maddr((unsigned long)__2M_rwdata_end - 1)))
+ (mfn_to_maddr(mfn) <= virt_to_maddr(brk_end - 1)))
#define PRtype_info "016lx"/* should only be used for printk's */
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1,6 +1,7 @@
#include <xen/acpi.h>
#include <xen/alternative-call.h>
#include <xen/bitops.h>
+#include <xen/brk.h>
#include <xen/console.h>
#include <xen/cpu.h>
#include <xen/cpuidle.h>
@@ -1157,7 +1158,6 @@ void asmlinkage __init noreturn __start_
struct boot_info *bi;
unsigned long raw_max_page;
int i, j, bytes = 0;
- unsigned long eb_start, eb_end;
bool acpi_boot_table_init_done = false, relocated = false;
bool vm_init_done = false;
int ret;
@@ -1523,7 +1523,7 @@ void asmlinkage __init noreturn __start_
/*
* This needs to remain in sync with remove_xen_ranges() and the
* respective reserve_e820_ram() invocation below. No need to
- * query efi_boot_mem_unused() here, though.
+ * query brk_cease() here, though.
*/
xen->start = virt_to_maddr(_stext);
xen->size = __2M_rwdata_end - _stext;
@@ -1667,20 +1667,12 @@ void asmlinkage __init noreturn __start_
if ( !xen_phys_start )
panic("Not enough memory to relocate Xen\n");
- /* FIXME: Putting a hole in .bss would shatter the large page mapping. */
- if ( using_2M_mapping() )
- efi_boot_mem_unused(NULL, NULL);
-
/* This needs to remain in sync with remove_xen_ranges(). */
- if ( efi_boot_mem_unused(&eb_start, &eb_end) )
- {
- if ( !reserve_e820_ram(&boot_e820, __pa(_stext), __pa(eb_start)) ||
- !reserve_e820_ram(&boot_e820, __pa(eb_end), __pa(__2M_rwdata_end)) )
- panic("Failed to reserve Xen in E820\n");
- }
- else
- if ( !reserve_e820_ram(&boot_e820, __pa(_stext), __pa(__2M_rwdata_end)) )
- panic("Failed to reserve Xen in E820\n");
+ brk_cease();
+ if ( using_2M_mapping() )
+ brk_end = PAGE_ALIGN_2M(brk_end);
+ if ( !reserve_e820_ram(&boot_e820, __pa(_stext), __pa(brk_end)) )
+ panic("Failed to reserve Xen in E820\n");
/* Late kexec reservation (dynamic start address). */
kexec_reserve_area();
@@ -2274,7 +2266,6 @@ __initcall(init_xen_cap_info);
int __hwdom_init remove_xen_ranges(struct rangeset *r)
{
- paddr_t start, end;
int rc;
/* S3 resume code (and other real mode trampoline code) */
@@ -2296,26 +2287,10 @@ int __hwdom_init remove_xen_ranges(struc
return rc;
/* hypervisor .data + .bss */
- if ( efi_boot_mem_unused(&start, &end) )
- {
- ASSERT(__pa(start) >= __pa(&__2M_rwdata_start));
- rc = rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)),
- PFN_DOWN(__pa(start) - 1));
- if ( rc )
- return rc;
- ASSERT(__pa(end) <= __pa(&__2M_rwdata_end));
- rc = rangeset_remove_range(r, PFN_DOWN(__pa(end)),
- PFN_DOWN(__pa(&__2M_rwdata_end) - 1));
- if ( rc )
- return rc;
- }
- else
- {
- rc = rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)),
- PFN_DOWN(__pa(&__2M_rwdata_end) - 1));
- if ( rc )
- return rc;
- }
+ rc = rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)),
+ PFN_DOWN(__pa(brk_end) - 1));
+ if ( rc )
+ return rc;
return 0;
}
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -1,4 +1,5 @@
#include <xen/acpi.h>
+#include <xen/brk.h>
#include <xen/domain_page.h>
#include <xen/efi.h>
#include <xen/init.h>
@@ -321,8 +322,6 @@ void tboot_shutdown(uint32_t shutdown_ty
/* if this is S3 then set regions to MAC */
if ( shutdown_type == TB_SHUTDOWN_S3 )
{
- unsigned long s, e;
-
/*
* Xen regions for tboot to MAC. This needs to remain in sync with
* remove_xen_ranges().
@@ -336,16 +335,8 @@ void tboot_shutdown(uint32_t shutdown_ty
g_tboot_shared->mac_regions[1].size = __2M_rodata_end - _stext;
/* hypervisor .data + .bss */
g_tboot_shared->mac_regions[2].start = (uint64_t)__pa(&__2M_rwdata_start);
- g_tboot_shared->mac_regions[2].size = __2M_rwdata_end - __2M_rwdata_start;
- if ( efi_boot_mem_unused(&s, &e) )
- {
- g_tboot_shared->mac_regions[2].size =
- s - (unsigned long)__2M_rwdata_start;
- g_tboot_shared->mac_regions[3].start = __pa(e);
- g_tboot_shared->mac_regions[3].size =
- (unsigned long)__2M_rwdata_end - e;
- g_tboot_shared->num_mac_regions = 4;
- }
+ g_tboot_shared->mac_regions[2].size =
+ brk_end - (unsigned long)__2M_rwdata_start;
/*
* MAC domains and other Xen memory
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1830,8 +1830,6 @@ void __init efi_init_memory(void)
pte_attr_t prot;
} *extra, *extra_head = NULL;
- free_ebmalloc_unused_mem();
-
if ( !efi_enabled(EFI_BOOT) )
return;
--- a/xen/common/efi/ebmalloc.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "efi.h"
-#include <xen/init.h>
-#include <xen/mm.h>
-
-#ifdef CONFIG_ARM
-/*
- * TODO: Enable EFI boot allocator on ARM.
- * This code can be common for x86 and ARM.
- * Things TODO on ARM before enabling ebmalloc:
- * - estimate required EBMALLOC_SIZE value,
- * - where (in which section) ebmalloc_mem[] should live; if in
- * .bss.page_aligned, as it is right now, then whole BSS zeroing
- * have to be disabled in xen/arch/arm/arm64/head.S; though BSS
- * should be initialized somehow before use of variables living there,
- * - use ebmalloc() in ARM/common EFI boot code,
- * - call free_ebmalloc_unused_mem() somewhere in init code.
- */
-#define EBMALLOC_SIZE MB(0)
-#else
-#define EBMALLOC_SIZE MB(1)
-#endif
-
-static char __section(".bss.page_aligned") __aligned(PAGE_SIZE)
- ebmalloc_mem[EBMALLOC_SIZE];
-static unsigned long __read_mostly ebmalloc_allocated;
-
-/* EFI boot allocator. */
-void __init *ebmalloc(size_t size)
-{
- void *ptr = ebmalloc_mem + ebmalloc_allocated;
-
- ebmalloc_allocated += ROUNDUP(size, sizeof(void *));
-
- if ( ebmalloc_allocated > sizeof(ebmalloc_mem) )
- blexit(L"Out of static memory\r\n");
-
- return ptr;
-}
-
-bool efi_boot_mem_unused(unsigned long *start, unsigned long *end)
-{
- /* FIXME: Drop once the call here with two NULLs goes away. */
- if ( !start && !end )
- {
- ebmalloc_allocated = sizeof(ebmalloc_mem);
- return false;
- }
-
- *start = (unsigned long)ebmalloc_mem + PAGE_ALIGN(ebmalloc_allocated);
- *end = (unsigned long)ebmalloc_mem + sizeof(ebmalloc_mem);
-
- return *start < *end;
-}
-
-void __init free_ebmalloc_unused_mem(void)
-{
- unsigned long start, end;
-
- if ( !efi_boot_mem_unused(&start, &end) )
- return;
-
- destroy_xen_mappings(start, end);
-
-#ifdef CONFIG_X86
- /*
- * By reserving the space early in the E820 map, it gets freed way before
- * we make it here. Don't free the range a 2nd time.
- */
-#else
- init_xenheap_pages(__pa(start), __pa(end));
-#endif
-
- printk(XENLOG_INFO "Freed %lukB unused BSS memory\n", (end - start) >> 10);
-}
--- a/xen/common/efi/efi-common.mk
+++ b/xen/common/efi/efi-common.mk
@@ -1,4 +1,4 @@
-EFIOBJ-y := boot.init.o pe.init.o ebmalloc.o runtime.o
+EFIOBJ-y := boot.init.o pe.init.o runtime.o
EFIOBJ-$(CONFIG_COMPAT) += compat.o
CFLAGS-y += -fshort-wchar
--- a/xen/common/efi/efi.h
+++ b/xen/common/efi/efi.h
@@ -48,10 +48,6 @@ void noreturn blexit(const CHAR16 *str);
const CHAR16 *wmemchr(const CHAR16 *s, CHAR16 c, UINTN n);
-/* EFI boot allocator. */
-void *ebmalloc(size_t size);
-void free_ebmalloc_unused_mem(void);
-
const void *pe_find_section(const void *image, const UINTN image_size,
const CHAR16 *section_name, UINTN *size_out);
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -120,6 +120,7 @@
* regions within it.
*/
+#include <xen/brk.h>
#include <xen/domain_page.h>
#include <xen/event.h>
#include <xen/init.h>
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -39,7 +39,6 @@ static inline bool efi_enabled(unsigned
extern bool efi_secure_boot;
void efi_init_memory(void);
-bool efi_boot_mem_unused(unsigned long *start, unsigned long *end);
unsigned long efi_get_time(void);
void efi_reset_system(bool warm);
#ifndef COMPAT
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o
2026-11-25 14:36 ` [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o Jan Beulich
@ 2026-11-25 16:05 ` Andrew Cooper
2026-11-26 7:30 ` Jan Beulich
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cooper @ 2026-11-25 16:05 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
On 25/11/2026 2:36 pm, Jan Beulich wrote:
> Setting __ro_after_init variables is one of the purposes of __init code.
> Permit such data to be present in objects to be converted to *.init.o.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>, although...
> ---
> v5: New.
>
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -263,7 +263,7 @@ quiet_cmd_obj_init_o = INIT_O $@
> define cmd_obj_init_o
> $(OBJDUMP) -h $< | while read idx name sz rest; do \
> case "$$name" in \
> - .*.local|.data.rel.ro|.data.rel.ro.*) ;; \
> + .*.local|.data.rel.ro|.data.rel.ro.*|.data.ro_after_init) ;; \
... won't we want .data.ro_after_init.* eventually when we get
--gc-sections fully working?
~Andrew
> .text|.text.*|.data|.data.*|.bss|.bss.*) \
> test $$(echo $$sz | sed 's,00*,0,') != 0 || continue; \
> echo "Error: size of $<:$$name is 0x$$sz" >&2; \
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 2/3] common: introduce brk_end
2026-11-25 14:36 ` [PATCH v5 2/3] common: introduce brk_end Jan Beulich
@ 2026-11-25 16:12 ` Andrew Cooper
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cooper @ 2026-11-25 16:12 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné
On 25/11/2026 2:36 pm, Jan Beulich wrote:
> It is anticipated that all architectures meaning to use the BRK allocator
> will have a need for this variable. With this there's then also no need
> for brk_cease() to have a return value; it simply sets the variable.
>
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> Looks like "finished" could then be dropped.
Yeah. Probably best to fold into this patch.
> ---
> v5: New.
>
> --- a/xen/common/brk.c
> +++ b/xen/common/brk.c
> @@ -18,6 +18,8 @@ static inline unsigned long brk_adjust_s
> extern char __brk_start[];
> extern const char __bss_end[];
>
> +unsigned long __ro_after_init brk_end;
> +
> static unsigned long __initdata allocated;
> static bool __initdata finished;
>
> @@ -52,20 +54,22 @@ void *__init brk_alloc(size_t size)
> return ptr;
> }
>
> -unsigned long __init brk_cease(void)
> +void __init brk_cease(void)
> {
> finished = true;
>
> allocated = ROUNDUP(allocated, PAGE_SIZE);
>
> - return (unsigned long)__brk_start + allocated;
> + brk_end = (unsigned long)__brk_start + allocated;
> }
>
> void __init brk_free_unused(void)
> {
> - unsigned long start = brk_cease(), end = (unsigned long)__bss_end;
> + unsigned long start, end = (unsigned long)__bss_end;
> +
> + brk_cease();
>
> - start = brk_adjust_start(start);
> + start = brk_adjust_start(brk_end);
>
> if ( start >= end )
> return;
> --- a/xen/include/xen/brk.h
> +++ b/xen/include/xen/brk.h
> @@ -24,8 +24,10 @@
> static char __section(".bss..brk.page_aligned") __aligned(PAGE_SIZE) \
> __used var ## _brk_[size]
>
/* Set by brk_cease(), and becomes a permanent extension to the Xen
image. */
or words to this effect.
~Andrew
> +extern unsigned long brk_end;
> +
> void *brk_alloc(size_t size);
> -unsigned long brk_cease(void);
> +void brk_cease(void);
> void brk_free_unused(void);
>
> #endif /* XEN_BRK_H */
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 3/3] x86/EFI: replace ebmalloc()
2026-11-25 14:36 ` [PATCH v5 3/3] x86/EFI: replace ebmalloc() Jan Beulich
@ 2026-11-25 16:12 ` Andrew Cooper
2026-11-27 0:42 ` Andrew Cooper
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Cooper @ 2026-11-25 16:12 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Marek Marczykowski,
Teddy Astie
On 25/11/2026 2:36 pm, Jan Beulich wrote:
> Use the new brk_alloc() instead, with ebmalloc() merely being a thin
> wrapper.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o
2026-11-25 16:05 ` Andrew Cooper
@ 2026-11-26 7:30 ` Jan Beulich
0 siblings, 0 replies; 9+ messages in thread
From: Jan Beulich @ 2026-11-26 7:30 UTC (permalink / raw)
To: Andrew Cooper
Cc: Julien Grall, Stefano Stabellini, Anthony PERARD, Michal Orzel,
Roger Pau Monné, xen-devel@lists.xenproject.org
On 25.11.2026 17:05, Andrew Cooper wrote:
> On 25/11/2026 2:36 pm, Jan Beulich wrote:
>> Setting __ro_after_init variables is one of the purposes of __init code.
>> Permit such data to be present in objects to be converted to *.init.o.
>>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>, although...
Thanks.
>> ---
>> v5: New.
>>
>> --- a/xen/Rules.mk
>> +++ b/xen/Rules.mk
>> @@ -263,7 +263,7 @@ quiet_cmd_obj_init_o = INIT_O $@
>> define cmd_obj_init_o
>> $(OBJDUMP) -h $< | while read idx name sz rest; do \
>> case "$$name" in \
>> - .*.local|.data.rel.ro|.data.rel.ro.*) ;; \
>> + .*.local|.data.rel.ro|.data.rel.ro.*|.data.ro_after_init) ;; \
>
> ... won't we want .data.ro_after_init.* eventually when we get
> --gc-sections fully working?
Likely, yet many more changes are going to be needed for that to work.
.init.data.* and .init.text.*, for example, also require dealing with
afaics.
Jan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v5 3/3] x86/EFI: replace ebmalloc()
2026-11-25 14:36 ` [PATCH v5 3/3] x86/EFI: replace ebmalloc() Jan Beulich
2026-11-25 16:12 ` Andrew Cooper
@ 2026-11-27 0:42 ` Andrew Cooper
1 sibling, 0 replies; 9+ messages in thread
From: Andrew Cooper @ 2026-11-27 0:42 UTC (permalink / raw)
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Julien Grall, Stefano Stabellini, Anthony PERARD,
Michal Orzel, Roger Pau Monné, Marek Marczykowski,
Teddy Astie
On 25/11/2026 2:36 pm, Jan Beulich wrote:
> Use the new brk_alloc() instead, with ebmalloc() merely being a thin
> wrapper.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
From AI review, two issues:
1. brk_end loses its 2M rounding (18b2e1fc6e "x86/EFI: replace
ebmalloc()", together with 82cab821d0 "common: introduce brk_end")
The order of events in __start_xen():
1. setup.c:1671 calls brk_cease(), then rounds up with brk_end =
PAGE_ALIGN_2M(brk_end) when 2M mappings are in use, which is always the
case for xen.efi. The E820 reservation uses that rounded value.
2. Later, arch_init_memory() (line 2102) calls brk_free_unused(). That
calls brk_cease() again, which unconditionally sets brk_end =
__brk_start + allocated, discarding the rounding.
3. Everything after that sees the unrounded value:
- remove_xen_ranges(), which runs during create_dom0() at line 2211;
- is_xen_fixed_mfn();
- the S3 integrity-measurement (MAC) region size in tboot_shutdown().
The range [brk_end, PAGE_ALIGN_2M(brk_end)) is then reserved in E820
and still mapped by Xen's 2M mapping, but it isn't treated as Xen memory:
- With dom0-iommu=map-inclusive or map-reserved, the IOMMU set-up in
iommu.c:486 relies on remove_xen_ranges() to cut Xen out of dom0's
mappings. These pages would stay mapped for dom0's devices.
- Page offlining wouldn't refuse them as Xen pages.
The pages are unused brk space and padding, so the impact is small,
but it breaks the "permanent bound of the Xen image" promise in brk.h. A
possible fix is to make brk_cease() do nothing once brk_end is set, or
to apply the
2M rounding inside brk_cease() via brk_adjust_start() so there's a
single place that computes the value.
2. Stale MISRA entry (18b2e1fc6e):
docs/misra/function-macro-properties.json:499 still lists
^.*efi_boot_mem_unused.*$, but that function was removed. Nothing in
automation/eclair_analysis or the other docs/misra files
mentions ebmalloc or efi_boot_mem_unused.
~Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-27 0:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 14:35 [PATCH v5 0/3] "brk" allocator Jan Beulich
2026-11-25 14:36 ` [PATCH v5 1/3] build: permit .data.ro_after_init in *.init.o Jan Beulich
2026-11-25 16:05 ` Andrew Cooper
2026-11-26 7:30 ` Jan Beulich
2026-11-25 14:36 ` [PATCH v5 2/3] common: introduce brk_end Jan Beulich
2026-11-25 16:12 ` Andrew Cooper
2026-11-25 14:36 ` [PATCH v5 3/3] x86/EFI: replace ebmalloc() Jan Beulich
2026-11-25 16:12 ` Andrew Cooper
2026-11-27 0:42 ` Andrew Cooper
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.