Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp870576rwb; Wed, 26 Jul 2023 04:23:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlGuPeBdvXaJ1CHr262G1jDdA9vPz8sqkdPmxzeULHcZYUU8CvXt/DvQ2quV5GBUkR2nuPvK X-Received: by 2002:a05:6402:54d:b0:522:1956:a29e with SMTP id i13-20020a056402054d00b005221956a29emr1229644edx.34.1690370624857; Wed, 26 Jul 2023 04:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690370624; cv=none; d=google.com; s=arc-20160816; b=y0hUSIoQa0VaMZjQAdC+kzwxJNSXrE2g0vgsvuau3CeKXcEHviJGYAW+xgYheUJ9Vi dAVH7cW4++bt3xw3BIzN4H0L5KqIB201TTeKHsQc+cFwq+5rD8pn57AZrcZWWElaEkwk KhMSjsgW1FumrKXraXNh7jvV/Gz5Domc6ARvBahjutkfgiIehysKDpQRPJeJWuXUowFh 3ZPSqiPyTVdneKjYy5TnfMauwG5pBNxPGuEJMj7xj7t7fnfd+c1oyLY/gTC3kwkNmLyz 60G3J+atu0DpFovKsC/H4+2fpS1sBHxb7wQ4VDKzsz+1F3sbouNsGRdJt8F22gDiecXR p6wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/weAtwTHjNO7rS6y4GhdgsImXCWIMlLBhob2idfNOcc=; fh=628iOkxKoFjwYFpe4/UUsO7eEG2fFpt/bCqQ+fGWed4=; b=T3XY8U6vMfRlU65cFtGGu/3AaS+RMfp8IfIpyU9fkV7bWZ/kuSwyXgY/a/0be4E3MW ZLmrCWC8VcwYLo2GeUL9m6a+eWkEBXqJUjC+ErvJyrPT/5MJ06PDw7SvpefWrzkxETao Z1RXk5A4/1Bi8JoLSAaub7Tynp1g26/+OUM8RZ8i7yjbs6kKhwQWBjzIn3XxtD93/ZIy md/ybCuzaIpCTqp+fRPwFkeh+aMskvwqQS5FuK486KNPl776eRS0AhkJJ4EbPgpNS3iH 1x80K54qhO3fBfkFmkOcXdDrt4OjeV5lu6bPxYBSlu3PnGhPi3+7iqt1n30ZFKvZ7Saj UB3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a05640203c800b0051e065bbc1dsi9702668edw.36.2023.07.26.04.23.19; Wed, 26 Jul 2023 04:23:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232277AbjGZJ4r (ORCPT + 99 others); Wed, 26 Jul 2023 05:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbjGZJ4U (ORCPT ); Wed, 26 Jul 2023 05:56:20 -0400 Received: from frasgout12.his.huawei.com (unknown [14.137.139.154]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCB93B6 for ; Wed, 26 Jul 2023 02:55:21 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout12.his.huawei.com (SkyGuard) with ESMTP id 4R9pp303mvz9v7bl for ; Wed, 26 Jul 2023 17:42:03 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.81.211.226]) by APP1 (Coremail) with SMTP id LxC2BwBHo95C7cBk+WYTBQ--.33492S5; Wed, 26 Jul 2023 10:54:52 +0100 (CET) From: Petr Tesarik To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Li Huafei , Liao Chang , Masahiro Yamada , Kees Cook , Andrew Morton , Heiko Stuebner , Ricardo Ribalda , Alyssa Ross , Li Zhengyu , linux-riscv@lists.infradead.org (open list:RISC-V ARCHITECTURE), kexec@lists.infradead.org, linux-kernel@vger.kernel.org (open list) Cc: Torsten Duwe , Roberto Sassu , petr@tesarici.cz Subject: [PATCH v2 3/3] riscv/kexec: load initrd high in available memory Date: Wed, 26 Jul 2023 11:54:01 +0200 Message-Id: <67c8eb9eea25717c2c8208d9bfbfaa39e6e2a1c6.1690365011.git.petr.tesarik.ext@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwBHo95C7cBk+WYTBQ--.33492S5 X-Coremail-Antispam: 1UD129KBjvJXoWxJr13KrWrXFWfuw4kArW7XFb_yoW8Gr1Dpw sxCF4UGrWUuwsrC34j93Wxua48Aa95Wr1aga1DCayrJrs8XrW5Z3yqq342vF4vkr1agF9Y vFyY9r1S93WkA3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQq14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26r4j6F4UM28EF7xvwVC2z280aVCY1x0267AKxVW8Jr0_Cr1U M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxkF7I0En4kS14v26r1q6r43MxkF7I0Ew4C26cxK6c8Ij28IcwCF04k20xvY0x0E wIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UMIIF0xvE42 xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF 7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUjmFAJUUUUU== X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, RCVD_IN_MSPIKE_BL,RCVD_IN_MSPIKE_L3,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Torsten Duwe When initrd is loaded low, the secondary kernel fails like this: INITRD: 0xdc581000+0x00eef000 overlaps in-use memory region This initrd load address corresponds to the _end symbol, but the reservation is aligned on PMD_SIZE, as explained by a comment in setup_bootmem(). It is technically possible to align the initrd load address accordingly, leaving a hole between the end of kernel and the initrd, but it is much simpler to allocate the initrd top-down. Fixes: 838b3e28488f ("RISC-V: Load purgatory in kexec_file") Signed-off-by: Torsten Duwe Signed-off-by: Petr Tesarik Cc: stable@vger.kernel.org --- arch/riscv/kernel/elf_kexec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 38390d3bdcac..c08bb5c3b385 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -281,7 +281,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, kbuf.buffer = initrd; kbuf.bufsz = kbuf.memsz = initrd_len; kbuf.buf_align = PAGE_SIZE; - kbuf.top_down = false; + kbuf.top_down = true; kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); if (ret) -- 2.25.1