Skip to content

Commit 65b71cc

Browse files
cmuellnerpalmer-dabbelt
authored andcommitted
riscv: T-Head: Test availability bit before enabling MAE errata
T-Head's memory attribute extension (XTheadMae) (non-compatible equivalent of RVI's Svpbmt) is currently assumed for all T-Head harts. However, QEMU recently decided to drop acceptance of guests that write reserved bits in PTEs. As XTheadMae uses reserved bits in PTEs and Linux applies the MAE errata for all T-Head harts, this broke the Linux startup on QEMU emulations of the C906 emulation. This patch attempts to address this issue by testing the MAE-enable bit in the th.sxstatus CSR. This CSR is available in HW and can be emulated in QEMU. This patch also makes the XTheadMae probing mechanism reliable, because a test for the right combination of mvendorid, marchid, and mimpid is not sufficient to enable MAE. Reviewed-by: Conor Dooley <[email protected]> Signed-off-by: Christoph Müllner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6179d4a commit 65b71cc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arch/riscv/errata/thead/errata.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <asm/patch.h>
2020
#include <asm/vendorid_list.h>
2121

22+
#define CSR_TH_SXSTATUS 0x5c0
23+
#define SXSTATUS_MAEE _AC(0x200000, UL)
24+
2225
static bool errata_probe_mae(unsigned int stage,
2326
unsigned long arch_id, unsigned long impid)
2427
{
@@ -28,11 +31,14 @@ static bool errata_probe_mae(unsigned int stage,
2831
if (arch_id != 0 || impid != 0)
2932
return false;
3033

31-
if (stage == RISCV_ALTERNATIVES_EARLY_BOOT ||
32-
stage == RISCV_ALTERNATIVES_MODULE)
33-
return true;
34+
if (stage != RISCV_ALTERNATIVES_EARLY_BOOT &&
35+
stage != RISCV_ALTERNATIVES_MODULE)
36+
return false;
3437

35-
return false;
38+
if (!(csr_read(CSR_TH_SXSTATUS) & SXSTATUS_MAEE))
39+
return false;
40+
41+
return true;
3642
}
3743

3844
/*

0 commit comments

Comments
 (0)