On 12/3/2024 7:49 PM, Borislav Petkov wrote: > On Tue, Dec 03, 2024 at 02:30:33PM +0530, Nikunj A Dadhania wrote: >> @@ -458,6 +456,20 @@ void set_pte_enc_mask(pte_t *kpte, unsigned long pfn, pgprot_t new_prot); >> void snp_kexec_finish(void); >> void snp_kexec_begin(void); >> >> +static inline bool snp_is_vmpck_empty(struct snp_msg_desc *mdesc) >> +{ >> + static const char zero_key[VMPCK_KEY_LEN] = {0}; >> + >> + if (mdesc->vmpck) >> + return !memcmp(mdesc->vmpck, zero_key, VMPCK_KEY_LEN); >> + >> + return true; >> +} > > This function looks silly in a header with that array allocation. > > I think you should simply do: > > if (memchr_inv(mdesc->vmpck, 0, VMPCK_KEY_LEN)) Just a minor nit, it will need a negation: if (!memchr_inv(mdesc->vmpck, 0, VMPCK_KEY_LEN)) > at the call sites and not have this helper at all. > > But please do verify whether what I'm saying actually makes sense and if it > does, this can be a cleanup pre-patch. Yes, it makes sense. I have verified the code and below is the cleanup pre-patch.