- Oct 06, 2023
-
-
Heinrich Schuchardt authored
'1' is a 32 bit integer. When shifting it by more than 31 bits it becomes zero and we get an incorrect return value. Addresses-Coverity-ID: 1568356 Bad bit shift operation Fixes: 296e70d6 ("lib: sbi: Extend sbi_hartmask to support both hartid and hartindex") Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
This patch adds unspecified permission flags for the PLICSW region and updates the permission of the PLMT region. With this update, both regions will become M-mode only read/write regions in the root domain. Domain0 Region00: 0x00000000f0300000-0x00000000f0300fff M: (I,R,W) S/U: (R,W) Domain0 Region01: 0x0000000000040000-0x000000000005ffff M: (R,W) S/U: () Domain0 Region02: 0x0000000000000000-0x000000000003ffff M: (R,X) S/U: () > Domain0 Region03: 0x00000000e6000000-0x00000000e60fffff M: (I,R,W) S/U: () > Domain0 Region04: 0x00000000e6400000-0x00000000e67fffff M: (I,R,W) S/U: () Domain0 Region05: 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X) The PMP rules of AE350-AX65 (single-core) w/ Smepmp: p/x $pmpcfg0 $1 = {0x1f9b9b9d9b1e00, pmp0cfg = {0x0}, L--AAXWR pmp1cfg = {0x1e} (00011110), pmpaddr1: 0xf0300000 ~ 0xf0300fff (UART1) pmp2cfg = {0x9b} (10011011), pmpaddr2: 0x40000 ~ 0x5ffff pmp3cfg = {0x9d} (10011101), pmpaddr3: 0x0 ~ 0x3ffff pmp4cfg = {0x9b} (10011011), pmpaddr4: 0xe6000000 ~ 0xe60fffff (PLMT) pmp5cfg = {0x9b} (10011011), pmpaddr5: 0xe6400000 ~ 0xe67fffff (PLICSW) pmp6cfg = {0x1f} (00011111), pmpaddr6: 0x0 ~ 0xffffffffff pmp7cfg = {0x0 }} The PMP rules of AE350-AX45MP (qual-core) w/o Smepmp: p/x $pmpcfg0 $1 = {0x1f181818181b, L--AAXWR pmp0cfg = {0x1b}, (00011011), pmpaddr0: 0xf0300000 ~ 0xf0300fff (UART1) pmp1cfg = {0x18}, (00011000), pmpaddr1: 0x40000 ~ 0x5ffff pmp2cfg = {0x18}, (00011000), pmpaddr2: 0x0 ~ 0x3ffff pmp3cfg = {0x18}, (00011000), pmpaddr3: 0xe6000000 ~ 0xe60fffff (PLMT) pmp4cfg = {0x18}, (00011000), pmpaddr4: 0xe6400000 ~ 0xe67fffff (PLICSW) pmp5cfg = {0x1f}, (00011111), pmpaddr5: 0x0 ~ 0x1ffffffff pmp6cfg = {0x0 }} Note that starting from this patch, we restrict the S/U-mode read permission to the PLMT region, since we should read the TIME CSR in a lower privilege mode. Signed-off-by:Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yu Chien Peter Lin authored
The added memory region should start from the base address. Otherwise, the range will be shifted by reg_offset and not able to merge consecutive NAPOT regions in the root domain, resulting in wasted PMP entries. Fixes: e8bc1621 ("lib: utils/serial: Add shared regions for serial drivers") Signed-off-by:
Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Hoa Nguyen authored
The base of .text is defined by `FW_TEXT_START`, not `FW_TEXT_BASE`. Signed-off-by:
Hoa Nguyen <hn@hnpl.org> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
Since everything is statically linked, we don't need to expose symbols for dynamic linking. For a default build this saves about 2 KiB of useless read only data in .dynsym, .dynstr, .hash, .gnu.hash sections. Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
Since everything is statically linked, we won't actually have R_RISCV_{32,64} relocations. No need to handle these. Fixes: 0f20e8ad ("firmware: Support position independent execution") Signed-off-by:Vivian Wang <dramforever@live.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Vivian Wang authored
The .rela.dyn section should be exactly the size of the relocations, without padding. On RV64, .rela* sections are already aligned and there's no need for padding. On RV32, this adds padding up to 4 bytes, which, if present, confuses the relocation loop into processing an extra entry past the end of .rela*, and it crashes with an invalid memory access. Fixes: 0f20e8ad ("firmware: Support position independent execution") Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Oct 04, 2023
-
-
Inochi Amaoto authored
The TLB entries remain functional all the time once added in T-HEAD th1520 and Sophgo sg2042 (even if the MMU is then disabled afterwards). If there are some stale TLB entries that contains the address of SBI, it will cause unexpected memory access and issue a illegal instruction error. To avoid this, a TLB flush is needed to drop these TLB entries before any memory access in the trap handler. To handle this workaroud, add a custom trap handler with executing TLB flush first in the T-HEAD platform to fix affected socs. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Sep 24, 2023
-
-
Anup Patel authored
The syscon region used by OpenSBI should be marked as a shared read-write region between M-mode and SU-mode. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com>
-
Mayuresh Chitale authored
The serial driver regions used by OpenSBI should be marked as a shared read-write regions between M-mode and SU-mode as those are accessed by earlycon and the corresponding tty serial drivers running in 'S' mode. When the smepmp extension is enabled, PMP entries for these shared regions will get programmed. Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com> Signed-off-by:
Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
Based on sections 4.c and 4.d in Ch.2 of the Smepmp spec the PMP entries must be programmed as below: 1. Program M-only entries 2. Enable mseccfg.MML 3. Program shared-region entries 4. Program SU-only entries Co-developed-by:
Mayuresh Chitale <mchitale@ventanamicro.com> Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com> Signed-off-by:
Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
The Smepmp read-only shared region must have pmpcfg.L, pmpcfg.R, pmpcfg.W, and pmpcfg.X bits set so sbi_hart_get_smepmp_flags() must return pmp_flags accordingly. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com>
-
Anup Patel authored
The mseccfg.MML bit is a sticky bit which remains unchanged once set so no need to clear it in sbi_hart_smepmp_configure(). Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com>
-
Anup Patel authored
Let us factor-out Smepmp configuaration as separate function so that code is more readable. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com>
-
Mayuresh Chitale authored
The macros to test permissions must perform an exact match of all the bits in the input with the desired permission bits. Otherwise, the check returns false positives in those cases where only some of the desired permissions are set in the input. Fixes: 6c202c5e ("include: sbi: Add Smepmp specific access flags for PMP entries") Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Anup Patel authored
The sbi_hartmask_for_each_hart() macro is slow and has only one user so let us completely remove the sbi_hartmask_for_each_hart() macro. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
Let us maximize the use of HART index in sbi_domain because hartindex based hartmask access and sbi_scratch lookup is faster. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
The sbi_scratch_last_hartid() macro is not of much use on platforms with really sparse hartids so let us replace use of this macro with other approaches. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
Let us prefer hartindex over hartid in IPI framework which in-turn forces IPI users to also prefer hartindex. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
The sbi_hartid_to_scratch() involves translating hartid to hartindex which is expensive so let's use sbi_hartindex_to_scratch() instead. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Xiang W authored
Currently, the sbi_hartmask is indexed by hartid which puts a limit on hartid to be less than SBI_HARTMASK_MAX_BITS. We extend the sbi_hartmask implementation to use hartindex and support updating sbi_hartmask using hartid. This removes the limit on hartid and existing code works largely unmodified. Signed-off-by:
Xiang W <wxjstz@126.com> Signed-off-by:
Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
The hartid to hartindex mapping is now tracked in sbi_scratch so we don't need sbi_platform_hart_index() and sbi_platform_hart_invalid() functions hence let us remove them. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Anup Patel authored
We introduce HART index and related helper functions in sbi_scratch where HART index is contiguous and each HART index maps to a physical HART id such that 0 <= HART index and HART index < SBI_HARTMASK_MAX_BITS. The HART index to HART id mapping follows the index2id mapping provided by the platform. If the platform does not provide index2id mapping then identity mapping is assumed. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
- Sep 22, 2023
-
-
Greentime Hu authored
We found the mstatus.FS status is not set correctly after the SET_F64_REG() and SET_F32_REG(). We should set mstatus.FS dirty after we emulate the FPU instructions. Co-developed-by:
Roy Lin <roy.lin@sifive.com> Signed-off-by:
Roy Lin <roy.lin@sifive.com> Signed-off-by:
Greentime Hu <greentime.hu@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Sep 10, 2023
-
-
Xiang W authored
If the system is defined from tlb_fifo_num_entries, the scratch may be too small to hold the fifo, so it is alloc through the heap. Signed-off-by:
Xiang W <wxjstz@126.com> Signed-off-by:
Xing Xiaoguang <xiaoguang.xing@sophgo.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Xiang W authored
For some platforms with a particularly high number of harts, if the tlb fifo is too small, it case harts to wait. Platforms should be allowed to specify the size of the tlb fifo. Signed-off-by:
Xiang W <wxjstz@126.com> Signed-off-by:
Xing Xiaoguang <xiaoguang.xing@sophgo.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
After the hardware hpm counter is stopped, it should not raise any new interrupt as it is already stopped. So add the hw_counter_disable_irq callback to allow the custom pmu device to control this behavior. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Guo Ren <guoren@kernel.org> Reviewed-by:
Anup Patel <anup@brainfault.org> Tested-by:
Samuel Holland <samuel@sholland.org>
-
Inochi Amaoto authored
T-HEAD c9xx pmu needs to clear OV bits of MCOUNTEROF in any condition to avoid unnecessary OF interrupts. In addition, the S-mode SCOUNTEROF only have OF bit set when the related bits of MCOUNTERWEN is set, so also configure MCOUNTERWEN to allow kernel to access valid SCOUNTEROF. Signed-off-by:
Haijiao Liu <haijiao.liu@sophgo.com> Co-authored-by:
Inochi Amaoto <inochiama@outlook.com> Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Tested-by:
Samuel Holland <samuel@sholland.org>
-
Inochi Amaoto authored
When detecting features of PMU, the hpm counter may be written to some value, this will cause some unexpected behavior in some cases. So ensure the hpm counter is updated before starting the counter and the related interrupt. Signed-off-by:
Haijiao Liu <haijiao.liu@sophgo.com> Co-authored-by:
Inochi Amaoto <inochiama@outlook.com> Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Tested-by:
Samuel Holland <samuel@sholland.org>
-
- Sep 06, 2023
-
-
Xiang W authored
The previous definition had the assumption that the machine word length is equal to the word length of LONG. Remove this assumption and add a static check to prevent errors in subsequent modifications. Signed-off-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
As the the "Console Putchar" extension is already legacy and may be removed in the furture. So replace it with the SBI v2.0 "DBCN" extension. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 22, 2023
-
-
Inochi Amaoto authored
After supporting noncontigous hpm event and counters in opensbi, the number of hpm counters can be calculated by the mhpm_mask. So this field is unnecessary and can be removed to save some space. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Only the CSR mhpmevent 3-9,13-17 of D1 have valid function, so change the mhpm_mask to a valid value to avoid invalid usage. Due to the openc906 pmu code https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/pmu/rtl/aq_hpcp_top.v Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
grep (at least my version, grep-3.8-3.fc38.x86_64) warns with "grep: warning: stray \ before -". Fix the warning by making the command line input to grep less ambiguous. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 18, 2023
-
-
Kaiwen Xue authored
This adds the support for ISA extension smcntrpmf. When some inhibit flags are set by a lower privilege mode for new CSRs added by smcntrpmf, OpenSBI sets the appropriate values correspondingly. Signed-off-by:
Kaiwen Xue <kaiwenx@andrew.cmu.edu> Signed-off-by:
Kaiwen Xue <kaiwenx@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Aug 06, 2023
-
-
Mitchell Horne authored
Attempting to build OpenSBI with clang 16 and the following command: $ make LLVM=1 PLATFORM=generic Results in the following error: AS platform/generic/firmware/fw_dynamic.o /tmp/fw_dynamic-d000a6.s:429:9: error: symbol '_fw_start' can not be undefined in a subtraction expression .dword _fw_rw_start - _fw_start Work around this issue by eliminating the __fw_rw_offset variable and performing the offset calculation at run-time instead. This takes advantage of the fact that the a4 register contains the value of _fw_start. Signed-off-by:Mitchell Horne <mhorne@FreeBSD.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Kaiwen Xue authored
Cycle and instructions are hardware events instead of firmware ones. Fix the typo in the name of this function. Signed-off-by:
Kaiwen Xue <kaiwenx@andrew.cmu.edu> Signed-off-by:
Kaiwen Xue <kaiwenx@rivosinc.com> Reviewed-by:
Anup patel <anup@brainfault.org>
-
Anup Patel authored
Currently, the fdt_parse_isa_extensions() tries to parse the ISA string once for each HART. This ISA string parsing can fail for secondary HARTs if the FDT memory is already overwritten by the supervisor OS. To tackle this issue, we improve the fdt_parse_isa_extensions() implementation to pre-parse ISA string for all HARTs during cold boot. Fixes: d72f5f17 ("lib: utils: Add detection of Smepmp from ISA string in FDT") Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-By:
Mayuresh <Chitale<mchitale@ventanamicro.com>
-
Mayuresh Chitale authored
Platforms may implement hpm events/counters non contiguously but the current implementation assumes them to be always contigous. Add a bitmap that captures the hpm events/counters as implemented in the hardware and use it to set the max limit of hardware counters visible to the OS. Counters not implemented in the hardware can't be used by the OS because those wont be described in the DT. Signed-off-by:
Mayuresh Chitale <mchitale@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Nowadays, most of the editor use files or directories begin with dot to store some settings. So let git ignore these files and directories to reduce potential mistakes. Add dot match to ignore any editor file and there are two exceptions: - .gitignore - .clang-format Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Bin Meng <bmeng.cn@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-