Skip to content

Commit d4aea23

Browse files
committed
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>
1 parent 9aeb9d8 commit d4aea23

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
@@ -275,8 +275,10 @@ struct operand {
275275
};
276276
};
277277

278+
#define X86_MAX_INSTRUCTION_LENGTH 15
279+
278280
struct fetch_cache {
279-
u8 data[15];
281+
u8 data[X86_MAX_INSTRUCTION_LENGTH];
280282
u8 *ptr;
281283
u8 *end;
282284
};

arch/x86/kvm/trace.h

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

832832
TP_STRUCT__entry(
833-
__field( __u64, rip )
834-
__field( __u32, csbase )
835-
__field( __u8, len )
836-
__array( __u8, insn, 15 )
837-
__field( __u8, flags )
838-
__field( __u8, failed )
833+
__field( __u64, rip )
834+
__field( __u32, csbase )
835+
__field( __u8, len )
836+
__array( __u8, insn, X86_MAX_INSTRUCTION_LENGTH )
837+
__field( __u8, flags )
838+
__field( __u8, failed )
839839
),
840840

841841
TP_fast_assign(
@@ -846,7 +846,7 @@ TRACE_EVENT(kvm_emulate_insn,
846846
__entry->rip = vcpu->arch.emulate_ctxt->_eip - __entry->len;
847847
memcpy(__entry->insn,
848848
vcpu->arch.emulate_ctxt->fetch.data,
849-
15);
849+
X86_MAX_INSTRUCTION_LENGTH);
850850
__entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt->mode);
851851
__entry->failed = failed;
852852
),

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2970,7 +2970,7 @@ static int nested_check_vm_entry_controls(struct kvm_vcpu *vcpu,
29702970
case INTR_TYPE_SOFT_EXCEPTION:
29712971
case INTR_TYPE_SOFT_INTR:
29722972
case INTR_TYPE_PRIV_SW_EXCEPTION:
2973-
if (CC(vmcs12->vm_entry_instruction_len > 15) ||
2973+
if (CC(vmcs12->vm_entry_instruction_len > X86_MAX_INSTRUCTION_LENGTH) ||
29742974
CC(vmcs12->vm_entry_instruction_len == 0 &&
29752975
CC(!nested_cpu_has_zero_length_injection(vcpu))))
29762976
return -EINVAL;

0 commit comments

Comments
 (0)