From: David Gibson <david@gibson.dropbear.id.au>
To: Sam Bobroff <sam.bobroff@au1.ibm.com>
Cc: anton@au1.ibm.com, mikey@neuling.org, aik@ozlabs.ru,
mpe@ellerman.id.au, agraf@suse.de, qemu-devel@nongnu.org,
paulus@samba.org, qemu-ppc@nongnu.org,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 3/3] spapr: Set ibm, pa-features HTM from KVM_CAP_PPC_HTM
Date: Thu, 7 Jul 2016 14:39:26 +1000 [thread overview]
Message-ID: <20160707043926.GR14675@voom.fritz.box> (raw)
In-Reply-To: <fb64116eb0795e0b2b0789a02b4ce8f694fc69e4.1467783317.git.sam.bobroff@au1.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 4094 bytes --]
On Wed, Jul 06, 2016 at 03:35:23PM +1000, Sam Bobroff wrote:
> Advertise HTM support in ibm, pa-features if KVM indicates support when
> queried via a new capability (KVM_CAP_PPC_HTM).
>
> If KVM returns false for the capability (which may indicate that the
> host kernel doesn't support the capability itself) attempt to
> determine availability using a fallback method based on KVM being
> KVM-HV and HTM being available to the QEMU process.
>
> Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> v2:
>
> * Improve readability of HTM bit set code.
> * Move the test for KVM into kvmppc_get_htm_support().
>
> hw/ppc/spapr.c | 3 +++
> target-ppc/kvm.c | 29 +++++++++++++++++++++++++++++
> target-ppc/kvm_ppc.h | 6 ++++++
> 3 files changed, 38 insertions(+)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 704aae7..843fbe7 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -712,6 +712,9 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
> } else /* env->mmu_model == POWERPC_MMU_2_07 */ {
> pa_features = pa_features_207;
> pa_size = sizeof(pa_features_207);
> + if (kvmppc_get_htm_support(env)) {
> + pa_features[24] |= 0x80;
> + }
> }
> if (env->ci_large_pages) {
> pa_features[3] |= 0x20;
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index 884d564..9d13446 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -20,6 +20,7 @@
> #include <sys/vfs.h>
>
> #include <linux/kvm.h>
> +#include "elf.h"
>
> #include "qemu-common.h"
> #include "qemu/error-report.h"
> @@ -1976,6 +1977,34 @@ uint32_t kvmppc_get_dfp(void)
> return kvmppc_read_int_cpu_dt("ibm,dfp");
> }
>
> +bool kvmppc_get_htm_support(CPUPPCState *env)
> +{
> + PowerPCCPU *cpu = ppc_env_get_cpu(env);
> + CPUState *cs = CPU(cpu);
> +
> + if (!kvm_enabled()) {
> + return false;
> + }
> + if (kvm_vm_check_extension(cs->kvm_state, KVM_CAP_PPC_HTM)) {
> + return true;
> + }
> + /*
> + * Fallback test for host kernels that don't yet support KVM_CAP_PPC_HTM.
> + * This will be unnecessary when KVM_API_VERSION is incremented (to 13 or
> + * above) because that will remove the ambiguity between the host kernel
> + * lacking support for KVM_CAP_PPC_HTM and it having support but reporting
> + * HTM as unavailable (both of which return 0, above).
> + */
> + if (kvm_vm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_PVINFO)) {
> + /* Assume this means PR KVM, so no TM. */
> + return false;
> + } else {
> + /* Assume this means HV KVM, propagate whatever host userspace sees. */
> + unsigned long hwcap2 = qemu_getauxval(AT_HWCAP2);
> + return !!(hwcap2 & PPC_FEATURE2_HAS_HTM);
> + }
> +}
> +
> static int kvmppc_get_pvinfo(CPUPPCState *env, struct kvm_ppc_pvinfo *pvinfo)
> {
> PowerPCCPU *cpu = ppc_env_get_cpu(env);
> diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
> index 20bfb59..b01c717 100644
> --- a/target-ppc/kvm_ppc.h
> +++ b/target-ppc/kvm_ppc.h
> @@ -17,6 +17,7 @@ uint32_t kvmppc_get_tbfreq(void);
> uint64_t kvmppc_get_clockfreq(void);
> uint32_t kvmppc_get_vmx(void);
> uint32_t kvmppc_get_dfp(void);
> +bool kvmppc_get_htm_support(CPUPPCState *env);
> bool kvmppc_get_host_model(char **buf);
> bool kvmppc_get_host_serial(char **buf);
> int kvmppc_get_hasidle(CPUPPCState *env);
> @@ -90,6 +91,11 @@ static inline uint32_t kvmppc_get_dfp(void)
> return 0;
> }
>
> +static inline bool kvmppc_get_htm_support(KVMState *kvm_state)
> +{
> + return false;
> +}
> +
> static inline int kvmppc_get_hasidle(CPUPPCState *env)
> {
> return 0;
--
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 --]
next prev parent reply other threads:[~2016-07-07 4:37 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 6:44 PR KVM and TM issues Anton Blanchard
2016-04-04 7:00 ` Alexey Kardashevskiy
2016-04-04 10:43 ` Anton Blanchard
2016-04-04 11:09 ` [PATCH] spapr: Don't set the TM ibm,pa-features bit in PR KVM mode Anton Blanchard
2016-04-04 11:13 ` [PATCH] spapr: Don't set the TM ibm, pa-features " Alexander Graf
2016-04-30 0:48 ` [PATCH v2] spapr: Don't set the TM ibm,pa-features " Anton Blanchard
2016-05-02 9:36 ` [Qemu-devel] [PATCH v2] spapr: Don't set the TM ibm, pa-features " haris iqbal
2016-05-27 4:52 ` David Gibson
2016-06-07 12:28 ` [PATCH 1/2] Add PowerPC AT_HWCAP2 definitions Anton Blanchard
2016-06-07 12:32 ` [PATCH 2/2] spapr: Better handling of ibm,pa-features TM bit Anton Blanchard
2016-06-08 2:26 ` David Gibson
2016-07-05 5:19 ` [PATCH 0/3] Rework spapr: Better handling of ibm, pa-features " Sam Bobroff
2016-07-05 5:19 ` [PATCH 1/3] spapr: Disable ibm, pa-features HTM bit Sam Bobroff
2016-07-05 5:51 ` David Gibson
2016-07-05 5:19 ` [PATCH 2/3] Add KVM_CAP_PPC_HTM to linux/kvm.h Sam Bobroff
2016-07-05 6:05 ` David Gibson
2016-07-06 4:41 ` Sam Bobroff
2016-07-06 5:09 ` David Gibson
2016-07-05 5:19 ` [PATCH 3/3] spapr: Set ibm, pa-features HTM from KVM_CAP_PPC_HTM Sam Bobroff
2016-07-05 6:52 ` David Gibson
2016-07-06 5:35 ` [PATCH v2 0/3] Rework spapr: Better handling of ibm, pa-features TM bit Sam Bobroff
2016-07-06 5:35 ` [PATCH v2 1/3] spapr: Disable ibm, pa-features HTM bit Sam Bobroff
2016-07-07 4:38 ` David Gibson
2016-07-06 5:35 ` [PATCH v2 2/3] Add KVM_CAP_PPC_HTM to linux/kvm.h Sam Bobroff
2016-07-07 4:38 ` David Gibson
2016-07-06 5:35 ` [PATCH v2 3/3] spapr: Set ibm, pa-features HTM from KVM_CAP_PPC_HTM Sam Bobroff
2016-07-07 4:39 ` David Gibson [this message]
2016-06-08 2:19 ` [PATCH 1/2] Add PowerPC AT_HWCAP2 definitions David Gibson
2016-04-05 2:12 ` [PATCH] spapr: Don't set the TM ibm,pa-features bit in PR KVM mode Paul Mackerras
2016-04-05 4:09 ` David Gibson
2016-04-05 7:33 ` Alexey Kardashevskiy
2016-04-04 11:11 ` [PATCH] powerpc: Clear user CPU feature bits if TM is disabled at runtime Anton Blanchard
2016-04-05 0:52 ` David Gibson
2016-04-05 9:35 ` Michael Ellerman
2016-04-05 9:56 ` Benjamin Herrenschmidt
2016-04-05 22:40 ` Michael Ellerman
2016-04-15 2:06 ` [PATCH 1/3] powerpc: scan_features() updates incorrect bits Anton Blanchard
2016-04-15 14:27 ` [1/3] " Michael Ellerman
2016-04-18 4:40 ` Michael Ellerman
2016-04-18 4:16 ` Michael Ellerman
2016-04-18 10:36 ` [PATCH v2 1/3] powerpc: scan_features() updates incorrect bits for REAL_LE Michael Ellerman
2016-04-19 10:09 ` [v2, " Michael Ellerman
2016-04-15 2:07 ` [PATCH 2/3] powerpc: Update cpu_user_features2 in scan_features() Anton Blanchard
2016-04-19 10:09 ` [2/3] " Michael Ellerman
2016-04-15 2:08 ` [PATCH 3/3] powerpc: Update TM user feature bits " Anton Blanchard
2016-04-19 10:09 ` [3/3] " Michael Ellerman
2016-04-04 11:09 ` PR KVM and TM issues Michael Neuling
2016-04-05 7:29 ` Alexey Kardashevskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160707043926.GR14675@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=anton@au1.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sam.bobroff@au1.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).