From patchwork Fri Feb 10 16:37:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 652349 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1060125wrr; Fri, 10 Feb 2023 08:40:03 -0800 (PST) X-Google-Smtp-Source: AK7set/N3ARHJKlcDtgL7bw3kXgsTilpve606jd0meJlB+LlMwzUbIN9oIpid37Qj31PxAW97gXZ X-Received: by 2002:a05:6214:318e:b0:557:a5c5:7dfc with SMTP id lb14-20020a056214318e00b00557a5c57dfcmr13461423qvb.20.1676047203327; Fri, 10 Feb 2023 08:40:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676047203; cv=none; d=google.com; s=arc-20160816; b=LBQQ4/Hmeqrdp1n4R3XTi1rsSGecEPbUIsGJM0C7IDDpNBUL7b0O2HWtCp7iZ44thY kg0KoKblg4uH5Pc3ZT+4mlVVfjS19cbQ79SPGaBHPHoOF6i4peAYEXwdvHiMP9cDau3N p7jTBV/+JVRs+xt7VVU5mXUlGxCL2Pdou5VVRAfQHkmi31630Zj1XEeS0VF+1IuLrFdE DChOVbNhPDjy5ajkxw3K2PUB0BWfX/8yLR6lzq6tZdNK5MzuC6yCu6WwUfSQywEVDMs7 xFlOXEGE5GDTNPS3RAjKYBO1SQ5tnZ7JvWda1o06aHgSNkbouSoShVUMCAOXUJ9aIK3A dFfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9MhaVPxfxbtAezcy2vU3U8mTUUFFbUwtf08uGYyb7ms=; b=DeN4ckP2xdkZ+FiJs6T1+HqlHOv1AbccAlYTPevVhChKxfD4Klrw3AtcwzHxLJ1Ehp 6ET2IuRs8YuDHa93Tb60bGjXMNJCOnmDcICeIBPUwF0GMvH3z6NbBITu9mmFYeMCWjkY /ZuT86gIXjydNyeNmAtpfzYTKm2WOtqbRjY9A/2ec0fl0mCHZSvzxSLZ3iLd2bnOFz8i Y2T8Olyeecp5yTmVH1b8TZdlNbk6zAPZnuVJXcbhMd4QwOzDrSpIwxtKtLmL68eXQicT UhzQASYKIV7sjxZVBegtb/lt+7G4KjKEeczc31DL47oBmZOqRAIXJ7UH7ONQUJdfh+JE gSoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otyrgvzX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id do55-20020a05620a2b3700b006fa7ad78b63si3937923qkb.680.2023.02.10.08.40.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Feb 2023 08:40:03 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=otyrgvzX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQWRE-0007By-GI; Fri, 10 Feb 2023 11:39:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQWR7-0006gO-Dp for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:39:45 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQWR4-0000UP-AK for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:39:45 -0500 Received: by mail-wm1-x32c.google.com with SMTP id j32-20020a05600c1c2000b003dc4fd6e61dso6687846wms.5 for ; Fri, 10 Feb 2023 08:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9MhaVPxfxbtAezcy2vU3U8mTUUFFbUwtf08uGYyb7ms=; b=otyrgvzX0nzYp0hPREsp3SRaiNgXtH2xnusVJKtkJrv8noEsduLcB5nrPJxs21RYZ1 i8ilO2l4J/GDuFixWoXAkdDZdnXLmTJta2AOx61hBalpZQvv8fI+FxcQ2TWDdHY2paMJ VtvVxtFjOPDffsZ2KT4TMwKw8vaKVi/mVWoCJhs1YbjPgQTfGi7jTRAg97bW1SbIaifn SqT9VNlLr0NmZ0MSAzMJZJv2yREEmze+9PVxN0TS8wNN1Rrh/JxTo9jch/F2ZAHZA1bY T+6vLoJNloJkdPNPTODetQVE8EiRdUq1OmzU93+BOzEKcLt1MATOmPYEk81e49y0Aiu2 6exw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9MhaVPxfxbtAezcy2vU3U8mTUUFFbUwtf08uGYyb7ms=; b=193xBCdrgSbG3NC+CAQlJYH2r5fvXXd1HSQayHAyW3KF9SxTkjhv7DMs/ZJYLtxj3u mpD50WcGmiPx/eIeQhYfxe9XLcsewtF140tjKJngmX4IGXhGWR7hHQGwaFb60B+6Twgd 2fba+Ykchk+8gUHd83U6FAW7nbXLPKYcjvPlaajmkMl46lkPZtR4nNWGxSK4c1kDJ2bw jrotxKwjuQznuGqrglgegpzDdUcUVh6UJeOIdoHv581gn999646FUlrim6Nnvb93LT2h +6Yy2Qc+SjEe676mubuzthrLhvqySFxXzVRdSzAdRU1sviDsMIdenvpWyZ58/nrqvxp3 0Vzg== X-Gm-Message-State: AO0yUKWP8DcqhfWiNGxn2yp80Cotr0pch+l7VSxohrytWKaa9A4qQWJ3 mVCacn1TQEtK6HWWN4WU/B0gTw== X-Received: by 2002:a05:600c:318a:b0:3df:94c3:46f2 with SMTP id s10-20020a05600c318a00b003df94c346f2mr13577402wmp.23.1676047179597; Fri, 10 Feb 2023 08:39:39 -0800 (PST) Received: from localhost.localdomain (054592b0.skybroadband.com. [5.69.146.176]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c4e8800b003da28dfdedcsm6312144wmq.5.2023.02.10.08.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 08:39:38 -0800 (PST) From: Jean-Philippe Brucker To: eric.auger@redhat.com Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, ola.hugosson@arm.com, Jean-Philippe Brucker Subject: [PATCH 1/2] hw/arm/smmu-common: Support 64-bit addresses Date: Fri, 10 Feb 2023 16:37:31 +0000 Message-Id: <20230210163731.970130-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230210163731.970130-1-jean-philippe@linaro.org> References: <20230210163731.970130-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Addresses targeting the second translation table (TTB1) in the SMMU have all upper bits set. Ensure the IOMMU region covers all 64 bits. Signed-off-by: Jean-Philippe Brucker Reviewed-by: Richard Henderson --- hw/arm/smmu-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 733c964778..2b8c67b9a1 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -439,7 +439,7 @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu), s->mrtypename, - OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS); + OBJECT(s), name, UINT64_MAX); address_space_init(&sdev->as, MEMORY_REGION(&sdev->iommu), name); trace_smmu_add_mr(name); From patchwork Fri Feb 10 16:37:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 652352 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp1060291wrr; Fri, 10 Feb 2023 08:40:27 -0800 (PST) X-Google-Smtp-Source: AK7set8JRidpjjnEjAQdIpyUdVuD2pjHnYnJxi7F+VfhYzA8BOEDvuN5umAPYYw5FecbQqMYhlcX X-Received: by 2002:a05:6214:5011:b0:56e:941d:a4b3 with SMTP id jo17-20020a056214501100b0056e941da4b3mr5273611qvb.7.1676047227252; Fri, 10 Feb 2023 08:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676047227; cv=none; d=google.com; s=arc-20160816; b=gpLazBNSEo0eS7G9FTxWED05Qqn2iXyWSbuaALTVTgTiBKPmSKM9GQ6ah5QMrPaDI3 laIgox6UsRtfhmEb3WbdWtBjYBg8InLB1GNIgQDrmwm6EJ52vT0PyGbmWy+E89dhjJx7 GapR0iGJOymsW/vmpI3eKv0Ki8vENtLHzz6p+ahcoz4jeI1mFv/XLVd8Th+PXSkWEWos HWju+9jeX/4GOffVEmc6JlzqYdo44cNnnk9o7YmNy0TiUUuJRqbdPaAeXcQsqy9KFSZj 9uBxc4dy+KKLEZQYajYdOil9/isarTY/mpC2u6m09loOnjqMCSb/w2pRJQFVih8+dLrl Ovug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m6P8HLBt4ufHIqb717DBvHQgjnd6QfYZ+mBBlnxbNRQ=; b=jHQiEd1oysUZoDX2ciPl8lTZyGxMRiz7Om1GEfCOtgMiTgbczo1kYEHfIjx8ADHv6L VNYlkgsDGitsz78g5nMtQW+2Kwo9bkAa4W7n7GdkRtyGzF8hb4gM1EOI9kn/HkLu6IHJ 5cJsDcvBlwHq+BgEC6syO0o6v8kqnpDZfbndcpKsQ2fjItLF73Xl6WeOgjgzGOLoaWHc c1+I6XimRb7Irx4ba4G2u/T46h4vCwJUk9r0mQGhcFevibBgD2fT2wexUFa7H7a4i3Yw f4oigNHP1boUZIGZ2hl/sBdg8j/1PxIUDSut1KOYujZ+UtwMQqJxsaNziKs+FtSOZ1UE GhhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJoB1KSg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j17-20020a0cf511000000b0056e92b34e8dsi1731964qvm.376.2023.02.10.08.40.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Feb 2023 08:40:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJoB1KSg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQWRG-0007My-0N; Fri, 10 Feb 2023 11:39:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQWR7-0006gu-F3 for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:39:45 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQWR4-0000UZ-BJ for qemu-devel@nongnu.org; Fri, 10 Feb 2023 11:39:45 -0500 Received: by mail-wm1-x32c.google.com with SMTP id k8-20020a05600c1c8800b003dc57ea0dfeso6715085wms.0 for ; Fri, 10 Feb 2023 08:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m6P8HLBt4ufHIqb717DBvHQgjnd6QfYZ+mBBlnxbNRQ=; b=VJoB1KSgexIV3gWjsTTMEKj446wJyahxrcZeqJrmrBlKlC8xGv/qJ7QoG1pDASCo4w BdUrrn9KkID9LCIto5dfMmwuGrbdKowocC7jt/gncawiFUg7YMXAiutXTFBgS8I/4Vk9 gE2VTna3Mzk/63Eq9t7Sn80Ij5k2v1mKeu0vd7HU/KDLOAePCYmvc99UnF5onPO5UK0/ Y3rCzRQzcFbvndn+GHrEQ1RuafMb/8knyPgIZ8F37wznjjF3dmtuNRlchETf/AXtAafr ECnz3WaGVt0DGDKf2o7O5nMX6Y2bGWJpqpWNl2JOclPZTcg0H5ZJwkwSzQJmgeMmlx4Z Agag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m6P8HLBt4ufHIqb717DBvHQgjnd6QfYZ+mBBlnxbNRQ=; b=HstIIqe9QkYSbAzphXkXvpgLpBrZ/FQlXPjForYluWhKDTtC3LDD/bqGbkMijl2nNZ EEWlWH6osaLdNJGhU4OceiLwHEW+57DczuEDPNPQoVXfullHOeCf+ZN4nB4fMkNNKWPF sv4DF9+3Fp/3Z0b5VhIp6jUQD3rVzkPQYEISgY/h7GxI30dAbwLtttYBpYA0hFez9CU+ 60Ap6+/Z+7ShmlLnF2CMiz+irm3gEsa5x3jFzZEoTLqo2nUiwDlvyO4NLnGhijyfm2Hv wqtGODnqypxzN2tZAWWH6SSZRESqAOobX5WbpKmB+PF5ov6gqSee0TBTsmywynd36OBW MFNA== X-Gm-Message-State: AO0yUKWbjFAXSeyZ5wIgyuGk0r7cnWdJjVUH/LTgX7Z0Nqii+oRbZ8A3 cA/icjRu9Zoe2O2JG0lFBQjJDg== X-Received: by 2002:a05:600c:4387:b0:3da:b40f:7a55 with SMTP id e7-20020a05600c438700b003dab40f7a55mr2585644wmn.6.1676047180517; Fri, 10 Feb 2023 08:39:40 -0800 (PST) Received: from localhost.localdomain (054592b0.skybroadband.com. [5.69.146.176]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c4e8800b003da28dfdedcsm6312144wmq.5.2023.02.10.08.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 08:39:40 -0800 (PST) From: Jean-Philippe Brucker To: eric.auger@redhat.com Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, ola.hugosson@arm.com, Jean-Philippe Brucker Subject: [PATCH 2/2] hw/arm/smmu-common: Fix TTB1 handling Date: Fri, 10 Feb 2023 16:37:32 +0000 Message-Id: <20230210163731.970130-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230210163731.970130-1-jean-philippe@linaro.org> References: <20230210163731.970130-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Addresses targeting the second translation table (TTB1) in the SMMU have all upper bits set (except for the top byte when TBI is enabled). Fix the TTB1 check. Reported-by: Ola Hugosson Signed-off-by: Jean-Philippe Brucker Reviewed-by: Richard Henderson Reviewed-by: Eric Auger --- hw/arm/smmu-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 2b8c67b9a1..0a5a60ca1e 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -249,7 +249,7 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) /* there is a ttbr0 region and we are in it (high bits all zero) */ return &cfg->tt[0]; } else if (cfg->tt[1].tsz && - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { /* there is a ttbr1 region and we are in it (high bits all one) */ return &cfg->tt[1]; } else if (!cfg->tt[0].tsz) {