From patchwork Tue Jul 9 18:20:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11037277 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 0F99F912 for ; Tue, 9 Jul 2019 18:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE71520246 for ; Tue, 9 Jul 2019 18:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E00A52870E; Tue, 9 Jul 2019 18:20:42 +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 826B820246 for ; Tue, 9 Jul 2019 18:20:42 +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=t4eZyqqtSsD6EW XTSqD41/CZbvxn59rLtAqhmf2fR9gaaMpu3IkzpiiFaGMa1ueaKOPJ5G8hzTwHFfCs1bNldOJPUtq 23Wo+d6vmTPPmNBNKV+LtTrcp30Iy3CPYVRwXkdumRU9/huGEEsYlTNeFEJbYJnP5+ij1YI+8uXlT v5zggWfvV2FhZf4XoKpqodmxZr4GgKe+i1QIKRFe5p8ahGzUgAHoB+WGXwLFQIYluyVQtlm5yB+V6 seQjKQ5eD/n8bHlGp2ZByVMPeR/UYmJ3TUYgzGtYheTK5FiD/ANcBIcAZGl8incxSwcWXMmGB2DfR B0yNOMePYD9Fl1z8GDKw==; 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 1hkujK-0008Uw-1z; Tue, 09 Jul 2019 18:20:42 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hkuiw-0008Aa-T7 for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:20:21 +0000 Received: by mail-qt1-x843.google.com with SMTP id h18so15190828qtm.9 for ; Tue, 09 Jul 2019 11:20:18 -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=XSW61kWTCXRdscVw0OH+r9e4vwdXvYbKjBz6k2VZ4GjxPw4990pNb4BAwrNmmRtsKa WtJJtAVYm0yQyc0gT9qSB2/HJ82+H/MyS3XC9ctMBPbmW7oIgk6eANZnGVKs2HBNiQ31 /bHZn6IWmWrVDAl4L6vMC+WdnQz/McJp0xLy9cq1x0N7urntIF/8qUhPuZMeitTr6tYj seq7y1K4rV+ZnPT/cE9I0rwd7rtanJ3jIDMOql2+Ikg4jcapC2ZEhDEL5dbgh2nC9Yd7 7VxNW+sDRKWTWxuTciOBY6N/SjEJM6T2DfzfKRi5ZSX4eCt/ImtICLCJ7wV7q6H4hJ/t hxMA== 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=noZqYwe/c4So6o4qnTGDgxrCii+rWEyG7Wqp5N5KlD5mKsaPFMOEIxZTnxH+n1oz+2 tsv9tRg92XpC9OcSduusyGyMM5n3wdaJdoL+sEA21UBPxtW/Qgb/xmA1T3PXSzZCrHqm /Y4P8liWkhrADdWpz2hZgt69eKcRw/TPKVfAEP4m1Ye2VHs2gi3K//fCddn1YHbMC/YF W3rmVipYffUN5tl/cPXJZ7AzUladBUrqj1tokhcfgzKun4jVEpxRp4ZPWwJPw1/pGla4 xWK+ohrVftOrGU6meb9FyxTktFfaGUwh/u0/QCFr00d+Rm0C/1vhJeJuNoscKQH1ynZD JSXQ== X-Gm-Message-State: APjAAAWPjtg0vy19qxFSFcuVyMIyFhxzN9ZK1Xk4lKhiJlif3xWnxeAn Eqo51FNB7UJxMMuoVHxRoSnIkA== X-Google-Smtp-Source: APXvYqwK3sHb+R0eRvj6/WADS1T4iF+JrbGV2Q7udh84kzeXGKKiVV5f5NzGnIT7DBMyye2cxX8F5w== X-Received: by 2002:ac8:4758:: with SMTP id k24mr19729228qtp.20.1562696417894; Tue, 09 Jul 2019 11:20:17 -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 k123sm9113056qkf.13.2019.07.09.11.20.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 11:20:17 -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: [v2 1/5] kexec: quiet down kexec reboot Date: Tue, 9 Jul 2019 14:20:10 -0400 Message-Id: <20190709182014.16052-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709182014.16052-1-pasha.tatashin@soleen.com> References: <20190709182014.16052-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-20190709_112018_956074_3000A91D X-CRM114-Status: GOOD ( 10.20 ) 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 Tue Jul 9 18:20:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11037279 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 5365213A4 for ; Tue, 9 Jul 2019 18:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC0628815 for ; Tue, 9 Jul 2019 18:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D04A28826; Tue, 9 Jul 2019 18:21:11 +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 ACE3528815 for ; Tue, 9 Jul 2019 18:21:10 +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=eikkH26ZP6ZRPm dZcOhURJrorzO/aQ+WQsg1jI8ILfSt0c5gxjD9ysJMHzjHr1Sw3a791AVVrqEGXlz3YVwsfxHkve+ TAl85+KRBMUnknwWh/lQR6H8gp+JkZt0ypWiMqZ6mkV1a39jPX/Lzd0TCHcf2nQ6lVczKHszfK6sZ BcXK20OrcFuQ8NM8tjUgHr4/sBmv1fih3o2jxNx5eDcNO10Gi6iDV0HAMrALyrnabsufrf+MdNEr0 cY8jwHptMW/VGaBuA4q+Ng5/0gTVQIu+72P+8BWKAiUylPAu02HMrnNxYgzH6DyBedzLjvDZLE+x0 MVgaZMNt67rs8FSidLCA==; 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 1hkujh-0000R6-CN; Tue, 09 Jul 2019 18:21:05 +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 1hkuiz-0008BY-1l for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:20:23 +0000 Received: by mail-qt1-x841.google.com with SMTP id 44so18751906qtg.11 for ; Tue, 09 Jul 2019 11:20:19 -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=Lxz1gcUMBjd/teRSMIUe0VCxgzAsMdo3Rrn2b801LIo6TpuHTsRwusYzWVPRKkazNn aAdOj2lu6GpB5lRRJHygM5I8HppPYWYDQAaywxAfo2xqyv64cDjnnOeOHkGgezgBW6Nu djzd2PEL9D+Qec4rkUSmWz1H+lTOHJEjt7GhXcSO4imn4ddhyK3Hk7AQ70/qN00gW7hu wIEFtsDNWfbhO2cfJblKWFwp6D9W3cUBuqCUlw0F2/VglB2QrsaAsobfraWn1QISADWD dpJWu9FxbHD/vEFNL3NozHPeDPJcYEXDBomOxuPMe6xhnzj7RHJpqS2pUV7nuPeTWBA3 oM5Q== 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=c5IWscoNOmpJcCqHWv3FeTLf8yk6qRDxTxAwywcNhS/EVBzrp6ywbJhd8BPSjIV5vq vroLXK5AddWraq8oqSd7R/CVaeezWkM2F0LGHIwHNAJPnkYoHcKA+gZtD9jS8t8NsRmD bDDMJg3z6cE4yMi6S9kIOGPKjfSr8c3kzOS1DGiYCnVvL5WXeAJ60PXKSTN18n2svdO7 h0SXJ2POapwoJSFCpWSx5yvX5gj8VOFOR7JlU5Wc0XaDJq3Uan8QDLlJz8HwM9IE8OqG DbB6plwIUdnSRNg4U/HEeu4JlbJkyT/NyhK0JVglL6T6vTrT6/2R6Gl8VN1YWDh1ivxS T2aA== X-Gm-Message-State: APjAAAUPAEUIjYijsW97pQRHpRTxcATFBMRgylHT6fihMcxi3CDturSl S1DZ/jIcl4iNMyNyk4ywQT8plw== X-Google-Smtp-Source: APXvYqwAG4/7u8EKC7EBi9MHlMvmuFXHJunA2cypRFYP7aL7Lw7iEQ73R7gZHDrIdOHZAo9JKHhQaw== X-Received: by 2002:ac8:35ae:: with SMTP id k43mr19635975qtb.259.1562696419082; Tue, 09 Jul 2019 11:20:19 -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 k123sm9113056qkf.13.2019.07.09.11.20.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 11:20:18 -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: [v2 2/5] kexec: add resource for normal kexec region Date: Tue, 9 Jul 2019 14:20:11 -0400 Message-Id: <20190709182014.16052-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709182014.16052-1-pasha.tatashin@soleen.com> References: <20190709182014.16052-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-20190709_112021_095862_E87BECD3 X-CRM114-Status: GOOD ( 11.87 ) 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 Tue Jul 9 18:20:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11037281 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 4718413A4 for ; Tue, 9 Jul 2019 18:21:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36C3228815 for ; Tue, 9 Jul 2019 18:21:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A54228826; Tue, 9 Jul 2019 18:21:30 +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 9CCE228815 for ; Tue, 9 Jul 2019 18:21:29 +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=aKDxDFFHUjgCE0 uGLvRboB2usy3zZsxhod8kNYqEy92xVAfwkFJXeVrKpVO3dTjeUENAtqixiBWcTjEglP8kHCiev0T L53cYWMB6SGXkz/Wia65VrxPUZkCTtsc1R4DIuGKNjVVpAAHBhwJgeTHPyGusnugGghFgMUGtdzAU /yI15vw//6Oa/DCu1Gf74W9boM4gzTb/CjsjPgkVLB75inPgUj564lISH/RSKhCHByCzk/E9DJHir K1DwKVj8wv1JOuZIOwG2RedI8ve6NNzC0tJ7dcQfRZn+wQOyf9WRvi0fj+n4ReoRv2ZdBy1M4VDUn daJm9VrCr8xSvjvv5nhA==; 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 1hkuk4-0000k1-Lx; Tue, 09 Jul 2019 18:21:28 +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 1hkuiz-0008CD-62 for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:20:23 +0000 Received: by mail-qt1-x844.google.com with SMTP id l9so14352680qtu.6 for ; Tue, 09 Jul 2019 11:20:21 -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=fROPV6xgBSJhQ01nOcdaPocwDpq/tgqFMzKuQ1aRxe0BdHGYSbE7Mx44Vo+unqXPkG 2iQxFwNOSDAL+6xrRHgsE+5oOTpNUcaTtUnWzBQnoArvLe1SZxJuhHKRqH6oJXqWWaJp mYmJUMNp0hMmxuR5+lUvmF10SjSgGCn+X92RBQXE9trtp4e1hWtwVG70nLYhqgZMEneU 8FmJGF1qVgPlKmCQFFhG0OpQiGa2Sk5FjgCfMZI5LZbu1a0BxKAkQuR29zt1kcT31VdG IC8BDEXiFHBmdYydbK6a2ULNeXX78BJpyz62xQihfh1Y656wUkRhF7ksMuPF83a9UM3a 2t6Q== 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=GneA+dEfHrU01CW4EvL+uASJ6VW6Fd32j5CdQuM10pLRwK5jzsOyHCwRjC/W/ZFUW9 BSDB06rKhMclYHPdDGJqypUfTxtm3Ba6MuH6SLYc3Fu+P4wbIT/RjxeXPRUfw2+71qIc Koy/VKSPp/4c7wRRfEAkjWe1+6FqsCScNugcyW1jFqXi42IYlmwQ16veR8JvqwvNTvOv cT1ixmgztZ51v2ycLOjoC1uX0SXGen5vetpqeZ8+WDagdm04BXIu1SRpxLK2Vn/KFFsi cmoD4CqPyjp66bov8wr2HAox9jLu8EFIdalYeuYGBx7ujzMhWHeDNQltVax+8BwlXcYX g5UA== X-Gm-Message-State: APjAAAVy14zQadAv7/rR9JpWyY1oo1YqrrUe3sN+VoehqvmyCN/1+3nD JOdJ8EeTj5ZjDO5uNjqukuyNCQ== X-Google-Smtp-Source: APXvYqwpag+IBIQrGBDcCLRZVOWUUlgFjtMGgOzroSxhP3WwPBpgsirFrCOkxvY0XxfGhw6CZgULUQ== X-Received: by 2002:ac8:1106:: with SMTP id c6mr18604187qtj.332.1562696420496; Tue, 09 Jul 2019 11:20:20 -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 k123sm9113056qkf.13.2019.07.09.11.20.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 11:20:19 -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: [v2 3/5] kexec: export common crashkernel/kexeckernel parser Date: Tue, 9 Jul 2019 14:20:12 -0400 Message-Id: <20190709182014.16052-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709182014.16052-1-pasha.tatashin@soleen.com> References: <20190709182014.16052-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-20190709_112021_255622_2974F361 X-CRM114-Status: GOOD ( 11.14 ) 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 Tue Jul 9 18:20:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11037283 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 3F631912 for ; Tue, 9 Jul 2019 18:21:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B81F28815 for ; Tue, 9 Jul 2019 18:21:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CC9328826; Tue, 9 Jul 2019 18:21:56 +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 B0C4428815 for ; Tue, 9 Jul 2019 18:21:55 +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=JtOKow9ycg7mmU LEezgV984ksmdl0s6a+7GhBzc6a4QbN/9+fCRXOc8GaPVKybEsuaW/6nWbUM+LknvO/WA4tyrJWkB 6W8Ijwfk4uVuPbrNDIbZX3IgGoqoWNBFRfB8Ju7YTCrZT5NdzVkl7zyXNBv/aIuvHXyvEbTm/yzP1 45OPrg3e0cOmC7y9VdvDNm+Mz5IVhGYVw+Siif0BetuDVZeyJk1ZsVHtgTqZ7DVK2+SPsj4CaIAYR OyrJJFWiRXkzPskRyBJIt0uEJcVYiZCwehVu5TK1g3FEgwn7FupU4BStf52qMshN+ceiBsYqdkQpc 9g33eWB0q9RKpj2N8WvQ==; 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 1hkukO-00012K-Vg; Tue, 09 Jul 2019 18:21:49 +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 1hkuj0-0008Df-Gg for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:20:24 +0000 Received: by mail-qt1-x844.google.com with SMTP id k10so14991485qtq.1 for ; Tue, 09 Jul 2019 11:20:22 -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=alGd9MvUbfRqM3kWiylqGdR8tXCWntU7urG6O/GicndbUQb45Df3lZ60ss0lN4iTMX jILCKJ8XZjIJdyeJ9PcMuePTuVByoJd0pIN6Zvi/4M5oIPlwrKJ9CLBWGL1jSDoRpkf0 7X2QpEiClR1Sqxlu/X0MWv0BSWiGKT7v524JLl7HEKf6FhOOLIOozehl9Jf+5Bybqzb3 Yq18ArXRnGQthoo3H5BaaEHVGZOc/wySgb/UPR0PjLwFUdTbZAL5xBFZQi23eAr5VBtf IN7pVQ8wypit/IlAEFI+AYFsKgAOblvL17tMEno3+sg80gzfyoxh8k12uI7mGYUEGlMz VC2w== 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=k4YciHi8H20Z4IaECx/RhMEQRRX9vgyahUvBQFJGv+/OrwjKkfyikTB+KEahrMaW32 Huf1iROWzvsD/EmlQoLb+WlVXDZVahMAmpYX9lfnwttxiYBhMfwgptBNY1iKNbTY/GeV QYFVNqsFCZS2BarDpx9jSjF2WyBUu3RcCoUMS052eVJ6ACWDUto9Kpoiwt6lvHklVrod m/IHiqB+mEhZlPjQHuZEnjC3St0kl3MXgpZgD+Wo2wrTPqX6+vOzzQj4ge1jh8BbIqLF Frs4IJ9D2yxglt5VRcJd1uesr69QVgJ2Wy+7ki9wn6zNq4tUu+TZr/1OcuvGPYChzChE VNAg== X-Gm-Message-State: APjAAAVcPE4Wgkn2SOJZyor98ecvySiOmzfdiFtMQrT8leJgxMBh+v4p UnKbWDUPZNDLmiIYHEn8oum8NQ== X-Google-Smtp-Source: APXvYqw8hj3zXjnTBHv5EU0i1mynT0zTuqlV/Rhh2l9bHQwU9e09NhIl+cnbQoA6x9C2nK4A4lK5kg== X-Received: by 2002:a0c:81b8:: with SMTP id 53mr19886187qvd.91.1562696421760; Tue, 09 Jul 2019 11:20:21 -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 k123sm9113056qkf.13.2019.07.09.11.20.20 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 11:20:21 -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: [v2 4/5] kexec: use reserved memory for normal kexec reboot Date: Tue, 9 Jul 2019 14:20:13 -0400 Message-Id: <20190709182014.16052-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709182014.16052-1-pasha.tatashin@soleen.com> References: <20190709182014.16052-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-20190709_112022_591110_84247CC5 X-CRM114-Status: GOOD ( 14.49 ) 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 Tue Jul 9 18:20:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 11037293 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 712D3912 for ; Tue, 9 Jul 2019 18:22:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F82B28815 for ; Tue, 9 Jul 2019 18:22:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5355A28826; Tue, 9 Jul 2019 18:22:15 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 8F0A528823 for ; Tue, 9 Jul 2019 18:22:11 +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=bil4RfToGabGG5 pXpvKdJR3qHVSguJj3jDPpi4UJC2GYe8EPt8ESPGY6NAWxwQOGRbwtUhoq2ZFJ7GgiPjsXs/Rqgk7 +My4LjVxJMz48J+2kZvf0OLgbTLTE9HKi0BPRSQQK4GcUiOYfm8kv0Pc7pon5BN8FghqiPdcnkk1k cUMqLVuW8LyI1gCfEY1A9cxwfCDNxqzdhgqMpBBkPvR4niUkSIhfwGivg3ubg32b+ME18qxZ/jHRt KwXEvXSH/HFrlfr7t1n/MpfBWnLs6q8hCe2wO8DSRUvzl1Lsv/UVL1H0EVqSz3mfZlzVVM2ruVGjR 1Jpvmdr+pvnh0qNNJcfw==; 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 1hkukk-0001Ns-Q1; Tue, 09 Jul 2019 18:22:10 +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 1hkuj1-0008Eq-NV for linux-arm-kernel@lists.infradead.org; Tue, 09 Jul 2019 18:20:26 +0000 Received: by mail-qt1-x841.google.com with SMTP id l9so14352876qtu.6 for ; Tue, 09 Jul 2019 11:20:23 -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=AqunWWWxGh4NAhLbFvISj8wCzu6id3JXejuIXa4TvV30VuMXGIT0XEXhkQJ6p4TGgR DjjKaYUsaAaVrwO0CP1uVEJp5OBZ4ZkazaAVcwwTVNPZpUvUow0ckU9EpwWik/tlIupX b/5dCH7k5TtiD1e3G4JHhANhB95vpUm8sKLXx6E1+5Ay29tkvlxkYf9asnwd2JcpbkDs ZflCqDPNQ9DDfGOkeI1EgEgDY8Txm1qrd14+8P75qq+3BJyby4paKruB3BM8iwSL5wRi Q8JvaJDDY7rxp4ujqvGLkI1MTqlzc4WcOryOl/Sk1EbjnjIndttpQuVZgDtUlgTT7MXp Xqbg== 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=hHGQuT5fPGzrxcT4uwEmzcSB0ApcWkCOYnZdQ04+d99ctib73TDL0ZU0ASbDcPjw++ uf6eDXZCgpYTwpKpb/hx3//e5dEUEW4tyEY78ks3nl9MQZtylloKfkRvU5qvua4I/zv2 EgERc9Bs22XoSBjc49WY7fO0dlHNoBxKav1sQYxV+RWtmCK74oBKVGAdyXLGgmRUJthT 2wahfqo7DmoKWlIWubZBhaMmHFQaPTZL5W4ZzrKSvuPUd22oYk8CW6zTnVtrUc6mqg+K A9hJ+FE9BoAMS4zTZQlvz+m86zs9Izj4OmkScXgD4DKxYgF8iL/+kGWgYbng52IBgFso y7PQ== X-Gm-Message-State: APjAAAVKgUYH7YGgSCbmaIdIA61QqKg6W6s0vSPFBrD2YsSzGi7Th9XG lB+S2lNLp11fBTkb7UDdR+lBTJVxkN4= X-Google-Smtp-Source: APXvYqypFDORJK55t4/iPYv6UX1UCBaFaqAzD+I5UAklLCwgFf6Nywn8Ipf3ouT61bmq39qnWmnv5Q== X-Received: by 2002:ac8:1195:: with SMTP id d21mr19311947qtj.278.1562696422992; Tue, 09 Jul 2019 11:20:22 -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 k123sm9113056qkf.13.2019.07.09.11.20.21 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 11:20:22 -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: [v2 5/5] arm64, kexec: reserve kexeckernel region Date: Tue, 9 Jul 2019 14:20:14 -0400 Message-Id: <20190709182014.16052-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190709182014.16052-1-pasha.tatashin@soleen.com> References: <20190709182014.16052-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-20190709_112023_839062_FA6DB1A4 X-CRM114-Status: GOOD ( 17.75 ) 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();