From patchwork Wed May 2 01:10:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134813 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp125617lji; Tue, 1 May 2018 18:13:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+nJtHAo6izJOOBzRoY+KHMOvbQH4EZlP/5M4Mg+Z2cNcPHYPrfAQRsIVVv8ur5pLYSZqX X-Received: by 2002:a17:902:b483:: with SMTP id y3-v6mr17817981plr.157.1525223593403; Tue, 01 May 2018 18:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223593; cv=none; d=google.com; s=arc-20160816; b=FTChq3mdpyw3DMVRSx71JKdgcrX4mRjfri86WpwRH2PrBqOYyMOKpaijZunV1smVNB KvKfknwyzB2kwKdG2emZcJ+fRo/gNH+TZ5SXTlpzpdhHFaubSj3TWrUszkIxhmZvcgeb bQ32MJeOW9YNzI4TDq6tlO7iSWNtU0fYG4hCJNydDT5WIdB6m1GGXlIIdRgdLORitCRC Q427JZy3ugf14M5fpYT3dAKNE9E85/bFsQBkhCR6CF+Lkxy20O32LCoW0fBXEg2jl3zE VwPfS3tZZZLKZlDDAdS9bvlESZoIhnyRW9anqZuGkjH5Qkl2BvrbAhJqeCESA/Gw4CQx Xm9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Z9nNmN0dv5c10M+05z0AlN8IcSB+hb1/CDmVP0IqYnQ=; b=00p5TYR3exmRgv6r0Ndt1kavUqz2oTO+f3FJIcFxqG4PhYT4k62uU0eKUROZcWKbgu zfOipXeJtDXBf31LXIWu5yZws2JWC73t5767Yu0I7wXU/wx5cR5LQGJm8kVTFajm9YBI ZYvdPVGhh50HQJj0rXprxNjgpv4x8Ip6EpT1L6m3O0tQMZ9nF03shWR7DTYlP4YvG11P f7P5jjhGwTdxFX873VwaW9lklXxo18hSiQISYBXt7h78+dL4XIab2T5KKl8vmIK3Scau 73mmP+lg0aAcudIrP8LVLzZR6ba5lwgtlzJCBlOk5fTRWvlTTnqxA4g+WABK3OGbQlaq 0blw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OaDVbyvI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id w130si10551532pfd.169.2018.05.01.18.13.13; Tue, 01 May 2018 18:13:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=OaDVbyvI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751635AbeEBBNK (ORCPT + 29 others); Tue, 1 May 2018 21:13:10 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:37747 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbeEBBK3 (ORCPT ); Tue, 1 May 2018 21:10:29 -0400 Received: by mail-io0-f196.google.com with SMTP id e20-v6so15588013iof.4 for ; Tue, 01 May 2018 18:10:28 -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:in-reply-to:references; bh=Z9nNmN0dv5c10M+05z0AlN8IcSB+hb1/CDmVP0IqYnQ=; b=OaDVbyvI14PxwZg/AUwTWuGaHKNFvr7TOD2MWulHKNmusqyTm6HqGG+oMkMDsroxE4 OuA67B05PMTk3mBo5eKpJKV/RC5iQGHTI+bSntj6UqwtcflZK3sxY72ZzMou+Gz4ohEy Ws7jaacyBFeexClq4yYYsayYTDUTprex1XxJw= 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:in-reply-to :references; bh=Z9nNmN0dv5c10M+05z0AlN8IcSB+hb1/CDmVP0IqYnQ=; b=iyg8zHPezuJKLmDrBY6m51m+u+5ffgZnyyRp/XFHkMk2RrvMax/rHTGVB+YeAu5S8Y Py+Op3VzQXXXgXZbsRVSMYfHMKUy35hKBe45TBESVPbeUXCwXU7ixUcHDIxlnVF2V550 3XDUZE9UDJ1kUodmPa0YN5BN7UJGx5jD4hFLcipHVTr+6YK+nZW9JP0f8+Zdisx7g7CF I2AjLPwnjXRAT3DP0mlBpUqoo8s2V6O1IUtANFlxHh7Qj5u5lURu9FQKYWuQXrWi9DMB QfPGscIjxv51itpdjQH3hY+cUuQrw0CK5YgriD+edvGNiyfxBfk1wQO8fkQG9zcOSkFP idYg== X-Gm-Message-State: ALQs6tDuomv8z6alWQY2rC2atm2uLUJiYancURU537JeXSituJAdeFLS eQRYP/fbrDfILpQr8zX6f1wSyQ== X-Received: by 2002:a6b:7c9:: with SMTP id g70-v6mr19330913ioi.82.1525223428349; Tue, 01 May 2018 18:10:28 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:27 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/12] soc: qcom: smem: rename variable in qcom_smem_get_global() Date: Tue, 1 May 2018 20:10:08 -0500 Message-Id: <20180502011019.22812-2-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename the variable "area" to be "region" in qcom_smem_get_global(), so its name better matches its type. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 70b2ee80d6bd..c46bb43c0f3d 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -277,7 +277,7 @@ struct qcom_smem { u32 item_count; unsigned num_regions; - struct smem_region regions[0]; + struct smem_region regions[]; }; static void * @@ -494,7 +494,7 @@ static void *qcom_smem_get_global(struct qcom_smem *smem, size_t *size) { struct smem_header *header; - struct smem_region *area; + struct smem_region *region; struct smem_global_entry *entry; u32 aux_base; unsigned i; @@ -507,12 +507,12 @@ static void *qcom_smem_get_global(struct qcom_smem *smem, aux_base = le32_to_cpu(entry->aux_base) & AUX_BASE_MASK; for (i = 0; i < smem->num_regions; i++) { - area = &smem->regions[i]; + region = &smem->regions[i]; - if (area->aux_base == aux_base || !aux_base) { + if (region->aux_base == aux_base || !aux_base) { if (size != NULL) *size = le32_to_cpu(entry->size); - return area->virt_base + le32_to_cpu(entry->offset); + return region->virt_base + le32_to_cpu(entry->offset); } } From patchwork Wed May 2 01:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134802 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp123890lji; Tue, 1 May 2018 18:10:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpi3bBwmAYcQNV0Kx7dYjubIeR3cREzqyaFh4nOq2WYlurAsDppmp0uz396B9S9mE/FbIAw X-Received: by 2002:a63:b306:: with SMTP id i6-v6mr14488527pgf.434.1525223441376; Tue, 01 May 2018 18:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223441; cv=none; d=google.com; s=arc-20160816; b=G9t2tj2RTQT2TDkq5ByaBZ13E0Bhm7mlQ3yu3oxMWw2B2/dfrm7Ffi6OZW5LnR/0JR +NECeSbHFLP0BgmJ742iS0vguR9N0J5biVk2GB4d8F1DsDjqHGTiQpvjhgmExLqhJzvQ DXtIpoRRovKbrFS7JDJeg4WE/33UqooEVr7A7Yw1B8DycSJyUZVIM0uJN5xFUNgWP6KE gNbL4QhRywVKmMo5AZNcq0qTaNwcQTwhG5osU2AXAJ+3/xLZQWhNXHmEj+VYIQMST7g9 wgM14Q/vwrZRBA/8kxcXfS+Ufx5zDG/wrWn5lJkB2njqB4tFHgwXsWU84Pin/lMdESS9 XK3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=rX1UnxpULN7ZZ3pl91R8dPkSO2aIpBlQ6GcohoUleidMbU63mx07vcruGqJXymREuk 5XPOYNw4LQ6qbzeic5LFxYQuu1VK1sM0DwoxmZqJCE4OyBRXczYR/VMoHxoFelMw0zwf /4rxrQ0ocye3SpnJAF7g4wrkTkV0UGz0UCrMqiMx1Y0+tcfc1DDYd0K76+COqCFeWjm2 eLAVq4ZUvM694Lei0M4qHAEa7VV/GMvf9/cgxkWD+oV3p3OmJI2GgMZe6aikNXPE3D/c 115mqqZBkQt76rLRaoPG3S2BRhhObWfgHYrVJZDM9sufVrwMSF/SI3CBkeRttaC4wdWf KDGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a3V2Pnt8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si3718178pgu.27.2018.05.01.18.10.41; Tue, 01 May 2018 18:10:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=a3V2Pnt8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751324AbeEBBKi (ORCPT + 29 others); Tue, 1 May 2018 21:10:38 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:40212 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbeEBBKb (ORCPT ); Tue, 1 May 2018 21:10:31 -0400 Received: by mail-io0-f196.google.com with SMTP id g14-v6so11899680ioc.7 for ; Tue, 01 May 2018 18:10:31 -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:in-reply-to:references; bh=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=a3V2Pnt8jbYM7T57T8o9IeX5v7VwHeev3soVnvqOYborpb9RNTuFw+ubLc/s7HpTQ2 XLJl1VvW8a1GbKeUum/DPh+A/FpX/ILnI6yrSW97oIxv/SwzE3/bnK1qmlr1kn7HdsZu x6SkIjinZRgzkJCwAbr2WUYrPcJl0XZyva14Y= 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:in-reply-to :references; bh=kq6CRR13g0ZQDxfwlHNYxxG+y+NU/bsxsrEwj27VIMM=; b=fKdJWmnyodAGMsEIMQHkuE78uwV6Es5yrjQlAauV2RrAkr4PMGJyYSocslzXKSuZf0 7ex8wS2lc5cDcUdo+fzYZlHxihlMXamkNzPcxiRQnx5X/2gDTwqIcp0+dJnGEd/+BeIY eRfiCNQjV2ZlPM7NAKTryoND17X3YjIoFNbpJ6y1rMo+QdyFTqLOx2XtJ0gRvmArAxNi pWDnBTigpeqMxb8YZdarog8OKPBMPfgOFWGD2um+l1YfMkzXGxiop8VR8ZZpmrlI8+Gi GpO8UfillHqRZFMFDjSB7tyAlFezGfjFjxVcjUjtElAUOWiDmOozOXB/rgwJbIOq4zos KT+Q== X-Gm-Message-State: ALQs6tAyeG3o2sILyxHVHREc2Gu0lEYZwsKXxCRMxPozx2r1E8GM6K5z 3Gpr4Y0dY1bTLaNZtNjYpGtbWQ== X-Received: by 2002:a6b:d404:: with SMTP id l4-v6mr19011070iog.37.1525223430686; Tue, 01 May 2018 18:10:30 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:30 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/12] soc: qcom: smem: always ignore partitions with 0 offset or size Date: Tue, 1 May 2018 20:10:10 -0500 Message-Id: <20180502011019.22812-4-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In qcom_smem_enumerate_partitions(), any partition table entry having a zero offset or size field is ignored. Move those checks earlier in the loop, because there's no sense in examining the host fields for those entries. Add the same checks in qcom_smem_set_global_partition(), so the scan for the global partition skips over these invalid entries. This allows a later check for zero size or offset once the global entry is found to be eliminated. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index d8008bf480a4..83ba549cfea0 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -742,9 +742,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { found = true; break; @@ -756,11 +760,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (!le32_to_cpu(entry->offset) || !le32_to_cpu(entry->size)) { - dev_err(smem->dev, "Invalid entry for global partition\n"); - return -EINVAL; - } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); host0 = le16_to_cpu(header->host0); host1 = le16_to_cpu(header->host1); @@ -809,18 +808,16 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 != local_host && host1 != local_host) continue; - if (!le32_to_cpu(entry->offset)) - continue; - - if (!le32_to_cpu(entry->size)) - continue; - if (host0 == local_host) remote_host = host1; else From patchwork Wed May 2 01:10:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134803 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp123963lji; Tue, 1 May 2018 18:10:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsyk44QB+/ZaO2Rb1WE2ArFYbPvwbkFo6zDu1wWn7o9JYqEqGfc3/EcdUNIIrkWFvtzR9J X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr16728926plp.375.1525223449439; Tue, 01 May 2018 18:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223449; cv=none; d=google.com; s=arc-20160816; b=s91NG9wTqNjVREyvCwNHLo5Cjf8g6HSZlSpfa57D3sN20Vv0WGZIbOzwLdq4lqlfi2 YVUuutnssQ+hQpVZQ9V1h+Fa9gmS9qGeclqYThjPKU24v5fTxrHNHLf142+f8s0+AtMW G8xU8V1Jz7LvzZVG7Tab1MKA1a+jkbaCI/tnvXG1tz7Az+CVoF6Du4E1e17KQq9463bX sdHar3NvrlKEhe1zbyvYfgBGJ9C+LcaAgrTOox8i80KnuN/BjjFn5c21VlY3zvnT9b3D 5YwsZVnb0LKyjYjLFpO8WsbaWhYTIGZscsVPefL90fNAjks8q12WwUFo7qAPLKaewkZH ONeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=fuLD3cG8NbFXLM2nfOqCxwmWEGM/nPa2Rcq/dZj1L+0=; b=Dran0DF4qGlmnXACwFUqq2JFDvVgiZow0MacsDO/4yXyHKuh/yrPjjyQnCBhU+mR2G 4rIjzhganKuPb1Dnl2hwxh6z0nA3hmIloeLtm4Cmo6ts1l8EtlTtoKQYJB/sxlQvFYug NkT0tfb6WJEfET55UhTDvzLd6GzG8+yOg+vEt4Jd77zrOJSXovlOr+m1KPeSB/fwZ8IF 3VGqqBV9Pzgq4ANGUWwuOWyo45Nnca5hy0niyaFsf7J+spWpbRMvXbhJUKP4xwcm6qrb XT3lfYVVajaR8NTB6QMeWTj0DTwvqLirR0mjWyAalhiRbi3zu0yCxQfBCi8EMh6NJ219 ytbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wsk1SvDx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g10-v6si10789274plb.272.2018.05.01.18.10.49; Tue, 01 May 2018 18:10:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=Wsk1SvDx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751382AbeEBBKm (ORCPT + 29 others); Tue, 1 May 2018 21:10:42 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:36624 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178AbeEBBKc (ORCPT ); Tue, 1 May 2018 21:10:32 -0400 Received: by mail-io0-f194.google.com with SMTP id d73-v6so15595213iog.3 for ; Tue, 01 May 2018 18:10:32 -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:in-reply-to:references; bh=fuLD3cG8NbFXLM2nfOqCxwmWEGM/nPa2Rcq/dZj1L+0=; b=Wsk1SvDx1lOaM/DuhW4RhS3oU2H7DzMFObdM7KxBOmTbnbmksWUI5fsJq/GQ4llJvv z4Wzb7YbDnEDlmPvH0kCiM7YLpaZK8mKtJI2XbVzJlOs1yY27x3/WDoZwKWx8lfF4He0 HM3xmvEdRj0mDxhqvUtLaGNPch5nOESlex7vY= 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:in-reply-to :references; bh=fuLD3cG8NbFXLM2nfOqCxwmWEGM/nPa2Rcq/dZj1L+0=; b=F22HeKJFYH4ULrcAK7PqGLOTmcdfcuf5xOGwsQfPNLFfq+lmEgIF/N3Z3WHUitEunV epsq6jhmbREMpd6xXDyETc4OvOIbBrizgVOPpk04FYPw/6ob5LYOymD3UfKKXwfMC609 a058dVd7T+scRGHrIE8USbQZBe7eh1Udg09SztvNRIe99Nk8gpAyEiQVucb9tVTDuE/h ykZJ0JzZHpFLqNmQWz3BjK/IAL7NuyIGUx4V2L6Sjx0Mh+vI+zTDHCMZDXmnsVpmoxsL WapKjZUbMrugBycDbhNJlegSFypIu5teQT1kYL03iVWAxUg4+O0oVZppb1YR5J4AtELI ZyZA== X-Gm-Message-State: ALQs6tDVA5wzGxVHCdtD9+PunWhdqblT3ZVa7rWn/U0+xVq5Zw9+H+wg seW79BLgJYxlGQ6QZTBhreG2Gg== X-Received: by 2002:a6b:9107:: with SMTP id t7-v6mr19661369iod.32.1525223431660; Tue, 01 May 2018 18:10:31 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:31 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] soc: qcom: smem: small refactor in qcom_smem_enumerate_partitions() Date: Tue, 1 May 2018 20:10:11 -0500 Message-Id: <20180502011019.22812-5-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Combine the code that checks whether a partition table entry is associated with the local host with the assignment of the remote host id value. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 83ba549cfea0..5d3ed510e54b 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -815,13 +815,12 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 != local_host && host1 != local_host) - continue; - if (host0 == local_host) remote_host = host1; - else + else if (host1 == local_host) remote_host = host0; + else + continue; if (remote_host >= SMEM_HOST_COUNT) { dev_err(smem->dev, From patchwork Wed May 2 01:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134809 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124802lji; Tue, 1 May 2018 18:12:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrclV+abdTwCrv2SPGXoMTw3fY+ux1++8KBY4Lhxuefxnsf5O6V4+kcYnn3Cf+OMenVjLZD X-Received: by 10.98.242.74 with SMTP id y10mr17582497pfl.75.1525223523784; Tue, 01 May 2018 18:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223523; cv=none; d=google.com; s=arc-20160816; b=sReORx59fqFbxpWWTtPB8gCnppnRQh1GiMHC6WFqjMUf/A28QhwNbpQhXgU4a2DeEf zG7DD2vRLtaWMiRgtH3TMR6RnY7Q6zWvovAokjvDLLAfCxXF/hQDQcB2/OxSdNThAg0T 08kZX1BnHRZhOixf2ArafZtS64VsWeA5mljJbf0bG5H8uyHCfMUdTk2fC5YEZfIPDTwK mWhJKW/2IkK7EEI6yqE8nxYRbI11xJGEo4wGyd3QL1rHMtYqeDGJCnjnn6fuc5GOL4Ze IhXnHAM+mLoPYqe96rnTIqbrKfHC/3yo+QKOQ/P6L5+eEN1z2mUcqNAoQHjga2IFOgsJ YXHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EkNWVE78UHIGfw333sUDiOmWxutpxKxppyp0BR+tlNA=; b=Kc6gNRPbhZUF6Cgfzc/umnvzhO6/u9Y46SCrCPdTT6HpX6UHeztf6Y5ksjMtcy4D5N JoekyClndjNKDUMtUdN+Oa+LN7k3QhiUSAD2d67b6BnKnZDPspQk210jGNgURwRdNW37 Jqk7MKjJt7qNrWnkZT3XhKSl95Y4fodTE382hj1B1/HQfxI8QiB9hF5SBdfhJTcwx8tb I6Q3bPF6SePt3Wlbs5e0psFWAX3bORDY2Kkn3EWdBRRTmMxCXTF5+yrG65ONg/bO03WY 4FZ2k2FG2SUzxf/jsfpxIhRA7NH4z6Fyq13qOApNjq+t1S8/FA3apTwkFm7TvYfS05N0 26ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jvKBWBhK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id a92-v6si10794792pla.291.2018.05.01.18.12.03; Tue, 01 May 2018 18:12:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=jvKBWBhK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751521AbeEBBMA (ORCPT + 29 others); Tue, 1 May 2018 21:12:00 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:42386 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbeEBBKg (ORCPT ); Tue, 1 May 2018 21:10:36 -0400 Received: by mail-io0-f196.google.com with SMTP id a10-v6so15576755ioc.9 for ; Tue, 01 May 2018 18:10:36 -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:in-reply-to:references; bh=EkNWVE78UHIGfw333sUDiOmWxutpxKxppyp0BR+tlNA=; b=jvKBWBhKlN55UHYs8BMJXHfHTa9Dkdim4TD2IDwbD7hDCnkRlZzNBKYaluR2RrgEWo C0Xg8KZ2GkMLg2hNIBaLE4FA05tg0lDqaYBMS63T9tuRdDGLjWUoxsWx0+SZw7mi7LzT t3QL+upbPYci3JgIUX0KAVZccUELX9Ez3krAw= 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:in-reply-to :references; bh=EkNWVE78UHIGfw333sUDiOmWxutpxKxppyp0BR+tlNA=; b=EJz9FOpxsmSN5kGXiWwZ9/9E1cRhZ84fFPlESc1ppqVqPonFzDSBpIXVEqJc5OBSGX iCB4zf2TSC0MaEF6kO0QZoIpQC3/Yun177Jw0S0+9vZ4wIPc1MgfCp4f24r8lU2sq/xP Q/+7QNd5xVcKQPB9LMgoc8OVq0Rrfm1T6k7oknGbWfXXjyUM4KxgCeCm0KqsX5FxIjkY KtOIVhi0fQcuB5DpFpwrIclZRLOmTOr4cYdc8XwuRr9XTBvDRi19ZYF84aRkOLLCw5N3 L7VKVJG9aDkiyghOVULLtTUAcrgxme7KiZlOzai/p8V6UGOvSUkmqoD/KnSO1ycL8oc8 dNyw== X-Gm-Message-State: ALQs6tDDJHQIaB+NeGncZtrbl43jvq7uhqzADiHRBJcDFRhSh2XBfDlT e+hd1zJzQN+MJh6iQnep4f0Dig== X-Received: by 2002:a6b:a2d1:: with SMTP id l200-v6mr19371397ioe.166.1525223435581; Tue, 01 May 2018 18:10:35 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:35 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/12] soc: qcom: smem: verify partition header size Date: Tue, 1 May 2018 20:10:15 -0500 Message-Id: <20180502011019.22812-9-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the size in a partition's header structure matches the size in its partition table entry. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index d52a282f7338..f1e6e4609ccb 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -737,6 +737,7 @@ qcom_smem_partition_header(struct qcom_smem *smem, struct smem_ptable_entry *entry) { struct smem_partition_header *header; + u32 size; header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); @@ -747,6 +748,13 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + size = le32_to_cpu(header->size); + if (size != le32_to_cpu(entry->size)) { + dev_err(smem->dev, "bad partition size (%u != %u)\n", + size, le32_to_cpu(entry->size)); + return NULL; + } + return header; } @@ -795,11 +803,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (le32_to_cpu(header->size) != le32_to_cpu(entry->size)) { - dev_err(smem->dev, "Global partition has invalid size\n"); - return -EINVAL; - } - size = le32_to_cpu(header->offset_free_uncached); if (size > le32_to_cpu(header->size)) { dev_err(smem->dev, @@ -868,12 +871,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (le32_to_cpu(header->size) != le32_to_cpu(entry->size)) { - dev_err(smem->dev, - "Partition %d has invalid size\n", i); - return -EINVAL; - } - if (le32_to_cpu(header->offset_free_uncached) > le32_to_cpu(header->size)) { dev_err(smem->dev, "Partition %d has invalid free pointer\n", i); From patchwork Wed May 2 01:10:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134807 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124721lji; Tue, 1 May 2018 18:11:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq7wBuMKFIFYD5IFHuxrdonadXNtpGG36eySCEi7bdgulnrBoa0m28ZQDOKAveFuGrk5T9s X-Received: by 2002:a17:902:6b45:: with SMTP id g5-v6mr3489400plt.67.1525223517584; Tue, 01 May 2018 18:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223517; cv=none; d=google.com; s=arc-20160816; b=Pwh4jjXl2/yiaNlorMhZoO0K8bn+4i+c6V3g8GKuC+jyLMwrMxtesmV4IhJzKm8wxc GLcc5vou3c6Yt42xIq7hCHDT9L2NTpHYGCwMd7wQrhqSxUbC47tiE3oNgr2/YslEQxNG Or7W61v+L1gzhl9jR5HBfEm/liU/cFkUWluKSg8kHo181WrvvG8btXKkwar6TxsqhDO8 zITnkYkWEJMW0rtQXtaBKgdaSSFQIlxrhiChYcnQtkrnXBNGen51CKWEo5L3JBdAQiKb K0L5+8Yl++cgSTP6YLCb5PGH1bCAhBjt8SfC2YsXiTEQFuQ9X1JZH8CTHUC1CumOyuba A2EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=znptUnZx0R3NadRdMSznhIujdZEya1BwEJm1jhWK1Dc=; b=BeFJjx3S88hxw7+s5SeQRet4Ue2Mx4s1v/OPJb5eOfug8tVL7q8i2yf4Hg9Hevf5el As6cpZIpkHJo+0gQotJggt12yUpkegMJhXd1Pxod1NRTgaZlYcdSLGDUgMkcPusXKVF4 ly+6LhzSNZ9x9OqoKtYH20L7J69QQ+MoImlp7xpCPTMqIwt0nIhGaFpN/4b11JhMRKpu lDGyzheZaLyZ2KrlCdYyqt4gmrDZnuBR97KAMnWhDG8B3jbWpkRpqD0SPU4ScBX365lS ku7xY/56Tqx06B7SEickePF3WCMR99McrH4yMzYzyiES2K7bIGiBUpt2TUNaor3QpvI9 Eh1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SWRSZnGh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id z9-v6si4495461plk.94.2018.05.01.18.11.57; Tue, 01 May 2018 18:11:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=SWRSZnGh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751499AbeEBBLy (ORCPT + 29 others); Tue, 1 May 2018 21:11:54 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:40990 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751269AbeEBBKh (ORCPT ); Tue, 1 May 2018 21:10:37 -0400 Received: by mail-io0-f196.google.com with SMTP id e12-v6so15579704iob.8 for ; Tue, 01 May 2018 18:10:36 -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:in-reply-to:references; bh=znptUnZx0R3NadRdMSznhIujdZEya1BwEJm1jhWK1Dc=; b=SWRSZnGhkqlZc8cJP2An+L6lZEUjb6kx7y66u5Hg42X9pO6/F8CFZCUhWdC55Fquky LAjjM0hrDHcIfwCnyzBnxUv+StM7YhX1kWQhroJYUUKv5E9idew+BrrfpRcvDpQJaxNw cEMogZ5eXmdNXbsiuDEAX/aX+o1FS85e19pkk= 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:in-reply-to :references; bh=znptUnZx0R3NadRdMSznhIujdZEya1BwEJm1jhWK1Dc=; b=r2jTq7z+88ST4TOlHwBfY1C59Iuy8aCvGk7EAIKSbDEAWHRfK2tu6Ca8MwNVC49/6M I0iYDU1yFo9f5jRGacsJM6E8vQF4Myp6j737OcNzdliADYJFczPI4lSbsDHkaiWC8P64 5BcjmLV/kBuddiEOl7OYJMPKVCpjk2QxVU9IJ/oRyGlYfFHJb9vZ+7ccmT7tWPPEu3a0 xjMPo0cpsoHIApYNifUSYjx3KUTtgzL0Xn9J8S4Y+tQzTXn7kik903fv+SpWS/AI1+tn XiMzg4oiLDHqtcD1jCukXG35DmTT8z4hZWb1baImT6FNhUfiMu6QTzOaqM2yJ2vTbpy9 kszw== X-Gm-Message-State: ALQs6tCjaFkJXOIonIo4rNy87kByOJuqL+YCnC3UyzBYkYgsUNQ1vWWd uKnofc03+VrjIxCtq/uTeW2+Gg== X-Received: by 2002:a6b:aae0:: with SMTP id g93-v6mr18745669ioj.202.1525223436540; Tue, 01 May 2018 18:10:36 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:36 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/12] soc: qcom: smem: verify partition offset_free_uncached Date: Tue, 1 May 2018 20:10:16 -0500 Message-Id: <20180502011019.22812-10-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the offset_free_uncached field in a partition's header structure does not exceed the partition's size. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index f1e6e4609ccb..7ef415c4d62e 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -755,6 +755,12 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + if (le32_to_cpu(header->offset_free_uncached) > size) { + dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", + le32_to_cpu(header->offset_free_uncached), size); + return NULL; + } + return header; } @@ -763,7 +769,7 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; - u32 host0, host1, size; + u32 host0, host1; bool found = false; int i; @@ -803,13 +809,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - size = le32_to_cpu(header->offset_free_uncached); - if (size > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Global partition has invalid free pointer\n"); - return -EINVAL; - } - smem->global_partition = header; smem->global_cacheline = le32_to_cpu(entry->cacheline); @@ -871,12 +870,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (le32_to_cpu(header->offset_free_uncached) > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Partition %d has invalid free pointer\n", i); - return -EINVAL; - } - smem->partitions[remote_host] = header; smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); } From patchwork Wed May 2 01:10:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134806 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124265lji; Tue, 1 May 2018 18:11:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqvGHHetefAfDoQiG6Cs4H2KgEWDkJTpcF9J8dIpRy4W+mDX0EnYORwtMCQOKojH8kJv4+x X-Received: by 10.98.87.84 with SMTP id l81mr17555455pfb.56.1525223477384; Tue, 01 May 2018 18:11:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223477; cv=none; d=google.com; s=arc-20160816; b=xAjUve0mlfp+S9U1QY9Bw+p0mnwcRGVtvQ+mfiGmNh9nakUEZbkTvpm5lH4q2be7G4 2v6H3khflWnnGdhSsu/2vIbAp326/ErlI3zZf9naooDN38uN3iFBmgqK+ahaWK1m25WD QJycYulyLaWURJVdVlAnlzHI94U91ppN8aGuZgLhCRXWSMQ3ZKkPT7dfPsqUy8iu6Ovv 78MaMLZz9fsTYNQQQisrzrOXWogGYe1BffBzvGTJ48P6Ff/QZdkkK0ty/1zZd610Avy8 Emf+7AjKK7CBQ0GxDbQ6zugG/42Jq7lURqUwVSbh96maw/VTp8CaAvBIDcbZ219bVr3j ljhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dQ15NHDVyvrwZ/VNinJBFjezyZ8u6kEGM5Eewkig4Zc=; b=a8vQi8uHGZgyZvtWH/jePmyc1texxJvo1U57wRWG3AVgaGKoHQuMB6ZYBJEky1oRvK 43tXAKbFw8KrzlUoN/sU0xmHfLGzPZq7D8UNVTWC8BGKHOzRazZqjbucS9DeiHHPCkvq tTti0TnD4vESHZ50/636c14AQc/itRnhNRgwTg/jLd0XPeYH8pD0UUXC11neSdE9aavA xfdJUM6TgUVShklI4+YsuQh9AXlUVJexBz9c8NyTB2426INa/w/UID7M7arVuoE5bm2/ YzFYlOitDCXERNiF8PtXbfoGMZkoCiYATagdsk3swYOuiLw7RLsgycEaZKlqTXKQ8I68 h96g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bj2eaQgq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j26-v6si8725543pgn.326.2018.05.01.18.11.17; Tue, 01 May 2018 18:11:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=Bj2eaQgq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751454AbeEBBLO (ORCPT + 29 others); Tue, 1 May 2018 21:11:14 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:55629 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbeEBBKi (ORCPT ); Tue, 1 May 2018 21:10:38 -0400 Received: by mail-it0-f68.google.com with SMTP id 144-v6so15574716iti.5 for ; Tue, 01 May 2018 18:10:37 -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:in-reply-to:references; bh=dQ15NHDVyvrwZ/VNinJBFjezyZ8u6kEGM5Eewkig4Zc=; b=Bj2eaQgq9onUJQ7XP+Cdl02fn9w6nkylxMUaihGZ2qdBIEEHp20klqmpgh84hwJs5K Kf0x4hzHKJcCRY1V7haOf+4IagTeZyplY+ZZYTEe1h7GLkjXgmR30TaEG6MUsVNXvvWx WguIOE8bYms8TnxtX/laPXZMgpkWfXaUovza0= 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:in-reply-to :references; bh=dQ15NHDVyvrwZ/VNinJBFjezyZ8u6kEGM5Eewkig4Zc=; b=Z1MJfKZqsNoabSMBviks2qzPj4GHjNlG82sG0RA8aDDhaxQesU52MMQyws6r1wxEXK bxhLUmA2tyrhOr50jDz2NML18wFvaYzPK2adODN4OyJTIfE9v1625yK09mX/1Aw16Der QtK1IJoT309USoz6WjkbbrFVG+qS7E1uRPy3VcliDvFc7NjznmPLKGIrQiKKaNXZiLs+ q2A87OMHiAHN0utzKgFnY0g5BvTan66tS7J3WDq/XnXL5e4kIclQ0Ura4ey3B80pnJ6Y PraNn1N+JFzeQ0f7QXcJ2Z1IlszSFZXGlelPrAf9+VRKB8gfWgnQazxBT8SfIcsLPzYi TXkA== X-Gm-Message-State: ALQs6tASbkVqePz2Cije2EqNx6FL3HTbcA8NTdelj0O63j6Bh+2h5+0+ uCjsKsQPIA40ySqwtwaSWLWoNA== X-Received: by 2002:a24:9149:: with SMTP id i70-v6mr18193058ite.142.1525223437454; Tue, 01 May 2018 18:10:37 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:37 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/12] soc: qcom: smem: small change in global entry loop Date: Tue, 1 May 2018 20:10:17 -0500 Message-Id: <20180502011019.22812-11-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change the logic in the loop that finds that global host entry in the partition table not require the host0 and host1 local variables. The next patch will remove them. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7ef415c4d62e..54c504e41508 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -784,9 +784,10 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) if (!le32_to_cpu(entry->size)) continue; - host0 = le16_to_cpu(entry->host0); - host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { + if (le16_to_cpu(entry->host0) != SMEM_GLOBAL_HOST) + continue; + + if (le16_to_cpu(entry->host1) == SMEM_GLOBAL_HOST) { found = true; break; } From patchwork Wed May 2 01:10:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 134805 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp124220lji; Tue, 1 May 2018 18:11:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrtWiEbyHPJkXgrAQoNWUjF2TQa4vxCGFfESVc9nLTWYF2V27dhTgWVAM51SUB/6LkPOyQ3 X-Received: by 10.167.129.204 with SMTP id c12mr4873952pfn.169.1525223474087; Tue, 01 May 2018 18:11:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525223474; cv=none; d=google.com; s=arc-20160816; b=DEVPheATMoidhC5vG5nonl58KuoAhUCg+KBKtggJSQ2b5oLpRDOLJubX27v+SFru8a 8oge1MCoO8t9FNkAUHDb6yh41Swz0MXSSH2/80CSwq2dVcF/GZWlQyvmq6t2pIxP1dM5 hlHHw+cyNujtczI13qBpznL5CJosbFi4ZSRY2or5+8hNsGI5tKiukyRbtlhavMAQxun7 UzcWIqrh84lh7Drmwlmh3egDJQkndHdU5mXKKXsW4pIzT8nCquGCloP/Zibm7GaJB5zP ixcXQj0mMLVnwErbKvc9xqOqEbu+v4RvSbmhwGlKEupHcj9AJF2P3DOW9qq00BVnyAyi Vq1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0N7mqW0MP/CZKS+2sfMTDlQv7tC8kl8APpV2SbuO4fA=; b=HL6OfAXUp805bABi/v31dGCggPExaDWV6um2bFBqaatA8gYqiOwwvJWo3BGGKYfHbS X/0wS7USlXkzcdRW06WCFLWRvM1VEKIoE8xiP4gnai2R6ly3Xms5ZD3ZbRLIx2yZjjJp LAqwL/Qb4v2Daf4wEzxO1lhEr2VJ6M2a1/5r3kkPce5vpkdXMOs9dCZMX90MIorNJqJB 8SqgFHPwRr7nrW7ZCCZPSuGyhRh2XU7zK6OL5L2ZrtpB6STrxHGFwQy/I3VIbIlQEULa u8dSOi7RZkLuoZabhuvkTm5VuRVlUdWGMRsPcR1Wv4TajLUf0C+//gSbXFApJgTlKFKb SAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SBLt1gi7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id i10-v6si8554601pgs.239.2018.05.01.18.11.13; Tue, 01 May 2018 18:11:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=SBLt1gi7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751426AbeEBBLL (ORCPT + 29 others); Tue, 1 May 2018 21:11:11 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:55628 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbeEBBKj (ORCPT ); Tue, 1 May 2018 21:10:39 -0400 Received: by mail-it0-f65.google.com with SMTP id 144-v6so15574747iti.5 for ; Tue, 01 May 2018 18:10:38 -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:in-reply-to:references; bh=0N7mqW0MP/CZKS+2sfMTDlQv7tC8kl8APpV2SbuO4fA=; b=SBLt1gi7WF/nnkoxxCnii08PqC5WCVS28zV2LzyI2Sw56wGa7FFbQ6+ySNf4MKgFOG g8STWG0ntEsX+WqZBeFUwitAhcMRU5/zc5NtGT9/4wquo6x4USL4rGo2XB/xrbN/Glzb 1IJmUmgapTe39o/dD6zz/xboZlC0zk+pN8wqU= 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:in-reply-to :references; bh=0N7mqW0MP/CZKS+2sfMTDlQv7tC8kl8APpV2SbuO4fA=; b=dvmsLgdoaYQI4uX7Sk96pi8g3rTWZR68m20VLSB+Ilj1XTMpv9FTIliVjDbouWi3Bn diMOYyboZl5vJFLHjHOztXhEseSxBGnuT8bqqHqFuu/VHkKkAGLlCyrbh62hG9FzHhTX Bl4DvVq749UU1RiYxIqq0KBBqdmtr+y2sK16JwLqdUfjbmSGRmim1HJzb57yTXesVT3F TNajrkhP+7bDVUPNF3M8/sQntcX2os6tpxmnSRuN0Dxi2NrObRjuBtypS+wcYZJpIQWQ OC2iusmWmXDoZYvpaBiY8Qg9IY0q6oU8ZnuvtsDxSU88r6Iy2EwNGXpzVSWXU6+9auDK vleg== X-Gm-Message-State: ALQs6tAl+ZJRJniL+Q5cqCJPKEsD6lmam4sX4mLfd+VFgy1d2DFizX4j caS7zXUAUFMKkSRWMg6hWircIg== X-Received: by 2002:a24:fdc9:: with SMTP id m192-v6mr17033066ith.95.1525223438430; Tue, 01 May 2018 18:10:38 -0700 (PDT) Received: from presto.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id g200-v6sm2082479itb.26.2018.05.01.18.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 May 2018 18:10:37 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/12] soc: qcom: smem: verify partition host ids match Date: Tue, 1 May 2018 20:10:18 -0500 Message-Id: <20180502011019.22812-12-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180502011019.22812-1-elder@linaro.org> References: <20180502011019.22812-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the host ids found in a partition's header structure match those in its partition table entry. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 54c504e41508..7383a0e1b468 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -734,7 +734,7 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem) */ static struct smem_partition_header * qcom_smem_partition_header(struct qcom_smem *smem, - struct smem_ptable_entry *entry) + struct smem_ptable_entry *entry, u16 host0, u16 host1) { struct smem_partition_header *header; u32 size; @@ -748,6 +748,17 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + if (host0 != le16_to_cpu(header->host0)) { + dev_err(smem->dev, "bad host0 (%hu != %hu)\n", + host0, le16_to_cpu(header->host0)); + return NULL; + } + if (host1 != le16_to_cpu(header->host1)) { + dev_err(smem->dev, "bad host1 (%hu != %hu)\n", + host1, le16_to_cpu(header->host1)); + return NULL; + } + size = le32_to_cpu(header->size); if (size != le32_to_cpu(entry->size)) { dev_err(smem->dev, "bad partition size (%u != %u)\n", @@ -769,7 +780,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; - u32 host0, host1; bool found = false; int i; @@ -798,18 +808,11 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - header = qcom_smem_partition_header(smem, entry); + header = qcom_smem_partition_header(smem, entry, + SMEM_GLOBAL_HOST, SMEM_GLOBAL_HOST); if (!header) return -EINVAL; - host0 = le16_to_cpu(header->host0); - host1 = le16_to_cpu(header->host1); - - if (host0 != SMEM_GLOBAL_HOST || host1 != SMEM_GLOBAL_HOST) { - dev_err(smem->dev, "Global partition hosts are invalid\n"); - return -EINVAL; - } - smem->global_partition = header; smem->global_cacheline = le32_to_cpu(entry->cacheline); @@ -860,17 +863,10 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - header = qcom_smem_partition_header(smem, entry); + header = qcom_smem_partition_header(smem, entry, host0, host1); if (!header) return -EINVAL; - if (host0 != le16_to_cpu(header->host0) || - host1 != le16_to_cpu(header->host1)) { - dev_err(smem->dev, - "Partition %d hosts don't match\n", i); - return -EINVAL; - } - smem->partitions[remote_host] = header; smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); }