arch-riscv: Make Zicbom/Zicboz extensions optional in FS mode

Currently, we're enable Zicbom/Zicboz by default. Since those
extensions might be buggy as they are not well-tested, making
those entensions optional allows running simulation where
the performance implication of the instructions do not matter.

Effectively, by turning off the extensions, we simply remove
those extensions from the device tree, so the OS would not
use them. It doesn't prohibit the userspace application to
use those instructions, however.

Change-Id: Ib30e98c4c39f741dec5f7d31bd7b832391686840
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
This commit is contained in:
Hoa Nguyen
2023-10-30 02:41:26 +00:00
parent 7c6fcb3838
commit 68287604ee
2 changed files with 19 additions and 2 deletions

View File

@@ -96,6 +96,9 @@ class RiscvISA(BaseISA):
ELEN in Ch. 2 of RISC-V vector spec",
)
enable_Zicbom_fs = Param.Bool(True, "Enable Zicbom extension in FS mode")
enable_Zicboz_fs = Param.Bool(True, "Enable Zicboz extension in FS mode")
def get_isa_string(self):
isa_extensions = []
# check for the base ISA type
@@ -110,8 +113,10 @@ class RiscvISA(BaseISA):
isa_extensions.append("v")
isa_string = "".join(isa_extensions)
isa_string += "_Zicbom" # Cache-block Management Instructions
isa_string += "_Zicboz" # Cache-block Zero Instruction
if self.enable_Zicbom_fs.value:
isa_string += "_Zicbom" # Cache-block Management Instructions
if self.enable_Zicboz_fs.value:
isa_string += "_Zicboz" # Cache-block Zero Instruction
isa_string += "_Zicntr" # Performance Couter Spec
isa_string += "_Zicsr" # RMW CSR Instructions (Privileged Spec)
isa_string += "_Zifencei" # FENCE.I Instruction (Unprivileged Spec)

View File

@@ -279,6 +279,18 @@ class RiscvBoard(AbstractSystemBoard, KernelDiskWorkload):
node.append(FdtPropertyStrings("device_type", "cpu"))
node.append(FdtPropertyWords("reg", state.CPUAddrCells(i)))
node.append(FdtPropertyStrings("mmu-type", "riscv,sv48"))
if core.core.isa[0].enable_Zicbom_fs.value:
node.append(
FdtPropertyWords(
"riscv,cbom-block-size", self.get_cache_line_size()
)
)
if core.core.isa[0].enable_Zicboz_fs.value:
node.append(
FdtPropertyWords(
"riscv,cboz-block-size", self.get_cache_line_size()
)
)
node.append(FdtPropertyStrings("status", "okay"))
node.append(
FdtPropertyStrings(