[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 07/49] xics/spapr: Prevent RTAS/hypercalls emulation to
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 07/49] xics/spapr: Prevent RTAS/hypercalls emulation to be used by in-kernel XICS |
Date: |
Tue, 2 Jul 2019 16:08:15 +1000 |
From: Greg Kurz <address@hidden>
The XICS-related RTAS calls and hypercalls in QEMU are not supposed to
be called when the KVM in-kernel XICS is in use.
Add some explicit checks to detect that, print an error message and report
an hardware error to the guest.
Signed-off-by: Greg Kurz <address@hidden>
Message-Id: <address@hidden>
[dwg: Correction to commit message]
Signed-off-by: David Gibson <address@hidden>
---
hw/intc/xics_spapr.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/hw/intc/xics_spapr.c b/hw/intc/xics_spapr.c
index 5a1835e8b1..d470ab5f7a 100644
--- a/hw/intc/xics_spapr.c
+++ b/hw/intc/xics_spapr.c
@@ -41,11 +41,31 @@
* Guest interfaces
*/
+static bool check_in_kernel_xics(const char *func)
+{
+ if (kvm_irqchip_in_kernel()) {
+ error_report("pseries: %s must never be called for in-kernel XICS",
+ func);
+ return true;
+ }
+
+ return false;
+}
+
+#define CHECK_IN_KERNEL_XICS_HCALL \
+ do { \
+ if (check_in_kernel_xics(__func__)) { \
+ return H_HARDWARE; \
+ } \
+ } while (0)
+
static target_ulong h_cppr(PowerPCCPU *cpu, SpaprMachineState *spapr,
target_ulong opcode, target_ulong *args)
{
target_ulong cppr = args[0];
+ CHECK_IN_KERNEL_XICS_HCALL;
+
icp_set_cppr(spapr_cpu_state(cpu)->icp, cppr);
return H_SUCCESS;
}
@@ -56,6 +76,8 @@ static target_ulong h_ipi(PowerPCCPU *cpu, SpaprMachineState
*spapr,
target_ulong mfrr = args[1];
ICPState *icp = xics_icp_get(XICS_FABRIC(spapr), args[0]);
+ CHECK_IN_KERNEL_XICS_HCALL;
+
if (!icp) {
return H_PARAMETER;
}
@@ -69,6 +91,8 @@ static target_ulong h_xirr(PowerPCCPU *cpu, SpaprMachineState
*spapr,
{
uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
+ CHECK_IN_KERNEL_XICS_HCALL;
+
args[0] = xirr;
return H_SUCCESS;
}
@@ -78,6 +102,8 @@ static target_ulong h_xirr_x(PowerPCCPU *cpu,
SpaprMachineState *spapr,
{
uint32_t xirr = icp_accept(spapr_cpu_state(cpu)->icp);
+ CHECK_IN_KERNEL_XICS_HCALL;
+
args[0] = xirr;
args[1] = cpu_get_host_ticks();
return H_SUCCESS;
@@ -88,6 +114,8 @@ static target_ulong h_eoi(PowerPCCPU *cpu, SpaprMachineState
*spapr,
{
target_ulong xirr = args[0];
+ CHECK_IN_KERNEL_XICS_HCALL;
+
icp_eoi(spapr_cpu_state(cpu)->icp, xirr);
return H_SUCCESS;
}
@@ -99,6 +127,8 @@ static target_ulong h_ipoll(PowerPCCPU *cpu,
SpaprMachineState *spapr,
uint32_t mfrr;
uint32_t xirr;
+ CHECK_IN_KERNEL_XICS_HCALL;
+
if (!icp) {
return H_PARAMETER;
}
@@ -111,6 +141,14 @@ static target_ulong h_ipoll(PowerPCCPU *cpu,
SpaprMachineState *spapr,
return H_SUCCESS;
}
+#define CHECK_IN_KERNEL_XICS_RTAS(rets) \
+ do { \
+ if (check_in_kernel_xics(__func__)) { \
+ rtas_st((rets), 0, RTAS_OUT_HW_ERROR); \
+ return; \
+ } \
+ } while (0)
+
static void rtas_set_xive(PowerPCCPU *cpu, SpaprMachineState *spapr,
uint32_t token,
uint32_t nargs, target_ulong args,
@@ -119,6 +157,8 @@ static void rtas_set_xive(PowerPCCPU *cpu,
SpaprMachineState *spapr,
ICSState *ics = spapr->ics;
uint32_t nr, srcno, server, priority;
+ CHECK_IN_KERNEL_XICS_RTAS(rets);
+
if ((nargs != 3) || (nret != 1)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
@@ -152,6 +192,8 @@ static void rtas_get_xive(PowerPCCPU *cpu,
SpaprMachineState *spapr,
ICSState *ics = spapr->ics;
uint32_t nr, srcno;
+ CHECK_IN_KERNEL_XICS_RTAS(rets);
+
if ((nargs != 1) || (nret != 3)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
@@ -182,6 +224,8 @@ static void rtas_int_off(PowerPCCPU *cpu, SpaprMachineState
*spapr,
ICSState *ics = spapr->ics;
uint32_t nr, srcno;
+ CHECK_IN_KERNEL_XICS_RTAS(rets);
+
if ((nargs != 1) || (nret != 1)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
@@ -213,6 +257,8 @@ static void rtas_int_on(PowerPCCPU *cpu, SpaprMachineState
*spapr,
ICSState *ics = spapr->ics;
uint32_t nr, srcno;
+ CHECK_IN_KERNEL_XICS_RTAS(rets);
+
if ((nargs != 1) || (nret != 1)) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
--
2.21.0
- [Qemu-ppc] [PULL 05/49] ppc/pnv: remove xscom_base field from PnvChip, (continued)
- [Qemu-ppc] [PULL 05/49] ppc/pnv: remove xscom_base field from PnvChip, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 04/49] ppc/pnv: fix XSCOM MMIO base address for P9 machines with multiple chips, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 06/49] spapr_pci: Fix potential NULL pointer dereference in spapr_dt_pci_bus(), David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 09/49] xics/spapr: Detect old KVM XICS on POWER9 hosts, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 02/49] docs: updates on the POWER9 XIVE interrupt controller documentation, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 16/49] spapr_pci: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 14/49] spapr_pci: Fix DRC owner in spapr_dt_pci_bus(), David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 28/49] target/ppc/machine: Add kvmppc_pvr_workaround_required() stub, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 08/49] xics/spapr: Register RTAS/hypercalls once at machine init, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 17/49] hw/ppc/mac_oldworld: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 07/49] xics/spapr: Prevent RTAS/hypercalls emulation to be used by in-kernel XICS,
David Gibson <=
- [Qemu-ppc] [PULL 18/49] hw/ppc/mac_newworld: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 15/49] xics/spapr: Only emulated XICS should use RTAS/hypercalls emulation, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 29/49] target/ppc: remove getVSR()/putVSR() from int_helper.c, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 12/49] target/ppc: remove getVSR()/putVSR() from fpu_helper.c, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 43/49] spapr/xive: rework the mapping the KVM memory regions, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 13/49] target/ppc: remove getVSR()/putVSR() from mem_helper.c, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 25/49] xics/kvm: Add error propagation to ic*_set_kvm_state() functions, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 22/49] xics/spapr: Rename xics_kvm_init(), David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 11/49] xics: Add comment about CPU hotplug, David Gibson, 2019/07/02
- [Qemu-ppc] [PULL 20/49] hw/ppc: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02