Re: [RFC][PATCH 04/34] x86/mm: Introduce physical address limit helper

Huang, Kai
2024-02-27T11:05:44Z

On Thu, 2024-02-22 at 10:39 -0800, Dave Hansen wrote:
> From: Dave Hansen <dave.hansen@linux.intel.com>
>
> Modern processors enumerate the sizes of the physical and virtual address
> spaces that they can handle. The kernel stashes this information for each
> CPU in 'cpuinfo_x86'.
>
> Like a lot of system-wide configuration, in practice the kernel only uses
> this information from the boot CPU. That makes a lot of sense because
> the kernel can't practically support two CPUs with such different
> fundamental support as the size of the address spaces.
>
> Having a per-cpu copy of this data is silly. It is, at best, a waste
> of space to keep it around for the non-boot CPUs. At worst, it is yet
> another bit of data that must be initialized in a particular order and
> can be a source of bugs.
>
> Introduce a helper to look up the number of supported physical address bits:
>
> x86_phys_bits()
>
> Replace most open-coded references to boot_cpu_data.x86_phys_bits.
>
> This form is more compact and also opens up the door to adding some
> centralized checking and enforcing rules around this important system-
> wide value.
>
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> ---
>

Reviewed-by: Kai Huang <kai.huang@intel.com>