- Aug 22, 2022
-
-
Vivian Wang authored
The machine mode GVA field is in mstatus for RV64 and mstatush for RV32, and is available if the hypervisor extension is available. If an exception occurs, we may need to redirect the trap to HS-mode, in which case, hstatus.GVA should be set to same as the machine mode GVA bit. Add MSTATUS_GVA for RV64, MSTATUSH_GVA for RV32, and their SHIFT encodings. The SHIFT index is helpful in assembly code, since field extraction can be implemented in only one register. In pseudocode: - For RV32: gva = (mstatus >> MSTATUS_GVA_SHIFT) & 1; - For RV64: gva = (mstatush >> MSTATUSH_GVA_SHIFT) & 1; Signed-off-by:
Vivian Wang <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Aug 08, 2022
-
-
Anup Patel authored
The "object.mk" name referred in top-level makefile should be "objects.mk". Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update all documentation files to: 1) Remove references to platform specific config.mk file since it is has been removed. 2) Add details about platform specific configs/defconfig and Kconfig files mandatory for each platform. 3) Add required packages in top-level README.md 4) Fix typo releated to object.mk in docs/platform/platform.md Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The options defined in config.mk can be specified in objects.mk of each platform so let us remove config.mk from all platforms. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
The generic platform version and default name should be set based on kconfig options so that users can override it. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update generic platform to use kconfig for enabling/disabling platform overrides. We also enable all platform overrides in generic platform defconfig. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update FDT support makefile to use kconfig for enabling/disabling. To avoid compilation errors, we also enable FDT for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update gpio drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate gpio drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update i2c drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate i2c drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update irqchip drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate irqchip drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update ipi drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate ipi drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update timer drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate timer drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update system drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate system drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update reset drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate reset drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We update serial drivers makefile to use kconfig for enabling/disabling drivers. To avoid compile errors, we also enable appropriate serial drivers for each platform. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
Currently, if same build directory is used to compile two different platforms then lib/utils objects are shared for these platforms. We will be having platform specific configs to enable/disable drivers in lib/utils and select compile time options for lib/utils sources. This means lib/utils sources will now be compiled in a platform specific way. To tackle above, we update top-level Makefile as follows: 1) Don't create libsbiutils.a anymore because this can't be shared between platforms. 2) Compile lib/utils sources separately for each platform. 3) Add comments showing which make rules are for lib/sbi, lib/utils, firmware, and platform sources. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We extend the top-level makefile to allow kconfig based configuration for each platform where each platform has it's own set of configs with "defconfig" being the default config. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
Anup Patel authored
We adopt Kconfiglib v14.1.0 sources under scripts directory so that top-level OpenSBI makefile can directly use Kconfiglib scripts without expecting users to install a particular version of Kconfiglib on their build system. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Tested-by:
Andrew Jones <ajones@ventanamicro.com> Acked-by:
Atish Patra <atishp@rivosinc.com> Tested-by:
Atish Patra <atishp@rivosinc.com>
-
- Jul 30, 2022
-
-
dramforever authored
Read long long arguments directly using va_arg. Remove original hack for RV32 that read a long long arg as two long args. This un-breaks the case on RV64 where e.g. the long long is followed by an odd number of ints: sbi_printf("%d %lld", (int) 1, (long long) 2LL); Also remove the acnt variable, which is now unused. Signed-off-by:dramforever <dramforever@live.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
RISC-V doesn't generate exceptions on divide-by-zero, but the result, all bits set, is not likely what people expect either. In all cases where we divide by baudrate there's a chance it's zero (when the DT it came from is "bad"). To avoid difficult to debug situations, leave baudrate dependent registers alone when baudrate is zero, as, also in all cases, it appears we can skip initialization of those registers and still [hopefully] have a functioning UART. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
While it doesn't look like there are any current cases of using uninitialized data, let's zero all the UART data members to be safe. Zero may not actually be better than a random number in some cases, so all structure members should still be validated before use, but at least zero is usually easier to debug than some random stack garbage... Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
Factor out the common code used by the fdt UART node parsers, allowing us to drop duplicate code. Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
fw_event_map represents array of firmware events. It should initialized for maximum number of firmware events not counters. Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
The active_events array is accessed with counter ID passed from the supervisor software before the counter ID bound check. This may cause a buffer overrun if a supervisor passes an invalid counter ID. Fix this by moving the access part after the bound check. Reported-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
Currently, there is no sanity check for firmware event code. We don't see any issue as Linux kernel driver does a bound check on firmware events already. However, OpenSBI can't assume sane supervisor mode software always. Thus, an invalid event idx can cause a buffer overflow error. For hardware events, the match will fail for invalid event code anyways. However, a search is unecessary if event code is invalid. Add a event ID validation function to solve the issue. Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Atish Patra authored
The current implementation computes the possible counter range by doing a left shift of counter base. However, this may overflow depending on the counter base value. In case of overflow, the highest counter id may be computed incorrectly. As per the SBI specification, the respective function should return an error if any of the counter is not valid. Fix the counter index check by avoiding left shifting while doing the sanity checks. Without the shift, the implementation just iterates over the counter mask and computes the correct counter index by adding the base to it. Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Andrew Jones authored
printc would happily write to 'out' even when 'out_len' was zero, potentially overflowing buffers. Rework printc to not do that and also ensure the null byte is written at the last position when necessary, as stated in the snprintf man page. Also, panic if sprintf or snprintf are called with NULL output strings (except the special case of snprintf having a NULL output string and a zero output size, allowing it to be used to get the number of characters that would have been written). Finally, rename a goto label which clashed with 'out'. Fixes: 9e8ff05c ("Initial commit.") Signed-off-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Jul 20, 2022
-
-
Prasanna T authored
The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now. Signed-off-by:
Prasanna T <ptprasanna@gmail.com> Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Xiang W <wxjstz@126.com>
-
gagachang authored
MPV bit is set when the value of next_virt boolean variable equals true. Since the value of next_virt is either 0 or 1, we can set MPV bit without if-else logic. Signed-off-by:
Che-Chia Chang <alvinga@andestech.com> Reviewed-by:
Andrew Jones <ajones@ventanamicro.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Jul 11, 2022
-
-
Ben Dooks authored
If the ecall SBI_EXT_HSM_HART_START is called it might try to wake the secondary hart using sbi_ipi_raw_send() to send an IPI to the hart. This can fail if there is no IPI device but no error is returned from sbi_ipi_raw_send() so the ecall returns as if the action completed and the caller continues without noticing (in the case of Linux it just hangs waiting for the secondary hart to become active) Fix this by changing sbi_ipi_raw_send() to return and error, and if an error is returned, then return it via SBI_EXT_HSM_HART_START call. Signed-off-by:
Ben Dooks <ben.dooks@sifive.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Jul 08, 2022
-
-
Adnan Rahman Chowdhury authored
Motivation: Suppose a peripheral needs to be configured to transmit data. There is an SFR bit which indicates that the peripheral is ready to transmit. The firmware should check the bit and will only transmit data when the peripheral is ready. When the firmware starts polling the SFR, the peripheral could be busy transmitting/receiving other data so the firmware must wait till that completes. Assuming that there is no other way, the firmware shouldn't wait indefinitely. The function sbi_timer_waitms_until() will constantly check whether a certain condition is satisfied, or timeout occurs. It can be used for the cases when a timeout is required. Signed-off-by:
Adnan Rahman Chowdhury <adnan.chowdhury@sifive.com> Reviewed-by:
Xiang W <wxjstz@126.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
- Jun 25, 2022
-
-
Anup Patel authored
This patch updates OpenSBI version to 1.1 as part of release preparation. Signed-off-by:Anup Patel <apatel@ventanamicro.com>
-
Sergey Matyukevich authored
OpenSBI explicitly assumes that there is no pmu hardware counter with index 1: hardware uses that bit for TM control. So OpenSBI filters out that index in sanity checks. However OpenSBI also excludes that counter when reports total amount of hardware counters to Linux. As a result, Linux uses incomplete counters mask excluding the highest available counter. Return accurate number of counters, update the firmware counter starting index, fix range checks that include num_hw_ctrs. The simple test is to make sure that there is no counter multiplexing in the following command: $ perf stat -e \ r8000000000000000,r8000000000000001,r8000000000000002,r8000000000000003, \ r8000000000000004,r8000000000000005,r8000000000000006,r8000000000000007, \ r8000000000000008,r8000000000000009,r800000000000000a,r800000000000000b, \ r800000000000000c,r800000000000000d,r800000000000000e,r800000000000000f \ ls Note that 16 firmware events with 16 counters won't require multiplexing. Signed-off-by:
Sergey Matyukevich <geomatsi@gmail.com> Signed-off-by:
Atish Patra <atishp@rivosinc.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Jun 24, 2022
-
-
Anup Patel authored
Now that SBI v1.0 specification is ratified, we change spec verion implemented by OpenSBI to v1.0. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
- Jun 22, 2022
-
-
Samuel Holland authored
The allwinner,sun20i-d1-clint compatible string is not documented in any official binding, so it should not be used by drivers. The MSWI in the D1 CLINT is compatible with the ACLINT specification, so it can take advantage of generic driver support. However, that is only possible if the MSWI and MTIMER are split into separate DT nodes. This means the final binding for this device is likely to be incompatible with what is implemented here. Remove this compatible string from the driver to prevent it from appearing in a stable version and causing future issues. Signed-off-by:
Samuel Holland <samuel@sholland.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Jan Remes authored
The second invocation of plic_context_init() incorrectly calls the function with m_cntx_id instead of s_cntx_id. This breaks systems which only have 1 external interrupt per hart. Fixes: 8c362e7d ("lib: irqchip/plic: Factor out a context init function") Signed-off-by:
Jan Remes <jan.remes@codasip.com> Reviewed-by:
Anup Patel <anup@brainfault.org> Reviewed-by:
Samuel Holland <samuel@sholland.org>
-
- Jun 21, 2022
-
-
Samuel Holland authored
The CLINT in the Allwinner D1 SoC apparently does not support 64-bit MMIO access. A property was added to support this quirk (and that property was copied to the ACLINT MTIMER code). However, since this difference in behavior makes the D1 CLINT incompatible with the SiFive CLINT's programming interface, a better solution is to use a separate compatible string. Signed-off-by:
Samuel Holland <samuel@sholland.org> Reviewed-by:
Anup Patel <anup@brainfault.org>
-
Anup Patel authored
Based on architecture review committee feedback, the [m|s|vs]seteienum, [m|s|vs]clreienum, [m|s|vs]seteipnum, and [m|s|vs]clreipnum CSRs are removed in the latest AIA draft v0.3.0 specification. (Refer, https://github.com/riscv/riscv-aia/releases/tag/0.3.0-draft.31 ) These CSRs were mostly for software convenience and software can always use [m|s|vs]iselect and [m|s|vs]ireg CSRs to update the IMSIC interrupt file bits. We update the IMSIC programming as-per above to match the latest AIA draft specification. Signed-off-by:
Anup Patel <apatel@ventanamicro.com> Reviewed-by:
Atish Patra <atishp@rivosinc.com>
-
dramforever authored
We should not change trap->tval to mepc because mtval already points to the faulting portion of the emulated instruction fetch, which is also what stval is expected to be. In addition, htinst is only allowed to be zero for instruction access faults or page faults, and is only allowed to be zero or a psuedoinstruction for instruction guest-page faults. Fix trap->tinst for these cases. Signed-off-by:
dramforever <dramforever@live.com> Reviewed-by:
Anup Patel <anup@brainfault.org>
-