|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v4 13/42] xen/riscv: introduce vintc_ctxt_switch_{from,to}()
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 <oleksii.kurochko@xxxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
---
Changes in v4:
- Add Reviewed-by: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>.
---
Changes in v3:
- s/v/{p,n} for vintc_ctxt_switch_{from,to}() arguments and also for
hook prototypes.
- Add Acked-by: Jan Beulich <jbeulich@xxxxxxxx>.
---
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 089d968ace27..a65de57e486f 100644
--- a/xen/arch/riscv/domain.c
+++ b/xen/arch/riscv/domain.c
@@ -412,6 +412,8 @@ static void ctxt_switch_from(struct vcpu *p)
vtimer_ctxt_switch_from(p);
+ vintc_ctxt_switch_from(p);
+
csrs_ctxt_switch_from(p);
}
@@ -427,6 +429,8 @@ static void ctxt_switch_to(struct vcpu *n)
csrs_ctxt_switch_to(n);
+ vintc_ctxt_switch_to(n);
+
vtimer_ctxt_switch_to(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 7a31c6a298a0..58196927aab2 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 *p);
+
+ /* Restore vINTC state of the vCPU being switched in */
+ void (*ctxt_switch_to)(struct vcpu *n);
};
struct vintc {
@@ -94,4 +100,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 *p);
+void vintc_ctxt_switch_to(struct vcpu *n);
+
#endif /* RISCV_INTC_H */
diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c
index cdbc039d0258..70dfe6cd6f34 100644
--- a/xen/arch/riscv/intc.c
+++ b/xen/arch/riscv/intc.c
@@ -190,3 +190,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 *p)
+{
+ const struct vintc_ops *ops = p->domain->arch.vintc->ops;
+
+ ops->ctxt_switch_from(p);
+}
+
+void vintc_ctxt_switch_to(struct vcpu *n)
+{
+ const struct vintc_ops *ops = n->domain->arch.vintc->ops;
+
+ ops->ctxt_switch_to(n);
+}
--
2.56.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |