2020-09-04 20:10:21 +00:00
|
|
|
From ce3aeb76f778a401f356a534e77d0964a5f3b2cb Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <ce3aeb76f778a401f356a534e77d0964a5f3b2cb.1599166690.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
|
|
|
References: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
Date: Thu, 26 Jul 2018 09:13:42 +0200
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 020/333] arm64: KVM: compute_layout before altenates are
|
2019-04-08 23:49:20 +00:00
|
|
|
applied
|
2020-09-04 20:10:21 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.142-rt63.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
compute_layout() is invoked as part of an alternative fixup under
|
|
|
|
stop_machine() and needs a sleeping lock as part of get_random_long().
|
|
|
|
|
|
|
|
Invoke compute_layout() before the alternatives are applied.
|
|
|
|
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
arch/arm64/include/asm/alternative.h | 6 ++++++
|
|
|
|
arch/arm64/kernel/alternative.c | 1 +
|
|
|
|
arch/arm64/kvm/va_layout.c | 7 +------
|
2018-08-27 14:32:32 +00:00
|
|
|
3 files changed, 8 insertions(+), 6 deletions(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
|
2020-09-04 20:10:21 +00:00
|
|
|
index 844f05b23115..04b950d4c7f5 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/arch/arm64/include/asm/alternative.h
|
|
|
|
+++ b/arch/arm64/include/asm/alternative.h
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -35,6 +35,12 @@ void apply_alternatives_module(void *start, size_t length);
|
2018-08-27 14:32:32 +00:00
|
|
|
static inline void apply_alternatives_module(void *start, size_t length) { }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef CONFIG_KVM_ARM_HOST
|
|
|
|
+void kvm_compute_layout(void);
|
|
|
|
+#else
|
|
|
|
+static inline void kvm_compute_layout(void) { }
|
|
|
|
+#endif
|
|
|
|
+
|
2020-03-06 11:44:27 +00:00
|
|
|
#define ALTINSTR_ENTRY(feature) \
|
2018-08-27 14:32:32 +00:00
|
|
|
" .word 661b - .\n" /* label */ \
|
2020-03-06 11:44:27 +00:00
|
|
|
" .word 663f - .\n" /* new instruction */ \
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
|
2020-08-28 04:53:35 +00:00
|
|
|
index 0d345622bbba..ab96c1c3ab77 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/arch/arm64/kernel/alternative.c
|
|
|
|
+++ b/arch/arm64/kernel/alternative.c
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -212,6 +212,7 @@ static int __apply_alternatives_multi_stop(void *unused)
|
2018-08-27 14:32:32 +00:00
|
|
|
void __init apply_alternatives_all(void)
|
|
|
|
{
|
|
|
|
/* better not try code patching on a live SMP system */
|
|
|
|
+ kvm_compute_layout();
|
|
|
|
stop_machine(__apply_alternatives_multi_stop, NULL, cpu_online_mask);
|
|
|
|
}
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/arch/arm64/kvm/va_layout.c b/arch/arm64/kvm/va_layout.c
|
|
|
|
index c712a7376bc1..792da0e125de 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/arch/arm64/kvm/va_layout.c
|
|
|
|
+++ b/arch/arm64/kvm/va_layout.c
|
|
|
|
@@ -33,7 +33,7 @@ static u8 tag_lsb;
|
|
|
|
static u64 tag_val;
|
|
|
|
static u64 va_mask;
|
|
|
|
|
|
|
|
-static void compute_layout(void)
|
|
|
|
+__init void kvm_compute_layout(void)
|
|
|
|
{
|
|
|
|
phys_addr_t idmap_addr = __pa_symbol(__hyp_idmap_text_start);
|
|
|
|
u64 hyp_va_msb;
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -121,8 +121,6 @@ void __init kvm_update_va_mask(struct alt_instr *alt,
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
BUG_ON(nr_inst != 5);
|
|
|
|
|
|
|
|
- if (!has_vhe() && !va_mask)
|
|
|
|
- compute_layout();
|
|
|
|
|
|
|
|
for (i = 0; i < nr_inst; i++) {
|
|
|
|
u32 rd, rn, insn, oinsn;
|
2019-04-08 23:49:20 +00:00
|
|
|
@@ -167,9 +165,6 @@ void kvm_patch_vector_branch(struct alt_instr *alt,
|
2018-08-27 14:32:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!va_mask)
|
|
|
|
- compute_layout();
|
|
|
|
-
|
|
|
|
/*
|
|
|
|
* Compute HYP VA by using the same computation as kern_hyp_va()
|
|
|
|
*/
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|