From patchwork Fri Apr 20 05:04:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901654 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3lK28wfz9s5H for ; Fri, 20 Apr 2018 15:07:57 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3lK11q2zF1Rv for ; Fri, 20 Apr 2018 15:07:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3gJ4QPPzF25F for ; Fri, 20 Apr 2018 15:04:28 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3gJ3rn5z8tKg for ; Fri, 20 Apr 2018 15:04:28 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3gJ3gK4z9s5b; Fri, 20 Apr 2018 15:04:28 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3gJ095Gz9s5H for ; Fri, 20 Apr 2018 15:04:27 +1000 (AEST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K4xBRr120416 for ; Fri, 20 Apr 2018 01:04:26 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hf42vurq1-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:04:25 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:04:23 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:04:22 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K54LBX34799630; Fri, 20 Apr 2018 05:04:21 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E955FAE04D; Fri, 20 Apr 2018 05:54:08 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 10735AE058; Fri, 20 Apr 2018 05:54:07 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:54:06 +0100 (BST) Subject: [PATCH v4 1/7] powerpc/fadump: Move the metadata region to start of the reserved area. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:34:18 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0044-0000-0000-0000054A3B41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0045-0000-0000-0000288A5A9E Message-Id: <152420065839.31037.9373191008433546810.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200047 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar Currently the metadata region that holds crash info structure and ELF core header is placed towards the end of reserved memory area. This patch places it at the beginning of the reserved memory area. It also introduces additional dump section called metadata section to communicate location of metadata region to 2nd kernel. This patch also maintains the compatibility between production/capture kernels irrespective of their kernel versions. Both combination older/newer and newer/older works fine. Signed-off-by: Mahesh Salgaonkar --- arch/powerpc/include/asm/fadump.h | 9 ++ arch/powerpc/kernel/fadump.c | 177 ++++++++++++++++++++++++++++++++----- 2 files changed, 160 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h index 5a23010af600..03d5140a6f0d 100644 --- a/arch/powerpc/include/asm/fadump.h +++ b/arch/powerpc/include/asm/fadump.h @@ -53,6 +53,11 @@ #define FADUMP_HPTE_REGION 0x0002 #define FADUMP_REAL_MODE_REGION 0x0011 +/* User define dump sections. + * Per PAPR: 0x0100 - 0xFFFF OS defined source types + */ +#define FADUMP_METADATA_REGION 0x0100 + /* Dump request flag */ #define FADUMP_REQUEST_FLAG 0x00000001 @@ -61,6 +66,9 @@ #define FADUMP_UNREGISTER 2 #define FADUMP_INVALIDATE 3 +/* Number of dump sections requested by kernel */ +#define FADUMP_NUM_SECTIONS 4 + /* Dump status flag */ #define FADUMP_ERROR_FLAG 0x2000 @@ -119,6 +127,7 @@ struct fadump_mem_struct { struct fadump_section cpu_state_data; struct fadump_section hpte_region; struct fadump_section rmr_region; + struct fadump_section metadata_region; }; /* Firmware-assisted dump configuration details. */ diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 8ceabef40d3d..43bfa535d0ea 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -188,17 +188,40 @@ static void fadump_show_config(void) pr_debug("Boot memory size : %lx\n", fw_dump.boot_memory_size); } +static unsigned long get_fadump_metadata_size(void) +{ + unsigned long size = 0; + + size += sizeof(struct fadump_crash_info_header); + size += sizeof(struct elfhdr); /* ELF core header.*/ + size += sizeof(struct elf_phdr); /* place holder for cpu notes */ + /* Program headers for crash memory regions. */ + size += sizeof(struct elf_phdr) * (memblock_num_regions(memory) + 2); + + size = PAGE_ALIGN(size); + pr_debug("fadump Metadata size is %ld\n", size); + return size; +} + static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm, unsigned long addr) { + uint16_t num_sections = 0; + unsigned long metadata_base = 0; + unsigned long metadata_size = 0; + if (!fdm) return 0; + /* Skip the fadump metadata area. */ + metadata_base = addr; + metadata_size = get_fadump_metadata_size(); + addr += metadata_size; + memset(fdm, 0, sizeof(struct fadump_mem_struct)); addr = addr & PAGE_MASK; fdm->header.dump_format_version = cpu_to_be32(0x00000001); - fdm->header.dump_num_sections = cpu_to_be16(3); fdm->header.dump_status_flag = 0; fdm->header.offset_first_dump_section = cpu_to_be32((u32)offsetof(struct fadump_mem_struct, cpu_state_data)); @@ -222,6 +245,7 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm, fdm->cpu_state_data.source_address = 0; fdm->cpu_state_data.source_len = cpu_to_be64(fw_dump.cpu_state_data_size); fdm->cpu_state_data.destination_address = cpu_to_be64(addr); + num_sections++; addr += fw_dump.cpu_state_data_size; /* hpte region section */ @@ -230,6 +254,7 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm, fdm->hpte_region.source_address = 0; fdm->hpte_region.source_len = cpu_to_be64(fw_dump.hpte_region_size); fdm->hpte_region.destination_address = cpu_to_be64(addr); + num_sections++; addr += fw_dump.hpte_region_size; /* RMA region section */ @@ -238,8 +263,27 @@ static unsigned long init_fadump_mem_struct(struct fadump_mem_struct *fdm, fdm->rmr_region.source_address = cpu_to_be64(RMA_START); fdm->rmr_region.source_len = cpu_to_be64(fw_dump.boot_memory_size); fdm->rmr_region.destination_address = cpu_to_be64(addr); + num_sections++; addr += fw_dump.boot_memory_size; + /* + * fadump metadata section. + * This section will help 2nd kernel to locate the metadata base + * looking at source_address. This entry will also copy the metadata + * content after the RMR region dump data, so that old kernels that + * does not support this section can still find the metadata to + * process fadump. + */ + fdm->metadata_region.request_flag = cpu_to_be32(FADUMP_REQUEST_FLAG); + fdm->metadata_region.source_data_type = + cpu_to_be16(FADUMP_METADATA_REGION); + fdm->metadata_region.source_address = cpu_to_be64(metadata_base); + fdm->metadata_region.source_len = cpu_to_be64(metadata_size); + fdm->metadata_region.destination_address = cpu_to_be64(addr); + num_sections++; + + fdm->header.dump_num_sections = cpu_to_be16(num_sections); + BUILD_BUG_ON(num_sections != FADUMP_NUM_SECTIONS); return addr; } @@ -325,12 +369,12 @@ static unsigned long get_fadump_area_size(void) size += fw_dump.cpu_state_data_size; size += fw_dump.hpte_region_size; size += fw_dump.boot_memory_size; - size += sizeof(struct fadump_crash_info_header); - size += sizeof(struct elfhdr); /* ELF core header.*/ - size += sizeof(struct elf_phdr); /* place holder for cpu notes */ - /* Program headers for crash memory regions. */ - size += sizeof(struct elf_phdr) * (memblock_num_regions(memory) + 2); - + size += get_fadump_metadata_size(); + /* Add it twice. We will ask platform to move metadata contents + * at rmr_region.destination_address + source_len, so that old + * kernels also can get metadata to process fadump successfully. + */ + size += get_fadump_metadata_size(); size = PAGE_ALIGN(size); return size; } @@ -355,6 +399,35 @@ static void __init fadump_reserve_crash_area(unsigned long base, } } +static inline unsigned long get_fadump_metadata_base( + const struct fadump_mem_struct *fdm) +{ + const struct fadump_section *dump_section; + uint16_t num_sections; + + /* Scan through all dump sections to find out metadata section. */ + dump_section = &fdm->cpu_state_data; + num_sections = be16_to_cpu(fdm->header.dump_num_sections); + + while (num_sections--) { + uint16_t type = be16_to_cpu(dump_section->source_data_type); + if (type == FADUMP_METADATA_REGION) + return be64_to_cpu(dump_section->source_address); + + dump_section++; + } + + /* + * Support the older kernel which does not contain metadata + * dump section. We end up here only when fadump is active and + * the previously crashed kernel is old kernel which had metadata + * section at the top of the reserved memory. + */ + BUG_ON(fw_dump.dump_active == 0); + return be64_to_cpu(fdm->rmr_region.destination_address) + + be64_to_cpu(fdm->rmr_region.source_len); +} + int __init fadump_reserve_mem(void) { unsigned long base, size, memory_boundary; @@ -420,9 +493,9 @@ int __init fadump_reserve_mem(void) size = memory_boundary - base; fadump_reserve_crash_area(base, size); - fw_dump.fadumphdr_addr = - be64_to_cpu(fdm_active->rmr_region.destination_address) + - be64_to_cpu(fdm_active->rmr_region.source_len); + pr_info("Number of kernel Dump sections: %d\n", + be16_to_cpu(fdm_active->header.dump_num_sections)); + fw_dump.fadumphdr_addr = get_fadump_metadata_base(fdm_active); pr_debug("fadumphdr_addr = %p\n", (void *) fw_dump.fadumphdr_addr); } else { @@ -821,6 +894,38 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm) } +static int validate_dump(const struct fadump_mem_struct *fdm_active) +{ + const struct fadump_section *dump_section; + uint16_t num_sections = 0; + int rc = 0; + + num_sections = be16_to_cpu(fdm_active->header.dump_num_sections); + dump_section = &fdm_active->cpu_state_data; + + if ((be16_to_cpu(fdm_active->header.dump_status_flag) + == FADUMP_ERROR_FLAG)) { + pr_err("Error occured while taking a dump by platform\n"); + rc = -EINVAL; + } + + /* Print Section type and error flags for failed dump section. */ + while (num_sections--) { + if (dump_section->error_flags != 0 || + (dump_section->source_len != dump_section->bytes_dumped)) { + pr_err("Section: %04x, Error flag: %04x, " + "Bytes Req: %llx, Bytes Dumped: %llx\n", + be16_to_cpu(dump_section->source_data_type), + be16_to_cpu(dump_section->error_flags), + be64_to_cpu(dump_section->source_len), + be64_to_cpu(dump_section->bytes_dumped)); + rc = -EINVAL; + } + dump_section++; + } + return rc; +} + /* * Validate and process the dump data stored by firmware before exporting * it through '/proc/vmcore'. @@ -834,17 +939,10 @@ static int __init process_fadump(const struct fadump_mem_struct *fdm_active) return -EINVAL; /* Check if the dump data is valid. */ - if ((be16_to_cpu(fdm_active->header.dump_status_flag) == FADUMP_ERROR_FLAG) || - (fdm_active->cpu_state_data.error_flags != 0) || - (fdm_active->rmr_region.error_flags != 0)) { + rc = validate_dump(fdm_active); + if (rc) { printk(KERN_ERR "Dump taken by platform is not valid\n"); - return -EINVAL; - } - if ((fdm_active->rmr_region.bytes_dumped != - fdm_active->rmr_region.source_len) || - !fdm_active->cpu_state_data.bytes_dumped) { - printk(KERN_ERR "Dump taken by platform is incomplete\n"); - return -EINVAL; + return rc; } /* Validate the fadump crash info header */ @@ -1107,7 +1205,7 @@ static int register_fadump(void) fadump_setup_crash_memory_ranges(); - addr = be64_to_cpu(fdm.rmr_region.destination_address) + be64_to_cpu(fdm.rmr_region.source_len); + addr = be64_to_cpu(fdm.metadata_region.source_address); /* Initialize fadump crash info header. */ addr = init_fadump_header(addr); vaddr = __va(addr); @@ -1146,7 +1244,7 @@ static int fadump_unregister_dump(struct fadump_mem_struct *fdm) return 0; } -static int fadump_invalidate_dump(struct fadump_mem_struct *fdm) +static int fadump_invalidate_dump(const struct fadump_mem_struct *fdm) { int rc = 0; unsigned int wait_time; @@ -1177,9 +1275,7 @@ void fadump_cleanup(void) { /* Invalidate the registration only if dump is active. */ if (fw_dump.dump_active) { - init_fadump_mem_struct(&fdm, - be64_to_cpu(fdm_active->cpu_state_data.destination_address)); - fadump_invalidate_dump(&fdm); + fadump_invalidate_dump(fdm_active); } } @@ -1250,6 +1346,35 @@ static void fadump_release_memory(unsigned long begin, unsigned long end) fadump_release_reserved_area(begin, end); } +static inline unsigned long get_fadump_prev_mstart( + const struct fadump_mem_struct *fdm) +{ + const struct fadump_section *dump_section; + uint16_t num_sections; + + /* This function is called only when fadump is active. */ + BUG_ON(fw_dump.dump_active == 0); + + /* Scan through all dump sections to find out metadata section. */ + dump_section = &fdm->cpu_state_data; + num_sections = be16_to_cpu(fdm->header.dump_num_sections); + + while (num_sections--) { + uint16_t type = be16_to_cpu(dump_section->source_data_type); + if (type == FADUMP_METADATA_REGION) + return be64_to_cpu(dump_section->source_address); + + dump_section++; + } + + /* + * Support the older kernel which does not contain metadata + * dump section. For older kernel reserved memory start is + * at cpu_state_data.destination_address. + */ + return be64_to_cpu(fdm->cpu_state_data.destination_address); +} + static void fadump_invalidate_release_mem(void) { unsigned long reserved_area_start, reserved_area_end; @@ -1261,7 +1386,7 @@ static void fadump_invalidate_release_mem(void) return; } - destination_address = be64_to_cpu(fdm_active->cpu_state_data.destination_address); + destination_address = get_fadump_prev_mstart(fdm_active); fadump_cleanup(); mutex_unlock(&fadump_mutex); From patchwork Fri Apr 20 05:04:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901656 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3nr48blz9s5H for ; Fri, 20 Apr 2018 15:10:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3nr31mmzDqnn for ; Fri, 20 Apr 2018 15:10:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3gV45LszF24L for ; Fri, 20 Apr 2018 15:04:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3gV3Vd2z8tKg for ; Fri, 20 Apr 2018 15:04:38 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3gV2LC3z9s5b; Fri, 20 Apr 2018 15:04:38 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3gT5YDfz9s5H for ; Fri, 20 Apr 2018 15:04:37 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K53p9S101654 for ; Fri, 20 Apr 2018 01:04:35 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hf45p3caj-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:04:35 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:04:33 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:04:30 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K54T7s11796606; Fri, 20 Apr 2018 05:04:29 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B6C8A4053; Fri, 20 Apr 2018 05:56:35 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53EFFA4040; Fri, 20 Apr 2018 05:56:33 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:56:33 +0100 (BST) Subject: [PATCH v4 2/7] powerpc/fadump: Update documentation to reflect the metadata region movement. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:34:26 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0020-0000-0000-00000413EE93 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0021-0000-0000-000042A83F02 Message-Id: <152420066675.31037.4888400094785392534.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200047 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar Metadata region that holds fadump header and ELF header is now placed at the start of reserved memory area. Update the documentation accordingly Signed-off-by: Mahesh Salgaonkar --- Documentation/powerpc/firmware-assisted-dump.txt | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/Documentation/powerpc/firmware-assisted-dump.txt b/Documentation/powerpc/firmware-assisted-dump.txt index bdd344aa18d9..30b32f879219 100644 --- a/Documentation/powerpc/firmware-assisted-dump.txt +++ b/Documentation/powerpc/firmware-assisted-dump.txt @@ -115,17 +115,26 @@ be kept permanently reserved, so that it can act as a receptacle for a copy of the boot memory content in addition to CPU state and HPTE region, in the case a crash does occur. +The first kernel, during fadump registration, prepares ELF core header +that contains necessary information for the coredump of the 1st kernel +which includes its physical memory layout. This ELF header and some more +additional data is stored in the area called metadata region at the start +of the reserved memory area. The implementation maintains the compatibility +between production/capture kernels irrespective of their kernel versions. +Both combination older/newer and newer/older works fine. + o Memory Reservation during first kernel Low memory Top of memory 0 boot memory size | | | |<--Reserved dump area -->| | V V | Permanent Reservation | V - +-----------+----------/ /---+---+----+-----------+----+------+ - | | |CPU|HPTE| DUMP |ELF | | - +-----------+----------/ /---+---+----+-----------+----+------+ - | ^ - | | + +-----------+----------/ /---+----+---+----+-----------+------+ + | | |ELF |CPU|HPTE| DUMP | | + +-----------+---------/ /----+----+---+----+-----------+------+ + | ^ ^ + | | | + | metadata region | \ / ------------------------------------------- Boot memory content gets transferred to @@ -137,14 +146,14 @@ and HPTE region, in the case a crash does occur. Low memory Top of memory 0 boot memory size | - | |<------------- Reserved dump area ----------- -->| + | |<------------- Reserved dump area -------------->| V V V - +-----------+----------/ /---+---+----+-----------+----+------+ - | | |CPU|HPTE| DUMP |ELF | | - +-----------+----------/ /---+---+----+-----------+----+------+ - | | - V V - Used by second /proc/vmcore + +-----------+----------/ /---+----+----+---------------+------+ + | | |ELF |CPU|HPTE| DUMP | | + +-----------+----------/ /---+----+----+---------------+------+ + | | + V V + Used by second /proc/vmcore kernel to boot Fig. 2 From patchwork Fri Apr 20 05:04:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901658 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3r34RQYz9s0n for ; Fri, 20 Apr 2018 15:12:03 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3r33CmxzF24D for ; Fri, 20 Apr 2018 15:12:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3gm5z0HzF24t for ; Fri, 20 Apr 2018 15:04:52 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3gm4S7sz8tKg for ; Fri, 20 Apr 2018 15:04:52 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3gm3W5qz9s70; Fri, 20 Apr 2018 15:04:52 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3gl5Jdwz9s5b for ; Fri, 20 Apr 2018 15:04:51 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K54j2q113924 for ; Fri, 20 Apr 2018 01:04:49 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hf8g2ab36-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:04:48 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:04:41 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:04:38 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K54bbq53739686; Fri, 20 Apr 2018 05:04:37 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49BA452049; Fri, 20 Apr 2018 04:55:23 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 65BA55204C; Fri, 20 Apr 2018 04:55:21 +0100 (BST) Subject: [PATCH v4 3/7] powerpc/fadump: un-register fadump on kexec path. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:34:35 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0040-0000-0000-0000044F8D3D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0041-0000-0000-000020F3E6E3 Message-Id: <152420067500.31037.2795727017934578072.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar otherwise the fadump registration in new kexec-ed kernel complains that fadump is already registered. This makes new kernel to continue using fadump registered by previous kernel which may lead to invalid vmcore generation. Hence this patch fixes this issue by un-registering fadump in fadump_cleanup() which is called during kexec path so that new kernel can register fadump with new valid values. Signed-off-by: Mahesh Salgaonkar --- arch/powerpc/kernel/fadump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 43bfa535d0ea..16b3e8c5cae0 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -1276,6 +1276,9 @@ void fadump_cleanup(void) /* Invalidate the registration only if dump is active. */ if (fw_dump.dump_active) { fadump_invalidate_dump(fdm_active); + } else if (fw_dump.dump_registered) { + /* Un-register Firmware-assisted dump if it was registered. */ + fadump_unregister_dump(&fdm); } } From patchwork Fri Apr 20 05:04:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901659 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3tC6s8yz9s5H for ; Fri, 20 Apr 2018 15:13:55 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3tC3lTYzF24R for ; Fri, 20 Apr 2018 15:13:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3h10FjxzF26F for ; Fri, 20 Apr 2018 15:05:05 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3h06PPSz8vqS for ; Fri, 20 Apr 2018 15:05:04 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3h067Tvz9s5b; Fri, 20 Apr 2018 15:05:04 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3h01dsqz9s5H for ; Fri, 20 Apr 2018 15:05:03 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K54xtZ111473 for ; Fri, 20 Apr 2018 01:05:02 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hf39tnme5-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:05:00 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:04:48 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:04:46 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K54k9U54591642; Fri, 20 Apr 2018 05:04:46 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4D574C040; Fri, 20 Apr 2018 05:57:13 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 809E34C044; Fri, 20 Apr 2018 05:57:11 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:57:11 +0100 (BST) Subject: [PATCH v4 4/7] powerpc/fadump: Reservationless firmware assisted dump From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:34:43 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0040-0000-0000-00000430FFA6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0041-0000-0000-000026351A34 Message-Id: <152420068315.31037.10792452404355231147.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar One of the primary issues with Firmware Assisted Dump (fadump) on Power is that it needs a large amount of memory to be reserved. On large systems with TeraBytes of memory, this reservation can be quite significant. In some cases, fadump fails if the memory reserved is insufficient, or if the reserved memory was DLPAR hot-removed. In the normal case, post reboot, the preserved memory is filtered to extract only relevant areas of interest using the makedumpfile tool. While the tool provides flexibility to determine what needs to be part of the dump and what memory to filter out, all supported distributions default this to "Capture only kernel data and nothing else". We take advantage of this default and the Linux kernel's Contiguous Memory Allocator (CMA) to fundamentally change the memory reservation model for fadump. Instead of setting aside a significant chunk of memory nobody can use, this patch uses CMA instead, to reserve a significant chunk of memory that the kernel is prevented from using (due to MIGRATE_CMA), but applications are free to use it. With this fadump will still be able to capture all of the kernel memory and most of the user space memory except the user pages that were present in CMA region. Essentially, on a P9 LPAR with 2 cores, 8GB RAM and current upstream: [root@zzxx-yy10 ~]# free -m total used free shared buff/cache available Mem: 7557 193 6822 12 541 6725 Swap: 4095 0 4095 With this patch: [root@zzxx-yy10 ~]# free -m total used free shared buff/cache available Mem: 8133 194 7464 12 475 7338 Swap: 4095 0 4095 Changes made here are completely transparent to how fadump has traditionally worked. Thanks to Aneesh Kumar and Anshuman Khandual for helping us understand CMA and its usage. TODO: - Handle case where CMA reservation spans nodes. Signed-off-by: Ananth N Mavinakayanahalli Signed-off-by: Mahesh Salgaonkar --- arch/powerpc/kernel/fadump.c | 120 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 17 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 16b3e8c5cae0..7f76924ab190 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -45,11 +46,57 @@ static struct fw_dump fw_dump; static struct fadump_mem_struct fdm; static const struct fadump_mem_struct *fdm_active; +static struct cma *fadump_cma; static DEFINE_MUTEX(fadump_mutex); struct fad_crash_memory_ranges crash_memory_ranges[INIT_CRASHMEM_RANGES]; int crash_mem_ranges; +/* + * fadump_cma_reserve() - reserve area for fadump memory reservation + * + * This function reserves memory from early allocator. It should be + * called by arch specific code once the memblock allocator + * has been activated. + */ +int __init fadump_cma_reserve(void) +{ + unsigned long long base, size; + int rc; + + if (!fw_dump.fadump_enabled) + return 0; + + base = fw_dump.reserve_dump_area_start; + size = fw_dump.reserve_dump_area_size; + pr_debug("Original reserve area base %ld, size %ld\n", + (unsigned long)base >> 20, + (unsigned long)size >> 20); + if (!size) + return 0; + + rc = cma_declare_contiguous(base, size, 0, 0, 0, false, + "fadump_cma", &fadump_cma); + if (rc) { + printk(KERN_ERR "fadump: Failed to reserve cma area for " + "firmware-assisted dump, %d\n", rc); + fw_dump.reserve_dump_area_size = 0; + return 0; + } + /* + * So we now have cma area reserved for fadump. base may be different + * from what we requested. + */ + fw_dump.reserve_dump_area_start = cma_get_base(fadump_cma); + fw_dump.reserve_dump_area_size = cma_get_size(fadump_cma); + printk("Reserved %ldMB cma area at %ldMB for firmware-assisted dump " + "(System RAM: %ldMB)\n", + cma_get_size(fadump_cma) >> 20, + (unsigned long)cma_get_base(fadump_cma) >> 20, + (unsigned long)(memblock_phys_mem_size() >> 20)); + return 1; +} + /* Scan the Firmware Assisted dump configuration details. */ int __init early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data) @@ -496,8 +543,9 @@ int __init fadump_reserve_mem(void) pr_info("Number of kernel Dump sections: %d\n", be16_to_cpu(fdm_active->header.dump_num_sections)); fw_dump.fadumphdr_addr = get_fadump_metadata_base(fdm_active); - pr_debug("fadumphdr_addr = %p\n", - (void *) fw_dump.fadumphdr_addr); + pr_debug("fadumphdr_addr = %pa\n", &fw_dump.fadumphdr_addr); + fw_dump.reserve_dump_area_start = base; + fw_dump.reserve_dump_area_size = size; } else { size = get_fadump_area_size(); @@ -514,21 +562,10 @@ int __init fadump_reserve_mem(void) !memblock_is_region_reserved(base, size)) break; } - if ((base > (memory_boundary - size)) || - memblock_reserve(base, size)) { - pr_err("Failed to reserve memory\n"); - return 0; - } - - pr_info("Reserved %ldMB of memory at %ldMB for firmware-" - "assisted dump (System RAM: %ldMB)\n", - (unsigned long)(size >> 20), - (unsigned long)(base >> 20), - (unsigned long)(memblock_phys_mem_size() >> 20)); + fw_dump.reserve_dump_area_start = base; + fw_dump.reserve_dump_area_size = size; + return fadump_cma_reserve(); } - - fw_dump.reserve_dump_area_start = base; - fw_dump.reserve_dump_area_size = size; return 1; } @@ -1191,6 +1228,39 @@ static unsigned long init_fadump_header(unsigned long addr) return addr; } +static unsigned long allocate_metadata_area(void) +{ + int nr_pages; + unsigned long size; + struct page *page = NULL; + + /* + * Check if fadump cma region is activated. + * fadump_cma->count == 0 means cma activation has failed. This means + * that the fadump reserved memory now will not be visible/available + * for user applications to use. It will be as good as old fadump + * behaviour of blocking this memory chunk from production system + * use. CMA activation failure does not mean that fadump will not + * work. Will continue to setup fadump. + */ + if (!fadump_cma || !cma_get_size(fadump_cma)) { + pr_warn("fadump cma region activation failed.\n"); + return 0; + } + + size = get_fadump_metadata_size(); + nr_pages = ALIGN(size, PAGE_SIZE) >> PAGE_SHIFT; + pr_info("Fadump metadata size = %ld (nr_pages = %d)\n", size, nr_pages); + + page = cma_alloc(fadump_cma, nr_pages, 0, GFP_KERNEL); + if (page) { + pr_debug("Allocated fadump metadata area at %ldMB (cma)\n", + (unsigned long)page_to_phys(page) >> 20); + return page_to_phys(page); + } + return 0; +} + static int register_fadump(void) { unsigned long addr; @@ -1643,8 +1713,24 @@ int __init setup_fadump(void) fadump_invalidate_release_mem(); } /* Initialize the kernel dump memory structure for FAD registration. */ - else if (fw_dump.reserve_dump_area_size) + else if (fw_dump.reserve_dump_area_size) { + /* + * By this time cma area has been activated. Allocate memory + * for metadata from fadump cma region. Since this is very + * early during boot we are guaranteed to get metadata cma + * allocation at address fw_dump.reserve_dump_area_start. + * + * During fadump registration, metadata region is used + * to setup fadump header and ELF core header. We don't want + * this region to be touched by anyone. Allocating metadata + * region memory from fadump cma will make sure that this + * region will not given to any user space application. + * However the rest of the fadump cma memory is still free + * to be used by user applications. + */ + allocate_metadata_area(); init_fadump_mem_struct(&fdm, fw_dump.reserve_dump_area_start); + } fadump_init_files(); return 1; From patchwork Fri Apr 20 05:04:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901662 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S4181Bhsz9s5H for ; Fri, 20 Apr 2018 15:19:56 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S4177577zF255 for ; Fri, 20 Apr 2018 15:19:55 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3jW4r2pzF258 for ; Fri, 20 Apr 2018 15:06:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3jW3kMBz8tKK for ; Fri, 20 Apr 2018 15:06:23 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3jW36Yzz9s5b; Fri, 20 Apr 2018 15:06:23 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3jW0JGWz9s5H for ; Fri, 20 Apr 2018 15:06:22 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K560DP019195 for ; Fri, 20 Apr 2018 01:06:21 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hf2jwffcp-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:06:10 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:04:56 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:04:55 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K54t3p55771146; Fri, 20 Apr 2018 05:04:55 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6C6F4204D; Fri, 20 Apr 2018 05:56:24 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D93E42042; Fri, 20 Apr 2018 05:56:22 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:56:22 +0100 (BST) Subject: [PATCH v4 5/7] powerpc/fadump: Update documentation to reflect CMA reservation. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:34:51 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0008-0000-0000-000004ED4FC7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0009-0000-0000-00001E81650D Message-Id: <152420069171.31037.10578740903757971568.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar Signed-off-by: Mahesh Salgaonkar --- Documentation/powerpc/firmware-assisted-dump.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/powerpc/firmware-assisted-dump.txt b/Documentation/powerpc/firmware-assisted-dump.txt index 30b32f879219..2ab13270b050 100644 --- a/Documentation/powerpc/firmware-assisted-dump.txt +++ b/Documentation/powerpc/firmware-assisted-dump.txt @@ -113,7 +113,15 @@ header, is usually reserved at an offset greater than boot memory size (see Fig. 1). This area is *not* released: this region will be kept permanently reserved, so that it can act as a receptacle for a copy of the boot memory content in addition to CPU state -and HPTE region, in the case a crash does occur. +and HPTE region, in the case a crash does occur. Since this reserved +memory area is used only after the system crash, there is no point in +blocking this significant chunk of memory from production kernel. +Hence, the implementation uses the Linux kernel's Contiguous Memory +Allocator (CMA) for memory reservation. With CMA reservation this memory +will be available for applications to use it, while kernel is prevented +from using it. With this fadump will still be able to capture all of +the kernel memory and most of the user space memory except the user +pages that were present in CMA region. The first kernel, during fadump registration, prepares ELF core header that contains necessary information for the coredump of the 1st kernel From patchwork Fri Apr 20 05:05:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901660 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3wH1Tr0z9s5H for ; Fri, 20 Apr 2018 15:15:43 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3wH0C5nzF24B for ; Fri, 20 Apr 2018 15:15:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3h7193nzF267 for ; Fri, 20 Apr 2018 15:05:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3h70Tvmz8vqS for ; Fri, 20 Apr 2018 15:05:11 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3h70Gtkz9s5b; Fri, 20 Apr 2018 15:05:11 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3h63Ybzz9s5H for ; Fri, 20 Apr 2018 15:05:10 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K54iRp105044 for ; Fri, 20 Apr 2018 01:05:08 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hf45p3d3w-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:05:08 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:05:06 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:05:03 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K553fm57934046; Fri, 20 Apr 2018 05:05:03 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18E3011C04A; Fri, 20 Apr 2018 05:56:56 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B8B911C054; Fri, 20 Apr 2018 05:56:54 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:56:53 +0100 (BST) Subject: [PATCH v4 6/7] powerpc/fadump: throw proper error message on fadump registration failure. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:35:00 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0012-0000-0000-000005CCDBAD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0013-0000-0000-00001949376C Message-Id: <152420070027.31037.8135074047958189805.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar fadump fails to register when there are holes in reserved memory area. This can happen if user has hot-removed a memory that falls in the fadump reserved memory area. Throw a meaningful error message to the user in such case. Signed-off-by: Mahesh Salgaonkar --- arch/powerpc/kernel/fadump.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 7f76924ab190..4884ab796f4a 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -216,6 +216,36 @@ static int is_boot_memory_area_contiguous(void) return ret; } +/* + * Returns 1, if there are no holes in reserved memory area, + * 0 otherwise. + */ +static int is_reserved_memory_area_contiguous(void) +{ + struct memblock_region *reg; + unsigned long start, end; + unsigned long d_start = fw_dump.reserve_dump_area_start; + unsigned long d_end = d_start + fw_dump.reserve_dump_area_size; + int ret = 0; + + for_each_memblock(memory, reg) { + start = max(d_start, (unsigned long)reg->base); + end = min(d_end, (unsigned long)(reg->base + reg->size)); + if (d_start < end) { + /* Memory hole from d_start to start */ + if (start > d_start) + break; + + if (end == d_end) { + ret = 1; + break; + } + d_start = end + 1; + } + } + return ret; +} + /* Print firmware assisted dump configurations for debugging purpose. */ static void fadump_show_config(void) { @@ -634,6 +664,9 @@ static int register_fw_dump(struct fadump_mem_struct *fdm) if (!is_boot_memory_area_contiguous()) pr_err("Can't have holes in boot memory area while " "registering fadump\n"); + else if (!is_reserved_memory_area_contiguous()) + pr_err("Can't have holes in reserved memory area while" + " registering fadump\n"); printk(KERN_ERR "Failed to register firmware-assisted kernel" " dump. Parameter Error(%d).\n", rc); From patchwork Fri Apr 20 05:05:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 901661 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3z06qRHz9s5H for ; Fri, 20 Apr 2018 15:18:04 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40S3z052TyzF23D for ; Fri, 20 Apr 2018 15:18:04 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40S3hG01YRzF25y for ; Fri, 20 Apr 2018 15:05:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 40S3hF6Wbsz8vqS for ; Fri, 20 Apr 2018 15:05:17 +1000 (AEST) Received: by ozlabs.org (Postfix) id 40S3hF6KpRz9s5b; Fri, 20 Apr 2018 15:05:17 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.vnet.ibm.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40S3hF1ZqWz9s5H for ; Fri, 20 Apr 2018 15:05:17 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3K54i3r113865 for ; Fri, 20 Apr 2018 01:05:15 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hf8g2abwc-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 20 Apr 2018 01:05:15 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Apr 2018 06:05:13 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 20 Apr 2018 06:05:12 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3K55BtF58327088; Fri, 20 Apr 2018 05:05:11 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AFD7A4051; Fri, 20 Apr 2018 05:57:17 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3787BA4059; Fri, 20 Apr 2018 05:57:15 +0100 (BST) Received: from jupiter.in.ibm.com (unknown [9.109.202.29]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 20 Apr 2018 05:57:14 +0100 (BST) Subject: [PATCH v4 7/7] powerpc/fadump: Do not allow hot-remove memory from fadump reserved area. From: Mahesh J Salgaonkar To: linuxppc-dev Date: Fri, 20 Apr 2018 10:35:08 +0530 In-Reply-To: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> References: <152420062000.31037.770773018944092449.stgit@jupiter.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18042005-0040-0000-0000-0000044F8D4A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042005-0041-0000-0000-000020F3E6F1 Message-Id: <152420070863.31037.11093621382553645534.stgit@jupiter.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-20_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804200048 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ananth Narayan , kernelfans@gmail.com, "Aneesh Kumar K.V" , Hari Bathini , Nathan Fontenot , Anshuman Khandual , Srikar Dronamraju Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Mahesh Salgaonkar For fadump to work successfully there should not be any holes in reserved memory ranges where kernel has asked firmware to move the content of old kernel memory in event of crash. But this memory area is currently not protected from hot-remove operations. Hence, fadump service can fail to re-register after the hot-remove operation, if hot-removed memory belongs to fadump reserved region. To avoid this make sure that memory from fadump reserved area is not hot-removable if fadump is registered. However, if user still wants to remove that memory, he can do so by manually stopping fadump service before hot-remove operation. Signed-off-by: Mahesh Salgaonkar --- arch/powerpc/include/asm/fadump.h | 2 +- arch/powerpc/kernel/fadump.c | 10 ++++++++-- arch/powerpc/platforms/pseries/hotplug-memory.c | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h index 03d5140a6f0d..5c0a88821ae9 100644 --- a/arch/powerpc/include/asm/fadump.h +++ b/arch/powerpc/include/asm/fadump.h @@ -212,7 +212,7 @@ struct fad_crash_memory_ranges { unsigned long long size; }; -extern int is_fadump_boot_memory_area(u64 addr, ulong size); +extern int is_fadump_memory_area(u64 addr, ulong size); extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data); extern int fadump_reserve_mem(void); diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 4884ab796f4a..2fda1e4a6318 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -162,13 +162,19 @@ int __init early_init_dt_scan_fw_dump(unsigned long node, /* * If fadump is registered, check if the memory provided - * falls within boot memory area. + * falls within boot memory area and reserved memory area. */ -int is_fadump_boot_memory_area(u64 addr, ulong size) +int is_fadump_memory_area(u64 addr, ulong size) { + u64 d_start = fw_dump.reserve_dump_area_start; + u64 d_end = d_start + fw_dump.reserve_dump_area_size; + if (!fw_dump.dump_registered) return 0; + if (((addr + size) > d_start) && (addr <= d_end)) + return 1; + return (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size; } diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c1578f54c626..e4c658cda3a7 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -389,8 +389,11 @@ static bool lmb_is_removable(struct drmem_lmb *lmb) phys_addr = lmb->base_addr; #ifdef CONFIG_FA_DUMP - /* Don't hot-remove memory that falls in fadump boot memory area */ - if (is_fadump_boot_memory_area(phys_addr, block_sz)) + /* + * Don't hot-remove memory that falls in fadump boot memory area + * and memory that is reserved for capturing old kernel memory. + */ + if (is_fadump_memory_area(phys_addr, block_sz)) return false; #endif