From: Andrew Jones <drjones@redhat.com>
To: qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: peter.maydell@linaro.org, christoffer.dall@linaro.org,
marc.zyngier@arm.com, imammedo@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] arm: kvm: set MPIDR when we can
Date: Mon, 27 Feb 2017 18:37:06 +0100 [thread overview]
Message-ID: <20170227173706.15210-3-drjones@redhat.com> (raw)
In-Reply-To: <20170227173706.15210-1-drjones@redhat.com>
If KVM supports user provided MPIDRs for the vcpus, then provide
them. This simplifies management of vcpus as we can be sure of
the identity of a vcpu even before it's been instantiated.
Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
target/arm/cpu.c | 3 +--
target/arm/kvm32.c | 22 ++++++++++++++--------
target/arm/kvm64.c | 22 ++++++++++++++--------
3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index f7157dc0e59d..83cd5eefbef8 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -741,8 +741,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
return;
}
- /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override it.
- * We don't support setting cluster ID ([16..23]) (known as Aff2
+ /* We don't currently support setting cluster ID ([16..23]) (known as Aff2
* in later ARM ARM versions), or any of the higher affinity level fields,
* so these bits always RAZ.
*/
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
index 069da0c5fd10..5ad732498e5c 100644
--- a/target/arm/kvm32.c
+++ b/target/arm/kvm32.c
@@ -186,7 +186,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
{
int ret;
uint64_t v;
- uint32_t mpidr;
struct kvm_one_reg r;
ARMCPU *cpu = ARM_CPU(cs);
@@ -223,16 +222,23 @@ int kvm_arch_init_vcpu(CPUState *cs)
return -EINVAL;
}
- /*
- * When KVM is in use, PSCI is emulated in-kernel and not by qemu.
- * Currently KVM has its own idea about MPIDR assignment, so we
- * override our defaults with what we get from KVM.
- */
- ret = kvm_get_one_reg(cs, ARM_CP15_REG32(ARM_CPU_ID_MPIDR), &mpidr);
+ if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_USER_MPIDR)) {
+ ret = kvm_set_one_reg(cs, ARM_CP15_REG32(ARM_CPU_ID_MPIDR),
+ &cpu->mp_affinity);
+ } else {
+ /* If we can't set the MPIDR, then KVM will generate one. We must
+ * update our copy to that one in order to stay synchronized.
+ */
+ uint32_t mpidr;
+
+ ret = kvm_get_one_reg(cs, ARM_CP15_REG32(ARM_CPU_ID_MPIDR), &mpidr);
+ if (!ret) {
+ cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK;
+ }
+ }
if (ret) {
return ret;
}
- cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK;
return kvm_arm_init_cpreg_list(cpu);
}
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index 61111091ad3b..a7d3f876c43b 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -486,7 +486,6 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc)
int kvm_arch_init_vcpu(CPUState *cs)
{
int ret;
- uint64_t mpidr;
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
@@ -524,16 +523,23 @@ int kvm_arch_init_vcpu(CPUState *cs)
return ret;
}
- /*
- * When KVM is in use, PSCI is emulated in-kernel and not by qemu.
- * Currently KVM has its own idea about MPIDR assignment, so we
- * override our defaults with what we get from KVM.
- */
- ret = kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), &mpidr);
+ if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_USER_MPIDR)) {
+ ret = kvm_set_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR),
+ &cpu->mp_affinity);
+ } else {
+ /* If we can't set the MPIDR, then KVM will generate one. We must
+ * update our copy to that one in order to stay synchronized.
+ */
+ uint64_t mpidr;
+
+ ret = kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), &mpidr);
+ if (!ret) {
+ cpu->mp_affinity = mpidr & ARM64_AFFINITY_MASK;
+ }
+ }
if (ret) {
return ret;
}
- cpu->mp_affinity = mpidr & ARM64_AFFINITY_MASK;
kvm_arm_init_debug(cs);
--
2.9.3
next prev parent reply other threads:[~2017-02-27 17:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 17:37 [Qemu-devel] [PATCH 0/2] Enable QEMU to control MPIDR values Andrew Jones
2017-02-27 17:37 ` [Qemu-devel] [PATCH 1/2] HACK: update linux/kvm header Andrew Jones
2017-02-27 17:37 ` Andrew Jones [this message]
2017-03-02 16:13 ` [Qemu-devel] [PATCH 2/2] arm: kvm: set MPIDR when we can Peter Maydell
2017-03-02 16:23 ` Andrew Jones
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=20170227173706.15210-3-drjones@redhat.com \
--to=drjones@redhat.com \
--cc=christoffer.dall@linaro.org \
--cc=imammedo@redhat.com \
--cc=marc.zyngier@arm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).