]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: Remove extra ISBs when using msr_hcr_el2
authorMarc Zyngier <maz@kernel.org>
Sat, 21 Mar 2026 21:24:19 +0000 (21:24 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 23 Mar 2026 11:03:53 +0000 (11:03 +0000)
The msr_hcr_el2 macro is slightly awkward, as it provides an ISB
when CONFIG_AMPERE_ERRATUM_AC04_CPU_23 is present, and none
otherwise. Note that this this option is 'default y', meaning that
it is likely to be selected.

Most instances of msr_hcr_el2 are also immediately followed by an ISB,
meaning that in most cases, you end-up with two back-to-back ISBs.
This isn't a big deal, but once you have seen that, you can't unsee it.

Rework the msr_hcr_el2 macro to always provide the ISB, and drop
the superfluous ISBs everywhere else.

Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260321212419.2803972-6-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/el2_setup.h
arch/arm64/include/asm/sysreg.h
arch/arm64/kernel/hyp-stub.S
arch/arm64/kvm/hyp/nvhe/host.S

index 85f4c1615472d74b24df9c13dad2d338e235250e..3e58d6264581ee0005ace5dc2d6404627ae4d1a4 100644 (file)
@@ -50,7 +50,6 @@
         * effectively VHE-only or not.
         */
        msr_hcr_el2 x0          // Setup HCR_EL2 as nVHE
-       isb
        mov     x1, #1          // Write something to FAR_EL1
        msr     far_el1, x1
        isb
@@ -64,7 +63,6 @@
 .LnE2H0_\@:
        orr     x0, x0, #HCR_E2H
        msr_hcr_el2 x0
-       isb
 .LnVHE_\@:
 .endm
 
index f4436ecc630cd6b481f2123fbd901fdc8dc2da70..ca66b8017fa87e7fe60df8e825b696c3ec4e5d09 100644 (file)
        .macro  msr_hcr_el2, reg
 #if IS_ENABLED(CONFIG_AMPERE_ERRATUM_AC04_CPU_23)
        dsb     nsh
-       msr     hcr_el2, \reg
-       isb
-#else
-       msr     hcr_el2, \reg
 #endif
+       msr     hcr_el2, \reg
+       isb                     // Required by AMPERE_ERRATUM_AC04_CPU_23
        .endm
 #else
 
index 085bc9972f6bb8c5f569975c98c783b9329f9649..634ddc9042444f263fe2bc774238ffbac10e50ef 100644 (file)
@@ -103,7 +103,6 @@ SYM_CODE_START_LOCAL(__finalise_el2)
        // Engage the VHE magic!
        mov_q   x0, HCR_HOST_VHE_FLAGS
        msr_hcr_el2 x0
-       isb
 
        // Use the EL1 allocated stack, per-cpu offset
        mrs     x0, sp_el1
index 465f6f1dd6414897517c8691821637dcf5f083f3..ff10cafa0ca8158b1cd7fe700b71f58ab4871b7f 100644 (file)
@@ -125,7 +125,6 @@ SYM_FUNC_START(__hyp_do_panic)
        mrs     x0, hcr_el2
        bic     x0, x0, #HCR_VM
        msr_hcr_el2 x0
-       isb
        tlbi    vmalls12e1
        dsb     nsh
 #endif