Module Name: src
Committed By: maxv
Date: Tue Jan 8 07:34:22 UTC 2019
Modified Files:
src/lib/libnvmm: libnvmm_x86.c
Log Message:
Handle REPN. FreeBSD has a "repn movs", which is a bit unusual, but doesn't
seem illegal as far as I can tell from the AMD SDM.
With that, I can boot FreeBSD on Qemu+NVMM.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libnvmm/libnvmm_x86.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libnvmm/libnvmm_x86.c
diff -u src/lib/libnvmm/libnvmm_x86.c:1.13 src/lib/libnvmm/libnvmm_x86.c:1.14
--- src/lib/libnvmm/libnvmm_x86.c:1.13 Mon Jan 7 18:13:34 2019
+++ src/lib/libnvmm/libnvmm_x86.c Tue Jan 8 07:34:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: libnvmm_x86.c,v 1.13 2019/01/07 18:13:34 maxv Exp $ */
+/* $NetBSD: libnvmm_x86.c,v 1.14 2019/01/08 07:34:22 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -2902,11 +2902,6 @@ nvmm_assist_mem(struct nvmm_machine *mac
return -1;
}
- if (__predict_false(instr.legpref.repn)) {
- errno = ENODEV;
- return -1;
- }
-
if (instr.opcode->movs) {
ret = assist_mem_double(mach, &state, &instr);
} else {
@@ -2917,10 +2912,14 @@ nvmm_assist_mem(struct nvmm_machine *mac
return -1;
}
- if (instr.legpref.rep) {
+ if (instr.legpref.rep || instr.legpref.repn) {
cnt = rep_dec_apply(&state, instr.address_size);
if (cnt == 0) {
state.gprs[NVMM_X64_GPR_RIP] += instr.len;
+ } else if (__predict_false(instr.legpref.repn)) {
+ if (state.gprs[NVMM_X64_GPR_RFLAGS] & PSL_Z) {
+ state.gprs[NVMM_X64_GPR_RIP] += instr.len;
+ }
}
} else {
state.gprs[NVMM_X64_GPR_RIP] += instr.len;