Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Fix two issues:
details: https://anonhg.NetBSD.org/src/rev/1154b6438189
branches: trunk
changeset: 448386:1154b6438189
user: maxv <maxv%NetBSD.org@localhost>
date: Fri Feb 01 06:49:58 2019 +0000
description:
Fix two issues:
* Uh I put the wrong masks in some GPRs, fuck.
* When the opsize of MOVZX is 4, we need to combine the zero-extend from
the instruction with the natural zero-extend of long mode.
Add two associated tests.
diffstat:
lib/libnvmm/libnvmm_x86.c | 33 +++++++++++++++++++--------------
tests/lib/libnvmm/h_mem_assist.c | 4 ++++
tests/lib/libnvmm/h_mem_assist_asm.S | 25 +++++++++++++++++++++++++
3 files changed, 48 insertions(+), 14 deletions(-)
diffs (196 lines):
diff -r 12e3950276d5 -r 1154b6438189 lib/libnvmm/libnvmm_x86.c
--- a/lib/libnvmm/libnvmm_x86.c Fri Feb 01 05:44:29 2019 +0000
+++ b/lib/libnvmm/libnvmm_x86.c Fri Feb 01 06:49:58 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: libnvmm_x86.c,v 1.17 2019/01/27 02:08:35 pgoyette Exp $ */
+/* $NetBSD: libnvmm_x86.c,v 1.18 2019/02/01 06:49:58 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -1489,7 +1489,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_RAX, 0x00000000FFFFFFFF }, /* RAX */
+ [7] = { NVMM_X64_GPR_RAX, 0xFFFFFFFFFFFFFFFF }, /* RAX */
},
[0b001] = {
[0] = { NVMM_X64_GPR_RCX, 0x00000000000000FF }, /* CL */
@@ -1499,7 +1499,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_RCX, 0x00000000FFFFFFFF }, /* RCX */
+ [7] = { NVMM_X64_GPR_RCX, 0xFFFFFFFFFFFFFFFF }, /* RCX */
},
[0b010] = {
[0] = { NVMM_X64_GPR_RDX, 0x00000000000000FF }, /* DL */
@@ -1509,7 +1509,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_RDX, 0x00000000FFFFFFFF }, /* RDX */
+ [7] = { NVMM_X64_GPR_RDX, 0xFFFFFFFFFFFFFFFF }, /* RDX */
},
[0b011] = {
[0] = { NVMM_X64_GPR_RBX, 0x00000000000000FF }, /* BL */
@@ -1519,7 +1519,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_RBX, 0x00000000FFFFFFFF }, /* RBX */
+ [7] = { NVMM_X64_GPR_RBX, 0xFFFFFFFFFFFFFFFF }, /* RBX */
},
[0b100] = {
[0] = { -1, 0 }, /* SPECIAL */
@@ -1572,7 +1572,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R8, 0x00000000FFFFFFFF }, /* R8 */
+ [7] = { NVMM_X64_GPR_R8, 0xFFFFFFFFFFFFFFFF }, /* R8 */
},
[0b001] = {
[0] = { NVMM_X64_GPR_R9, 0x00000000000000FF }, /* R9B */
@@ -1582,7 +1582,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R9, 0x00000000FFFFFFFF }, /* R9 */
+ [7] = { NVMM_X64_GPR_R9, 0xFFFFFFFFFFFFFFFF }, /* R9 */
},
[0b010] = {
[0] = { NVMM_X64_GPR_R10, 0x00000000000000FF }, /* R10B */
@@ -1592,7 +1592,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R10, 0x00000000FFFFFFFF }, /* R10 */
+ [7] = { NVMM_X64_GPR_R10, 0xFFFFFFFFFFFFFFFF }, /* R10 */
},
[0b011] = {
[0] = { NVMM_X64_GPR_R11, 0x00000000000000FF }, /* R11B */
@@ -1602,7 +1602,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R11, 0x00000000FFFFFFFF }, /* R11 */
+ [7] = { NVMM_X64_GPR_R11, 0xFFFFFFFFFFFFFFFF }, /* R11 */
},
[0b100] = {
[0] = { NVMM_X64_GPR_R12, 0x00000000000000FF }, /* R12B */
@@ -1612,7 +1612,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R12, 0x00000000FFFFFFFF }, /* R12 */
+ [7] = { NVMM_X64_GPR_R12, 0xFFFFFFFFFFFFFFFF }, /* R12 */
},
[0b101] = {
[0] = { NVMM_X64_GPR_R13, 0x00000000000000FF }, /* R13B */
@@ -1622,7 +1622,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R13, 0x00000000FFFFFFFF }, /* R13 */
+ [7] = { NVMM_X64_GPR_R13, 0xFFFFFFFFFFFFFFFF }, /* R13 */
},
[0b110] = {
[0] = { NVMM_X64_GPR_R14, 0x00000000000000FF }, /* R14B */
@@ -1632,7 +1632,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R14, 0x00000000FFFFFFFF }, /* R14 */
+ [7] = { NVMM_X64_GPR_R14, 0xFFFFFFFFFFFFFFFF }, /* R14 */
},
[0b111] = {
[0] = { NVMM_X64_GPR_R15, 0x00000000000000FF }, /* R15B */
@@ -1642,7 +1642,7 @@
[4] = { -1, 0 },
[5] = { -1, 0 },
[6] = { -1, 0 },
- [7] = { NVMM_X64_GPR_R15, 0x00000000FFFFFFFF }, /* R15 */
+ [7] = { NVMM_X64_GPR_R15, 0xFFFFFFFFFFFFFFFF }, /* R15 */
},
}
};
@@ -2267,12 +2267,17 @@
instr->operand_size = get_operand_size(fsm, instr);
instr->address_size = get_address_size(fsm, instr);
+ if (fsm->is64bit && (instr->operand_size == 4)) {
+ /* Zero-extend to 64 bits. */
+ instr->zeroextend_mask = ~size_to_mask(4);
+ }
+
if (opcode->flags & FLAG_ze) {
/*
* Compute the mask for zero-extend. Update the operand size,
* we move fewer bytes.
*/
- instr->zeroextend_mask = size_to_mask(instr->operand_size);
+ instr->zeroextend_mask |= size_to_mask(instr->operand_size);
instr->zeroextend_mask &= ~size_to_mask(opcode->defsize);
instr->operand_size = opcode->defsize;
}
diff -r 12e3950276d5 -r 1154b6438189 tests/lib/libnvmm/h_mem_assist.c
--- a/tests/lib/libnvmm/h_mem_assist.c Fri Feb 01 05:44:29 2019 +0000
+++ b/tests/lib/libnvmm/h_mem_assist.c Fri Feb 01 06:49:58 2019 +0000
@@ -290,6 +290,8 @@
extern uint8_t test7_begin, test7_end;
extern uint8_t test8_begin, test8_end;
extern uint8_t test9_begin, test9_end;
+extern uint8_t test10_begin, test10_end;
+extern uint8_t test11_begin, test11_end;
static const struct test tests[] = {
{ "test1 - MOV", &test1_begin, &test1_end, 0x3004 },
@@ -301,6 +303,8 @@
{ "test7 - STOS", &test7_begin, &test7_end, 0x00123456 },
{ "test8 - LODS", &test8_begin, &test8_end, 0x12345678 },
{ "test9 - MOVS", &test9_begin, &test9_end, 0x12345678 },
+ { "test10 - MOVZXB", &test10_begin, &test10_end, 0x00000078 },
+ { "test11 - MOVZXW", &test11_begin, &test11_end, 0x00005678 },
{ NULL, NULL, NULL, -1 }
};
diff -r 12e3950276d5 -r 1154b6438189 tests/lib/libnvmm/h_mem_assist_asm.S
--- a/tests/lib/libnvmm/h_mem_assist_asm.S Fri Feb 01 05:44:29 2019 +0000
+++ b/tests/lib/libnvmm/h_mem_assist_asm.S Fri Feb 01 06:49:58 2019 +0000
@@ -36,6 +36,8 @@
.globl test7_begin, test7_end
.globl test8_begin, test8_end
.globl test9_begin, test9_end
+ .globl test10_begin, test10_end
+ .globl test11_begin, test11_end
.text
.code64
@@ -177,3 +179,26 @@
TEST_END
test9_end:
+ .align 64
+test10_begin:
+ movq $0x1000,%rax
+ movq $0x12345678,(%rax)
+
+ movq $0xFFFFFFFFFFFFFFFF,%rbx
+ movzxb (%rax),%ebx
+ movq %rbx,(%rax)
+
+ TEST_END
+test10_end:
+
+ .align 64
+test11_begin:
+ movq $0x1000,%rax
+ movq $0x12345678,(%rax)
+
+ movq $0xFFFFFFFFFFFFFFFF,%rbx
+ movzxw (%rax),%rbx
+ movq %rbx,(%rax)
+
+ TEST_END
+test11_end:
Home |
Main Index |
Thread Index |
Old Index