]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Add a #define for the architectural max instruction length
authorSean Christopherson <seanjc@google.com>
Sat, 1 Feb 2025 01:55:15 +0000 (17:55 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 24 Feb 2025 17:01:07 +0000 (09:01 -0800)
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>
arch/x86/kvm/kvm_emulate.h
arch/x86/kvm/trace.h
arch/x86/kvm/vmx/nested.c

index 35029b12667f2b7798ee9b83c4d0e1c868c16398..c1df5acfacaffac3b4b1107c32969efbeee0515e 100644 (file)
@@ -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;
 };
index 0b844cb97978a5c1d89c0eb3806f6ef70310093e..ccda95e53f626dcb472cf0964c14e71e56e5b5dd 100644 (file)
@@ -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;
                ),
index bca2575837ceac9531ca6c5b441adb1531e07515..e5c17fba65070418705e98291fc419bd61b1219a 100644 (file)
@@ -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;