From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02122C433FE for ; Sat, 12 Dec 2020 15:23:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A466722240 for ; Sat, 12 Dec 2020 15:23:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A466722240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nR8DWJP9o9kqeT+lIJg7Vd9+SV/jfttPeDu70zi8O+A=; b=NwfQKP5UWphT6lhW8b0bmcDp9 Y1vXiIPmD1RwLJ847SodzGjMvvPWwoLpeTJJi6nB5CP8+qhKM42ex7qFkquxkxIepfZh9rZuYdBhe T1CPpnVIp/g1pSBLTsI8sjPFZiLcyTiLlk4QQsG9XKJ+KSAIGT9jvVT7VxNLSC31MG78aS3i0v5uq 3c53T8vtoS93GBzK4EftZDmjfjz1ZhUmAIymloNzWi4x7LxqAmoFQaX2pzQ9Grx5OVf7J+SGLaDYz NfECHuyfH6tTMMcYAb3yUc8GaAhVQ1skP813yMzS4vufmsi0IPXzD+ayTpt2haxBjrtVBhKjJgVy2 Df5WSwtmg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ko6iz-0007oF-5k; Sat, 12 Dec 2020 15:22:21 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ko6iw-0007no-C4 for linux-arm-kernel@lists.infradead.org; Sat, 12 Dec 2020 15:22:19 +0000 Received: from [192.168.0.104] (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 4997020B717A; Sat, 12 Dec 2020 07:22:17 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4997020B717A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1607786537; bh=BtIRQkWov9YJUVmerRIbFF7Rh3Yzt5VxVWb+6PFNe3o=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=W0yDY4BEiRN2lCJRoUEguoFZzDQk6PhmOHyom5/tu7Za1OkdqaxxNc3xN4yXIQp4N tAb5BelU2ivcIi0Uaa9pB1LM+iBdQaSvuqJP4fDzlEuLT0ymYeLivoymE8EwyNlO+Y 3aiZFuzyd437g5yZkg+G0urm4VPL7bdMg7QT5K2M= Subject: Re: [RFC PATCH 4/4] powerpc: Use common of_kexec_setup_new_fdt() To: Rob Herring , takahiro.akashi@linaro.org, will@kernel.org, catalin.marinas@arm.com, mpe@ellerman.id.au References: <20201211221006.1052453-1-robh@kernel.org> <20201211221006.1052453-5-robh@kernel.org> From: Lakshmi Ramasubramanian Message-ID: Date: Sat, 12 Dec 2020 07:22:16 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201211221006.1052453-5-robh@kernel.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201212_102218_591005_0D136D6C X-CRM114-Status: GOOD ( 26.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, benh@kernel.crashing.org, bhsharma@redhat.com, tao.li@vivo.com, zohar@linux.ibm.com, paulus@samba.org, vincenzo.frascino@arm.com, frowand.list@gmail.com, sashal@kernel.org, masahiroy@kernel.org, jmorris@namei.org, linux-arm-kernel@lists.infradead.org, serge@hallyn.com, devicetree@vger.kernel.org, pasha.tatashin@soleen.com, prsriva@linux.microsoft.com, hsinyi@chromium.org, allison@lohutok.net, christophe.leroy@c-s.fr, mbrugger@suse.com, balajib@linux.microsoft.com, dmitry.kasatkin@gmail.com, linux-kernel@vger.kernel.org, james.morse@arm.com, linux-integrity@vger.kernel.org, Thiago Jung Bauermann Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/11/20 2:10 PM, Rob Herring wrote: > Signed-off-by: Rob Herring > --- > > After the IMA changes, delete_fdt_mem_rsv() can also be removed. > > arch/powerpc/kexec/file_load.c | 125 ++------------------------------- > 1 file changed, 6 insertions(+), 119 deletions(-) > This change looks good to me. Reviewed-by: Lakshmi Ramasubramanian -lakshmi > diff --git a/arch/powerpc/kexec/file_load.c b/arch/powerpc/kexec/file_load.c > index e452b11df631..956bcb2d1ec2 100644 > --- a/arch/powerpc/kexec/file_load.c > +++ b/arch/powerpc/kexec/file_load.c > @@ -16,6 +16,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -156,132 +157,18 @@ int setup_new_fdt(const struct kimage *image, void *fdt, > unsigned long initrd_load_addr, unsigned long initrd_len, > const char *cmdline) > { > - int ret, chosen_node; > - const void *prop; > - > - /* Remove memory reservation for the current device tree. */ > - ret = delete_fdt_mem_rsv(fdt, __pa(initial_boot_params), > - fdt_totalsize(initial_boot_params)); > - if (ret == 0) > - pr_debug("Removed old device tree reservation.\n"); > - else if (ret != -ENOENT) > - return ret; > - > - chosen_node = fdt_path_offset(fdt, "/chosen"); > - if (chosen_node == -FDT_ERR_NOTFOUND) { > - chosen_node = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), > - "chosen"); > - if (chosen_node < 0) { > - pr_err("Error creating /chosen.\n"); > - return -EINVAL; > - } > - } else if (chosen_node < 0) { > - pr_err("Malformed device tree: error reading /chosen.\n"); > - return -EINVAL; > - } > - > - /* Did we boot using an initrd? */ > - prop = fdt_getprop(fdt, chosen_node, "linux,initrd-start", NULL); > - if (prop) { > - uint64_t tmp_start, tmp_end, tmp_size; > - > - tmp_start = fdt64_to_cpu(*((const fdt64_t *) prop)); > - > - prop = fdt_getprop(fdt, chosen_node, "linux,initrd-end", NULL); > - if (!prop) { > - pr_err("Malformed device tree.\n"); > - return -EINVAL; > - } > - tmp_end = fdt64_to_cpu(*((const fdt64_t *) prop)); > - > - /* > - * kexec reserves exact initrd size, while firmware may > - * reserve a multiple of PAGE_SIZE, so check for both. > - */ > - tmp_size = tmp_end - tmp_start; > - ret = delete_fdt_mem_rsv(fdt, tmp_start, tmp_size); > - if (ret == -ENOENT) > - ret = delete_fdt_mem_rsv(fdt, tmp_start, > - round_up(tmp_size, PAGE_SIZE)); > - if (ret == 0) > - pr_debug("Removed old initrd reservation.\n"); > - else if (ret != -ENOENT) > - return ret; > - > - /* If there's no new initrd, delete the old initrd's info. */ > - if (initrd_len == 0) { > - ret = fdt_delprop(fdt, chosen_node, > - "linux,initrd-start"); > - if (ret) { > - pr_err("Error deleting linux,initrd-start.\n"); > - return -EINVAL; > - } > - > - ret = fdt_delprop(fdt, chosen_node, "linux,initrd-end"); > - if (ret) { > - pr_err("Error deleting linux,initrd-end.\n"); > - return -EINVAL; > - } > - } > - } > - > - if (initrd_len) { > - ret = fdt_setprop_u64(fdt, chosen_node, > - "linux,initrd-start", > - initrd_load_addr); > - if (ret < 0) > - goto err; > - > - /* initrd-end is the first address after the initrd image. */ > - ret = fdt_setprop_u64(fdt, chosen_node, "linux,initrd-end", > - initrd_load_addr + initrd_len); > - if (ret < 0) > - goto err; > - > - ret = fdt_add_mem_rsv(fdt, initrd_load_addr, initrd_len); > - if (ret) { > - pr_err("Error reserving initrd memory: %s\n", > - fdt_strerror(ret)); > - return -EINVAL; > - } > - } > - > - if (cmdline != NULL) { > - ret = fdt_setprop_string(fdt, chosen_node, "bootargs", cmdline); > - if (ret < 0) > - goto err; > - } else { > - ret = fdt_delprop(fdt, chosen_node, "bootargs"); > - if (ret && ret != -FDT_ERR_NOTFOUND) { > - pr_err("Error deleting bootargs.\n"); > - return -EINVAL; > - } > - } > + int ret; > > - if (image->type == KEXEC_TYPE_CRASH) { > - /* > - * Avoid elfcorehdr from being stomped on in kdump kernel by > - * setting up memory reserve map. > - */ > - ret = fdt_add_mem_rsv(fdt, image->arch.elf_headers_mem, > - image->arch.elf_headers_sz); > - if (ret) { > - pr_err("Error reserving elfcorehdr memory: %s\n", > - fdt_strerror(ret)); > - goto err; > - } > - } > + ret = of_kexec_setup_new_fdt(image, fdt, initrd_load_addr, initrd_len, cmdline); > + if (ret) > + goto err; > > - ret = setup_ima_buffer(image, fdt, chosen_node); > + ret = setup_ima_buffer(image, fdt, fdt_path_offset(fdt, "/chosen")); > if (ret) { > pr_err("Error setting up the new device tree.\n"); > return ret; > } > > - ret = fdt_setprop(fdt, chosen_node, "linux,booted-from-kexec", NULL, 0); > - if (ret) > - goto err; > - > return 0; > > err: > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel