Received: by 10.223.185.116 with SMTP id b49csp4537478wrg; Mon, 26 Feb 2018 20:57:01 -0800 (PST) X-Google-Smtp-Source: AH8x227NKuooB1RT9adTlKeU+aDu5Qg7XraTo0TMY+mHBzGkF33NC5HbAELyyZFJHKP6GaTo1VUs X-Received: by 10.99.111.130 with SMTP id k124mr10666947pgc.236.1519707421496; Mon, 26 Feb 2018 20:57:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519707421; cv=none; d=google.com; s=arc-20160816; b=U9+a3pD3BFADepV/r4rrFoM/eccgQqvWfyrh1/JDXjA9PhjHdoxYtQCZD3IZzt69lq EZd9mqGwpuj1Y444rLEBLIKgZ8DZXB0L/Kb+Y54RO42eKj4SBGJtRG46O2YpW+EEQ6Xz u13EGwD1yY7IHPdmRBrjOq4byDfrZq4WTDbyY28nbqMsrZpPT+mIQsiKKSUyYK1NxH8Y JaUv68SVgbIRN0o6B7hmCPPZ88A2j8aJK+xhkM7+oujueVwrOfry+3mlj5FoSAHmsxad 1BUHwJaUJwFk+zkOkHANelZQ5A0Fo9pNQqCLX29ZcR6e07e57h9MtGhEBwkIcKr08H00 9pGg== 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 w9-v6si7843190plp.425.2018.02.26.20.56.47; Mon, 26 Feb 2018 20:57:01 -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 S1752003AbeB0Ess (ORCPT + 99 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(+) 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 */ -- 2.16.2