diff mbox series

[v2,2/3] edu: mmio: allow mmio read dispatch accept 8 bytes

Message ID 20190420161446.2274-3-liq3ea@163.com
State New
Headers show
Series hw: edu: some fixes | expand

Commit Message

Li Qiang April 20, 2019, 4:14 p.m. UTC
The edu spec said when address >= 0x80, the MMIO area can
be accessed by 8 bytes.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 hw/misc/edu.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Philippe Mathieu-Daudé April 21, 2019, 10:44 a.m. UTC | #1
Hi Li,

On 4/20/19 6:14 PM, Li Qiang wrote:
> The edu spec said when address >= 0x80, the MMIO area can

"says"

> be accessed by 8 bytes.
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  hw/misc/edu.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/misc/edu.c b/hw/misc/edu.c
> index 65fc32b928..4018dddcb8 100644
> --- a/hw/misc/edu.c
> +++ b/hw/misc/edu.c
> @@ -189,6 +189,10 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr addr, unsigned size)

Completing the diff ...:

       if (size != 4) {

>          return val;
>      }
>  
> +    if (addr >= 0x80 && size != 4 && size != 8) {

... to show this code is unreachable for size == 8.

> +        return val;
> +    }
> +
>      switch (addr) {
>      case 0x00:
>          val = 0x010000edu;
> 

I think the change you wanted is:

-- >8 --
@@ -185,7 +185,11 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr
addr, unsigned size)
     EduState *edu = opaque;
     uint64_t val = ~0ULL;

-    if (size != 4) {
+    if (addr < 0x80 && size != 4) {
+        return val;
+    }
+
+    if (addr >= 0x80 && size != 4 && size != 8) {
         return val;
     }

---

Another cleaner way to solve this is use 2 MemoryRegionOps, one for the
first 0x80 addresses and another for the rest.

Regards,

Phil.
Li Qiang April 22, 2019, 1:22 a.m. UTC | #2
Philippe Mathieu-Daudé <philmd@redhat.com> 于2019年4月21日周日 下午6:44写道:

> Hi Li,
>
> On 4/20/19 6:14 PM, Li Qiang wrote:
> > The edu spec said when address >= 0x80, the MMIO area can
>
> "says"
>
> > be accessed by 8 bytes.
> >
> > Signed-off-by: Li Qiang <liq3ea@163.com>
> > ---
> >  hw/misc/edu.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/hw/misc/edu.c b/hw/misc/edu.c
> > index 65fc32b928..4018dddcb8 100644
> > --- a/hw/misc/edu.c
> > +++ b/hw/misc/edu.c
> > @@ -189,6 +189,10 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr
> addr, unsigned size)
>
> Completing the diff ...:
>
>        if (size != 4) {
>
> >          return val;
> >      }
> >
> > +    if (addr >= 0x80 && size != 4 && size != 8) {
>
> ... to show this code is unreachable for size == 8.
>
>
Ohhh, yes



> > +        return val;
> > +    }
> > +
> >      switch (addr) {
> >      case 0x00:
> >          val = 0x010000edu;
> >
>
> I think the change you wanted is:
>
> -- >8 --
> @@ -185,7 +185,11 @@ static uint64_t edu_mmio_read(void *opaque, hwaddr
> addr, unsigned size)
>      EduState *edu = opaque;
>      uint64_t val = ~0ULL;
>
> -    if (size != 4) {
> +    if (addr < 0x80 && size != 4) {
> +        return val;
> +    }
> +
> +    if (addr >= 0x80 && size != 4 && size != 8) {
>          return val;
>      }
>
>

Yes, this is what I want. Thanks, will change to this in next revision.

Thanks,
Li Qiang



> ---
>
> Another cleaner way to solve this is use 2 MemoryRegionOps, one for the
> first 0x80 addresses and another for the rest.
>
> Regards,
>
> Phil.
>
diff mbox series

Patch

diff --git a/hw/misc/edu.c b/hw/misc/edu.c
index 65fc32b928..4018dddcb8 100644
--- a/hw/misc/edu.c
+++ b/hw/misc/edu.c
@@ -189,6 +189,10 @@  static uint64_t edu_mmio_read(void *opaque, hwaddr addr, unsigned size)
         return val;
     }
 
+    if (addr >= 0x80 && size != 4 && size != 8) {
+        return val;
+    }
+
     switch (addr) {
     case 0x00:
         val = 0x010000edu;