linux kernel, how to enable 'sv39' based address translation

570 views
Skip to first unread message

vithurson subasharan

unread,
Jul 12, 2022, 6:16:41 PM7/12/22
to RISC-V SW Dev
Hi,

How to configure the latest linux kernel to build it for sv39 support, it seems it's building for sv57..

Thanks Regards,
Vithurson

Bruce Hoult

unread,
Jul 12, 2022, 6:25:19 PM7/12/22
to vithurson subasharan, RISC-V SW Dev
I suspect what you're seeing is an ability for a kernel to support sv57 hardware, not a requirement for it.

4.6 Sv57: Page-Based 57-bit Virtual-Memory System

Implementations that support Sv57 must also support Sv48.
-----------------
Systems that support Sv57 can also support Sv48 at essentially no cost, and so should do so to maintain compatibility with supervisor software that assumes Sv48.


4.5 Sv48: Page-Based 48-bit Virtual-Memory System

Implementations that support Sv48 must also support Sv39.
----------------
Systems that support Sv48 can also support Sv39 at essentially no cost, and so should do so to maintain compatibility with supervisor software that assumes Sv39.

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/352411da-3703-48c0-84b0-eab7be032d49n%40groups.riscv.org.

vithurson subasharan

unread,
Jul 12, 2022, 6:47:47 PM7/12/22
to Bruce Hoult, RISC-V SW Dev
My system only support sv39, I want to the kernel to be configured for sv39, because in .config file i see that,
CONFIG_PAGE_OFFSET=0xff60000000000000
CONFIG_ARCH_FLATMEM_ENABLE=y
CONFIG_ARCH_SPARSEMEM_ENABLE=y
CONFIG_ARCH_SELECT_MEMORY_MODEL=y
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_GENERIC_BUG=y
CONFIG_GENERIC_BUG_RELATIVE_POINTERS=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
CONFIG_GENERIC_CSUM=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_FIX_EARLYCON_MEM=y
CONFIG_PGTABLE_LEVELS=5
CONFIG_LOCKDEP_SUPPORT=y

It should be 3 for sv39, but directly changing it , not helping for me. When I ran it on my, satp.mode is set to 10 (sv57) by the kernel despite parsing the mmu-type='riscv,sv39'  as an argument in the device tree.

Tommy Murphy

unread,
Jul 13, 2022, 2:23:39 AM7/13/22
to vithurson subasharan, Bruce Hoult, RISC-V SW Dev
This is probably why it's defaulting to 5 (sv48):


But this suggests that 3 (sv39) should be possible:

vithurson subasharan

unread,
Jul 13, 2022, 3:02:53 AM7/13/22
to RISC-V SW Dev, tommy_...@hotmail.com, RISC-V SW Dev, vithurson subasharan, Bruce Hoult
Hi Tommy,

Thanks for the Reply, the second article seems to be last updated on 2021, before linux kernel updated support for sv57. I was wondering what option to change to make it support LEVEL 3 aka sv39. changing the KConfig results in the following error message
In file included from ./include/linux/mm.h:29,
                 from arch/riscv/kernel/asm-offsets.c:10:
./include/linux/pgtable.h:19:2: error: #error CONFIG_PGTABLE_LEVELS is not consistent with __PAGETABLE_{P4D,PUD,PMD}_FOLDED
   19 | #error CONFIG_PGTABLE_LEVELS is not consistent with __PAGETABLE_{P4D,PUD,PMD}_FOLDED

thanks.

Tommy Murphy

unread,
Jul 13, 2022, 6:52:29 AM7/13/22
to vithurson subasharan, RISC-V SW Dev, RISC-V SW Dev, vithurson subasharan, Bruce Hoult
Doesn't what Bruce said earlier mean that you can configure the kernel for sv48 but then, at runtime, you can use either sv48 OR sv39? Have you tried that?

vithurson subasharan

unread,
Jul 13, 2022, 8:22:22 AM7/13/22
to Tommy Murphy, RISC-V SW Dev, Bruce Hoult
Hi Tommy, 
I tried running it, with the below device tree entry. but still it is configuring the satp.mmode to 0xa which is sv57. 

CPU0: cpu@0 {
device_type = "cpu";
reg = <0>;
status = "okay";
compatible = "riscv";
riscv,isa = "rv64ima";
mmu-type = "riscv,sv39";
clock-frequency = <50000000>;
CPU0_intc: interrupt-controller {
#interrupt-cells = <1>;
interrupt-controller;
compatible = "riscv,cpu-intc";
};
};
};

thank you,
vithurson

Bruce Hoult

unread,
Jul 13, 2022, 5:06:19 PM7/13/22
to vithurson subasharan, Tommy Murphy, RISC-V SW Dev
If your hardware doesn't support sv57 then for sure it is NOT configuring satp.mmode to sv57. It might be *trying* *to*, as a probe to see if it is supported, before falling back to sv48 and then sv39.

--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.

vithurson subasharan

unread,
Jul 13, 2022, 5:16:05 PM7/13/22
to Bruce Hoult, Tommy Murphy, RISC-V SW Dev
So i need to generate page in such instances, is it? 

vithurson subasharan

unread,
Jul 13, 2022, 7:21:59 PM7/13/22
to RISC-V SW Dev, vithurson subasharan, tommy_...@hotmail.com, RISC-V SW Dev, Bruce Hoult
Hi Bruce, Tommy,

I figured it out. I simply need to avoid writing to satp.mode when it's not sv39. since it is Write Any Read Legal field

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages