git: 20083496866c - stable/13 - vmm: Emulate testb imm8,r/m8

From: Jose Luis Duran <jlduran_at_FreeBSD.org>
Date: Tue, 11 Mar 2025 00:43:40 UTC
The branch stable/13 has been updated by jlduran:

URL: https://cgit.FreeBSD.org/src/commit/?id=20083496866c379aef98fc352a4b6fd49801894d

commit 20083496866c379aef98fc352a4b6fd49801894d
Author:     Jose Luis Duran <jlduran@FreeBSD.org>
AuthorDate: 2025-03-04 13:51:47 +0000
Commit:     Jose Luis Duran <jlduran@FreeBSD.org>
CommitDate: 2025-03-11 00:42:30 +0000

    vmm: Emulate testb imm8,r/m8
    
    Add support for "testb imm8,r/m8" emulation.
    
    PR:             261940
    PR:             282852
    Reviewed by:    markj, emaste
    Approved by:    emaste (mentor)
    Obtained from:  Illumos (https://www.illumos.org/issues/14483)
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D49208
    
    (cherry picked from commit 49a4838a0d94e145a826abf02aa03ff444e614e3)
---
 sys/amd64/vmm/vmm_instruction_emul.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 10661ba40c8c..ad46163ed377 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -234,6 +234,12 @@ static const struct vie_op one_byte_opcodes[256] = {
 		.op_byte = 0x8F,
 		.op_type = VIE_OP_TYPE_POP,
 	},
+	[0xF6] = {
+		/* XXX Group 3 extended opcode - not just TEST */
+		.op_byte = 0xF6,
+		.op_type = VIE_OP_TYPE_TEST,
+		.op_flags = VIE_OP_F_IMM8,
+	},
 	[0xF7] = {
 		/* XXX Group 3 extended opcode - not just TEST */
 		.op_byte = 0xF7,
@@ -1282,6 +1288,12 @@ emulate_test(VCPU_DECL, uint64_t gpa, struct vie *vie,
 	error = EINVAL;
 
 	switch (vie->op.op_byte) {
+	case 0xF6:
+		/*
+		 * F6 /0		test r/m8, imm8
+		 */
+		size = 1;	/* override for byte operation */
+		/* FALLTHROUGH */
 	case 0xF7:
 		/*
 		 * F7 /0		test r/m16, imm16