* [PATCH v2] system/memory: use ldn_he_p/stn_he_p
@ 2023-11-16 16:36 Patrick Venture
2023-11-17 8:18 ` Philippe Mathieu-Daudé
2023-11-17 8:43 ` David Hildenbrand
0 siblings, 2 replies; 6+ messages in thread
From: Patrick Venture @ 2023-11-16 16:36 UTC (permalink / raw)
To: pbonzini, peterx, david, philmd, peter.maydell, richard.henderson
Cc: qemu-devel, qemu-stable, Patrick Venture, Chris Rauer,
Peter Foley
Using direct pointer dereferencing can allow for unaligned accesses,
which was seen during execution with sanitizers enabled.
Reviewed-by: Chris Rauer <crauer@google.com>
Reviewed-by: Peter Foley <pefoley@google.com>
Signed-off-by: Patrick Venture <venture@google.com>
Cc: qemu-stable@nongnu.org
---
v2: changed commit mesage to be more accurate and switched from using
memcpy to using the endian appropriate assignment load and store.
---
system/memory.c | 32 ++------------------------------
1 file changed, 2 insertions(+), 30 deletions(-)
diff --git a/system/memory.c b/system/memory.c
index 304fa843ea..affc7ea83c 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1339,22 +1339,7 @@ static uint64_t memory_region_ram_device_read(void *opaque,
hwaddr addr, unsigned size)
{
MemoryRegion *mr = opaque;
- uint64_t data = (uint64_t)~0;
-
- switch (size) {
- case 1:
- data = *(uint8_t *)(mr->ram_block->host + addr);
- break;
- case 2:
- data = *(uint16_t *)(mr->ram_block->host + addr);
- break;
- case 4:
- data = *(uint32_t *)(mr->ram_block->host + addr);
- break;
- case 8:
- data = *(uint64_t *)(mr->ram_block->host + addr);
- break;
- }
+ uint64_t data = ldn_he_p(mr->ram_block->host + addr, size);
trace_memory_region_ram_device_read(get_cpu_index(), mr, addr, data, size);
@@ -1368,20 +1353,7 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr,
trace_memory_region_ram_device_write(get_cpu_index(), mr, addr, data, size);
- switch (size) {
- case 1:
- *(uint8_t *)(mr->ram_block->host + addr) = (uint8_t)data;
- break;
- case 2:
- *(uint16_t *)(mr->ram_block->host + addr) = (uint16_t)data;
- break;
- case 4:
- *(uint32_t *)(mr->ram_block->host + addr) = (uint32_t)data;
- break;
- case 8:
- *(uint64_t *)(mr->ram_block->host + addr) = data;
- break;
- }
+ stn_he_p(mr->ram_block->host + addr, size, data);
}
static const MemoryRegionOps ram_device_mem_ops = {
--
2.43.0.rc0.421.g78406f8d94-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] system/memory: use ldn_he_p/stn_he_p
2023-11-16 16:36 [PATCH v2] system/memory: use ldn_he_p/stn_he_p Patrick Venture
@ 2023-11-17 8:18 ` Philippe Mathieu-Daudé
2023-11-17 8:43 ` David Hildenbrand
1 sibling, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-11-17 8:18 UTC (permalink / raw)
To: Patrick Venture, pbonzini, peterx, david, peter.maydell,
richard.henderson
Cc: qemu-devel, qemu-stable, Chris Rauer, Peter Foley
On 16/11/23 17:36, Patrick Venture wrote:
> Using direct pointer dereferencing can allow for unaligned accesses,
> which was seen during execution with sanitizers enabled.
>
> Reviewed-by: Chris Rauer <crauer@google.com>
> Reviewed-by: Peter Foley <pefoley@google.com>
> Signed-off-by: Patrick Venture <venture@google.com>
> Cc: qemu-stable@nongnu.org
> ---
> v2: changed commit mesage to be more accurate and switched from using
> memcpy to using the endian appropriate assignment load and store.
> ---
> system/memory.c | 32 ++------------------------------
> 1 file changed, 2 insertions(+), 30 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] system/memory: use ldn_he_p/stn_he_p
2023-11-16 16:36 [PATCH v2] system/memory: use ldn_he_p/stn_he_p Patrick Venture
2023-11-17 8:18 ` Philippe Mathieu-Daudé
@ 2023-11-17 8:43 ` David Hildenbrand
2023-12-03 15:42 ` Patrick Venture
1 sibling, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2023-11-17 8:43 UTC (permalink / raw)
To: Patrick Venture, pbonzini, peterx, philmd, peter.maydell,
richard.henderson
Cc: qemu-devel, qemu-stable, Chris Rauer, Peter Foley
On 16.11.23 17:36, Patrick Venture wrote:
> Using direct pointer dereferencing can allow for unaligned accesses,
> which was seen during execution with sanitizers enabled.
>
> Reviewed-by: Chris Rauer <crauer@google.com>
> Reviewed-by: Peter Foley <pefoley@google.com>
> Signed-off-by: Patrick Venture <venture@google.com>
> Cc: qemu-stable@nongnu.org
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] system/memory: use ldn_he_p/stn_he_p
2023-11-17 8:43 ` David Hildenbrand
@ 2023-12-03 15:42 ` Patrick Venture
2023-12-04 11:24 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 6+ messages in thread
From: Patrick Venture @ 2023-12-03 15:42 UTC (permalink / raw)
To: David Hildenbrand
Cc: pbonzini, peterx, philmd, peter.maydell, richard.henderson,
qemu-devel, qemu-stable, Chris Rauer, Peter Foley
[-- Attachment #1: Type: text/plain, Size: 686 bytes --]
On Fri, Nov 17, 2023 at 12:43 AM David Hildenbrand <david@redhat.com> wrote:
> On 16.11.23 17:36, Patrick Venture wrote:
> > Using direct pointer dereferencing can allow for unaligned accesses,
> > which was seen during execution with sanitizers enabled.
> >
> > Reviewed-by: Chris Rauer <crauer@google.com>
> > Reviewed-by: Peter Foley <pefoley@google.com>
> > Signed-off-by: Patrick Venture <venture@google.com>
> > Cc: qemu-stable@nongnu.org
>
>
>
> Reviewed-by: David Hildenbrand <david@redhat.com>
>
> --
> Cheers,
>
> David / dhildenb
>
Friendly ping? Is this going to be applied or do I need to add another CC
or? I do think it should go into stable.
[-- Attachment #2: Type: text/html, Size: 1385 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] system/memory: use ldn_he_p/stn_he_p
2023-12-03 15:42 ` Patrick Venture
@ 2023-12-04 11:24 ` Philippe Mathieu-Daudé
2023-12-04 17:40 ` Patrick Venture
0 siblings, 1 reply; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-12-04 11:24 UTC (permalink / raw)
To: Patrick Venture, David Hildenbrand
Cc: pbonzini, peterx, peter.maydell, richard.henderson, qemu-devel,
qemu-stable, Chris Rauer, Peter Foley
Hi Patrick,
On 3/12/23 16:42, Patrick Venture wrote:
> Friendly ping? Is this going to be applied or do I need to add another
> CC or? I do think it should go into stable.
I'll send a PR with this patch included.
Regards,
Phil.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] system/memory: use ldn_he_p/stn_he_p
2023-12-04 11:24 ` Philippe Mathieu-Daudé
@ 2023-12-04 17:40 ` Patrick Venture
0 siblings, 0 replies; 6+ messages in thread
From: Patrick Venture @ 2023-12-04 17:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: David Hildenbrand, pbonzini, peterx, peter.maydell,
richard.henderson, qemu-devel, qemu-stable, Chris Rauer,
Peter Foley
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
On Mon, Dec 4, 2023 at 3:24 AM Philippe Mathieu-Daudé <philmd@linaro.org>
wrote:
> Hi Patrick,
>
> On 3/12/23 16:42, Patrick Venture wrote:
>
> > Friendly ping? Is this going to be applied or do I need to add another
> > CC or? I do think it should go into stable.
>
> I'll send a PR with this patch included.
>
Thanks!
>
> Regards,
>
> Phil.
>
[-- Attachment #2: Type: text/html, Size: 865 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-04 17:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-16 16:36 [PATCH v2] system/memory: use ldn_he_p/stn_he_p Patrick Venture
2023-11-17 8:18 ` Philippe Mathieu-Daudé
2023-11-17 8:43 ` David Hildenbrand
2023-12-03 15:42 ` Patrick Venture
2023-12-04 11:24 ` Philippe Mathieu-Daudé
2023-12-04 17:40 ` Patrick Venture
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).