diff mbox

[SRU,K,0/1] Disable sv57 on riscv64

Message ID 20221010112729.42522-1-emil.renner.berthing@canonical.com
State New
Headers show

Commit Message

Emil Renner Berthing Oct. 10, 2022, 11:27 a.m. UTC
[ Impact ]

* Linux 5.18 merged support for 5-level page tables (sv57), and it
  does it such that 5-level page tables are used whenever the
  system supports it.

* So far only Qemu support sv57, but it breaks Go since Go uses
  too many of the upper bits of pointers to store data, and is not
  yet ready for sv57. It probably breaks other types of software
  using too many bits for this "pointer tagging" technique.
  At the moment, there is no way to indicate to the kernel to
  downgrade to sv48, so we must patch the kernel:


[ Test Plan ]

* Build an image with the patched kernel and make sure snapd and
  other Go programs works correctly and that you can compile a
  simple helloworld written in Go.

[ Where problems could occur ]

* The patch could be buggy.

* Qemu will no longer work with > 256 TB of memory.

Alexandre Ghiti (1):
  UBUNTU: SAUCE: riscv: mm: Force disable sv57

 arch/riscv/mm/init.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Tim Gardner Oct. 10, 2022, 12:48 p.m. UTC | #1
On 10/10/22 05:27, Emil Renner Berthing wrote:
> [ Impact ]
> 
> * Linux 5.18 merged support for 5-level page tables (sv57), and it
>    does it such that 5-level page tables are used whenever the
>    system supports it.
> 
> * So far only Qemu support sv57, but it breaks Go since Go uses
>    too many of the upper bits of pointers to store data, and is not
>    yet ready for sv57. It probably breaks other types of software
>    using too many bits for this "pointer tagging" technique.
>    At the moment, there is no way to indicate to the kernel to
>    downgrade to sv48, so we must patch the kernel:
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 2c4a64e97aec..18a0c70ed313 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -775,6 +775,10 @@ static __init void set_satp_mode(void)
>                  disable_pgtable_l4();
>          }
> 
> + /* UBUNTU: Force disable sv57 and fallback to sv48 */
> + if (pgtable_l5_enabled)
> + disable_pgtable_l5();
> +
>          memset(early_pg_dir, 0, PAGE_SIZE);
>          memset(early_p4d, 0, PAGE_SIZE);
>          memset(early_pud, 0, PAGE_SIZE);
> 
> [ Test Plan ]
> 
> * Build an image with the patched kernel and make sure snapd and
>    other Go programs works correctly and that you can compile a
>    simple helloworld written in Go.
> 
> [ Where problems could occur ]
> 
> * The patch could be buggy.
> 
> * Qemu will no longer work with > 256 TB of memory.
> 
> Alexandre Ghiti (1):
>    UBUNTU: SAUCE: riscv: mm: Force disable sv57
> 
>   arch/riscv/mm/init.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Dimitri John Ledkov Oct. 10, 2022, 2:43 p.m. UTC | #2
Applied to unstable and kinetic.

On Mon, 10 Oct 2022 at 13:49, Tim Gardner <tim.gardner@canonical.com> wrote:
>
> On 10/10/22 05:27, Emil Renner Berthing wrote:
> > [ Impact ]
> >
> > * Linux 5.18 merged support for 5-level page tables (sv57), and it
> >    does it such that 5-level page tables are used whenever the
> >    system supports it.
> >
> > * So far only Qemu support sv57, but it breaks Go since Go uses
> >    too many of the upper bits of pointers to store data, and is not
> >    yet ready for sv57. It probably breaks other types of software
> >    using too many bits for this "pointer tagging" technique.
> >    At the moment, there is no way to indicate to the kernel to
> >    downgrade to sv48, so we must patch the kernel:
> >
> > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > index 2c4a64e97aec..18a0c70ed313 100644
> > --- a/arch/riscv/mm/init.c
> > +++ b/arch/riscv/mm/init.c
> > @@ -775,6 +775,10 @@ static __init void set_satp_mode(void)
> >                  disable_pgtable_l4();
> >          }
> >
> > + /* UBUNTU: Force disable sv57 and fallback to sv48 */
> > + if (pgtable_l5_enabled)
> > + disable_pgtable_l5();
> > +
> >          memset(early_pg_dir, 0, PAGE_SIZE);
> >          memset(early_p4d, 0, PAGE_SIZE);
> >          memset(early_pud, 0, PAGE_SIZE);
> >
> > [ Test Plan ]
> >
> > * Build an image with the patched kernel and make sure snapd and
> >    other Go programs works correctly and that you can compile a
> >    simple helloworld written in Go.
> >
> > [ Where problems could occur ]
> >
> > * The patch could be buggy.
> >
> > * Qemu will no longer work with > 256 TB of memory.
> >
> > Alexandre Ghiti (1):
> >    UBUNTU: SAUCE: riscv: mm: Force disable sv57
> >
> >   arch/riscv/mm/init.c | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> Acked-by: Tim Gardner <tim.gardner@canonical.com>
> --
> -----------
> Tim Gardner
> Canonical, Inc
>
>
> --
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox

Patch

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 2c4a64e97aec..18a0c70ed313 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -775,6 +775,10 @@  static __init void set_satp_mode(void)
                disable_pgtable_l4();
        }

+ /* UBUNTU: Force disable sv57 and fallback to sv48 */
+ if (pgtable_l5_enabled)
+ disable_pgtable_l5();
+
        memset(early_pg_dir, 0, PAGE_SIZE);
        memset(early_p4d, 0, PAGE_SIZE);
        memset(early_pud, 0, PAGE_SIZE);