aspeed: small cleanups
cover aspeed: small cleanups
Hello,
I was preparing a PR and I realized that these small patches had never seen the light. Here they are.
Thanks,
C.
Cédric Le Goater (2):
aspeed/scu: Add trace events for read ops aspeed/i2c: Change trace event for NORMAL_STOP states
Joel Stanley (1):
aspeed: sbc: Allow per-machine settings
include/hw/misc/aspeed_sbc.h | 13 ++++++++++++ hw/i2c/aspeed_i2c.c | 2 +- hw/misc/aspeed_sbc.c | 41 ++++++++++++++++++++++++++++++++++-- hw/misc/aspeed_scu.c | 2 ++ hw/misc/trace-events | 1 + 5 files changed, 56 insertions(+), 3 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/3 aspeed/scu: Add trace events for read ops
--- hw/misc/aspeed_scu.c | 2 ++ hw/misc/trace-events | 1 + 2 files changed, 3 insertions(+)
hw/misc/aspeed_scu.c +2 -0
@@ -270,6 +270,7 @@ static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size)break ; } +trace_aspeed_scu_read (offset, size, s->regs[reg]);return s->regs[reg]; }
@@ -637,6 +638,7 @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset,break ; } +trace_aspeed_scu_read (offset, size, s->regs[reg]);return s->regs[reg]; }
hw/misc/trace-events +1 -0
@@ -69,6 +69,7 @@ slavio_led_mem_readw(uint32_t ret) "Read diagnostic LED 0x%04x" # aspeed_scu.c aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 +aspeed_scu_read(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 # mps2-scc.c mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
Signature · 1 line
2.35.3
Re: [PATCH 1/3] aspeed/scu: Add trace events for read ops
Quoted 5 lines · Cédric Le Goater
Signed-off-by Cédric Le Goater <[email protected]>
Also a nice change.
Quoted 41 lines
---
hw/misc/aspeed_scu.c| 2 ++
hw/misc/trace-events | 1 +2 files changed, 3 insertions(+)hw/misc/aspeed_scu.c +2
-0@@ -270,6 +270,7 @@ static uint64_t aspeed_scu_read(void *opaque, hwaddr offset, unsigned size)break ; } +trace_aspeed_scu_read (offset, size, s->regs[reg]);return s->regs[reg]; }@@ -637,6 +638,7 @@ static uint64_t aspeed_ast2600_scu_read(void *opaque, hwaddr offset,break ; } +trace_aspeed_scu_read (offset, size, s->regs[reg]);return s->regs[reg]; }hw/misc/trace-events +0
-0@@ -69,6 +69,7 @@ slavio_led_mem_readw(uint32_t ret) "Read diagnostic LED 0x%04x" # aspeed_scu.c
aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data)"To 0x%" PRIx64 " of size %u: 0x%" PRIx32 +aspeed_scu_read(uint64_t offset, unsigned size,uint32_tdata) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32# mps2-scc.c mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"Signature · 1 line
2.35.3
PATCH 2/3 aspeed/i2c: Change trace event for NORMAL_STOP states
In reply to Cédric Le GoaterUsing a 'stop' string seems more appropriate than 'normal'.
--- hw/i2c/aspeed_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/aspeed_i2c.c +1 -1
@@ -58,7 +58,7 @@ static inline void aspeed_i2c_bus_raise_interrupt(AspeedI2CBus *bus)ARRAY_FIELD_EX32 (bus->regs,I2CD_INTR_STS ,SLAVE_ADDR_RX_MATCH ) ?"slave-match|" :"" ,SHARED_ARRAY_FIELD_EX32 (bus->regs, reg_intr_sts,NORMAL_STOP ) ? -"normal|" :"" , +"stop|" :"" ,SHARED_ARRAY_FIELD_EX32 (bus->regs, reg_intr_sts,ABNORMAL ) ? "abnormal" : "");
Signature · 1 line
2.35.3
Re: [PATCH 2/3] aspeed/i2c: Change trace event for NORMAL_STOP states
Quoted 5 lines · Cédric Le Goater
Using a 'stop' string seems more appropriate than 'normal'.
Ha yes! This is an understatement, the change is much appreciated.
I've seen that trace and never realized it was referring to ‘stop’.
Quoted 23 lines
Signed-off-by Cédric Le Goater <[email protected]>---
hw/i2c/aspeed_i2c.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/i2c/aspeed_i2c.c +1
-1@@ -58,7 +58,7 @@ static inline void aspeed_i2c_bus_raise_interrupt(AspeedI2CBus *bus)ARRAY_FIELD_EX32 (bus->regs,I2CD_INTR_STS ,SLAVE_ADDR_RX_MATCH ) ?"slave-match|" :"" ,SHARED_ARRAY_FIELD_EX32 (bus->regs, reg_intr_sts,NORMAL_STOP ) ? -"normal|" :"" , +"stop|" :"" ,SHARED_ARRAY_FIELD_EX32 (bus->regs, reg_intr_sts,ABNORMAL ) ? "abnormal" : "");Signature · 1 line
2.35.3
PATCH 3/3 aspeed: sbc: Allow per-machine settings
In reply to Cédric Le GoaterFrom: Joel Stanley <[email protected]>
In order to correctly report secure boot running firmware the values of certain registers must be set.
We don't yet have documentation from ASPEED on what they mean. The meaning is inferred from u-boot's use of them.
Introduce properties so the settings can be configured per-machine.
--- include/hw/misc/aspeed_sbc.h | 13 ++++++++++++ hw/misc/aspeed_sbc.c | 41 ++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)
include/hw/misc/aspeed_sbc.h +13 -0
@@ -17,9 +17,22 @@ OBJECT_DECLARE_TYPE(AspeedSBCState, AspeedSBCClass, ASPEED_SBC)#define ASPEED_SBC_NR_REGS (0x93c >> 2) +#define QSR_AES BIT(27) +#define QSR_RSA1024 (0x0 << 12) +#define QSR_RSA2048 (0x1 << 12) +#define QSR_RSA3072 (0x2 << 12) +#define QSR_RSA4096 (0x3 << 12) +#define QSR_SHA224 (0x0 << 10) +#define QSR_SHA256 (0x1 << 10) +#define QSR_SHA384 (0x2 << 10) +#define QSR_SHA512 (0x3 << 10) +struct AspeedSBCState {SysBusDevice parent; +bool emmc_abr; +uint32_t signing_settings; +MemoryRegion iomem;uint32_t regs[ASPEED_SBC_NR_REGS ];
hw/misc/aspeed_sbc.c +39 -2
71 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH 3/3] aspeed: sbc: Allow per-machine settings
Quoted 105 lines · Cédric Le Goater
From: Joel Stanley <[email protected]>
In order to correctly report secure boot running firmware the values of certain registers must be set.
We don't yet have documentation from ASPEED on what they mean. The meaning is inferred from u-boot's use of them.
Introduce properties so the settings can be configured per-machine.
Signed-off-by Joel Stanley <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/misc/aspeed_sbc.h | 13 ++++++++++++ hw/misc/aspeed_sbc.c | 41 ++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)include/hw/misc/aspeed_sbc.h +13
-0@@ -17,9 +17,22 @@ OBJECT_DECLARE_TYPE(AspeedSBCState, AspeedSBCClass, ASPEED_SBC)#define ASPEED_SBC_NR_REGS (0x93c >> 2) +#define QSR_AES BIT(27) +#define QSR_RSA1024 (0x0 << 12) +#define QSR_RSA2048 (0x1 << 12) +#define QSR_RSA3072 (0x2 << 12) +#define QSR_RSA4096 (0x3 << 12) +#define QSR_SHA224 (0x0 << 10) +#define QSR_SHA256 (0x1 << 10) +#define QSR_SHA384 (0x2 << 10) +#define QSR_SHA512 (0x3 << 10) +struct AspeedSBCState {SysBusDevice parent; +bool emmc_abr; +uint32_t signing_settings; +MemoryRegion iomem;uint32_t regs[ASPEED_SBC_NR_REGS ];hw/misc/aspeed_sbc.c +33
-2@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/error-report.h" +#include "hw/qdev-properties.h" #include "hw/misc/aspeed_sbc.h" #include "qapi/error.h" #include "migration/vmstate.h" @@ -19,6 +20,27 @@#define R_STATUS (0x014 / 4)#define R_QSR (0x040 / 4) +/* R_STATUS */ +#define ABR_EN BIT(14)/* Mirrors SCU510[11] */ +#define ABR_IMAGE_SOURCE BIT(13) +#define SPI_ABR_IMAGE_SOURCE BIT(12) +#define SB_CRYPTO_KEY_EXP_DONE BIT(11) +#define SB_CRYPTO_BUSY BIT(10) +#define OTP_WP_EN BIT(9) +#define OTP_ADDR_WP_EN BIT(8) +#define LOW_SEC_KEY_EN BIT(7) +#define SECURE_BOOT_EN BIT(6) +#define UART_BOOT_EN BIT(5) +/* bit 4 reserved*/ +#define OTP_CHARGE_PUMP_READY BIT(3) +#define OTP_IDLE BIT(2) +#define OTP_MEM_IDLE BIT(1) +#define OTP_COMPARE_STATUS BIT(0) + +/* QSR */ +#define QSR_RSA_MASK (0x3 << 12) +#define QSR_HASH_MASK (0x3 << 10) +static uint64_t aspeed_sbc_read (void *opaque,hwaddr addr,unsigned int size) {AspeedSBCState *s =ASPEED_SBC (opaque);@@ -80,8 +102,17 @@ static void aspeed_sbc_reset(DeviceState *dev)memset (s->regs,0 ,sizeof (s->regs));/* Set secure boot enabled with RSA4096_SHA256 and enable eMMC ABR */ - s->regs[R_STATUS ] =0x000044C6 ; - s->regs[R_QSR ] =0x07C07C89 ; + s->regs[R_STATUS ] =OTP_IDLE |OTP_MEM_IDLE ; + +if (s->emmc_abr) { + s->regs[R_STATUS ] &=ABR_EN ; + } + +if (s->signing_settings) { + s->regs[R_STATUS ] &=SECURE_BOOT_EN ; + } + + s->regs[R_QSR ] = s->signing_settings; }static void aspeed_sbc_realize (DeviceState *dev,Error **errp)
hw/misc/aspeed_sbc.c static const VMStateDescription vmstate_aspeed_sbc = { · line 142
Quoted 7 lines
hw/misc/aspeed_sbc.c +4
-0@@ -105,6 +136,11 @@ static const VMStateDescription vmstate_aspeed_sbc = { } }; +static Property aspeed_sbc_properties[] = { +DEFINE_PROP_BOOL ("emmc-abr" , AspeedSBCState, emmc_abr,0 ), +DEFINE_PROP_UINT32 ("signing-settings" , AspeedSBCState, signing_settings,0 ), +};
This needs a DEFINE_PROP_END_OF_LIST(), I bisected to this commit in Cedric's aspeed-7.1 branch.
Quoted 16 lines
hw/misc/aspeed_sbc.c +2
-0+static void aspeed_sbc_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);@@ -112,6 +148,7 @@ static void aspeed_sbc_class_init(ObjectClass *klass, void *data) dc->realize = aspeed_sbc_realize; dc->reset = aspeed_sbc_reset; dc->vmsd = &vmstate_aspeed_sbc; +device_class_set_props (dc, aspeed_sbc_properties); }static const TypeInfo aspeed_sbc_info = {Signature · 1 line
2.35.3
Re: [PATCH 3/3] aspeed: sbc: Allow per-machine settings
Quoted 109 lines · Peter Delevoryas
Quoted 108 lines · Cédric Le Goater
From: Joel Stanley <[email protected]>
In order to correctly report secure boot running firmware the values of certain registers must be set.
We don't yet have documentation from ASPEED on what they mean. The meaning is inferred from u-boot's use of them.
Introduce properties so the settings can be configured per-machine.
Signed-off-by Joel Stanley <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/misc/aspeed_sbc.h | 13 ++++++++++++ hw/misc/aspeed_sbc.c | 41 ++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)include/hw/misc/aspeed_sbc.h +13
-0@@ -17,9 +17,22 @@ OBJECT_DECLARE_TYPE(AspeedSBCState, AspeedSBCClass, ASPEED_SBC)#define ASPEED_SBC_NR_REGS (0x93c >> 2) +#define QSR_AES BIT(27) +#define QSR_RSA1024 (0x0 << 12) +#define QSR_RSA2048 (0x1 << 12) +#define QSR_RSA3072 (0x2 << 12) +#define QSR_RSA4096 (0x3 << 12) +#define QSR_SHA224 (0x0 << 10) +#define QSR_SHA256 (0x1 << 10) +#define QSR_SHA384 (0x2 << 10) +#define QSR_SHA512 (0x3 << 10) +struct AspeedSBCState {SysBusDevice parent; +bool emmc_abr; +uint32_t signing_settings; +MemoryRegion iomem;uint32_t regs[ASPEED_SBC_NR_REGS ];hw/misc/aspeed_sbc.c +33
-2@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/error-report.h" +#include "hw/qdev-properties.h" #include "hw/misc/aspeed_sbc.h" #include "qapi/error.h" #include "migration/vmstate.h" @@ -19,6 +20,27 @@#define R_STATUS (0x014 / 4)#define R_QSR (0x040 / 4) +/* R_STATUS */ +#define ABR_EN BIT(14)/* Mirrors SCU510[11] */ +#define ABR_IMAGE_SOURCE BIT(13) +#define SPI_ABR_IMAGE_SOURCE BIT(12) +#define SB_CRYPTO_KEY_EXP_DONE BIT(11) +#define SB_CRYPTO_BUSY BIT(10) +#define OTP_WP_EN BIT(9) +#define OTP_ADDR_WP_EN BIT(8) +#define LOW_SEC_KEY_EN BIT(7) +#define SECURE_BOOT_EN BIT(6) +#define UART_BOOT_EN BIT(5) +/* bit 4 reserved*/ +#define OTP_CHARGE_PUMP_READY BIT(3) +#define OTP_IDLE BIT(2) +#define OTP_MEM_IDLE BIT(1) +#define OTP_COMPARE_STATUS BIT(0) + +/* QSR */ +#define QSR_RSA_MASK (0x3 << 12) +#define QSR_HASH_MASK (0x3 << 10) +static uint64_t aspeed_sbc_read (void *opaque,hwaddr addr,unsigned int size) {AspeedSBCState *s =ASPEED_SBC (opaque);@@ -80,8 +102,17 @@ static void aspeed_sbc_reset(DeviceState *dev)memset (s->regs,0 ,sizeof (s->regs));/* Set secure boot enabled with RSA4096_SHA256 and enable eMMC ABR */ - s->regs[R_STATUS ] =0x000044C6 ; - s->regs[R_QSR ] =0x07C07C89 ; + s->regs[R_STATUS ] =OTP_IDLE |OTP_MEM_IDLE ; + +if (s->emmc_abr) { + s->regs[R_STATUS ] &=ABR_EN ; + } + +if (s->signing_settings) { + s->regs[R_STATUS ] &=SECURE_BOOT_EN ; + } + + s->regs[R_QSR ] = s->signing_settings; }static void aspeed_sbc_realize (DeviceState *dev,Error **errp)@@ -105,6 +136,11 @@ static const VMStateDescription vmstate_aspeed_sbc = { } };
Quoted 7 lines
hw/misc/aspeed_sbc.c static const VMStateDescription vmstate_aspeed_sbc = { · line 142
Quoted 4 lines
hw/misc/aspeed_sbc.c +4
-0+static Property aspeed_sbc_properties[] = { +DEFINE_PROP_BOOL ("emmc-abr" , AspeedSBCState, emmc_abr,0 ), +DEFINE_PROP_UINT32 ("signing-settings" , AspeedSBCState, signing_settings,0 ), +};This needs a
DEFINE_PROP_END_OF_LIST(), I bisected to this commit in Cedric's aspeed-7.1 branch.
Ah you did also ! Sorry I should have told. The problem only showed on f35 using clang, and I didn't notice until I pushed the branch on gitlab yersterday.
Quoted 2 lines
Reviewed-by Peter Delevoryas <[email protected]>Tested-by Peter Delevoryas <[email protected]>
I will include the patch in the next PR.
Thanks,
C.
Quoted 16 lines
Quoted 16 lines
hw/misc/aspeed_sbc.c +2
-0+static void aspeed_sbc_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);@@ -112,6 +148,7 @@ static void aspeed_sbc_class_init(ObjectClass *klass, void *data) dc->realize = aspeed_sbc_realize; dc->reset = aspeed_sbc_reset; dc->vmsd = &vmstate_aspeed_sbc; +device_class_set_props (dc, aspeed_sbc_properties); }static const TypeInfo aspeed_sbc_info = {Signature · 1 line
2.35.3
Re: [PATCH 3/3] aspeed: sbc: Allow per-machine settings
Quoted 110 lines · Cédric Le Goater
Quoted 100 lines · Peter Delevoryas
Quoted 99 lines · Cédric Le Goater
From: Joel Stanley <[email protected]>
In order to correctly report secure boot running firmware the values of certain registers must be set.
We don't yet have documentation from ASPEED on what they mean. The meaning is inferred from u-boot's use of them.
Introduce properties so the settings can be configured per-machine.
Signed-off-by Joel Stanley <[email protected]>Signed-off-by Cédric Le Goater <[email protected]>--- include/hw/misc/aspeed_sbc.h | 13 ++++++++++++ hw/misc/aspeed_sbc.c | 41 ++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-)include/hw/misc/aspeed_sbc.h +13
-0@@ -17,9 +17,22 @@ OBJECT_DECLARE_TYPE(AspeedSBCState, AspeedSBCClass, ASPEED_SBC)#define ASPEED_SBC_NR_REGS (0x93c >> 2) +#define QSR_AES BIT(27) +#define QSR_RSA1024 (0x0 << 12) +#define QSR_RSA2048 (0x1 << 12) +#define QSR_RSA3072 (0x2 << 12) +#define QSR_RSA4096 (0x3 << 12) +#define QSR_SHA224 (0x0 << 10) +#define QSR_SHA256 (0x1 << 10) +#define QSR_SHA384 (0x2 << 10) +#define QSR_SHA512 (0x3 << 10) +struct AspeedSBCState {SysBusDevice parent; +bool emmc_abr; +uint32_t signing_settings; +MemoryRegion iomem;uint32_t regs[ASPEED_SBC_NR_REGS ];hw/misc/aspeed_sbc.c +33
-2@@ -11,6 +11,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "qemu/error-report.h" +#include "hw/qdev-properties.h" #include "hw/misc/aspeed_sbc.h" #include "qapi/error.h" #include "migration/vmstate.h" @@ -19,6 +20,27 @@#define R_STATUS (0x014 / 4)#define R_QSR (0x040 / 4) +/* R_STATUS */ +#define ABR_EN BIT(14)/* Mirrors SCU510[11] */ +#define ABR_IMAGE_SOURCE BIT(13) +#define SPI_ABR_IMAGE_SOURCE BIT(12) +#define SB_CRYPTO_KEY_EXP_DONE BIT(11) +#define SB_CRYPTO_BUSY BIT(10) +#define OTP_WP_EN BIT(9) +#define OTP_ADDR_WP_EN BIT(8) +#define LOW_SEC_KEY_EN BIT(7) +#define SECURE_BOOT_EN BIT(6) +#define UART_BOOT_EN BIT(5) +/* bit 4 reserved*/ +#define OTP_CHARGE_PUMP_READY BIT(3) +#define OTP_IDLE BIT(2) +#define OTP_MEM_IDLE BIT(1) +#define OTP_COMPARE_STATUS BIT(0) + +/* QSR */ +#define QSR_RSA_MASK (0x3 << 12) +#define QSR_HASH_MASK (0x3 << 10) +static uint64_t aspeed_sbc_read (void *opaque,hwaddr addr,unsigned int size) {AspeedSBCState *s =ASPEED_SBC (opaque);@@ -80,8 +102,17 @@ static void aspeed_sbc_reset(DeviceState *dev)memset (s->regs,0 ,sizeof (s->regs));/* Set secure boot enabled with RSA4096_SHA256 and enable eMMC ABR */ - s->regs[R_STATUS ] =0x000044C6 ; - s->regs[R_QSR ] =0x07C07C89 ; + s->regs[R_STATUS ] =OTP_IDLE |OTP_MEM_IDLE ; + +if (s->emmc_abr) { + s->regs[R_STATUS ] &=ABR_EN ; + } + +if (s->signing_settings) { + s->regs[R_STATUS ] &=SECURE_BOOT_EN ; + } + + s->regs[R_QSR ] = s->signing_settings; }static void aspeed_sbc_realize (DeviceState *dev,Error **errp)@@ -105,6 +136,11 @@ static const VMStateDescription vmstate_aspeed_sbc = { }Quoted 8 lines
hw/misc/aspeed_sbc.c static const VMStateDescription vmstate_aspeed_sbc = { · line 142
Quoted 5 lines
hw/misc/aspeed_sbc.c +4
-0}; +static Property aspeed_sbc_properties[] = { +DEFINE_PROP_BOOL ("emmc-abr" , AspeedSBCState, emmc_abr,0 ), +DEFINE_PROP_UINT32 ("signing-settings" , AspeedSBCState, signing_settings,0 ), +};This needs a
DEFINE_PROP_END_OF_LIST(), I bisected to this commit in Cedric's aspeed-7.1 branch.
Quoted 3 lines
Ah you did also ! Sorry I should have told. The problem only showed on f35 using clang, and I didn't notice until I pushed the branch on gitlab yersterday.
Oh glad you noticed too, it's no problem.
Quoted 5 lines
Quoted 3 lines
Reviewed-by Peter Delevoryas <[email protected]>Tested-by Peter Delevoryas <[email protected]>I will include the patch in the next PR.
That's great, thanks!
Quoted 22 lines
Thanks,
C.
Quoted 15 lines
Quoted 15 lines
hw/misc/aspeed_sbc.c +2
-0+static void aspeed_sbc_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);@@ -112,6 +148,7 @@ static void aspeed_sbc_class_init(ObjectClass *klass, void *data) dc->realize = aspeed_sbc_realize; dc->reset = aspeed_sbc_reset; dc->vmsd = &vmstate_aspeed_sbc; +device_class_set_props (dc, aspeed_sbc_properties); }static const TypeInfo aspeed_sbc_info = {Signature · 1 line
2.35.3