[lkml]   [2022]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH v2 5/5] x86/kasan: Populate shadow for shared chunk of the CPU entry area

    On 11/10/22 23:35, Sean Christopherson wrote:

    > + /*
    > + * Populate the shadow for the shared portion of the CPU entry area.
    > + * Shadows for the per-CPU areas are mapped on-demand, as each CPU's
    > + * area is randomly placed somewhere in the 512GiB range and mapping
    > + * the entire 512GiB range is prohibitively expensive.
    > + */
    > + kasan_populate_early_shadow((void *)shadow_cea_begin,
    > + (void *)shadow_cea_per_cpu_begin);
    > +

    I know I suggested to use "early" here, but I just realized that this might be a problem.
    This will actually map shadow page for the 8 pages (KASAN_SHADOW_SCALE_SHIFT) of the original memory.
    In case there is some per-cpu entry area starting right at CPU_ENTRY_AREA_PER_CPU the shadow for it will
    be covered with kasan_early_shadow_page instead of the usual one.

    So we need to go back to your v1 PATCH, or alternatively we can round up CPU_ENTRY_AREA_PER_CPU

    Such change will also require fixing up max_cea calculation in init_cea_offsets()

    Going back kasan_populate_shadow() seems like safer and easier choice. The only disadvantage of it
    that we might waste 1 page, which is not much compared to the KASAN memory overhead.

    > kasan_populate_early_shadow((void *)shadow_cea_end,
    > kasan_mem_to_shadow((void *)__START_KERNEL_map));

     \ /
      Last update: 2022-11-14 15:45    [W:13.348 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site