From: Pavel Tatashin <pasha.tatashin@soleen.com>
To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org,
ebiederm@xmission.com, kexec@lists.infradead.org,
linux-kernel@vger.kernel.org, corbet@lwn.net,
catalin.marinas@arm.com, will@kernel.org,
linux-arm-kernel@lists.infradead.org, maz@kernel.org,
james.morse@arm.com, vladimir.murzin@arm.com,
matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com,
steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de,
selindag@gmail.com, tyhicks@linux.microsoft.com,
kernelfans@gmail.com, akpm@linux-foundation.org,
madvenka@linux.microsoft.com
Subject: [PATCH v15 01/15] arm64: kernel: add helper for booted at EL2 and not VHE
Date: Tue, 8 Jun 2021 20:44:05 -0400 [thread overview]
Message-ID: <20210609004419.936873-2-pasha.tatashin@soleen.com> (raw)
In-Reply-To: <20210609004419.936873-1-pasha.tatashin@soleen.com>
Replace places that contain logic like this:
is_hyp_mode_available() && !is_kernel_in_hyp_mode()
With a dedicated boolean function is_hyp_nvhe(). This will be needed
later in kexec in order to sooner switch back to EL2.
Suggested-by: James Morse <james.morse@arm.com>
Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
---
arch/arm64/include/asm/virt.h | 5 +++++
arch/arm64/kernel/cpu-reset.h | 3 +--
arch/arm64/kernel/hibernate.c | 2 +-
arch/arm64/kernel/sdei.c | 2 +-
4 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
index 7379f35ae2c6..a9457e96203c 100644
--- a/arch/arm64/include/asm/virt.h
+++ b/arch/arm64/include/asm/virt.h
@@ -128,6 +128,11 @@ static __always_inline bool is_protected_kvm_enabled(void)
return cpus_have_final_cap(ARM64_KVM_PROTECTED_MODE);
}
+static inline bool is_hyp_nvhe(void)
+{
+ return is_hyp_mode_available() && !is_kernel_in_hyp_mode();
+}
+
#endif /* __ASSEMBLY__ */
#endif /* ! __ASM__VIRT_H */
diff --git a/arch/arm64/kernel/cpu-reset.h b/arch/arm64/kernel/cpu-reset.h
index 9a7b1262ef17..81b3d0fe7a63 100644
--- a/arch/arm64/kernel/cpu-reset.h
+++ b/arch/arm64/kernel/cpu-reset.h
@@ -20,8 +20,7 @@ static inline void __noreturn __nocfi cpu_soft_restart(unsigned long entry,
{
typeof(__cpu_soft_restart) *restart;
- unsigned long el2_switch = !is_kernel_in_hyp_mode() &&
- is_hyp_mode_available();
+ unsigned long el2_switch = is_hyp_nvhe();
restart = (void *)__pa_symbol(function_nocfi(__cpu_soft_restart));
cpu_install_idmap();
diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index b1cef371df2b..42b5d8105ab9 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c
@@ -49,7 +49,7 @@
extern int in_suspend;
/* Do we need to reset el2? */
-#define el2_reset_needed() (is_hyp_mode_available() && !is_kernel_in_hyp_mode())
+#define el2_reset_needed() (is_hyp_nvhe())
/* temporary el2 vectors in the __hibernate_exit_text section. */
extern char hibernate_el2_vectors[];
diff --git a/arch/arm64/kernel/sdei.c b/arch/arm64/kernel/sdei.c
index 2c7ca449dd51..cf06929c44e3 100644
--- a/arch/arm64/kernel/sdei.c
+++ b/arch/arm64/kernel/sdei.c
@@ -200,7 +200,7 @@ unsigned long sdei_arch_get_entry_point(int conduit)
* dropped to EL1 because we don't support VHE, then we can't support
* SDEI.
*/
- if (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) {
+ if (is_hyp_nvhe()) {
pr_err("Not supported on this hardware/boot configuration\n");
goto out_err;
}
--
2.25.1
next prev parent reply other threads:[~2021-06-09 0:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 0:44 [PATCH v15 00/15] arm64: MMU enabled kexec relocation Pavel Tatashin
2021-06-09 0:44 ` Pavel Tatashin [this message]
2021-06-09 0:44 ` [PATCH v15 02/15] arm64: trans_pgd: hibernate: Add trans_pgd_copy_el2_vectors Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 03/15] arm64: hibernate: abstract ttrb0 setup function Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 04/15] arm64: kexec: flush image and lists during kexec load time Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 05/15] arm64: kexec: skip relocation code for inplace kexec Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 06/15] arm64: kexec: Use dcache ops macros instead of open-coding Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 07/15] arm64: kexec: pass kimage as the only argument to relocation function Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 08/15] arm64: kexec: configure EL2 vectors for kexec Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 09/15] arm64: kexec: relocate in EL1 mode Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 10/15] arm64: kexec: use ld script for relocation function Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 11/15] arm64: kexec: install a copy of the linear-map Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 12/15] arm64: kexec: keep MMU enabled during kexec relocation Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 13/15] arm64: kexec: remove the pre-kexec PoC maintenance Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 14/15] arm64: kexec: remove cpu-reset.h Pavel Tatashin
2021-06-09 0:44 ` [PATCH v15 15/15] arm64: trans_pgd: remove trans_pgd_map_page() Pavel Tatashin
2021-06-16 12:17 ` [PATCH v15 00/15] arm64: MMU enabled kexec relocation Pavel Tatashin
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=20210609004419.936873-2-pasha.tatashin@soleen.com \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=ebiederm@xmission.com \
--cc=james.morse@arm.com \
--cc=jmorris@namei.org \
--cc=kernelfans@gmail.com \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=madvenka@linux.microsoft.com \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=maz@kernel.org \
--cc=rfontana@redhat.com \
--cc=sashal@kernel.org \
--cc=selindag@gmail.com \
--cc=steve.capper@arm.com \
--cc=tglx@linutronix.de \
--cc=tyhicks@linux.microsoft.com \
--cc=vladimir.murzin@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