From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baHpK-0003SM-PG for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:33:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1baHp8-00015m-Cu for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:33:21 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:21182) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1baHp8-00015E-6Y for qemu-devel@nongnu.org; Thu, 18 Aug 2016 03:33:10 -0400 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 18 Aug 2016 09:31:27 +0200 Message-Id: <1471505489-1221-3-git-send-email-hpoussin@reactos.org> In-Reply-To: <1471505489-1221-1-git-send-email-hpoussin@reactos.org> References: <1471505489-1221-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 2/4] lsi: do not exit QEMU if reading invalid register List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= When guest accesses invalid register, return 0xff instead of exiting. Also add a log when reading or writing invalid registers. Signed-off-by: Herv=C3=A9 Poussineau --- hw/scsi/lsi53c895a.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c index 07dc73a..9d2e3eb 100644 --- a/hw/scsi/lsi53c895a.c +++ b/hw/scsi/lsi53c895a.c @@ -19,6 +19,7 @@ #include "hw/pci/pci.h" #include "hw/scsi/scsi.h" #include "sysemu/dma.h" +#include "qemu/log.h" =20 //#define DEBUG_LSI //#define DEBUG_LSI_REG @@ -34,7 +35,6 @@ do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_= ARGS__); exit(1);} while do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (= 0) #endif =20 -#ifdef DEBUG_LSI_REG static const char *names[] =3D { "SCNTL0", "SCNTL1", "SCNTL2", "SCNTL3", "SCID", "SXFER", "SDID", "GP= REG", "SFBR", "SOCL", "SSID", "SBCL", "DSTAT", "SSTAT0", "SSTAT1", "SSTAT2= ", @@ -49,7 +49,6 @@ static const char *names[] =3D { "SIDL", "0x51", "0x52", "0x53", "SODL", "0x55", "0x56", "0x57", "SBDL", "0x59", "0x5a", "0x5b", "SCRATCHB0", "SCRATCHB1", "SCRATCHB2= ", "SCRATCHB3", }; -#endif =20 #define LSI_MAX_DEVS 7 =20 @@ -1715,8 +1714,14 @@ static uint8_t lsi_reg_readb(LSIState *s, int offs= et) break; } default: - BADF("readb 0x%x\n", offset); - exit(1); + { + qemu_log_mask(LOG_GUEST_ERROR, + "lsi_scsi: invalid read from reg %s %x\n", + offset < ARRAY_SIZE(names) ? names[offset] : "???"= , + offset); + ret =3D 0xff; + break; + } } #undef CASE_GET_REG24 #undef CASE_GET_REG32 @@ -1959,7 +1964,10 @@ static void lsi_reg_writeb(LSIState *s, int offset= , uint8_t val) shift =3D (offset & 3) * 8; s->scratch[n] =3D deposit32(s->scratch[n], shift, 8, val); } else { - BADF("Unhandled writeb 0x%x =3D 0x%x\n", offset, val); + qemu_log_mask(LOG_GUEST_ERROR, + "lsi_scsi: invalid write to reg %s %x (0x%02x)= \n", + offset < ARRAY_SIZE(names) ? names[offset] : "= ???", + offset, val); } } #undef CASE_SET_REG24 --=20 2.1.4