Received: by 10.223.164.221 with SMTP id h29csp63535wrb; Fri, 3 Nov 2017 10:31:11 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Qz8k8SLDw0kLo+Za+r90OqvJRVwRuLYXw23TFFA58vsiywSoNlICbKFC2Oq/hCMqAMrqFV X-Received: by 10.98.245.152 with SMTP id b24mr8531130pfm.56.1509730270896; Fri, 03 Nov 2017 10:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509730270; cv=none; d=google.com; s=arc-20160816; b=Ns4WiqS2NuEmUPrpOrx7yjF7vqZJkZHLTCyq0/yOmqjnL6MKZTW+CFYhEexZLbp9fT BgwhEweCDIaVGvqQGcnxg0xdKaa7KkO/T1fs7IT5WdGzgCNTJeMRsc8hxq3gg1i1CBlW IUgDa/AtKD6HDvNmFv6wtM0Avf0VbJoPQVAyuDsprg0LKAhvpcItRnkDCouHuzNWnsJ7 +GWb+oUdX7umJwZY/Za2sraK55HMTq0xcqUy6sTfxbu6yuSJGAuZIlQUoE/YtrMGlR7l gScesm4uC1j36kTOmtMUJjz5D/7PEi194DfWSECQxqJuLwuyg91GBMXeCNe7ERscY3q1 iwUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=fFlmUiILgir8uKFNjeujBEendlUFYXJ+Yt5D5g6HSk0=; b=yfFlDJA2NJ7aWdRkt/eJUtP1bhZCInEdR3wDxFioa/wuCq8ZjQV4oVDhpKqU0zx3hY tEzIKb0/1cy91QeHe17LVH87g8R67mozfCaWL1LBeajbGL/TAYHi3zRw/6G/2C+raJDv FXrD6BtrY0woms6EPCCrVSlHNUNVF/4/cfWT4wljwPEthkpdShe/zbqzKtCgSYCqgusg cFeuz8MyqDEQU95vWqNRnZ2yNkxtmKTfclOhWxuf8er0ItI9Olma7pfZFWkPIH2oR/xw CFFPXaZMIQkxls0Gh1lNiOL79wBPwy+HTLZXDNAvTG419sCJj4V/gr6Siky96pCv/b48 BxCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si6318321pge.75.2017.11.03.10.30.58; Fri, 03 Nov 2017 10:31:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933382AbdKCR20 (ORCPT + 93 others); Fri, 3 Nov 2017 13:28:26 -0400 Received: from mx2.suse.de ([195.135.220.15]:60404 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756143AbdKCR2Z (ORCPT ); Fri, 3 Nov 2017 13:28:25 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E716DAC16; Fri, 3 Nov 2017 17:28:23 +0000 (UTC) Date: Fri, 3 Nov 2017 18:28:22 +0100 From: Jiri Bohac To: David Airlie , Dave Young , Baoquan He , Vivek Goyal , Bjorn Helgaas , Toshi Kani Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, Borislav Petkov Subject: [PATCH] x86/kexec: Exclude GART aperture from vmcore Message-ID: <20171103172822.4ty6yjhewroe4z4j@dwarf.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On machines where the GART aperture is mapped over physical RAM /proc/vmcore contains the remapped range and reading it may cause hangs or reboots. This range needs to be excluded from /proc/vmcore. This has originally been implemented by commit dd5f726076cc ("kexec: support for kexec on panic using new system call"). The implementation relied on the GART code adding an iomem_resource for this range called "GART", as implemented by commit 56dd669a138c ("[PATCH] Insert GART region into resource map") However, inserting the iomem_resource from the early GART code caused resource conflicts with some AGP drivers (bko#72201), which got avoided by reverting the patch in commit 707d4eefbdb3 ("Revert [PATCH] Insert GART region into resource map"). This revert introduced the /proc/vmcore bug. With the "GART" iomem_resource removed, the defunct code in crash.c has been removed by commit f296f2634920 ("x86/kexec: Remove walk_iomem_res() call with GART type") The patch below stores the location of the GART region in two variables (named gart_stolen_ram_start and gart_stolen_ram_end) and reverts/adapts parts of f296f2634920 to exclude the region from /proc/vmcore. Passing the information via an iomem_resource (or by reserving the range in the e820, which would propagate into an iomem_resource) would reintroduce bko#72201. Signed-off-by: Jiri Bohac Fixes: 707d4eefbdb3 ("Revert [PATCH] Insert GART region into resource map") diff --git a/arch/x86/include/asm/gart.h b/arch/x86/include/asm/gart.h index 1d268098ac2e..324a0a19d166 100644 --- a/arch/x86/include/asm/gart.h +++ b/arch/x86/include/asm/gart.h @@ -2,6 +2,7 @@ #define _ASM_X86_GART_H #include +#include extern void set_up_gart_resume(u32, u32); @@ -33,6 +34,8 @@ extern int fix_aperture; extern int gart_iommu_aperture; extern int gart_iommu_aperture_allowed; extern int gart_iommu_aperture_disabled; +extern u32 gart_stolen_ram_start; +extern u32 gart_stolen_ram_end; extern void early_gart_iommu_check(void); extern int gart_iommu_init(void); @@ -43,6 +46,8 @@ extern int gart_iommu_hole_init(void); #define gart_iommu_aperture 0 #define gart_iommu_aperture_allowed 0 #define gart_iommu_aperture_disabled 1 +#define gart_stolen_ram_start 0 +#define gart_stolen_ram_end 0 static inline void early_gart_iommu_check(void) { diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c index ef2859f9fcce..bc9a9b5b88e3 100644 --- a/arch/x86/kernel/aperture_64.c +++ b/arch/x86/kernel/aperture_64.c @@ -49,6 +49,8 @@ int gart_iommu_aperture; int gart_iommu_aperture_disabled __initdata; int gart_iommu_aperture_allowed __initdata; +u32 gart_stolen_ram_start; +u32 gart_stolen_ram_end; int fallback_aper_order __initdata = 1; /* 64MB */ int fallback_aper_force __initdata; @@ -87,6 +89,9 @@ static u32 __init allocate_aperture(void) register_nosave_region(addr >> PAGE_SHIFT, (addr+aper_size) >> PAGE_SHIFT); + gart_stolen_ram_start = (u32)addr; + gart_stolen_ram_end = (u32)addr + aper_size - 1; + return (u32)addr; } diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 44404e2307bb..ce065d72656d 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -37,6 +37,7 @@ #include #include #include +#include /* Alignment required for elf header segment */ #define ELF_CORE_HEADER_ALIGN 4096 @@ -58,7 +59,7 @@ struct crash_elf_data { struct kimage *image; /* * Total number of ram ranges we have after various adjustments for - * crash reserved region, etc. + * GART, crash reserved region etc. */ unsigned int max_nr_ranges; @@ -217,7 +218,6 @@ static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg) return 0; } - /* Gather all the required information to prepare elf headers for ram regions */ static void fill_up_crash_elf_data(struct crash_elf_data *ced, struct kimage *image) @@ -231,6 +231,15 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced, ced->max_nr_ranges = nr_ranges; + /* + * We don't create ELF headers for GART aperture as an attempt + * to dump this memory in second kernel leads to hang/crash. + * If gart aperture is mapped over RAM, one needs to exclude that region + * and that requires an extra phdr. + */ + if (gart_stolen_ram_start) + ced->max_nr_ranges++; + /* Exclusion of crash region could split memory ranges */ ced->max_nr_ranges++; @@ -339,6 +348,14 @@ static int elf_header_exclude_ranges(struct crash_elf_data *ced, return ret; } + /* Exclude GART region */ + if (gart_stolen_ram_start) { + ret = exclude_mem_range(cmem, gart_stolen_ram_start, + gart_stolen_ram_end); + if (ret) + return ret; + } + return ret; } -- Jiri Bohac SUSE Labs, Prague, Czechia From 1585423762737639713@xxx Wed Nov 29 17:52:03 +0000 2017 X-GM-THRID: 1585422935487576466 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread