[RFC][PATCH 02/34] x86/xen: Remove early "debug" physical address lookups

Dave Hansen posted 34 patches 1 year, 10 months ago
[RFC][PATCH 02/34] x86/xen: Remove early "debug" physical address lookups
Posted by Dave Hansen 1 year, 10 months ago

From: Dave Hansen <dave.hansen@linux.intel.com>

The __pa() facility is subject to debugging checks if CONFIG_DEBUG_VIRTUAL=y.
One of those debugging checks is whether the physical address is valid
on the platform.  That information is normally available via CPUID.  But
the __pa() code currently looks it up in 'boot_cpu_data' which is not
fully set up in early Xen PV boot.

The Xen PV code currently tries to get this info with
get_cpu_address_sizes() which also depends on 'boot_cpu_data' to be at
least somewhat set up.  The result is that the c->x86_phys_bits gets a
sane value, but not one that has anything to do with the hardware.  In
other words, the CONFIG_DEBUG_VIRTUAL checks are performed with what
amounts to garbage inputs.

Garbage checks are worse than no check at all.  Move over to the
"nodebug" variant to axe the checks.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Juergen Gross <jgross@suse.com>
---

 b/arch/x86/xen/enlighten_pv.c |    2 +-
 b/arch/x86/xen/mmu_pv.c       |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -puN arch/x86/xen/enlighten_pv.c~xen-no-early-__pa arch/x86/xen/enlighten_pv.c
--- a/arch/x86/xen/enlighten_pv.c~xen-no-early-__pa	2024-02-22 10:08:48.868469363 -0800
+++ b/arch/x86/xen/enlighten_pv.c	2024-02-22 10:08:48.872469519 -0800
@@ -1452,7 +1452,7 @@ asmlinkage __visible void __init xen_sta
 	boot_params.hdr.type_of_loader = (9 << 4) | 0;
 	boot_params.hdr.ramdisk_image = initrd_start;
 	boot_params.hdr.ramdisk_size = xen_start_info->mod_len;
-	boot_params.hdr.cmd_line_ptr = __pa(xen_start_info->cmd_line);
+	boot_params.hdr.cmd_line_ptr = __pa_nodebug(xen_start_info->cmd_line);
 	boot_params.hdr.hardware_subarch = X86_SUBARCH_XEN;
 
 	if (!xen_initial_domain()) {
diff -puN arch/x86/xen/mmu_pv.c~xen-no-early-__pa arch/x86/xen/mmu_pv.c
--- a/arch/x86/xen/mmu_pv.c~xen-no-early-__pa	2024-02-22 10:08:48.872469519 -0800
+++ b/arch/x86/xen/mmu_pv.c	2024-02-22 10:08:48.872469519 -0800
@@ -2006,7 +2006,7 @@ void __init xen_reserve_special_pages(vo
 {
 	phys_addr_t paddr;
 
-	memblock_reserve(__pa(xen_start_info), PAGE_SIZE);
+	memblock_reserve(__pa_nodebug(xen_start_info), PAGE_SIZE);
 	if (xen_start_info->store_mfn) {
 		paddr = PFN_PHYS(mfn_to_pfn(xen_start_info->store_mfn));
 		memblock_reserve(paddr, PAGE_SIZE);
_
Re: [RFC][PATCH 02/34] x86/xen: Remove early "debug" physical address lookups
Posted by Jürgen Groß 1 year, 9 months ago
On 22.02.24 19:39, Dave Hansen wrote:
> From: Dave Hansen <dave.hansen@linux.intel.com>
> 
> The __pa() facility is subject to debugging checks if CONFIG_DEBUG_VIRTUAL=y.
> One of those debugging checks is whether the physical address is valid
> on the platform.  That information is normally available via CPUID.  But
> the __pa() code currently looks it up in 'boot_cpu_data' which is not
> fully set up in early Xen PV boot.
> 
> The Xen PV code currently tries to get this info with
> get_cpu_address_sizes() which also depends on 'boot_cpu_data' to be at
> least somewhat set up.  The result is that the c->x86_phys_bits gets a
> sane value, but not one that has anything to do with the hardware.  In
> other words, the CONFIG_DEBUG_VIRTUAL checks are performed with what
> amounts to garbage inputs.
> 
> Garbage checks are worse than no check at all.  Move over to the
> "nodebug" variant to axe the checks.
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Juergen Gross <jgross@suse.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
Re: [RFC][PATCH 02/34] x86/xen: Remove early "debug" physical address lookups
Posted by Borislav Petkov 1 year, 9 months ago
On Thu, Feb 22, 2024 at 10:39:29AM -0800, Dave Hansen wrote:
> 
> From: Dave Hansen <dave.hansen@linux.intel.com>
> 
> The __pa() facility is subject to debugging checks if CONFIG_DEBUG_VIRTUAL=y.
> One of those debugging checks is whether the physical address is valid
> on the platform.  That information is normally available via CPUID.  But
> the __pa() code currently looks it up in 'boot_cpu_data' which is not
> fully set up in early Xen PV boot.
> 
> The Xen PV code currently tries to get this info with
> get_cpu_address_sizes() which also depends on 'boot_cpu_data' to be at
> least somewhat set up.  The result is that the c->x86_phys_bits gets a
> sane value, but not one that has anything to do with the hardware.  In
> other words, the CONFIG_DEBUG_VIRTUAL checks are performed with what
> amounts to garbage inputs.
> 
> Garbage checks are worse than no check at all.  Move over to the
> "nodebug" variant to axe the checks.
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Juergen Gross <jgross@suse.com>
> ---
> 
>  b/arch/x86/xen/enlighten_pv.c |    2 +-
>  b/arch/x86/xen/mmu_pv.c       |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>

At least as far as I can follow the Xen boot flow, yap, this makes
sense.

But let's have Jürgen confirm first.

Thx.

-- 
Regards/Gruss,
    Boris.

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