Skip to contentSkip to conversation

Memory API fixes

PATCH In review Paolo Bonzini 4 participants 8 messages Jul 16, 2013 – Jul 29, 2013

lore
Share & tools
lore
#0 lore raw

cover Memory API fixes

Three fixes from Peter, Jan and me. I'm still recovering from the email backlog, hence I don't trust myself sending a pull request... In any case, they are available also from

git://github.com/bonzini/qemu.git iommu-from-anthony

Paolo

Jan Kiszka (1):
memory: Return -1 again on reads from unsigned regions

Paolo Bonzini (1):
memory: actually set the owner

Peter Maydell (1):
exec.c: Pass correct pointer type to qemu_ram_ptr_length

 exec.c   | 2 +-
 memory.c | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 1/3 exec.c: Pass correct pointer type to qemu_ram_ptr_length

From: Peter Maydell <[email protected]>

Commit e3127ae0 introduced a problem where we're passing a hwaddr* to qemu_ram_ptr_length() but it wants a ram_addr_t*; this will cause problems on 32 bit hosts and in any case provokes a clang warning on MacOSX:

CC arm-softmmu/exec.o
exec.c:2164:46: warning: incompatible pointer types passing 'hwaddr *' (aka 'unsigned long long *') to parameter of type 'ram_addr_t *' (aka 'unsigned long *')
[-Wincompatible-pointer-types]

    return qemu_ram_ptr_length(raddr + base, plen);
                                             ^~~~
exec.c:1392:63: note: passing argument to parameter 'size' here
static void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size)
                                                              ^

Since this function is only used in one place, change its prototype to pass a hwaddr* rather than a ram_addr_t*, rather than contorting the calling code to get the type right.

---
 exec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
exec.c +1 -1
index 80ee2ab..ffd611a 100644
@@ -1379,7 +1379,7 @@ static void *qemu_safe_ram_ptr(ram_addr_t addr)
 
 /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr
  * but takes a size argument */
-static void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size)
+static void *qemu_ram_ptr_length(ram_addr_t addr, hwaddr *size)
 {
     if (*size == 0) {
         return NULL;
Signature · 1 line
1.8.1.4
#2 lore raw

PATCH 2/3 memory: actually set the owner

In reply to Paolo Bonzini

Brown paper bag for me. Commit 2c9b15c added a line setting mr->owner, but there was already one that initialized it to NULL (added in the earlier commit 803c0816).

---
 memory.c | 1 -
 1 file changed, 1 deletion(-)
memory.c +0 -1
index c8f9a2b..9938b6b 100644
@@ -805,7 +805,6 @@ void memory_region_init(MemoryRegion *mr,
     mr->owner = owner;
     mr->iommu_ops = NULL;
     mr->parent = NULL;
-    mr->owner = NULL;
     mr->size = int128_make64(size);
     if (size == UINT64_MAX) {
         mr->size = int128_2_64();
Signature · 1 line
1.8.1.4
Reviewed-by on v1 2/3
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] memory: actually set the owner

Quoted 3 lines · Paolo Bonzini

Brown paper bag for me. Commit 2c9b15c added a line setting mr->owner, but there was already one that initialized it to NULL (added in the earlier commit 803c0816).

What I read from log is the reverse, Commit 2c9b15c added a line setting mr->owner, which was correct, but 803c0816 accidentally set it to NULL later.

Quoted 23 lines
---
 memory.c | 1 -
 1 file changed, 1 deletion(-)
memory.c +0 -1
index c8f9a2b..9938b6b 100644
@@ -805,7 +805,6 @@ void memory_region_init(MemoryRegion *mr,
     mr->owner = owner;
     mr->iommu_ops = NULL;
     mr->parent = NULL;
-    mr->owner = NULL;
     mr->size = int128_make64(size);
     if (size == UINT64_MAX) {
         mr->size = int128_2_64();
Signature · 1 line
1.8.1.4
#4 lore raw

PATCH 3/3 memory: Return -1 again on reads from unsigned regions

In reply to Paolo Bonzini

From: Jan Kiszka <[email protected]>

This restore the behavior prior to b018ddf633 which accidentally changed the return code to 0. Specifically guests probing for register existence were affected by this.

---
 memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
memory.c +1 -1
index 9938b6b..34a088e 100644
@@ -840,7 +840,7 @@ static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
     if (current_cpu != NULL) {
         cpu_unassigned_access(current_cpu, addr, false, false, 0, size);
     }
-    return 0;
+    return -1ULL;
 }
 
 static void unassigned_mem_write(void *opaque, hwaddr addr,
Signature · 1 line
1.8.1.4
#5 lore raw

Re: [Qemu-devel] [PATCH 3/3] memory: Return -1 again on reads from unsigned regions

Am 16.07.2013 17:31, schrieb Paolo Bonzini:

Quoted 8 lines

From: Jan Kiszka <[email protected]>

This restore the behavior prior to b018ddf633 which accidentally changed the return code to 0. Specifically guests probing for register existence were affected by this.

Unfortunately this negatively affects PReP: OpenHack'Ware booting Debian Etch prints:

ERROR: WIN_READ_NATIVE_MAX : status 50 != 0x40

It does continue if one is patient enough.
No problems before this commit.

Any ideas, except that OHW may be doing Bad Things?

Andreas

Quoted 18 lines
---
 memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
memory.c +1 -1
index 9938b6b..34a088e 100644
@@ -840,7 +840,7 @@ static uint64_t unassigned_mem_read(void *opaque, hwaddr addr,
     if (current_cpu != NULL) {
         cpu_unassigned_access(current_cpu, addr, false, false, 0, size);
     }
-    return 0;
+    return -1ULL;
 }
 
 static void unassigned_mem_write(void *opaque, hwaddr addr,
#6 lore raw

Re: [Qemu-devel] [PATCH 3/3] memory: Return -1 again on reads from unsigned regions

Quoted 13 lines · Andreas Färber

Am 16.07.2013 17:31, schrieb Paolo Bonzini:

Quoted 8 lines

From: Jan Kiszka <[email protected]>

This restore the behavior prior to b018ddf633 which accidentally changed the return code to 0. Specifically guests probing for register existence were affected by this.

Unfortunately this negatively affects PReP: OpenHack'Ware booting Debian Etch prints:

Quoted 6 lines

ERROR: WIN_READ_NATIVE_MAX : status 50 != 0x40

It does continue if one is patient enough.
No problems before this commit.

Any ideas, except that OHW may be doing Bad Things?

Which accesses return different results now, PIO or MMIO? What did they return prior to b018ddf633?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
#7 lore raw

Re: [Qemu-devel] [PATCH 3/3] memory: Return -1 again on reads from unsigned regions

Am 29.07.2013 17:01, schrieb Jan Kiszka:

Quoted 16 lines · Andreas Färber
Quoted 15 lines

Am 16.07.2013 17:31, schrieb Paolo Bonzini:

Quoted 8 lines

From: Jan Kiszka <[email protected]>

This restore the behavior prior to b018ddf633 which accidentally changed the return code to 0. Specifically guests probing for register existence were affected by this.

Unfortunately this negatively affects PReP: OpenHack'Ware booting Debian Etch prints:

ERROR: WIN_READ_NATIVE_MAX : status 50 != 0x40

Quoted 7 lines
Quoted 4 lines

It does continue if one is patient enough.
No problems before this commit.

Any ideas, except that OHW may be doing Bad Things?

Which accesses return different results now, PIO or MMIO? What did they return prior to b018ddf633?

Would I have to locally apply Paolo's MMIO tracing patches to find out? My guess is as good as yours otherwise... ;)

Andreas