From: Alexandru Elisei <alexandru.elisei@arm.com>
To: will@kernel.org, julien.thierry.kdev@gmail.com,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, maz@kernel.org,
james.morse@arm.com, suzuki.poulose@arm.com,
mark.rutland@arm.com, andre.przywara@arm.com
Subject: [PATCH v2 kvmtool 04/10] arm: Get rid of the ARM_VCPU_FEATURE_FLAGS() macro
Date: Thu, 27 Jan 2022 16:20:27 +0000 [thread overview]
Message-ID: <20220127162033.54290-5-alexandru.elisei@arm.com> (raw)
In-Reply-To: <20220127162033.54290-1-alexandru.elisei@arm.com>
The ARM_VCPU_FEATURE_FLAGS() macro sets a feature bit in a rather
convoluted way: if cpu_id is 0, then bit KVM_ARM_VCPU_POWER_OFF is 0,
otherwise is set to 1. There's really no need for this indirection,
especially considering that the macro has been changed to return the same
value for both the arm and arm64 architectures. Replace it with a simple
conditional statement in kvm_cpu__arch_init(), which makes it clearer to
understand.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
arm/aarch32/include/kvm/kvm-cpu-arch.h | 4 ----
arm/aarch64/include/kvm/kvm-cpu-arch.h | 4 ----
arm/kvm-cpu.c | 6 +++++-
3 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/arm/aarch32/include/kvm/kvm-cpu-arch.h b/arm/aarch32/include/kvm/kvm-cpu-arch.h
index 780e0e2f0934..fc9aef9f6320 100644
--- a/arm/aarch32/include/kvm/kvm-cpu-arch.h
+++ b/arm/aarch32/include/kvm/kvm-cpu-arch.h
@@ -5,10 +5,6 @@
#include "arm-common/kvm-cpu-arch.h"
-#define ARM_VCPU_FEATURE_FLAGS(kvm, cpuid) { \
- [0] = (!!(cpuid) << KVM_ARM_VCPU_POWER_OFF), \
-}
-
#define ARM_MPIDR_HWID_BITMASK 0xFFFFFF
#define ARM_CPU_ID 0, 0, 0
#define ARM_CPU_ID_MPIDR 5
diff --git a/arm/aarch64/include/kvm/kvm-cpu-arch.h b/arm/aarch64/include/kvm/kvm-cpu-arch.h
index 016cf5b2b9ea..17b80493e2c0 100644
--- a/arm/aarch64/include/kvm/kvm-cpu-arch.h
+++ b/arm/aarch64/include/kvm/kvm-cpu-arch.h
@@ -5,10 +5,6 @@
#include "arm-common/kvm-cpu-arch.h"
-#define ARM_VCPU_FEATURE_FLAGS(kvm, cpuid) { \
- [0] = (!!(cpuid) << KVM_ARM_VCPU_POWER_OFF), \
-}
-
#define ARM_MPIDR_HWID_BITMASK 0xFF00FFFFFFUL
#define ARM_CPU_ID 3, 0, 0, 0
#define ARM_CPU_ID_MPIDR 5
diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 554414f81b7a..62177ea73f82 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -43,7 +43,7 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
unsigned int i;
struct kvm_vcpu_init preferred_init;
struct kvm_vcpu_init vcpu_init = {
- .features = ARM_VCPU_FEATURE_FLAGS(kvm, cpu_id)
+ .features = {},
};
vcpu = calloc(1, sizeof(struct kvm_cpu));
@@ -63,6 +63,10 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
if (vcpu->kvm_run == MAP_FAILED)
die("unable to mmap vcpu fd");
+ /* VCPU 0 is the boot CPU, the others start in a poweroff state. */
+ if (cpu_id > 0)
+ vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_POWER_OFF);
+
/* Set KVM_ARM_VCPU_PSCI_0_2 if available */
if (kvm__supports_extension(kvm, KVM_CAP_ARM_PSCI_0_2)) {
vcpu_init.features[0] |= (1UL << KVM_ARM_VCPU_PSCI_0_2);
--
2.31.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-27 16:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 16:20 [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 01/10] linux/err.h: Add missing stdbool.h include Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 02/10] bitops.h: Include wordsize.h to provide the __WORDSIZE define Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 03/10] arm: Move arch specific VCPU features to the arch specific function Alexandru Elisei
2022-01-27 16:20 ` Alexandru Elisei [this message]
2022-01-27 16:20 ` [PATCH v2 kvmtool 05/10] arm: Make the PMUv3 emulation code arm64 specific Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 06/10] arm64: Rework set_pmu_attr() Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 07/10] Add cpumask functions Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 08/10] update_headers.sh: Sync headers with Linux v5.17-rc1 + SET_PMU attribute Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 09/10] arm64: Add support for KVM_ARM_VCPU_PMU_V3_SET_PMU Alexandru Elisei
2022-01-27 16:20 ` [PATCH v2 kvmtool 10/10] arm64: Add --vcpu-affinity command line argument Alexandru Elisei
2022-02-14 10:20 ` [PATCH v2 kvmtool 00/10] arm64: Improve PMU support on heterogeneous systems Alexandru Elisei
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=20220127162033.54290-5-alexandru.elisei@arm.com \
--to=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=james.morse@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.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