Skip to content

Commit 0f6a37d

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: Add a #define for the architectural max instruction length
JIRA: https://issues.redhat.com/browse/RHEL-95318 commit d4aea23 Author: Sean Christopherson <seanjc@google.com> Date: Fri Jan 31 17:55:15 2025 -0800 KVM: x86: Add a #define for the architectural max instruction length 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. Link: https://lore.kernel.org/r/20250201015518.689704-9-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent af1583e commit 0f6a37d

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

arch/x86/kvm/kvm_emulate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ struct operand {
273273
};
274274
};
275275

276+
#define X86_MAX_INSTRUCTION_LENGTH 15
277+
276278
struct fetch_cache {
277-
u8 data[15];
279+
u8 data[X86_MAX_INSTRUCTION_LENGTH];
278280
u8 *ptr;
279281
u8 *end;
280282
};

arch/x86/kvm/trace.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,12 +819,12 @@ TRACE_EVENT(kvm_emulate_insn,
819819
TP_ARGS(vcpu, failed),
820820

821821
TP_STRUCT__entry(
822-
__field( __u64, rip )
823-
__field( __u32, csbase )
824-
__field( __u8, len )
825-
__array( __u8, insn, 15 )
826-
__field( __u8, flags )
827-
__field( __u8, failed )
822+
__field( __u64, rip )
823+
__field( __u32, csbase )
824+
__field( __u8, len )
825+
__array( __u8, insn, X86_MAX_INSTRUCTION_LENGTH )
826+
__field( __u8, flags )
827+
__field( __u8, failed )
828828
),
829829

830830
TP_fast_assign(
@@ -835,7 +835,7 @@ TRACE_EVENT(kvm_emulate_insn,
835835
__entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len;
836836
memcpy(__entry->insn,
837837
vcpu->arch.emulate_ctxt->fetch.data,
838-
15);
838+
X86_MAX_INSTRUCTION_LENGTH);
839839
__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode);
840840
__entry->failed = failed;
841841
),

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2919,7 +2919,7 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
29192919
case INTR_TYPE_SOFT_EXCEPTION:
29202920
case INTR_TYPE_SOFT_INTR:
29212921
case INTR_TYPE_PRIV_SW_EXCEPTION:
2922-
if (CC(vmcs12->vm_entry_instruction_len > 15) ||
2922+
if (CC(vmcs12->vm_entry_instruction_len > X86_MAX_INSTRUCTION_LENGTH) ||
29232923
CC(vmcs12->vm_entry_instruction_len == 0 &&
29242924
CC(!nested_cpu_has_zero_length_injection(vcpu))))
29252925
return -EINVAL;

0 commit comments

Comments
 (0)