Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp692788pxu; Thu, 7 Jan 2021 16:05:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlzbHiZ9fu6b4QUFPjBEnYQM61BFx7yZxz/OQMLDMR3C563kHNeUDoQMmVj2A5ZyljFnEK X-Received: by 2002:a50:c209:: with SMTP id n9mr3418900edf.123.1610064338350; Thu, 07 Jan 2021 16:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610064338; cv=none; d=google.com; s=arc-20160816; b=fXzxnDE7MA0IZtGlLfBn5qsyvJKvHnRDD+sYfsjTozn2JAdtfAjwuBAu+LEHFGH527 fhcanPh2MJsUCDQTc+WSKvVDVRZ9aWFt0fhABTOwmXhIhBIi1qpmwPDDVL5JiaYgAg5+ tPfyJ/xcB3MVZOBl9OospauS3XuH0ZvN6jVL17ugYiF4poLkiD/NPp2CIyXYrBp7+U/x spGfa1AQIJyaRvSMD0yDeBEITAHMUe0Y9JNVPI06yEhsMNvnUkm+50KpmpebSzmHkV+i eW0ymWwdloz/vTCIRu5x0cjuMno3aPwW6yDeozYcwcp3PAgEmzf+4/soeop+LbNpp02a 4ESw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VnrWTd2vISRaf7ZK8SYvTF83BwjJL1Dds3Ex444l+Oc=; b=TuSVfJ/6MmEGw//Tw71EEi+yvj6tsSFXz3MaG6Bv4WVBSk9Lomjhzaltu4HsaEV6KL 7xHMWoQzpVSCemo3osY2OM4bjCTHXq4lHOmdd/40IoeyXNSqljuyyJwH6BKJ31FRseo+ PSwcVlyXs/i8ZiAEhoKT6EOdjr3zb3NIVQQ0OD8R9/enlcA5DGIKFUoroWyWV8A9pMwp FahTTSxM0XhaTCvAqzoa7lIjQTpF0ZlSGYd1KsxQw5+ABIXcHsyT0bOf8KoP6Tr6N7mN SW+F6639qkXB7b8cgJR4hAt0HLQPjSjqCPf8lSVS/nCKXBrocHYHzkpCV5BfDPjrhoQL 8btw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eUtAZ6C1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id gw26si2839455ejb.537.2021.01.07.16.05.14; Thu, 07 Jan 2021 16:05:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eUtAZ6C1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729486AbhAHAD6 (ORCPT + 99 others); Thu, 7 Jan 2021 19:03:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728674AbhAHAD5 (ORCPT ); Thu, 7 Jan 2021 19:03:57 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DBAAC0612F5 for ; Thu, 7 Jan 2021 16:03:17 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id s75so9474638oih.1 for ; Thu, 07 Jan 2021 16:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VnrWTd2vISRaf7ZK8SYvTF83BwjJL1Dds3Ex444l+Oc=; b=eUtAZ6C1q8Ukgw7rArZ5bwk0Slk89o1R9bsNuxQztd8bC1pOKDzL88J5sR4CXV7d9B dTdn6ZSlzVj/gvEQ5AMDSYSL+AT2hj3c8Av8x2ZiGJoJKXE/5zV2R9Cq+waYNCPXwott g/QiAb8ukx56QCeb2nCYGFe4XbtXNsqczpdZP0LxyBxlLXvLdjJxGGsi/uvJ5YvP1geS YPFFb8JO0KwvQ6zCQcVKR5T28Blwb9MysxXyc5TSZAcSdu0g76XYRPuvMFiCkyXs0CMG Hp6g/PePlDsz9Pzx/WRXwH+HtthVNlR/LDZbNxYI+0yuQuG2jneMev/4F1fDefd06IU4 IA5A== 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=VnrWTd2vISRaf7ZK8SYvTF83BwjJL1Dds3Ex444l+Oc=; b=HR6x/xWaVE5F/l4XdeFnBI5dyGyZh+VWZDBNz3cKfG6wuB/mQodetCn2b5Y5/OzPPw e7ppvjr8USDlKc5dYzLarzRhiPtQdafWcaH7LgmlyfOjK6bNMF2/v56Es5E/UgZ9TyBr SvoqX17cByVDrLDvQjtP8A1NJrr/eSAJiBVYKuHXIoVNlXzk9jsodUZhqpinJWVEEtCe 5sn6vPh+rwFKlbyJimG4Ba8JRnQ7q5pLCghK4IF8HPA0IT3OvH7u7YX8+BUfSY7wYgc9 2Q9uw1pBs6hfz3OgJdP18ssJCniptqEA/nRBgh+tCTw7iO6CDT+U0HVFc44PK75k9w2g dIcw== X-Gm-Message-State: AOAM532zU+XekjH31OOy1LbqbMbHZETELgmJ5ZFOiX/iFymRVz5V6IV3 g4pLrk4Y9iN9kPe9s1i8j7Fwih2F5NJiLA== X-Received: by 2002:aca:afd0:: with SMTP id y199mr701814oie.7.1610064196811; Thu, 07 Jan 2021 16:03:16 -0800 (PST) Received: from builder.lan (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id o49sm1420932ota.51.2021.01.07.16.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 16:03:15 -0800 (PST) Date: Thu, 7 Jan 2021 18:03:14 -0600 From: Bjorn Andersson To: Siddharth Gupta Cc: agross@kernel.org, ohad@wizery.com, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, psodagud@codeaurora.org, rishabhb@codeaurora.org Subject: Re: [PATCH 1/3] soc: qcom: mdt_loader: Allow hash at any phdr Message-ID: References: <1609968211-7579-1-git-send-email-sidgup@codeaurora.org> <1609968211-7579-2-git-send-email-sidgup@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1609968211-7579-2-git-send-email-sidgup@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 06 Jan 15:23 CST 2021, Siddharth Gupta wrote: > The assumption that the elf program header will always have the hash > segment program header at index 1 may not hold true in all cases. This > change updates the read metadata function to find the hash program header > dynamically. > Reviewed-by: Bjorn Andersson Regards, Bjorn > Signed-off-by: Siddharth Gupta > --- > drivers/soc/qcom/mdt_loader.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c > index 24cd193..813216d 100644 > --- a/drivers/soc/qcom/mdt_loader.c > +++ b/drivers/soc/qcom/mdt_loader.c > @@ -4,7 +4,7 @@ > * > * Copyright (C) 2016 Linaro Ltd > * Copyright (C) 2015 Sony Mobile Communications Inc > - * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. > + * Copyright (c) 2012-2013, 2020 The Linux Foundation. All rights reserved. > */ > > #include > @@ -88,6 +88,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len) > const struct elf32_phdr *phdrs; > const struct elf32_hdr *ehdr; > size_t hash_offset; > + size_t hash_index; > size_t hash_size; > size_t ehdr_size; > void *data; > @@ -98,14 +99,19 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len) > if (ehdr->e_phnum < 2) > return ERR_PTR(-EINVAL); > > - if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD) > + if (phdrs[0].p_type == PT_LOAD) > return ERR_PTR(-EINVAL); > > - if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH) > + for (hash_index = 1; hash_index < ehdr->e_phnum; hash_index++) { > + if (phdrs[hash_index].p_type != PT_LOAD && > + (phdrs[hash_index].p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) > + break; > + } > + if (hash_index >= ehdr->e_phnum) > return ERR_PTR(-EINVAL); > > ehdr_size = phdrs[0].p_filesz; > - hash_size = phdrs[1].p_filesz; > + hash_size = phdrs[hash_index].p_filesz; > > data = kmalloc(ehdr_size + hash_size, GFP_KERNEL); > if (!data) > @@ -115,7 +121,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len) > if (ehdr_size + hash_size == fw->size) > hash_offset = phdrs[0].p_filesz; > else > - hash_offset = phdrs[1].p_offset; > + hash_offset = phdrs[hash_index].p_offset; > > memcpy(data, fw->data, ehdr_size); > memcpy(data + ehdr_size, fw->data + hash_offset, hash_size); > -- > Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project >