From patchwork Sun Jan 15 15:02:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sourabh Jain X-Patchwork-Id: 1726736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m3x3qRGZ; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nvz436FXZz23fp for ; Mon, 16 Jan 2023 02:05:39 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Nvz4355Q8z3cKX for ; Mon, 16 Jan 2023 02:05:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m3x3qRGZ; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Nvz0b4FpYz3cFd for ; Mon, 16 Jan 2023 02:02:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m3x3qRGZ; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Nvz0W4Yt3z4xN6 for ; Mon, 16 Jan 2023 02:02:35 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4Nvz0W4WM8z4xwl; Mon, 16 Jan 2023 02:02:35 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=sourabhjain@linux.ibm.com; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=m3x3qRGZ; dkim-atps=neutral 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 gandalf.ozlabs.org (Postfix) with ESMTPS id 4Nvz0W2HDQz4xN6 for ; Mon, 16 Jan 2023 02:02:35 +1100 (AEDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30FDNJus008147; Sun, 15 Jan 2023 15:02:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=se/AbKxEAzPGIT8b7kYc0WK57vD4QgbFQND1jbMcWVU=; b=m3x3qRGZLnblb6OopdO+jnMDpt3XGlnSH2yqh+IOYeTF1e+fBardjrq9IKMn09ud/u17 X+jbz42KkekhCF0ftKORpVTvedOo6/3dOvobezLrdWehzf0jylyrZ10sVWKsv1paXE7C u/s3z6sm++C90KxnmQo5N8L+uOK4u5PphZKcVZ3iKUivvI3FGfFIyPzv1UezPKbcxaQG 65v7UcBvoezkUB4CJFMKPSMQbaq+SYtQj4dPVHLR4Oyvqa+GbvD7MpVt+HLYlrh3gX3T YwgAmw2dSTa1R8Pgoel3mk6i4jGYd4H2d8/3lB0SH4q4RehdRmaOZURWslLCL2YXn1iM XQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4cvw5k0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Jan 2023 15:02:28 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 30FF0Olg000770; Sun, 15 Jan 2023 15:02:27 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n4cvw5k00-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Jan 2023 15:02:27 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30F1lAgn006229; Sun, 15 Jan 2023 15:02:25 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3n3knfhcvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 15 Jan 2023 15:02:25 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30FF2LBn40894956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 15 Jan 2023 15:02:21 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B8D92004B; Sun, 15 Jan 2023 15:02:21 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB9AF20040; Sun, 15 Jan 2023 15:02:18 +0000 (GMT) Received: from sjain014.ibmuc.com (unknown [9.43.71.156]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Sun, 15 Jan 2023 15:02:18 +0000 (GMT) From: Sourabh Jain To: linuxppc-dev@ozlabs.org, mpe@ellerman.id.au Subject: [PATCH v7 3/8] powerpc/crash: update kimage_arch struct Date: Sun, 15 Jan 2023 20:32:01 +0530 Message-Id: <20230115150206.431528-4-sourabhjain@linux.ibm.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230115150206.431528-1-sourabhjain@linux.ibm.com> References: <20230115150206.431528-1-sourabhjain@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: k3FhR-SJjy1pGfRBPviQy0fBGsFU3cPl X-Proofpoint-GUID: UKiRXUiOpl6GxEnJhd1gQkvWTRdvDLj5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-15_09,2023-01-13_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 adultscore=0 bulkscore=0 clxscore=1015 suspectscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301150116 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: eric.devolder@oracle.com, bhe@redhat.com, mahesh@linux.vnet.ibm.com, kexec@lists.infradead.org, ldufour@linux.ibm.com, hbathini@linux.ibm.com Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Add a new member "fdt_index" to kimage_arch struct to hold the index of the FDT (Flattened Device Tree) segment in the kexec segment array. Having direct access to FDT segment will help arch crash hotplug handler to avoid looping kexec segment array to identify the FDT segment index for every FDT update on hotplug events. The fdt_index is initialized during the kexec load for both kexec_load and kexec_file_load system call. Signed-off-by: Sourabh Jain --- arch/powerpc/include/asm/kexec.h | 7 +++++++ arch/powerpc/kexec/core_64.c | 27 +++++++++++++++++++++++++++ arch/powerpc/kexec/elf_64.c | 6 ++++++ arch/powerpc/kexec/file_load_64.c | 5 +++++ 4 files changed, 45 insertions(+) diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h index 8090ad7d97d9d..5a322c1737661 100644 --- a/arch/powerpc/include/asm/kexec.h +++ b/arch/powerpc/include/asm/kexec.h @@ -103,6 +103,10 @@ void kexec_copy_flush(struct kimage *image); struct crash_mem; int update_cpus_node(void *fdt); int get_crash_memory_ranges(struct crash_mem **mem_ranges); +#if defined(CONFIG_CRASH_HOTPLUG) +int machine_kexec_post_load(struct kimage *image); +#define machine_kexec_post_load machine_kexec_post_load +#endif #endif #if defined(CONFIG_CRASH_DUMP) && defined(CONFIG_PPC_RTAS) @@ -118,6 +122,9 @@ extern const struct kexec_file_ops kexec_elf64_ops; struct kimage_arch { struct crash_mem *exclude_ranges; +#if defined(CONFIG_CRASH_HOTPLUG) + int fdt_index; +#endif unsigned long backup_start; void *backup_buf; void *fdt; diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c index 0b292f93a74cc..3d4fe1aa6f761 100644 --- a/arch/powerpc/kexec/core_64.c +++ b/arch/powerpc/kexec/core_64.c @@ -77,6 +77,33 @@ int machine_kexec_prepare(struct kimage *image) return 0; } +#if defined(CONFIG_CRASH_HOTPLUG) +int machine_kexec_post_load(struct kimage *kimage) +{ + int i; + void *ptr; + unsigned long mem; + + /* Mark fdt_index invalid */ + kimage->arch.fdt_index = -1; + + if (kimage->type != KEXEC_TYPE_CRASH) + return 0; + + for (i = 0; i < kimage->nr_segments; i++) { + mem = kimage->segment[i].mem; + ptr = __va(mem); + + if (ptr && fdt_magic(ptr) == FDT_MAGIC) { + kimage->arch.fdt_index = i; + break; + } + } + + return 0; +} +#endif + /* Called during kexec sequence with MMU off */ static notrace void copy_segments(unsigned long ind) { diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c index eeb258002d1e0..2a17f171661f1 100644 --- a/arch/powerpc/kexec/elf_64.c +++ b/arch/powerpc/kexec/elf_64.c @@ -123,6 +123,12 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, kbuf.buf_align = PAGE_SIZE; kbuf.top_down = true; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; + +#if defined(CONFIG_CRASH_HOTPLUG) + image->arch.fdt_index = image->nr_segments; +#endif + kbuf.memsz = fdt_totalsize(fdt); + ret = kexec_add_buffer(&kbuf); if (ret) goto out_free_fdt; diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 9bc70b4d8eafc..725f74d1b928c 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -1153,6 +1153,11 @@ int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, return ret; } +#if defined(CONFIG_CRASH_HOTPLUG) + /* Mark fdt_index invalid */ + image->arch.fdt_index = -1; +#endif + return kexec_image_probe_default(image, buf, buf_len); }