mirror of
https://github.com/qemu/qemu.git
synced 2026-02-04 02:24:51 +00:00
target/alpha: Replace legacy ld_phys() -> address_space_ld()
Prefer the address_space_ld/st API over the legacy ld_phys() because it allow checking for bus access fault. Since we removed the last legacy uses of the legacy ldst_phys() API, set the TARGET_NOT_USING_LEGACY_LDST_PHYS_API variable to hide the legacy API to alpha binaries, avoiding further API uses to creep in. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20251224160040.88612-7-philmd@linaro.org>
This commit is contained in:
@@ -4,3 +4,4 @@ TARGET_SYSTBL=syscall.tbl
|
|||||||
TARGET_LONG_BITS=64
|
TARGET_LONG_BITS=64
|
||||||
TARGET_XML_FILES= gdb-xml/alpha-core.xml
|
TARGET_XML_FILES= gdb-xml/alpha-core.xml
|
||||||
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
|
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
|
||||||
|
TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ TARGET_ARCH=alpha
|
|||||||
TARGET_LONG_BITS=64
|
TARGET_LONG_BITS=64
|
||||||
TARGET_XML_FILES= gdb-xml/alpha-core.xml
|
TARGET_XML_FILES= gdb-xml/alpha-core.xml
|
||||||
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
|
TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
|
||||||
|
TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
|
|||||||
int prot_need, int mmu_idx,
|
int prot_need, int mmu_idx,
|
||||||
target_ulong *pphys, int *pprot)
|
target_ulong *pphys, int *pprot)
|
||||||
{
|
{
|
||||||
|
const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED;
|
||||||
CPUState *cs = env_cpu(env);
|
CPUState *cs = env_cpu(env);
|
||||||
target_long saddr = addr;
|
target_long saddr = addr;
|
||||||
target_ulong phys = 0;
|
target_ulong phys = 0;
|
||||||
@@ -176,6 +177,7 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
|
|||||||
target_ulong pt, index;
|
target_ulong pt, index;
|
||||||
int prot = 0;
|
int prot = 0;
|
||||||
int ret = MM_K_ACV;
|
int ret = MM_K_ACV;
|
||||||
|
MemTxResult txres;
|
||||||
|
|
||||||
/* Handle physical accesses. */
|
/* Handle physical accesses. */
|
||||||
if (mmu_idx == MMU_PHYS_IDX) {
|
if (mmu_idx == MMU_PHYS_IDX) {
|
||||||
@@ -214,18 +216,13 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
|
|||||||
|
|
||||||
pt = env->ptbr;
|
pt = env->ptbr;
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: rather than using ldq_phys_le() to read the page table we should
|
|
||||||
* use address_space_ldq() so that we can handle the case when
|
|
||||||
* the page table read gives a bus fault, rather than ignoring it.
|
|
||||||
* For the existing code the zero data that ldq_phys_le will return for
|
|
||||||
* an access to invalid memory will result in our treating the page
|
|
||||||
* table as invalid, which may even be the right behaviour.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* L1 page table read. */
|
/* L1 page table read. */
|
||||||
index = (addr >> (TARGET_PAGE_BITS + 20)) & 0x3ff;
|
index = (addr >> (TARGET_PAGE_BITS + 20)) & 0x3ff;
|
||||||
L1pte = ldq_phys_le(cs->as, pt + index * 8);
|
L1pte = address_space_ldq_le(cs->as, pt + index * 8, attrs, &txres);
|
||||||
|
if (txres != MEMTX_OK) {
|
||||||
|
/* bus fault */
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely((L1pte & PTE_VALID) == 0)) {
|
if (unlikely((L1pte & PTE_VALID) == 0)) {
|
||||||
ret = MM_K_TNV;
|
ret = MM_K_TNV;
|
||||||
@@ -238,7 +235,11 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
|
|||||||
|
|
||||||
/* L2 page table read. */
|
/* L2 page table read. */
|
||||||
index = (addr >> (TARGET_PAGE_BITS + 10)) & 0x3ff;
|
index = (addr >> (TARGET_PAGE_BITS + 10)) & 0x3ff;
|
||||||
L2pte = ldq_phys_le(cs->as, pt + index * 8);
|
L2pte = address_space_ldq_le(cs->as, pt + index * 8, attrs, &txres);
|
||||||
|
if (txres != MEMTX_OK) {
|
||||||
|
/* bus fault */
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (unlikely((L2pte & PTE_VALID) == 0)) {
|
if (unlikely((L2pte & PTE_VALID) == 0)) {
|
||||||
ret = MM_K_TNV;
|
ret = MM_K_TNV;
|
||||||
@@ -251,7 +252,11 @@ static int get_physical_address(CPUAlphaState *env, target_ulong addr,
|
|||||||
|
|
||||||
/* L3 page table read. */
|
/* L3 page table read. */
|
||||||
index = (addr >> TARGET_PAGE_BITS) & 0x3ff;
|
index = (addr >> TARGET_PAGE_BITS) & 0x3ff;
|
||||||
L3pte = ldq_phys_le(cs->as, pt + index * 8);
|
L3pte = address_space_ldq_le(cs->as, pt + index * 8, attrs, &txres);
|
||||||
|
if (txres != MEMTX_OK) {
|
||||||
|
/* bus fault */
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
phys = L3pte >> 32 << TARGET_PAGE_BITS;
|
phys = L3pte >> 32 << TARGET_PAGE_BITS;
|
||||||
if (unlikely((L3pte & PTE_VALID) == 0)) {
|
if (unlikely((L3pte & PTE_VALID) == 0)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user