You need to sign in or sign up before continuing.
- Nov 15, 2023
-
-
Inochi Amaoto authored
Separate the implement of T-HEAD c9xx errata to allow any platform with bug related to c9xx cores can use it. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
Separate the implement of T-HEAD c9xx pmu to allow any platform with c9xx cores can use it. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Inochi Amaoto authored
The CSR encoding for t-head c9xx cores is shared across all the platforms with these cores. So move header thead_c9xx.h to the thead subdir. Signed-off-by:
Inochi Amaoto <inochiama@outlook.com> Acked-by:
Guo Ren <guoren@kernel.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Nov 14, 2023
-
-
Heinrich Schuchardt authored
Since commit 112daa2e ("lib: sbi: Maximize the use of HART index in sbi_domain") the platform parameter is unused. Fixes: 112daa2e ("lib: sbi: Maximize the use of HART index in sbi_domain") Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Oct 19, 2023
-
-
Anup Patel authored
Now that SBI v2.0 specification is frozen, we change spec version implemented by OpenSBI to v2.0. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com>
-
- Oct 09, 2023
-
-
Amanieu d'Antras authored
Unlike C.LWSP/C.LDSP, these encodings can be used with the zero register, so checking that the rs2 field is non-zero is unnecessary. Additionally, the previous check was incorrect since it was checking the immediate field of the instruction instead of the rs2 field. Signed-off-by:
Amanieu d'Antras <amanieu@gmail.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Oct 06, 2023
-
-
Yangjie Zhang authored
RISC-V privileged specification v1.12 introduced the mconfigptr CSR which will hold the physical address of a configuration data structure. Signed-off-by:
Yangjie Zhang <jay1273062855@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Yangjie Zhang authored
"Zicsr" isa extension has been separated from "I" extension. This patch add the isa requirement of "Zicsr" extension in platform requirements documentation. Signed-off-by:
Yangjie Zhang <jay1273062855@outlook.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Heinrich Schuchardt authored
In starfive_gpio_direction_output() readl() is called twice to read the gpio direction register. The result of the first read is discarded. Remove the redundant read. Fixes: 908be1b8 ("gpio/starfive: add gpio driver and support gpio reset") Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Heinrich Schuchardt authored
sbi_pmu_ctr_cfg_match() receives data from a lower privilege level mode. We must catch maliciously wrong values. We already check against total_ctrs. But we do not check that total_ctrs is less than SBI_PMU_HW_CTR_MAX + SBI_PMU_FW_CTR_MAX. Check that the number of hardware counters is in the valid range. Addresses-Coverity-ID: 1566114 Out-of-bounds write Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
Heinrich Schuchardt authored
The define is hard to read. The continue statement does not do what was intended. * Remove do {} while (false); * Change the name to set_multi_letter_ext - Other local macros are lower case too. - Refer to the fact that this is only used for multi-letter extensions. Addresses-Coverity-ID: 1568359 Unexpected control flow Fixes: d72f5f17 ("lib: utils: Add detection of Smepmp from ISA string in FDT") Signed-off-by:Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Heinrich Schuchardt authored
hart_exts == NULL can only occur if offset and node address lead to an overflow resulting in exactly NULL. As we don't catch other values of overflow it does not make sense to treat this one as special. Addresses-Coverity-ID: 1568355 Logically dead code Addresses-Coverity-ID: 1568358 Logically dead code Fixes: 6259b2ec ("lib: utils/fdt: Fix fdt_parse_isa_extensions() implementation") Signed-off-by:
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
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>
-