[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk |
Date: |
Thu, 9 Nov 2023 16:59:18 +0300 |
From: Peter Maydell <peter.maydell@linaro.org>
In a two-stage translation, the result of the BTI guarded bit should
be the guarded bit from the first stage of translation, as there is
no BTI guard information in stage two. Our code tried to do this,
but got it wrong, because we currently have two fields where the GP
bit information might live (ARMCacheAttrs::guarded and
CPUTLBEntryFull::extra::arm::guarded), and we were storing the GP bit
in the latter during the stage 1 walk but trying to copy the former
in combine_cacheattrs().
Remove the duplicated storage, and always use the field in
CPUTLBEntryFull; correctly propagate the stage 1 value to the output
in get_phys_addr_twostage().
Note for stable backports: in v8.0 and earlier the field is named
result->f.guarded, not result->f.extra.arm.guarded.
Cc: qemu-stable@nongnu.org
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1950
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20231031173723.26582-1-peter.maydell@linaro.org
(cherry picked from commit 4c09abeae8704970ff03bf2196973f6bf08ab6f9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: replace f.extra.arm.guarded -> f.guarded due to v8.1.0-1179-ga81fef4b64)
diff --git a/target/arm/internals.h b/target/arm/internals.h
index 161e42d50f..3c7ff51c99 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1129,7 +1129,6 @@ typedef struct ARMCacheAttrs {
unsigned int attrs:8;
unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
bool is_s2_format:1;
- bool guarded:1; /* guarded bit of the v8-64 PTE */
} ARMCacheAttrs;
/* Fields that are valid upon success. */
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 97c85f3c95..be0cc3e347 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -2635,7 +2635,7 @@ static bool get_phys_addr_twostage(CPUARMState *env,
S1Translate *ptw,
hwaddr ipa;
int s1_prot, s1_lgpgsz;
bool is_secure = ptw->in_secure;
- bool ret, ipa_secure;
+ bool ret, ipa_secure, s1_guarded;
ARMCacheAttrs cacheattrs1;
bool is_el0;
uint64_t hcr;
@@ -2661,6 +2661,7 @@ static bool get_phys_addr_twostage(CPUARMState *env,
S1Translate *ptw,
*/
s1_prot = result->f.prot;
s1_lgpgsz = result->f.lg_page_size;
+ s1_guarded = result->f.guarded;
cacheattrs1 = result->cacheattrs;
memset(result, 0, sizeof(*result));
@@ -2701,6 +2702,9 @@ static bool get_phys_addr_twostage(CPUARMState *env,
S1Translate *ptw,
result->cacheattrs = combine_cacheattrs(hcr, cacheattrs1,
result->cacheattrs);
+ /* No BTI GP information in stage 2, we just use the S1 value */
+ result->f.guarded = s1_guarded;
+
/*
* Check if IPA translates to secure or non-secure PA space.
* Note that VSTCR overrides VTCR and {N}SW overrides {N}SA.
--
2.39.2
- [Stable-7.2.7 45/62] Revert "linux-user: add more compat ioctl definitions", (continued)
- [Stable-7.2.7 45/62] Revert "linux-user: add more compat ioctl definitions", Michael Tokarev, 2023/11/09
- [Stable-7.2.7 35/62] migration: Fix analyze-migration read operation signedness, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 41/62] tests/migration: Add -fno-stack-protector, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 40/62] misc/led: LED state is set opposite of what is expected, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 39/62] hw/sd/sdhci: Block Size Register bits [14:12] is lost, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 47/62] target/arm: Don't access TCG code when debugging with KVM, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 46/62] Revert "linux-user: fix compat with glibc >= 2.36 sys/mount.h", Michael Tokarev, 2023/11/09
- [Stable-7.2.7 52/62] ati-vga: Implement fallback for pixman routines, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 49/62] target/arm: Fix handling of SW and NSW bits for stage 2 walks, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 48/62] target/arm: Don't allow stage 2 page table walks to downgrade to NS, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 50/62] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk,
Michael Tokarev <=
- [Stable-7.2.7 53/62] ui/gtk: force realization of drawing area, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 55/62] ui/gtk-egl: Check EGLSurface before doing scanout, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 51/62] block/nvme: nvme_process_completion() fix bound for cid, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 56/62] target/mips: Fix MSA BZ/BNZ opcodes displacement, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 54/62] ui/gtk-egl: apply scale factor when calculating window's dimension, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 57/62] target/mips: Fix TX79 LQ/SQ opcodes, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 58/62] hw/ide: reset: cancel async DMA operation before resetting state, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 59/62] tests/qtest: ahci-test: add test exposing reset issue with pending callback, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 61/62] tests/tcg/s390x: Test LAALG with negative cc_src, Michael Tokarev, 2023/11/09
- [Stable-7.2.7 60/62] target/s390x: Fix LAALG not updating cc_src, Michael Tokarev, 2023/11/09