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: 10089571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8FE4160327 for ; Mon, 4 Dec 2017 03:03:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8594428E54 for ; Mon, 4 Dec 2017 03:03:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 781F528E56; Mon, 4 Dec 2017 03:03:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, URIBL_DBL_ABUSE_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B2A028E54 for ; Mon, 4 Dec 2017 03:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1HAUADklW2AefA4XwAPh+int9vXZLaD/+CiK9bocngE=; b=t4yWzX3NIaO39+Ejx5Aj29mayi OBVp8/Jfa5KRh6DAqp09j9375Cg3LxnUrhCOOpzV+Ihi6GnHchlWA8pW8tSgSDrw4zcJT2zIOG46m yf8jiB/URsEr9QQHZA15tctgpq1EFpOFMcq4YAhK6N6qw5g2IEGFn5N7Pk3Jx3CtC35mdsyQ0Zr0H ztlwvgdtAUNiCBPevIXadflQAWFDsPCmicAiT4dwYQh7SULxEHJaYuLPit4Ym62xWkrCPIwEz+euH Li8Bgn92OG/pIt7x04rc13Vb50/aAEHSnOA0onXa3mOg1UO0FnSqee/gf4kEwVm1lXmQLaCp1d4Vh 0EB8fsug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLh2j-00074N-Dj; Mon, 04 Dec 2017 03:03:41 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLguk-0000fE-6O for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 02:55:28 +0000 Received: by mail-pf0-x243.google.com with SMTP id e3so7467171pfi.10 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=fcYvTRWL2qUO5I+BPmO4i6WVGs8VwsUkaKfZlg2nKtoy/ooYPBsbu3RdIPLHdtR8mw 9qHtvuy9f3Tg5ZrXavtw/80EU02gEolcxCVq5veVFnQnY9+YBxyoH5U3ThJLdzUoS0/V LWic3rx0yfr4v3DM1lFW0hihlqydinRjO641WX4KxU2q9mbkKZt1Atezh/iYz7ly1wkA usb0217vDm3OsA88k6YFCKJYFWPvKu6O4sxH1ESvxUkGJhBh08FR6z3wlg5YxNevDwl3 BZUmFWzvNxe/8ovZKkvfjc9WTpBoaevfrkaGqgz2MhyQlkLsm2MEGNz3uVo+G7/0jBxL hkOA== X-Gm-Message-State: AJaThX7SGMbd5fCfsODruv1jbldV9rRSsmhQDF3jPTKY1a5HvcIAsWlt 1J3TqbFyzEv3RK6q1pF0bXrroQ== X-Google-Smtp-Source: AGs4zMZ4WfHy02fCQze5P4xwLG7TOo/+vmunnLDwaciwKBxCyp1oAhZERlbEkOdUrFGCt9G5f+SKfw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171203_185526_323312_3353A420 X-CRM114-Status: GOOD ( 16.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: AKASHI Takahiro , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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)