From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AABDDC433DB for ; Thu, 31 Dec 2020 22:30:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E0FB2080C for ; Thu, 31 Dec 2020 22:30:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E0FB2080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NsREM851K//tC1dAXZ11VabVmeXaro3Li1vBvMLe+AM=; b=YBG7EuC1Pd+jY5GKVcOiGx8JF hOtokji0+R4CUqrgqLw3BLHZmLu/kBO+IwGRgg38Swloz3vw/u3FCcImCm0EM8pQqijtneUr0UvaJ 7QW39GIO4/w1Wt8TaeWyvxGOPql/FgjvsiarANtj4zFvNE/uWGVFW0vrF6+B5TiBSM5DPC36y2IAN sCMeYqxER63gbbkUGNWtBh3V+keBhtEJuESO4jqiWSPV4ozSCp9+aF45Cw4Qey2XB1v8Y9u5eyZD4 F77p/7Gw80J8HJ48Igsi7JXIG9H5Zo+3UvLemm1tfX4ueDpUp4qmDzFB1eiWmep3CdaAWDI+xxnsV gglu4bRFQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kv6Qz-0003PW-Ql; Thu, 31 Dec 2020 22:28:41 +0000 Received: from mail-io1-f41.google.com ([209.85.166.41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kv6Qx-0003P7-Pd for linux-arm-kernel@lists.infradead.org; Thu, 31 Dec 2020 22:28:40 +0000 Received: by mail-io1-f41.google.com with SMTP id t8so18104775iov.8 for ; Thu, 31 Dec 2020 14:28:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=x7NBsAO2KE+z+yQWJcX6vzv7SJGSJPPSWnCUrDbDsAc=; b=H6/KjDMwxjw/MP7oifuDLjwOV6MOomyRsA9dxDqqKPywLevvgM/6Y7aWesAtnG9xPy +HtzyIyJD+v/J7M3fJgjeSXFgs1Qk9p6X5NSFu3Pz4Xv4XuudjqtmQSeRAWCCRDHQea9 oN6RkK/aFWZLxje2sjiVGZUWT8D0Pbl1YNIzMYvdIPz2/HLjD166Ah1tVD4sX6ik7Qpo 3ik+HeftIwrhsyTDzjPW7t+rhjLmkaeBXoPOdJJ3KnT5dr/IjQwRnIkRoEPxZYE0Mxc5 Mfvv/ZNaMRuY/IItrDBzisUfraIr068P/b+Ux0LNxX99pT3k9AKqfXlMKLPVhzh0xwkM EOew== X-Gm-Message-State: AOAM531a/oBtxo7CbN9yrcSFgUddw/ZQYdkc/1AOFRZ361Y/rFd1Hueb JdJA9Su1l/xdcV5VyQyuUg== X-Google-Smtp-Source: ABdhPJwhVLrGlaHbOUaDZ0baiJlPdkJsY6FTy4vTxmvuPeyp0XbkRHPU3rq3aOTrVWLSJ3YmVHk9Mw== X-Received: by 2002:a6b:8b88:: with SMTP id n130mr47758169iod.122.1609453716086; Thu, 31 Dec 2020 14:28:36 -0800 (PST) Received: from robh.at.kernel.org ([64.188.179.253]) by smtp.gmail.com with ESMTPSA id q5sm33813004ilg.62.2020.12.31.14.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Dec 2020 14:28:35 -0800 (PST) Received: (nullmailer pid 2489841 invoked by uid 1000); Thu, 31 Dec 2020 22:28:33 -0000 Date: Thu, 31 Dec 2020 15:28:33 -0700 From: Rob Herring To: Lakshmi Ramasubramanian Subject: Re: [PATCH v13 2/6] powerpc: Move arch independent ima kexec functions to drivers/of/kexec.c Message-ID: <20201231222833.GA2466706@robh.at.kernel.org> References: <20201219175713.18888-1-nramas@linux.microsoft.com> <20201219175713.18888-3-nramas@linux.microsoft.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201219175713.18888-3-nramas@linux.microsoft.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201231_172839_854363_FBB8EB95 X-CRM114-Status: GOOD ( 27.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, benh@kernel.crashing.org, bhsharma@redhat.com, tao.li@vivo.com, zohar@linux.ibm.com, paulus@samba.org, vincenzo.frascino@arm.com, frowand.list@gmail.com, sashal@kernel.org, mpe@ellerman.id.au, masahiroy@kernel.org, jmorris@namei.org, takahiro.akashi@linaro.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, serge@hallyn.com, devicetree@vger.kernel.org, pasha.tatashin@soleen.com, will@kernel.org, prsriva@linux.microsoft.com, hsinyi@chromium.org, allison@lohutok.net, christophe.leroy@c-s.fr, mbrugger@suse.com, balajib@linux.microsoft.com, dmitry.kasatkin@gmail.com, linux-kernel@vger.kernel.org, james.morse@arm.com, gregkh@linuxfoundation.org, linux-integrity@vger.kernel.org, bauerman@linux.ibm.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Dec 19, 2020 at 09:57:09AM -0800, Lakshmi Ramasubramanian wrote: > The functions defined in "arch/powerpc/kexec/ima.c" handle setting up > and freeing the resources required to carry over the IMA measurement > list from the current kernel to the next kernel across kexec system call. > These functions do not have architecture specific code, but are > currently limited to powerpc. > > Move setup_ima_buffer() call into of_kexec_setup_new_fdt() defined in > "drivers/of/kexec.c". > > Move the remaining architecture independent functions from > "arch/powerpc/kexec/ima.c" to "drivers/of/kexec.c". > Delete "arch/powerpc/kexec/ima.c" and "arch/powerpc/include/asm/ima.h". > Remove references to the deleted files in powerpc and in ima. > > Co-developed-by: Prakhar Srivastava > Signed-off-by: Prakhar Srivastava > Signed-off-by: Lakshmi Ramasubramanian > --- > arch/powerpc/include/asm/ima.h | 27 ---- > arch/powerpc/kexec/Makefile | 7 - > arch/powerpc/kexec/file_load.c | 7 - > arch/powerpc/kexec/ima.c | 202 ------------------------- > drivers/of/kexec.c | 235 +++++++++++++++++++++++++++++ > include/linux/of.h | 2 + > security/integrity/ima/ima.h | 4 - > security/integrity/ima/ima_kexec.c | 1 + > 8 files changed, 238 insertions(+), 247 deletions(-) > delete mode 100644 arch/powerpc/include/asm/ima.h > delete mode 100644 arch/powerpc/kexec/ima.c > diff --git a/drivers/of/kexec.c b/drivers/of/kexec.c > index 66787be081fe..33d97106f176 100644 > --- a/drivers/of/kexec.c > +++ b/drivers/of/kexec.c > @@ -11,6 +11,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -59,6 +60,181 @@ static int fdt_find_and_del_mem_rsv(void *fdt, unsigned long start, unsigned lon > return -ENOENT; > } > > +/** > + * get_addr_size_cells - Get address and size of root node > + * > + * @addr_cells: Return address of the root node > + * @size_cells: Return size of the root node > + * > + * Return: 0 on success, or negative errno on error. > + */ > +static int get_addr_size_cells(int *addr_cells, int *size_cells) > +{ > + struct device_node *root; > + > + root = of_find_node_by_path("/"); > + if (!root) > + return -EINVAL; > + > + *addr_cells = of_n_addr_cells(root); > + *size_cells = of_n_size_cells(root); > + > + of_node_put(root); > + > + return 0; > +} > + > +/** > + * do_get_kexec_buffer - Get address and size of device tree property > + * > + * @prop: Device tree property > + * @len: Size of @prop > + * @addr: Return address of the node > + * @size: Return size of the node > + * > + * Return: 0 on success, or negative errno on error. > + */ > +static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr, > + size_t *size) > +{ > + int ret, addr_cells, size_cells; > + > + ret = get_addr_size_cells(&addr_cells, &size_cells); > + if (ret) > + return ret; > + > + if (len < 4 * (addr_cells + size_cells)) > + return -ENOENT; > + > + *addr = of_read_number(prop, addr_cells); > + *size = of_read_number(prop + 4 * addr_cells, size_cells); > + > + return 0; > +} > + > +#ifdef CONFIG_HAVE_IMA_KEXEC > +/** > + * remove_ima_buffer - remove the IMA buffer property and reservation from @fdt > + * > + * @fdt: Flattened Device Tree to update > + * @chosen_node: Offset to the chosen node in the device tree > + * > + * The IMA measurement buffer is of no use to a subsequent kernel, so we always > + * remove it from the device tree. > + */ > +static void remove_ima_buffer(void *fdt, int chosen_node) > +{ > + int ret, len; > + unsigned long addr; > + size_t size; > + const void *prop; > + Should be able to do this instead of #ifdef: if (!IS_ENABLED(CONFIG_HAVE_IMA_KEXEC)) return; Otherwise, I think it looks good. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel