[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 12/22] ppc: First cut implementation of -cpu host
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 12/22] ppc: First cut implementation of -cpu host |
Date: |
Sun, 30 Oct 2011 21:23:03 +0100 |
From: David Gibson <address@hidden>
For convenience with kvm, x86 allows the user to specify -cpu host on the
qemu command line, which means make the guest cpu the same as the host
cpu. This patch implements the same option for ppc targets.
For now, this just read the host PVR (Processor Version Register) and
selects one of our existing CPU specs based on it. This means that the
option will not work if the host cpu is not supported by TCG, even if that
wouldn't matter for use under kvm.
In future, we can extend this in future to override parts of the cpu spec
based on information obtained from the host (via /proc/cpuinfo, the host
device tree, or explicit KVM calls). That will let us handle cases where
the real kvm-virtualized CPU doesn't behave exactly like the TCG-emulated
CPU. With appropriate annotation of the CPU specs we'll also then be able
to use host cpus under kvm even when there isn't a matching full TCG model.
Signed-off-by: David Gibson <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
---
target-ppc/cpu.h | 1 +
target-ppc/kvm.c | 19 +++++++++++++++++++
target-ppc/kvm_ppc.h | 6 ++++++
target-ppc/translate_init.c | 8 +++++++-
4 files changed, 33 insertions(+), 1 deletions(-)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 3f77e30..8e5c85c 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1107,6 +1107,7 @@ void ppc_store_msr (CPUPPCState *env, target_ulong value);
void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
+const ppc_def_t *ppc_find_by_pvr(uint32_t pvr);
const ppc_def_t *cpu_ppc_find_by_name (const char *name);
int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def);
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 96139ac..313c7b2 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -879,6 +879,25 @@ int kvmppc_remove_spapr_tce(void *table, int fd, uint32_t
window_size)
return 0;
}
+static inline uint32_t mfpvr(void)
+{
+ uint32_t pvr;
+
+ asm ("mfpvr %0"
+ : "=r"(pvr));
+ return pvr;
+}
+
+const ppc_def_t *kvmppc_host_cpu_def(void)
+{
+ uint32_t host_pvr = mfpvr();
+ const ppc_def_t *base_spec;
+
+ base_spec = ppc_find_by_pvr(host_pvr);
+
+ return base_spec;
+}
+
bool kvm_arch_stop_on_emulation_error(CPUState *env)
{
return true;
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index 955729a..b0d6fb6 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -26,6 +26,7 @@ int kvmppc_smt_threads(void);
off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd);
int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
+const ppc_def_t *kvmppc_host_cpu_def(void);
#else
@@ -85,6 +86,11 @@ static inline int kvmppc_remove_spapr_tce(void *table, int
pfd,
return -1;
}
+static inline const ppc_def_t *kvmppc_host_cpu_def(void)
+{
+ return NULL;
+}
+
#endif
#ifndef CONFIG_KVM
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 73b49cf..62f0a6b 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -24,6 +24,8 @@
#include "dis-asm.h"
#include "gdbstub.h"
+#include <kvm.h>
+#include "kvm_ppc.h"
//#define PPC_DUMP_CPU
//#define PPC_DEBUG_SPR
@@ -10041,7 +10043,7 @@ int cpu_ppc_register_internal (CPUPPCState *env, const
ppc_def_t *def)
return 0;
}
-static const ppc_def_t *ppc_find_by_pvr (uint32_t pvr)
+const ppc_def_t *ppc_find_by_pvr(uint32_t pvr)
{
int i;
@@ -10063,6 +10065,10 @@ const ppc_def_t *cpu_ppc_find_by_name (const char
*name)
const char *p;
int i, max, len;
+ if (kvm_enabled() && (strcasecmp(name, "host") == 0)) {
+ return kvmppc_host_cpu_def();
+ }
+
/* Check if the given name is a PVR */
len = strlen(name);
if (len == 10 && name[0] == '0' && name[1] == 'x') {
--
1.6.0.2
- [Qemu-ppc] [PATCH 11/22] ppc: Remove broken partial PVR matching, (continued)
- [Qemu-ppc] [PATCH 11/22] ppc: Remove broken partial PVR matching, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 15/22] PPC: Bump qemu-system-ppc to 64-bit physical address space, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 09/22] pseries: Add device tree properties for VMX/VSX and DFP under kvm, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 08/22] ppc: Generalize the kvmppc_get_clockfreq() function, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 14/22] pseries: Under kvm use guest cpu = host cpu by default, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 18/22] PPC: Fail configure when libfdt is not available, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 19/22] pseries: Correct vmx/dfp handling in both KVM and TCG cases, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 17/22] ppc: Avoid decrementer related kvm exits, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 16/22] PPC: Disable non-440 CPUs for ppcemb target, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 20/22] ppc: Fix up usermode only builds, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 12/22] ppc: First cut implementation of -cpu host,
Alexander Graf <=
- [Qemu-ppc] [PATCH 21/22] KVM: PPC: Override host vmx/vsx/dfp only when information known, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 22/22] pseries: Allow writes to KVM accelerated TCE table, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 07/22] Set an invalid-bits mask for each SPE instructions, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 10/22] pseries: Update SLOF firmware image, Alexander Graf, 2011/10/30
- [Qemu-ppc] [PATCH 23/22] ppc: Alter CPU state to mask out TCG unimplemented instructions as appropriate, Alexander Graf, 2011/10/31
- [Qemu-ppc] [PATCH 24/22] pseries: Add partial support for PCI, Alexander Graf, 2011/10/31
- Re: [Qemu-ppc] [Qemu-devel] [PULL 00/22] ppc patch queue 2011-10-30, Alexander Graf, 2011/10/31