Skip to contentSkip to conversation

riscv: Work to remove kernel dependence on the M-extension

PATCH In review Michael T. Kloos 5 participants 16 messages Mar 9, 2022 – Apr 2, 2022 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Work to remove kernel dependence on the M-extension

Added a new config symbol RISCV_ISA_M to enable the usage of the multiplication, division, and remainder (modulus) instructions from the M-extension. This configures the march build flag to either include or omit it.

I didn't find any assembly using any of the instructions from the M-extension. However, the BPF JIT is a complicating factor. Currently, it emits M-extension instructions to implement various BPF operations. For now, I have made HAVE_EBPF_JIT depend on CONFIG_RISCV_ISA_M.

I have added the supplementary integer arithmetic functions in the file "arch/riscv/lib/ext_m_supplement.c". All the code contained in this file is wrapped in an ifndef contingent on the presence of CONFIG_RISCV_ISA_M.

---
 arch/riscv/Kconfig                |  20 +-
 arch/riscv/Makefile               |   6 +-
 arch/riscv/lib/Makefile           |   1 +
 arch/riscv/lib/ext_m_supplement.c | 588 ++++++++++++++++++++++++++++++
 4 files changed, 608 insertions(+), 7 deletions(-)
 create mode 100644 arch/riscv/lib/ext_m_supplement.c
arch/riscv/Kconfig +15 -5
index 5adcbd9b5e88..40e1110a405c 100644
@@ -83,7 +83,7 @@ config RISCV
 	select HAVE_CONTEXT_TRACKING
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DMA_CONTIGUOUS if MMU
-	select HAVE_EBPF_JIT if MMU
+	select HAVE_EBPF_JIT if (MMU && RISCV_ISA_M)
 	select HAVE_FUNCTION_ERROR_INJECTION
 	select HAVE_GCC_PLUGINS
 	select HAVE_GENERIC_VDSO if MMU && 64BIT
@@ -323,15 +323,25 @@ config NODES_SHIFT
 	  Specify the maximum number of NUMA Nodes available on the target
 	  system.  Increases memory reserved to accommodate various tables.
 
+config RISCV_ISA_M
+	bool "Emit multiplication instructions when building Linux"
+	default y
+	help
+	  Adds "M" to the ISA subsets that the toolchain is allowed to emit
+	  when building Linux, which results in multiplication, division, and
+	  remainder instructions in the Linux binary.
+
+	  If you don't know what to do here, say Y.
+
 config RISCV_ISA_C
 	bool "Emit compressed instructions when building Linux"
 	default y
 	help
-	   Adds "C" to the ISA subsets that the toolchain is allowed to emit
-	   when building Linux, which results in compressed instructions in the
-	   Linux binary.
+	  Adds "C" to the ISA subsets that the toolchain is allowed to emit
+	  when building Linux, which results in compressed instructions in the
+	  Linux binary.
 
-	   If you don't know what to do here, say Y.
+	  If you don't know what to do here, say Y.
 
 menu "supported PMU type"
 	depends on PERF_EVENTS
arch/riscv/Makefile +4 -2
index 7d81102cffd4..7e24cfe51ef7 100644
@@ -46,8 +46,10 @@ endif
 endif
 
 # ISA string setting
-riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32ima
-riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64ima
+riscv-march-$(CONFIG_ARCH_RV32I)	:= rv32i
+riscv-march-$(CONFIG_ARCH_RV64I)	:= rv64i
+riscv-march-$(CONFIG_RISCV_ISA_M)	:= $(riscv-march-y)m
+riscv-march-y				:= $(riscv-march-y)a
 riscv-march-$(CONFIG_FPU)		:= $(riscv-march-y)fd
 riscv-march-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-y)c
 
arch/riscv/lib/Makefile +1 -0
index 25d5c9664e57..965eebaaa1ce 100644
@@ -5,5 +5,6 @@ lib-y			+= memset.o
 lib-y			+= memmove.o
 lib-$(CONFIG_MMU)	+= uaccess.o
 lib-$(CONFIG_64BIT)	+= tishift.o
+lib-y			+= ext_m_supplement.o
 
 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
arch/riscv/lib/ext_m_supplement.c new file +588 -0

588 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
Quoted 12 lines · Michael T. Kloos

Added a new config symbol RISCV_ISA_M to enable the usage of the multiplication, division, and remainder (modulus) instructions from the M-extension. This configures the march build flag to either include or omit it.

I didn't find any assembly using any of the instructions from the M-extension. However, the BPF JIT is a complicating factor. Currently, it emits M-extension instructions to implement various BPF operations. For now, I have made HAVE_EBPF_JIT depend on CONFIG_RISCV_ISA_M.

Quoted 6 lines

I have added the supplementary integer arithmetic functions in the file "arch/riscv/lib/ext_m_supplement.c". All the code contained in this file is wrapped in an ifndef contingent on the presence of CONFIG_RISCV_ISA_M.

The patch looks fine to me, but I increasingly get the feeling that the entire platform feature selection in Kconfig should be guarded with a global flag that switches between "fully generic" and "fully custom" builds, where the generic kernel assumes that all the standard features (64-bit, C, M, FPU, MMU, UEFI, ...) are present, the incompatible options (XIP, PHYS_RAM_BASE_FIXED, CMDLINE_FORCE, BUILTIN_DTB, ...) are force-disabled,
and all optional features (V/B/P/H extensions, custom instructions, platform specific device drivers, ...) are runtime detected.

At the moment, those three types are listed at the same level, which gives the impression that they can be freely mixed.

Arnd

#2 lore raw

Thank you for your feedback. I don't really have much of an opinion about that right now aside from that I know where things are in the current structure and am comfortable. My goal with this contribution was to keep it in-line with the current config structure. Hence, I put it right next to the menuconfig option to control CONFIG_RISCV_ISA_C under Platform Type.

I wouldn't necessarily be opposed to rethinking the way platform feature selection is presented in menuconfig. If people feel that most users will be looking for an rv64gc config and that it should be made for clear, perhaps it could be done. I would need to do more thinking about how exactly that would look.

I do think that it is outside the scope of this patch. Were you working on something like that and worried about a merge conflict?

Michael

Quoted 33 lines · Arnd Bergmann
Quoted 11 lines · Michael T. Kloos

Added a new config symbol RISCV_ISA_M to enable the usage of the multiplication, division, and remainder (modulus) instructions from the M-extension. This configures the march build flag to either include or omit it.

I didn't find any assembly using any of the instructions from the M-extension. However, the BPF JIT is a complicating factor. Currently, it emits M-extension instructions to implement various BPF operations. For now, I have made HAVE_EBPF_JIT depend on CONFIG_RISCV_ISA_M.

Quoted 6 lines

I have added the supplementary integer arithmetic functions in the file "arch/riscv/lib/ext_m_supplement.c". All the code contained in this file is wrapped in an ifndef contingent on the presence of CONFIG_RISCV_ISA_M.

The patch looks fine to me, but I increasingly get the feeling that the entire platform feature selection in Kconfig should be guarded with a global flag that switches between "fully generic" and "fully custom" builds, where the generic kernel assumes that all the standard features (64-bit, C, M, FPU, MMU, UEFI, ...) are present, the incompatible options (XIP, PHYS_RAM_BASE_FIXED, CMDLINE_FORCE, BUILTIN_DTB, ...) are force-disabled,
and all optional features (V/B/P/H extensions, custom instructions, platform specific device drivers, ...) are runtime detected.

At the moment, those three types are listed at the same level, which gives the impression that they can be freely mixed.

Arnd

#3 lore raw
Quoted 8 lines · Michael T. Kloos

Thank you for your feedback. I don't really have much of an opinion about that right now aside from that I know where things are in the current structure and am comfortable. My goal with this contribution was to keep it in-line with the current config structure. Hence, I put it right next to the menuconfig option to control CONFIG_RISCV_ISA_C under Platform Type.

Quoted 8 lines

I wouldn't necessarily be opposed to rethinking the way platform feature selection is presented in menuconfig. If people feel that most users will be looking for an rv64gc config and that it should be made for clear, perhaps it could be done. I would need to do more thinking about how exactly that would look.

I do think that it is outside the scope of this patch. Were you working on something like that and worried about a merge conflict?

As I said, I think your patch is ok, and I have no objections to it being merged. It's just one more option among others that can cause problems if users get it wrong.

Arnd

maintainer
#4 lore raw
In reply to Arnd Bergmann
Quoted 21 lines · Arnd Bergmann
Quoted 12 lines · Michael T. Kloos

Added a new config symbol RISCV_ISA_M to enable the usage of the multiplication, division, and remainder (modulus) instructions from the M-extension. This configures the march build flag to either include or omit it.

I didn't find any assembly using any of the instructions from the M-extension. However, the BPF JIT is a complicating factor. Currently, it emits M-extension instructions to implement various BPF operations. For now, I have made HAVE_EBPF_JIT depend on CONFIG_RISCV_ISA_M.

Quoted 6 lines

I have added the supplementary integer arithmetic functions in the file "arch/riscv/lib/ext_m_supplement.c". All the code contained in this file is wrapped in an ifndef contingent on the presence of CONFIG_RISCV_ISA_M.

Quoted 9 lines

The patch looks fine to me, but I increasingly get the feeling that the entire platform feature selection in Kconfig should be guarded with a global flag that switches between "fully generic" and "fully custom" builds, where the generic kernel assumes that all the standard features (64-bit, C, M, FPU, MMU, UEFI, ...) are present, the incompatible options (XIP, PHYS_RAM_BASE_FIXED, CMDLINE_FORCE, BUILTIN_DTB, ...) are force-disabled,
and all optional features (V/B/P/H extensions, custom instructions, platform specific device drivers, ...) are runtime detected.

That'd be wonderful, but unfortunately we're trending the other way -- we're at the point where "words in the specification have meaning" is controversial, so trying to talk about which flavors of the specification are standard is just meaningless. I obviously hope that gets sorted out, as we've clearly been pointed straight off a cliff for a while now, but LMKL isn't the place to have that discussion. We've all seen this before, nobody needs to be convinced this leads to a mess.

Until we get to the point where "I wrote 'RISC-V' on that potato I found in my couch" can be conclusively determined not compliant with the spec, it's just silly to try and talk about what is.

Quoted 4 lines

At the moment, those three types are listed at the same level, which gives the impression that they can be freely mixed.

Arnd

#5 lore raw
Quoted 11 lines · Palmer Dabbelt
Quoted 1 line · Arnd Bergmann

On Wed, Mar 9, 2022 at 6:28 AM Michael T. Kloos <[email protected]> wrote:

That'd be wonderful, but unfortunately we're trending the other way -- we're at the point where "words in the specification have meaning" is controversial, so trying to talk about which flavors of the specification are standard is just meaningless. I obviously hope that gets sorted out, as we've clearly been pointed straight off a cliff for a while now, but LMKL isn't the place to have that discussion. We've all seen this before, nobody needs to be convinced this leads to a mess.

Quoted 3 lines

Until we get to the point where "I wrote 'RISC-V' on that potato I found in my couch" can be conclusively determined not compliant with the spec, it's just silly to try and talk about what is.

I would argue that codifying the required extensions through kernel source code is much stronger than interpreting a specification. Ideally the specification
would match what the kernel requires, but it's not the end of the world if the kernel ends up making decisions that are different: If Linux can do runtime detection of non-M, non-A or pre-standard extensions and handle them correctly without a notable performance impact, it can do that. Or Linux could end up requiring things that are normally there but not in the scope of the spec.

Regardless of who determines what the compatible subset is, I think there is value in splitting out Kconfig options that prevent booting on normal RV64GC machines (XIP, NOMMU, 32-bit, ...). This would probably not include the non-M option, as long as a non-M kernel works as expected on CPUs with the M instructions.

Arnd

maintainer
#6 lore raw
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines · Palmer Dabbelt
Quoted 1 line · Arnd Bergmann

On Wed, Mar 9, 2022 at 6:28 AM Michael T. Kloos <[email protected]> wrote:

That'd be wonderful, but unfortunately we're trending the other way -- we're at the point where "words in the specification have meaning" is controversial, so trying to talk about which flavors of the specification are standard is just meaningless. I obviously hope that gets sorted out, as we've clearly been pointed straight off a cliff for a while now, but LMKL isn't the place to have that discussion. We've all seen this before, nobody needs to be convinced this leads to a mess.

Quoted 5 lines
Quoted 3 lines

Until we get to the point where "I wrote 'RISC-V' on that potato I found in my couch" can be conclusively determined not compliant with the spec, it's just silly to try and talk about what is.

I would argue that codifying the required extensions through kernel source

The problem here isn't the required extensions, it's that vendors can claim to implement an extension on hardware that doesn't exhibit any of the behavior the specification expresses that systems with those extensions must have. The D1 is a very concrete example of this.

Quoted 9 lines

code is much stronger than interpreting a specification. Ideally the specification
would match what the kernel requires, but it's not the end of the world if the kernel ends up making decisions that are different: If Linux can do runtime detection of non-M, non-A or pre-standard extensions and handle them correctly without a notable performance impact, it can do that. Or Linux could end up requiring things that are normally there but not in the scope of the spec.

Quoted 5 lines

Regardless of who determines what the compatible subset is, I think there is value in splitting out Kconfig options that prevent booting on normal RV64GC machines (XIP, NOMMU, 32-bit, ...). This would probably not include the non-M option, as long as a non-M kernel works as expected on CPUs with the M instructions.

I get the value to having an option hiding these things, as users might shoot themselves in the foot. I sent a patch, not sure it's exactly what we want but at least it's something concrete to discuss.

#7 lore raw

Hi!

Quoted 12 lines
Quoted 12 lines
Quoted 11 lines

That'd be wonderful, but unfortunately we're trending the other way -- we're at the point where "words in the specification have meaning" is controversial, so trying to talk about which flavors of the specification are standard is just meaningless. I obviously hope that gets sorted out, as we've clearly been pointed straight off a cliff for a while now, but LMKL isn't the place to have that discussion. We've all seen this before, nobody needs to be convinced this leads to a mess.

Until we get to the point where "I wrote 'RISC-V' on that potato I found in my couch" can be conclusively determined not compliant with the spec, it's just silly to try and talk about what is.

Quoted 6 lines
Quoted 1 line

I would argue that codifying the required extensions through kernel source

The problem here isn't the required extensions, it's that vendors can claim to implement an extension on hardware that doesn't exhibit any of the behavior the specification expresses that systems with those extensions must have. The D1 is a very concrete example of this.

Sounds like someone interested should make a webpage listing available CPUs that claim RISC-V compatibility but far short of advertised claims?

I'd like to get RISC-V board to play with sometime soon, and some help in what board to get would be welcome...

Best regards,
Pavel

Signature · 1 line
People of Russia, stop Putin before his war on Ukraine escalates.
maintainer
#9 lore raw
Quoted 1 line · Christoph Hellwig

Why?

I have no idea, but this has come up a few times before.

IIRC the original port had a no-M flavor (don't remember if it even made it to the original patch submission, but it was around for a bit). We decided to drop this under the theory that nobody would use it: essentially, if you can afford the handful of MiB of memory required to run Linux then you've probably got a multiplier.

If someone has hardware that lacks M and users care about running Linux on that then I'm happy to support it. I'll still point out the silliness of that decision, but if it's too late to change things then I'd rather support the hardware. If it's one of these "fill out every possible allowed ISA flavor, even if nobody has one that runs Linux" then I don't see a reason to bother -- there's an infinite amount of allowable RISC-V implementations, we'll all go crazy chasing them around.

FWIW: to a first order, that applies to the no-A stuff as well (though that got dropped because the Arm folks pointed out a way to support that was way better than ours).

#10 lore raw
Quoted 7 lines · Palmer Dabbelt

If someone has hardware that lacks M and users care about running Linux on that then I'm happy to support it. I'll still point out the silliness of that decision, but if it's too late to change things then I'd rather support the hardware. If it's one of these "fill out every possible allowed ISA flavor, even if nobody has one that runs Linux" then I don't see a reason to bother -- there's an infinite amount of allowable RISC-V implementations, we'll all go crazy chasing them around.

It's not like Linux had required M mode since the RISC-V port was merged upstream, so any new implementor really should know about it. And performance on anything that requires Linux will just be horrible. I could see a bit of an excuse for a nommu port.

Anyway, this kind of patch really does need to state the why. And it better be a really good reason.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#11 lore raw
In reply to Palmer Dabbelt

As far as I can tell, it's simply a compiler flag to enable or disable it. The only complicating issue that I found was the BPF JIT. That is a special case amounting to a compiler within the kernel itself and can be patched or set to depend on M. There is still the BPF interpreter. The kernel doesn't depend on the C-extension. I have grepped through the source code where that symbol is referenced, the checking of instruction alignment constraints, and various checks used to make that work are much more extensive than I expected, yet that is supported. To quote the commentary from the beginning of chapter 2 (Base-I) of the RISC-V spec:

Quoted 10 lines

"RV32I was designed to be sufficient to form a compiler target and to support modern operating system environments. The ISA was also designed to reduce the hardware required in a minimal implementation. RV32I contains 40 unique instructions, though a simple implementation might cover the ECALL/EBREAK instructions with a single SYSTEM hardware instruction that always traps and might be able to implement the FENCE instruction as a NOP, reducing base instruction count to 38 total. RV32I can emulate almost any other ISA extension (except the A extension, which requires additional hardware support for atomicity).

Quoted 8 lines

In practice, a hardware implementation including the machine-mode privileged architecture will also require the 6 CSR instructions.

Subsets of the base integer ISA might be useful for pedagogical purposes, but the base has been defined such that there should be little incentive to subset a real hardware implementation beyond omitting support for misaligned memory accesses and treating all SYSTEM instructions as a single trap."

This is all a noble goal of RISC-V, to create a minimal, yet robust ISA. I'm not arguing to support no-A, as stated in the commentary, atomic can not be emulated (I mean, maybe you could by taking over sscratch) and the atomic properties of the CSR instructions. But that does seem hacky.) and everything else is handled in the Base-I (Not including Zicsr). The kernel supports rv(32/64)ima so to draw the line in the sand that rv(32/64)ia is unacceptable seems silly.

One of my concerns here is that if support is not added, that people may start writing assembly that uses M instructions and other non-portable stuff. This will make a future port more difficult.

I do not have real hardware like this but I do have an emulator that implements rv32iasu. Eventually I want to build a HART implementation out of real hardware logic chips. Adding M, adds hardware complexity and I think that it is better to do in software for such a minimal case. Sure it will be slower than having native hardware M support. Firmware emulation will be even slower than that. I'd much rather have the option in the kernel to switch this on or off.

I am not trying to argue that the kernel should bend over to support my pet projects, but it seems quite strange and arbitrary to draw the line here over such a beautifully modular and minimal ISA.

Quoted 3 lines

there's an infinite amount of
allowable RISC-V implementations, we'll all go crazy chasing them around.

2 points on that:

1) Then it would seem logical to have the kernel target the most minimal implementation to get the widest support.

2) I actually don't think this is entirely true, or at least not in the sense that it is relevant to the kernel. Atomics are needed for a modern system. The kernel needs to know about the floating-point support because it needs to handle the clean-up and context-switching of the additional floating point registers. The kernel needs to know about the C extension because of the ramifications to alignment. Everything else is just gravy. If sometime in the future the L-extension or the B-extension are finished and implemented in future hardware, unless they make some very strange decisions, I don't see why a kernel built today couldn't run on that hardware with userspace software taking advantage of those native features. Sure, in that situation, the kernel binary wouldn't be taking advantage of them. But then wouldn't you want to add CONFIG_RISCV_ISA_L and CONFIG_RISCV_ISA_B in said future kernel so that the compiler is passed an -march value such that the kernel can take advantage of these new native hardware features?

It seems to me that this is the grand vision in the modularity of both the RISC-V ISA and the C programming language. We aren't writing everything in assembly for a reason. I don't think it makes sense to stop one extension away from what the RISC-V spec documents themselves state is the intended minimal system capable of running a full modern operating system. I think it is an arbitrary limit to the portability of the kernel.

Michael

Quoted 19 lines · Palmer Dabbelt
Quoted 1 line · Christoph Hellwig

Why?

I have no idea, but this has come up a few times before. IIRC the original port had a no-M flavor (don't remember if it even made it to the original patch submission, but it was around for a bit).  We decided to drop this under the theory that nobody would use it:
essentially, if you can afford the handful of MiB of memory required to run Linux then you've probably got a multiplier.
If someone has hardware that lacks M and users care about running Linux on that then I'm happy to support it.  I'll still point out the silliness of that decision, but if it's too late to change things then I'd rather support the hardware.  If it's one of these "fill out every possible allowed ISA flavor, even if nobody has one that runs Linux" then I don't see a reason to bother -- there's an infinite amount of allowable RISC-V implementations, we'll all go crazy chasing them around.
FWIW: to a first order, that applies to the no-A stuff as well (though that got dropped because the Arm folks pointed out a way to support that was way better than ours).

#12 lore raw

Some other thoughts:
It sounds like I am not the first person to want this feature and I probably won't be the last. I created the change for my own reasons, the same as any other contributor. I think we all know that I can not pull out some chart and say, "This many people want this and here is why." I live in central Ohio and have been doing this as a hobby. I don't even know anyone else who knows about systems and operating system development. If the justification that you are looking for is that I as some hypothetical developer at a major tech company is about to release a new RISC-V chip without M support but we want it to run Linux, I can not provide that answer. It sounds a bit like some software or hardware, chicken or the egg anyway. Trying to maintain my own fork if people start contributing patches with incompatible assembly scares me.

Michael

Quoted 97 lines · Michael T. Kloos

As far as I can tell, it's simply a compiler flag to enable or disable it. The only complicating issue that I found was the BPF JIT.  That is a special case amounting to a compiler within the kernel itself and can be patched or set to depend on M.  There is still the BPF interpreter.  The kernel doesn't depend on the C-extension.  I have grepped through the source code where that symbol is referenced, the checking of instruction alignment constraints, and various checks used to make that work are much more extensive than I expected, yet that is supported.  To quote the commentary from the beginning of chapter 2 (Base-I) of the RISC-V spec:

Quoted 8 lines

"RV32I was designed to be sufficient to form a compiler target and to support modern operating system environments. The ISA was also designed to reduce the hardware required in a minimal implementation. RV32I contains 40 unique instructions, though a simple implementation might cover the ECALL/EBREAK instructions with a single SYSTEM hardware instruction that always traps and might be able to implement the FENCE instruction as a NOP, reducing base instruction count to 38 total. RV32I can emulate almost any other ISA extension (except the A extension,

Quoted 8 lines

which requires additional hardware support for atomicity).
In practice, a hardware implementation including the machine-mode privileged architecture will also require the 6 CSR instructions. Subsets of the base integer ISA might be useful for pedagogical purposes, but the base has been defined such that there should be little incentive to subset a real hardware implementation beyond omitting support for misaligned memory accesses and treating all SYSTEM instructions as a single trap."

This is all a noble goal of RISC-V, to create a minimal, yet robust ISA. I'm not arguing to support no-A, as stated in the commentary, atomic can not be emulated (I mean, maybe you could by taking over sscratch) and the atomic properties of the CSR instructions.  But that does seem hacky.) and everything else is handled in the Base-I (Not including Zicsr).  The kernel supports rv(32/64)ima so to draw the line in the sand that rv(32/64)ia is unacceptable seems silly.
One of my concerns here is that if support is not added, that people may start writing assembly that uses M instructions and other non-portable stuff.  This will make a future port more difficult.
I do not have real hardware like this but I do have an emulator that implements rv32iasu.  Eventually I want to build a HART implementation out of real hardware logic chips.  Adding M, adds hardware complexity and I think that it is better to do in software for such a minimal case. Sure it will be slower than having native hardware M support.  Firmware emulation will be even slower than that.  I'd much rather have the option in the kernel to switch this on or off.
I am not trying to argue that the kernel should bend over to support my pet projects, but it seems quite strange and arbitrary to draw the line here over such a beautifully modular and minimal ISA.

Quoted 3 lines

there's an infinite amount of
allowable RISC-V implementations, we'll all go crazy chasing them around.

2 points on that:
1) Then it would seem logical to have the kernel target the most minimal implementation to get the widest support.
2) I actually don't think this is entirely true, or at least not in the sense that it is relevant to the kernel.  Atomics are needed for a modern system.  The kernel needs to know about the floating-point support because it needs to handle the clean-up and context-switching of the additional floating point registers.  The kernel needs to know about the C extension because of the ramifications to alignment.  Everything else is just gravy. If sometime in the future the L-extension or the B-extension are finished and implemented in future hardware, unless they make some very strange decisions, I don't see why a kernel built today couldn't run on that hardware with userspace software taking advantage of those native features. Sure, in that situation, the kernel binary wouldn't be taking advantage of them.  But then wouldn't you want to add CONFIG_RISCV_ISA_L and CONFIG_RISCV_ISA_B in said future kernel so that the compiler is passed an -march value such that the kernel can take advantage of these new native hardware features?
It seems to me that this is the grand vision in the modularity of both the RISC-V ISA and the C programming language.  We aren't writing everything in assembly for a reason.  I don't think it makes sense to stop one extension away from what the RISC-V spec documents themselves state is the intended minimal system capable of running a full modern operating system.  I think it is an arbitrary limit to the portability of the kernel.
    Michael

Quoted 11 lines · Palmer Dabbelt
Quoted 1 line · Christoph Hellwig

Why?

I have no idea, but this has come up a few times before. IIRC the original port had a no-M flavor (don't remember if it even made it to the original patch submission, but it was around for a bit).  We decided to drop this under the theory that nobody would use it:
essentially, if you can afford the handful of MiB of memory required to run Linux then you've probably got a multiplier.
If someone has hardware that lacks M and users care about running Linux on that then I'm happy to support it.  I'll still point out the silliness of that decision, but if it's too late to change things then

Quoted 8 lines

I'd rather support the hardware.  If it's one of these "fill out every possible allowed ISA flavor, even if nobody has one that runs Linux" then I don't see a reason to bother -- there's an infinite amount of allowable RISC-V implementations, we'll all go crazy chasing them around.
FWIW: to a first order, that applies to the no-A stuff as well (though that got dropped because the Arm folks pointed out a way to support that was way better than ours).

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#13 lore raw

Is there something I can do that would help alleviate your concerns or apprehension?

Quoted 14 lines · Michael T. Kloos

Some other thoughts:
It sounds like I am not the first person to want this feature and I probably won't be the last.  I created the change for my own reasons, the same as any other contributor.  I think we all know that I can not pull out some chart and say, "This many people want this and here is why."  I live in central Ohio and have been doing this as a hobby.  I don't even know anyone else who knows about systems and operating system development. If the justification that you are looking for is that I as some hypothetical developer at a major tech company is about to release a new RISC-V chip without M support but we want it to run Linux, I can not provide that answer.  It sounds a bit like some software or hardware, chicken or the egg anyway.  Trying to maintain my own fork if people start contributing patches with incompatible assembly scares me.
    Michael

maintainer
#14 lore raw
Quoted 2 lines · On Thu, 10 Mar 2022 05:37:27 PST (-0800), [email protected] wrote:

Is there something I can do that would help alleviate your concerns or apprehension?

IMO this is one of those cases where having hardware is required.

I can understand the goal of providing a Linux port for the minimal RISC-V compatible system, but IIUC the minimal RISC-V compatible system is any object associated with a member of the RISC-V foundation that said member attests is a RISC-V system. There's really no way to implement Linux on all such systems so we have to set the bar somewhere, and bar is generally set at "more time will be spent using this than maintaining it". Systems without M have generally not met that bar, and I don't see anything changing now.

If you have users then I'm happy to reconsider, the goal here is to make real systems work. That said: we've already got enough trouble trying to make actual shipping hardware function correctly, we're all going to lose our minds trying to chase around everything that could in theory be a RISC-V system but doesn't actually exist.

Quoted 17 lines · Michael T. Kloos
Quoted 15 lines

Some other thoughts:
It sounds like I am not the first person to want this feature and I probably won't be the last.  I created the change for my own reasons, the same as any other contributor.  I think we all know that I can not pull out some chart and say, "This many people want this and here is why."  I live in central Ohio and have been doing this as a hobby.  I don't even know anyone else who knows about systems and operating system development. If the justification that you are looking for is that I as some hypothetical developer at a major tech company is about to release a new RISC-V chip without M support but we want it to run Linux, I can not provide that answer.  It sounds a bit like some software or hardware, chicken or the egg anyway.  Trying to maintain my own fork if people start contributing patches with incompatible assembly scares me.
    Michael

#15 lore raw

Well at least I can take some satisfaction in that it seems that on my 2nd patch sent to the Linux kernel, I got it right the first time. No one has complained about problems with the code itself, just that they don't want the feature. I have also received no errors back from the build bot.

For now, I will try to maintain this port on my own. Thank you for the consideration Palmer.

Michael

Quoted 38 lines · Palmer Dabbelt
Quoted 2 lines · On Thu, 10 Mar 2022 05:37:27 PST (-0800), [email protected] wrote:

Is there something I can do that would help alleviate your concerns or apprehension?

IMO this is one of those cases where having hardware is required.

I can understand the goal of providing a Linux port for the minimal RISC-V compatible system, but IIUC the minimal RISC-V compatible system is any object associated with a member of the RISC-V foundation that said member attests is a RISC-V system. There's really no way to implement Linux on all such systems so we have to set the bar somewhere, and bar is generally set at "more time will be spent using this than maintaining it". Systems without M have generally not met that bar, and I don't see anything changing now.

If you have users then I'm happy to reconsider, the goal here is to make real systems work. That said: we've already got enough trouble trying to make actual shipping hardware function correctly, we're all going to lose our minds trying to chase around everything that could in theory be a RISC-V system but doesn't actually exist.

Quoted 17 lines · Michael T. Kloos
Quoted 15 lines

Some other thoughts:
It sounds like I am not the first person to want this feature and I probably won't be the last.  I created the change for my own reasons, the same as any other contributor.  I think we all know that I can not pull out some chart and say, "This many people want this and here is why."  I live in central Ohio and have been doing this as a hobby.  I don't even know anyone else who knows about systems and operating system development. If the justification that you are looking for is that I as some hypothetical developer at a major tech company is about to release a new RISC-V chip without M support but we want it to run Linux, I can not provide that answer.  It sounds a bit like some software or hardware, chicken or the egg anyway.  Trying to maintain my own fork if people start contributing patches with incompatible assembly scares me.
    Michael