From nobody Sun Nov 08 16:18:31 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jMylC6Xlmz6ybV7 for ; Sun, 08 Nov 2026 16:18:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jMylC4ndxz4Gf6 for ; Sun, 08 Nov 2026 16:18:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794154711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Yq5FlO4jsXyML1vwP7tc3VrRVIr+pXxbB+RsJ0Ek9FM=; b=wbZFRsW1pRYwJsoxWY+VbMj6rZfl3SIX9gq4RqWc6b+1Yki8kKL9cKp3U7dt/79PjQTjiz Mc1088c7PwsSDmJjuq7QF+m1OuZMcQXkMYVdM22iR4Y6B6YxGvbHSSbGD9xLRokEVUgBEd 0afAXcsECaznSyysY/xjJ3adwMnPWRR1LwJAEJO+SCYFGbBx9zmiEsjB7IP9xpLZ3HRTm5 JOXqUfY96z+zogD84ZlVUnw2Xcwzd7NV9L56Q3z/mYXMVGoJD5vJ/p1Uxhtn3z9hgNGjj0 v5ASt2sPrB/Rg1IqbgQXb8MtQJHrutvLi7gT3MtdHsVCovA3lzKEBNmCu0F2Gg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794154711; b=SA9CVpV3ruxhlVpa9vL1Y18ib9GKFn3gBr6yzGe2JmOWMnh6eqdY6ZLtixHazdIQFNvYk9 bXIQglqboUsi09TyxubixqeHz+o9WUjsMxa4UgITtRRY7KSnHPGePiEDYrZ3pbptmQBfTs U89g/EoeqqT3/ayyu2pkLDyEetPKJgETm95oyX2TeDIuI6lfLwH74F8YsQ9l2AeNSrNAXJ 0nQCZA4HJERJGA91X1URS60fLJJ9c1pSY+poYXms+JHQ0/+ttR+IIu5rbTyePhLini/KVE 8T4sEtmfWf48fm8hrlIAxR/ZlLSxefBEswGGE+1e4MOePuwoSaIBjP57cVOtCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794154711; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Yq5FlO4jsXyML1vwP7tc3VrRVIr+pXxbB+RsJ0Ek9FM=; b=U1NPlaAKZiGHMszuzmLSv33Jv8xW6OBvCCT+ewVIWCHWu6k/IvArmHleACoWJ5xOhBFeYa Y4u5leb8pQZ/+A8N7o59xOuv86I7cOuCDfK+Z8S0yqsZmz+aRKnA/tw+S4avaalXSByRfs Xu6/WaXpO4/Nguv8k25RlDF+i4I+sLSsNAzm4Uk4mCGso2iOWpu8dy24I5IK7rYQykm/eU rXP6lSpL5+vKmuT7o7RQ9EyruXUeu7ENMt3UJ5x4W4M8xokVyVaJ8vM+IGsfla5DD187mK fwC+eODYgrWKKimuZvtpSn+6fTo9zZPV1m+QmA/yN/oAQ6img+gmDPViokUBGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jMylC3jjlz1F72 for ; Sun, 08 Nov 2026 16:18:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 13596 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 08 Nov 2026 16:18:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Wanpeng Qian From: Mark Johnston Subject: git: 8e7f9aa97b3e - main - vmm: Emulate the byte forms of OR and AND with an immediate List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8e7f9aa97b3e886afc2c445bb51c4d781a106a1e Auto-Submitted: auto-generated Date: Sun, 08 Nov 2026 16:18:31 +0000 Message-Id: <6af0a0d7.13596.2d7926d@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8e7f9aa97b3e886afc2c445bb51c4d781a106a1e commit 8e7f9aa97b3e886afc2c445bb51c4d781a106a1e Author: Wanpeng Qian AuthorDate: 2026-11-08 16:05:04 +0000 Commit: Mark Johnston CommitDate: 2026-11-08 16:18:14 +0000 vmm: Emulate the byte forms of OR and AND with an immediate Opcode 0x80 (group 1: r/m8, imm8) is in the decode table and emulate_cmp() handles 80 /7, but emulate_or() and emulate_and() only accept 0x81 and 0x83. An "or byte ptr [mem], imm8" or "and byte ptr [mem], imm8" on emulated memory therefore fails with EINVAL and bhyve stops the guest with "Failed to emulate instruction sequence [ 80 ... ]". Seen with macOS: VoodooHDA starts the HDA controller's CORB with "or byte [rax+0x4c], 2" (CORBCTL |= CORBRUN), and the guest died at the first sound. Accept 0x80 in both, with a one byte operand as emulate_cmp() does. The file is shared with bhyve(8), so the fix covers the in-kernel devices (HPET, local APIC without APICv, I/O APIC) and the user space device models alike. Signed-off-by: Wanpeng Qian Reviewed by: markj MFC after: 1 week Sponsored by: keelos.dev Differential Revision: https://reviews.freebsd.org/D60997 --- 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 963da132c36b..b588b3618764 100644 --- a/sys/amd64/vmm/vmm_instruction_emul.c +++ b/sys/amd64/vmm/vmm_instruction_emul.c @@ -1040,12 +1040,16 @@ emulate_and(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, result = val1 & val2; error = vie_update_register(vcpu, reg, result, size); break; + case 0x80: case 0x81: case 0x83: /* * AND mem (ModRM:r/m) with immediate and store the * result in mem. * + * 80 /4 and r/m8, imm8 + * REX + 80 /4 and r/m8, imm8 + * * 81 /4 and r/m16, imm16 * 81 /4 and r/m32, imm32 * REX.W + 81 /4 and r/m64, imm32 sign-extended to 64 @@ -1054,6 +1058,8 @@ emulate_and(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, * 83 /4 and r/m32, imm8 sign-extended to 32 * REX.W + 83/4 and r/m64, imm8 sign-extended to 64 */ + if (vie->op.op_byte == 0x80) + size = 1; /* get the first operand */ error = memread(vcpu, gpa, &val1, size, arg); @@ -1128,12 +1134,16 @@ emulate_or(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, result = val1 | val2; error = vie_update_register(vcpu, reg, result, size); break; + case 0x80: case 0x81: case 0x83: /* * OR mem (ModRM:r/m) with immediate and store the * result in mem. * + * 80 /1 or r/m8, imm8 + * REX + 80 /1 or r/m8, imm8 + * * 81 /1 or r/m16, imm16 * 81 /1 or r/m32, imm32 * REX.W + 81 /1 or r/m64, imm32 sign-extended to 64 @@ -1142,6 +1152,8 @@ emulate_or(struct vcpu *vcpu, uint64_t gpa, struct vie *vie, * 83 /1 or r/m32, imm8 sign-extended to 32 * REX.W + 83/1 or r/m64, imm8 sign-extended to 64 */ + if (vie->op.op_byte == 0x80) + size = 1; /* get the first operand */ error = memread(vcpu, gpa, &val1, size, arg);