]> git.hungrycats.org Git - linux/commitdiff
arm64: KVM: Preserve RES1 bits in SCTLR_EL2
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 6 Jun 2017 18:08:33 +0000 (19:08 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 15 Sep 2017 17:30:04 +0000 (18:30 +0100)
commit d68c1f7fd1b7148dab5fe658321d511998969f2d upstream.

__do_hyp_init has the rather bad habit of ignoring RES1 bits and
writing them back as zero. On a v8.0-8.2 CPU, this doesn't do anything
bad, but may end-up being pretty nasty on future revisions of the
architecture.

Let's preserve those bits so that we don't have to fix this later on.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
[bwh: Backported to 3.16:
 - s/ELx/EL2/
 - Adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/arm64/include/asm/kvm_arm.h
arch/arm64/kvm/hyp-init.S

index c33a96bac82426ded0125ae30c2f2fab7775ee93..243bd77558c311d2e0b44629bdff88fa3df3a7c0 100644 (file)
 #define SCTLR_EL2_C    (1 << 2)
 #define SCTLR_EL2_A    (1 << 1)
 #define SCTLR_EL2_M    1
+
+#define SCTLR_EL2_RES1 ((1 << 4)  | (1 << 5)  | (1 << 11) | (1 << 16) | \
+                        (1 << 16) | (1 << 18) | (1 << 22) | (1 << 23) | \
+                        (1 << 28) | (1 << 29))
+
 #define SCTLR_EL2_FLAGS        (SCTLR_EL2_M | SCTLR_EL2_A | SCTLR_EL2_C |      \
                         SCTLR_EL2_SA | SCTLR_EL2_I)
 
index c3191168a994fba06b6f5ddc807dbc8eceec224b..a409482fc19b551fa42dc83ad78a12ec56f7dc39 100644 (file)
@@ -84,10 +84,12 @@ __do_hyp_init:
        tlbi    alle2
        dsb     sy
 
-       mrs     x4, sctlr_el2
-       and     x4, x4, #SCTLR_EL2_EE   // preserve endianness of EL2
-       ldr     x5, =SCTLR_EL2_FLAGS
-       orr     x4, x4, x5
+       /*
+        * Preserve all the RES1 bits while setting the default flags,
+        * as well as the EE bit on BE.
+        */
+       ldr     x4, =(SCTLR_EL2_RES1 | SCTLR_EL2_FLAGS)
+CPU_BE(        orr     x4, x4, #SCTLR_EL2_EE)
        msr     sctlr_el2, x4
        isb