From patchwork Tue Oct 10 06:36:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 115354 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3401512qgn; Mon, 9 Oct 2017 23:35:27 -0700 (PDT) X-Received: by 10.101.71.135 with SMTP id e7mr11458336pgs.112.1507617327742; Mon, 09 Oct 2017 23:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507617327; cv=none; d=google.com; s=arc-20160816; b=J2V4KVtEJEcI4QwNERXtHbJ2N5CaK0i6sttBDtox2X6Y1U16bx8+JKkLp2/qASoWck zH5D3aqcX9pKVS0c1rXU0jAEodcnrjD6v8dqgvqpv+24acDkqy1lt93keqgdHi43l4hg 72b51QhCV4kK2epHYB8zEkcg+WIDz3j37dK9zTaeoocRAfNc1KF0isHAF4dziP/VdtkL rnRESsoyt9InQV03nK59tdO+5vmuVL917kHGwVMFf8Vjqb9wXIw7TiyBneEvMIwX0ZAD D9djQ3TwgECyuq/0GvnhtOuQsYCX+dLABYGQK1+0SaSnHsGNcC1UEUo6+HtG92E1Yh0t 2KUg== 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=YaKBzkr/cIWgFVTBEsCUvwM4WhsObL1dHTAi6/jIrrg=; b=LbVVVHNK/bS/huev1+/M+t5ADSjS8yJaEzdB27zCQgPp2XG/WIjsj88yUqT0YeC7FK jMKntqnIy8uVqdXLGFuIGJuDGlBKp1oOvYwMuyOHsSwhHy0qqs79+efiWp42wzEBlfIa YNrFlOe1mMnPrffW0jADOzSr8wqMJ93g3ZA05rB/jY8kocBXsgX2kqu21VYCn0PgfURZ Jg8gC5Oel6bY2auqP07eSe80/CZacgj8sdDaT5zYgFht8DKPzaBtQ9iZrK2DS3KGz2qK o1AAwKemoSmgZvhuz8kKGFpFzCuBHU9q2HDCUCKZkZkwTwSOYTyWAyTqB99JgXF4Rm8C u4wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ucpa2wyg; 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 f24si8659468pfk.415.2017.10.09.23.35.27; Mon, 09 Oct 2017 23:35:27 -0700 (PDT) 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=Ucpa2wyg; 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 S1755523AbdJJGfY (ORCPT + 26 others); Tue, 10 Oct 2017 02:35:24 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:47980 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755450AbdJJGfV (ORCPT ); Tue, 10 Oct 2017 02:35:21 -0400 Received: by mail-pf0-f179.google.com with SMTP id z11so6300165pfk.4 for ; Mon, 09 Oct 2017 23:35:20 -0700 (PDT) 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=YaKBzkr/cIWgFVTBEsCUvwM4WhsObL1dHTAi6/jIrrg=; b=Ucpa2wygpAP3zqGmPNYtc1wo+GPYBquKNMA18KC/BTl/A/gcKhA/srNVZRE/SBxx4o 6UwuQxhqwPANAwMRr/OlYhJ9deq7dqZ2A3I/JGVI43wiazo8rmCGoc7hNBOOgFOUlag2 zS5qVEw7hn7wLCO9Fpk/Jzx0oCe/JYk9Cmbzk= 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=YaKBzkr/cIWgFVTBEsCUvwM4WhsObL1dHTAi6/jIrrg=; b=e3/QV7q6NpKdGWdvHpRphrCaQfWisJkS/3Ko6By4/rFN4s2bTNs85CB1fY+qISac5N jDimPqugWIGBAT9YMlEiCD5Si/kNJsCbeQBXwl5WNQpzdPGucyF8U59SYcv7L0OXMqdZ HAFvK7ijm8TZu9565/bih+hCW6RnBJei2Z5cUpr0SN54U8119iEIqco93Zm5xDPKLSIJ 31WHNNFq/y43AMlFEI2Voy/7ASTOOWI3C8ZpL24Tyzrursj2wocyudnUG7vq9Rf6Tz34 QBZF1e9gblB/FjYfufWmvnNc6tNp6bbzNu2nGL95zdJFjCKNyiE+8PMUINFMVRNoA0DC IgDg== X-Gm-Message-State: AMCzsaVJI4pBwX3s403wt07oYsteHc4ujyNOZGZhzfa6lKyaL3DFBach GEWe2pYexQSHQczeu5/i+FkPUw== X-Google-Smtp-Source: AOwi7QAyCUA9/v+Wq48KM7tKwHAPeRQ4ucUiGDCJ2eK0xdqwk3GrStIwLqPDoaH6YAPL2zw77X/aXg== X-Received: by 10.101.78.5 with SMTP id r5mr6877282pgt.94.1507617320462; Mon, 09 Oct 2017 23:35:20 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id c25sm16236348pgn.64.2017.10.09.23.35.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Oct 2017 23:35:19 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, bauerman@linux.vnet.ibm.com, dhowells@redhat.com, vgoyal@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net, akpm@linux-foundation.org, mpe@ellerman.id.au, dyoung@redhat.com, bhe@redhat.com, arnd@arndb.de, ard.biesheuvel@linaro.org, julien.thierry@arm.com Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v5 06/10] arm64: kexec_file: create purgatory Date: Tue, 10 Oct 2017 15:36:15 +0900 Message-Id: <20171010063619.6303-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171010063619.6303-1-takahiro.akashi@linaro.org> References: <20171010063619.6303-1-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a basic purgatory, or a kind of glue code between the two kernels, for arm64. Since purgatory is assumed to be relocatable (not executable) object by kexec generic code, arch_kexec_apply_relocations_add() is required in general. Arm64's purgatory, however, is a simple asm and all the references can be resolved as local, no re-linking is needed here. Please note that even if we don't support digest check at purgatory we need purgatory_sha_regions and purgatory_sha256_digest as they are referenced by generic kexec code. Signed-off-by: AKASHI Takahiro Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/Makefile | 1 + arch/arm64/purgatory/Makefile | 24 +++++++++++++++++++ arch/arm64/purgatory/entry.S | 55 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 arch/arm64/purgatory/Makefile create mode 100644 arch/arm64/purgatory/entry.S -- 2.14.1 diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 939b310913cf..cf39ec3baf5a 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -110,6 +110,7 @@ core-$(CONFIG_XEN) += arch/arm64/xen/ core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ libs-y := arch/arm64/lib/ $(libs-y) core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a +core-$(CONFIG_KEXEC_FILE) += arch/arm64/purgatory/ # Default target when executing plain make boot := arch/arm64/boot diff --git a/arch/arm64/purgatory/Makefile b/arch/arm64/purgatory/Makefile new file mode 100644 index 000000000000..c2127a2cbd51 --- /dev/null +++ b/arch/arm64/purgatory/Makefile @@ -0,0 +1,24 @@ +OBJECT_FILES_NON_STANDARD := y + +purgatory-y := entry.o + +targets += $(purgatory-y) +PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) + +LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined \ + -nostdlib -z nodefaultlib +targets += purgatory.ro + +$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE + $(call if_changed,ld) + +targets += kexec_purgatory.c + +CMD_BIN2C = $(objtree)/scripts/basic/bin2c +quiet_cmd_bin2c = BIN2C $@ + cmd_bin2c = $(CMD_BIN2C) kexec_purgatory < $< > $@ + +$(obj)/kexec_purgatory.c: $(obj)/purgatory.ro FORCE + $(call if_changed,bin2c) + +obj-${CONFIG_KEXEC_FILE} += kexec_purgatory.o diff --git a/arch/arm64/purgatory/entry.S b/arch/arm64/purgatory/entry.S new file mode 100644 index 000000000000..fe6e968076db --- /dev/null +++ b/arch/arm64/purgatory/entry.S @@ -0,0 +1,55 @@ +/* + * kexec core purgatory + */ +#include +#include + +#define SHA256_DIGEST_SIZE 32 /* defined in crypto/sha.h */ + +.text + +ENTRY(purgatory_start) + /* Start new image. */ + ldr x17, __kernel_entry + ldr x0, __dtb_addr + mov x1, xzr + mov x2, xzr + mov x3, xzr + br x17 +END(purgatory_start) + +/* + * data section: + * kernel_entry and dtb_addr are global but also labelled as local, + * "__xxx:", to avoid unwanted re-linking. + * + * purgatory_sha_regions and purgatory_sha256_digest are referenced + * by kexec generic code and so must exist, but not actually used + * here because hash check is not that useful in purgatory. + */ +.align 3 + +.globl kernel_entry +kernel_entry: +__kernel_entry: + .quad 0 +END(kernel_entry) + +.globl dtb_addr +dtb_addr: +__dtb_addr: + .quad 0 +END(dtb_addr) + +.globl purgatory_sha_regions +purgatory_sha_regions: + .rept KEXEC_SEGMENT_MAX + .quad 0 + .quad 0 + .endr +END(purgatory_sha_regions) + +.globl purgatory_sha256_digest +purgatory_sha256_digest: + .skip SHA256_DIGEST_SIZE +END(purgatory_sha256_digest)