hw/sensor: add stub for ADM1266 blackbox
PATCH v2 1/1 hw/sensor: add stub for ADM1266 blackbox
From: Titus Rwantare <[email protected]>
This patch fixes a bug that causes a kernel panic when calling ADM1266_BLACKBOX_INFORMATION.
Log Message:
adm1266 5-0042: Could not read blackbox!
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: adm1266_nvmem_read+0x168/0x170
--- hw/sensor/adm1266.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/sensor/adm1266.c +15 -0
@@ -75,6 +75,7 @@ typedef struct ADM1266State {static const uint8_t adm1266_ic_device_id[] = {0x03 ,0x41 ,0x12 ,0x66 };static const uint8_t adm1266_ic_device_rev[] = {0x08 ,0x01 ,0x08 ,0x07 ,0x0 ,0x0 ,0x07 ,0x41 ,0x30 }; +static const uint8_t adm1266_blackbox_info[] = {0x04 ,0x00 ,0x00 ,0x00 ,0x00 };static void adm1266_exit_reset (Object *obj,ResetType type) {
@@ -125,6 +126,17 @@ static uint8_t adm1266_read_byte(PMBusDevice *pmdev)pmbus_send (pmdev, adm1266_ic_device_rev,sizeof (adm1266_ic_device_rev));break ; +case ADM1266_BLACKBOX_CONFIG : +return 0 ; + +case ADM1266_READ_BLACKBOX : +return 0 ; + +case ADM1266_BLACKBOX_INFORMATION : +pmbus_send (pmdev, adm1266_blackbox_info, +sizeof (adm1266_blackbox_info)); +break ; +default : qemu_log_mask(LOG_UNIMP, "%s: reading from unimplemented register: 0x%02x\n",
@@ -154,6 +166,9 @@ static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf,pmbus_receive_block (pmdev, (uint8_t *)s->mfr_rev,sizeof (s->mfr_rev));break ; +case ADM1266_BLACKBOX_CONFIG : +case ADM1266_READ_BLACKBOX : +case ADM1266_BLACKBOX_INFORMATION :case ADM1266_SET_RTC :/* do nothing */ break ;
Signature · 1 line
2.51.0.rc0.155.g4a0f42376b-goog
Hi Titus,
Quoted 3 lines · Ben Hillier
From: Titus Rwantare <[email protected]>
This patch fixes a bug that causes a kernel panic when calling
ADM1266_BLACKBOX_INFORMATION.
But you also implement BLACKBOX_CONFIG / READ_BLACKBOX...
Quoted 15 lines
Log Message:
adm1266 5-0042: Could not read blackbox!
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: adm1266_nvmem_read+0x168/0x170Signed-off-by Titus Rwantare <[email protected]>--- hw/sensor/adm1266.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)hw/sensor/adm1266.c +0
-0
hw/sensor/adm1266.c typedef struct ADM1266State { · line 78
Quoted 4 lines
hw/sensor/adm1266.c +1
-0@@ -75,6 +75,7 @@ typedef struct ADM1266State {static const uint8_t adm1266_ic_device_id[] = {0x03 ,0x41 ,0x12 ,0x66 };static const uint8_t adm1266_ic_device_rev[] = {0x08 ,0x01 ,0x08 ,0x07 ,0x0 ,0x0 ,0x07 ,0x41 ,0x30 }; +static const uint8_t adm1266_blackbox_info[] = {0x04 ,0x00 ,0x00 ,0x00 ,0x00 };
{
0x04, /* length */
0x00, 0x00, /* latest ID */
0x00, /* latest record logic index */
0x00 /* latest record count */};
hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 130
Quoted 9 lines
hw/sensor/adm1266.c +2
-0static void adm1266_exit_reset (Object *obj,ResetType type) {@@ -125,6 +126,17 @@ static uint8_t adm1266_read_byte(PMBusDevice *pmdev)pmbus_send (pmdev, adm1266_ic_device_rev,sizeof (adm1266_ic_device_rev));break ; +case ADM1266_BLACKBOX_CONFIG : +return 0 ;
I'd was expecting pmbus_send(pmdev, "\0\0", 2) for CYCLIC_RECORD_DISABLED.
hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 132
Quoted 2 lines
hw/sensor/adm1266.c +2
-0+ +case ADM1266_READ_BLACKBOX :
Here I'm confused, as len+data is 65bytes. Is the guest reading a stream of 0xff?
hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 138
Quoted 6 lines
hw/sensor/adm1266.c +6
-0+return 0 ; + +case ADM1266_BLACKBOX_INFORMATION : +pmbus_send (pmdev, adm1266_blackbox_info, +sizeof (adm1266_blackbox_info)); +break ;
OK.
hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 169
Quoted 8 lines
hw/sensor/adm1266.c +1
-0default : qemu_log_mask(LOG_UNIMP, "%s: reading from unimplemented register: 0x%02x\n",@@ -154,6 +166,9 @@ static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf,pmbus_receive_block (pmdev, (uint8_t *)s->mfr_rev,sizeof (s->mfr_rev));break ; +case ADM1266_BLACKBOX_CONFIG :
Do we want to check, if lduw_p(buf) != 0 -> log(UNIMP)?
hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 170
Quoted 1 line
hw/sensor/adm1266.c +1
-0+case ADM1266_READ_BLACKBOX :
Do we want to check, if (buf[0] != 1) -> log(GUEST_ERROR), and log(UNIMP) regardless?
hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 171
Quoted 1 line
hw/sensor/adm1266.c +1
-0+case ADM1266_BLACKBOX_INFORMATION :
log(GUEST_ERROR);
hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 174
Quoted 3 lines
hw/sensor/adm1266.c +0
-0case ADM1266_SET_RTC :/* do nothing */ break ;
Regards,
Phil.
Quoted 80 lines · Philippe Mathieu-Daudé
Hi Titus,
Quoted 3 lines · Ben Hillier
From: Titus Rwantare <[email protected]>
This patch fixes a bug that causes a kernel panic when calling
ADM1266_BLACKBOX_INFORMATION.But you also implement
BLACKBOX_CONFIG/READ_BLACKBOX...Quoted 15 lines
Log Message:
adm1266 5-0042: Could not read blackbox!
Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: adm1266_nvmem_read+0x168/0x170Signed-off-by Titus Rwantare <[email protected]>--- hw/sensor/adm1266.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)hw/sensor/adm1266.c +0
-0hw/sensor/adm1266.c typedef struct ADM1266State { · line 78
Quoted 4 lines
hw/sensor/adm1266.c +1
-0@@ -75,6 +75,7 @@ typedef struct ADM1266State {static const uint8_t adm1266_ic_device_id[] = {0x03 ,0x41 ,0x12 ,0x66 };static const uint8_t adm1266_ic_device_rev[] = {0x08 ,0x01 ,0x08 ,0x07 ,0x0 ,0x0 ,0x07 ,0x41 ,0x30 }; +static const uint8_t adm1266_blackbox_info[] = {0x04 ,0x00 ,0x00 ,0x00 ,0x00 };{ 0x04, /* length */ 0x00, 0x00, /* latest ID */ 0x00, /* latest record logic index */ 0x00 /* latest record count */};
hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 130
Quoted 9 lines
hw/sensor/adm1266.c +2
-0static void adm1266_exit_reset (Object *obj,ResetType type) {@@ -125,6 +126,17 @@ static uint8_t adm1266_read_byte(PMBusDevice *pmdev)pmbus_send (pmdev, adm1266_ic_device_rev,sizeof (adm1266_ic_device_rev));break ; +case ADM1266_BLACKBOX_CONFIG : +return 0 ;I'd was expecting
pmbus_send(pmdev, "\0\0", 2)forCYCLIC_RECORD_DISABLED.hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 132
Quoted 2 lines
hw/sensor/adm1266.c +2
-0+ +case ADM1266_READ_BLACKBOX :Here I'm confused, as len+data is 65bytes. Is the guest reading a stream of
0xff?hw/sensor/adm1266.c static uint8_t adm1266_read_byte(PMBusDevice *pmdev) · line 138
Quoted 6 lines
hw/sensor/adm1266.c +6
-0+return 0 ; + +case ADM1266_BLACKBOX_INFORMATION : +pmbus_send (pmdev, adm1266_blackbox_info, +sizeof (adm1266_blackbox_info)); +break ;OK.
hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 169
Quoted 8 lines
hw/sensor/adm1266.c +1
-0default : qemu_log_mask(LOG_UNIMP, "%s: reading from unimplemented register: 0x%02x\n",@@ -154,6 +166,9 @@ static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf,pmbus_receive_block (pmdev, (uint8_t *)s->mfr_rev,sizeof (s->mfr_rev));break ; +case ADM1266_BLACKBOX_CONFIG :Do we want to check, if
lduw_p(buf)!= 0 -> log(UNIMP)?hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 170
Quoted 1 line
hw/sensor/adm1266.c +1
-0+case ADM1266_READ_BLACKBOX :Do we want to check, if (buf[0] != 1) ->
log(GUEST_ERROR), and log(UNIMP) regardless?hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 171
Quoted 1 line
hw/sensor/adm1266.c +1
-0+case ADM1266_BLACKBOX_INFORMATION :
Quoted 8 lines
log(GUEST_ERROR);hw/sensor/adm1266.c static int adm1266_write_data(PMBusDevice *pmdev, const uint8_t *buf, · line 174
Quoted 3 lines
hw/sensor/adm1266.c +0
-0case ADM1266_SET_RTC :/* do nothing */ break ;Regards,
Phil.
Thanks for the feedback, I wound up implementing more of the blackbox and implementing a test for it.
-Titus