[Qemu-devel] [PATCH 10/11] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error

Philippe Mathieu-Daudé posted 11 patches 7 years, 7 months ago
Only 10 patches received!
There is a newer version of this series
[Qemu-devel] [PATCH 10/11] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error
Posted by Philippe Mathieu-Daudé 7 years, 7 months ago
hw_error() finally calls abort(), but there is no need to abort here.

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

diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index 04bd10ada3..188adcbd15 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -9,6 +9,7 @@
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
 #include "net/net.h"
+#include "qemu/log.h"
 #include <zlib.h>
 
 //#define DEBUG_STELLARIS_ENET 1
@@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
     case 0x3c: /* Undocuented: Timestamp? */
         return 0;
     default:
-        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "stellaris_enet_rd%d: 0x%" HWADDR_PRIx "\n",
+                      size, offset);
         return 0;
     }
 }
@@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
         /* Ignored.  */
         break;
     default:
-        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "stellaris_enet_wr%d: 0x%" HWADDR_PRIx " = 0x%lx\n",
+                      size, offset, value);
     }
 }
 
-- 
2.18.0.rc2


Re: [Qemu-devel] [PATCH 10/11] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error
Posted by Thomas Huth 7 years, 7 months ago
On 21.06.2018 20:02, Philippe Mathieu-Daudé wrote:
> hw_error() finally calls abort(), but there is no need to abort here.

Additionally, hw_error() is also only meant for CPU errors (since it
dumps the CPU state). We should really rename that function to
"cpu_hw_error" one day to avoid that people use it in the wrong spots...

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/net/stellaris_enet.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
> index 04bd10ada3..188adcbd15 100644
> --- a/hw/net/stellaris_enet.c
> +++ b/hw/net/stellaris_enet.c
> @@ -9,6 +9,7 @@
>  #include "qemu/osdep.h"
>  #include "hw/sysbus.h"
>  #include "net/net.h"
> +#include "qemu/log.h"
>  #include <zlib.h>
>  
>  //#define DEBUG_STELLARIS_ENET 1
> @@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
>      case 0x3c: /* Undocuented: Timestamp? */
>          return 0;
>      default:
> -        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
> +        qemu_log_mask(LOG_GUEST_ERROR,
> +                      "stellaris_enet_rd%d: 0x%" HWADDR_PRIx "\n",
> +                      size, offset);
>          return 0;
>      }
>  }
> @@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
>          /* Ignored.  */
>          break;
>      default:
> -        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
> +        qemu_log_mask(LOG_GUEST_ERROR,
> +                      "stellaris_enet_wr%d: 0x%" HWADDR_PRIx " = 0x%lx\n",
> +                      size, offset, value);
>      }
>  }

Could you please keep the "bad offset" or a similar error message, so
that the user knows that there is really something wrong here?

 Thomas

Re: [Qemu-devel] [PATCH 10/11] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error
Posted by Philippe Mathieu-Daudé 7 years, 7 months ago
On 06/22/2018 05:43 AM, Thomas Huth wrote:
> On 21.06.2018 20:02, Philippe Mathieu-Daudé wrote:
>> hw_error() finally calls abort(), but there is no need to abort here.
> 
> Additionally, hw_error() is also only meant for CPU errors (since it
> dumps the CPU state). We should really rename that function to
> "cpu_hw_error" one day to avoid that people use it in the wrong spots...

Another painful cleanup series...

> 
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  hw/net/stellaris_enet.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
>> index 04bd10ada3..188adcbd15 100644
>> --- a/hw/net/stellaris_enet.c
>> +++ b/hw/net/stellaris_enet.c
>> @@ -9,6 +9,7 @@
>>  #include "qemu/osdep.h"
>>  #include "hw/sysbus.h"
>>  #include "net/net.h"
>> +#include "qemu/log.h"
>>  #include <zlib.h>
>>  
>>  //#define DEBUG_STELLARIS_ENET 1
>> @@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
>>      case 0x3c: /* Undocuented: Timestamp? */
>>          return 0;
>>      default:
>> -        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
>> +        qemu_log_mask(LOG_GUEST_ERROR,
>> +                      "stellaris_enet_rd%d: 0x%" HWADDR_PRIx "\n",
>> +                      size, offset);
>>          return 0;
>>      }
>>  }
>> @@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
>>          /* Ignored.  */
>>          break;
>>      default:
>> -        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
>> +        qemu_log_mask(LOG_GUEST_ERROR,
>> +                      "stellaris_enet_wr%d: 0x%" HWADDR_PRIx " = 0x%lx\n",
>> +                      size, offset, value);
>>      }
>>  }
> 
> Could you please keep the "bad offset" or a similar error message, so
> that the user knows that there is really something wrong here?

Sure.