Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp449259ybb; Fri, 10 Apr 2020 03:26:03 -0700 (PDT) X-Google-Smtp-Source: APiQypJKBU2qNnawxGV9qd3LtOvXiIP0aLA2mNBLdVpKUrl82D24E8q/MvAODy9erkEtEV1PBeD5 X-Received: by 2002:a05:620a:713:: with SMTP id 19mr3314569qkc.264.1586514363284; Fri, 10 Apr 2020 03:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586514363; cv=none; d=google.com; s=arc-20160816; b=xuUaiT5EceKrddSgSSkufAdamW7crgg22EgmRER3gdwDkeKPMf9pKXjXcDtTImkFkK tWTKz/uLLc1k63vdA+mESCkvc1o2SM5YuzO09b1wIjqetneeO8U2xEGC1IozqbOXgn1L MQmUuw8tSPzkAnWZE2cUCXMUa77RVGiFFHxRxXFIsn7wj28blkk0nRQmMt2fu7ay94L1 pY3rvOdNHfIXgWepBq30EiFy7R/mdYZ9qS84NXuAup+DaVGYD6UopPGA/dBcMOdAbVUI XvyTHSQdM5HnNdYG7Ty/xhSDKRTQizW/KtWD4Sw/+C4ilaFuwaYACTQ9bVagdzu/jggO 5iYw== 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:dkim-filter; bh=HcxJ6DLN3dQyTIH886Czrjj7+pb+tkaU97+d+7JF+Kw=; b=mtpJIFO1cDRCvqjiFguDIpG8wztJ5yB3EmEdgTd38M5LkwT+TaIBhGB9Y5/VWXd0Qw +yPpdlLrhzJCnW8YPxsN9JQfDi7waP8Bq61r9t7npvqqdbMlvGoUhUPCsmAyYT59TNv+ ryJtdkH840Ku3H8fT6SYvaeJeiVHSgZ55Sy0XvPnsfTndE48AI1RTVwdfm1Evl9G/yl2 KjJUd9kz0CFuRc21N5ouYL5jXS24819o9AyjH/yyvyy01huXVIfOCT3CMkQl+3IHSWvO kCkTSswEzCNWVsOS1VDCWFyEH5vqVSHFuVIjfVhKaMjRG1Jy3TUSPQ+xAd/4FUwAsbi0 FpNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=e9YOgxQ8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kalray.eu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si1053870qkd.168.2020.04.10.03.25.48; Fri, 10 Apr 2020 03:26:03 -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=@kalray.eu header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=e9YOgxQ8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kalray.eu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbgDJKYo (ORCPT + 99 others); Fri, 10 Apr 2020 06:24:44 -0400 Received: from zimbra2.kalray.eu ([92.103.151.219]:57196 "EHLO zimbra2.kalray.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbgDJKYm (ORCPT ); Fri, 10 Apr 2020 06:24:42 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id CF18527E05D7; Fri, 10 Apr 2020 12:24:41 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Tauu7QdF0F_V; Fri, 10 Apr 2020 12:24:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 5F82627E0589; Fri, 10 Apr 2020 12:24:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 5F82627E0589 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1586514281; bh=HcxJ6DLN3dQyTIH886Czrjj7+pb+tkaU97+d+7JF+Kw=; h=From:To:Date:Message-Id; b=e9YOgxQ8KJK6iwGyl1wfGlIJ0sLD7SiyWn2pMxn7C1ovz2yJb3Hl1rCwFRccJ/Y1s JWfbH24nceHgj7R/r/bM0QFcsdVvDeth3WhaHsUIRXR5pFybGaXU2AAOeQEtYly8hb HhsUqc4dazZ1HMMAD/ECiOSyKjP6auN3wz3G7HKI= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XktIL38oOsdu; Fri, 10 Apr 2020 12:24:41 +0200 (CEST) Received: from triton.lin.mbt.kalray.eu (unknown [192.168.37.25]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 44BEC27E039A; Fri, 10 Apr 2020 12:24:41 +0200 (CEST) From: Clement Leger To: Andy Gross , Bjorn Andersson , Ohad Ben-Cohen , Maxime Coquelin , Alexandre Torgue Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Clement Leger Subject: [PATCH 1/2] remoteproc: add rproc_coredump_set_elf_info Date: Fri, 10 Apr 2020 12:24:32 +0200 Message-Id: <20200410102433.2672-2-cleger@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200410102433.2672-1-cleger@kalray.eu> References: <20200410102433.2672-1-cleger@kalray.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function allows drivers to correctly setup the coredump output elf information. Signed-off-by: Clement Leger --- drivers/remoteproc/remoteproc_core.c | 32 ++++++++++++++++++++-- drivers/remoteproc/remoteproc_elf_loader.c | 3 -- include/linux/remoteproc.h | 2 ++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a9ac1d01e09b..382443bab583 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1562,6 +1562,28 @@ int rproc_coredump_add_custom_segment(struct rproc *rproc, } EXPORT_SYMBOL(rproc_coredump_add_custom_segment); +/** + * rproc_coredump_set_elf_info() - set coredump elf information + * @rproc: handle of a remote processor + * @class: elf class for coredump elf file + * @size: elf machine for coredump elf file + * + * Set elf information which will be used for coredump elf file. + * + * Return: 0 on success, negative errno on error. + */ +int rproc_coredump_set_elf_info(struct rproc *rproc, u8 class, u16 machine) +{ + if (class != ELFCLASS64 && class != ELFCLASS32) + return -EINVAL; + + rproc->elf_class = class; + rproc->elf_machine = machine; + + return 0; +} +EXPORT_SYMBOL(rproc_coredump_set_elf_info); + /** * rproc_coredump() - perform coredump * @rproc: rproc handle @@ -1584,6 +1606,11 @@ static void rproc_coredump(struct rproc *rproc) if (list_empty(&rproc->dump_segments)) return; + if (class == ELFCLASSNONE) { + dev_err(&rproc->dev, "Elf class is not set\n"); + return; + } + data_size = elf_size_of_hdr(class); list_for_each_entry(segment, &rproc->dump_segments, node) { data_size += elf_size_of_phdr(class) + segment->size; @@ -1602,7 +1629,7 @@ static void rproc_coredump(struct rproc *rproc) elf_hdr_init_ident(ehdr, class); elf_hdr_set_e_type(class, ehdr, ET_CORE); - elf_hdr_set_e_machine(class, ehdr, EM_NONE); + elf_hdr_set_e_machine(class, ehdr, rproc->elf_machine); elf_hdr_set_e_version(class, ehdr, EV_CURRENT); elf_hdr_set_e_entry(class, ehdr, rproc->bootaddr); elf_hdr_set_e_phoff(class, ehdr, elf_size_of_hdr(class)); @@ -2043,7 +2070,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, rproc->name = name; rproc->priv = &rproc[1]; rproc->auto_boot = true; - rproc->elf_class = ELFCLASS32; + rproc->elf_class = ELFCLASSNONE; + rproc->elf_machine = EM_NONE; device_initialize(&rproc->dev); rproc->dev.parent = dev; diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index 16e2c496fd45..4869fb7d8fe4 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -248,9 +248,6 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) memset(ptr + filesz, 0, memsz - filesz); } - if (ret == 0) - rproc->elf_class = class; - return ret; } EXPORT_SYMBOL(rproc_elf_load_segments); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ed127b2d35ca..d67eb5a40476 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -515,6 +515,7 @@ struct rproc { struct list_head dump_segments; int nb_vdev; u8 elf_class; + u16 elf_machine; }; /** @@ -619,6 +620,7 @@ int rproc_coredump_add_custom_segment(struct rproc *rproc, struct rproc_dump_segment *segment, void *dest), void *priv); +int rproc_coredump_set_elf_info(struct rproc *rproc, u8 class, u16 machine); static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev) { -- 2.17.1