Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59ea7463 authored by Jiri Slaby's avatar Jiri Slaby Committed by Ingo Molnar
Browse files

MM: virtual address debug



Add some (configurable) expensive sanity checking to catch wrong address
translations on x86.

- create linux/mmdebug.h file to be able include this file in
  asm headers to not get unsolvable loops in header files
- __phys_addr on x86_32 became a function in ioremap.c since
  PAGE_OFFSET, is_vmalloc_addr and VMALLOC_* non-constasts are undefined
  if declared in page_32.h
- add __phys_addr_const for initializing doublefault_tss.__cr3

Tested on 386, 386pae, x86_64 and x86_64 numa=fake=2.

Contains Andi's enable numa virtual address debug patch.

Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 952f4a0a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -66,6 +66,6 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
		.ds		= __USER_DS,
		.ds		= __USER_DS,
		.fs		= __KERNEL_PERCPU,
		.fs		= __KERNEL_PERCPU,


		.__cr3		= __pa(swapper_pg_dir)
		.__cr3		= __phys_addr_const((unsigned long)swapper_pg_dir)
	}
	}
};
};
+24 −7
Original line number Original line Diff line number Diff line
@@ -23,18 +23,26 @@


#ifdef CONFIG_X86_64
#ifdef CONFIG_X86_64


unsigned long __phys_addr(unsigned long x)
static inline int phys_addr_valid(unsigned long addr)
{
{
	if (x >= __START_KERNEL_map)
	return addr < (1UL << boot_cpu_data.x86_phys_bits);
		return x - __START_KERNEL_map + phys_base;
	return x - PAGE_OFFSET;
}
}
EXPORT_SYMBOL(__phys_addr);


static inline int phys_addr_valid(unsigned long addr)
unsigned long __phys_addr(unsigned long x)
{
{
	return addr < (1UL << boot_cpu_data.x86_phys_bits);
	if (x >= __START_KERNEL_map) {
		x -= __START_KERNEL_map;
		VIRTUAL_BUG_ON(x >= KERNEL_IMAGE_SIZE);
		x += phys_base;
	} else {
		VIRTUAL_BUG_ON(x < PAGE_OFFSET);
		x -= PAGE_OFFSET;
		VIRTUAL_BUG_ON(system_state == SYSTEM_BOOTING ? x > MAXMEM :
					!phys_addr_valid(x));
	}
	return x;
}
}
EXPORT_SYMBOL(__phys_addr);


#else
#else


@@ -43,6 +51,15 @@ static inline int phys_addr_valid(unsigned long addr)
	return 1;
	return 1;
}
}


unsigned long __phys_addr(unsigned long x)
{
	/* VMALLOC_* aren't constants; not available at the boot time */
	VIRTUAL_BUG_ON(x < PAGE_OFFSET || (system_state != SYSTEM_BOOTING &&
					is_vmalloc_addr((void *)x)));
	return x - PAGE_OFFSET;
}
EXPORT_SYMBOL(__phys_addr);

#endif
#endif


int page_is_ram(unsigned long pagenr)
int page_is_ram(unsigned long pagenr)
+1 −1
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@


#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA


#define VIRTUAL_BUG_ON(x)
#include <linux/mmdebug.h>


#include <asm/smp.h>
#include <asm/smp.h>


+2 −1
Original line number Original line Diff line number Diff line
@@ -64,7 +64,8 @@ typedef struct page *pgtable_t;
#endif
#endif


#ifndef __ASSEMBLY__
#ifndef __ASSEMBLY__
#define __phys_addr(x)		((x) - PAGE_OFFSET)
#define __phys_addr_const(x)	((x) - PAGE_OFFSET)
extern unsigned long __phys_addr(unsigned long);
#define __phys_reloc_hide(x)	RELOC_HIDE((x), 0)
#define __phys_reloc_hide(x)	RELOC_HIDE((x), 0)


#ifdef CONFIG_FLATMEM
#ifdef CONFIG_FLATMEM
+1 −6
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@


#include <linux/gfp.h>
#include <linux/gfp.h>
#include <linux/list.h>
#include <linux/list.h>
#include <linux/mmdebug.h>
#include <linux/mmzone.h>
#include <linux/mmzone.h>
#include <linux/rbtree.h>
#include <linux/rbtree.h>
#include <linux/prio_tree.h>
#include <linux/prio_tree.h>
@@ -210,12 +211,6 @@ struct inode;
 */
 */
#include <linux/page-flags.h>
#include <linux/page-flags.h>


#ifdef CONFIG_DEBUG_VM
#define VM_BUG_ON(cond) BUG_ON(cond)
#else
#define VM_BUG_ON(condition) do { } while(0)
#endif

/*
/*
 * Methods to modify the page usage count.
 * Methods to modify the page usage count.
 *
 *
Loading