lkml.org 
[lkml]   [2021]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH v8 33/40] x86/compressed/64: add identity mapping for Confidential Computing blob
    From
    Date
    On 12/10/21 7:43 AM, 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);
    > + }

    The casting here is pretty ugly. Also, isn't ->cpuid_phys already a
    u64? Whats the idea behind casting it?

    I also have a sneaking suspicion that a single "unsigned long cc_blob"
    could remove virtually all the casting. Does this work?

    unsigned long cc_blob = boot_params->cc_blob_addres;
    struct cc_blob_sev_info *cc_info;

    add_identity_map(cc_blob, cc_blob + sizeof(*cc_info));

    cc_info = (struct cc_blob_sev_info *)cc_blob;
    add_identity_map(cc_info->cpuid_phys,
    cc_info->cpuid_phys + cc_info->cpuid_len);

    \
     
     \ /
      Last update: 2021-12-10 20:53    [W:5.007 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site