Re: [PATCH v8 33/40] x86/compressed/64: add identity mapping for Confidential Computing blob

From: Borislav Petkov
Date: Tue Jan 25 2022 - 08:52:03 EST


On Fri, Dec 10, 2021 at 09:43:25AM -0600, Brijesh Singh wrote:
> +static void sev_prep_identity_maps(void)
> +{
> + /*
> + * The ConfidentialComputing blob is used very early in uncompressed
> + * kernel to find the in-memory cpuid table to handle cpuid
> + * instructions. Make sure an identity-mapping exists so it can be
> + * accessed after switchover.
> + */
> + if (sev_snp_enabled()) {
> + struct cc_blob_sev_info *cc_info =
> + (void *)(unsigned long)boot_params->cc_blob_address;
> +
> + add_identity_map((unsigned long)cc_info,
> + (unsigned long)cc_info + sizeof(*cc_info));
> + add_identity_map((unsigned long)cc_info->cpuid_phys,
> + (unsigned long)cc_info->cpuid_phys + cc_info->cpuid_len);
> + }
> +
> + sev_verify_cbit(top_level_pgt);
> +}
> +

Also, that function can just as well live in compressed/sev.c and
you can export add_identity_map() instead.

That latter function calls kernel_ident_mapping_init() which is
already exported. add_identity_map() doesn't do anything special
and it is limited to the decompressor kernel so nothing stands in
the way of exporting it in a pre-patch and renaming it there to
kernel_add_identity_map() or so...

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette