All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] plugins: Fix physical address calculation for IO regions
@ 2021-07-20 19:57 Aaron Lindsay
  2021-07-20 20:02 ` [PATCH-for-6.1?] " Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Aaron Lindsay @ 2021-07-20 19:57 UTC (permalink / raw)
  To: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée
  Cc: cota, richard.henderson, Paolo Bonzini, Peter Xu, Aaron Lindsay

The address calculation for IO regions introduced by

commit 787148bf928a54b5cc86f5b434f9399e9737679c
Author: Aaron Lindsay <aaron@os.amperecomputing.com>
    plugins: Expose physical addresses instead of device offsets

is not always accurate. Use the more correct
MemoryRegionSection.offset_within_address_space.
---
 plugins/api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/api.c b/plugins/api.c
index 5c1a413928..ba14e6f2b2 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -319,7 +319,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
             return block->offset + offset + block->mr->addr;
         } else {
             MemoryRegionSection *mrs = haddr->v.io.section;
-            return haddr->v.io.offset + mrs->mr->addr;
+            return mrs->offset_within_address_space + haddr->v.io.offset;
         }
     }
 #endif
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH-for-6.1?] plugins: Fix physical address calculation for IO regions
  2021-07-20 19:57 [PATCH] plugins: Fix physical address calculation for IO regions Aaron Lindsay
@ 2021-07-20 20:02 ` Philippe Mathieu-Daudé
  2021-07-20 20:04 ` [PATCH] " Aaron Lindsay
  2021-07-20 22:14 ` Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-07-20 20:02 UTC (permalink / raw)
  To: Aaron Lindsay, qemu-devel, Alex Bennée
  Cc: Paolo Bonzini, cota, richard.henderson, Peter Xu

On 7/20/21 9:57 PM, Aaron Lindsay wrote:
> The address calculation for IO regions introduced by
> 
> commit 787148bf928a54b5cc86f5b434f9399e9737679c
> Author: Aaron Lindsay <aaron@os.amperecomputing.com>
>     plugins: Expose physical addresses instead of device offsets
> 
> is not always accurate.

Indeed unlikely accurate in case of aliases (at least).

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> Use the more correct
> MemoryRegionSection.offset_within_address_space.
> ---
>  plugins/api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/plugins/api.c b/plugins/api.c
> index 5c1a413928..ba14e6f2b2 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -319,7 +319,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
>              return block->offset + offset + block->mr->addr;
>          } else {
>              MemoryRegionSection *mrs = haddr->v.io.section;
> -            return haddr->v.io.offset + mrs->mr->addr;
> +            return mrs->offset_within_address_space + haddr->v.io.offset;
>          }
>      }
>  #endif
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] plugins: Fix physical address calculation for IO regions
  2021-07-20 19:57 [PATCH] plugins: Fix physical address calculation for IO regions Aaron Lindsay
  2021-07-20 20:02 ` [PATCH-for-6.1?] " Philippe Mathieu-Daudé
@ 2021-07-20 20:04 ` Aaron Lindsay
  2021-07-20 22:14 ` Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Aaron Lindsay @ 2021-07-20 20:04 UTC (permalink / raw)
  To: qemu-devel, Philippe Mathieu-Daudé, Alex Bennée
  Cc: cota, richard.henderson, Paolo Bonzini, Peter Xu

For reference, this patch is intended to address this conversation:
https://lists.nongnu.org/archive/html/qemu-devel/2021-07/msg01293.html

This appears to be better than the previous version in my testing, but I
absolutely welcome being told there is a better way to solve this!

Thanks!

-Aaron

On Jul 20 15:57, Aaron Lindsay wrote:
> The address calculation for IO regions introduced by
> 
> commit 787148bf928a54b5cc86f5b434f9399e9737679c
> Author: Aaron Lindsay <aaron@os.amperecomputing.com>
>     plugins: Expose physical addresses instead of device offsets
> 
> is not always accurate. Use the more correct
> MemoryRegionSection.offset_within_address_space.

Whoops, forgot my:

Signed-off-by: Aaron Lindsay <aaron@os.amperecomputing.com>

> ---
>  plugins/api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/plugins/api.c b/plugins/api.c
> index 5c1a413928..ba14e6f2b2 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -319,7 +319,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
>              return block->offset + offset + block->mr->addr;
>          } else {
>              MemoryRegionSection *mrs = haddr->v.io.section;
> -            return haddr->v.io.offset + mrs->mr->addr;
> +            return mrs->offset_within_address_space + haddr->v.io.offset;
>          }
>      }
>  #endif
> -- 
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] plugins: Fix physical address calculation for IO regions
  2021-07-20 19:57 [PATCH] plugins: Fix physical address calculation for IO regions Aaron Lindsay
  2021-07-20 20:02 ` [PATCH-for-6.1?] " Philippe Mathieu-Daudé
  2021-07-20 20:04 ` [PATCH] " Aaron Lindsay
@ 2021-07-20 22:14 ` Alex Bennée
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2021-07-20 22:14 UTC (permalink / raw)
  To: Aaron Lindsay
  Cc: richard.henderson, qemu-devel, Peter Xu, cota, Paolo Bonzini,
	Philippe Mathieu-Daudé


Aaron Lindsay <aaron@os.amperecomputing.com> writes:

> The address calculation for IO regions introduced by
>
> commit 787148bf928a54b5cc86f5b434f9399e9737679c
> Author: Aaron Lindsay <aaron@os.amperecomputing.com>
>     plugins: Expose physical addresses instead of device offsets

Queued to for-6.1/fixes-for-rc1, thanks.

>
> is not always accurate. Use the more correct
> MemoryRegionSection.offset_within_address_space.
> ---
>  plugins/api.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/plugins/api.c b/plugins/api.c
> index 5c1a413928..ba14e6f2b2 100644
> --- a/plugins/api.c
> +++ b/plugins/api.c
> @@ -319,7 +319,7 @@ uint64_t qemu_plugin_hwaddr_phys_addr(const struct qemu_plugin_hwaddr *haddr)
>              return block->offset + offset + block->mr->addr;
>          } else {
>              MemoryRegionSection *mrs = haddr->v.io.section;
> -            return haddr->v.io.offset + mrs->mr->addr;
> +            return mrs->offset_within_address_space + haddr->v.io.offset;
>          }
>      }
>  #endif


-- 
Alex Bennée


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-20 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 19:57 [PATCH] plugins: Fix physical address calculation for IO regions Aaron Lindsay
2021-07-20 20:02 ` [PATCH-for-6.1?] " Philippe Mathieu-Daudé
2021-07-20 20:04 ` [PATCH] " Aaron Lindsay
2021-07-20 22:14 ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.