Nothing special, but two important things: the ipi_cause and the hsm field.
There's only one single IPI, and we can't differentiate between different IPI causes. That makes things hard: if an IPI arrives at a HART, we don't know if it is a management IPI or if the IPI is for our guest. Hence, store the cause of the ipi for a CPU in the public per CPU fields. Simple protocol: - The sender must wait until ipi_cause is IPI_CAUSE_NONE. - The sender must set the cause before sending the IPI. - The receiver must clear the cause before after finishing the IPI handling HSM stands for "HART State Management". Refer to https://github.com/riscv-non-isa/riscv-sbi-doc/blob/master/riscv-sbi.adoc#hart-state-management-extension-eid-0x48534d-hsm We will understand and support HSM for CPU On/Offlining. For Onlining CPU, we need some data, which is stored in the hsm field. Besides that, the state of the current hart is stored in hart_state. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/riscv/include/asm/percpu.h | 37 ++++++++++++++++++---- hypervisor/arch/riscv/include/asm/plic.h | 18 +++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 hypervisor/arch/riscv/include/asm/plic.h diff --git a/hypervisor/arch/riscv/include/asm/percpu.h b/hypervisor/arch/riscv/include/asm/percpu.h index fce6c052..4eda15b6 100644 --- a/hypervisor/arch/riscv/include/asm/percpu.h +++ b/hypervisor/arch/riscv/include/asm/percpu.h @@ -2,22 +2,47 @@ * Jailhouse, a Linux-based partitioning hypervisor * * Copyright (c) Siemens AG, 2020 + * Copyright (c) OTH Regensburg, 2022 * * Authors: - * Jan Kiszka <[email protected]> + * Konrad Schwarz <[email protected]> + * Ralf Ramsauer <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. */ -// this shouldn't be here +#include <asm/plic.h> #include <asm/processor.h> +#include <asm/spinlock.h> -#define STACK_SIZE PAGE_SIZE +#define STACK_SIZE (PAGE_SIZE << 2) + +enum sbi_hart_state { + STARTED = 0, + STOPPED = 1, + START_PENDING = 2, + STOP_PENDING = 3, + SUSPENDED = 4, + SUSPEND_PENDING = 5, + RESUME_PENDING = 6, +}; #define ARCH_PUBLIC_PERCPU_FIELDS \ + unsigned long phys_id; \ + enum { \ + IPI_CAUSE_NONE, \ + IPI_CAUSE_GUEST, \ + IPI_CAUSE_MGMT, \ + } ipi_cause; \ spinlock_t control_lock; \ - ; + struct { \ + enum sbi_hart_state state; \ + unsigned long start_addr; \ + unsigned long opaque; \ + } hsm; \ + bool wait_for_power_on; \ + bool reset; \ + bool park; -#define ARCH_PERCPU_FIELDS \ - ; +#define ARCH_PERCPU_FIELDS diff --git a/hypervisor/arch/riscv/include/asm/plic.h b/hypervisor/arch/riscv/include/asm/plic.h new file mode 100644 index 00000000..04cdfa63 --- /dev/null +++ b/hypervisor/arch/riscv/include/asm/plic.h @@ -0,0 +1,18 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) OTH Regensburg, 2022 + * + * Authors: + * Ralf Ramsauer <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef _PLIC_H +#define _PLIC_H + +#define PLIC_MAX_IRQS 1024 + +#endif /* _PLIC_H */ -- 2.36.1 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20220627132905.4338-8-ralf.ramsauer%40oth-regensburg.de.
