Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1615021pxb; Mon, 11 Oct 2021 09:31:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqWIHUzSy07VF8HvGfzZdmeqvtdyS1Kt31S/RyX9yhgd8ZtCXpMfemx+qVGUt0KIEROjoX X-Received: by 2002:aa7:9735:0:b0:44c:619f:29fc with SMTP id k21-20020aa79735000000b0044c619f29fcmr26365301pfg.79.1633969909814; Mon, 11 Oct 2021 09:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969909; cv=none; d=google.com; s=arc-20160816; b=Y/V6BJKZnjKR2YcxKRiK0/C+ieGhU+MSLcq3yUqGOQoZeWGIbAbdS4MkM9SoHikOok q2j/pR37vRNeUXzHo7r1vMEAlbDIgyzCVWkwQQy4qjUoNKLKj7rb+kvUCJgnTfRSsagf qDaeibBvedul+BVNyIJcyUdgD3yxQEn3qIFtb0/juTRu9x1EFFxvyKl0DelBjNTzQEnX IAQ/XnEuP6H6qw853WEtaWYiHSWpv0CT1kapVgHSJI4fm3rXrcHtTSem8Uf+ApyyDVaQ Ds3YcEqJxJuRwIEZYuQmpTsWzgligPuFWmY02VZJB8l9EIxZ7tTbrh2fSFdqWkdjHvxL VoVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=55OBnEyr6APERzhIulQ+OwuOO3gX/H/0j2j5ZkCt91E=; b=SSdfiwQqmb0BXtv3HO+UHXYYI0PRRvcOwqvcHYxwnVg8wjMWzEBjOap9T0BDy77n6q iiTFMqsDo3/VKhzf+aHeYmiDmfiRHh8MYtoHNV3xUexrnZlL/2hWtXId7svJ077T4Mou a5Wcg6Cj8oVV/eHgHkvgAWRWSR3mfCMSjN0XsaHUoLTvgjZ+mT6khtgMuP3nh1VANp/r 7FnG6URZVBW410AGLM7wTMzQdd0XCA4UpAsh7e14JzfHnFCMf+WPcIGwLBKGA4j7rsMi px0WDgjTBzVrNss7QOCM7SBTxL06f3FvL1WpWGgOsdQSxsW7LnSGvrpUDL+7dp/lReuR oHeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iKuDDeIK; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si10950109pgr.291.2021.10.11.09.31.37; Mon, 11 Oct 2021 09:31:49 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=iKuDDeIK; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237589AbhJKNzx (ORCPT + 99 others); Mon, 11 Oct 2021 09:55:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:39898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237403AbhJKNxt (ORCPT ); Mon, 11 Oct 2021 09:53:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD89560E8B; Mon, 11 Oct 2021 13:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960309; bh=KatlpQaVe2Tnj8+hKldMj+ZI/hitDdpstM/2v3SlcLM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKuDDeIKAvFvidDG+WYEXnIquVBNsvKxX+LXu5HWQXB/o96vRiXjB2Iwj/H5+e/gw npFPrKJpDHCXA4+bxeIP5crTFEs35McKleOMWo+DNnd+8yIxaL0b/qm2NzUNKeNg9I cb+zDyZLfzihZRWYnOSKi05JbbDB7/ZHz6O/rOq8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shawn Guo , Marijn Suijten , Bjorn Andersson , Sasha Levin Subject: [PATCH 5.10 25/83] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment Date: Mon, 11 Oct 2021 15:45:45 +0200 Message-Id: <20211011134509.230620469@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shawn Guo [ Upstream commit 833d51d7c66d6708abbc02398892b96b950167b9 ] 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 Reviewed-by: Marijn Suijten Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20210828070202.7033-1-shawn.guo@linaro.org Signed-off-by: Sasha Levin --- drivers/soc/qcom/mdt_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- 2.33.0