From patchwork Fri Mar 24 19:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaying Liang X-Patchwork-Id: 9643895 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 90013601E9 for ; Fri, 24 Mar 2017 19:30:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CBC927D16 for ; Fri, 24 Mar 2017 19:30:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 717C727F07; Fri, 24 Mar 2017 19:30:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF0F27D16 for ; Fri, 24 Mar 2017 19:30:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967070AbdCXTaI (ORCPT ); Fri, 24 Mar 2017 15:30:08 -0400 Received: from mail-by2nam01on0089.outbound.protection.outlook.com ([104.47.34.89]:22859 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966966AbdCXT34 (ORCPT ); Fri, 24 Mar 2017 15:29:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/YUOs10biZYpve2XcnzbKBwrVuZ8SJrAsD7Xeo849Ic=; b=d6q+nMKy/qZrlFtG3jMJpLvNfOha8w7xkbnx/IvU3IarVR3Ht/Tm++QbMt9WZ+cLfMdjecRaQJm7TZLRdogcEEhPgYq5MhFnQOM4HHz5EgaCEzc0tuCi/APpQeOzyfwj8Loc7yT+Uxmo093vxJHdT6KrgC51oPQGPuRRrKawBwI= Received: from BN6PR02CA0030.namprd02.prod.outlook.com (10.173.146.144) by SN1PR02MB1390.namprd02.prod.outlook.com (10.162.0.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Fri, 24 Mar 2017 19:29:49 +0000 Received: from CY1NAM02FT030.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::207) by BN6PR02CA0030.outlook.office365.com (2603:10b6:404:5f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.991.14 via Frontend Transport; Fri, 24 Mar 2017 19:29:49 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by CY1NAM02FT030.mail.protection.outlook.com (10.152.75.163) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.977.7 via Frontend Transport; Fri, 24 Mar 2017 19:29:48 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1crUuB-0006J1-OI; Fri, 24 Mar 2017 12:29:47 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1crUuB-0002kt-K7; Fri, 24 Mar 2017 12:29:47 -0700 Received: from xsj-pvapsmtp01 (mailhost.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id v2OJTjUL022941; Fri, 24 Mar 2017 12:29:45 -0700 Received: from [172.19.2.167] (helo=xsjjliang50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1crUu9-0002jg-Dw; Fri, 24 Mar 2017 12:29:45 -0700 From: Wendy Liang To: CC: , , "Wendy Liang" , Wendy Liang , Michal Simek Subject: [RFC LINUX PATCH 09/19] remoteproc: check firmware checksum in rproc_is_running_fw() Date: Fri, 24 Mar 2017 12:22:25 -0700 Message-ID: <1490383355-23176-10-git-send-email-jliang@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490383355-23176-1-git-send-email-jliang@xilinx.com> References: <1490383355-23176-1-git-send-email-jliang@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.1.0.1062-22962.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(39450400003)(39410400002)(39840400002)(39850400002)(2980300002)(438002)(189002)(199003)(9170700003)(106466001)(189998001)(38730400002)(77096006)(110136004)(50986999)(107886003)(36386004)(33646002)(47776003)(2351001)(48376002)(5660300001)(36756003)(76176999)(50466002)(305945005)(356003)(81166006)(9786002)(4326008)(54906002)(5003940100001)(2950100002)(50226002)(6916009)(8936002)(8676002)(2906002)(6666003)(107986001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR02MB1390; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02FT030; 1:CYKSahDqpip/dp7VzjU9XUGcVFsSGmXZqasbTykbvq7JPkGMhXO/qZkbJ+PEWKIfUbHmeXVD4oG3K39GG1sbkIx+IlL7aR2IUrIti2k88Avdotlo3QkOMgjhpAxr3IX/J5qxtzSUsysdM1rTuKOeqZ0q7UyTE2EpPw1WgTHJcVuaL2uyaJcYyUH75KOIAJb9NDaf45ekK//aAz2O5eLAjbpaYlxYBuJdPhZAb1TqQn5IoEQ6CUuVt3PfXNhF4LyR/bfBOp6eIFfzEbaG2dHNfkAYCBR/apoCqdwD8V8hvQwwkqe5NgiTl08Pvpmi7QWiEMVjqNdibJBvGncldz/WAqg8ArtIVxB/KIwFtWdclU0TRCuPvlol3ZqDyuvbu4WmAeWPnS8CEtzX7PEjGuDw8BpPulvMklqlkSh4MmlYL2R+RPmijT6rhzihrdcbiA/LEASpmT2WYBNfNQJGec0AU7Rg61xnzRNwX7Z/JE2egejyFbofHl6Qsm3a+mLftDoAyojw2HSi9Ep0u71utCl/rTtqV/DSsS9s3ziE6MRZAjFYNLZdoWevNbLD6xCczHDC59nnHrMiFZDGjj3gYF1aDQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 66de6e3e-9a26-4980-2bbd-08d472ec22eb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075); SRVR:SN1PR02MB1390; X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1390; 3:125SxEXbTqGnJvB4ONOlVLhEEkRwIzLAJ7KMCvg+It5vy5eWU+MSZHoT0j6jWJhX8JlO/I7gJJHzVBRXxWf6wE03yL+weWlrul+k278h5rTb8BLkWeSoz6e0sFGryZzmz6wYC9/ZkQzuU7ADd/FDdhHyUC9hRnZzGiUNqw6IQZJyoQ6D2JLGVaDfiZ6t2NV6/E3/yOpVtjQCXmXMcjIvOSI8V0udpWfJqll/x626YyS0TtldiGSNdoD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V4/o+B4+hE7rbn3KroqgMGAZLdzLKtdGttGkn6hYPxPamLft6EgJ3UMGmXJmTHG0aXEiKl6uBtqUFJAokvdsauDPx8nygDrmUJfQU97y+nR7OhAN8G6rYF2NlGVErnKsxVFLBYRdqpVnXy1MIctXd35Ii5AYTIhDJWAF6Cv5c7cxQ6L2Nxseh3heCSVwH/NnevnV9gWm9avcg1SKUAhBpTz1VSyfc8pN6jJcapH7TNokNH7QPuaS/CGbpj/eEAK39RJE0owEqABC7AC6a4fJNYq/IvrK2pcZLKADiYla+QDiVls1MbV5AikzmbjOU2pKRlSUA0+kJ13Vlofh5R60UHnNkgmjRCp2Fy0nqkrOH/uj4UQH8QivXQsFX+L2JGP0o6JOsEBPlMacvIP3t6AZriSU8sbxr5s9Arcnj9x8DCN9luvSswr+0c X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13017025)(5005006)(13015025)(13024025)(8121501046)(13023025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123558025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:SN1PR02MB1390; BCL:0; PCL:0; RULEID:; SRVR:SN1PR02MB1390; X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1390; 4:1nUkfQK3GcUYQQZyygN0s4ZYkSuaOdHSN7EO8pvyw2Gt0VwF+4HtyP2xR2ep6Ajk+ox+5K42H9kEx61KAhdVlPrw2P9arJgeoWERS4u+9XhjWrBDdrDw/duLNnXr86BFfFVSjhBZiXTczqZ9UgR423g2vIfPB/Xtw1uTW2v3IkTVBaJAdinn7ftA/Z6hRRclloVGXUcDjmJaz/d2AqmnMEFsLaI44KVTu7FaOo8FOmeyROTZMZ9tS4WaMrmt15lfZN5ELdDjLlgy+ovVEHMVboTTHylj98Hzmc+U5WuC8s2elG4SL+GcSaCHoWZxSwlnU3pePQN7x9F9SY4jSU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KxcwutM4PdlN/qifq7i1RhNswAW6W3tWAufuMUrUf6I55bmLoOLmqXTc4b81TTBwrhcScOrRjtvZxAW1gnxp0tMFbYqcwdI0v1+T79sua38oYNEr9trje4pMPw0HL9mbklk9SCULTf1uSA8JB3F6732NRppnrYn6IiAGcEYQzLc=; 5:K8LvAXiaGFe8XDnx2mfAOM/GMAiXsrEwEqgpYFb+vG1I5m5gBdynHV+tLs6lzh3zTrb+G7S/s8BKk97kY2F5JXxZ8JkjYenDegyD3l3xAmABd06ufoGRkJCtwLs96BLsh87lP54fCvZX8UY5+tf7ZQ==; 24:Zzz3P2nc79BdbIPZNi/ObfTAUr3G82YtRR4+cWK21tPzljwjVbE/YZrJFLWc8lRpdjG5zvzfE2Xkkb2UDznySi5zJY9/+PnWF1byjFnb9Ck= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR02MB1390; 7:AmnKTMuDG5N+tzWXX+xaTQHTh6dBV8oJjT98iItu1SXqfMwY5I1ocwlQxAt7LOsLIYUINm+sWA7cr8KJQX8tDQjuZEMPWRDgZ78opqHfL4XyVcgIv9cHR9bDtEHCWg3Zg7r7Hcr0dRhIbga6RJh6L7wVZbUh+t86nQyJNJYNPfhpiBxroAz0Zxy0ONg9/1pLKjQaXcLtFowfWHDzj+KEE9m0HHIkDIHnyc3VtbbECwpiJ7J2AmJNPRIQmR76+i98+E0Vez1pvLv44oWRTY25KKHmVSg4EEN+1W7A7c9tiNrhlhy6AIvGb8kIBCaOpj6cL74q4wH9PrIbqfrFoQS1dA== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2017 19:29:48.7268 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB1390 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wendy Liang In rproc_is_running_fw() function, set the firmware checksum in resource in the resource table and compared it with the one in the loaded resource table. If the firmware checksum in the loaded resource table matches the one calculated with the firmware, the remote is running with the expected firmware. Signed-off-by: Wendy Liang Signed-off-by: Michal Simek --- drivers/remoteproc/remoteproc_core.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 447c28b..e4fb289 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -956,10 +956,33 @@ struct fw_rsc_fw_chksum *rproc_handle_fw_chksum(struct rproc *rproc, */ static bool rproc_is_running_fw(struct rproc *rproc, const struct firmware *fw) { - (void)rproc; - (void) fw; + struct resource_table *loaded_table; + struct fw_rsc_fw_chksum *rsc, *loaded_rsc; + int rsc_fw_chksum_offset; - return false; + rsc = rproc_handle_fw_chksum(rproc, fw, &rsc_fw_chksum_offset); + if (!rsc) + return false; + + if (!rproc_is_running(rproc)) + return false; + + /* look for the loaded resource table */ + loaded_table = rproc_find_loaded_rsc_table(rproc, fw); + if (!loaded_table) + return false; + + loaded_rsc = (void *)loaded_table + rsc_fw_chksum_offset; + if (!loaded_rsc->algo || !loaded_rsc->chksum) + return false; + + if (strncmp(rsc->algo, loaded_rsc->algo, strlen(rsc->algo))) + return false; + + if (memcmp(rsc->chksum, loaded_rsc->chksum, sizeof(rsc->chksum))) + return false; + + return true; } /*