Skip to content

Commit 14f62ac

Browse files
zifeihanRealFYang
authored andcommitted
8324280: RISC-V: Incorrect implementation in VM_Version::parse_satp_mode
Backport-of: e7fdac9d5ce56d2f589df59a7fd2869e35ba2991
1 parent 7f40804 commit 14f62ac

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ void VM_Version::os_aux_features() {
168168
}
169169

170170
VM_Version::VM_MODE VM_Version::parse_satp_mode(const char* vm_mode) {
171-
if (!strcmp(vm_mode, "sv39")) {
171+
if (!strncmp(vm_mode, "sv39", sizeof "sv39" - 1)) {
172172
return VM_SV39;
173-
} else if (!strcmp(vm_mode, "sv48")) {
173+
} else if (!strncmp(vm_mode, "sv48", sizeof "sv48" - 1)) {
174174
return VM_SV48;
175-
} else if (!strcmp(vm_mode, "sv57")) {
175+
} else if (!strncmp(vm_mode, "sv57", sizeof "sv57" - 1)) {
176176
return VM_SV57;
177-
} else if (!strcmp(vm_mode, "sv64")) {
177+
} else if (!strncmp(vm_mode, "sv64", sizeof "sv64" - 1)) {
178178
return VM_SV64;
179179
} else {
180180
return VM_MBARE;
@@ -196,7 +196,7 @@ char* VM_Version::os_uarch_additional_features() {
196196
if ((p = strchr(buf, ':')) != nullptr) {
197197
if (mode == VM_NOTSET) {
198198
if (strncmp(buf, "mmu", sizeof "mmu" - 1) == 0) {
199-
mode = VM_Version::parse_satp_mode(p);
199+
mode = VM_Version::parse_satp_mode(p + 2);
200200
}
201201
}
202202
if (ret == nullptr) {

0 commit comments

Comments
 (0)