[PATCH RFC 3/7] KVM: nVMX: add I/O exit ECX, ESI, EDI, EIP vmcs12 fields

Vitaly Kuznetsov
2017-12-18T17:18:12Z

From: Ladi Prosek <lprosek@redhat.com>

These non-synthetic VMCS fields were not supported by KVM thus far. The
layout is according to Hyper-V TLFS 5.0b, the physical encoding according
to the Intel SDM.

Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
arch/x86/include/asm/vmx.h | 4 ++++
arch/x86/kvm/vmx.c | 9 ++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 8b6780751132..92a10aa839e6 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -298,6 +298,10 @@ enum vmcs_field {
CR3_TARGET_VALUE2 = 0x0000600c,
CR3_TARGET_VALUE3 = 0x0000600e,
EXIT_QUALIFICATION = 0x00006400,
+ EXIT_IO_INSTR_ECX = 0x00006402,
+ EXIT_IO_INSTR_ESI = 0x00006404,
+ EXIT_IO_INSTR_EDI = 0x00006406,
+ EXIT_IO_INSTR_EIP = 0x00006408,
GUEST_LINEAR_ADDRESS = 0x0000640a,
GUEST_CR0 = 0x00006800,
GUEST_CR3 = 0x00006802,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index cd5f29a57880..f3215b6a0531 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -391,7 +391,10 @@ struct __packed vmcs12 {
u32 vmx_instruction_info;

natural_width exit_qualification;
- natural_width padding64_3[4];
+ natural_width exit_io_instr_ecx;
+ natural_width exit_io_instr_esi;
+ natural_width exit_io_instr_edi;
+ natural_width exit_io_instr_eip;

natural_width guest_linear_address;
natural_width guest_rsp;
@@ -913,6 +916,10 @@ static const unsigned short vmcs_field_to_offset_table[] = {
FIELD(CR3_TARGET_VALUE2, cr3_target_value2),
FIELD(CR3_TARGET_VALUE3, cr3_target_value3),
FIELD(EXIT_QUALIFICATION, exit_qualification),
+ FIELD(EXIT_IO_INSTR_ECX, exit_io_instr_ecx),
+ FIELD(EXIT_IO_INSTR_ESI, exit_io_instr_esi),
+ FIELD(EXIT_IO_INSTR_EDI, exit_io_instr_edi),
+ FIELD(EXIT_IO_INSTR_EIP, exit_io_instr_eip),
FIELD(GUEST_LINEAR_ADDRESS, guest_linear_address),
FIELD(GUEST_CR0, guest_cr0),
FIELD(GUEST_CR3, guest_cr3),
--
2.14.3