[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 36/40] pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, ST
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PULL 36/40] pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, STORE} implementations |
Date: |
Wed, 3 Jun 2015 23:45:37 +0200 |
From: David Gibson <address@hidden>
qemu currently implements the hypercalls H_LOGICAL_CI_LOAD and
H_LOGICAL_CI_STORE as PAPR extensions. These are used by the SLOF firmware
for IO, because performing cache inhibited MMIO accesses with the MMU off
(real mode) is very awkward on POWER.
This approach breaks when SLOF needs to access IO devices implemented
within KVM instead of in qemu. The simplest example would be virtio-blk
using an iothread, because the iothread / dataplane mechanism relies on
an in-kernel implementation of the virtio queue notification MMIO.
To fix this, an in-kernel implementation of these hypercalls has been made,
(kernel commit 99342cf "kvmppc: Implement H_LOGICAL_CI_{LOAD,STORE} in KVM"
however, the hypercalls still need to be enabled from qemu. This performs
the necessary calls to do so.
It would be nice to provide some warning if we encounter a problematic
device with a kernel which doesn't support the new calls. Unfortunately,
I can't see a way to detect this case which won't either warn in far too
many cases that will probably work, or which is horribly invasive.
Signed-off-by: David Gibson <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
hw/ppc/spapr.c | 5 +++++
target-ppc/kvm.c | 17 +++++++++++++++++
target-ppc/kvm_ppc.h | 5 +++++
3 files changed, 27 insertions(+)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 2e9ac87..f174e5a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1506,6 +1506,11 @@ static void ppc_spapr_init(MachineState *machine)
qemu_register_reset(spapr_cpu_reset, cpu);
}
+ if (kvm_enabled()) {
+ /* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */
+ kvmppc_enable_logical_ci_hcalls();
+ }
+
/* allocate RAM */
spapr->ram_limit = ram_size;
memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram",
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 1da9ea8..97a50b1 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1884,6 +1884,23 @@ int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf,
int buf_len)
return 0;
}
+static inline int kvmppc_enable_hcall(KVMState *s, target_ulong hcall)
+{
+ return kvm_vm_enable_cap(s, KVM_CAP_PPC_ENABLE_HCALL, 0, hcall, 1);
+}
+
+void kvmppc_enable_logical_ci_hcalls(void)
+{
+ /*
+ * FIXME: it would be nice if we could detect the cases where
+ * we're using a device which requires the in kernel
+ * implementation of these hcalls, but the kernel lacks them and
+ * produce a warning.
+ */
+ kvmppc_enable_hcall(kvm_state, H_LOGICAL_CI_LOAD);
+ kvmppc_enable_hcall(kvm_state, H_LOGICAL_CI_STORE);
+}
+
void kvmppc_set_papr(PowerPCCPU *cpu)
{
CPUState *cs = CPU(cpu);
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index 2e0224c..4d30e27 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -24,6 +24,7 @@ bool kvmppc_get_host_serial(char **buf);
int kvmppc_get_hasidle(CPUPPCState *env);
int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
+void kvmppc_enable_logical_ci_hcalls(void);
void kvmppc_set_papr(PowerPCCPU *cpu);
int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
@@ -107,6 +108,10 @@ static inline int kvmppc_set_interrupt(PowerPCCPU *cpu,
int irq, int level)
return -1;
}
+static inline void kvmppc_enable_logical_ci_hcalls(void)
+{
+}
+
static inline void kvmppc_set_papr(PowerPCCPU *cpu)
{
}
--
1.8.1.4
- [Qemu-ppc] [PULL 14/40] spapr_iommu: Give unique QOM name to TCE table, (continued)
- [Qemu-ppc] [PULL 14/40] spapr_iommu: Give unique QOM name to TCE table, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 07/40] spapr_pci: Introduce a liobn number generating macros, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 21/40] spapr_rtas: add get/set-power-level RTAS interfaces, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 35/40] spapr: override default ram size to 512MB, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 37/40] Add David Gibson for sPAPR in MAINTAINERS file, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 04/40] spapr_pci: Fix unsafe signed/unsigned comparisons, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 29/40] spapr_pci: add dynamic-reconfiguration option for spapr-pci-host-bridge, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 38/40] tci: do not use CPUArchState in tcg-target.h, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 22/40] spapr_rtas: add set-indicator RTAS interface, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 39/40] tcg: add TCG_TARGET_TLB_DISPLACEMENT_BITS, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 36/40] pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, STORE} implementations,
Alexander Graf <=
- [Qemu-ppc] [PULL 11/40] spapr_pci: Make find_phb()/find_dev() public, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 17/40] hw/ppc/spapr: Fix error message when firmware could not be loaded, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 34/40] machine: add default_ram_size to machine class, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 27/40] spapr_events: event-scan RTAS interface, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 28/40] spapr_drc: add spapr_drc_populate_dt(), Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 40/40] softmmu: support up to 12 MMU modes, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 19/40] docs: add sPAPR hotplug/dynamic-reconfiguration documentation, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 25/40] spapr_rtas: add ibm, configure-connector RTAS interface, Alexander Graf, 2015/06/03
- [Qemu-ppc] [PULL 32/40] spapr_pci: enable basic hotplug operations, Alexander Graf, 2015/06/03