From patchwork Mon Jul 8 21:15:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11035801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C07C414DB for ; Mon, 8 Jul 2019 21:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF0FF28396 for ; Mon, 8 Jul 2019 21:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0F2F284C3; Mon, 8 Jul 2019 21:16:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 469E228396 for ; Mon, 8 Jul 2019 21:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f8LxXPMQ1wSJznE/4k58emuiSdHaruNV/0M1hKxpD1M=; b=YDtBGEw5TtX8z+ etTuRdJ5Tw/Umu8O7pfUJYwAmyaZSl63dYlg718l/9FrKR9TX5y0XGVF8VmSMyqI0eRoeY7qMKOku KsW3wyakpwc0lY+Fads4khmF/dXjlDBwOc4qVDIqskp1/qevAg54dKYpzht+XL6CxcCpoc7EcsUA9 NjEWsUD06CM0QI0baqkuhAgaAWDcVms0lb1b1444hoLEeh3azuAmhhg+vJ7IFHJ3Kq5a6164zig8v /z7tJM61vOgDzNNI67zmTOdBhFvTJ1r3rL4nxdTYazKBQ2Xz8jG/fPxI5zhv5AocZkFZT4J1neB2n KVHX9SE9TC7h5dTcO4kA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkb0D-0002PP-MB; Mon, 08 Jul 2019 21:16:49 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkayz-0001N1-IZ for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2019 21:15:37 +0000 Received: by mail-qt1-x842.google.com with SMTP id y26so6945982qto.4 for ; Mon, 08 Jul 2019 14:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O8sp7Ivz1alrz3xXygPalicyjdu3OPu+GkykS7h2DZg=; b=n8BIhwWJ9zh0jUg2RW2/uYQy7FXCgRGeTdMBO55KXOXgAIespxSPLZq0PYdQHargu4 8/6ZmX6+n021l86aooEGRSG6OOh9z87P2hsOb//zkA6XSfbnLwX1J6q9EqiRDhiSEkei 37/LIxbZzFCypM5/mZYla7j/sFWUIrbc8e3qhgO4wFofOmUK0lhXe4tr6tDxWT0nr2tS QQ0+d7Qy7D/REmw0t12Dt0EtWx80RzWMBAEUOejhW8CkeW2/+kE8QKMZkyyV8nLai6eQ 0uWgAgMS4TLYACEQUE8stDXIn7xumtxeI3mjoGdxI0wMvKfmReYsVjRk6sJfFqriuHbY Us6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O8sp7Ivz1alrz3xXygPalicyjdu3OPu+GkykS7h2DZg=; b=MtkfCgrKB1ac4ZyX/yPio/MO9Vxgpp0P9tAjb0YC+Hi0BpT7rPRY9gNKM3+oSwIbGX qcOvoplsjSaPeIjdoSQYFwFCZUp8CnzUzCU4Ja3qwEdTFFoiQAzycYFg8aPVr5NIct7r 8K1Ak7fRlDpilfu2v1pALh74KmSm43M0HBpahSpkN4BZg2ZM53j2a60a6+mlFPUyyvKv V2ELe+umaj371oydANOE2VAoNqG6d++Uf8M+r0WnII+pLHBBdOwdPmW3/IhuG0WcUS5D x3G7dUX8XrltbcpbTTTYQCBr6W1Fa7k39bWvXClLf6g7wtQ+7+VfYzKT5QO+1vCrhnu+ SUGw== X-Gm-Message-State: APjAAAVbZ1hikbbL1KQIUsZEpCH2fSMpdxhrXxTyCVrEaceB/9Ng7t3h oARXPmjINv8ZeJY7zMcaiMHdHnmmUf4= X-Google-Smtp-Source: APXvYqyKqoOHu6EcUgIJIytE2kcvp422ziKgpaW7euQ8lCRv+YnhnmdNGlmL0VXgx8QTvMj1RSZ8nQ== X-Received: by 2002:a0c:b148:: with SMTP id r8mr16207600qvc.240.1562620532517; Mon, 08 Jul 2019 14:15:32 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id b67sm8335620qkd.82.2019.07.08.14.15.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:15:31 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [v1 1/5] kexec: quiet down kexec reboot Date: Mon, 8 Jul 2019 17:15:24 -0400 Message-Id: <20190708211528.12392-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708211528.12392-1-pasha.tatashin@soleen.com> References: <20190708211528.12392-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190708_141534_192500_F551F089 X-CRM114-Status: GOOD ( 10.69 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Here is a regular kexec command sequence and output: ===== $ kexec --reuse-cmdline -i --load Image $ kexec -e [ 161.342002] kexec_core: Starting new kernel Welcome to Buildroot buildroot login: ===== Even when "quiet" kernel parameter is specified, "kexec_core: Starting new kernel" is printed. This message has KERN_EMERG level, but there is no emergency, it is a normal kexec operation, so quiet it down to appropriate KERN_NOTICE. Machines that have slow console baud rate benefit from less output. Signed-off-by: Pavel Tatashin Reviewed-by: Simon Horman --- kernel/kexec_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index d5870723b8ad..2c5b72863b7b 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -1169,7 +1169,7 @@ int kernel_kexec(void) * CPU hotplug again; so re-enable it here. */ cpu_hotplug_enable(); - pr_emerg("Starting new kernel\n"); + pr_notice("Starting new kernel\n"); machine_shutdown(); } From patchwork Mon Jul 8 21:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11035799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B74417D5 for ; Mon, 8 Jul 2019 21:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 582832837D for ; Mon, 8 Jul 2019 21:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B3C9283BB; Mon, 8 Jul 2019 21:16:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3D602837D for ; Mon, 8 Jul 2019 21:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cLuN509HlKt/4onRSyP8aZn2yfJvqbqKw2JYBDzlJi8=; b=CTVvYn3CPE4fBq f86Oj4ofxE+HU6+6I0I+zwucL8ePG182n0Qd9mNIo3oNqeD7Z5lcyaLcNKAtJOKrCGAPdktZt3ezS TOwMEs07jexeHFh3YUQHC1AGJx2N9VUfwS/xrjlpxpGU/9F0QNl9OYQSiz4jnhpy/BLU4s46liTQo ywlMSKwsvKhL6VW1U/uNV2fXQXnN+1xmJX1VDDN7PngESqjhCxuUoqfqkyVzXvof2/6bFsIU348hN vRDnVEFxupGOmKEEl4v7vF2lZ0y23JMn7iIq5HuSPUjGXnW/W9rIgTfaU32/j4MmhK6TXspxnIeb4 P2WEWohxkC5rJPao+Q2Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkazv-0002BP-EP; Mon, 08 Jul 2019 21:16:31 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkaz0-0001OR-Vm for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2019 21:15:37 +0000 Received: by mail-qt1-x844.google.com with SMTP id h18so12089874qtm.9 for ; Mon, 08 Jul 2019 14:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VdsesycGrscxvl9VUJv2OrYGiO6I5hjIVNNGDZpPz+A=; b=mbcbklPnE9aSK5WgO3DjHoIPCmDRPu0y6gFhVqT2wERSQkqrlINfT1Dum/1YBHqVIA MHfCGiZYhNcyqdpiDNvMZSUSkBjk9mmUm2UzAXxyreXwkDarMe79+dMnFwRPOh7+l6Tk aB6rNkHgLO7Y1Jiz9NmlCAtxcQsnJZJn3GDc2qcLNW/H2zSoSBaJvjnwMgsVYjZasY6h wMgRHG4K4lnwl6PWSVbLTrSouwk/nknjx/sQIWAwaSwgSoByC78yhCB9mcQr5qM4iUFx zS5tOkS+Tj8MCjoQW99WEy4HdQ8WxAlpnEJNn0bceuRbwkIodt64QR6c1sZewin18v6i Sqww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VdsesycGrscxvl9VUJv2OrYGiO6I5hjIVNNGDZpPz+A=; b=kfguVBm9gaFFBKmiY8oousPtzytYZwTp9kTmNBk3W1s2A/5qW1TvisT9Y3lRfWAWlh wKHJbdU4aWgdVXTwC6z/BEnDenSh9PJ3AZzyzTzUaJpeAfySyLwFH2/SpkXPkryAAcZy IcbE+9Kmut41VdGjniGrRci2Px6B0bnLacFs6+UTEV39HVgjB1rBBeMrmHk2lfSrantZ 1dVnBtlgeJ1Ir620gGBvy78m7Wp4rftMfHP3Id2CJo6xAiekwZqKNl5xQGeC5SoSuAG/ 2Yfqv0f8iLdWk14k1mjOgfO3n6870Mkx0EZ/nmQIcC7gAEqG8Swsgk75V6x8M8z9EqZl xIsA== X-Gm-Message-State: APjAAAUfYf8PXrI0Ivaf/kbq4Uup6MOGWuz2eUaaH2Jdc1tPTKnbe/Vz 1uh3pIMrT/g+rZ26/Gie3IR7RbikiAI= X-Google-Smtp-Source: APXvYqxh88FuDHDTA50xcvkZxoDS6gx6EQNHyyvXUFPd1oxFXlmv0rBVOQea/c8sZqigS6xV/quFaw== X-Received: by 2002:a0c:89b7:: with SMTP id 52mr16660367qvr.199.1562620533833; Mon, 08 Jul 2019 14:15:33 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id b67sm8335620qkd.82.2019.07.08.14.15.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:15:33 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [v1 2/5] kexec: add resource for normal kexec region Date: Mon, 8 Jul 2019 17:15:25 -0400 Message-Id: <20190708211528.12392-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708211528.12392-1-pasha.tatashin@soleen.com> References: <20190708211528.12392-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190708_141535_290180_3C3408E1 X-CRM114-Status: GOOD ( 12.41 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP crashk_res resource is used to reserve memory for crash kernel. There is also, however, a benefit to reserve memory for normal kernel to speed up reboot performance. This is because during regular kexec reboot, kernel performs relocations to the final destination of the loaded segments, and the relocation might take a long time especially if initramfs is big. Therefore, similarly to crashk_res, add kexeck_res that will be used to reserve memory for normal kexec kernel. Signed-off-by: Pavel Tatashin --- include/linux/ioport.h | 1 + include/linux/kexec.h | 6 ++++-- kernel/kexec_core.c | 9 +++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index da0ebaec25f0..3b18a3c112f3 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -133,6 +133,7 @@ enum { IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5, IORES_DESC_DEVICE_PRIVATE_MEMORY = 6, IORES_DESC_DEVICE_PUBLIC_MEMORY = 7, + IORES_DESC_KEXEC_KERNEL = 8, }; /* helpers to define resources */ diff --git a/include/linux/kexec.h b/include/linux/kexec.h index b9b1bc5f9669..4c1121b385fb 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -303,12 +303,14 @@ extern int kexec_load_disabled; #define KEXEC_FILE_FLAGS (KEXEC_FILE_UNLOAD | KEXEC_FILE_ON_CRASH | \ KEXEC_FILE_NO_INITRAMFS) -/* Location of a reserved region to hold the crash kernel. - */ +/* Location of a reserved region to hold the crash kernel. */ extern struct resource crashk_res; extern struct resource crashk_low_res; extern note_buf_t __percpu *crash_notes; +/* Location of a reserved region to hold normal kexec kernel. */ +extern struct resource kexeck_res; + /* flag to track if kexec reboot is in progress */ extern bool kexec_in_progress; diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 2c5b72863b7b..932feadbeb3a 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -70,6 +70,15 @@ struct resource crashk_low_res = { .desc = IORES_DESC_CRASH_KERNEL }; +/* Location of the reserved area for the normal kexec kernel */ +struct resource kexeck_res = { + .name = "Kexec kernel", + .start = 0, + .end = 0, + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_KEXEC_KERNEL +}; + int kexec_should_crash(struct task_struct *p) { /* From patchwork Mon Jul 8 21:15:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11035805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C27AD14DB for ; Mon, 8 Jul 2019 21:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B107B28396 for ; Mon, 8 Jul 2019 21:17:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A52CA284C3; Mon, 8 Jul 2019 21:17:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3814828396 for ; Mon, 8 Jul 2019 21:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GqIBGc93sbAh0Ox57zutXlVh/vqT8QDSNNZxBNGAX64=; b=JmsniQb6alkGMt fQAV0LRcKGcFjPOP+99bNxRdyHvOnn4pTnsPLyyBEgyb5OTtvbDk62TAnwUEf4lhC/55xgV0sYnnl 7C90QDynHrKQ62AAxJLvA2ASmsxQ9o2m8i0Y3mGWsmp9iBuyvfw2DzJB4ZSa56hxTvXgF79a5FtG7 QBY35Bg18d8qpm2GNu2Z2EJN1ElMWeyWFWF0jDK4LqFuZcdj/1cxyo77N6+OnaoMyqRVvtptgB7wH MTuqenIoHEOCtMwgDcuhmzBKydXzelDWrHbgVamC6QxzmCiXiibBTzLHNMDoGxEhTtrIhRUg8r2bs qzstbrDZhscCj7I7c4dQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkb0o-0002wV-9u; Mon, 08 Jul 2019 21:17:26 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkaz2-0001QE-B4 for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2019 21:15:39 +0000 Received: by mail-qt1-x841.google.com with SMTP id a15so19480053qtn.7 for ; Mon, 08 Jul 2019 14:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=vxweX2U2+Z856CcsxOG088urab10u3d6VzbrdBwUe6o=; b=XkNfo7Ng1869ovdwpudNrw0wlKf9MA92JwTYiEJph+VGQaPDhIC8ozhsHnT3ZFniLu xX5baRnstpeEOucyVITA9Xz9gppuLf27+QYgMNoyyfvQQhbQm0IkYXSD4wudfvFtmWdc ft6PJVK9OseR8BeKy0amPm4xmQjutbUoow+0G2TPi/J3Zv8+jT9lkM9bUP73Sk0FgLFe Zo2AHEwA/8MQzVRxCMMmTV55f20IHgKxNhU3CGLLk4SdrOP78pSafOWNNt8ATwroaJWg DKiMOy0AoBI25TfdY+Ua4a0SXfP583XcfX5hcBjYLwNKKBDiq2qpD/Jk0nTyIcH5vILI mg6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vxweX2U2+Z856CcsxOG088urab10u3d6VzbrdBwUe6o=; b=StlfnzZWX23LVEa9mMrUZyO5AcEmeYDEM7zZ/NJ/KzIaJLuaFJRA1KHa1UIYpAncv4 UnvDPGU+egWM5z2FQjcR3u92eQlYziSBTCdZY2YCDuQLG4wSe4Pwfeyf73p6r9MLsx7h bFGGVMZgPua7Bod+nE5ugCA1gCrL7zC8Ajsald3HUJ+AZa94+R6ArrTq1lD7wkjenyQG CTH6W+bd3bMB0tUK9PNrMP8wjLmHLp9e1TMXNMbz7iSNajqWuRRR/9iH+xgmKf0c0eii fF5sVVas7WDg1J1Y5eSRrijvaCGARm9BDMuNdGbMT6ttis2NBEZ/bQkzFy0P2anQuTI0 A+/w== X-Gm-Message-State: APjAAAVYaPFfA2Kd0VHiKsBwwFoFIdjcTxmMrxsOPUgjIwEMP4Hhiadj WKDy39jxgGbDLmWRe0IVrM93ZEpVLds= X-Google-Smtp-Source: APXvYqzOynfC/xBCJVtVyeRdCM0qBpL/RmjpG/GqV9GNhFtfJLujygjgPzG6SCWKgrGRU8fAmuANkw== X-Received: by 2002:ac8:368a:: with SMTP id a10mr15795831qtc.143.1562620535026; Mon, 08 Jul 2019 14:15:35 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id b67sm8335620qkd.82.2019.07.08.14.15.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:15:34 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [v1 3/5] kexec: export common crashkernel/kexeckernel parser Date: Mon, 8 Jul 2019 17:15:26 -0400 Message-Id: <20190708211528.12392-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708211528.12392-1-pasha.tatashin@soleen.com> References: <20190708211528.12392-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190708_141536_429360_26760EC9 X-CRM114-Status: GOOD ( 11.56 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP To reserve memory for normal kexec reboot, the new parameter: kexeckernel=size[KMG][@offset[KMG]] is used. Its syntax is the same as craskernel=, therefore they can use the same function to parse parameter settings. Rename: __parse_crashkernel() to parse_crash_or_kexec_kernel(), and make it public. Signed-off-by: Pavel Tatashin --- .../admin-guide/kernel-parameters.txt | 7 +++++ include/linux/crash_core.h | 6 +++++ kernel/crash_core.c | 27 ++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 5c7a0f5b0a2f..0f5ce665c7f5 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -739,6 +739,13 @@ It will be ignored when crashkernel=X,high is not used or memory reserved is below 4G. + kexeckernel=size[KMG][@offset[KMG]] + [KNL] Using kexec, Linux can reboot to a new kernel. + This parameter reserves the physical memory region + [offset, offset + size] for that kernel. If '@offset' is + omitted, then a suitable offset is selected + automatically. + cryptomgr.notests [KNL] Disable crypto self-tests diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index 525510a9f965..e90789ff0bec 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -74,5 +74,11 @@ int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base); +int parse_crash_or_kexec_kernel(char *cmdline, + unsigned long long system_ram, + unsigned long long *crash_size, + unsigned long long *crash_base, + const char *name, + const char *suffix); #endif /* LINUX_CRASH_CORE_H */ diff --git a/kernel/crash_core.c b/kernel/crash_core.c index 9f1557b98468..11e0f9837a32 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -224,12 +224,12 @@ static __init char *get_last_crashkernel(char *cmdline, return ck_cmdline; } -static int __init __parse_crashkernel(char *cmdline, - unsigned long long system_ram, - unsigned long long *crash_size, - unsigned long long *crash_base, - const char *name, - const char *suffix) +int __init parse_crash_or_kexec_kernel(char *cmdline, + unsigned long long system_ram, + unsigned long long *crash_size, + unsigned long long *crash_base, + const char *name, + const char *suffix) { char *first_colon, *first_space; char *ck_cmdline; @@ -270,8 +270,9 @@ int __init parse_crashkernel(char *cmdline, unsigned long long *crash_size, unsigned long long *crash_base) { - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, - "crashkernel=", NULL); + return parse_crash_or_kexec_kernel(cmdline, system_ram, crash_size, + crash_base, "crashkernel=", + NULL); } int __init parse_crashkernel_high(char *cmdline, @@ -279,8 +280,9 @@ int __init parse_crashkernel_high(char *cmdline, unsigned long long *crash_size, unsigned long long *crash_base) { - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, - "crashkernel=", suffix_tbl[SUFFIX_HIGH]); + return parse_crash_or_kexec_kernel(cmdline, system_ram, crash_size, + crash_base, "crashkernel=", + suffix_tbl[SUFFIX_HIGH]); } int __init parse_crashkernel_low(char *cmdline, @@ -288,8 +290,9 @@ int __init parse_crashkernel_low(char *cmdline, unsigned long long *crash_size, unsigned long long *crash_base) { - return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, - "crashkernel=", suffix_tbl[SUFFIX_LOW]); + return parse_crash_or_kexec_kernel(cmdline, system_ram, crash_size, + crash_base, "crashkernel=", + suffix_tbl[SUFFIX_LOW]); } Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, From patchwork Mon Jul 8 21:15:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11035797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C48314E5 for ; Mon, 8 Jul 2019 21:16:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29C7D2837D for ; Mon, 8 Jul 2019 21:16:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B3F8283BB; Mon, 8 Jul 2019 21:16:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A03912837D for ; Mon, 8 Jul 2019 21:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MqmJpv5BWDDEzyI0eBgpQuJdP7w/dkNeEj9pXJB5wv0=; b=oU4U/bDYUACCgj sVcA+JsppEyvcyjzfiZi0oy06hVhcdfRK08FAPZrOOcrwQ5X8Btp5huNdxEm3i5B1FrINwjk7J7Sw BLi5qf+yubdsO+n9m7QWF+rEhEMoFygWF+FixcScHbrGdleIt2c1gezqrEDzPT4gQ5OdEwInrXUxP +r2EmaBUw7ovqn6+NWsqyty4d84V/FkVmHOqZAJb2zEz0nKNsvvjo5QJ+iIFAHx/wODIUTGgHQJXU FSjQezvYM247Y0bVQyWztSg6lB3eTcFp0hHRKs9otC+YGoyC2qfl1b99hcE+OoyCZPFIbcX46U9oF XXjC3wYcXb8d6wcaxBAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkazg-0001wo-1J; Mon, 08 Jul 2019 21:16:16 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkaz3-0001Ri-Ex for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2019 21:15:40 +0000 Received: by mail-qk1-x742.google.com with SMTP id r6so14483573qkc.0 for ; Mon, 08 Jul 2019 14:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=0AMQxB8fjID6n1nIoBRP/bexLOV4+LcL9MqYB3dLbp0=; b=nh2063uICAObAjvkowsMusqQTntBkHqsfDRkCKAaQr6mTjmZpjHeQbbJETBcCobAji gGycJV8JxvYKKHhTrBKhzzaa/0oync9yQY22DTAt6Lasb8/KgeCIV1yTfKJfPA4bSP5H XNkKsLyMvQkV72jCjE85v0IoPLvyvhY4i8NIB/SQAT6Sg+vdWDdAa0pNLjGlyZob2RKu KSMLCm5gq949sNAsKLj2ma2oXyJx/ugj3A9fd9byhxVX/hy78ZWLeWfWUB5DKxh9l9tB ExkSwi1sOivngEa7rGmXpr701XcGlSIKddV+gNESh946PsgUjHAjZJ6S9ZUhcy+8ia+V ucWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0AMQxB8fjID6n1nIoBRP/bexLOV4+LcL9MqYB3dLbp0=; b=qQy8GoWdOPU3eglOozcsRCA926Bn3L3/7h3Y77wVC+3jxmmRfpy47aDmNIdOoHeYnE +9qXfSGKdcsmHmfus/XUEICb69IFRBZgBY5rbdnR5vGO5emzZ2eolj9QWKsxQipwCosh 9J1MMPJQ7kjw3ypD396MoGvuhAvO9uW1uq8UFc7o5yN0iUvMppof5LozWl2jcInXjXAJ y2Pe35s3KlhiWvpxW9sbV3f1Pdnp1xeFAroz5aceWG5B7YuurHJI1J8EiHGboGs5MJms nhlfYxYnAiAfjkI00N5qyfVUK9s+t01p0bN4AcM8AmhxB0Ym7Q93QKypX6aXpY1MgQV9 RR0Q== X-Gm-Message-State: APjAAAUuo4AyZzSpDfONl3NG33QxvZKWQ1tjjqVljYT07sL7mzLzJ25m CDea9pkK9vdQ1nnoJ9SnpFaJEQ== X-Google-Smtp-Source: APXvYqxil68FzEbaqfS3VsZ9U/3z7w3WmWgrJNx8pulJ4mSV3A2nSrAQIOKvet23G/V3Ph6Itu0yLw== X-Received: by 2002:ae9:f303:: with SMTP id p3mr15620551qkg.320.1562620536253; Mon, 08 Jul 2019 14:15:36 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id b67sm8335620qkd.82.2019.07.08.14.15.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:15:35 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [v1 4/5] kexec: use reserved memory for normal kexec reboot Date: Mon, 8 Jul 2019 17:15:27 -0400 Message-Id: <20190708211528.12392-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708211528.12392-1-pasha.tatashin@soleen.com> References: <20190708211528.12392-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190708_141537_755339_B1154217 X-CRM114-Status: GOOD ( 15.04 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If memory was reserved for the given segment use it directly instead of allocating on per-page bases. This will avoid relocating this segment to final destination when machine is rebooted. This is done on a per segment bases because user might decide to always load kernel segments at the given address (i.e. non-relocatable kernel), but load initramfs at reserved address, and thus save reboot time on copying initramfs if it is large, and reduces reboot performance. Signed-off-by: Pavel Tatashin --- kernel/kexec_core.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 932feadbeb3a..2a8d8746e0a1 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -154,6 +154,18 @@ static struct page *kimage_alloc_page(struct kimage *image, gfp_t gfp_mask, unsigned long dest); +/* Check whether this segment is fully within the resource */ +static bool segment_is_reserved(struct kexec_segment *seg, struct resource *res) +{ + unsigned long mstart = seg->mem; + unsigned long mend = mstart + seg->memsz - 1; + + if (mstart < phys_to_boot_phys(res->start) || + mend > phys_to_boot_phys(res->end)) + return false; + return true; +} + int sanity_check_segment_list(struct kimage *image) { int i; @@ -246,13 +258,9 @@ int sanity_check_segment_list(struct kimage *image) if (image->type == KEXEC_TYPE_CRASH) { for (i = 0; i < nr_segments; i++) { - unsigned long mstart, mend; - - mstart = image->segment[i].mem; - mend = mstart + image->segment[i].memsz - 1; /* Ensure we are within the crash kernel limits */ - if ((mstart < phys_to_boot_phys(crashk_res.start)) || - (mend > phys_to_boot_phys(crashk_res.end))) + if (!segment_is_reserved(&image->segment[i], + &crashk_res)) return -EADDRNOTAVAIL; } } @@ -848,12 +856,13 @@ static int kimage_load_normal_segment(struct kimage *image, return result; } -static int kimage_load_crash_segment(struct kimage *image, - struct kexec_segment *segment) +static int kimage_load_crash_or_reserved_segment(struct kimage *image, + struct kexec_segment *segment) { - /* For crash dumps kernels we simply copy the data from - * user space to it's destination. - * We do things a page at a time for the sake of kmap. + /* + * For crash dumps and kexec-reserved kernels we simply copy the data + * from user space to it's destination. We do things a page at a time + * for the sake of kmap. */ unsigned long maddr; size_t ubytes, mbytes; @@ -923,10 +932,14 @@ int kimage_load_segment(struct kimage *image, switch (image->type) { case KEXEC_TYPE_DEFAULT: - result = kimage_load_normal_segment(image, segment); + if (segment_is_reserved(segment, &kexeck_res)) + result = kimage_load_crash_or_reserved_segment(image, + segment); + else + result = kimage_load_normal_segment(image, segment); break; case KEXEC_TYPE_CRASH: - result = kimage_load_crash_segment(image, segment); + result = kimage_load_crash_or_reserved_segment(image, segment); break; } From patchwork Mon Jul 8 21:15:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11035803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30CA917D5 for ; Mon, 8 Jul 2019 21:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A5D12837D for ; Mon, 8 Jul 2019 21:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B9B4283BB; Mon, 8 Jul 2019 21:17:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7B4182837D for ; Mon, 8 Jul 2019 21:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8WiTBYoGxJWwmxaiNoTbwaKfzxhTeH2uXaPki6mdGYg=; b=rsZpDVaylyH5iR 5+WD9cswApejdfwQk5qYUbA77+FTblmDlnw9U6JeLUAOmu5WTlx2mHWcAY7Q6iCdhbTtmkI282M8X D0+0zqz2eKwaD958gSHf7+jJCe1ljetWb9sgDOuBSZ3szfXjPQjbEAr2RhHUPHel3/knY1fPiMKE5 s74MAQIyzZQ9U0LmPdjDn+brxXYr3el+1fw1QZO0Cfrv5vMWeC/fAK17Wqte/UTxL3gs9K4wwV+gt 2aW6zTCy9VxEhKZZKhAYhBES+j77pmyjF3a5dcIXZhwBEyVM5bDompCNlVPTlXC7c0hzmFR5fSODV a710DyJJ2UT46pvWYM8Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hkb0U-0002gf-5B; Mon, 08 Jul 2019 21:17:06 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkaz4-0001TJ-Cq for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2019 21:15:41 +0000 Received: by mail-qk1-x741.google.com with SMTP id r4so14395379qkm.13 for ; Mon, 08 Jul 2019 14:15:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AiVVzsQgxExtlPdXUQO7u3KIlgj9fJXNjXAFaENAUkA=; b=hBOFe5Ugx8wiuHA/gjntnci5gyCoKGx2KeUGJzzIexTkV/nSc9m1wu1T3dPF3WEYlY lwMmi6wk/x1rt0bVkNJWpCL1+QH1ucrG89pfU/Isl/kUcpBebVFOWEvxPALC3iThVuqG ADWFeylsNMjjNctZNfFC/tsxiYCM89r45RVa2JJrS5RMWEiTiWiGUfh2oiNXyupiAH3g cE6WFbGJY3c5kcFPTx0V9QTiI0bipkfLQlrw6OCsuks9o6h6EGGcKxGMbiuZHxlMWMi1 kbLgzBstYWq+jXa6BHc3h9N+ljlc8rZaZy3kFfH+zMMRFV46PunVk3YJusKsL4zZQHKQ hIAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AiVVzsQgxExtlPdXUQO7u3KIlgj9fJXNjXAFaENAUkA=; b=rMtUNj0r+DXCk0A/lTPFBSA3KJGr+UyjU/8agqIFZqF0zdw2HAfyrY0ZiowzmICua6 bIa4hRoaE5x5q9LGmjoqQOMI+YyFcAt8JhGQ1GA1ibZkCd96R1EsjYVa859jfXZA5l53 4qwf++uRU9GiAcihzjXXzuU/Khj7pqB1yhaIAt5DFMyWDIRqDo8LgdjCJYDgK7e6Cg/9 XbfB+Mj2ylF7pENGrNzSTtwRlDJoe9idiHy8Ev7/1m0ylIHNCg/x9RD3s8SKFLjvy8FK IAT1XadbeiUMB1DW+/TswMviosG5bhR6v4aR7bp8I0paxk1KODU35PGIjTVKgnOySoxG qbGA== X-Gm-Message-State: APjAAAUT02MaHR2scG/KNNN0tB7ffXJCCTgdQZRgWc/RKV+LnEkYOCPA clKMKmh4IarcuV9zGepGhacn6g== X-Google-Smtp-Source: APXvYqyHLZkbmfQTKjXh1EEa/IoaB1YEoR8Z3fSF2HU2Rzl8oz3tGEYtOcg6+Dl43IZZhoEp3B/fZg== X-Received: by 2002:a37:be41:: with SMTP id o62mr15906517qkf.356.1562620537487; Mon, 08 Jul 2019 14:15:37 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id b67sm8335620qkd.82.2019.07.08.14.15.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 14:15:36 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [v1 5/5] arm64, kexec: reserve kexeckernel region Date: Mon, 8 Jul 2019 17:15:28 -0400 Message-Id: <20190708211528.12392-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708211528.12392-1-pasha.tatashin@soleen.com> References: <20190708211528.12392-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190708_141538_680093_46100379 X-CRM114-Status: GOOD ( 18.21 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP kexeckernel= is used to reserve memory for normal kexec kernel for faster reboot. Rename reserve_crashkernel() to reserve_crash_or_kexec_kernel(), and generalize it by adding an argument that specifies what is reserved: "crashkernel=" for crash kernel region "kexeckernel=" for normal kexec region Signed-off-by: Pavel Tatashin --- .../admin-guide/kernel-parameters.txt | 10 +-- arch/arm64/kernel/setup.c | 5 ++ arch/arm64/mm/init.c | 83 ++++++++++++------- 3 files changed, 63 insertions(+), 35 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0f5ce665c7f5..a18222c1fbee 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -740,11 +740,11 @@ or memory reserved is below 4G. kexeckernel=size[KMG][@offset[KMG]] - [KNL] Using kexec, Linux can reboot to a new kernel. - This parameter reserves the physical memory region - [offset, offset + size] for that kernel. If '@offset' is - omitted, then a suitable offset is selected - automatically. + [KNL, ARM64] Using kexec, Linux can reboot to a new + kernel. This parameter reserves the physical memory + region [offset, offset + size] for that kernel. If + '@offset' is omitted, then a suitable offset is + selected automatically. cryptomgr.notests [KNL] Disable crypto self-tests diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 7e541f947b4c..9f308fa103c5 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -235,6 +235,11 @@ static void __init request_standard_resources(void) if (crashk_res.end && crashk_res.start >= res->start && crashk_res.end <= res->end) request_resource(res, &crashk_res); + + /* Userspace will find "Kexec kernel" region in /proc/iomem. */ + if (kexeck_res.end && kexeck_res.start >= res->start && + kexeck_res.end <= res->end) + request_resource(res, &kexeck_res); #endif } } diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f3c795278def..dfef39f72faf 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -54,61 +54,83 @@ phys_addr_t arm64_dma_phys_limit __ro_after_init; #ifdef CONFIG_KEXEC_CORE /* - * reserve_crashkernel() - reserves memory for crash kernel + * reserve_crash_or_kexec_kernel() - reserves memory for crash kernel or + * for normal kexec kernel. * - * This function reserves memory area given in "crashkernel=" kernel command - * line parameter. The memory reserved is used by dump capture kernel when - * primary kernel is crashing. + * This function reserves memory area given in "crashkernel=" or "kexeckenel=" + * kernel command line parameter. The memory reserved is used by dump capture + * kernel when primary kernel is crashing, or to load new kexec kernel for + * faster reboot without relocation. */ -static void __init reserve_crashkernel(void) +static void __init reserve_crash_or_kexec_kernel(char *cmd) { - unsigned long long crash_base, crash_size; + unsigned long long base, size; + struct resource *res; + char s[16]; int ret; - ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), - &crash_size, &crash_base); - /* no crashkernel= or invalid value specified */ - if (ret || !crash_size) + /* cmd must be either: "crashkernel=" or "kexeckernel=" */ + if (!strcmp(cmd, "crashkernel=")) { + res = &crashk_res; + } else if (!strcmp(cmd, "kexeckernel=")) { + res = &kexeck_res; + } else { + pr_err("%s: invalid cmd %s\n", __func__, cmd); + return; + } + + /* remove trailing '=' for a nicer printfs */ + strcpy(s, cmd); + s[strlen(s) - 1] = '\0'; + + ret = parse_crash_or_kexec_kernel(boot_command_line, + memblock_phys_mem_size(), + &size, &base, cmd, NULL); + /* no specified command or invalid value specified */ + if (ret || !size) return; - crash_size = PAGE_ALIGN(crash_size); + size = PAGE_ALIGN(size); - if (crash_base == 0) { + if (base == 0) { /* Current arm64 boot protocol requires 2MB alignment */ - crash_base = memblock_find_in_range(0, ARCH_LOW_ADDRESS_LIMIT, - crash_size, SZ_2M); - if (crash_base == 0) { - pr_warn("cannot allocate crashkernel (size:0x%llx)\n", - crash_size); + base = memblock_find_in_range(0, ARCH_LOW_ADDRESS_LIMIT, + size, SZ_2M); + if (base == 0) { + pr_warn("cannot allocate %s (size:0x%llx)\n", + s, size); return; } } else { /* User specifies base address explicitly. */ - if (!memblock_is_region_memory(crash_base, crash_size)) { - pr_warn("cannot reserve crashkernel: region is not memory\n"); + if (!memblock_is_region_memory(base, size)) { + pr_warn("cannot reserve %s: region is not memory\n", + s); return; } - if (memblock_is_region_reserved(crash_base, crash_size)) { - pr_warn("cannot reserve crashkernel: region overlaps reserved memory\n"); + if (memblock_is_region_reserved(base, size)) { + pr_warn("cannot reserve %s: region overlaps reserved memory\n", + s); return; } - if (!IS_ALIGNED(crash_base, SZ_2M)) { - pr_warn("cannot reserve crashkernel: base address is not 2MB aligned\n"); + if (!IS_ALIGNED(base, SZ_2M)) { + pr_warn("cannot reserve %s: base address is not 2MB aligned\n", + s); return; } } - memblock_reserve(crash_base, crash_size); + memblock_reserve(base, size); - pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", - crash_base, crash_base + crash_size, crash_size >> 20); + pr_info("%s reserved: 0x%016llx - 0x%016llx (%lld MB)\n", + s, base, base + size, size >> 20); - crashk_res.start = crash_base; - crashk_res.end = crash_base + crash_size - 1; + res->start = base; + res->end = base + size - 1; } #else -static void __init reserve_crashkernel(void) +static void __init reserve_crash_or_kexec_kernel(char *cmd) { } #endif /* CONFIG_KEXEC_CORE */ @@ -411,7 +433,8 @@ void __init arm64_memblock_init(void) else arm64_dma_phys_limit = PHYS_MASK + 1; - reserve_crashkernel(); + reserve_crash_or_kexec_kernel("crashkernel="); + reserve_crash_or_kexec_kernel("kexeckernel="); reserve_elfcorehdr();