From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: "Roger Pau Monné" <roger@xenproject.org>,
"Teddy Astie" <teddy.astie@vates.tech>,
"Marek Marczykowski" <marmarek@invisiblethingslab.com>,
"Daniel Smith" <dpsmith@apertussolutions.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v4 2/3] x86/EFI: replace ebmalloc()
Date: Wed, 18 Nov 2026 11:00:44 +0100 [thread overview]
Message-ID: <4e005a73-7690-4b83-8215-ece5ed17582c@suse.com> (raw)
In-Reply-To: <a9186c61-c21e-48b1-9fd4-ce2625ac1a83@suse.com>
On 17.11.2026 08:37, Jan Beulich wrote:
> On 16.11.2026 19:13, Andrew Cooper wrote:
>> On 03/11/2026 12:50 pm, Jan Beulich wrote:
>>> --- a/xen/arch/x86/include/asm/setup.h
>>> +++ b/xen/arch/x86/include/asm/setup.h
>>> @@ -9,6 +9,8 @@ extern const char __2M_rodata_start[], _
>>> extern char __2M_init_start[], __2M_init_end[];
>>> extern char __2M_rwdata_start[], __2M_rwdata_end[];
>>>
>>> +extern unsigned long brk_end;
>>> +
>>> extern unsigned long xenheap_initial_phys_start;
>>> extern uint64_t boot_tsc_stamp;
>>>
>>> --- 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>
>>> @@ -164,6 +165,8 @@ cpumask_t __read_mostly cpu_present_map;
>>>
>>> unsigned long __read_mostly xen_phys_start;
>>>
>>> +unsigned long __ro_after_init brk_end;
>>> +
>>
>> I know it's only x86 which uses brk_end right now, but given uses such
>> as ...
>>
>>
>>> /* Only used in asm code and within this source file */
>>> char asmlinkage __section(".init.bss.stack_aligned") __aligned(STACK_SIZE)
>>> cpu0_stack[STACK_SIZE];
>>> @@ -1157,7 +1160,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 +1525,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 +1669,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_end = 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 +2268,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 +2289,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;
>>
>> ... this, it clearly needs to be common in order for other architectures
>> to start using the allocator.
>
> I don't see why this would necessarily be this way. This is x86-specific
> memory management, and other ports may have no need. I'd therefore prefer
> to leave brk_end x86-only until proven otherwise. It was, after all, a
> deliberate decision to make this x86-only.
>
>> So, I think the variable ought to be in xen/brk.h and common/brk.c, and
>> with that, brk_cease() can lose the return value.
>>
>> I know that's yet another change to both patches 1 and 2. If you're
>> happy with this suggestion then consider both Reviewed-by: Andrew Cooper
>> <andrew.cooper3@citrix.com> in light of those changes.
>
> I'd prefer to commit patch 1 as is. Strictly speaking patches 2 and 3 can
> go in on top with Marek's R-b. As it's not clear whether your reply here
> is an objection to this patch, I'll go with just patches 1 and 3 for now.
> If need be, the adjustment you describe could easily be done by a small
> independent prep patch for the one here, or perhaps also right in this
> patch (yet as said, I'd prefer to keep things as-are).
To add to this: With a bit better isolation/abstraction, brk_end could
actually be static in setup.c. Which (to me) also speaks against making
it a common var.
Jan
next prev parent reply other threads:[~2026-11-18 10:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 12:47 [PATCH v4 0/3] "brk" allocator Jan Beulich
2026-11-03 12:49 ` [PATCH v4 1/3] common: introduce " Jan Beulich
2026-11-16 17:27 ` Andrew Cooper
2026-11-03 12:50 ` [PATCH v4 2/3] x86/EFI: replace ebmalloc() Jan Beulich
2026-11-16 18:13 ` Andrew Cooper
2026-11-17 7:37 ` Jan Beulich
2026-11-18 10:00 ` Jan Beulich [this message]
2026-11-03 12:51 ` [PATCH v4 3/3] xhci-dbc: use brk_alloc() Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e005a73-7690-4b83-8215-ece5ed17582c@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dpsmith@apertussolutions.com \
--cc=marmarek@invisiblethingslab.com \
--cc=roger@xenproject.org \
--cc=teddy.astie@vates.tech \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.