From patchwork Sat Aug 28 07:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 503768 Delivered-To: patch@linaro.org Received: by 2002:a02:6f15:0:0:0:0:0 with SMTP id x21csp1973236jab; Sat, 28 Aug 2021 00:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE7pUaYtundeXk3PgrQKTmqi3CcbWLY/tEBEC9hNHCqwjsh53FW6FTNOfFZPqm5NehS1Dz X-Received: by 2002:a05:6402:b85:: with SMTP id cf5mr1422846edb.153.1630134142864; Sat, 28 Aug 2021 00:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630134142; cv=none; d=google.com; s=arc-20160816; b=OtnqvNvU0pUykUA5fMbACu3xYiRw50pnslxAZjmg+hPI8gQMOjX5yhHJP4fOlgzeOX SgDu58SSRKFyboVYl7peL2vyY0SRIOHZjmnzWyQcay7a2yDsCpfw1IDdtNM7VTXKqOQm BOZoPmoxY8xg55lGLeNXeSrfCr92C+Nqs6b8AmPh2mu4wREqxk6jpZ+fh7pLpo13DAk6 cKJkiSbjAeOxlXxS5QlQmx/mLqV15UcA76+M4usw2mnowxIBfniPTPimVtAWMxj3VZZD A2+k+ZLmr4zM9jtRAdggXyAileICbxpWSKGYOw7abM7GkR4W5knKkHgunufL2QKvwaEu sIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=Oma39e4ztyqU/L0DrbCeGQ/UJAnQ1l0pUG/tIJG6wR4=; b=rQlR2GLqi60EamWhFR5gJpuMFTBTJ1o105wUkY0QrZfrji9U/GhEmvigsRRTDaEAjf 09O8Fo/FpCEPDF4r4ydnb/lKyWUQaigOWjE7JFxNhWj3QqNR3Hi+d+Q/X0b3DHRT4PYA qTZXlIls/XjeMQ2QiVYmNUIXiyNioyhsGvEQR9g+Ct/2IsNtldL7UD2hmljTAXPETD6x ZqKwNjScpLDDI9OCn+wYSXoudvkDAY42eeWtN+zs3rFmpOk5LMvGoTgq3Fws5/dkqFbg K+WNTa3/PwkURSO8AZUhM/BfEAofJgzJcOYV9l08cCG5AjFHyCp//LKsA9TPv42gZxog J/kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="s/CUPMeD"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 qw31si8890708ejc.633.2021.08.28.00.02.21; Sat, 28 Aug 2021 00:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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="s/CUPMeD"; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S233375AbhH1HDJ (ORCPT + 16 others); Sat, 28 Aug 2021 03:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233352AbhH1HDI (ORCPT ); Sat, 28 Aug 2021 03:03:08 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8763CC0613D9 for ; Sat, 28 Aug 2021 00:02:18 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id m6so3066pfh.13 for ; Sat, 28 Aug 2021 00:02:18 -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=Oma39e4ztyqU/L0DrbCeGQ/UJAnQ1l0pUG/tIJG6wR4=; b=s/CUPMeDIpZQSgMbAi4HZ+h401BTKoxrEbc9dVPc2nFy6iY3o6sbC7Qf353urfMCQs w9jnKRqj1j3tV3hWJ17nzQGo35q/0sP7JslWmsiHHuFHNUJIwM4UfeETs8RN1Whcq2iV so7uqB51C89jgiA8CCb9uzfQ9zlMdW4NpEKZ23bj3L8B6G7e7TNTeouviZa72lHFQSoC lm+O0ooX7yHhwQhBR5oGOoK0f98056ycI+yhuxiCZqNmCTk27bFdCIxyKI07DqSFtDqF JvInMkxusmvsnqLFilFB1Fx4WX7r6CevezlsFacD2XECi2Em6eq0KJZNFoaEdA9VctWM hsCQ== 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=Oma39e4ztyqU/L0DrbCeGQ/UJAnQ1l0pUG/tIJG6wR4=; b=ZK6K38NCUlZ8Y8i06+ecdzFmNIYDN3xk1XGBYZomQts3OnR9y6MZB8sVhk7K1AkFTr AvDjVJm1GMFP+j3k750vFAeZ+DYhqAN8oN7TH1/zKYsQnwSwzmgNMAkUcPANhBmihMg/ t4T3RAFByItSJh5MhBjJjGMoEwRE82TR8SgHiMXcrQnlSACtxktMPkR1kck7dUPE55jq BvyBp8eMihO8HEdXfHcO38RCJb1gGHtLqBiMh2UuqFssyhEbLo6d4xgymLD4L7B7aRp2 h4POGK7L+PHROFfpUeX86IkboIk+wZCEdK5Y5MqxUXGKhp2WjkJosllp/oFs0wSkzUJP 1uDQ== X-Gm-Message-State: AOAM533n3x+m9/Jpk3J9/ELJQD9ldezMiGx+TdJGZbl1Ds7OyGb001l9 /yVbmS+mdC4edjtsjkK+iBbNFA== X-Received: by 2002:a63:1b60:: with SMTP id b32mr11188888pgm.422.1630134138055; Sat, 28 Aug 2021 00:02:18 -0700 (PDT) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id 141sm8674284pfv.15.2021.08.28.00.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Aug 2021 00:02:17 -0700 (PDT) From: Shawn Guo To: Bjorn Andersson Cc: Marijn Suijten , Siddharth Gupta , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment Date: Sat, 28 Aug 2021 15:02:02 +0800 Message-Id: <20210828070202.7033-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org PT_LOAD type denotes that the segment should be loaded into the final firmware memory region. Hash segment is not one such, because it's only needed for PAS init and shouldn't be in the final firmware memory region. That's why mdt_phdr_valid() explicitly reject non PT_LOAD segment and hash segment. This actually makes the hash segment type check in qcom_mdt_read_metadata() unnecessary and redundant. For a hash segment, it won't be loaded into firmware memory region anyway, due to the QCOM_MDT_TYPE_HASH check in mdt_phdr_valid(), even if it has a PT_LOAD type for some reason (misusing or abusing?). Some firmware files on Sony phones are such examples, e.g WCNSS firmware of Sony Xperia M4 Aqua phone. The type of hash segment is just PT_LOAD. Drop the unnecessary hash segment type check in qcom_mdt_read_metadata() to fix firmware loading failure on these phones, while hash segment is still kept away from the final firmware memory region. Fixes: 498b98e93900 ("soc: qcom: mdt_loader: Support loading non-split images") Signed-off-by: Shawn Guo --- Changes for v2: - Update commit log based on the great disscussion with Marijn and Bjorn. drivers/soc/qcom/mdt_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Marijn Suijten diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index eba7f76f9d61..6034cd8992b0 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -98,7 +98,7 @@ 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)