From patchwork Mon Jul 26 17:40:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 485853 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4042300jao; Mon, 26 Jul 2021 10:40:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQDqkeaO6cR8/JeAY8x9jdNXDzF3fF2uosGVXVoD42ANd/R950T11s4azSu2Uq1N9fw09k X-Received: by 2002:a17:906:22db:: with SMTP id q27mr3747420eja.185.1627321224418; Mon, 26 Jul 2021 10:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627321224; cv=none; d=google.com; s=arc-20160816; b=PVnqO2CxKopyKIZ2eUahDMfHOWHB5C1961xo7KOMUGPYJNCxOndeoRjGV4OiJ2Tc/z d3nIPsb3ShsyPWsCU+cq7ehc0okW/lFYZ/3sKCzoN8v3zZwnDvyD1pnsTQvrIHUNz62B 6kVY6eVZjxxzRKQhxgA6oAt+kRdF3uy4KN8bxRtxei3N+Mrp67pI75uvu8U8omK6gJni ifqv9ANypCqmnkLmkNUbeCzXQ5rVbtRpenoDbda2XgZDAURsh7LSs/L6klcgxLzITrUX bzC3Bb/FCjdHAjc356+tAm2cQgLxUhX4X2SdKzfb5BYNMqh2bj4iiBhCz2MNInrRpxNU 52cw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RhapsKA6J25kD25lmyi6/Yv9x0InAtnL2pbV2Xb9qwU=; b=fH/B8BXL54FMms8uq/Cn7V2YKykTAJEjntNi/+YIF/05BqAJEY+iNh6PKMASbHQ03d zPJxZ7aDD145QRtiCmRui67FO/y0XNHfplLFwWx/1krqj0PCgGKUZs9AHuyfsqcme/mc 7E5x5vRfyLtxsb9n5Ade8KdKAdn6RyMh60VBJ6Q4lMuGvaSlu7VFpuA5J1ZEXz45mqhD j8NI6aUs+ywImsvIziI1/+huU9XONY74SMCtb87nvZ+KvUh1uFuLzBJsXLcExCU+qZsQ B/TKYuOwW1+8K27rE1rDQ/E/VNSS5VmE1z1SkTgmn5+e3zgFniAjdwZMz1wgMbEOp742 jS+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EgeRPtba; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 gv3si514404ejc.42.2021.07.26.10.40.24; Mon, 26 Jul 2021 10:40:24 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=EgeRPtba; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S229646AbhGZQ7y (ORCPT + 8 others); Mon, 26 Jul 2021 12:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhGZQ7r (ORCPT ); Mon, 26 Jul 2021 12:59:47 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0081CC061764 for ; Mon, 26 Jul 2021 10:40:15 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id m13so12860448iol.7 for ; Mon, 26 Jul 2021 10:40:15 -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 :mime-version:content-transfer-encoding; bh=RhapsKA6J25kD25lmyi6/Yv9x0InAtnL2pbV2Xb9qwU=; b=EgeRPtba7JmXRFpCb8FHFkqy26AmvA+X5gH4ja6s47tmBi07ies/bKg+QIpedEfGnt mVWdIky5xLde1ZvHr6eg6JlgIUDcmAJ0upfIAo6kaz42joyY8cRNU5xzx9ZSzr/yq5ef AK4muCJVTIpkbnpDark9BNW398xyLVilfvTETNoiJmfbEWtgYvI6gWf0cu8dPYO4uGfx mZPgq8UVbTcEK65nrbN/+AECMrmvC3MczDPGy/tnUqFM2ROaf57QpJtJ70uuxYncRxh2 3OSiENmJjmcxu7i9J4GcMk52Wn+Bk3Ib310OzcH/ZbamQtRd8n5wFE8sDPl/+rRryRQu VxlA== 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:mime-version:content-transfer-encoding; bh=RhapsKA6J25kD25lmyi6/Yv9x0InAtnL2pbV2Xb9qwU=; b=ndYb21oQ2hVR8c7rQ1d4/7VgOgR3wRZfJW0lv2zpoGyKdT+SrlhaBjdLd07GWsMpo2 q378iEiR8spG3NG2mCdv7TGS0c7HkZOt9FOlF/9DEOjX6k8DtiSCyF89bP2/zT2bHPVs RY8rAfbufmvH7gPkRa4aeX2b5Zwl6OaQRmVSoco/xv+vCPuYzukd9OxVMhb8JCw5lymn U6Q+WpBpULztE9fA8aGnjBRna49d+uhG5s+z0Al3tkikquiX11CeA7HJjt6a8JE2tkiQ R2Db91d+cg4+YwKffZgDBrchrR91Ad7j0IRGrwEVa4bkhRf+67K3twoahh7JnOPmzHTs sNaA== X-Gm-Message-State: AOAM532UmxWQAoJws6JsEupPa7tRRc0p6K6patGHMVqAxlcm/8eE+daC Yr176XTLJRr3Nn4fXn7tKf1hDQ== X-Received: by 2002:a02:93a7:: with SMTP id z36mr17237528jah.112.1627321215463; Mon, 26 Jul 2021 10:40:15 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id l4sm202721ilh.41.2021.07.26.10.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 10:40:15 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: leon@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/4] net: ipa: always validate filter and route tables Date: Mon, 26 Jul 2021 12:40:08 -0500 Message-Id: <20210726174010.396765-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210726174010.396765-1-elder@linaro.org> References: <20210726174010.396765-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org All checks in ipa_table_validate_build() are computed at build time, so build that unconditionally. In ipa_table_valid() calls to ipa_table_valid_one() are missing the IPA pointer parameter is missing in (a bug that shows up only when IPA_VALIDATE is defined). Don't bother checking whether hashed table memory regions are valid if hashed tables are not supported. With those things fixed, have these table validation functions built unconditionally (not dependent on IPA_VALIDATE). Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 36 +++++++++++++++++------------------- drivers/net/ipa/ipa_table.h | 16 ---------------- 2 files changed, 17 insertions(+), 35 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 4f5b6749f6aae..c607ebec74567 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -120,8 +120,6 @@ */ #define IPA_ZERO_RULE_SIZE (2 * sizeof(__le32)) -#ifdef IPA_VALIDATE - /* Check things that can be validated at build time. */ static void ipa_table_validate_build(void) { @@ -169,7 +167,7 @@ ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) return true; /* Hashed table regions can be zero size if hashing is not supported */ - if (hashed && !mem->size) + if (ipa_table_hash_support(ipa) && !mem->size) return true; dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n", @@ -183,14 +181,22 @@ bool ipa_table_valid(struct ipa *ipa) { bool valid; - valid = ipa_table_valid_one(IPA_MEM_V4_FILTER, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_FILTER_HASHED, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER_HASHED, false); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE_HASHED, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE, true); - valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE_HASHED, true); + valid = ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER, false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER, false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE, true); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE, true); + + if (!ipa_table_hash_support(ipa)) + return valid; + + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER_HASHED, + false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER_HASHED, + false); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE_HASHED, + true); + valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE_HASHED, + true); return valid; } @@ -217,14 +223,6 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) return true; } -#else /* !IPA_VALIDATE */ -static void ipa_table_validate_build(void) - -{ -} - -#endif /* !IPA_VALIDATE */ - /* Zero entry count means no table, so just return a 0 address */ static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) { diff --git a/drivers/net/ipa/ipa_table.h b/drivers/net/ipa/ipa_table.h index 1e2be9fce2f81..b6a9a0d79d68e 100644 --- a/drivers/net/ipa/ipa_table.h +++ b/drivers/net/ipa/ipa_table.h @@ -16,8 +16,6 @@ struct ipa; /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ #define IPA_ROUTE_COUNT_MAX 15 -#ifdef IPA_VALIDATE - /** * ipa_table_valid() - Validate route and filter table memory regions * @ipa: IPA pointer @@ -35,20 +33,6 @@ bool ipa_table_valid(struct ipa *ipa); */ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); -#else /* !IPA_VALIDATE */ - -static inline bool ipa_table_valid(struct ipa *ipa) -{ - return true; -} - -static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask) -{ - return true; -} - -#endif /* !IPA_VALIDATE */ - /** * ipa_table_hash_support() - Return true if hashed tables are supported * @ipa: IPA pointer