All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Cc: "Alistair Francis" <alistair.francis@wdc.com>,
	"Bob Eshleman" <bobbyeshleman@gmail.com>,
	"Connor Davis" <connojdavis@gmail.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>,
	"Michal Orzel" <michal.orzel@amd.com>,
	"Julien Grall" <julien@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v1] xen/riscv: Increase XEN_VIRT_SIZE
Date: Mon, 31 Mar 2025 18:14:03 +0200	[thread overview]
Message-ID: <54ebdcb7-071f-411f-803a-930dc330a497@suse.com> (raw)
In-Reply-To: <e5fa4219ccf43125e2489cc8c49b4404e6ed22ce.1743434164.git.oleksii.kurochko@gmail.com>

On 31.03.2025 17:20, Oleksii Kurochko wrote:
> A randconfig job failed with the following issue:
>   riscv64-linux-gnu-ld: Xen too large for early-boot assumptions
> 
> The reason is that enabling the UBSAN config increased the size of
> the Xen binary.
> 
> Increase XEN_VIRT_SIZE to reserve enough space, allowing both UBSAN
> and GCOV to be enabled together, with some slack for future growth.

At some point you may want to use 2M mappings for .text (rx), .rodata
(r), and .data (rw). Together with .init that would then completely
fill those 8Mb afaict. Hence you may want to go a little further right
away, e.g. to 16Mb.

> --- a/xen/arch/riscv/include/asm/mm.h
> +++ b/xen/arch/riscv/include/asm/mm.h
> @@ -43,13 +43,19 @@ static inline void *maddr_to_virt(paddr_t ma)
>   */
>  static inline unsigned long virt_to_maddr(unsigned long va)
>  {
> +    const unsigned int vpn1_shift = PAGETABLE_ORDER + PAGE_SHIFT;
> +    const unsigned long va_vpn = va >> vpn1_shift;
> +    const unsigned long xen_virt_starn_vpn =

s/starn/start/ ?

> +        _AC(XEN_VIRT_START, UL) >> vpn1_shift;
> +    const unsigned long xen_virt_end_vpn =
> +        xen_virt_starn_vpn + ((XEN_VIRT_SIZE >> vpn1_shift) - 1);
> +
>      if ((va >= DIRECTMAP_VIRT_START) &&
>          (va <= DIRECTMAP_VIRT_END))
>          return directmapoff_to_maddr(va - directmap_virt_start);
>  
> -    BUILD_BUG_ON(XEN_VIRT_SIZE != MB(2));
> -    ASSERT((va >> (PAGETABLE_ORDER + PAGE_SHIFT)) ==
> -           (_AC(XEN_VIRT_START, UL) >> (PAGETABLE_ORDER + PAGE_SHIFT)));
> +    BUILD_BUG_ON(XEN_VIRT_SIZE != MB(8));

Is it necessary to be != ? Won't > suffice?

> +    ASSERT((va_vpn >= xen_virt_starn_vpn) && (va_vpn <= xen_virt_end_vpn));

Are you sure about <= on the rhs of the && ?

> --- a/xen/arch/riscv/mm.c
> +++ b/xen/arch/riscv/mm.c
> @@ -31,20 +31,21 @@ unsigned long __ro_after_init phys_offset; /* = load_start - XEN_VIRT_START */
>  #define LOAD_TO_LINK(addr) ((unsigned long)(addr) - phys_offset)
>  
>  /*
> - * It is expected that Xen won't be more then 2 MB.
> + * It is expected that Xen won't be more then 8 MB.
>   * The check in xen.lds.S guarantees that.
> - * At least 3 page tables (in case of Sv39 ) are needed to cover 2 MB.
> + * At least 6 page tables (in case of Sv39) are needed to cover 8 MB.
>   * One for each page level table with PAGE_SIZE = 4 Kb.
>   *
> - * One L0 page table can cover 2 MB(512 entries of one page table * PAGE_SIZE).
> + * Four L0 page table can cover 8 MB(512 entries of
> + * one page table * PAGE_SIZE).
>   *
>   * It might be needed one more page table in case when Xen load address
>   * isn't 2 MB aligned.
>   *
> - * CONFIG_PAGING_LEVELS page tables are needed for the identity mapping,
> + * (CONFIG_PAGING_LEVELS + 2) page tables are needed for the identity mapping,
>   * except that the root page table is shared with the initial mapping
>   */
> -#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 2 + 1)
> +#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS + 2) * 2 + 1)

I'm in trouble fitting the comment updates with the update of the #define. Why
would more tables be needed for the identity mapping? Why does XEN_VIRT_SIZE
not appear anywhere here?

Jan


  reply	other threads:[~2025-03-31 16:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31 15:20 [PATCH v1] xen/riscv: Increase XEN_VIRT_SIZE Oleksii Kurochko
2025-03-31 16:14 ` Jan Beulich [this message]
2025-03-31 16:17   ` Julien Grall
2025-04-01  6:24     ` Jan Beulich
2025-04-01 11:59       ` Julien Grall
2025-04-01 15:46         ` Oleksii Kurochko
2025-04-01 15:58   ` Oleksii Kurochko
2025-04-01 16:04     ` Jan Beulich
2025-04-03 16:20       ` Oleksii Kurochko
2025-04-04  6:56         ` Jan Beulich
2025-04-04  7:31           ` Oleksii Kurochko
2025-04-04  7:52             ` Jan Beulich
2025-04-04  8:43               ` Oleksii Kurochko
2025-04-04 10:00                 ` 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=54ebdcb7-071f-411f-803a-930dc330a497@suse.com \
    --to=jbeulich@suse.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bobbyeshleman@gmail.com \
    --cc=connojdavis@gmail.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=oleksii.kurochko@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --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.