summaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_hsm.c
AgeCommit message (Collapse)AuthorFilesLines
2023-03-10lib: sbi: Set the state of a hart to START_PENDING after the hart is readyEvgenii Shatokhin1-16/+67
When a boot hart executes sbi_hsm_hart_start() to start a secondary hart, next_arg1, next_addr and next_mode for the latter are stored in the scratch area after the state has been set to SBI_HSM_STATE_START_PENDING. The secondary hart waits in the loop with wfi() in sbi_hsm_hart_wait() at that time. However, "wfi" instruction is not guaranteed to wait for an interrupt to be received by the hart, it is just a hint for the CPU. According to RISC-V Privileged Architectures spec. v20211203, even an implementation of "wfi" as "nop" is legal. So, the secondary might leave the loop in sbi_hsm_hart_wait() as soon as its state has been set to SBI_HSM_STATE_START_PENDING, even if it got no IPI or it got an IPI unrelated to sbi_hsm_hart_start(). This could lead to the following race condition when booting Linux, for example: Boot hart (#0) Secondary hart (#1) runs Linux startup code waits in sbi_hsm_hart_wait() sbi_ecall(SBI_EXT_HSM, SBI_EXT_HSM_HART_START, ...) enters sbi_hsm_hart_start() sets state of hart #1 to START_PENDING leaves sbi_hsm_hart_wait() runs to the end of init_warmboot() returns to scratch->next_addr (next_addr can be garbage here) sets next_addr, etc. for hart #1 (no good: hart #1 has already left) sends IPI to hart #1 (no good either) If this happens, the secondary hart jumps to a wrong next_addr at the end of init_warmboot(), which leads to a system hang or crash. To reproduce the issue more reliably, one could add a delay in sbi_hsm_hart_start() after setting the hart's state but before sending IPI to that hart: hstate = atomic_cmpxchg(&hdata->state, SBI_HSM_STATE_STOPPED, SBI_HSM_STATE_START_PENDING); ... + sbi_timer_mdelay(10); init_count = sbi_init_count(hartid); rscratch->next_arg1 = arg1; rscratch->next_addr = saddr; The issue can be reproduced, for example, in a QEMU VM with '-machine virt' and 2 or more CPUs, with Linux as the guest OS. This patch moves writing of next_arg1, next_addr and next_mode for the secondary hart before setting its state to SBI_HSM_STATE_START_PENDING. In theory, it is possible that two or more harts enter sbi_hsm_hart_start() for the same target hart simultaneously. To make sure the current hart has exclusive access to the scratch area of the target hart at that point, a per-hart 'start_ticket' is used. It is initially 0. The current hart tries to acquire the ticket first (set it to 1) at the beginning of sbi_hsm_hart_start() and only proceeds if it has successfully acquired it. The target hart reads next_addr, etc., and then the releases the ticket (sets it to 0) before calling sbi_hart_switch_mode(). This way, even if some other hart manages to enter sbi_hsm_hart_start() after the ticket has been released but before the target hart jumps to next_addr, it will not cause problems. atomic_cmpxchg() already has "acquire" semantics, among other things, so no additional barriers are needed in hsm_start_ticket_acquire(). No hart can perform or observe the update of *rscratch before setting of 'start_ticket' to 1. atomic_write() only imposes ordering of writes, so an explicit barrier is needed in hsm_start_ticket_release() to ensure its "release" semantics. This guarantees that reads of scratch->next_addr, etc., in sbi_hsm_hart_start_finish() cannot happen after 'start_ticket' has been released. Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-03-10lib: sbi: Refactor the calls to sbi_hart_switch_mode()Evgenii Shatokhin1-2/+11
Move them into sbi_hsm_hart_start_finish() and sbi_hsm_hart_resume_finish() to make them easier to manage. This will be used by subsequent patches. Suggested-by: Anup Patel <anup@brainfault.org> Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Export some functionsAndrew Jones1-2/+10
A coming patch can make use of a few internal hsm functions if we export them. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Move misplaced commentAndrew Jones1-2/+4
While non-retentive suspend is not allowed for M-mode, the comment at the top of sbi_hsm_hart_suspend() implied suspend wasn't allowed for M-mode at all. Move the comment above the mode check which is inside a suspend type is non-retentive check. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Ensure errors are consistent with specAndrew Jones1-3/+3
HSM functions define when SBI_ERR_INVALID_PARAM should be returned. Ensure it's not used for reasons that don't meet the definitions by using the catch-all code, SBI_ERR_FAILED, for those reasons instead. Also, in one case sbi_hart_suspend() may have returned SBI_ERR_DENIED, which isn't defined for that function at all. Use SBI_ERR_FAILED for that case too. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Don't try to restore state on failed changeAndrew Jones1-5/+2
When a state change fails there's no need to restore the original state as it remains the same. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-27lib: sbi_hsm: Factor out invalid state detectionAndrew Jones1-41/+24
Remove some redundant code by creating an invalid state detection macro. No functional change intended. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-02-08lib: sbi_hsm: Use csr_set to restore the MIPNick Hu1-1/+1
If we use the csr_write to restore the MIP, we may clear the SEIP. In generic behavior of QEMU, if the pending bits of PLIC are set and we clear the SEIP, the QEMU may not set it back immediately. It may cause the interrupts won't be handled anymore until the new interrupts arrived and QEMU set the bits back. Signed-off-by: Nick Hu <nick.hu@sifive.com> Signed-off-by: Jim Shu <jim.shu@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-22lib: sbi_hsm: handle failure when hart_stop returns SBI_ENOTSUPPYu Chien Peter Lin1-4/+3
Make use of generic warm-boot path when platform hart_stop callback returns SBI_ENOTSUPP, in case certain hart can not turn off its power domain, or it detects some error occured in power management unit, it can fall through warm-boot flow and wait for interrupt in sbi_hsm_hart_wait(). Also improves comment in sbi_hsm_hart_wait(). Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2023-01-09lib: sbi_hsm: Rename 'priv' argument to 'arg1'Bin Meng1-4/+4
'priv' argument of sbi_hsm_hart_start() and sbi_hsm_hart_suspend() may mislead people to think it stands for 'privilege mode', but it is not. Change it to 'arg1' to clearly indicate the a1 register. Signed-off-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Samuel Holland <samuel@sholland.org> Tested-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Atish Patra <atishp@rivosinc.com> Reviewed-by: Anup Patel <anup@brainfault.org>
2022-07-11lib: sbi: add check for ipi device for hsm startBen Dooks1-1/+3
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>
2022-06-13lib: sbi_hsm: Assume a consistent resume addressSamuel Holland1-26/+20
The suspend code needs to know the resume address for two reasons: 1) Programming some hardware register or management firmware. Here we assume the hardware/firmware maintains its state between suspends, so it only needs to be programmed once at startup. 2) When a non-retentive suspend request ends up being retentive, due to lack of hardware support, pending interrupt, or for some other reason. However, the behavior here is not platform-dependent, and this can be handled in the generic hart suspend function. Since neither situation requires the platform-level suspend function to know the resume address, stop passing it to that function. Instead, handle the non-retentive to retentive situation generically. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-06-13lib: sbi_hsm: Call a device hook during hart resumeSamuel Holland1-0/+8
Non-retentive suspend states may require platform-specific actions during resume. For example, firmware may need to save and restore the values of custom CSRs. Add a hook to support this. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Samuel Holland <samuel@sholland.org>
2022-02-15lib: sbi: Enable mie.MEIE bit for IPIs based on external interrupts.Anup Patel1-2/+2
We can have IPIs based on external interrupts provided by devices such as AIA IMSIC so we should enable mie.MEIE bit at appropriate places in generic library. Signed-off-by: Anup Patel <anup@brainfault.org> Signed-off-by: Anup Patel <apatel@ventanamicro.com> Reviewed-by: Atish Patra <atishp@rivosinc.com>
2021-10-18lib: sbi: Save context for all non-retentive suspend typesAnup Patel1-6/+7
Instead of saving context only for default non-retentive suspend, we should save context for all non-retentive suspend types. Fixes: 74756891cc35 ("lib: sbi: Implement SBI HSM suspend function") Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Xiang W <wxjstz@126.com>
2021-06-02lib: sbi_scratch: remove owner from sbi_scratch_alloc_offsetHeinrich Schuchardt1-2/+1
The parameter owner of function sbi_scratch_alloc_offset() is never used. The scratch memory is small. We should not use it for debug information in future. Hence eliminate the parameter. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Xiang W <wxjstz@126.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2021-04-28lib: sbi: Simplify HSM platform operationsAnup Patel1-12/+56
Instead of having hsm_start(), hsm_stop() and hsm_suspend() callbacks in platform operations, it will be much simpler for HSM driver to directly register these operations as a device to the sbi_hsm implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2021-04-28lib: sbi: Simplify ipi platform operationsAnup Patel1-1/+1
Instead of having ipi_send() and ipi_clear() callbacks in platform operations, it will be much simpler for ipi driver to directly register these operations as a device to sbi_ipi implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2021-03-03lib: Remove redundant sbi_platform_ipi_clear() callsAnup Patel1-3/+4
The sbi_platform_ipi_clear() called from wait_for_coldboot() and sbi_hsm_hart_wait() is redundant because IPI will be automatically cleared by sbi_platform_ipi_init() called from sbi_ipi_init(). Further, wait_for_coldboot() is common for warm startup and warm resume path so the sbi_platform_ipi_clear() called in warm resume path cause resuming HART to miss an IPI injected other HART to wakeup the HART. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03lib: sbi: Implement SBI HSM suspend functionAnup Patel1-3/+190
This patch implements the SBI HSM suspend function. Using this new SBI call, the S-mode software can put calling HART in platform specific suspend (i.e. low-power) state. For a successful retentive suspend, the SBI call will return without errors upon resuming whereas for a successful non-retentive suspend, the SBI call will resume from a user provided resume address. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03lib: sbi: Fix error codes returned by HSM start() and stop() functionsAnup Patel1-2/+2
The sbi_hsm_hart_start() and sbi_hsm_hart_stop() functions should only return error codes as defined by the SBI specification. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03lib: sbi: Remove redundant sbi_hsm_hart_started() functionAnup Patel1-11/+3
The sbi_hsm_hart_started() function is only used by sbi_hsm_hart_stop() for checking state of calling HART and current domain assignment. The atomic_cmpxchg() called by sbi_hsm_hart_stop() will check state of calling hart anyway and domain assignment can be checked by other domain function such as sbi_domain_is_assigned_hart(). This means sbi_hsm_hart_started() is redundant and can be removed. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03lib: sbi: Rename sbi_hsm_hart_started_mask() functionAnup Patel1-2/+2
A hart can take interrupt in the new HSM states introduced by the SBI HSM suspend function (such as SUSPENDED state) so we rename sbi_hsm_hart_started_mask() to something more generic such as sbi_hsm_hart_interruptible_mask(). Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03lib: sbi: Use SBI_HSM_STATE_xyz defines instead of SBI_STATE_xyz definesAnup Patel1-43/+21
We replace the use of SBI_STATE_xyz defines with SBI_HSM_STATE_xyz defines because the HSM state defines are complete enough to implement HSM state machine in OpenSBI. As a result of this, we can now remove sbi_hsm_hart_state_to_status() function because it is now redundant and sbi_hsm_hart_get_state() can directly return HSM state or error. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2021-03-03include: sbi: Simplify HSM state define namesAnup Patel1-4/+4
We simplify HSM state define names so that these defines can directly replace SBI_HART_xyz defines used by SBI HSM implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Optimize sbi_hsm_hart_started_mask() implementationAnup Patel1-12/+22
Instead of calling sbi_hsm_hart_get_state() in a loop, we can simply call a new inline __sbi_hsm_hart_get_state() which only takes "hartid" and enforce domain checks using sbi_domain_assigned_hartmask(). This patch optimizes sbi_hsm_hart_started_mask() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Extend sbi_hsm_hart_start() for domainsAnup Patel1-9/+10
The sbi_hsm_hart_start() should consider the domain under which we are trying to start the HART. This will help ensure that HART A can start HART B only if both HARTs A and B belong to the same domain. We also have a special case when we bring-up boot HART of non-root domains in sbi_domain_finalize() where we should skip domain checks in sbi_hsm_hart_start(). To achieve this, sbi_hsm_hart_start() should do domain checks only when domain parameter is non-NULL. This patch extends sbi_hsm_hart_start() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-10-20lib: sbi: Extend sbi_hsm_hart_started_mask() for domainsAnup Patel1-7/+10
The sbi_hsm_hart_started_mask() API should take one more parameter to allow caller specify domain under which started_mask is being generated. Further, the sbi_hsm_hart_started_mask() depends on sbi_hsm_hart_get_state() which also should return HART state under specified domain. This patch updates both sbi_hsm_hart_started_mask() and sbi_hsm_hart_get_state() as-per above. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-16lib: sbi: Allow specifying mode in sbi_hart_pmp_check_addr() APIAnup Patel1-1/+1
We extend sbi_hart_pmp_check_addr() API so that users can specify privilege mode of the address for checking PMP access permissions. To achieve this, we end-up converting "unsigned long *size" parameter to "unsigned long *log2len" for pmp_get() implementation so that we can deal with regions of "1UL << __riscv_xlen" size in a special case in sbi_hart_pmp_check_addr() implementation. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-09-16lib: sbi: Allow specifying start mode to sbi_hsm_hart_start() APIAnup Patel1-1/+5
The sbi_scratch already has provision to specify the next stage mode so we can leverage this to specify start mode to sbi_hsm_hart_start(). In future, this will be useful in providing SBI calls to U-mode on embedded cores where we M-mode and U-mode but no S-mode. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-06-20lib: Don't return any invalid error from SBI ecallAnup Patel1-2/+2
We should only return valid error codes from SBI ecalls as defined by the RISC-V SBI spec. To achieve this: 1. We use SBI_Exxxx defines for OpenSBI internal errors with error values starting from -1000 2. We use SBI_ERR_xxxx defines for errors defined by SBI spec 3. We map some of the SBI_Exxxx defines to SBI_ERR_xxxx defines which are semantically same 4. We throw a error print and force return error code to SBI_ERR_FAILED in sbi_ecall_handler() if we see an invalid error code being returned to S-mode Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-28lib: sbi_scratch: Introduce sbi_scratch_last_hartid() APIAnup Patel1-2/+2
The patch adds sbi_scratch_last_hartid() API which returns last HART id having a scratch space. We can use this new API to optimize places where we iterate over HART id from 0 to SBI_HARTMASK_MAX_BITS. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-28include: Use more consistent name for atomic xchg() and cmpxchg()Anup Patel1-8/+8
We should remove the "arch_" prefix from atomic xchg() and cmpxchg() function names to have consistent naming of all atomic functions. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-28include: sbi_platform: Remove priv parameter from hart_start() callbackAnup Patel1-1/+1
The priv parameter in hart_start() platform callback is redundant hence we remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-19lib: sbi_hsm: Don't use sbi_platform_hart_disabled() APIAnup Patel1-5/+1
Checking return value of sbi_hartid_to_scratch() is sufficient so no need to explicitly check for disabled HART using the sbi_platform_hart_disabled() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-19lib: sbi_hsm: Remove scratch parameter from hart_started_mask() APIAnup Patel1-3/+1
The scratch parameter in sbi_hsm_hart_started_mask() API is now redundant hence removing it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-19lib: sbi_hsm: Don't use sbi_platform_hart_count() APIAnup Patel1-15/+4
We remove usage of sbi_platform_hart_count() API from sbi_hsm so that discontinuous and sparse HART ids can be supported. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-19lib: Handle failure of sbi_hartid_to_scratch() APIAnup Patel1-4/+13
The sbi_hartid_to_scratch() API can fail for non-existent HARTs so all uses of sbi_hartid_to_scratch() API should check return value. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-19lib: sbi_hsm: Simplify hart_get_state() and hart_started() APIsAnup Patel1-5/+6
We remove redundant scratch parameter from sbi_hsm_hart_get_state() and sbi_hsm_hart_started() APIs. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-19include: Simplify HART id to scratch macroAnup Patel1-3/+3
This patch simplify HART id to scratch macro as follows: 1. Remove current "scratch" pointer argument because now we use HART id to scratch table 2. Rename sbi_hart_id_to_scratch() to sbi_hartid_to_scratch() to have macro name consistent with the name of callback in struct sbi_scratch Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-13include: Make sbi_current_hartid() as macro in riscv_asm.hAnup Patel1-2/+2
The sbi_current_hartid() being a regular function is quite expensive because for callers it is a function call instead of a direct CSR read. This patch converts sbi_current_hartid() into a macro in riscv_asm.h. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-13lib: sbi_hsm: Optimize sbi_hsm_hart_get_state() implementationAnup Patel1-6/+2
Now that sbi_hart_id_to_scratch() is optimized, we don't need the "if ()" statement. Also, the hstate local variable is redundant so we remove that as well. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-11lib: Introduce sbi_hsm_hart_started_mask() APIAnup Patel1-0/+38
This patch introduce sbi_hsm_hart_started_mask() API as a replacement of sbi_hart_available_mask() API. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-03-10lib: sbi: Fix coding style issuesBin Meng1-7/+7
This fixes various coding style issues found in the SBI codes. No functional changes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-03-08include: Move bits related defines and macros to sbi_bitops.hAnup Patel1-1/+1
The right location for all bits related defines and macros is sbi_bitops.h hence this patch. With this patch, the sbi_bits.h is redundant so we remove it. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
2020-03-08lib: Fix return type of sbi_hsm_hart_started()Anup Patel1-2/+1
The return type of sbi_hsm_hart_started() should be bool. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-02-24lib: Add possible hart status valuesAtish Patra1-0/+25
SBI HSM extension defines possible hart status values in the specification. Define all possible status values. Add a helper function to convert hart state to status because hart states are internal to OpenSBI only and may not match the status values defined in the specification. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2020-02-24lib: Implement hart hotplugAtish Patra1-0/+222
This patch adds support for hart hotplug in OpenSBI using a generic WFI based approach. Hart hotplug can be achieved via SBI HSM extension which allows supervisor mode software to start or stop any harts anytime. Any platform wishes to implement platform specific hart hotplug must implement both hart_start and hart_stop in addition to enable platform feature SBI_PLATFORM_HAS_HART_HOTPLUG. Signed-off-by: Atish Patra <atish.patra@wdc.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>