summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-11-26lib: sbi: Allow relaxed MMIO writes in device ipi_clear() callbackAnup Patel2-3/+15
Currently, there are no barriers before or after the ipi_clear() device callback which forces ipi_clear() device callback to always use non-relaxed MMIO writes. Instead of above, we use wmb() in after the ipi_clear() device callback which pairs with the wmb() done before the ipi_send() device callback. This also allows device ipi_clear() callback to use relaxed MMIO writes. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reported-by: Bo Gan <ganboing@gmail.com>
2023-11-26lib: sbi: Allow relaxed MMIO writes in device ipi_send() callbackAnup Patel3-7/+14
Currently, we have a smp_wmb() between atomic_raw_set_bit() and ipi_send() device callback whereas the MMIO writes done by the device ipi_send() callback will also include a barrier. We can avoid unnecessary/redundant barriers described above by allowing relaxed MMIO writes in device ipi_send() callback. To achieve this, we simply use wmb() instead of smp_wmb() before calling device ipi_send(). Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reported-by: Bo Gan <ganboing@gmail.com>
2023-11-24lib: utils/irqchip: Avoid redundant writes to APLIC CLRIE registerAnup Patel1-1/+1
Each APLIC CLRIE register allows disabling 32 interrupt sources at a time by writing -1 so no need to write CLRIE register separately for each interrupt source. Fixes: 99792653de29 ("lib: utils/irqchip: Add APLIC initialization library") Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2023-11-22lib: sbi_pmu: avoid buffer overflowHeinrich Schuchardt1-2/+2
total_ctrs is bounded by SBI_PMU_FW_CTR_MAX + SBI_PMU_HW_CTR_MAX) == 48 which exceeds BITS_PER_LONG on 32 bit systems. Iterating over the bits of &cmask results in a buffer overflow when looking for a bit >= BITS_PER_LONG. Adjust the iterators in sbi_pmu_ctr_start() and sbi_pmu_ctr_stop() accordingly. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-22lib: sbi: Fix PMP granularity handling in sbi_hart_map_saddr()Anup Patel1-1/+2
The sbi_hart_map_saddr() must create PMP mapping of size greater than or equal to PMP granularity otherwise PMP mapping does not work when size parameter less than sbi_hart_pmp_granularity(scratch). Fixes: 6e44ef686a9b ("lib: sbi: Add functions to map/unmap shared memory") Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
2023-11-17lib: utils/serial: remove semihosting_putcXiang W1-6/+0
For some debuggers that do not implement SYSWRITEC and SYSREADC operations, we have to use SYSWRITE and SYSREAD. Instead of implementing semihosting_putc() using SYSWRITE, let us simply remove semihosting_putc() because console_putc/console_puts are now interchangeable. Signed-off-by: Chen Pei <cp0613@linux.alibaba.com> Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-17lib: sbi: Make console_puts/console_putc interchangeableXiang W1-18/+17
console_puts/console_putc should replace each other, but the previous sbi_putc can only use console_putc. This patch addresses this problem. Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-17lib: sbi: change sbi_hart_features.extensions as an arrayXiang W3-22/+15
In the future there may be a lot of ISA extensions, a 'long' may not be able to accommodate, changed to an array for the future. Addresses-Coverity-ID: 1568357 Out-of-bounds access Fixes: 6259b2ec2d09 ("lib: utils/fdt: Fix fdt_parse_isa_extensions() implementation") Signed-off-by: Xiang W <wxjstz@126.com> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-17lib: sbi: enable seed access in S-modeHeinrich Schuchardt1-0/+6
If ISA extension Zkr is available, set mseccfg.sseed=1 mseccfg.useed=0 This enables access to the seed CSR in S-mode but not in U-mode. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-17lib: sbi: Add Zkr in hart extensionsHeinrich Schuchardt3-0/+6
- Add Zkr as extension in sbi_hart_extensions enum - Return "zkr" string for Zkr extension from sbi_hart_extension_id2string Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-17include: sbi: macros for mseccfg.sseed and .useedHeinrich Schuchardt1-0/+4
Define macros to access the sseed and the useed bit in the machine security configuration register (mseccfg). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16platform: generic: Add Sophgo sg2042 platform supportInochi Amaoto4-0/+79
Add Sophgo sg2042 soc support Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: sbi: Add regions merging when sanitizing domain regionInochi Amaoto1-22/+38
As the domain will reject a new memory region which has a sub-regions already in the domain, even the new region is bigger and has the same flags. This problem can be solved by relaxing region restriction and rechecking when adding and sanitizing domains. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: sbi: separate the swap operation of domain regionInochi Amaoto1-4/+12
Swapping domain region is a common operation when sorting domain region, so separate it as a function to make code clean. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: utils/ipi: mswi: add separate T-Head C9xx CLINT mswi compatibleInochi Amaoto1-0/+1
Like the mtimer of T-HEAD C9xx clint, the mswi also needs new compatible string to avoid misuse. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Link: https://lore.kernel.org/linux-riscv/1f6b82a1864477a51db33d3f295889ff985b497b.1696433229.git.unicorn_wang@outlook.com/ Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: utils/timer: mtimer: add separate T-Head C9xx CLINT mtimer compatibleInochi Amaoto1-0/+6
T-HEAD allows soc vendor to map the mtimer and mswi of C9xx clint on different address, which may cause a misuse if use the same compatible string, add a new timer compatible string to avoid this. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Link: https://lore.kernel.org/linux-riscv/6e48cbe5e60f9ada2fd1fe58e803e127f1a678e5.1696433229.git.unicorn_wang@outlook.com/ Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: utils/timer: Allow ACLINT MTIMER driver to setup quirksInochi Amaoto1-15/+20
The quirks checking will cause ACLINT step into a CLINT code path, this is not expected when ACLINT needs custom quirks. Add a new quirk to identify custom ACLINT, and apply the general quirks after applying CLINT specific quirks. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16utils/reset: Remove fdt_reset_theadGuo Ren7-389/+7
In the past, we used fdt_reset_thead to help customers with prototype verification. However, with the emergence of the Big-little SoC system, it can no longer meet the demand. Therefore, we use zero_stage_boot instead of fdt_reset_thead. It cleans up the opensbi code and ends the disputation of reset_sample's dts. This patch removes the fdt_reset_thead component and updates the related doc. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16firmware: fw_base.S: Fix boot hart status synchronizationGuo Ren1-4/+4
It's wrong to put the fence after setting the boot status flag because all relocation operations must be finished before setting the status flag. So, this fence must be put before the setting status flag, and there is no use in putting a fence between _start_warm and setting status flag. Also, nop can't delay other harts too much, so use div instead, just like Linux cpu_relax. Current opensbi force enables “M” Standard Extension, and mul instructions have been used in the fw_base.S. After the above two fixes, the boot hart index param of the fw_dynamic_info could be guaranteed properly for all platforms. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: utils/serial: Optimize semihosting_putc implementationChen Pei1-5/+5
For some debuggers that do not implement SYSWRITEC and SYSREADC operations, we can use SYSWRITE and SYSREAD instead like the implementation of semihosting_getc(). Signed-off-by: Chen Pei <cp0613@linux.alibaba.com> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16platform: Uses hart count as the default size of tlb infoInochi Amaoto2-3/+2
For platform with high number of harts, it is better to auto detect a suitable number of entries in tlb fifo. Since allocating tlb entry for all online harts can reduce the wait time significantly, using the number of the online harts can make most platforms happy. This auto detection can avoid most duplicate code for setting tlb fifo size. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Acked-by: Guo Ren <guoren@kernel.org> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16platform: generic: thead: improve tlb flush errataInochi Amaoto1-1/+1
Flushing the tlb entries can solve the thead tlb problem, but flushing it by address will miss something and lead to a exception in some rare cases, and this is more common for sg2042. To solve this problem, flush the tlb entries by asid in the custom trap handler to ensure it is refreshed. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Guo Ren <guoren@kernel.org> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-16lib: sbi: Correctly limit flushes to a single ASID/VMIDSamuel Holland1-18/+3
Per the SBI specification, the effects of these functions are limited to a specific ASID and/or VMID. This applies even when flushing the entire address space. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-14platform: generic: thead: initialize PMU by default in thead generic platformInochi Amaoto2-2/+12
Since all the SoC with thead c9xx cores need this initialization at now, initialize the c9xx pmu in the thead generic platform by default. Signed-off-by: Inochi Amaoto <inochiama@outlook.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-11-14platform: generic: thead: separate implement of T-HEAD c9xx errataInochi Amaoto7-18/+49
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>
2023-11-14platform: generic: thead: separate implement of T-HEAD c9xx pmuInochi Amaoto6-49/+87
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>
2023-11-14platform: generic: thead: move to thead c9xx header to vendor specific postionInochi Amaoto2-3/+3
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>
2023-11-14lib: sbi: simplify sanitize_domain()Heinrich Schuchardt1-6/+3
Since commit 112daa2e647c ("lib: sbi: Maximize the use of HART index in sbi_domain") the platform parameter is unused. Fixes: 112daa2e647c ("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>
2023-10-19include: sbi: Change spec version to 2.0Anup Patel1-1/+1
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>
2023-10-09lib: sbi_misaligned_ldst: Fix handling of C.SWSP and C.SDSPAmanieu d'Antras1-4/+2
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>
2023-10-06lib: sbi: Add support for mconfigptrYangjie Zhang1-0/+1
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>
2023-10-06docs: platform: update platform_requirements.mdYangjie Zhang1-2/+2
"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>
2023-10-06gpio/starfive: redundant readl() callHeinrich Schuchardt1-1/+0
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: 908be1b85c8f ("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>
2023-10-06lib: sbi_pmu: check for index overflowsHeinrich Schuchardt1-0/+3
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>
2023-10-06lib: utils: Simplify SET_ISA_EXT_MAP()Heinrich Schuchardt1-6/+4
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: d72f5f17478d ("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>
2023-10-06lib: utils/fdt: simplify dt_parse_isa_extensionsHeinrich Schuchardt1-4/+0
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: 6259b2ec2d09 ("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>
2023-10-06lib: sbi: fix sbi_domain_get_assigned_hartmask()Heinrich Schuchardt1-1/+1
'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: 296e70d69da7 ("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>
2023-10-06lib: utils: timer/ipi: Update memregion flags for PLMT and PLICSWYu Chien Peter Lin2-3/+8
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>
2023-10-06lib: utils/serial: Ensure proper allocation of PMP entries for uart8250Yu Chien Peter Lin1-2/+1
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>
2023-10-06doc: Fix fw_payload.mdHoa Nguyen1-1/+1
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>
2023-10-06Makefile: Add --exclude-libs ALL to avoid .dynsymVivian Wang1-0/+1
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>
2023-10-06firmware: Remove handling of R_RISCV_{32,64}Vivian Wang3-36/+0
Since everything is statically linked, we won't actually have R_RISCV_{32,64} relocations. No need to handle these. Fixes: 0f20e8adcf42 ("firmware: Support position independent execution") Signed-off-by: Vivian Wang <dramforever@live.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-10-06firmware: Remove ALIGN in .rela.dyn in linker scriptVivian Wang1-1/+0
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: 0f20e8adcf42 ("firmware: Support position independent execution") Signed-off-by: Vivian Wang <dramforever@live.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-10-04platform: generic: thead: fix stale TLB entries for th1520/sg2042Inochi Amaoto5-0/+78
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>
2023-09-24lib: utils/regmap: Mark syscon region as shared read-writeAnup Patel1-0/+7
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>
2023-09-24lib: utils/serial: Add shared regions for serial driversMayuresh Chitale3-2/+20
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>
2023-09-24lib: sbi: Populate M-only Smepmp entries before setting mseccfg.MMLAnup Patel1-14/+59
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>
2023-09-24lib: sbi: Fix pmp_flags for Smepmp read-only shared regionAnup Patel1-1/+1
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>
2023-09-24lib: sbi: Don't clear mseccfg.MML bit in sbi_hart_smepmp_configure()Anup Patel1-4/+2
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>
2023-09-24lib: sbi: Factor-out Smepmp configuration as separate functionAnup Patel1-70/+110
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>