[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.0.4 07/57] target/arm: Avoid target_ulong for physical address
From: |
Michael Tokarev |
Subject: |
[Stable-9.0.4 07/57] target/arm: Avoid target_ulong for physical address lookups |
Date: |
Sat, 9 Nov 2024 15:07:09 +0300 |
From: Ard Biesheuvel <ardb@kernel.org>
target_ulong is typedef'ed as a 32-bit integer when building the
qemu-system-arm target, and this is smaller than the size of an
intermediate physical address when LPAE is being used.
Given that Linux may place leaf level user page tables in high memory
when built for LPAE, the kernel will crash with an external abort as
soon as it enters user space when running with more than ~3 GiB of
system RAM.
So replace target_ulong with vaddr in places where it may carry an
address value that is not representable in 32 bits.
Fixes: f3639a64f602ea ("target/arm: Use softmmu tlbs for page table walking")
Cc: qemu-stable@nongnu.org
Reported-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Message-id: 20240927071051.1444768-1-ardb+git@google.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit 67d762e716a7127ecc114e9708254316dd521911)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/arm/internals.h b/target/arm/internals.h
index 810b85a409..315591ae79 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1392,7 +1392,7 @@ typedef struct GetPhysAddrResult {
* * for PSMAv5 based systems we don't bother to return a full FSR format
* value.
*/
-bool get_phys_addr(CPUARMState *env, target_ulong address,
+bool get_phys_addr(CPUARMState *env, vaddr address,
MMUAccessType access_type, ARMMMUIdx mmu_idx,
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
__attribute__((nonnull));
@@ -1411,7 +1411,7 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
* Similar to get_phys_addr, but use the given security space and don't perform
* a Granule Protection Check on the resulting address.
*/
-bool get_phys_addr_with_space_nogpc(CPUARMState *env, target_ulong address,
+bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address,
MMUAccessType access_type,
ARMMMUIdx mmu_idx, ARMSecuritySpace space,
GetPhysAddrResult *result,
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index 2cb0e981a5..c0056a6f2d 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -73,13 +73,13 @@ typedef struct S1Translate {
} S1Translate;
static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi);
static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi);
@@ -3201,7 +3201,7 @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr,
*/
static bool get_phys_addr_disabled(CPUARMState *env,
S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi)
@@ -3284,7 +3284,7 @@ static bool get_phys_addr_disabled(CPUARMState *env,
}
static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi)
@@ -3389,7 +3389,7 @@ static bool get_phys_addr_twostage(CPUARMState *env,
S1Translate *ptw,
}
static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi)
@@ -3526,7 +3526,7 @@ static bool get_phys_addr_nogpc(CPUARMState *env,
S1Translate *ptw,
}
static bool get_phys_addr_gpc(CPUARMState *env, S1Translate *ptw,
- target_ulong address,
+ vaddr address,
MMUAccessType access_type,
GetPhysAddrResult *result,
ARMMMUFaultInfo *fi)
@@ -3542,7 +3542,7 @@ static bool get_phys_addr_gpc(CPUARMState *env,
S1Translate *ptw,
return false;
}
-bool get_phys_addr_with_space_nogpc(CPUARMState *env, target_ulong address,
+bool get_phys_addr_with_space_nogpc(CPUARMState *env, vaddr address,
MMUAccessType access_type,
ARMMMUIdx mmu_idx, ARMSecuritySpace space,
GetPhysAddrResult *result,
@@ -3555,7 +3555,7 @@ bool get_phys_addr_with_space_nogpc(CPUARMState *env,
target_ulong address,
return get_phys_addr_nogpc(env, &ptw, address, access_type, result, fi);
}
-bool get_phys_addr(CPUARMState *env, target_ulong address,
+bool get_phys_addr(CPUARMState *env, vaddr address,
MMUAccessType access_type, ARMMMUIdx mmu_idx,
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
{
--
2.39.5
- [Stable-9.0.4 v1 00/57] Patch Round-up for stable 9.0.4, freeze on 2024-11-18, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 01/57] softmmu/physmem.c: Keep transaction attribute in address_space_map(), Michael Tokarev, 2024/11/09
- [Stable-9.0.4 02/57] target/arm: Correct ID_AA64ISAR1_EL1 value for neoverse-v1, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 03/57] tcg: Fix iteration step in 32-bit gvec operation, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 04/57] target/ppc: Fix lxvx/stxvx facility check, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 05/57] hw/mips/jazz: fix typo in in-built NIC alias, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 06/57] block/reqlist: allow adding overlapping requests, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 07/57] target/arm: Avoid target_ulong for physical address lookups,
Michael Tokarev <=
- [Stable-9.0.4 08/57] fuzz: disable leak-detection for oss-fuzz builds, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 09/57] testing: bump mips64el cross to bookworm and fix package list, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 10/57] vnc: fix crash when no console attached, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 11/57] linux-user/flatload: Take mmap_lock in load_flt_binary(), Michael Tokarev, 2024/11/09
- [Stable-9.0.4 13/57] tcg/ppc: Use TCG_REG_TMP2 for scratch tcg_out_qemu_st, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 12/57] linux-user: Fix parse_elf_properties GNU0_MAGIC check, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 15/57] target/m68k: Always return a temporary from gen_lea_mode, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 14/57] tcg/ppc: Use TCG_REG_TMP2 for scratch index in prepare_host_addr, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 16/57] hw/intc/arm_gicv3_cpuif: Add cast to match the documentation, Michael Tokarev, 2024/11/09
- [Stable-9.0.4 17/57] hw/audio/hda: free timer on exit, Michael Tokarev, 2024/11/09