riscv: Disallow to build XIP_KERNEL with SOC_SIFIVE
Alexandre Ghiti
reviewerPATCH 1/1 riscv: Disallow to build XIP_KERNEL with SOC_SIFIVE
RISCV_ERRATA_ALTERNATIVE patches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.
--- arch/riscv/Kconfig.erratas | 2 +- arch/riscv/Kconfig.socs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
arch/riscv/Kconfig.erratas +1 -1
@@ -2,7 +2,7 @@ menu "CPU errata selection" config RISCV_ERRATA_ALTERNATIVE bool "RISC-V alternative scheme" - default y + default y if !XIP_KERNEL help This Kconfig allows the kernel to automatically patch the errata required by the execution platform at run time. The
arch/riscv/Kconfig.socs +1 -0
@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE config SOC_SIFIVE bool "SiFive SoCs" + depends on !XIP_KERNEL select SERIAL_SIFIVE if TTY select SERIAL_SIFIVE_CONSOLE if TTY select CLK_SIFIVE
Signature · 1 line
2.20.1
Quoted 30 lines · Alexandre Ghiti
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.Signed-off-by Alexandre Ghiti <[email protected]>--- arch/riscv/Kconfig.erratas | 2 +- arch/riscv/Kconfig.socs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +1
-1@@ -2,7 +2,7 @@ menu "CPU errata selection" config RISCV_ERRATA_ALTERNATIVE bool "RISC-V alternative scheme" - default y + default y if !XIP_KERNEL help This Kconfig allows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +0
-0
arch/riscv/Kconfig.socs config SOC_MICROCHIP_POLARFIRE · line 12
Quoted 4 lines
arch/riscv/Kconfig.socs +1
-0@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE config SOC_SIFIVE bool "SiFive SoCs" + depends on !XIP_KERNEL
Does this mean that now all SOCs will have to explicitly say "depends on !XIP_KERNEL"
How about adding "depends on !XIP_KERNEL" for RISCV_ERRATA_ALTERNATIVE ?
Regards,
Anup
Quoted 6 lines
arch/riscv/Kconfig.socs +0
-1select SERIAL_SIFIVE if TTY select SERIAL_SIFIVE_CONSOLE if TTY select CLK_SIFIVE --2.20.1
Alex Ghiti
reviewerLe 4/29/21 à 5:04 AM, Anup Patel a écrit :
Quoted 32 lines · Alexandre Ghiti
Quoted 31 lines
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.Signed-off-by Alexandre Ghiti <[email protected]>--- arch/riscv/Kconfig.erratas | 2 +- arch/riscv/Kconfig.socs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +1
-1@@ -2,7 +2,7 @@ menu "CPU errata selection" config RISCV_ERRATA_ALTERNATIVE bool "RISC-V alternative scheme" - default y + default y if !XIP_KERNEL help This Kconfig allows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +0
-0@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE
Quoted 7 lines
arch/riscv/Kconfig.socs config SOC_MICROCHIP_POLARFIRE · line 12
Quoted 3 lines
arch/riscv/Kconfig.socs +1
-0config SOC_SIFIVE bool "SiFive SoCs" + depends on !XIP_KERNELDoes this mean that now all SOCs will have to explicitly say "depends on !XIP_KERNEL"
Quoted 1 line
How about adding "depends on !XIP_KERNEL" for
RISCV_ERRATA_ALTERNATIVE?
In any case, I had to add this because I could not get rid of the following warnings:
WARNING: unmet direct dependencies detected for ERRATA_SIFIVE
Depends on [n]: RISCV_ERRATA_ALTERNATIVE [=n] Selected by [y]:
- SOC_SIFIVE [=y]
If you have a solution for that, without touching any SOC_* config, I'll take it.
I'll try to implement what Vitaly proposed as it sounds way better than this "bandage" patch.
Thanks Anup,
Alex
Quoted 16 lines
Regards,
AnupQuoted 6 lines
select
SERIAL_SIFIVEif TTY
selectSERIAL_SIFIVE_CONSOLEif TTY
selectCLK_SIFIVE
--
2.20.1_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 5 lines · Alexandre Ghiti
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.
Could you please hold off this patch for a bit? I will try to come up with an alternative solution. It should be possible to define a special section within the RW area and place the functions that need such patching there.
Not that I like that much but at least we'll keep the ability to use XIP on SiFive.
Best regards,
Vitaly
Quoted 39 lines
Signed-off-by Alexandre Ghiti <[email protected]>--- arch/riscv/Kconfig.erratas | 2 +- arch/riscv/Kconfig.socs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +1
-1@@ -2,7 +2,7 @@ menu "CPU errata selection" config RISCV_ERRATA_ALTERNATIVE bool "RISC-V alternative scheme" - default y + default y if !XIP_KERNEL help This Kconfig allows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +1
-1@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE config SOC_SIFIVE bool "SiFive SoCs" + depends on !XIP_KERNEL select SERIAL_SIFIVE if TTY select SERIAL_SIFIVE_CONSOLE if TTY select CLK_SIFIVE --2.20.1
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Alex Ghiti
reviewerLe 4/29/21 à 5:11 AM, Vitaly Wool a écrit :
Quoted 7 lines · Alexandre Ghiti
Quoted 5 lines
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.
Quoted 6 lines
Could you please hold off this patch for a bit? I will try to come up with an alternative solution. It should be possible to define a special section within the RW area and place the functions that need such patching there.
Not that I like that much but at least we'll keep the ability to use XIP on SiFive.
Ok, I'm wondering why I did not think of that...I'll give it a try just to punish myself.
Thanks Vitaly,
Alex
Quoted 49 lines
Best regards,
VitalyQuoted 35 lines
Signed-off-by Alexandre Ghiti <[email protected]>--- arch/riscv/Kconfig.erratas | 2 +- arch/riscv/Kconfig.socs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +1
-1@@ -2,7 +2,7 @@ menu "CPU errata selection" config RISCV_ERRATA_ALTERNATIVE bool "RISC-V alternative scheme" - default y + default y if !XIP_KERNEL help This Kconfig allows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +1
-1@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIRE config SOC_SIFIVE bool "SiFive SoCs" + depends on !XIP_KERNEL select SERIAL_SIFIVE if TTY select SERIAL_SIFIVE_CONSOLE if TTY select CLK_SIFIVE --2.20.1
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Alex Ghiti
reviewerLe 4/29/21 à 8:13 AM, Alex Ghiti a écrit :
Quoted 15 lines
Le 4/29/21 à 5:11 AM, Vitaly Wool a écrit :
Quoted 7 lines · Alexandre Ghiti
Quoted 5 lines
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.Quoted 6 lines
Could you please hold off this patch for a bit? I will try to come up with an alternative solution. It should be possible to define a special section within the RW area and place the functions that need such patching there.
Not that I like that much but at least we'll keep the ability to use XIP on SiFive.
Quoted 6 lines
Ok, I'm wondering why I did not think of that...I'll give it a try just to punish myself.
Thanks Vitaly,
Alex
I tried what you proposed and it works well, *callers* must be placed into this writable section in RAM and that's it, that may be more complicated if at some point the patched functions are generic but I think we can use an intermediate riscv function to patch instead or something else.
The modifications I did only consist in putting alternative section in RAM and place the exception vector table in this section.
If you can do the proper patch, I'll let you do it, otherwise I'll do that later as I have other things to do before.
So Palmer you can drop this patch.
Thanks again,
Quoted 54 lines
Quoted 39 lines
Best regards,
VitalyQuoted 35 lines
Signed-off-by Alexandre Ghiti <[email protected]>---
arch/riscv/Kconfig.erratas| 2 +-
arch/riscv/Kconfig.socs | 1 +2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +0
-0@@ -2,7 +2,7 @@ menu "CPU errata selection"config
RISCV_ERRATA_ALTERNATIVE
bool "RISC-V alternative scheme"
- default y
+ default y if !XIP_KERNEL
help
ThisKconfigallows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +0
-0@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIREconfig
SOC_SIFIVE
bool "SiFive SoCs"
+ depends on !XIP_KERNEL
selectSERIAL_SIFIVEif TTY
selectSERIAL_SIFIVE_CONSOLEif TTY
selectCLK_SIFIVESignature · 1 line
2.20.1Quoted 10 lines
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Palmer Dabbelt
maintainerQuoted 31 lines · On Fri, 30 Apr 2021 01:09:14 PDT (-0700), [email protected] wrote:
Le 4/29/21 à 8:13 AM, Alex Ghiti a écrit :
Quoted 16 lines
Le 4/29/21 à 5:11 AM, Vitaly Wool a écrit :
Quoted 8 lines · Alexandre Ghiti
Quoted 6 lines
RISCV_ERRATA_ALTERNATIVEpatches text at runtime which is not possible when
the kernel is executed from the flash in XIP mode, and as the SIFIVE errata must be fixed somehow, disallow to build a XIP kernel that supports SIFIVE socs.Quoted 6 lines
Could you please hold off this patch for a bit? I will try to come up with an alternative solution. It should be possible to define a special section within the RW area and place the functions that need such patching there.
Not that I like that much but at least we'll keep the ability to use XIP on SiFive.Quoted 7 lines
Ok, I'm wondering why I did not think of that...I'll give it a try just to punish myself.
Thanks Vitaly,
Alex
I tried what you proposed and it works well, *callers* must be placed into this writable section in RAM and that's it, that may be more complicated if at some point the patched functions are generic but I think we can use an intermediate riscv function to patch instead or something else.
Quoted 7 lines
The modifications I did only consist in putting alternative section in RAM and place the exception vector table in this section.
If you can do the proper patch, I'll let you do it, otherwise I'll do that later as I have other things to do before.
So Palmer you can drop this patch.
Great. I was going to push back and just say "we should swap the alternatives over to the errata implemnetation for XIP, as the current ones are just a performance hit when unnecessary and XIP users are likely to build for a single SOC anyway". That would mean we'd need to sort something out WRT errata that rely on design-specific functionality, and everything I came up with there was a headache.
It's way better if we can just full support the alternatives stuff, so I'll just wait for that.
Quoted 57 lines
Thanks again,
Quoted 54 lines
Quoted 39 lines
Best regards,
VitalyQuoted 35 lines
Signed-off-by Alexandre Ghiti <[email protected]>---
arch/riscv/Kconfig.erratas| 2 +-
arch/riscv/Kconfig.socs | 1 +2 files changed, 2 insertions(+), 1 deletion(-)arch/riscv/Kconfig.erratas +0
-0@@ -2,7 +2,7 @@ menu "CPU errata selection"config
RISCV_ERRATA_ALTERNATIVE
bool "RISC-V alternative scheme"
- default y
+ default y if !XIP_KERNEL
help
ThisKconfigallows the kernel to automatically patch the errata required by the execution platform at run time. Thearch/riscv/Kconfig.socs +0
-0@@ -9,6 +9,7 @@ config SOC_MICROCHIP_POLARFIREconfig
SOC_SIFIVE
bool "SiFive SoCs"
+ depends on !XIP_KERNEL
selectSERIAL_SIFIVEif TTY
selectSERIAL_SIFIVE_CONSOLEif TTY
selectCLK_SIFIVE
--
2.20.1Quoted 10 lines
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv