pseries: Support and improvements for KVM Book3S-HV support (v2)
cover pseries: Support and improvements for KVM Book3S-HV support (v2)
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implement CAP_SYNC_MMU and allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:
* Hack the host kernel to lie and advertise CAP_SYNC_MMU even though it doesn't really implement it.
or
* Hack qemu so it does not check for CAP_SYNC_MMU when the -mem-path option is used.
Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper CAP_SYNC_MMU support is ready.
Changes in v2:
* Bug fixes and style fixes based on feedback.
* Added new, fixed, SLOF update
PATCH 1/4 pseries: Support SMT systems for KVM Book3S-HV
Alex Graf has already made qemu support KVM for the pseries machine when using the Book3S-PR KVM variant (which runs the guest in usermode, emulating supervisor operations). This code allows gets us very close to also working with KVM Book3S-HV (using the hypervisor capabilities of recent POWER CPUs).
This patch moves us another step towards Book3S-HV support by correctly handling SMT (multithreaded) POWER CPUs. There are two parts to this:
* Querying KVM to check SMT capability, and if present, adjusting the cpu numbers that qemu assigns to cause KVM to assign guest threads to cores in the right way (this isn't automatic, because the POWER HV support has a limitation that different threads on a single core cannot be in different guests at the same time).
* Correctly informing the guest OS of the SMT thread to core mappings via the device tree.
--- hw/spapr.c | 24 +++++++++++++++++++++--- target-ppc/helper.c | 11 +++++++++++ target-ppc/kvm.c | 8 ++++++++ target-ppc/kvm_ppc.h | 6 ++++++ 4 files changed, 46 insertions(+), 3 deletions(-)
hw/spapr.c +21 -3
@@ -29,6 +29,9 @@#include "elf.h" #include "net.h" #include "blockdev.h" +#include "cpus.h" +#include "kvm.h" +#include "kvm_ppc.h" #include "hw/boards.h" #include "hw/ppc.h"
@@ -103,6 +106,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,uint32_t interrupt_server_ranges_prop[] = {0 ,cpu_to_be32 (smp_cpus)};int i;char *modelname; +int smt =kvmppc_smt_threads ();#define _FDT (exp) \ do { \
@@ -162,13 +166,18 @@ static void *spapr_create_fdt_skel(const char *cpu_model,for (env = first_cpu; env !=NULL ; env = env->next_cpu) {int index = env->cpu_index; -uint32_t gserver_prop[] = {cpu_to_be32 (index),0 };/* HACK! */ +uint32_t servers_prop[smp_threads]; +uint32_t gservers_prop[smp_threads *2 ];char *nodename;uint32_t segs[] = {cpu_to_be32 (28 ),cpu_to_be32 (40 ),0xffffffff ,0xffffffff };uint32_t tbfreq =kvm_enabled () ?kvmppc_get_tbfreq () :TIMEBASE_FREQ ;uint32_t cpufreq =kvm_enabled () ?kvmppc_get_clockfreq () :1000000000 ; +if ((index % smt) !=0 ) { +continue ; + } +if (asprintf (&nodename,"%s@%x" , modelname, index) <0 ) {fprintf (stderr,"Allocation failure\n" );exit (1 );
@@ -193,9 +202,18 @@ static void *spapr_create_fdt_skel(const char *cpu_model, pft_size_prop, sizeof(pft_size_prop))));_FDT ((fdt_property_string (fdt,"status" ,"okay" )));_FDT ((fdt_property (fdt,"64-bit" ,NULL ,0 ))); -_FDT ((fdt_property_cell (fdt,"ibm,ppc-interrupt-server#s" , index))); + +/* Build interrupt servers and gservers properties */ +for (i =0 ; i < smp_threads; i++) { + servers_prop[i] =cpu_to_be32 (index + i); +/* Hack, direct the group queues back to cpu 0 */ + gservers_prop[i*2 ] =cpu_to_be32 (index + i); + gservers_prop[i*2 +1 ] =0 ; + } +_FDT ((fdt_property (fdt,"ibm,ppc-interrupt-server#s" , + servers_prop,sizeof (servers_prop))));_FDT ((fdt_property (fdt,"ibm,ppc-interrupt-gserver#s" , - gserver_prop,sizeof (gserver_prop)))); + gservers_prop,sizeof (gservers_prop))));if (env->mmu_model &POWERPC_MMU_1TSEG ) { _FDT((fdt_property(fdt, "ibm,processor-segment-sizes",
target-ppc/helper.c +11 -0
@@ -26,6 +26,8 @@#include "helper_regs.h" #include "qemu-common.h" #include "kvm.h" +#include "kvm_ppc.h" +#include "cpus.h" //#define DEBUG_MMU //#define DEBUG_BATS
@@ -3189,6 +3191,15 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)if (tcg_enabled ()) {ppc_translate_init (); } +/* Adjust cpu index for SMT */ +#if !defined(CONFIG_USER_ONLY ) +if (kvm_enabled ()) { +int smt =kvmppc_smt_threads (); + + env->cpu_index = (env->cpu_index / smp_threads)*smt + + (env->cpu_index % smp_threads); + } +#endif /* !CONFIG_USER_ONLY */ env->cpu_model_str = cpu_model;cpu_ppc_register_internal (env, def);
target-ppc/kvm.c +8 -0
@@ -28,6 +28,7 @@#include "kvm_ppc.h" #include "cpu.h" #include "device_tree.h" +#include "hw/spapr.h" #include "hw/sysbus.h" #include "hw/spapr.h"
@@ -53,6 +54,7 @@ static int cap_interrupt_unset = false;static int cap_interrupt_level = false;static int cap_segstate;static int cap_booke_sregs; +static int cap_ppc_smt;/* XXX We have a race condition where we actually have a level triggered * interrupt, but the infrastructure can't expose that yet, so the guest
@@ -76,6 +78,7 @@ int kvm_arch_init(KVMState *s) cap_interrupt_level =kvm_check_extension (s,KVM_CAP_PPC_IRQ_LEVEL ); cap_segstate =kvm_check_extension (s,KVM_CAP_PPC_SEGSTATE ); cap_booke_sregs =kvm_check_extension (s,KVM_CAP_PPC_BOOKE_SREGS ); + cap_ppc_smt =kvm_check_extension (s,KVM_CAP_PPC_SMT );if (!cap_interrupt_level) { fprintf(stderr, "KVM: Couldn't find level irq capability. Expect the "
@@ -750,6 +753,11 @@ fail:cpu_abort (env,"This KVM version does not support PAPR\n" ); } +int kvmppc_smt_threads (void ) +{ +return cap_ppc_smt ? cap_ppc_smt :1 ; +} +bool kvm_arch_stop_on_emulation_error (CPUState *env) {return true;
target-ppc/kvm_ppc.h +6 -0
@@ -18,6 +18,7 @@ uint64_t kvmppc_get_clockfreq(void);int kvmppc_get_hypercall (CPUState *env,uint8_t *buf,int buf_len);int kvmppc_set_interrupt (CPUState *env,int irq,int level);void kvmppc_set_papr (CPUState *env); +int kvmppc_smt_threads (void );#else
@@ -45,6 +46,11 @@ static inline void kvmppc_set_papr(CPUState *env) { } +static inline int kvmppc_smt_threads (void ) +{ +return 1 ; +} +#endif #ifndef CONFIG_KVM
Signature · 1 line
1.7.6.3
PATCH 2/4 pseries: Allow KVM Book3S-HV on PPC970 CPUS
In reply to David GibsonAt present, using the hypervisor aware Book3S-HV KVM will only work with qemu on POWER7 CPUs. PPC970 CPUs also have hypervisor capability, but they lack the VRMA feature which makes assigning guest memory easier.
In order to allow KVM Book3S-HV on PPC970, we need to specially allocate the first chunk of guest memory (the "Real Mode Area" or RMA), so that it is physically contiguous.
Sufficiently recent host kernels allow such contiguous RMAs to be allocated, with a kvm capability advertising whether the feature is available and/or necessary on this hardware. This patch enables qemu to use this support, thus allowing kvm acceleration of pseries qemu machines on PPC970 hardware.
--- hw/spapr.c | 56 +++++++++++++++++++++++++++++++++++++++---------- target-ppc/kvm.c | 43 ++++++++++++++++++++++++++++++++++++++ target-ppc/kvm_ppc.h | 6 +++++ 3 files changed, 93 insertions(+), 12 deletions(-)
hw/spapr.c +44 -12
@@ -89,6 +89,7 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num) } static void *spapr_create_fdt_skel(const char *cpu_model, + target_phys_addr_t rma_size, target_phys_addr_t initrd_base, target_phys_addr_t initrd_size, const char *boot_device,
@@ -97,7 +98,9 @@ static void *spapr_create_fdt_skel(const char *cpu_model, {void *fdt;CPUState *env; -uint64_t mem_reg_property[] = {0 ,cpu_to_be64 (ram_size) }; +uint64_t mem_reg_property_rma[] = {0 ,cpu_to_be64 (rma_size) }; +uint64_t mem_reg_property_nonrma[] = {cpu_to_be64 (rma_size), +cpu_to_be64 (ram_size - rma_size) };uint32_t start_prop =cpu_to_be32 (initrd_base);uint32_t end_prop =cpu_to_be32 (initrd_base + initrd_size);uint32_t pft_size_prop[] = {0 ,cpu_to_be32 (hash_shift)};
@@ -143,15 +146,25 @@ static void *spapr_create_fdt_skel(const char *cpu_model,_FDT ((fdt_end_node (fdt))); -/* memory node */ +/* memory node(s) */ _FDT ((fdt_begin_node (fdt,"memory@0" )));_FDT ((fdt_property_string (fdt,"device_type" ,"memory" ))); -_FDT ((fdt_property (fdt,"reg" , - mem_reg_property,sizeof (mem_reg_property)))); - +_FDT ((fdt_property (fdt,"reg" , mem_reg_property_rma, +sizeof (mem_reg_property_rma))));_FDT ((fdt_end_node (fdt))); +if (ram_size > rma_size) { +char mem_name[32 ]; + +sprintf (mem_name,"memory@%" PRIx64, (uint64_t )rma_size); +_FDT ((fdt_begin_node (fdt, mem_name))); +_FDT ((fdt_property_string (fdt,"device_type" ,"memory" ))); +_FDT ((fdt_property (fdt,"reg" , mem_reg_property_nonrma, +sizeof (mem_reg_property_nonrma)))); +_FDT ((fdt_end_node (fdt))); + } +/* cpus */ _FDT ((fdt_begin_node (fdt,"cpus" )));
@@ -342,6 +355,7 @@ static void ppc_spapr_init(ram_addr_t ram_size, {CPUState *env;int i; +target_phys_addr_t rma_alloc_size, rma_size;ram_addr_t ram_offset;uint32_t initrd_base;long kernel_size, initrd_size, fw_size;
@@ -351,10 +365,23 @@ static void ppc_spapr_init(ram_addr_t ram_size, spapr =g_malloc (sizeof (*spapr)); cpu_ppc_hypercall = emulate_spapr_hypercall; -/* We place the device tree just below either the top of RAM, or -* 2GB, so that it can be processed with 32-bit code if -* necessary */ - spapr->fdt_addr =MIN (ram_size,0x80000000 ) -FDT_MAX_SIZE ; +/* Allocate RMA if necessary */ + rma_alloc_size =kvmppc_alloc_rma ("ppc_spapr.rma" ); + +if (rma_alloc_size ==-1 ) { +hw_error ("qemu: Unable to create RMA\n" ); +exit (1 ); + } +if (rma_alloc_size && (rma_alloc_size < ram_size)) { + rma_size = rma_alloc_size; + }else { + rma_size = ram_size; + } + +/* We place the device tree just below either the top of the RMA, +* or just below 2GB, whichever is lowere, so that it can be +* processed with 32-bit real mode code if necessary */ + spapr->fdt_addr =MIN (rma_size,0x80000000 ) -FDT_MAX_SIZE ; spapr->rtas_addr = spapr->fdt_addr -RTAS_MAX_SIZE ;/* init CPUs */
@@ -379,8 +406,13 @@ static void ppc_spapr_init(ram_addr_t ram_size,/* allocate RAM */ spapr->ram_limit = ram_size; - ram_offset =qemu_ram_alloc (NULL ,"ppc_spapr.ram" , spapr->ram_limit); -cpu_register_physical_memory (0 , ram_size, ram_offset); +if (spapr->ram_limit > rma_alloc_size) { +ram_addr_t nonrma_base = rma_alloc_size; +ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; + + ram_offset =qemu_ram_alloc (NULL ,"ppc_spapr.ram" , nonrma_size); +cpu_register_physical_memory (nonrma_base, nonrma_size, ram_offset); + }/* allocate hash page table. For now we always make this 16mb, * later we should probably make it scale to the size of guest
@@ -504,7 +536,7 @@ static void ppc_spapr_init(ram_addr_t ram_size, }/* Prepare the device tree */ - spapr->fdt_skel =spapr_create_fdt_skel (cpu_model, + spapr->fdt_skel =spapr_create_fdt_skel (cpu_model, rma_size, initrd_base, initrd_size, boot_device, kernel_cmdline, pteg_shift +7 );
target-ppc/kvm.c +43 -0
61 lines not on this page · raw message
target-ppc/kvm_ppc.h +6 -0
@@ -19,6 +19,7 @@ int kvmppc_get_hypercall(CPUState *env, uint8_t *buf, int buf_len);int kvmppc_set_interrupt (CPUState *env,int irq,int level);void kvmppc_set_papr (CPUState *env);int kvmppc_smt_threads (void ); +off_t kvmppc_alloc_rma (const char *name);#else
@@ -51,6 +52,11 @@ static inline int kvmppc_smt_threads(void) return 1; } +static inline off_t kvmppc_alloc_rma (const char *name) +{ +return 0 ; +} +#endif #ifndef CONFIG_KVM
Signature · 1 line
1.7.6.3
PATCH 3/4 pseries: Use Book3S-HV TCE acceleration capabilities
In reply to David GibsonThe pseries machine of qemu implements the TCE mechanism used as a virtual IOMMU for the PAPR defined virtual IO devices. Because the PAPR spec only defines a small DMA address space, the guest VIO drivers need to update TCE mappings very frequently - the virtual network device is particularly bad. This means many slow exits to qemu to emulate the H_PUT_TCE hypercall.
Sufficiently recent kernels allow this to be mitigated by implementing H_PUT_TCE in the host kernel. To make use of this, however, qemu needs to initialize the necessary TCE tables, and map them into itself so that the VIO device implementations can retrieve the mappings when they access guest memory (which is treated as a virtual DMA operation).
This patch adds the necessary calls to use the KVM TCE acceleration. If the kernel does not support acceleration, or there is some other error creating the accelerated TCE table, then it will still fall back to full userspace TCE implementation.
--- hw/spapr_vio.c | 8 ++++++- hw/spapr_vio.h | 1 + target-ppc/kvm.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/kvm_ppc.h | 14 +++++++++++++ 4 files changed, 76 insertions(+), 1 deletions(-)
hw/spapr_vio.c +7 -1
@@ -165,7 +165,13 @@ static void rtce_init(VIOsPAPRDevice *dev) *sizeof (VIOsPAPR_RTCE);if (size) { - dev->rtce_table =g_malloc0 (size); + dev->rtce_table =kvmppc_create_spapr_tce (dev->reg, + dev->rtce_window_size, + &dev->kvmtce_fd); + +if (!dev->rtce_table) { + dev->rtce_table =g_malloc0 (size); + } } }
hw/spapr_vio.h +1 -0
@@ -57,6 +57,7 @@ typedef struct VIOsPAPRDevice {target_ulong signal_state;uint32_t rtce_window_size;VIOsPAPR_RTCE *rtce_table; +int kvmtce_fd;VIOsPAPR_CRQ crq; } VIOsPAPRDevice;
target-ppc/kvm.c +54 -0
78 lines not on this page · raw message
target-ppc/kvm_ppc.h +14 -0
@@ -20,6 +20,8 @@ int kvmppc_set_interrupt(CPUState *env, int irq, int level);void kvmppc_set_papr (CPUState *env);int kvmppc_smt_threads (void );off_t kvmppc_alloc_rma (const char *name); +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);#else
@@ -57,6 +59,18 @@ static inline off_t kvmppc_alloc_rma(const char *name) return 0; } +static inline void *kvmppc_create_spapr_tce (uint32_t liobn, +uint32_t window_size,int *fd) +{ +return NULL ; +} + +static inline int kvmppc_remove_spapr_tce (void *table,int pfd, +uint32_t window_size) +{ +return -1 ; +} +#endif #ifndef CONFIG_KVM
Signature · 1 line
1.7.6.3
PATCH 4/4 pseries: Update SLOF firmware image
In reply to David GibsonThis patch updates the SLOF submodule and precompiled image. The new SLOF versions contains two changes of note:
* The previous SLOF has a bug in SCSI condition handling that was exposed by recent updates to qemu's SCSI emulation. This update fixes the bug.
* The previous SLOF has a bug in its addressing of SCSI devices, which can be exposed under certain conditions. The new SLOF also fixes this.
--- pc-bios/README | 2 +- pc-bios/slof.bin | Bin 579072 -> 578968 bytes roms/SLOF | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-)
pc-bios/README +1 -1
@@ -17,7 +17,7 @@ - SLOF (Slimline Open Firmware) is a free IEEE 1275 Open Firmware implementation for certain IBM POWER hardware. The sources are at https://github.com/dgibson/SLOF, and the image currently in qemu is - built from git tag qemu-slof-20110323. + built from git tag qemu-slof-20110930. - The PXE roms come from the iPXE project. Built with BANNER_TIME 0. Sources available at http://ipxe.org. Vendor:Device ID -> ROM mapping:
pc-bios/slof.bin binary +0 -0
roms/SLOF +1 -1
@@ -1 +1 @@ -Subproject commit d1d6b53b713a2b7c2c25685268fa932d28a4b4c0 +Subproject commit b94bde008b0d49ec4bfe933e110d0952d032ac28
Signature · 1 line
1.7.6.3
Quoted 21 lines · David Gibson
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises
CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implementCAP_SYNC_MMUand allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:* Hack the host kernel to lie and advertise
CAP_SYNC_MMUeven though it doesn't really implement it.
Quoted 8 lines
or
* Hack qemu so it does not check for
CAP_SYNC_MMUwhen the -mem-path option is used.Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper
CAP_SYNC_MMUsupport is ready.
I would prefer the latter. We could even #ifdef it for TARGET_PPC.
Alex
Quoted 26 lines · Alexander Graf
Quoted 23 lines · David Gibson
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises
CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implementCAP_SYNC_MMUand allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:* Hack the host kernel to lie and advertise
CAP_SYNC_MMUeven though it doesn't really implement it.or
Quoted 8 lines
Quoted 6 lines
* Hack qemu so it does not check for
CAP_SYNC_MMUwhen the -mem-path option is used.Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper
CAP_SYNC_MMUsupport is ready.I would prefer the latter. We could even #ifdef it for
TARGET_PPC.
Well, I don't see either approach as being remotely mergable. So it's really up to each individual person playing with it which hack is easier for them to apply temporarily while waiting for the proper solution to come along.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 34 lines · David Gibson
Quoted 33 lines · Alexander Graf
Quoted 29 lines · David Gibson
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises
CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implementCAP_SYNC_MMUand allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:* Hack the host kernel to lie and advertise
CAP_SYNC_MMUeven though it doesn't really implement it.or
* Hack qemu so it does not check for
CAP_SYNC_MMUwhen the -mem-path option is used.Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper
CAP_SYNC_MMUsupport is ready.
Quoted 6 lines
Quoted 1 line
I would prefer the latter. We could even #ifdef it for
TARGET_PPC.Well, I don't see either approach as being remotely mergable. So it's really up to each individual person playing with it which hack is easier for them to apply temporarily while waiting for the proper solution to come along.
Not sure. Why not make it a warning instead of failure on PPC and give people at least the chance to play with it?
Alex
Quoted 39 lines · Alexander Graf
Quoted 36 lines · David Gibson
Quoted 34 lines · Alexander Graf
Quoted 21 lines · David Gibson
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises
CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implementCAP_SYNC_MMUand allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:* Hack the host kernel to lie and advertise
CAP_SYNC_MMUeven though it doesn't really implement it.Quoted 8 lines
or
* Hack qemu so it does not check for
CAP_SYNC_MMUwhen the -mem-path option is used.Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper
CAP_SYNC_MMUsupport is ready.I would prefer the latter. We could even #ifdef it for
TARGET_PPC.
Quoted 7 lines
Quoted 4 lines
Well, I don't see either approach as being remotely mergable. So it's really up to each individual person playing with it which hack is easier for them to apply temporarily while waiting for the proper solution to come along.
Not sure. Why not make it a warning instead of failure on PPC and give people at least the chance to play with it?
Because it can trigger a serious kernel bug...
As far as I can tell, the fact that we haven't hit the crash/race on PPC so far is pure luck, not that we're actually less vulnerable to it.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 21 lines · David Gibson
Alex Graf has added support for KVM acceleration of the pseries machine, using his Book3S-PR KVM variant, which runs the guest in userspace, emulating supervisor operations. Recent kernels now have the Book3S-HV KVM variant which uses the hardware hypervisor features of recent POWER CPUs. Alex's changes to qemu are enough to get qemu working roughly with Book3S-HV, but taking full advantage of this mode needs more work. This patch series makes a start on better exploiting Book3S-HV.
Even with these patches, qemu won't quite be able to run on a current Book3S-HV KVM kernel. That's because current Book3S-HV requires guest memory to be backed by hugepages, but qemu refuses to use hugepages for guest memory unless KVM advertises
CAP_SYNC_MMU, which Book3S-HV does not currently do. We're working on improvements to the KVM code which will implementCAP_SYNC_MMUand allow smallpage backing of guests, but they're not there yet. So, in order to test Book3S-HV for now you need to either:* Hack the host kernel to lie and advertise
CAP_SYNC_MMUeven though it doesn't really implement it.
Quoted 8 lines
or
* Hack qemu so it does not check for
CAP_SYNC_MMUwhen the -mem-path option is used.Bot approaches are ugly and unsafe, but it seems we can generally get away with it in practice. Obviously this is only an interim hack until the proper
CAP_SYNC_MMUsupport is ready.
Thanks, applied all to my local ppc-next tree. Will push to repo.or.cz when Blue pulls the current ppc-next tree from there.
Alex