From patchwork Mon Dec 4 02:57:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 120478 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3919808qgn; Sun, 3 Dec 2017 18:55:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMZYZ4wm4nWJUO2+ZDj5VhHhFl4HlpgBbfU9VW37YeRrx5+mwM+m4vrcs5G+VyppfVADUvtE X-Received: by 10.99.114.30 with SMTP id n30mr12957036pgc.271.1512356117958; Sun, 03 Dec 2017 18:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512356117; cv=none; d=google.com; s=arc-20160816; b=NxQj58r1he9lbA9FfwsCXobV2tHUxUOIYBmyZH5fqVH3EOHQ3k2kgqydgAkh/We1eB O00xeS8R3O3pduiJS3a1c9OUehQz/yeiWT6FgVsrAvZ5ogALRtIdeZ8X3G6hmcBdA56u bzgQIdzntrF5ktV8OOiBi6lRhBFLrxrYZn4fayGdvNZPpGBR/i3kYJKASN+n+aAjtSjM g4zPZs11uotaqCogrPRb2rAF47GKx8pUW2ZuVhUmpluZU0aBxb0QMz3sUB9l0j8R7U3P Aj791ii7bcCKDRiIGBPPDa3IJKcfXE0u9pxrTZ9QPkLqcgrBUYkajEuvZhmXtL+gUWUO ZhxQ== 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=eaqM2YFE4pLElTWxPIy6UQX/U/pjnZQFhFnPPPh5vXc=; b=oMSkI/AYQ9Gt86sPaWuQBYgrve/yoqdcNsagC9T5tn5TkYplSEcaW4RYYCvuzZ4+au opprPX3Ugf1qFAQqDsYecYU1Wxg7vdu/TogI8OgbNQmaka+qQkyt2iJWDv91tWa4s3I6 IUon8Pk7ESpkIOXQYRtWBw+zAuzr1Ba7oZYYPb/zwOFfGL2cPk6/TQdLO478AJR83NRQ ib1FIdyb6RtN+slMSKdlc2jxoGhRXMS7uWAOE1kWAlkVdjwkgm+rntjJBGL9MexoiKNA xqYtBBl8/zxHXmZcDllEMRTGI7UZdvBwdPp2sjF7WLhp+PYO7nRaQ84lcTR8ajzeQfFp /S2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AbTTBDfv; 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 f9si8822884plo.553.2017.12.03.18.55.17; Sun, 03 Dec 2017 18:55:17 -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=AbTTBDfv; 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 S1753209AbdLDCzO (ORCPT + 28 others); Sun, 3 Dec 2017 21:55:14 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:42704 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753129AbdLDCzG (ORCPT ); Sun, 3 Dec 2017 21:55:06 -0500 Received: by mail-pf0-f193.google.com with SMTP id d23so7463027pfe.9 for ; Sun, 03 Dec 2017 18:55:06 -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=eaqM2YFE4pLElTWxPIy6UQX/U/pjnZQFhFnPPPh5vXc=; b=AbTTBDfvbtgluZgPbed2pReVmnrfwwvj/Lm68Q1TXy01G+JXWAtPzF5e5OfUtFG0cH lz2bQ/7jcOmBanQNPez7qVoBUlIFWW885j/DyJQV+RGKmYMdL2CjJe3RLeImkLEsWpZt MOsnFqwsp4OYM7PM564wiiBl7tEJvh+FLp284= 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=eaqM2YFE4pLElTWxPIy6UQX/U/pjnZQFhFnPPPh5vXc=; b=hxtPiwMdhoWXJC37RqK/4hvHB59YXbjgJMAOLnjZbzkhMD5X5XJR1bSmYmlD7cx3g1 MM7mVEZEuQRSCxq/DrhJ7wxn6Lx2VGHpNtmnMbQpl3XBS7SEmFqE2qKQNXzxid+Wh3Mp 49xnqO78OwVfHuvs0A4GVBxCa+cWRLz3WFexMalBrt2GcCn7XOr0+7BPRFNRXkSGUXLL dcDg5RyNjQVNQZC2x4nBRTlg2fPt5Gf0Br2PT4B7JNgbT8PfBM2WC2obfW8eVhX5u1nJ nPpLIn2cD3zeOle5xvyAkuQsPk08j0MPGTZCeizf5JlXszRnNZrOAss+svDgJTPmOzzP vZpg== X-Gm-Message-State: AJaThX4zX8j9GY7eNwVfxN0exQP6kSKwbWwo0ioPEcAx2uulLIQcoTD9 /oAA0EwJ7VfT75l2YUPDLyGlFw== X-Received: by 10.84.202.194 with SMTP id q2mr9599585plh.220.1512356105385; Sun, 03 Dec 2017 18:55:05 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v43sm3124735pgn.65.2017.12.03.18.55.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Dec 2017 18:55:04 -0800 (PST) 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 v7 05/11] arm64: kexec_file: create purgatory Date: Mon, 4 Dec 2017 11:57:55 +0900 Message-Id: <20171204025801.12161-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171204025801.12161-1-takahiro.akashi@linaro.org> References: <20171204025801.12161-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 b481b4a7c011..0f0742e98c08 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -113,6 +113,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)