Skip to contentSkip to conversation

target/sparc: Stop using the legacy ldst_phys() API

PATCH In review Philippe Mathieu-Daudé 2 participants 6 messages Feb 4 – Feb 6

lore
Share & tools
lore
#0 lore raw

cover target/sparc: Stop using the legacy ldst_phys() API

Remove the last ldst_phys() API call on SPARC.

Philippe Mathieu-Daudé (2):
target/sparc: Replace legacy st_phys() -> address_space_st() configs/targets: Restrict legacy ldst_phys() API on 32-bit SPARC
target

 configs/targets/sparc-softmmu.mak | 1 +
 target/sparc/mmu_helper.c         | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 target/sparc: Replace legacy st_phys() -> address_space_st()

Prefer the address_space_ld/st API over the legacy ld_phys() because it allow checking for bus access fault.

get_physical_address() already accessed the PTE stored at %pde_ptr and is going to update it. Assume the address space is also writeable there. The SPARC v8 manual only mentions faults (with error condition bits updated) in the READ path but not on the WRITE (update) one.

---
 target/sparc/mmu_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
target/sparc/mmu_helper.c +3 -1
index 5a58239d65e..a6f76a1ab76 100644
@@ -190,7 +190,9 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,
         if (is_dirty) {
             pde |= PG_MODIFIED_MASK;
         }
-        stl_be_phys(cs->as, pde_ptr, pde);
+        address_space_stl_be(cs->as, pde_ptr, pde,
+                             MEMTXATTRS_UNSPECIFIED, &result);
+        assert(result == MEMTX_OK);
     }
 
     /* the page can be put in the TLB */
Signature · 1 line
2.52.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] target/sparc: Replace legacy st_phys() -> address_space_st()

Quoted 19 lines · Philippe Mathieu-Daudé

Prefer the address_space_ld/st API over the legacy ld_phys() because it allow checking for bus access fault.

get_physical_address() already accessed the PTE stored at %pde_ptr and is going to update it. Assume the address space is also writeable there. The SPARC v8 manual only mentions faults (with error condition bits updated) in the READ path but not on the WRITE (update) one.

---
  target/sparc/mmu_helper.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
target/sparc/mmu_helper.c +0 -0
index 5a58239d65e..a6f76a1ab76 100644

target/sparc/mmu_helper.c static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full, · line 198

Quoted 10 lines
target/sparc/mmu_helper.c +3 -1
@@ -190,7 +190,9 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,
          if (is_dirty) {
              pde |= PG_MODIFIED_MASK;
          }
-        stl_be_phys(cs->as, pde_ptr, pde);
+        address_space_stl_be(cs->as, pde_ptr, pde,
+                             MEMTXATTRS_UNSPECIFIED, &result);
+        assert(result == MEMTX_OK);
      }
 
      /* the page can be put in the TLB */

r~

#3 lore raw

PATCH 2/2 configs/targets: Restrict legacy ldst_phys() API on 32-bit SPARC target

In reply to Philippe Mathieu-Daudé

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 the qemu-system-sparc binary, avoiding further API uses to creep in.

---
 configs/targets/sparc-softmmu.mak | 1 +
 1 file changed, 1 insertion(+)
configs/targets/sparc-softmmu.mak +1 -0
index 272fd46f6db..c4c38946d54 100644
@@ -1,4 +1,5 @@
 TARGET_ARCH=sparc
 TARGET_BIG_ENDIAN=y
 TARGET_LONG_BITS=32
+TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
Signature · 1 line
2.52.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] configs/targets: Restrict legacy ldst_phys() API on 32-bit SPARC target

Quoted 15 lines · Philippe Mathieu-Daudé

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 the qemu-system-sparc binary, avoiding further API uses to creep in.

---
  configs/targets/sparc-softmmu.mak | 1 +
  1 file changed, 1 insertion(+)
configs/targets/sparc-softmmu.mak +0 -0
index 272fd46f6db..c4c38946d54 100644

configs/targets/sparc-softmmu.mak line 5

Quoted 5 lines
configs/targets/sparc-softmmu.mak +1 -0
@@ -1,4 +1,5 @@
  TARGET_ARCH=sparc
  TARGET_BIG_ENDIAN=y
  TARGET_LONG_BITS=32
+TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y
  TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y

r~