Skip to contentSkip to conversation

hw/hyperv: Replace legacy ld_phys() -> address_space_ld()

PATCH In review Philippe Mathieu-Daudé 2 participants 3 messages Mar 19 – Apr 1

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/hyperv: Replace legacy ld_phys() -> address_space_ld()

Prefer the address_space_ld/st API over the legacy ld/st_phys() because it allow checking for bus access fault, which shouldn't happen here.

---
 hw/hyperv/hyperv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/hyperv/hyperv.c +4 -1
index 27e323a8196..5a0e00892d8 100644
@@ -704,13 +704,16 @@ uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast)
     EventFlagHandler *handler;
 
     if (unlikely(!fast)) {
+        MemTxResult result;
         hwaddr addr = param;
 
         if (addr & (__alignof__(addr) - 1)) {
             return HV_STATUS_INVALID_ALIGNMENT;
         }
 
-        param = ldq_phys(&address_space_memory, addr);
+        param = address_space_ldq_le(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &result);
+        assert(result == MEMTX_OK);
     }
 
     /*
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 21 lines · Philippe Mathieu-Daudé

Prefer the address_space_ld/st API over the legacy ld/st_phys() because it allow checking for bus access fault, which shouldn't happen here.

---
  hw/hyperv/hyperv.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
hw/hyperv/hyperv.c +1 -0
index 27e323a8196..5a0e00892d8 100644
@@ -704,13 +704,16 @@ uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast)
      EventFlagHandler *handler;
 
      if (unlikely(!fast)) {
+        MemTxResult result;
          hwaddr addr = param;
 
          if (addr & (__alignof__(addr) - 1)) {

hw/hyperv/hyperv.c uint16_t hyperv_hcall_signal_event(uint64_t param, bool fast) · line 719

Quoted 10 lines
hw/hyperv/hyperv.c +3 -1
              return HV_STATUS_INVALID_ALIGNMENT;
          }
 
-        param = ldq_phys(&address_space_memory, addr);
+        param = address_space_ldq_le(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &result);
+        assert(result == MEMTX_OK);
      }
 
      /*

Thanks,
Maciej