From patchwork Fri Sep 15 10:59:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 112710 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp470527qgf; Fri, 15 Sep 2017 03:57:51 -0700 (PDT) X-Received: by 10.98.196.73 with SMTP id y70mr24013744pff.334.1505473071015; Fri, 15 Sep 2017 03:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505473071; cv=none; d=google.com; s=arc-20160816; b=pyIxnATNKon2FfyYC/NOGnhDFCxDna8d7RH9ve90RaAkbKSPnE1KTwpeAzm/UY1sP3 VqsJmciPfEb1FwRcwQEvdOToIubbIEdqSpuNJMrBdAL/oM1UObth+TMO/4MWi+t/uKgn zyh79FPD13CGqrsD+2VBPwszs9omE3FpceXWAxbYGSY12hOkpYYEwFIGKXtBkpmtIr13 PG8oCPq0gxiTEkaKP9xVPStZxehTjzEjmals0BTNy/tJs7opPs0x+pL9o1S4VNYW6zzu o3Qmtqwv2vlGBwJkbLDhih4yCLqHcL0o9MQO2E5RLNFM1elOjU2az6pGsNiIZNxYKSvX rNfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=G8IuSGIeoIG2NL5VJhAfjDVujUmkg9tHs8XQYoklK0k=; b=bch0fec0/8LhZWy2pCxB1JkQBZ7gR9FrilXPf7P/elXOSlTC8xH5067qLqunezih1U hXzD4O+KQhd71lnLrY7x7JBURAdaHj4lxGg8W8J7xUicqw9uh3QGARawZLB1nixZP5oU f9tySaCzy6fGkQ1FRf0+H1FzArTkMUUG5LkipfZSFD4gX3xjmG2tjyB6w9q+Jdz/ZQzO wBub+duTsnQQBA4D48xtvp/iqIV/lnV8orvGeK4XJJjks5yBRuIJbZpxXReOK+peNnlr KNwpqUXwhmUQCySNiQLAR7gW1nA8/OWkHNpr1esB/t9cFi00sfe2UZHYr+CMw1OHPLHd Yiow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hil0uE/o; 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 y18si476518pfa.44.2017.09.15.03.57.49; Fri, 15 Sep 2017 03:57:50 -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=hil0uE/o; 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 S1751303AbdIOK5q (ORCPT + 26 others); Fri, 15 Sep 2017 06:57:46 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:45440 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbdIOK5o (ORCPT ); Fri, 15 Sep 2017 06:57:44 -0400 Received: by mail-pg0-f43.google.com with SMTP id 188so1310979pgb.2 for ; Fri, 15 Sep 2017 03:57:44 -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; bh=G8IuSGIeoIG2NL5VJhAfjDVujUmkg9tHs8XQYoklK0k=; b=hil0uE/ooAOvElwCGpagIzt9G8AJ5ryZgh3dePrT06k7pvXUzma1ncP6zmQfZURZNe IetWltPzT1/DJ/k/OHsLx3AD/GwH0FSYFzuXxj4xnGXuumlCaTXgELLHmRcA4yIA5fNP bFXc8wrZu4p88TkNwLK0fAiwfVnfyByQZhhgI= 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; bh=G8IuSGIeoIG2NL5VJhAfjDVujUmkg9tHs8XQYoklK0k=; b=Nh+mP+UxcUPqkMUIjzw0xAonswjN09Wv3g6RxW+V94IPHVN9n/w7+AOHP9XCpGAc/6 UTUJm+Af+XNvuq+znhPoOfD0IKHK4npzKIz/p7uhP82T1WgLVfDE7RBYHCOjlRZTBGb4 VLkiemjYVVNnu2kxIGnHSC5FYum3R06DnUrnTu4spX/HepRmu4CTsU2ZGUuo5WpvsDav 6KmVvkh+D7lyBwnZ4hJR8O2QlTPyJOOctNZ0+gBSQxsjXMvj/CjAVI90UhYGqDyBdNkb uyjpKDcyCRDRdaA0rKUglNEDXqTrnX16vZ8y/lgOhT53TMGKsxuiZD9ZtAFiqeziff7e hT3g== X-Gm-Message-State: AHPjjUiD+Y0BKkk/l5JNTXJSH6VlpbUYzfxcHDvwx3I5BrmDCEuLVx9S MH50oMWYAcTTGhDB X-Google-Smtp-Source: ADKCNb76z8mkjUy0bSxf2hZ5fhuz+vo/loaM/wNpztiY746CBurRY70tLnl2NybGDv7M1vHNR9GtIA== X-Received: by 10.98.138.17 with SMTP id y17mr17081365pfd.149.1505473064081; Fri, 15 Sep 2017 03:57:44 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id k82sm1796120pfj.66.2017.09.15.03.57.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 03:57:43 -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 00/10] arm64: kexec: add kexec_file_load() support Date: Fri, 15 Sep 2017 19:59:22 +0900 Message-Id: <20170915105932.25338-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is the third round of implementing kexec_file_load() support on arm64.[1] Most of the code is based on kexec-tools (along with some kernel code from x86, which also came from kexec-tools). This patch series enables us to * load the kernel, Image, with kexec_file_load system call, and * optionally verify its signature at load time for trusted boot. To load the kernel via kexec_file_load system call, a small change is also needed to kexec-tools. See [2]. This enables '-s' option. As we discussed a long time ago, users may not be allowed to specify device-tree file of the 2nd kernel explicitly with kexec-tools, hence re-using the blob of the first kernel. Regarding a signing method, we conform with x86 (or rather Microsoft?) style of signing since the binary can also be seen as in PE format (assuming that CONFIG_EFI is enabled). Powerpc is also going to support extended-file-attribute-based verification[3] with vmlinux, but arm64 doesn't for now partly because we don't have TPM-based IMA at this moment. Accordingly, we can use the existing command, sbsign, to sign the kernel. $ sbsign --key ${KEY} --cert ${CERT} Image Please note that it is totally up to the system what key/certificate is used for signing, but one of easy ways to *try* this feature is to turn on CONFIG_MODULE_SIG so that we can reuse certs/signing_key.pem as a signing key, KEY and CERT above, for kernel. (This also enables CONFIG_CRYPTO_SHA1 by default.) Some concerns(or future works): * Even if the kernel is configured with CONFIG_RANDOMIZE_BASE, the 2nd kernel won't be placed at a randomized address. We will have to add some boot code similar to efi-stub to implement the feature. * While big-endian kernel can support kernel signing, I'm not sure that Image can be recognized as in PE format because x86 standard only defines little-endian-based format. * IMA(and extended file attribute)-based kexec * vmlinux support [1] http://git.linaro.org/people/takahiro.akashi/linux-aarch64.git branch:arm64/kexec_file [2] http://git.linaro.org/people/takahiro.akashi/kexec-tools.git branch:arm64/kexec_file [3] http://lkml.iu.edu//hypermail/linux/kernel/1707.0/03669.html Changes in v3 (Sep 15, 2017) * fix kbuild test error * factor out arch_kexec_kernel_*() & arch_kimage_file_post_load_cleanup() * remove CONFIG_CRASH_CORE guard from kexec_file.c * add vmapped kernel region to vmcore for gdb backtracing (see prepare_elf64_headers()) * merge asm/kexec_file.h into asm/kexec.h * and some cleanups Changes in v2 (Sep 8, 2017) * move core-header-related functions from crash_core.c to kexec_file.c * drop hash-check code from purgatory * modify purgatory asm to remove arch_kexec_apply_relocations_add() * drop older kernel support * drop vmlinux support (at least, for this series) Patch #1 to #5 are all preparatory patches on generic side. Patch #6 is purgatory code. Patch #7 to #9 are common for enabling kexec_file_load. Patch #10 is for 'Image' support. AKASHI Takahiro (10): include: pe.h: remove message[] from mz header definition resource: add walk_system_ram_res_rev() kexec_file: factor out arch_kexec_kernel_*() from x86, powerpc kexec_file: factor out crashdump elf header function from x86 asm-generic: add kexec_file_load system call to unistd.h arm64: kexec_file: create purgatory arm64: kexec_file: load initrd, device-tree and purgatory segments arm64: kexec_file: set up for crash dump adding elf core header arm64: enable KEXEC_FILE config arm64: kexec_file: add Image format support arch/arm64/Kconfig | 29 +++ arch/arm64/Makefile | 1 + arch/arm64/include/asm/kexec.h | 93 +++++++ arch/arm64/kernel/Makefile | 4 +- arch/arm64/kernel/kexec_image.c | 105 ++++++++ arch/arm64/kernel/machine_kexec_file.c | 365 ++++++++++++++++++++++++++++ arch/arm64/purgatory/Makefile | 24 ++ arch/arm64/purgatory/entry.S | 55 +++++ arch/powerpc/include/asm/kexec.h | 4 + arch/powerpc/kernel/machine_kexec_file_64.c | 36 +-- arch/x86/kernel/crash.c | 324 ------------------------ arch/x86/kernel/machine_kexec_64.c | 59 +---- include/linux/ioport.h | 3 + include/linux/kexec.h | 43 +++- include/linux/pe.h | 2 +- include/uapi/asm-generic/unistd.h | 4 +- kernel/kexec_file.c | 360 ++++++++++++++++++++++++++- kernel/kexec_internal.h | 20 ++ kernel/resource.c | 59 +++++ 19 files changed, 1156 insertions(+), 434 deletions(-) create mode 100644 arch/arm64/kernel/kexec_image.c create mode 100644 arch/arm64/kernel/machine_kexec_file.c create mode 100644 arch/arm64/purgatory/Makefile create mode 100644 arch/arm64/purgatory/entry.S -- 2.14.1