|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 2/2] xen/riscv: fix the base ISA checks in riscv_isa_parse_string()
riscv_isa_parse_string() is meant to reject a riscv,isa string which
doesn't start with "rv32" or "rv64" (depending on Xen's bitness), but
the checks are written with && instead of ||, so a string is rejected
only when both characters of a pair are wrong. As a result, e.g.
"xv64i" or "rv62i" is accepted on RV64. Also, for a string as short as
"rv", isa[3] is read past the terminating NUL.
Use || so that each character is checked.
Fixes: f74ebf58b518 ("xen/riscv: identify specific ISA supported by cpu")
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
xen/arch/riscv/cpufeature.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c
index c4983ccdf3da..495cf3f655ba 100644
--- a/xen/arch/riscv/cpufeature.c
+++ b/xen/arch/riscv/cpufeature.c
@@ -261,14 +261,14 @@ static void __init match_isa_ext(const char *name, const
char *name_end,
static int __init riscv_isa_parse_string(const char *isa,
unsigned long *out_bitmap)
{
- if ( (isa[0] != 'r') && (isa[1] != 'v') )
+ if ( (isa[0] != 'r') || (isa[1] != 'v') )
return -EINVAL;
#if defined(CONFIG_RISCV_32)
- if ( isa[2] != '3' && isa[3] != '2' )
+ if ( (isa[2] != '3') || (isa[3] != '2') )
return -EINVAL;
#elif defined(CONFIG_RISCV_64)
- if ( isa[2] != '6' && isa[3] != '4' )
+ if ( (isa[2] != '6') || (isa[3] != '4') )
return -EINVAL;
#else
# error "unsupported RISC-V bitness"
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |