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: 130758 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3761940lja; Tue, 6 Mar 2018 02:23:23 -0800 (PST) X-Google-Smtp-Source: AG47ELu5wBQm1jx1I2d6gJy94GVDknvxStftCFfFhv5Y7YY3smeMX5iPIofCa1u+XdsnR+ovzqig X-Received: by 2002:a17:902:d891:: with SMTP id b17-v6mr15904253plz.241.1520331803698; Tue, 06 Mar 2018 02:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520331803; cv=none; d=google.com; s=arc-20160816; b=MGTV+b4fbkj+OgoQqEeJfUxW2svRtz6nmTDfpAIQ1It6nPVt1pzTVQBGjdecW9OhS1 3ZeB9xYonuiTCWraEGqp+7HlX1rk1AlvZrtTbNQ7zQY1UidDTSkidHKUbC2n7yvmRTC9 XvTbIppSZKzYafZt1KeIE6KYY3n4vkH/i1awBCnsQbb0OAAe+Rc82IBcOa9P837zQxw3 9gy0P0Abx+bpGb7Ncb/S4HrFtFQsaQSmsgI0PYRfLHSLiB3Z19r5qOWP+3I9HkZkghWj Wpd3xsazs4cCMm5M0JM0STqLlhOzDP8kzIEu+30OuUgxCWCK5TcjtglS+RYpUczneYLs hPzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TLkC14gfKn6Fp3BIip6KOc5tun8h4G9Y1pI52+NjIwI=; b=EaMKnA7pgTrZAqAgN3yy2dZifK1xY8rbJobeJAef+KfIFGH/gr5mgOMfK8M5D+3SpW 4F0B7CLHwq+7lLiIrIsqd6XWY2LtE/EFeLM6fVTh+mL/CMYU8fSWpWnBBamFqruEO4Em El3wAlDFyvX8I458Bue19quPbI6d+sOfMbLN2m8UqPpDeDF6DdF+Y9jZyr+FsiAhJvaW hp4SeOSlVRl7EfQl7aDLN2FjOl7Oa6t6hsUC0+TfXZEnFKoHmPYgfQ5eBxdvXAtkZojL lAZYvtctL/uJjnewt0jltn6Ck9TweMdP49F2ZdBBRF+7vlBWRfJeqFIZYRzhCJqJ6318 g+4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QvB1eUfD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si9647023pgd.452.2018.03.06.02.23.23; Tue, 06 Mar 2018 02:23:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QvB1eUfD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753386AbeCFKXT (ORCPT + 28 others); Tue, 6 Mar 2018 05:23:19 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:53401 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753155AbeCFKXR (ORCPT ); Tue, 6 Mar 2018 05:23:17 -0500 Received: by mail-it0-f68.google.com with SMTP id w63so13141369ita.3 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=QaoO1zu85GNfnDTPZFw1lYQS6IbzfwgHNb009FM8WIifmLJQERD1oHicCcJI3rKW0Y nWgIBgkblR50gu+XT3iMFfj8Q0Qc6SXjGm3Xe1Hi6QQ3yr38K6DNYIPN5dCwWf4wSPeE AZzWIDMDrHPo+9ey8Ua/h0kSQPo/haG6Sth0Ihx4KxTvkYPMI+R9hLwOJ3NKg+jm0bIS wyFGkDHJSHGYfZiqEQJUKIqtHQBWfUUU+c0tL9/LEJbQfwSKEzpWY66B4xUe2s061jBg btzCk+aJ0YtIWhxCbIH4CDlZhlAgPghPa8ntiB09tC86A/5/n+LdDejl/LuwKJD7ErWI Jrrg== X-Gm-Message-State: AElRT7FJ37ndJmpKPXT7n1YZqpgCyjcsf4Sr9HO8clfgSNbxhOl9p/DL ZemAoF7TBVjlIcy+9iDUZcersQ== 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 Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, AKASHI Takahiro 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 2.16.2 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 */