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.
This commit is contained in:
maxv 2019-01-08 07:34:22 +00:00
parent 15c784a479
commit 06484a82be
1 changed files with 6 additions and 7 deletions

View File

@ -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 *mach, nvmm_cpuid_t cpuid,
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 *mach, nvmm_cpuid_t cpuid,
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;