From: Marc Zyngier <marc.zyngier@arm.com>
To: stable@vger.kernel.org
Cc: Will Deacon <will.deacon@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Christoffer Dall <christoffer.dall@arm.com>
Subject: [PATCH 03/23] KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation
Date: Fri, 20 Jul 2018 10:56:14 +0100 [thread overview]
Message-ID: <20180720095634.2173-4-marc.zyngier@arm.com> (raw)
In-Reply-To: <20180720095634.2173-1-marc.zyngier@arm.com>
From: James Morse <james.morse@arm.com>
Commit 36989e7fd386a9a5822c48691473863f8fbb404d upstream.
kvm_host_cpu_state is a per-cpu allocation made from kvm_arch_init()
used to store the host EL1 registers when KVM switches to a guest.
Make it easier for ASM to generate pointers into this per-cpu memory
by making it a static allocation.
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/kvm/arm.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index ef6595c7d697..d7cd5410ab5c 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -51,8 +51,8 @@
__asm__(".arch_extension virt");
#endif
+DEFINE_PER_CPU(kvm_cpu_context_t, kvm_host_cpu_state);
static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page);
-static kvm_cpu_context_t __percpu *kvm_host_cpu_state;
static unsigned long hyp_default_vectors;
/* Per-CPU variable containing the currently running vcpu. */
@@ -338,7 +338,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
}
vcpu->cpu = cpu;
- vcpu->arch.host_cpu_context = this_cpu_ptr(kvm_host_cpu_state);
+ vcpu->arch.host_cpu_context = this_cpu_ptr(&kvm_host_cpu_state);
kvm_arm_set_running_vcpu(vcpu);
}
@@ -1199,19 +1199,8 @@ static inline void hyp_cpu_pm_exit(void)
}
#endif
-static void teardown_common_resources(void)
-{
- free_percpu(kvm_host_cpu_state);
-}
-
static int init_common_resources(void)
{
- kvm_host_cpu_state = alloc_percpu(kvm_cpu_context_t);
- if (!kvm_host_cpu_state) {
- kvm_err("Cannot allocate host CPU state\n");
- return -ENOMEM;
- }
-
/* set size of VMID supported by CPU */
kvm_vmid_bits = kvm_get_vmid_bits();
kvm_info("%d-bit VMID\n", kvm_vmid_bits);
@@ -1369,7 +1358,7 @@ static int init_hyp_mode(void)
for_each_possible_cpu(cpu) {
kvm_cpu_context_t *cpu_ctxt;
- cpu_ctxt = per_cpu_ptr(kvm_host_cpu_state, cpu);
+ cpu_ctxt = per_cpu_ptr(&kvm_host_cpu_state, cpu);
err = create_hyp_mappings(cpu_ctxt, cpu_ctxt + 1, PAGE_HYP);
if (err) {
@@ -1447,7 +1436,6 @@ int kvm_arch_init(void *opaque)
out_hyp:
teardown_hyp_mode();
out_err:
- teardown_common_resources();
return err;
}
--
2.18.0
next prev parent reply other threads:[~2018-07-20 10:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 9:56 [PATCH 00/23] arm64: 4.9 backport of the SSBD mitigation patches Marc Zyngier
2018-07-20 9:56 ` [PATCH 01/23] arm64: assembler: introduce ldr_this_cpu Marc Zyngier
2018-07-20 9:56 ` [PATCH 02/23] KVM: arm64: Store vcpu on the stack during __guest_enter() Marc Zyngier
2018-07-20 9:56 ` Marc Zyngier [this message]
2018-07-20 9:56 ` [PATCH 04/23] KVM: arm64: Change hyp_panic()s dependency on tpidr_el2 Marc Zyngier
2018-07-20 9:56 ` [PATCH 05/23] arm64: alternatives: use tpidr_el2 on VHE hosts Marc Zyngier
2018-07-20 9:56 ` [PATCH 06/23] KVM: arm64: Stop save/restoring host tpidr_el1 on VHE Marc Zyngier
2018-07-20 9:56 ` [PATCH 07/23] arm64: alternatives: Add dynamic patching feature Marc Zyngier
2018-07-20 9:56 ` [PATCH 08/23] KVM: arm/arm64: Do not use kern_hyp_va() with kvm_vgic_global_state Marc Zyngier
2018-07-20 9:56 ` [PATCH 09/23] KVM: arm64: Avoid storing the vcpu pointer on the stack Marc Zyngier
2018-07-20 9:56 ` [PATCH 10/23] arm/arm64: smccc: Add SMCCC-specific return codes Marc Zyngier
2018-07-20 9:56 ` [PATCH 11/23] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1 Marc Zyngier
2018-07-20 9:56 ` [PATCH 12/23] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2 Marc Zyngier
2018-07-20 9:56 ` [PATCH 13/23] arm64: Add ARCH_WORKAROUND_2 probing Marc Zyngier
2018-07-20 9:56 ` [PATCH 14/23] arm64: Add 'ssbd' command-line option Marc Zyngier
2018-07-20 9:56 ` [PATCH 15/23] arm64: ssbd: Add global mitigation state accessor Marc Zyngier
2018-07-20 9:56 ` [PATCH 16/23] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation Marc Zyngier
2018-07-20 9:56 ` [PATCH 17/23] arm64: ssbd: Restore mitigation status on CPU resume Marc Zyngier
2018-07-20 9:56 ` [PATCH 18/23] arm64: ssbd: Introduce thread flag to control userspace mitigation Marc Zyngier
2018-07-20 9:56 ` [PATCH 19/23] arm64: ssbd: Add prctl interface for per-thread mitigation Marc Zyngier
2018-07-20 9:56 ` [PATCH 20/23] arm64: KVM: Add HYP per-cpu accessors Marc Zyngier
2018-07-20 9:56 ` [PATCH 21/23] arm64: KVM: Add ARCH_WORKAROUND_2 support for guests Marc Zyngier
2018-07-20 9:56 ` [PATCH 22/23] arm64: KVM: Handle guest's ARCH_WORKAROUND_2 requests Marc Zyngier
2018-07-20 9:56 ` [PATCH 23/23] arm64: KVM: Add ARCH_WORKAROUND_2 discovery through ARCH_FEATURES_FUNC_ID Marc Zyngier
2018-07-20 10:43 ` [PATCH 00/23] arm64: 4.9 backport of the SSBD mitigation patches Greg KH
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=20180720095634.2173-4-marc.zyngier@arm.com \
--to=marc.zyngier@arm.com \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@arm.com \
--cc=mark.rutland@arm.com \
--cc=stable@vger.kernel.org \
--cc=will.deacon@arm.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).