* [Qemu-devel] [PATCH 0/2] ppc/kvm: Always allow transactional memory on POWER8 KVM-HV @ 2016-09-29 10:48 Thomas Huth 2016-09-29 10:48 ` [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR Thomas Huth 2016-09-29 10:48 ` [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too Thomas Huth 0 siblings, 2 replies; 5+ messages in thread From: Thomas Huth @ 2016-09-29 10:48 UTC (permalink / raw) To: David Gibson, qemu-ppc; +Cc: Alexander Graf, qemu-devel KVM-HV also supports transactional memory on POWER8 with older kernels that do not support the KVM_CAP_PPC_HTM extension yet. The first patch introduces a proper function for checking whether we're running on KVM-PR or KVM-HV, which is then used in the second patch to check that we're running on POWER8 with KVM-HV, so we can allow TM there, too. Thomas Huth (2): target-ppc/kvm: Add a wrapper function to check for KVM-PR target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too hw/ppc/spapr.c | 2 +- target-ppc/kvm.c | 32 +++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 12 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR 2016-09-29 10:48 [Qemu-devel] [PATCH 0/2] ppc/kvm: Always allow transactional memory on POWER8 KVM-HV Thomas Huth @ 2016-09-29 10:48 ` Thomas Huth 2016-09-29 23:23 ` David Gibson 2016-09-29 10:48 ` [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too Thomas Huth 1 sibling, 1 reply; 5+ messages in thread From: Thomas Huth @ 2016-09-29 10:48 UTC (permalink / raw) To: David Gibson, qemu-ppc; +Cc: Alexander Graf, qemu-devel It makes more sense if we have a proper function to check for KVM-PR than to check for the GET_PVINFO extension all over the place. Signed-off-by: Thomas Huth <thuth@redhat.com> --- target-ppc/kvm.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index e9a9faf..dca50bc 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -102,6 +102,13 @@ static void kvm_kick_cpu(void *opaque) qemu_cpu_kick(CPU(cpu)); } +/* Check whether we are running with KVM-PR (instead of KVM-HV) */ +static bool kvmppc_is_pr(KVMState *ks) +{ + /* Assume KVM-PR if the GET_PVINFO capability is available */ + return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; +} + static int kvm_ppc_register_host_cpu_type(void); int kvm_arch_init(MachineState *ms, KVMState *s) @@ -223,10 +230,9 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, * * For that to work we make a few assumptions: * - * - If KVM_CAP_PPC_GET_PVINFO is supported we are running "PR" - * KVM which only supports 4K and 16M pages, but supports them - * regardless of the backing store characteritics. We also don't - * support 1T segments. + * - Check whether we are running "PR" KVM which only supports 4K + * and 16M pages, but supports them regardless of the backing + * store characteritics. We also don't support 1T segments. * * This is safe as if HV KVM ever supports that capability or PR * KVM grows supports for more page/segment sizes, those versions @@ -241,7 +247,7 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, * implements KVM_CAP_PPC_GET_SMMU_INFO and thus doesn't hit * this fallback. */ - if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) { + if (kvmppc_is_pr(cs->kvm_state)) { /* No flags */ info->flags = 0; info->slb_size = 64; @@ -2270,11 +2276,8 @@ int kvmppc_reset_htab(int shift_hint) /* We have a kernel that predates the htab reset calls. For PR * KVM, we need to allocate the htab ourselves, for an HV KVM of - * this era, it has allocated a 16MB fixed size hash table - * already. Kernels of this era have the GET_PVINFO capability - * only on PR, so we use this hack to determine the right - * answer */ - if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { + * this era, it has allocated a 16MB fixed size hash table already. */ + if (kvmppc_is_pr(kvm_state)) { /* PR - tell caller to allocate htab */ return 0; } else { -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR 2016-09-29 10:48 ` [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR Thomas Huth @ 2016-09-29 23:23 ` David Gibson 0 siblings, 0 replies; 5+ messages in thread From: David Gibson @ 2016-09-29 23:23 UTC (permalink / raw) To: Thomas Huth; +Cc: qemu-ppc, Alexander Graf, qemu-devel [-- Attachment #1: Type: text/plain, Size: 3211 bytes --] On Thu, Sep 29, 2016 at 12:48:06PM +0200, Thomas Huth wrote: > It makes more sense if we have a proper function to check > for KVM-PR than to check for the GET_PVINFO extension all > over the place. > > Signed-off-by: Thomas Huth <thuth@redhat.com> Applied to ppc-for-2.8. I expanded your comment to say this should only be used for fallback tests, though. > --- > target-ppc/kvm.c | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > > diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c > index e9a9faf..dca50bc 100644 > --- a/target-ppc/kvm.c > +++ b/target-ppc/kvm.c > @@ -102,6 +102,13 @@ static void kvm_kick_cpu(void *opaque) > qemu_cpu_kick(CPU(cpu)); > } > > +/* Check whether we are running with KVM-PR (instead of KVM-HV) */ > +static bool kvmppc_is_pr(KVMState *ks) > +{ > + /* Assume KVM-PR if the GET_PVINFO capability is available */ > + return kvm_check_extension(ks, KVM_CAP_PPC_GET_PVINFO) != 0; > +} > + > static int kvm_ppc_register_host_cpu_type(void); > > int kvm_arch_init(MachineState *ms, KVMState *s) > @@ -223,10 +230,9 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, > * > * For that to work we make a few assumptions: > * > - * - If KVM_CAP_PPC_GET_PVINFO is supported we are running "PR" > - * KVM which only supports 4K and 16M pages, but supports them > - * regardless of the backing store characteritics. We also don't > - * support 1T segments. > + * - Check whether we are running "PR" KVM which only supports 4K > + * and 16M pages, but supports them regardless of the backing > + * store characteritics. We also don't support 1T segments. > * > * This is safe as if HV KVM ever supports that capability or PR > * KVM grows supports for more page/segment sizes, those versions > @@ -241,7 +247,7 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, > * implements KVM_CAP_PPC_GET_SMMU_INFO and thus doesn't hit > * this fallback. > */ > - if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) { > + if (kvmppc_is_pr(cs->kvm_state)) { > /* No flags */ > info->flags = 0; > info->slb_size = 64; > @@ -2270,11 +2276,8 @@ int kvmppc_reset_htab(int shift_hint) > > /* We have a kernel that predates the htab reset calls. For PR > * KVM, we need to allocate the htab ourselves, for an HV KVM of > - * this era, it has allocated a 16MB fixed size hash table > - * already. Kernels of this era have the GET_PVINFO capability > - * only on PR, so we use this hack to determine the right > - * answer */ > - if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { > + * this era, it has allocated a 16MB fixed size hash table already. */ > + if (kvmppc_is_pr(kvm_state)) { > /* PR - tell caller to allocate htab */ > return 0; > } else { -- 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too 2016-09-29 10:48 [Qemu-devel] [PATCH 0/2] ppc/kvm: Always allow transactional memory on POWER8 KVM-HV Thomas Huth 2016-09-29 10:48 ` [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR Thomas Huth @ 2016-09-29 10:48 ` Thomas Huth 2016-09-29 23:26 ` David Gibson 1 sibling, 1 reply; 5+ messages in thread From: Thomas Huth @ 2016-09-29 10:48 UTC (permalink / raw) To: David Gibson, qemu-ppc; +Cc: Alexander Graf, qemu-devel Transactional memory is also supported on POWER8 KVM-HV if the KVM_CAP_PPC_HTM is not available in the kernel yet, so add a hack to allow TM here, too. Signed-off-by: Thomas Huth <thuth@redhat.com> --- hw/ppc/spapr.c | 2 +- target-ppc/kvm.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index fc37145..2f4e818 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -584,7 +584,7 @@ static void spapr_populate_pa_features(CPUPPCState *env, void *fdt, int offset) */ pa_features[3] |= 0x20; } - if (kvmppc_has_cap_htm()) { + if (kvmppc_has_cap_htm() && pa_size > 24) { pa_features[24] |= 0x80; /* Transactional memory support */ } diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index dca50bc..e990cb7 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -567,11 +567,18 @@ int kvm_arch_init_vcpu(CPUState *cs) idle_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, kvm_kick_cpu, cpu); - /* Some targets support access to KVM's guest TLB. */ switch (cenv->mmu_model) { case POWERPC_MMU_BOOKE206: + /* This target supports access to KVM's guest TLB */ ret = kvm_booke206_tlb_init(cpu); break; + case POWERPC_MMU_2_07: + if (!cap_htm && !kvmppc_is_pr(cs->kvm_state)) { + /* KVM-HV has transactional memory on POWER8 also without the + * KVM_CAP_PPC_HTM extension, so enable it here instead. */ + cap_htm = true; + } + break; default: break; } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too 2016-09-29 10:48 ` [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too Thomas Huth @ 2016-09-29 23:26 ` David Gibson 0 siblings, 0 replies; 5+ messages in thread From: David Gibson @ 2016-09-29 23:26 UTC (permalink / raw) To: Thomas Huth; +Cc: qemu-ppc, Alexander Graf, qemu-devel [-- Attachment #1: Type: text/plain, Size: 2110 bytes --] On Thu, Sep 29, 2016 at 12:48:07PM +0200, Thomas Huth wrote: > Transactional memory is also supported on POWER8 KVM-HV if the > KVM_CAP_PPC_HTM is not available in the kernel yet, so add a hack > to allow TM here, too. > > Signed-off-by: Thomas Huth <thuth@redhat.com> Applied to ppc-for-2.8. > --- > hw/ppc/spapr.c | 2 +- > target-ppc/kvm.c | 9 ++++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index fc37145..2f4e818 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -584,7 +584,7 @@ static void spapr_populate_pa_features(CPUPPCState *env, void *fdt, int offset) > */ > pa_features[3] |= 0x20; > } > - if (kvmppc_has_cap_htm()) { > + if (kvmppc_has_cap_htm() && pa_size > 24) { It looks like this is an unrelated fix to the original TM test. I'll fold it into the original patch. > pa_features[24] |= 0x80; /* Transactional memory support */ > } > > diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c > index dca50bc..e990cb7 100644 > --- a/target-ppc/kvm.c > +++ b/target-ppc/kvm.c > @@ -567,11 +567,18 @@ int kvm_arch_init_vcpu(CPUState *cs) > > idle_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, kvm_kick_cpu, cpu); > > - /* Some targets support access to KVM's guest TLB. */ > switch (cenv->mmu_model) { > case POWERPC_MMU_BOOKE206: > + /* This target supports access to KVM's guest TLB */ > ret = kvm_booke206_tlb_init(cpu); > break; > + case POWERPC_MMU_2_07: > + if (!cap_htm && !kvmppc_is_pr(cs->kvm_state)) { > + /* KVM-HV has transactional memory on POWER8 also without the > + * KVM_CAP_PPC_HTM extension, so enable it here instead. */ > + cap_htm = true; > + } > + break; > default: > break; > } -- 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 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-29 23:37 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-29 10:48 [Qemu-devel] [PATCH 0/2] ppc/kvm: Always allow transactional memory on POWER8 KVM-HV Thomas Huth 2016-09-29 10:48 ` [Qemu-devel] [PATCH 1/2] target-ppc/kvm: Add a wrapper function to check for KVM-PR Thomas Huth 2016-09-29 23:23 ` David Gibson 2016-09-29 10:48 ` [Qemu-devel] [PATCH 2/2] target-ppc/kvm: Enable transactional memory on POWER8 with KVM-HV, too Thomas Huth 2016-09-29 23:26 ` David Gibson
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).