> > + u32 intr_info = vmcs12->vm_entry_intr_info_field; > > + u8 nr = intr_info & INTR_INFO_VECTOR_MASK; > Nit: I would rename 'nr' to 'vector' for better readability of the code. SGTM, will do. I used nr to be consistent with other parts of the code. That said, I agree that vector is more explicit and clear. > > + /* VM-entry interruption-info field: deliver error code */ > > + should_have_error_code = > > + intr_type == INTR_TYPE_HARD_EXCEPTION && > > + x86_exception_has_error_code(nr, prot_mode); > It's better to leave 'prot_mode' outside of the function as follows: > > should_have_error_code = > intr_type == INTR_TYPE_HARD_EXCEPTION && prot_mode && > x86_exception_has_error_code(nr); I think we should leave the helper as is because an exception can only have an error code in protected mode. > > + /* VM-entry exception error code */ > > + if (has_error_code && > > + vmcs12->vm_entry_exception_error_code & GENMASK(31, 15)) > > + return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > I would move this check above where 'delivery error code' is because > this check is related to that. Sure, will do. > > +static inline bool x86_exception_has_error_code(unsigned int nr, > > + bool protected_mode) > > +{ > > + static u32 exception_has_error_code = BIT(DF_VECTOR) | BIT(TS_VECTOR) | > > + BIT(NP_VECTOR) | BIT(SS_VECTOR) | BIT(GP_VECTOR) | > > + BIT(PF_VECTOR) | BIT(AC_VECTOR); > > + > > + return protected_mode && ((1U << nr) & exception_has_error_code); > Should it be (nr & exception_has_error_code) instead of ((1U << nr) & > exception_has_error_code) ? No, nr is a vector's absolute number, as defined in arch/x86/include/uapi/asm/kvm.h. For example, '#define GP_VECTOR 13'.