From 68287604ee3364747c6ef54bef38a8fc08245896 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Mon, 30 Oct 2023 02:41:26 +0000 Subject: [PATCH] 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 --- src/arch/riscv/RiscvISA.py | 9 +++++++-- src/python/gem5/components/boards/riscv_board.py | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/arch/riscv/RiscvISA.py b/src/arch/riscv/RiscvISA.py index ca533bef0e..bce7f2497f 100644 --- a/src/arch/riscv/RiscvISA.py +++ b/src/arch/riscv/RiscvISA.py @@ -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) diff --git a/src/python/gem5/components/boards/riscv_board.py b/src/python/gem5/components/boards/riscv_board.py index 9b0d6454e1..5e5af815a4 100644 --- a/src/python/gem5/components/boards/riscv_board.py +++ b/src/python/gem5/components/boards/riscv_board.py @@ -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(