From patchwork Tue Sep 1 19:50:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lakshmi Ramasubramanian X-Patchwork-Id: 11749421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F0871575 for ; Tue, 1 Sep 2020 19:50:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 001D9207D3 for ; Tue, 1 Sep 2020 19:50:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="b/g7HGaX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732712AbgIATuu (ORCPT ); Tue, 1 Sep 2020 15:50:50 -0400 Received: from linux.microsoft.com ([13.77.154.182]:47474 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732542AbgIATuh (ORCPT ); Tue, 1 Sep 2020 15:50:37 -0400 Received: from localhost.localdomain (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 9FA6620B36E7; Tue, 1 Sep 2020 12:50:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9FA6620B36E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1598989837; bh=uk5tkZtfuu9874FjBZVS0ALgWIcN65kyJsAQnFGmePg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b/g7HGaXNgg9Bx5QXv8e3+AfjI6jycWPi9gou9LgiIp0OQnt0GV02313bthzWybpG e1/KbWyW2VYR/aoxo0YdWglmTiLTs25/k6bRn7GipJh6pG+T5oRuzhASUbIua1FC0k CX2gsiG5WWsu5Z0oATEAu8zWMKMSaVAX6NDWM718= From: Lakshmi Ramasubramanian To: zohar@linux.ibm.com, bauerman@linux.ibm.com, robh@kernel.org, gregkh@linuxfoundation.org, james.morse@arm.com, catalin.marinas@arm.com, sashal@kernel.org, will@kernel.org, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, robh+dt@kernel.org, frowand.list@gmail.com, vincenzo.frascino@arm.com, mark.rutland@arm.com, dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, pasha.tatashin@soleen.com, allison@lohutok.net, kstewart@linuxfoundation.org, takahiro.akashi@linaro.org, tglx@linutronix.de, masahiroy@kernel.org, bhsharma@redhat.com, mbrugger@suse.com, hsinyi@chromium.org, tao.li@vivo.com, christophe.leroy@c-s.fr Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, prsriva@linux.microsoft.com, balajib@linux.microsoft.com Subject: [PATCH v5 3/3] arm64: Add IMA kexec buffer to DTB Date: Tue, 1 Sep 2020 12:50:29 -0700 Message-Id: <20200901195029.30039-4-nramas@linux.microsoft.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901195029.30039-1-nramas@linux.microsoft.com> References: <20200901195029.30039-1-nramas@linux.microsoft.com> MIME-Version: 1.0 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org The address and size of the current kernel's IMA measurement log need to be added to the device tree's IMA kexec buffer node for the log to be carried over to the next kernel on the kexec call. Add the IMA measurement log buffer properties to the device tree for ARM64 and reserve the memory for storing the IMA log. Update CONFIG_KEXEC_FILE to select CONFIG_HAVE_IMA_KEXEC to indicate that the IMA measurement log information is present in the device tree. Co-developed-by: Prakhar Srivastava Signed-off-by: Prakhar Srivastava Signed-off-by: Lakshmi Ramasubramanian --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/machine_kexec_file.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6d232837cbee..9f03c8245e5b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1077,6 +1077,7 @@ config KEXEC config KEXEC_FILE bool "kexec file based system call" select KEXEC_CORE + select HAVE_IMA_KEXEC help This is new version of kexec system call. This system call is file based and takes file descriptors as system call argument diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c index 361a1143e09e..0fe3d629eefe 100644 --- a/arch/arm64/kernel/machine_kexec_file.c +++ b/arch/arm64/kernel/machine_kexec_file.c @@ -136,6 +136,21 @@ static int setup_dtb(struct kimage *image, FDT_PROP_KASLR_SEED); } + /* add ima-kexec-buffer */ + if (image->arch.ima_buffer_size > 0) { + ret = fdt_appendprop_addrrange(dtb, 0, off, + FDT_PROP_IMA_KEXEC_BUFFER, + image->arch.ima_buffer_addr, + image->arch.ima_buffer_size); + if (ret) + return (ret == -FDT_ERR_NOSPACE ? -ENOMEM : -EINVAL); + + ret = fdt_add_mem_rsv(dtb, image->arch.ima_buffer_addr, + image->arch.ima_buffer_size); + if (ret) + goto out; + } + /* add rng-seed */ if (rng_is_initialized()) { void *rng_seed;