[PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

Arnd Bergmann posted 11 patches 1 year ago
There is a newer version of this series
[PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE
Posted by Arnd Bergmann 1 year ago
From: Arnd Bergmann <arnd@arndb.de>

Since kernels with and without CONFIG_X86_PAE are now limited
to the low 4GB of physical address space, there is no need to
use either swiotlb or 64-bit phys_addr_t any more, so stop
selecting these and fix up the build warnings from that.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/Kconfig      | 2 --
 arch/x86/mm/pgtable.c | 5 +++--
 include/linux/mm.h    | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index b373db8a8176..d0d055f6f56e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1456,8 +1456,6 @@ config HIGHMEM
 config X86_PAE
 	bool "PAE (Physical Address Extension) Support"
 	depends on X86_32 && X86_HAVE_PAE
-	select PHYS_ADDR_T_64BIT
-	select SWIOTLB
 	help
 	  PAE is required for NX support, and furthermore enables
 	  larger swapspace support for non-overcommit purposes. It
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 5745a354a241..b8f9e69b25c1 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -765,11 +765,12 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
 int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot)
 {
 	u8 uniform;
+	struct resource res = DEFINE_RES_MEM(addr, PMD_SIZE);
 
 	mtrr_type_lookup(addr, addr + PMD_SIZE, &uniform);
 	if (!uniform) {
-		pr_warn_once("%s: Cannot satisfy [mem %#010llx-%#010llx] with a huge-page mapping due to MTRR override.\n",
-			     __func__, addr, addr + PMD_SIZE);
+		pr_warn_once("%s: Cannot satisfy %pR with a huge-page mapping due to MTRR override.\n",
+			     __func__, &res);
 		return 0;
 	}
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
index c39c4945946c..7725e9e46e90 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -99,7 +99,7 @@ extern int mmap_rnd_compat_bits __read_mostly;
 
 #ifndef DIRECT_MAP_PHYSMEM_END
 # ifdef MAX_PHYSMEM_BITS
-# define DIRECT_MAP_PHYSMEM_END	((1ULL << MAX_PHYSMEM_BITS) - 1)
+# define DIRECT_MAP_PHYSMEM_END	(phys_addr_t)((1ULL << MAX_PHYSMEM_BITS) - 1)
 # else
 # define DIRECT_MAP_PHYSMEM_END	(((phys_addr_t)-1)&~(1ULL<<63))
 # endif
-- 
2.39.5
Re: [PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE
Posted by kernel test robot 12 months ago

Hello,

kernel test robot noticed "WARNING:at_mm/sparse.c:#sparse_init" on:

commit: a20f815a6f361e18a0a2a9480b5a5340c5860c7f ("[PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE")
url: https://github.com/intel-lab-lkp/linux/commits/Arnd-Bergmann/x86-Kconfig-Geode-CPU-has-cmpxchg8b/20241210-225443
base: https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git f576cfc3d433316990802cd521ddea645eb3971b
patch link: https://lore.kernel.org/all/20241210144945.2325330-8-arnd@kernel.org/
patch subject: [PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE

in testcase: boot

config: i386-randconfig-001-20241213
compiler: gcc-12
test machine: qemu-system-i386 -enable-kvm -cpu SandyBridge -smp 2 -m 4G

(please refer to attached dmesg/kmsg for entire log/backtrace)


+------------------------------------------------+------------+------------+
|                                                | 620a8e2d2b | a20f815a6f |
+------------------------------------------------+------------+------------+
| WARNING:at_mm/sparse.c:#sparse_init            | 0          | 12         |
| EIP:sparse_init                                | 0          | 12         |
| BUG:kernel_NULL_pointer_dereference,address    | 0          | 12         |
| Oops                                           | 0          | 12         |
| Kernel_panic-not_syncing:Fatal_exception       | 0          | 12         |
+------------------------------------------------+------------+------------+


If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202412201005.77fb063-lkp@intel.com


[    0.068283][    T0] ------------[ cut here ]------------
[ 0.068644][ T0] WARNING: CPU: 0 PID: 0 at mm/sparse.c:149 sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[    0.069169][    T0] Modules linked in:
[    0.069424][    T0] CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.13.0-rc2-00153-ga20f815a6f36 #1 55e1ad47972e976fedebf027f6853ef569639c5a
[    0.070285][    T0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[ 0.070972][ T0] EIP: sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.071277][ T0] Code: 85 d2 74 d1 8b 0d 44 5f 72 b2 85 c9 7e 1c 89 54 24 08 31 c0 31 d2 89 44 24 0c 89 54 24 04 c7 04 24 d8 e5 04 b2 e8 55 ea a2 fe <0f> 0b eb a7 90 8b 0d 80 16 e7 b2 31 d2 8d b4 26 00 00 00 00 90 83
All code
========
   0:	85 d2                	test   %edx,%edx
   2:	74 d1                	je     0xffffffffffffffd5
   4:	8b 0d 44 5f 72 b2    	mov    -0x4d8da0bc(%rip),%ecx        # 0xffffffffb2725f4e
   a:	85 c9                	test   %ecx,%ecx
   c:	7e 1c                	jle    0x2a
   e:	89 54 24 08          	mov    %edx,0x8(%rsp)
  12:	31 c0                	xor    %eax,%eax
  14:	31 d2                	xor    %edx,%edx
  16:	89 44 24 0c          	mov    %eax,0xc(%rsp)
  1a:	89 54 24 04          	mov    %edx,0x4(%rsp)
  1e:	c7 04 24 d8 e5 04 b2 	movl   $0xb204e5d8,(%rsp)
  25:	e8 55 ea a2 fe       	call   0xfffffffffea2ea7f
  2a:*	0f 0b                	ud2		<-- trapping instruction
  2c:	eb a7                	jmp    0xffffffffffffffd5
  2e:	90                   	nop
  2f:	8b 0d 80 16 e7 b2    	mov    -0x4d18e980(%rip),%ecx        # 0xffffffffb2e716b5
  35:	31 d2                	xor    %edx,%edx
  37:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  3e:	90                   	nop
  3f:	83                   	.byte 0x83

Code starting with the faulting instruction
===========================================
   0:	0f 0b                	ud2
   2:	eb a7                	jmp    0xffffffffffffffab
   4:	90                   	nop
   5:	8b 0d 80 16 e7 b2    	mov    -0x4d18e980(%rip),%ecx        # 0xffffffffb2e7168b
   b:	31 d2                	xor    %edx,%edx
   d:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  14:	90                   	nop
  15:	83                   	.byte 0x83
[    0.072580][    T0] EAX: 00000000 EBX: b218feb4 ECX: 00000000 EDX: 0000009f
[    0.073047][    T0] ESI: b218febc EDI: 00000000 EBP: b218fecc ESP: b218feb4
[    0.073513][    T0] DS: 007b ES: 007b FS: 0000 GS: 0000 SS: febc EFLAGS: 00210046
[    0.074016][    T0] CR0: 80050033 CR2: 00000000 CR3: 02773000 CR4: 00000090
[    0.074492][    T0] Call Trace:
[ 0.074709][ T0] ? show_regs (arch/x86/kernel/dumpstack.c:479)
[ 0.074989][ T0] ? sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.075283][ T0] ? __warn (kernel/panic.c:748)
[ 0.075550][ T0] ? sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.075845][ T0] ? sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.076140][ T0] ? report_bug (lib/bug.c:180 lib/bug.c:219)
[ 0.076437][ T0] ? sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.076731][ T0] ? early_fixup_exception (arch/x86/mm/extable.c:415)
[ 0.077081][ T0] ? early_idt_handler_common (arch/x86/kernel/head_32.S:352)
[ 0.077450][ T0] ? register_lock_class (kernel/locking/lockdep.c:195 kernel/locking/lockdep.c:1322)
[ 0.077799][ T0] ? sparse_init (mm/sparse.c:149 mm/sparse.c:227 mm/sparse.c:268 mm/sparse.c:565)
[ 0.078113][ T0] ? native_flush_tlb_global (arch/x86/include/asm/irqflags.h:154 arch/x86/mm/tlb.c:1225)
[ 0.078480][ T0] paging_init (arch/x86/mm/init_32.c:685)
[ 0.078759][ T0] native_pagetable_init (arch/x86/mm/init_32.c:481)
[ 0.079101][ T0] ? _printk (kernel/printk/printk.c:2461)
[ 0.079367][ T0] ? dma_contiguous_reserve (kernel/dma/contiguous.c:250)
[ 0.079722][ T0] setup_arch (arch/x86/kernel/setup.c:1130)
[ 0.080011][ T0] start_kernel (init/main.c:924 (discriminator 3))
[ 0.080301][ T0] ? load_ucode_bsp (arch/x86/kernel/cpu/microcode/core.c:135)
[ 0.080622][ T0] i386_start_kernel (??:?)
[ 0.080936][ T0] startup_32_smp (arch/x86/kernel/head_32.S:292)
[    0.081247][    T0] irq event stamp: 0
[ 0.081500][ T0] hardirqs last enabled at (0): 0x0
[ 0.081922][ T0] hardirqs last disabled at (0): 0x0
[ 0.082349][ T0] softirqs last enabled at (0): 0x0
[ 0.082771][ T0] softirqs last disabled at (0): 0x0
[    0.083193][    T0] ---[ end trace 0000000000000000 ]---


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20241220/202412201005.77fb063-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v2 07/11] x86: drop SWIOTLB and PHYS_ADDR_T_64BIT for PAE
Posted by Arnd Bergmann 11 months, 4 weeks ago
On Fri, Dec 20, 2024, at 03:52, kernel test robot wrote:
>
> config: i386-randconfig-001-20241213
> compiler: gcc-12
> test machine: qemu-system-i386 -enable-kvm -cpu SandyBridge -smp 2 -m 4G
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>

I haven't been able to figure this out, apparently something goes
wrong on a KVM guest that has more than 32-bit of addressing (RAM+MMIO)
when it uses a 32-bit phys_addr_t.

I changed the patch now to only drop SWIOTLB, not PHYS_ADDR_T_64BIT.

       Arnd