* [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour
@ 2020-05-05 9:01 Joel Stanley
2020-05-05 9:10 ` no-reply
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Joel Stanley @ 2020-05-05 9:01 UTC (permalink / raw)
To: Cédric Le Goater, Peter Maydell; +Cc: Andrew Jeffery, qemu-arm, qemu-devel
The AST2600 handles this differently with the extra 'hardlock' state, so
move the testing to the soc specific class' write callback.
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
hw/misc/aspeed_sdmc.c | 55 +++++++++++++++++++++++++++++++++++--------
1 file changed, 45 insertions(+), 10 deletions(-)
diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
index 02940e7c2a76..7c688becf8c7 100644
--- a/hw/misc/aspeed_sdmc.c
+++ b/hw/misc/aspeed_sdmc.c
@@ -23,7 +23,12 @@
/* Protection Key Register */
#define R_PROT (0x00 / 4)
+#define PROT_UNLOCKED 0x01
+#define PROT_HARDLOCKED 0x10 /* AST2600 */
+#define PROT_SOFTLOCKED 0x00
+
#define PROT_KEY_UNLOCK 0xFC600309
+#define PROT_KEY_HARDLOCK 0xDEADDEAD /* AST2600 */
/* Configuration Register */
#define R_CONF (0x04 / 4)
@@ -130,16 +135,6 @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data,
return;
}
- if (addr == R_PROT) {
- s->regs[addr] = (data == PROT_KEY_UNLOCK) ? 1 : 0;
- return;
- }
-
- if (!s->regs[R_PROT]) {
- qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
- return;
- }
-
asc->write(s, addr, data);
}
@@ -291,6 +286,16 @@ static uint32_t aspeed_2400_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
static void aspeed_2400_sdmc_write(AspeedSDMCState *s, uint32_t reg,
uint32_t data)
{
+ if (reg == R_PROT) {
+ s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED;
+ return;
+ }
+
+ if (!s->regs[R_PROT]) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
+ return;
+ }
+
switch (reg) {
case R_CONF:
data = aspeed_2400_sdmc_compute_conf(s, data);
@@ -339,6 +344,16 @@ static uint32_t aspeed_2500_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
static void aspeed_2500_sdmc_write(AspeedSDMCState *s, uint32_t reg,
uint32_t data)
{
+ if (reg == R_PROT) {
+ s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED;
+ return;
+ }
+
+ if (!s->regs[R_PROT]) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
+ return;
+ }
+
switch (reg) {
case R_CONF:
data = aspeed_2500_sdmc_compute_conf(s, data);
@@ -395,7 +410,27 @@ static uint32_t aspeed_2600_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
static void aspeed_2600_sdmc_write(AspeedSDMCState *s, uint32_t reg,
uint32_t data)
{
+ if (s->regs[R_PROT] == PROT_HARDLOCKED) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked until system reset!\n",
+ __func__);
+ return;
+ }
+
+ if (reg != R_PROT && s->regs[R_PROT] == PROT_SOFTLOCKED) {
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
+ return;
+ }
+
switch (reg) {
+ case R_PROT:
+ if (data == PROT_KEY_UNLOCK) {
+ data = PROT_UNLOCKED;
+ } else if (data == PROT_KEY_HARDLOCK) {
+ data = PROT_HARDLOCKED;
+ } else {
+ data = PROT_SOFTLOCKED;
+ }
+ break;
case R_CONF:
data = aspeed_2600_sdmc_compute_conf(s, data);
break;
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour
2020-05-05 9:01 [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour Joel Stanley
@ 2020-05-05 9:10 ` no-reply
2020-05-06 13:46 ` Cédric Le Goater
2020-05-11 10:01 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2020-05-05 9:10 UTC (permalink / raw)
To: joel; +Cc: andrew, peter.maydell, qemu-arm, clg, qemu-devel
Patchew URL: https://patchew.org/QEMU/20200505090136.341426-1-joel@jms.id.au/
Hi,
This series failed the asan build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===
The full log is available at
http://patchew.org/logs/20200505090136.341426-1-joel@jms.id.au/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour
2020-05-05 9:01 [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour Joel Stanley
2020-05-05 9:10 ` no-reply
@ 2020-05-06 13:46 ` Cédric Le Goater
2020-05-11 10:01 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2020-05-06 13:46 UTC (permalink / raw)
To: Joel Stanley, Peter Maydell; +Cc: Andrew Jeffery, qemu-arm, qemu-devel
On 5/5/20 11:01 AM, Joel Stanley wrote:
> The AST2600 handles this differently with the extra 'hardlock' state, so
> move the testing to the soc specific class' write callback.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/misc/aspeed_sdmc.c | 55 +++++++++++++++++++++++++++++++++++--------
> 1 file changed, 45 insertions(+), 10 deletions(-)
>
> diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c
> index 02940e7c2a76..7c688becf8c7 100644
> --- a/hw/misc/aspeed_sdmc.c
> +++ b/hw/misc/aspeed_sdmc.c
> @@ -23,7 +23,12 @@
>
> /* Protection Key Register */
> #define R_PROT (0x00 / 4)
> +#define PROT_UNLOCKED 0x01
> +#define PROT_HARDLOCKED 0x10 /* AST2600 */
> +#define PROT_SOFTLOCKED 0x00
> +
> #define PROT_KEY_UNLOCK 0xFC600309
> +#define PROT_KEY_HARDLOCK 0xDEADDEAD /* AST2600 */
>
> /* Configuration Register */
> #define R_CONF (0x04 / 4)
> @@ -130,16 +135,6 @@ static void aspeed_sdmc_write(void *opaque, hwaddr addr, uint64_t data,
> return;
> }
>
> - if (addr == R_PROT) {
> - s->regs[addr] = (data == PROT_KEY_UNLOCK) ? 1 : 0;
> - return;
> - }
> -
> - if (!s->regs[R_PROT]) {
> - qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
> - return;
> - }
> -
> asc->write(s, addr, data);
> }
>
> @@ -291,6 +286,16 @@ static uint32_t aspeed_2400_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
> static void aspeed_2400_sdmc_write(AspeedSDMCState *s, uint32_t reg,
> uint32_t data)
> {
> + if (reg == R_PROT) {
> + s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED;
> + return;
> + }
> +
> + if (!s->regs[R_PROT]) {
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
> + return;
> + }
> +
> switch (reg) {
> case R_CONF:
> data = aspeed_2400_sdmc_compute_conf(s, data);
> @@ -339,6 +344,16 @@ static uint32_t aspeed_2500_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
> static void aspeed_2500_sdmc_write(AspeedSDMCState *s, uint32_t reg,
> uint32_t data)
> {
> + if (reg == R_PROT) {
> + s->regs[reg] = (data == PROT_KEY_UNLOCK) ? PROT_UNLOCKED : PROT_SOFTLOCKED;
> + return;
> + }
> +
> + if (!s->regs[R_PROT]) {
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
> + return;
> + }
> +
> switch (reg) {
> case R_CONF:
> data = aspeed_2500_sdmc_compute_conf(s, data);
> @@ -395,7 +410,27 @@ static uint32_t aspeed_2600_sdmc_compute_conf(AspeedSDMCState *s, uint32_t data)
> static void aspeed_2600_sdmc_write(AspeedSDMCState *s, uint32_t reg,
> uint32_t data)
> {
> + if (s->regs[R_PROT] == PROT_HARDLOCKED) {
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked until system reset!\n",
> + __func__);
> + return;
> + }
> +
> + if (reg != R_PROT && s->regs[R_PROT] == PROT_SOFTLOCKED) {
> + qemu_log_mask(LOG_GUEST_ERROR, "%s: SDMC is locked!\n", __func__);
> + return;
> + }
> +
> switch (reg) {
> + case R_PROT:
> + if (data == PROT_KEY_UNLOCK) {
> + data = PROT_UNLOCKED;
> + } else if (data == PROT_KEY_HARDLOCK) {
> + data = PROT_HARDLOCKED;
> + } else {
> + data = PROT_SOFTLOCKED;
> + }
> + break;
> case R_CONF:
> data = aspeed_2600_sdmc_compute_conf(s, data);
> break;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour
2020-05-05 9:01 [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour Joel Stanley
2020-05-05 9:10 ` no-reply
2020-05-06 13:46 ` Cédric Le Goater
@ 2020-05-11 10:01 ` Peter Maydell
2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2020-05-11 10:01 UTC (permalink / raw)
To: Joel Stanley
Cc: Andrew Jeffery, qemu-arm, Cédric Le Goater, QEMU Developers
On Tue, 5 May 2020 at 10:01, Joel Stanley <joel@jms.id.au> wrote:
>
> The AST2600 handles this differently with the extra 'hardlock' state, so
> move the testing to the soc specific class' write callback.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
Applied to target-arm.next, thanks.
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-11 10:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-05 9:01 [PATCH] aspeed: sdmc: Implement AST2600 locking behaviour Joel Stanley
2020-05-05 9:10 ` no-reply
2020-05-06 13:46 ` Cédric Le Goater
2020-05-11 10:01 ` Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).