Skip to content

Commit 9426335

Browse files
committed
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm update from Thomas Gleixner: "A single patch which excludes the GART aperture from vmcore as accessing that area from a dump kernel can crash the kernel. Not necessarily the nicest way to fix this, but curing this from ground up requires a more thorough rewrite of the whole kexec/kdump magic" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/gart: Exclude GART aperture from vmcore
2 parents 36c289e + 2a3e83c commit 9426335

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

arch/x86/kernel/aperture_64.c

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <asm/dma.h>
3131
#include <asm/amd_nb.h>
3232
#include <asm/x86_init.h>
33+
#include <linux/crash_dump.h>
3334

3435
/*
3536
* Using 512M as goal, in case kexec will load kernel_big
@@ -56,6 +57,33 @@ int fallback_aper_force __initdata;
5657

5758
int fix_aperture __initdata = 1;
5859

60+
#ifdef CONFIG_PROC_VMCORE
61+
/*
62+
* If the first kernel maps the aperture over e820 RAM, the kdump kernel will
63+
* use the same range because it will remain configured in the northbridge.
64+
* Trying to dump this area via /proc/vmcore may crash the machine, so exclude
65+
* it from vmcore.
66+
*/
67+
static unsigned long aperture_pfn_start, aperture_page_count;
68+
69+
static int gart_oldmem_pfn_is_ram(unsigned long pfn)
70+
{
71+
return likely((pfn < aperture_pfn_start) ||
72+
(pfn >= aperture_pfn_start + aperture_page_count));
73+
}
74+
75+
static void exclude_from_vmcore(u64 aper_base, u32 aper_order)
76+
{
77+
aperture_pfn_start = aper_base >> PAGE_SHIFT;
78+
aperture_page_count = (32 * 1024 * 1024) << aper_order >> PAGE_SHIFT;
79+
WARN_ON(register_oldmem_pfn_is_ram(&gart_oldmem_pfn_is_ram));
80+
}
81+
#else
82+
static void exclude_from_vmcore(u64 aper_base, u32 aper_order)
83+
{
84+
}
85+
#endif
86+
5987
/* This code runs before the PCI subsystem is initialized, so just
6088
access the northbridge directly. */
6189

@@ -435,8 +463,16 @@ int __init gart_iommu_hole_init(void)
435463

436464
out:
437465
if (!fix && !fallback_aper_force) {
438-
if (last_aper_base)
466+
if (last_aper_base) {
467+
/*
468+
* If this is the kdump kernel, the first kernel
469+
* may have allocated the range over its e820 RAM
470+
* and fixed up the northbridge
471+
*/
472+
exclude_from_vmcore(last_aper_base, last_aper_order);
473+
439474
return 1;
475+
}
440476
return 0;
441477
}
442478

@@ -473,6 +509,14 @@ int __init gart_iommu_hole_init(void)
473509
return 0;
474510
}
475511

512+
/*
513+
* If this is the kdump kernel _and_ the first kernel did not
514+
* configure the aperture in the northbridge, this range may
515+
* overlap with the first kernel's memory. We can't access the
516+
* range through vmcore even though it should be part of the dump.
517+
*/
518+
exclude_from_vmcore(aper_alloc, aper_order);
519+
476520
/* Fix up the north bridges */
477521
for (i = 0; i < amd_nb_bus_dev_ranges[i].dev_limit; i++) {
478522
int bus, dev_base, dev_limit;

arch/x86/xen/mmu_hvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ void __init xen_hvm_init_mmu_ops(void)
7575
if (is_pagetable_dying_supported())
7676
pv_mmu_ops.exit_mmap = xen_hvm_exit_mmap;
7777
#ifdef CONFIG_PROC_VMCORE
78-
register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram);
78+
WARN_ON(register_oldmem_pfn_is_ram(&xen_oldmem_pfn_is_ram));
7979
#endif
8080
}

0 commit comments

Comments
 (0)