From patchwork Mon Jan 16 07:16:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 9518209 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 E4023601B7 for ; Mon, 16 Jan 2017 07:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B27242838E for ; Mon, 16 Jan 2017 07:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5907283D3; Mon, 16 Jan 2017 07:16:42 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36EF82838E for ; Mon, 16 Jan 2017 07:16:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cT1Wz-0002CD-6F; Mon, 16 Jan 2017 07:16:41 +0000 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cT1Wu-0001ow-GD for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2017 07:16:38 +0000 Received: by mail-lf0-x229.google.com with SMTP id n124so6030018lfd.2 for ; Sun, 15 Jan 2017 23:16:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=jP68Yhlo8azsFl53IMZkjqsLM5wvcekJTNDOhEjPvz0=; b=sfG5wC/ORP2z8nj6RXDV8KLo+BF/ODELZO3SsxQXJhPuipWkoNF4D2QnwJ2Lek2X+L bRhSi9dDMhHR4qsF/RKEei1UthB9DGlf9yRXApG7v3VUqci9TA/EnIHLymRyMkI3eH/O QO16y3HnY6AlrvlHQf1DV/m4trT8BpX9NL0jX0uXUUJPfzMjuBpmMbTxpEjLZt5Zbx+e w6gqlIILVXSL8l+STVgvoMl+koJqGDKsZpbB3tg0l3u41K54kxiixEdRTbTht1AlEcAO 1Nz3KP+Lk9cNwkzDE9INHhX7pLdJLSDCTPpBUmzmyKFJ2lMxNvCH1DQyuH7WO49mmQvG hqSA== 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; bh=jP68Yhlo8azsFl53IMZkjqsLM5wvcekJTNDOhEjPvz0=; b=Zcyt13mR4bouZSyMArfzZfNJBiRNQH8vjh23DeEHb7GsFzop9C+vw8raRNEPCXJFRA GQku0iQgQ2ZDQP0MZi/5bjkv3CzP0XU7pYRjcKUet2SJHqvILMp+chqEArVbY2R8lY7k 047GrrM4iKsg7jwUMnyQBv2Ok8N7IDnV7xlsrf7m0MST19eB5MIZGcefEjoxXcC0EJry Q4dh5Ur7ylcMoo9VRbQpyV5oIylw6x5OdjSPFVEBjuialWQABdQKcvCtg81zU16RWVfh 7VRc4Ohlh/8dz5RkiLDQ7KYb80N3/hefoxLRp9Fo/VwjaPnBds7X7FkUSI4knknh5GgJ Z9MA== X-Gm-Message-State: AIkVDXJ003TXznYgs4eHqTsUrkmVb/UlNdUZ07/lgtmF6gvwPMO/xwglyVgNVvSKWmDmhA== X-Received: by 10.25.125.132 with SMTP id y126mr11665052lfc.86.1484550973819; Sun, 15 Jan 2017 23:16:13 -0800 (PST) Received: from tn-desktop.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id f25sm6661420lji.26.2017.01.15.23.16.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 15 Jan 2017 23:16:13 -0800 (PST) From: Tomasz Nowicki To: will.deacon@arm.com, robin.murphy@arm.com, mark.rutland@arm.com, joro@8bytes.org, Linu.Cherian@cavium.com Subject: [PATCH 1/1] iommu/arm-smmu: Fix for ThunderX erratum #27704 Date: Mon, 16 Jan 2017 08:16:07 +0100 Message-Id: <1484550967-6328-1-git-send-email-tn@semihalf.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170115_231636_741488_8D51BCAD X-CRM114-Status: GOOD ( 10.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasun.Kapoor@cavium.com, Sunil.Goutham@cavium.com, Tomasz Nowicki , linux-kernel@vger.kernel.org, Tirumalesh.Chalamarla@cavium.com, Geethasowjanya.Akula@cavium.com, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The goal of erratum #27704 workaround was to make sure that ASIDs and VMIDs are unique across all SMMU instances on affected Cavium systems. Currently, the workaround code partitions ASIDs and VMIDs by increasing global cavium_smmu_context_count which in turn becomes the base ASID and VMID value for the given SMMU instance upon the context bank initialization. For systems with multiple SMMU instances this approach implies the risk of crossing 8-bit ASID, like for 1-socket CN88xx capable of 4 SMMUv2, 128 context banks each: SMMU_0 (0-127 ASID RANGE) SMMU_1 (127-255 ASID RANGE) SMMU_2 (256-383 ASID RANGE) <--- crossing 8-bit ASID SMMU_3 (384-511 ASID RANGE) <--- crossing 8-bit ASID Since now we use 8-bit ASID (SMMU_CBn_TCR2.AS = 0) we effectively misconfigure ASID[15:8] bits of SMMU_CBn_TTBRm register for SMMU_2/3. Moreover, we still assume non-zero ASID[15:8] bits upon context invalidation. In the end, except SMMU_0/1 devices all other devices under other SMMUs will fail on guest power off/on. Since we try to invalidate TLB with 16-bit ASID but we actually have 8-bit zero padded 16-bit entry. This patch adds 16-bit ASID support for stage-1 AArch64 contexts so that we use ASIDs consistently for all SMMU instances. Signed-off-by: Tomasz Nowicki Reviewed-by: Robin Murphy Reviewed-by: Tirumalesh Chalamarla --- drivers/iommu/arm-smmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index a60cded..476fab9 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -260,6 +260,7 @@ enum arm_smmu_s2cr_privcfg { #define TTBCR2_SEP_SHIFT 15 #define TTBCR2_SEP_UPSTREAM (0x7 << TTBCR2_SEP_SHIFT) +#define TTBCR2_AS (1 << 4) #define TTBRn_ASID_SHIFT 48 @@ -778,6 +779,8 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, reg = pgtbl_cfg->arm_lpae_s1_cfg.tcr; reg2 = pgtbl_cfg->arm_lpae_s1_cfg.tcr >> 32; reg2 |= TTBCR2_SEP_UPSTREAM; + if (cfg->fmt == ARM_SMMU_CTX_FMT_AARCH64) + reg2 |= TTBCR2_AS; } if (smmu->version > ARM_SMMU_V1) writel_relaxed(reg2, cb_base + ARM_SMMU_CB_TTBCR2);