[PATCH 2/2] hw/net/opencores_eth: Remove unnecessary address masking

Philippe Mathieu-Daudé posted 2 patches 5 years, 8 months ago
[PATCH 2/2] hw/net/opencores_eth: Remove unnecessary address masking
Posted by Philippe Mathieu-Daudé 5 years, 8 months ago
The memory region is limited to 1 KiB, so the address is
garantied to be in that range. No need to mask.

  711 static const MemoryRegionOps open_eth_desc_ops = {
  712     .read = open_eth_desc_read,
  713     .write = open_eth_desc_write,
  714 };
  ...
  725     memory_region_init_io(&s->desc_io, OBJECT(dev),
  725                           &open_eth_desc_ops, s,
  726                           "open_eth.desc", 0x400);

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/net/opencores_eth.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c
index 90d3846bb7..0c9879e8a7 100644
--- a/hw/net/opencores_eth.c
+++ b/hw/net/opencores_eth.c
@@ -687,7 +687,6 @@ static uint64_t open_eth_desc_read(void *opaque,
     OpenEthState *s = opaque;
     uint64_t v = 0;
 
-    addr &= 0x3ff;
     memcpy(&v, (uint8_t *)s->desc + addr, size);
     trace_open_eth_desc_read((uint32_t)addr, (uint32_t)v);
     return v;
@@ -698,7 +697,6 @@ static void open_eth_desc_write(void *opaque,
 {
     OpenEthState *s = opaque;
 
-    addr &= 0x3ff;
     trace_open_eth_desc_write((uint32_t)addr, (uint32_t)val);
     memcpy((uint8_t *)s->desc + addr, &val, size);
     open_eth_check_start_xmit(s);
-- 
2.21.3


Re: [PATCH 2/2] hw/net/opencores_eth: Remove unnecessary address masking
Posted by Max Filippov 5 years, 8 months ago
On Mon, Jun 8, 2020 at 2:15 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> The memory region is limited to 1 KiB, so the address is
> garantied to be in that range. No need to mask.
>
>   711 static const MemoryRegionOps open_eth_desc_ops = {
>   712     .read = open_eth_desc_read,
>   713     .write = open_eth_desc_write,
>   714 };
>   ...
>   725     memory_region_init_io(&s->desc_io, OBJECT(dev),
>   725                           &open_eth_desc_ops, s,
>   726                           "open_eth.desc", 0x400);
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/net/opencores_eth.c | 2 --
>  1 file changed, 2 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max