From patchwork Tue Mar 6 10:22:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10261311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D28A7602BD for ; Tue, 6 Mar 2018 10:24:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1780289C9 for ; Tue, 6 Mar 2018 10:24:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3DEB28DD5; Tue, 6 Mar 2018 10:24: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable 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 3C080289C9 for ; Tue, 6 Mar 2018 10:24:14 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=eFRAJ7xstWC4FL3JthFDZ72c5KDm2Qx8ZXtZJj7Syu4=; b=VbZaImYbO9zZ7IKBlbRLfpscgU 2+FoLwjX4PYy7mxStTHwtGYh6pdmU5NppzkN5IGB90nHBmsoYV6hBcJdsgKjoIORTeCYDYWx/fjfY S6VRZZ8F8Jb5v+Vg8Nrt4YROjnBOpjips9CfF5uMAApFtZ8k+Hlm+VYkG9QnOFHekP2ACSVmVLMg+ UyMR8tXhds4j1iJy1SpSKMD3ZF/jdCheVLq8ObeSD6lFQ1Rr/UtEB6TvT5hlq3whX1Ei9rIpWK+hO JO6s79hIYG2VPAlHZDN9u1mukniDj21er4X4C6Giyp/flD97JRi8gh6zO7rTaD+Y+Ld/s3yjT4qIP jhESqhHw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1et9lL-0007ic-9h; Tue, 06 Mar 2018 10:24:03 +0000 Received: from mail-it0-x241.google.com ([2607:f8b0:4001:c0b::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1et9kl-0007GB-3N for linux-arm-kernel@lists.infradead.org; Tue, 06 Mar 2018 10:23:38 +0000 Received: by mail-it0-x241.google.com with SMTP id n7so13127369ita.5 for ; Tue, 06 Mar 2018 02:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TLkC14gfKn6Fp3BIip6KOc5tun8h4G9Y1pI52+NjIwI=; b=QvB1eUfDM8b/oiIvTAUrgqcuY1qVdvoM8OOI2kGAi5zsI8EYpZgBhdzj8SEt9NhewI Hcf5j2TasQ/x6LlNSbCZNVOIPr1dGJTMQGgFFlWCUu5i8zi+Lj0x0GKkYa11uF4Opynt 9O5yrqQphSpV3gEPJ8aOmbljp4BRsW0CcXG/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TLkC14gfKn6Fp3BIip6KOc5tun8h4G9Y1pI52+NjIwI=; b=Me87kHZH89I+ZkZVo8a18oghA05pg1M6N6tncWwzZ/12tHc2GIM9oKTVGGQ8IPBsd1 NU2DwCAboDXgJzvE7KwihxkTl7tVqODaLL+Ev+6SW5BJjUcnGVpPHcGuim7f4ppHp+lv 4Cfx8oJ1gZ0mU2Y60Zq1zSwGJR/gIL2SMDRRN5A0mc4DvxduzQyuc9P1GgvkHr76vXvf gd2RpCISyxCNFmqtLOo/Z6vMi374h7oKtOHsyPWIl4PUgP5MpgyMyV9kk7wBqN7DUcMX xjCRJnUgiY3UyclVipk/5wfDcUEywx2lgIxpJ9OH6v+nl3WpaUZwajZ50XDFTV4k+heV 1iGg== X-Gm-Message-State: AElRT7H30Mc8TrgicfSvlUHXp8alhAw9U6QXmlgFduQd1AGncztsaTqt LWn6JAlp6K9k38no6aYNwIUZ9Q== X-Google-Smtp-Source: AG47ELsze6aGTJePkJAavgrC3Azp3kSeVdhurEaFkzeFDq/mi8DXloJCZUtrAj4UEL8ZBnnqZ+n7AQ== X-Received: by 10.36.111.4 with SMTP id x4mr18162462itb.51.1520331796476; Tue, 06 Mar 2018 02:23:16 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 30sm9963125iop.73.2018.03.06.02.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 02:23:15 -0800 (PST) From: AKASHI Takahiro To: dyoung@redhat.com, vgoyal@redhat.com, bhe@redhat.com, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, prudo@linux.vnet.ibm.com Subject: [PATCH v2 1/7] kexec_file: make an use of purgatory optional Date: Tue, 6 Mar 2018 19:22:57 +0900 Message-Id: <20180306102303.9063-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306102303.9063-1-takahiro.akashi@linaro.org> References: <20180306102303.9063-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180306_022328_294517_3A8E313F X-CRM114-Status: GOOD ( 16.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AKASHI Takahiro MIME-Version: 1.0 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 On arm64, crash dump kernel's usable memory is protected by *unmapping* it from kernel virtual space unlike other architectures where the region is just made read-only. It is highly unlikely that the region is accidentally corrupted and this observation rationalizes that digest check code can also be dropped from purgatory. The resulting code is so simple as it doesn't require a bit ugly re-linking/relocation stuff, i.e. arch_kexec_apply_relocations_add(). Please see: http://lists.infradead.org/pipermail/linux-arm-kernel/2017-December/545428.html All that the purgatory does is to shuffle arguments and jump into a new kernel, while we still need to have some space for a hash value (purgatory_sha256_digest) which is never checked against. As such, it doesn't make sense to have trampline code between old kernel and new kernel on arm64. This patch introduces a new configuration, ARCH_HAS_KEXEC_PURGATORY, and allows related code to be compiled in only if necessary. Signed-off-by: AKASHI Takahiro Cc: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- arch/powerpc/Kconfig | 3 +++ arch/x86/Kconfig | 3 +++ kernel/kexec_file.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 73ce5dd07642..c32a181a7cbb 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -552,6 +552,9 @@ config KEXEC_FILE for kernel and initramfs as opposed to a list of segments as is the case for the older kexec call. +config ARCH_HAS_KEXEC_PURGATORY + def_bool KEXEC_FILE + config RELOCATABLE bool "Build a relocatable kernel" depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE)) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c1236b187824..f031c3efe47e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -2019,6 +2019,9 @@ config KEXEC_FILE for kernel and initramfs as opposed to list of segments as accepted by previous system call. +config ARCH_HAS_KEXEC_PURGATORY + def_bool KEXEC_FILE + config KEXEC_VERIFY_SIG bool "Verify kernel signature during kexec_file_load() syscall" depends on KEXEC_FILE diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index e5bcd94c1efb..6dbbb89cbbac 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -532,6 +532,9 @@ static int kexec_calculate_store_digests(struct kimage *image) struct kexec_sha_region *sha_regions; struct purgatory_info *pi = &image->purgatory_info; + if (!IS_ENABLED(ARCH_HAS_KEXEC_PURGATORY)) + return 0; + zero_buf = __va(page_to_pfn(ZERO_PAGE(0)) << PAGE_SHIFT); zero_buf_sz = PAGE_SIZE; @@ -633,6 +636,7 @@ static int kexec_calculate_store_digests(struct kimage *image) return ret; } +#ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY /* Actually load purgatory. Lot of code taken from kexec-tools */ static int __kexec_load_purgatory(struct kimage *image, unsigned long min, unsigned long max, int top_down) @@ -1022,3 +1026,4 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } +#endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */