qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, STORE} implementations
@ 2015-02-03  6:10 David Gibson
  2015-02-03  8:56 ` [Qemu-devel] [Qemu-ppc] " Nikunj A Dadhania
  2015-02-03 21:19 ` [Qemu-devel] " Paul Mackerras
  0 siblings, 2 replies; 15+ messages in thread
From: David Gibson @ 2015-02-03  6:10 UTC (permalink / raw)
  To: aik, agraf, mdroth; +Cc: qemu-ppc, paulus, qemu-devel, David Gibson

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,
however, the hypercalls still need to be enabled from qemu.  This performs
the necessary calls to do so.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c       |  5 +++++
 target-ppc/kvm.c     | 27 +++++++++++++++++++++++++++
 target-ppc/kvm_ppc.h |  5 +++++
 3 files changed, 37 insertions(+)

The kernel support this qemu patch enables has been posted but not
merged as of this post.  See https://lkml.org/lkml/2015/2/3/17

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index b560459..40fe1dd 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1459,6 +1459,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 1edf2b5..c9d04e8 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1882,6 +1882,33 @@ 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)
+{
+    int ret1, ret2;
+
+    ret1 = kvmppc_enable_hcall(kvm_state, H_LOGICAL_CI_LOAD);
+    if (ret1 != 0) {
+        fprintf(stderr, "Warning: error enabling H_LOGICAL_CI_LOAD in KVM:"
+                " %s\n", strerror(errno));
+    }
+
+    ret2 = kvmppc_enable_hcall(kvm_state, H_LOGICAL_CI_STORE);
+    if (ret2 != 0) {
+        fprintf(stderr, "Warning: error enabling H_LOGICAL_CI_STORE in KVM:"
+                " %s\n", strerror(errno));
+     }
+
+    if ((ret1 != 0) || (ret2 != 0)) {
+        fprintf(stderr, "Warning: Couldn't enable H_LOGICAL_CI_* in KVM, SLOF"
+                " may be unable to operate devices with in-kernel emulation\n");
+    }
+}
+
 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)
 {
 }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-02-09  1:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03  6:10 [Qemu-devel] [RFC] pseries: Enable in-kernel H_LOGICAL_CI_{LOAD, STORE} implementations David Gibson
2015-02-03  8:56 ` [Qemu-devel] [Qemu-ppc] " Nikunj A Dadhania
2015-02-03 21:19 ` [Qemu-devel] " Paul Mackerras
2015-02-04  1:32   ` David Gibson
2015-02-04 15:19     ` Alexander Graf
2015-02-05  0:48       ` David Gibson
2015-02-05  0:54         ` Alexander Graf
2015-02-05  2:55           ` David Gibson
2015-02-05 10:22             ` Alexander Graf
2015-02-05 11:30               ` David Gibson
2015-02-05 11:55                 ` Alexander Graf
2015-02-06  2:54                   ` David Gibson
2015-02-06  7:56                     ` Alexander Graf
2015-02-09  0:37                       ` David Gibson
2015-02-09  1:41                         ` Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).