[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v1 5/7] x86/hvm: Move INSTR_* constants to hvm.h
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>
- Date: Fri, 22 May 2026 10:14:00 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mYq8Eq3IwKKX/eUYJnfz3JguYXQEaaaaBSAyij69T5I=; b=gqf4YQqzxvvQMblgPzM+pSwFz4Jjs+nj1onx1z0xpmyKauoA9iF4WuJEJqebGYHMnVVBikIvhn8yyi575USabBPdcvf5pup2chu3KkIg6bvapn30CzQLVKv6kHvj6Jltk9wYJY5pxaTlSbx0grAqzhq6RYuH2rIAFJzTZR8ZxW88sn1ezz5hYWs/mbmFjwsWAU5DxzybKRZjPhw7D6rgb2dCaHAHwML1D30wvLFNYgdsW3ozHrC0KRkBiOUguDDfzdmGRkkfoN1mLhMsilNfRqOBjPGYPbKiSIEtfYuwpZ2M4SwnU0iOmgyfl6zp+yPDOZ8W8L+Syh+Fq7b2w9CGfA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JuI3A4YbwgjE5ygkQuTp3ORNmDWuox9bO1SEIWnBvrut3fl7KUniy6CRiKQNFI15zxohwbqqy7JgHw+Bpll66JGYXMAmH80+/g166ZBiiINzoiQcKTmlUHv/VFgE7CJL7S8FQuGD/LHHDvccUvZMBs+dXRuEkQln0AdiyHD4K2zz1qLhU7AIT7yvJ60N+2RqWHALxqClBR6GJPF/Al8h0r6b0x/3CPo+/64bV0YIPGMRi64wCgkPHYJfgw8gKpFdtFva0V5HYPZqD3P1WgtyCUv8rSf31lDC2FcTBZkcQFlZ/FqLUurCTbrM8FKmtuJOvutA/nuYHNrYx9FfCmIjvg==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Fri, 22 May 2026 09:14:23 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 5/21/26 12:57 PM, Jan Beulich wrote:
On 21.05.2026 12:12, Ross Lagerwall wrote:
On 5/19/26 10:49 AM, Jan Beulich wrote:
On 18.05.2026 15:14, Ross Lagerwall wrote:
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -851,6 +851,35 @@ static inline void hvm_sync_pir_to_irr(struct vcpu *v)
alternative_vcall(hvm_funcs.sync_pir_to_irr, v);
}
+/*
+ * Encoding for svm_get_insn_len(). We take X86EMUL_OPC() for the main
+ * opcode, shifted left to make room for the ModRM byte.
With all of this moved, the comment wants adjusting, at the very least by
putting "e.g." in front of the function name.
+ * The Grp7 instructions have their ModRM byte expressed in octal for easier
+ * cross referencing with the opcode extension table.
+ */
+#define INSTR_ENC(opc, modrm) (((opc) << 8) | (modrm))
+
+#define INSTR_PAUSE INSTR_ENC(X86EMUL_OPC_F3(0, 0x90), 0)
+#define INSTR_INT3 INSTR_ENC(X86EMUL_OPC( 0, 0xcc), 0)
+#define INSTR_ICEBP INSTR_ENC(X86EMUL_OPC( 0, 0xf1), 0)
+#define INSTR_HLT INSTR_ENC(X86EMUL_OPC( 0, 0xf4), 0)
+#define INSTR_XSETBV INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0321) /* octal-ok
*/
+#define INSTR_VMRUN INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0330) /* octal-ok
*/
+#define INSTR_VMCALL INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0331) /* octal-ok
*/
+#define INSTR_VMLOAD INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0332) /* octal-ok
*/
+#define INSTR_VMSAVE INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0333) /* octal-ok
*/
+#define INSTR_STGI INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0334) /* octal-ok
*/
+#define INSTR_CLGI INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0335) /* octal-ok
*/
+#define INSTR_INVLPGA INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0337) /* octal-ok
*/
+#define INSTR_RDTSCP INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0371) /* octal-ok
*/
+#define INSTR_INVD INSTR_ENC(X86EMUL_OPC(0x0f, 0x08), 0)
+#define INSTR_WBINVD INSTR_ENC(X86EMUL_OPC(0x0f, 0x09), 0)
+#define INSTR_WRMSR INSTR_ENC(X86EMUL_OPC(0x0f, 0x30), 0)
+#define INSTR_RDTSC INSTR_ENC(X86EMUL_OPC(0x0f, 0x31), 0)
+#define INSTR_RDMSR INSTR_ENC(X86EMUL_OPC(0x0f, 0x32), 0)
+#define INSTR_CPUID INSTR_ENC(X86EMUL_OPC(0x0f, 0xa2), 0)
+
#else /* CONFIG_HVM */
I further wonder whether putting this in hvm.h is a good idea. Is there
anything wrong with using a brand new header, e.g. instr-enc.h?
No objection to that. I do wonder though if using the instruction encoding like
this is the best way of passing through the instruction to the fast path in
hvm_emulate_one_ctxt() since I think in some cases the instruction encoding
may not match the actual instruction that triggered the VMEXIT.
Do you have an example? If so, that would indeed be at risk of being misleading
or actively confusing. (Of course INSTR_VMCALL wants renaming, as was already
suggested.)
VMEXIT_CR0_READ may be triggered by MOV-from-CR or SMSW. There are probably
other examples...
Ross
|