]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/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)
committerChristoffer Dall <cdall@linaro.org>
Tue, 6 Jun 2017 20:20:02 +0000 (22:20 +0200)
__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.

Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
arch/arm64/include/asm/sysreg.h
arch/arm64/kvm/hyp-init.S

index 15c142ce991cd9180172f0ecb8ddf399e8e31c60..b4d13d9267ff8b56c95aa981928bb3b7ed950a88 100644 (file)
 #define SCTLR_ELx_A    (1 << 1)
 #define SCTLR_ELx_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_ELx_FLAGS        (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \
                         SCTLR_ELx_SA | SCTLR_ELx_I)
 
index 839425c24b1c7078c7397470aa811286eb119f49..4072d408a4b49f8d78677ca941553d5f73a5ff3d 100644 (file)
@@ -106,10 +106,12 @@ __do_hyp_init:
        tlbi    alle2
        dsb     sy
 
-       mrs     x4, sctlr_el2
-       and     x4, x4, #SCTLR_ELx_EE   // preserve endianness of EL2
-       ldr     x5, =SCTLR_ELx_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_ELx_FLAGS)
+CPU_BE(        orr     x4, x4, #SCTLR_ELx_EE)
        msr     sctlr_el2, x4
        isb