[PATCH v2 14/39] xen/riscv: introduce vintc_ctxt_switch_{from,to}()
Oleksii Kurochko <[email protected]>
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <678236568970b18a1924a76588c4c50f9bf0c659.1787838835.git.oleksii.kurochko@gmail.com> |
Virtual interrupt controller state must be preserved across vCPU context
switches.
Introduce vintc_ctxt_switch_{from,to}() wrappers around new
ctxt_switch_{from,to}() hooks in struct vintc_ops, and call them from the
context switch path, so that this state can be saved/restored without
knowing which vINTC variant a domain uses.
No vINTC variant implements the hooks yet: the vAPLIC implementation is
added separately.
Signed-off-by: Oleksii Kurochko <[email protected]>
---
Changes in v2:
- Update the commit message.
- s/vintc_state_{save,restore}/vintc_ctxt_switch_{to,from}.
- s/{re}store_state/ctxt_switch_{to,from} for vintc_ops.
- s/vcpu/v for vintc_ctxt_switch_{to,from}() arguments.
---
---
xen/arch/riscv/domain.c | 4 ++++
xen/arch/riscv/include/asm/intc.h | 9 +++++++++
xen/arch/riscv/intc.c | 14 ++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c
index 4afdfb4d09ab..2dfe4c2e72ce 100644
--- a/xen/arch/riscv/domain.c
+++ b/xen/arch/riscv/domain.c
@@ -437,6 +437,8 @@ static void ctxt_switch_from(struct vcpu *p)
vtimer_ctxt_switch_from(p);
+ vintc_ctxt_switch_from(p);
+
save_csr_regs(p);
}
@@ -462,6 +464,8 @@ static void ctxt_switch_to(struct vcpu *n)
vtimer_ctxt_switch_to(n);
+ vintc_ctxt_switch_to(n);
+
restore_csr_regs(n);
p2m_ctxt_switch_to(n);
diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm/intc.h
index 1bfba7c6155b..62e1410156c7 100644
--- a/xen/arch/riscv/include/asm/intc.h
+++ b/xen/arch/riscv/include/asm/intc.h
@@ -64,6 +64,12 @@ struct vintc_ops {
/* Deinitialize some vINTC-related stuff for a vCPU */
void (*vcpu_deinit)(struct vcpu *v);
+
+ /* Save vINTC state of the vCPU being switched out */
+ void (*ctxt_switch_from)(struct vcpu *v);
+
+ /* Restore vINTC state of the vCPU being switched in */
+ void (*ctxt_switch_to)(struct vcpu *v);
};
struct vintc {
@@ -91,4 +97,7 @@ void domain_vintc_deinit(struct domain *d);
int vintc_reserve_virq(const struct domain *d, unsigned int virq);
+void vintc_ctxt_switch_from(struct vcpu *v);
+void vintc_ctxt_switch_to(struct vcpu *v);
+
#endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */
diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c
index bca83b4f4fa3..9fff501b9c25 100644
--- a/xen/arch/riscv/intc.c
+++ b/xen/arch/riscv/intc.c
@@ -178,3 +178,17 @@ int __overlay_init vintc_reserve_virq(const struct domain *d,
return test_and_set_bit(virq, d->arch.vintc->used_irqs) ? -EEXIST : 0;
}
+
+void vintc_ctxt_switch_from(struct vcpu *v)
+{
+ const struct vintc_ops *ops = v->domain->arch.vintc->ops;
+
+ ops->ctxt_switch_from(v);
+}
+
+void vintc_ctxt_switch_to(struct vcpu *v)
+{
+ const struct vintc_ops *ops = v->domain->arch.vintc->ops;
+
+ ops->ctxt_switch_to(v);
+}
--
2.55.0