From: Marc Zyngier <maz@kernel.org>
To: kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oupton@kernel.org>,
Zenghui Yu <yuzenghui@huawei.com>, Fuad Tabba <tabba@google.com>,
Will Deacon <will@kernel.org>,
Mostafa Saleh <smostafa@google.com>,
Quentin Perret <qperret@google.com>
Subject: [PATCH 2/5] KVM: arm64: pkvm: Simplify BTI handling on CPU boot
Date: Sat, 21 Mar 2026 21:24:16 +0000 [thread overview]
Message-ID: <20260321212419.2803972-3-maz@kernel.org> (raw)
In-Reply-To: <20260321212419.2803972-1-maz@kernel.org>
In order to perform an indirect branch to kvm_host_psci_cpu_entry()
on a BTI-aware system, we first branch to a 'BTI j' landing pad,
and from there branch again to the target.
While this works, this is really not required:
- BLR works with 'BTI c' and 'PACIASP' as the landing pad
- Even if LR gets clobbered by BLR, we are going to restore the
host's registers, so it is pointless to try and avoid touching
LR
Given the above, drop the veneer and directly call into C code.
If we were to come back from it, we'd directly enter the error
handler.
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
arch/arm64/kvm/hyp/nvhe/host.S | 10 ----------
arch/arm64/kvm/hyp/nvhe/hyp-init.S | 9 +++++----
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S
index eef15b374abb0..465f6f1dd6414 100644
--- a/arch/arm64/kvm/hyp/nvhe/host.S
+++ b/arch/arm64/kvm/hyp/nvhe/host.S
@@ -291,13 +291,3 @@ SYM_CODE_START(__kvm_hyp_host_forward_smc)
ret
SYM_CODE_END(__kvm_hyp_host_forward_smc)
-
-/*
- * kvm_host_psci_cpu_entry is called through br instruction, which requires
- * bti j instruction as compilers (gcc and llvm) doesn't insert bti j for external
- * functions, but bti c instead.
- */
-SYM_CODE_START(kvm_host_psci_cpu_entry)
- bti j
- b __kvm_host_psci_cpu_entry
-SYM_CODE_END(kvm_host_psci_cpu_entry)
diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
index 5d00bde092010..55e0dce65dc56 100644
--- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S
+++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S
@@ -213,12 +213,13 @@ SYM_CODE_START_LOCAL(__kvm_hyp_init_cpu)
mov x0, x28
bl ___kvm_hyp_init // Clobbers x0..x2
- /* Leave idmap. */
+ /* Leave idmap -- using BLR is OK, LR is restored from host context */
mov x0, x29
- ldr x1, =kvm_host_psci_cpu_entry
- br x1
+ ldr x1, =__kvm_host_psci_cpu_entry
+ blr x1
- // The core booted in EL1. KVM cannot be initialized on it.
+ // The core booted in EL1, or the C code unexpectedly returned.
+ // Either way, KVM cannot be initialized on it.
1: wfe
wfi
b 1b
--
2.47.3
next prev parent reply other threads:[~2026-03-21 21:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 21:24 [PATCH 0/5] KVM: arm64: pkvm; Rework aspects of the PSCI relay Marc Zyngier
2026-03-21 21:24 ` [PATCH 1/5] KVM: arm64: pkvm: Move error handling to the end of kvm_hyp_cpu_entry Marc Zyngier
2026-03-22 15:08 ` Fuad Tabba
2026-03-21 21:24 ` Marc Zyngier [this message]
2026-03-22 15:37 ` [PATCH 2/5] KVM: arm64: pkvm: Simplify BTI handling on CPU boot Fuad Tabba
2026-03-21 21:24 ` [PATCH 3/5] KVM: arm64: pkvm: Turn __kvm_hyp_init_cpu into an inner label Marc Zyngier
2026-03-22 15:43 ` Fuad Tabba
2026-03-21 21:24 ` [PATCH 4/5] KVM: arm64: pkvm: Use direct function pointers for cpu_{on,resume} Marc Zyngier
2026-03-22 15:49 ` Fuad Tabba
2026-03-23 8:43 ` Marc Zyngier
2026-03-21 21:24 ` [PATCH 5/5] KVM: arm64: Remove extra ISBs when using msr_hcr_el2 Marc Zyngier
2026-03-22 15:55 ` Fuad Tabba
2026-03-22 15:57 ` [PATCH 0/5] KVM: arm64: pkvm; Rework aspects of the PSCI relay Fuad Tabba
2026-03-23 11:05 ` Marc Zyngier
2026-03-23 12:33 ` Mostafa Saleh
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=20260321212419.2803972-3-maz@kernel.org \
--to=maz@kernel.org \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oupton@kernel.org \
--cc=qperret@google.com \
--cc=smostafa@google.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.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