From patchwork Fri Dec 13 05:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 181520 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp176191ile; Thu, 12 Dec 2019 21:15:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyAG5gs77WAa5YJtUM92RbpfVcSEkiqu4I4XFY2aR4Z5ulqNo0Em1Esh+NfKYoMYjWfFLEF X-Received: by 2002:a05:6830:120c:: with SMTP id r12mr12898939otp.327.1576214133009; Thu, 12 Dec 2019 21:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576214133; cv=none; d=google.com; s=arc-20160816; b=ZcgzkseVJkl2PbO5k06c/tmqBIPTxkoKT1TY4V9Fn3q26BcNcHaNbkZqh+aJ6/qBk7 NVETUUiTkYXCUWaOJmQszY4NsBSqqCEmJy5stb/fXK+GQHwj1qcwD2rDH6NR3vycK+p4 4HQYIvKLnDQMJF7BY2iVl2M9h0YtLTDi77qeTaPGyAvJGpwT8mDCsB+5RM7rg7NvNNlb XDzPEhJ70zGngTWl5RMLQlN/WaYjrQDP7uOa5Ahp8anzVXgHEsiwScmuWl3KlUiGQjMK lyeKnvFmVgs5lMnlTzfKBInbNQXEam8sjJTVVCVFRat+NPhOF4c4S0rJSbNtojknEpBQ 8CEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sbtRF5Z/ahvzn5o3IzEj07oxQoWzK/KEBcmikz1JbyE=; b=pEBE3fktV74TK3lM6CV1MYDtWAO3ANMcJxo8KHeUN+DoljPZp+Xrq49p40as+uSKj5 JJND60yt6bBqLH7k/4Do+6S7uCbxdtVA8CDoqfh4b0BrRCCk2aqt2pqnZsNr+OuXJzEA opwrFQ67FAdDfUJ83iLqFJJDIXliXqJ4FF1pcoJnbHmIugrmKrl93AgSYXofyDDvscAR lw8uuO4wFtZAJfCDBV97Zn1wzGGo4CBBkLYrAZWUkvKsxh+mSkBenl7doGINtAkPTWHh CjdAYeWY3NOiSJOp8Plwk4moezzt00JhbCHaj5w34YB1WbWQcpdR1UagPjPq+JyTRfQd G1hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qv/jt8f4"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id z8si4534265oto.36.2019.12.12.21.15.32; Thu, 12 Dec 2019 21:15:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b="qv/jt8f4"; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 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 S1728180AbfLMFPb (ORCPT + 15 others); Fri, 13 Dec 2019 00:15:31 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36622 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725912AbfLMFPb (ORCPT ); Fri, 13 Dec 2019 00:15:31 -0500 Received: by mail-pf1-f194.google.com with SMTP id x184so835743pfb.3 for ; Thu, 12 Dec 2019 21:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sbtRF5Z/ahvzn5o3IzEj07oxQoWzK/KEBcmikz1JbyE=; b=qv/jt8f43rEwLuK1BFTbLJ6+7o81AFjtWlf+XZM7xlZwBjU9EBUULp3DRdj9EJK9Z9 06ikCa5UM08SQuYnvHmK3+sw7A3H0LV3O/tK+l1pt8qZJYECSb/CVB0NMhXu0LpRjges Hcp/zUrZbNDCpH6zzp9K09QekhnyybPQDiFpT7araq+kSEDdK8EOM88EGRVpRJ3Hesgj /UqtSjB+11wk8uJHnMWKAemhrN7TRxTO7LFDtAGjgcKmfKAo3MM2wmue9hj1BJiZJSX0 UZ43UUdDl5X5zkpgXboMTGLHNoI6D2jxZqAyPltbbrdmSsghbopCvYRSdYaII7uzpAk1 brfQ== 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:mime-version :content-transfer-encoding; bh=sbtRF5Z/ahvzn5o3IzEj07oxQoWzK/KEBcmikz1JbyE=; b=OPCsr+5nJ3Nj2Zc5wRh+o7RkgpHS0qYVJi+HuPFujMfm2675Z00wRzgUZ4i2WoNkMd yZygVUQS88/aXNtxg2TgLQxYE0DF3N/XqCgaAyZPq6zh1rl6XDIRg4PmY2PqJP3K0qi7 Hfn4NScaU8pxycsEoBlu2dBI6Mcml0qpmMWEVfqyYZd9Hrw0ExYyoydFyIW7Bh8he7Iu yObfU+BVpjw/SMbP/hvtjGZ0jcw8tsRjM00Hug8Q1OjOz80xb0t0z8omqMoWeWPdyvwr jqNjQqJg1j0BAsUVApqgabwFXa7YoSacK5pRkbLV69hwrIcQgDcceI62CAbWw0JV/ooF PRPw== X-Gm-Message-State: APjAAAXLnFC4KJ95400iCxKxFWXbUoCr59WpxG3DP2+xydsHFkTsqTgL +vCFCdboxbSITImfXxB6LI5ZWg== X-Received: by 2002:a63:134e:: with SMTP id 14mr15121570pgt.115.1576214130322; Thu, 12 Dec 2019 21:15:30 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id s15sm8475987pgq.4.2019.12.12.21.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 21:15:29 -0800 (PST) From: Bjorn Andersson To: Andy Gross , Bjorn Andersson , Luca Weiss Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: qcom: mdt_loader: Support firmware without hash segment Date: Thu, 12 Dec 2019 21:15:25 -0800 Message-Id: <20191213051525.3688682-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org At least some of the firmware found on 8974 does not follow the typical scheme of having a non-loadable hash segment directly following the ELF header, in the modem mdt. Rather than failing the read of metadata, fall back to passing back a copy of the full first firmware file and let the metadata validator do its job. Signed-off-by: Bjorn Andersson --- drivers/soc/qcom/mdt_loader.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.23.0 diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 24cd193dec55..dd8a27f866db 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -99,7 +99,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len) return ERR_PTR(-EINVAL); if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD) - return ERR_PTR(-EINVAL); + goto return_fw_copy; if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH) return ERR_PTR(-EINVAL); @@ -123,6 +123,18 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len) *data_len = ehdr_size + hash_size; return data; + +return_fw_copy: + /* + * Some older firmware (e.g. on 8974) doesn't have a hash segment + * following the ELF header, just return a verbatim copy of the + * fw->data and let the metadata authenticator consume what it needs. + */ + data = kmemdup(fw->data, fw->size, GFP_KERNEL); + if (!data) + return ERR_PTR(-ENOMEM); + *data_len = fw->size; + return data; } EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);