From patchwork Tue Feb 27 04:48:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 129733 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp972617lja; Mon, 26 Feb 2018 20:48:52 -0800 (PST) X-Google-Smtp-Source: AH8x224M1ePY+cCIVIYY1DwCwqG3HqqHo75GQEQLkRI5zKwcdm38a4+Aw3hUrgi31SfS3ZK7CSz9 X-Received: by 10.98.212.80 with SMTP id u16mr12936477pfl.58.1519706932000; Mon, 26 Feb 2018 20:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519706931; cv=none; d=google.com; s=arc-20160816; b=pnv4QLE4N9/bD7PwEb5tcYRFK8nk4D8a/6COcthk6W/Zy7GK20IbkkS0fcygmCs/Ug fxJnbytiip/5uq51q0ZZv7Rh0QsAO52i7UrdDN3QMC7kD7umyGU8i/vFsNdXCf8dadVy 4mBDXoX7ge8a6z5gHtahatnNC3RTj3JBAvYNZKnMrdvcy2g/FFRhGRm+LS6zA4TAWJvN dfq1nOa/fReFkNEjXyIemXGBQPvV6cOxn8uyw3q4j28UKFZrNImve/RmCC2mLwKL8aki lG9RriV9xMRdBEerLMrMD6hFJfEcQ/9TOPe41ryFEdzkbRYpKsrZshlis4bCPwBC5gXh 5Piw== 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=8KQUdI4Z9ingM2mimjl+JsuTI/1wm7KWpRgsWzyKrbg=; b=Y1C54BbXk7WwQQXLDThD8/Eya8MK55te9qDekcWAgq3YihL3idWwxDTtB/Wji9kmrV SOJkPOSAIGoelC0mVW3FSnVG6phRe70isDsqIQq0MTTd59Fz3bOj8GgYpQmUayoiGFsC xAnTOVajWL9Q1Dp4Yf3X9Z9IjFAsR/trS0MPnNG+N+kGK7CFygpE41szhcPQ+UETOw+X S/m85/MPef8aF+KQqXCyfK0OuP5Z/7CloyrkfRZALUX16oS+IrcUE5CvaW6R0hlhkhHW ETB6d1LLr9FsuBRWYoKIwXAo5KHDu60YK9AhbLqYl6SNElZwGw+V/xC9CjIH6gkeVYI0 ZwJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jgBwCJeY; 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 t15si2069346pgu.62.2018.02.26.20.48.51; Mon, 26 Feb 2018 20:48:51 -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=jgBwCJeY; 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 S1752015AbeB0Ess (ORCPT + 28 others); Mon, 26 Feb 2018 23:48:48 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43798 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751819AbeB0Esq (ORCPT ); Mon, 26 Feb 2018 23:48:46 -0500 Received: by mail-pf0-f196.google.com with SMTP id z14so7506145pfe.10 for ; Mon, 26 Feb 2018 20:48:46 -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=8KQUdI4Z9ingM2mimjl+JsuTI/1wm7KWpRgsWzyKrbg=; b=jgBwCJeY2mSzDywcuaMPQprXVub/cu0YURgSK6wiHbu8qF2GmTmYb8TlOYqJ+nGSxO impWhW483jKjQEhF0HifkTRq3LQo5dvJ/fO+7ZtuQ/gzf68bk7W/K3p1Oha5P+2W3xuw H69+3hTIKrKL/RjS2QZlSLIRn8crNUkPU4CTQ= 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=8KQUdI4Z9ingM2mimjl+JsuTI/1wm7KWpRgsWzyKrbg=; b=Dpcej8sSOh24prtL+6L2YJPzPXnfskZylOubkDuo2gh2dbfo/hC7LqdP0jCwcfzw3c mk9j5TwfHylPgqVY70Jc4GhA1Q5Zt8T+odQBlf985oJebLlJim6Abn34ycISMObG0GGd tyiVDTOxHs1JGlC1Zc65vkHk4ug4IUuMDEYR9PJxRaZvT082/2MqjhuqAH+Gft160RkJ juceJlfn2UMhYgX1Vq6B0C+Hv9RApVOYdj0PPVd3j+YYOVxYlczIF+tk6BJLTNS2kjSD y9Xp9FT8ndRyYCOsp6AGrqbYqaO25f2BcwLYghLAM2taeINNRWmMJd3NBmkc4cn8PI59 Ah5Q== X-Gm-Message-State: APf1xPChcT0xsw49rsIfA/HnMyqnYBQ0b4i4hJ2Vzh35zXAb0PkbW3gy Kj5048a4Tb4g6fwGm5Yfu01LlA== X-Received: by 10.99.183.68 with SMTP id w4mr7299704pgt.113.1519706926274; Mon, 26 Feb 2018 20:48:46 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id i11sm15983332pgq.34.2018.02.26.20.48.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 20:48:45 -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 1/7] kexec_file: make an use of purgatory optional Date: Tue, 27 Feb 2018 13:48:08 +0900 Message-Id: <20180227044814.24808-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227044814.24808-1-takahiro.akashi@linaro.org> References: <20180227044814.24808-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 | 6 ++++++ 3 files changed, 12 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..990adae52151 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -26,7 +26,11 @@ #include #include "kexec_internal.h" +#ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY static int kexec_calculate_store_digests(struct kimage *image); +#else +static int kexec_calculate_store_digests(struct kimage *image) { return 0; }; +#endif /* Architectures can provide this probe function */ int __weak arch_kexec_kernel_image_probe(struct kimage *image, void *buf, @@ -520,6 +524,7 @@ int kexec_add_buffer(struct kexec_buf *kbuf) return 0; } +#ifdef CONFIG_ARCH_HAS_KEXEC_PURGATORY /* Calculate and store the digest of segments */ static int kexec_calculate_store_digests(struct kimage *image) { @@ -1022,3 +1027,4 @@ int kexec_purgatory_get_set_symbol(struct kimage *image, const char *name, return 0; } +#endif /* CONFIG_ARCH_HAS_KEXEC_PURGATORY */