[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.1.3 26/55] target/arm: Correctly propagate stage 1 BTI guarded
From: |
Michael Tokarev |
Subject: |
[Stable-8.1.3 26/55] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk |
Date: |
Thu, 9 Nov 2023 16:42:30 +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 0f01bc32a8..784f1e0fab 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1180,7 +1180,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 8f94100c61..3195d5d401 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -2979,7 +2979,6 @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr,
assert(!s1.is_s2_format);
ret.is_s2_format = false;
- ret.guarded = s1.guarded;
if (s1.attrs == 0xf0) {
tagged = true;
@@ -3119,7 +3118,7 @@ static bool get_phys_addr_twostage(CPUARMState *env,
S1Translate *ptw,
int s1_prot, s1_lgpgsz;
bool is_secure = ptw->in_secure;
ARMSecuritySpace in_space = ptw->in_space;
- bool ret, ipa_secure;
+ bool ret, ipa_secure, s1_guarded;
ARMCacheAttrs cacheattrs1;
ARMSecuritySpace ipa_space;
uint64_t hcr;
@@ -3147,6 +3146,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));
@@ -3197,6 +3197,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-8.1.3 16/55] hw/sd/sdhci: Block Size Register bits [14:12] is lost, (continued)
- [Stable-8.1.3 16/55] hw/sd/sdhci: Block Size Register bits [14:12] is lost, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 21/55] block: Fix locking in media change monitor commands, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 20/55] misc/led: LED state is set opposite of what is expected, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 17/55] hw/rdma/vmw/pvrdma_cmd: Use correct struct in query_port(), Michael Tokarev, 2023/11/09
- [Stable-8.1.3 19/55] target/arm: Fix syndrome for FGT traps on ERET, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 18/55] target/sparc: Clear may_lookup for npc == DYNAMIC_PC, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 25/55] target/arm: Fix SVE STR increment, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 22/55] tests/tcg: Add -fno-stack-protector, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 23/55] qemu-img: rebase: stop when reaching EOF of old backing file, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 24/55] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 26/55] target/arm: Correctly propagate stage 1 BTI guarded bit in a two-stage walk,
Michael Tokarev <=
- [Stable-8.1.3 28/55] vfio/pci: Fix buffer overrun when writing the VF token, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 27/55] util/uuid: Add UUID_STR_LEN definition, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 29/55] util/uuid: Remove UUID_FMT_LEN, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 30/55] i386/xen: Don't advertise XENFEAT_supervisor_mode_kernel, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 35/55] hw/xen: take iothread mutex in xen_evtchn_reset_op(), Michael Tokarev, 2023/11/09
- [Stable-8.1.3 32/55] hw/xen: select kernel mode for per-vCPU event channel upcall vector, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 31/55] i386/xen: fix per-vCPU upcall vector for Xen emulation, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 33/55] hw/xen: don't clear map_track[] in xen_gnttab_reset(), Michael Tokarev, 2023/11/09
- [Stable-8.1.3 34/55] hw/xen: fix XenStore watch delivery to guest, Michael Tokarev, 2023/11/09
- [Stable-8.1.3 39/55] target/arm: Fix A64 LDRA immediate decode, Michael Tokarev, 2023/11/09