From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 08/11] KVM: x86: Add a #define for the architectural max instruction length
Date: Fri, 31 Jan 2025 17:55:15 -0800 [thread overview]
Message-ID: <20250201015518.689704-9-seanjc@google.com> (raw)
In-Reply-To: <20250201015518.689704-1-seanjc@google.com>
Add a #define to capture x86's architecturally defined max instruction
length instead of open coding the literal in a variety of places.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/kvm_emulate.h | 4 +++-
arch/x86/kvm/trace.h | 14 +++++++-------
arch/x86/kvm/vmx/nested.c | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
index 35029b12667f..c1df5acfacaf 100644
--- a/arch/x86/kvm/kvm_emulate.h
+++ b/arch/x86/kvm/kvm_emulate.h
@@ -275,8 +275,10 @@ struct operand {
};
};
+#define X86_MAX_INSTRUCTION_LENGTH 15
+
struct fetch_cache {
- u8 data[15];
+ u8 data[X86_MAX_INSTRUCTION_LENGTH];
u8 *ptr;
u8 *end;
};
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 0b844cb97978..ccda95e53f62 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -830,12 +830,12 @@ TRACE_EVENT(kvm_emulate_insn,
TP_ARGS(vcpu, failed),
TP_STRUCT__entry(
- __field( __u64, rip )
- __field( __u32, csbase )
- __field( __u8, len )
- __array( __u8, insn, 15 )
- __field( __u8, flags )
- __field( __u8, failed )
+ __field( __u64, rip )
+ __field( __u32, csbase )
+ __field( __u8, len )
+ __array( __u8, insn, X86_MAX_INSTRUCTION_LENGTH )
+ __field( __u8, flags )
+ __field( __u8, failed )
),
TP_fast_assign(
@@ -846,7 +846,7 @@ TRACE_EVENT(kvm_emulate_insn,
__entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len;
memcpy(__entry->insn,
vcpu->arch.emulate_ctxt->fetch.data,
- 15);
+ X86_MAX_INSTRUCTION_LENGTH);
__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode);
__entry->failed = failed;
),
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 8a7af02d466e..fb4fd96ce0f8 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -2970,7 +2970,7 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
case INTR_TYPE_SOFT_EXCEPTION:
case INTR_TYPE_SOFT_INTR:
case INTR_TYPE_PRIV_SW_EXCEPTION:
- if (CC(vmcs12->vm_entry_instruction_len > 15) ||
+ if (CC(vmcs12->vm_entry_instruction_len > X86_MAX_INSTRUCTION_LENGTH) ||
CC(vmcs12->vm_entry_instruction_len == 0 &&
CC(!nested_cpu_has_zero_length_injection(vcpu))))
return -EINVAL;
--
2.48.1.362.g079036d154-goog
next prev parent reply other threads:[~2025-02-01 1:55 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-01 1:55 [PATCH v2 00/11] KVM: x86: Fix emulation of (some) L2 instructions Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 01/11] KVM: nVMX: Check PAUSE_EXITING, not BUS_LOCK_DETECTION, on PAUSE emulation Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 02/11] KVM: nSVM: Pass next RIP, not current RIP, for nested VM-Exit on emulation Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 03/11] KVM: nVMX: Allow emulating RDPID on behalf of L2 Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 04/11] KVM: nVMX: Emulate HLT in L2 if it's not intercepted Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 05/11] KVM: nVMX: Consolidate missing X86EMUL_INTERCEPTED logic in L2 emulation Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 06/11] KVM: x86: Plumb the src/dst operand types through to .check_intercept() Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 07/11] KVM: x86: Plumb the emulator's starting RIP into nested intercept checks Sean Christopherson
2025-02-01 1:55 ` Sean Christopherson [this message]
2025-02-01 1:55 ` [PATCH v2 09/11] KVM: nVMX: Allow the caller to provide instruction length on nested VM-Exit Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 10/11] KVM: nVMX: Synthesize nested VM-Exit for supported emulation intercepts Sean Christopherson
2025-02-01 1:55 ` [PATCH v2 11/11] KVM: selftests: Add a nested (forced) emulation intercept test for x86 Sean Christopherson
2025-02-28 17:06 ` [PATCH v2 00/11] KVM: x86: Fix emulation of (some) L2 instructions Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250201015518.689704-9-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®