From patchwork Fri Sep 15 10:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 112716 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp471001qgf; Fri, 15 Sep 2017 03:58:29 -0700 (PDT) X-Received: by 10.84.224.141 with SMTP id s13mr27371131plj.409.1505473109149; Fri, 15 Sep 2017 03:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505473109; cv=none; d=google.com; s=arc-20160816; b=sJEuKsxLjue07aonqPJM1UpI325UkWO/+wOu4GgU3wkTRiSQKyILoDusQ0PEdU8X3i 6LazcjPfppzYcw37qaak8dQRblaKD7ciWuMBR3iw3J73q76Xlmxn3ajbHDtks+0DFLTI GuR5LVBEdqwkYKT3RcWOUOtgAEQfbF28gO/0PwgAWUjwDRAuaQ53+a1RQ0mtLz3SC3a7 28blou7T6Htc2XecgsjbbJyaMD+PZyzl6DM0oyokRSDK2zkd9er9K5CR8Vf4ThkrwVZN r0VmGIXCzg6GkREerxluPf9WTckI4d8t+WUGAnfp9ff3y5b9QBX86VYX+kDWKHVkSHk9 fZhg== 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=7jakUu5zZVUZd6l4cWf4+pL5rKleWCl55w/nm/hAfdo=; b=iJ86pKru8WAFXRhaETcDoPVdAm/z9f/FsxrLTbsD1UfYWob5lDRnLbo2YAf92w9MEk SFPIMyZbhKJrig/ByxsWo/3RM/amaasLESPgajSyNjFu1HlXLW8gLGaIkcQmHApp0mml u9LZGDsYQttJIOhw45mKMo+CcpN8VCRKg28Um94ebJ0QXH1/JqGnLVRQs1cmpcjsi30i cqrztr3TaBwoDuUFE4KXD5a0qXhNBEGJSTroi5Ar1KwOuqCC3R8bCGtxaCV71Coz4kci swtye2dipSR0H/GbBB3y1JmNvw5MsBvB6xbIcGDn9hKgjt2yoAh/qJNtbTt7O1b8ERX9 1Ufw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Y3jsVQpv; 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 z27si479373pgc.53.2017.09.15.03.58.28; Fri, 15 Sep 2017 03:58:29 -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=Y3jsVQpv; 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 S1751610AbdIOK60 (ORCPT + 26 others); Fri, 15 Sep 2017 06:58:26 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:51344 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbdIOK6Y (ORCPT ); Fri, 15 Sep 2017 06:58:24 -0400 Received: by mail-pg0-f43.google.com with SMTP id k193so1302706pgc.8 for ; Fri, 15 Sep 2017 03:58:24 -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=7jakUu5zZVUZd6l4cWf4+pL5rKleWCl55w/nm/hAfdo=; b=Y3jsVQpvEZQogOPhkmXs9QONBu+09E/eYC/vXe7WDSfcAWYwanNyvA+XEdRwVhMI8W I+xcmZtksT3p+g0Lt70dUigdGFsJkrNOmxK2jG/w1Z9cxwshLt1FUooKOSeAmjQcCB/T mfzRuCGBOf761KICx8xIsFKSRRQXjLF5kYY/I= 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=7jakUu5zZVUZd6l4cWf4+pL5rKleWCl55w/nm/hAfdo=; b=niVyxt+r7ymoAliq/MuYkcMtc0i6qioWH8Jm73ctNL1JODY+LVMrXPUfgaoFnguEVr 9DoR4o+QMmFAjdbomTblyARXczfpDJ7SsrzxXtg36pWyBft5yZRvMYWeOhJI/xrH3ahl xWTiWazGSPz97FSy/QyVPADX0dqWumbLwPO8VQg7kaCaggL1P7kAE1PbUNrIx0LqHhvH P9egj+B0tjplzqlbjJvEFc34XS0hnV/3CNxWtAr0ZE92ujrAbBCr3PDVZbkYk4U8t58W Z9X1EiMFAoVtV1yA+I71a5HGqwEuCgHl5b1LMKl+8E7C2YfyP+4wU8/SeqgFSjOlV8Ga taTQ== X-Gm-Message-State: AHPjjUgH3JCb334RGmeuasOcMazhSECEgahqvj1Wr4tt22qafLhswuus aosnoO08PWlVVg9W X-Google-Smtp-Source: ADKCNb7jgGIBgrA6lR9yOUQuY9/64uTXrsHhjdDRG7a3DzRlT3TqKfFPr7pmZCcgI+sJxtASXBq3WQ== X-Received: by 10.84.236.76 with SMTP id h12mr27771505pln.181.1505473103776; Fri, 15 Sep 2017 03:58:23 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id x189sm1944768pfx.188.2017.09.15.03.58.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 03:58:23 -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 Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v3 06/10] arm64: kexec_file: create purgatory Date: Fri, 15 Sep 2017 19:59:28 +0900 Message-Id: <20170915105932.25338-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170915105932.25338-1-takahiro.akashi@linaro.org> References: <20170915105932.25338-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 9b41f1e3b1a0..429f60728c0a 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -105,6 +105,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)