Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libnvmm Handle REPN. FreeBSD has a "repn movs", which is...



details:   https://anonhg.NetBSD.org/src/rev/c1e497ede206
branches:  trunk
changeset: 995865:c1e497ede206
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue Jan 08 07:34:22 2019 +0000

description:
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.

diffstat:

 lib/libnvmm/libnvmm_x86.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (37 lines):

diff -r 03b07367b33d -r c1e497ede206 lib/libnvmm/libnvmm_x86.c
--- a/lib/libnvmm/libnvmm_x86.c Tue Jan 08 07:29:46 2019 +0000
+++ b/lib/libnvmm/libnvmm_x86.c Tue Jan 08 07:34:22 2019 +0000
@@ -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 @@
                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 @@
                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;



Home | Main Index | Thread Index | Old Index