From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309032; cv=none; d=zohomail.com; s=zohoarc; b=L/Za44vNaKx9plWja3e5nKsKWw1vfvDvR3IgZJhkiLZMOJdTpa4KOqcOuRmk4iD1nidw+59gVNqMd5ugvswrhlwjft8nx0wf2RFX4ovKLAmD58iWCHS4mI28WYR/yF7vJZ0g9JktvQ8oqW0azE6q5KIcDln5yMON1N1EFwvCqc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309032; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=cAG6/a6hlbAJcA7xle3K3QGG4JF+dWFlZQV04eIRpCY=; b=G9hzakzDUxofHC3XHwTgD483W7PJZjgLHLc5K5kg+EM8nEx34DzrfnodJS784bCAn5wgJ6l2MiKcIRir1kWnCm9YBQn7VSJZdlHM1EwQmfPaFNrKkKcTbIZe8/HZPZ8pMQoKOmUudEVpG/WBhTo3pF9OPg7WduWaqEQXiSzMSwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309032019843.2668568114683; Thu, 18 Jul 2024 06:23:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR44-0001HY-Ku; Thu, 18 Jul 2024 09:20:56 -0400 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 1sUR3l-0007uJ-AW for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3i-0004Sn-NR for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:37 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-52e9b9fb3dcso355547e87.1 for ; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308831; x=1721913631; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cAG6/a6hlbAJcA7xle3K3QGG4JF+dWFlZQV04eIRpCY=; b=AMTTUvm8pG3gLFeld2bBPH5xJ89aBp0IfHgHL6o7YnfiFsa6npqYqE1CVZ4Ejg9HUq tDLK2RWkVrD/WSOr7kgoKZjitXAiiuACijQh/Xocwu/+lApAaudwqgKwL2jD4brTL4oj nLdgWLJgUMtRIWtA4P7caWkScr8GBpfPVxVpvqzNeLP46LidX+Himo9o3m/vdRExT+US 5LCVxYCP6ivkHS1i0omdoklQpU48K60qxPO9gR2cxPuHvZ8c4V3WwzPqIzXZJkEqzjK+ PWInuLwiCwH2V5ibukU+xtftmIzUx++8XtHYH43NMAmUY7ixedTgtLWi7/rjV7ESs1Ol eP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308831; x=1721913631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cAG6/a6hlbAJcA7xle3K3QGG4JF+dWFlZQV04eIRpCY=; b=u/cBPtM2Rvg8ckmBmmYpb4DTUeMtqeR94P6Faw2mp4LK/EMKgYG1WKXOSiczPj5Y7W D0x+JEQOxpB5YSwEKlBBvy7ucw49+sXuHHDR5jHb/FmFvMh8eJ3nptIKZpn3ekz5J6wZ Y1MehVyxRYvA66Pd2ipgxd1whHIcMXWe78AHyf2LPue5agNv0Bg91h+GsBdBG9KAbLYo NOCZ5w2yr1wm6txqIotQifFT2LnA5EngZ075VyAZf8vc3bCLrI80AKErxzj7n9AqRSgZ yxrTZxSs25KQKk9UAtsf2ZFquCV1Uy84DTfhPL+PK3Cimrye2EB1qPt5y7LhfuDmlksG i6bw== X-Gm-Message-State: AOJu0Yz2X0/Py6zS52zN93qq2GfgvuHEFVH9BYjXGiAeS8YxfLjtHFat hfg2lJhZULVL2zqq2KbJ6FjHz1kYMhuh2hlHHOcmh4A7PGXzz5SCyQYCQb4Q5BumJtLm7zNdr2J Z X-Google-Smtp-Source: AGHT+IHPu7ekE2nyYfgEmF/OkvZpQ8Ph2ltGOjy1OwXyVq5rzjmsNmhfDVtWo2ITL5uXWlV95qzYVQ== X-Received: by 2002:a05:6512:1281:b0:52b:bf8e:ffea with SMTP id 2adb3069b0e04-52ee54113d0mr3636635e87.40.1721308830611; Thu, 18 Jul 2024 06:20:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/26] target/arm: Fix handling of LDAPR/STLR with negative offset Date: Thu, 18 Jul 2024 14:20:03 +0100 Message-Id: <20240718132028.697927-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x133.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309033057116600 When we converted the LDAPR/STLR instructions to decodetree we accidentally introduced a regression where the offset is negative. The 9-bit immediate field is signed, and the old hand decoder correctly used sextract32() to get it out of the insn word, but the ldapr_stlr_i pattern in the decode file used "imm:9" instead of "imm:s9", so it treated the field as unsigned. Fix the pattern to treat the field as a signed immediate. Cc: qemu-stable@nongnu.org Fixes: 2521b6073b7 ("target/arm: Convert LDAPR/STLR (imm) to decodetree") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2419 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-id: 20240709134504.3500007-2-peter.maydell@linaro.org --- target/arm/tcg/a64.decode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index 2922de700ca..62df4c4ceb4 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -520,7 +520,7 @@ LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 = rt:5 LDRA 11 111 0 00 m:1 . 1 ......... w:1 1 rn:5 rt:5 imm=3D%ldra_= imm =20 &ldapr_stlr_i rn rt imm sz sign ext -@ldapr_stlr_i .. ...... .. . imm:9 .. rn:5 rt:5 &ldapr_stlr_i +@ldapr_stlr_i .. ...... .. . imm:s9 .. rn:5 rt:5 &ldapr_stlr_i STLR_i sz:2 011001 00 0 ......... 00 ..... ..... @ldapr_stlr_i si= gn=3D0 ext=3D0 LDAPR_i sz:2 011001 01 0 ......... 00 ..... ..... @ldapr_stlr_i si= gn=3D0 ext=3D0 LDAPR_i 00 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign= =3D1 ext=3D0 sz=3D0 --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308856; cv=none; d=zohomail.com; s=zohoarc; b=S4f3iKOp3YMViQNcERhYf1LQ53JyVncB/amyuOUSiiM0ORZomdNfKVzeRvmC22M9wpXL3eXgNjGttx+8OJnh7RBBkiSZD2/TGEQRksHNzZWTYhUl5EFssEPOu2mbhMlXKVhhJdDy4J2p8hGl9PCcJlJ5s5M60d/ofIwyRd3OV04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308856; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wNvxFR8UOIk9oR5FQocJEptc0zyJlU6CCgtVFEcW6V0=; b=F8AuFxOeel0tVMxFaGkZIZv+8rNYbVt16hKlBKs/JzMroozIEzLzxsFm0sa4GvYeim1JFsMJlyiVEuvHjbdunDVzlP5VV5bvCSNT33jCcbCAlisxE5+RVsTx1aP0UEFXH0yFpbHhKPBUAGdMFSpR4ah9jUFRfZnXlJ/l/1YYi8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308856433484.5054089919172; Thu, 18 Jul 2024 06:20:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3u-0008NY-TZ; Thu, 18 Jul 2024 09:20:47 -0400 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 1sUR3l-0007tW-4g for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3h-0004So-J9 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:36 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4266fd39527so2759875e9.1 for ; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308831; x=1721913631; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wNvxFR8UOIk9oR5FQocJEptc0zyJlU6CCgtVFEcW6V0=; b=CY3gEDc2u2gGFXgCgKCBko4guwrKfxqbuguDPNj67Q1B6rHSAhK/OWEmEgRce2jt3F D+nlias1FoViifEQBs+txtRLrG/pEhBZqGIPYVJ6PFRYTuaN4akbNTY6+gQ3BhAFidAA aHlRSG+GzcSSgFrkTy/7jDPvfYORUbhKoJJDSvNwrDR16hemmNOSjtvmEZZ/cGEj59d0 OVlVQZ3eD7UsjF6vhWFuFoNxeR4TUENSss+Rje38grGf/zzdho9vNG8p9JHM3ea3O300 hMjkyzHt+CMqEU06Umq3B0auKclhgxBBW+D///wYMSUnni/9QLoUvfUc/XZl1FG5Pusk +mFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308831; x=1721913631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wNvxFR8UOIk9oR5FQocJEptc0zyJlU6CCgtVFEcW6V0=; b=ZH2ODQLTXF925/v4QDe7Ck+CZMS1c7LyowfCogS5dpQnA2MV1BfmzCSmXZgPf/YV05 Nxfif/o3r9nRLgIHhJ/hXxZv/dlkY5CIhA9meC8SOklaegxsm0eyubQc0NIiE1rXbqvA hrkdVIq2Q60qaDIqBZctjyvfjxqgZbAtCoGtYlXMOEO9ILeoOtAzAkspnhaykk+kqXLO ztVM9dIna+6EkGlvG2RkiCU8QfAq+fDLHMsJXhktFmnKT2XsK0Atcxvy7RM8sbVsh1LY 0DSrde9YiVa5VemFqU2w8Q6fXQcO3iNhOWtfu1P5vyJKlRQMfCcyTi/YIA9cvEyY0VdQ hpPA== X-Gm-Message-State: AOJu0YzjwUrTKlHUYlPELXgbs0pXoAKJaCzRDMVtSZrKtfQ3RQQZ07qe j3gB2xVYyh1JiOpBEHybQ789a1PFlQGMArKiO1LVMFWFJJl2JaiIqNChP2Lbsj6qojXA1SSHzJ7 m X-Google-Smtp-Source: AGHT+IF1xFutbpCa7uWIYfL4mMj3x/OouopRK7O0feOcm1g4amWNNgBixXbfyMQZV6c6klDrnYJxsQ== X-Received: by 2002:a05:600c:4588:b0:426:6861:a1ab with SMTP id 5b1f17b1804b1-427c2d10a58mr33497605e9.39.1721308831103; Thu, 18 Jul 2024 06:20:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/26] target/arm: LDAPR should honour SCTLR_ELx.nAA Date: Thu, 18 Jul 2024 14:20:04 +0100 Message-Id: <20240718132028.697927-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308865447116600 Content-Type: text/plain; charset="utf-8" In commit c1a1f80518d360b when we added the FEAT_LSE2 relaxations to the alignment requirements for atomic and ordered loads and stores, we didn't quite get it right for LDAPR/LDAPRH/LDAPRB with no immediate offset. These instructions were handled in the old decoder as part of disas_ldst_atomic(), but unlike all the other insns that function decoded (LDADD, LDCLR, etc) these insns are "ordered", not "atomic", so they should be using check_ordered_align() rather than check_atomic_align(). Commit c1a1f80518d360b used check_atomic_align() regardless for everything in disas_ldst_atomic(). We then carried that incorrect check over in the decodetree conversion, where LDAPR/LDAPRH/LDAPRB are now handled by trans_LDAPR(). The effect is that when FEAT_LSE2 is implemented, these instructions don't honour the SCTLR_ELx.nAA bit and will generate alignment faults when they should not. (The LDAPR insns with an immediate offset were in disas_ldst_ldapr_stlr() and then in trans_LDAPR_i() and trans_STLR_i(), and have always used the correct check_ordered_align().) Use check_ordered_align() in trans_LDAPR(). Cc: qemu-stable@nongnu.org Fixes: c1a1f80518d360b ("target/arm: Relax ordered/atomic alignment checks = for LSE2") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20240709134504.3500007-3-peter.maydell@linaro.org --- target/arm/tcg/translate-a64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index 559a6cd799d..148be2826ec 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3543,7 +3543,7 @@ static bool trans_LDAPR(DisasContext *s, arg_LDAPR *a) if (a->rn =3D=3D 31) { gen_check_sp_alignment(s); } - mop =3D check_atomic_align(s, a->rn, a->sz); + mop =3D check_ordered_align(s, a->rn, 0, false, a->sz); clean_addr =3D gen_mte_check1(s, cpu_reg_sp(s, a->rn), false, a->rn !=3D 31, mop); /* --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308848; cv=none; d=zohomail.com; s=zohoarc; b=a/YEUsfAKBiNYhomCiT2Vr2KAoCvpJ8r0UNyPEOxloxFALAfNChH9Sooo/pOLwjWUo8A53qquGY/iaW/JQB74A+1Pya/K/8OQiIJASuDL48ouO8xtNDp8sm++yT9PQ1T3R5o2KVZQKi37k0EDr6iJMhkHp/MpfSYgF4Qp0Rp0uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308848; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=yCmmBscXHr7DP5v15ZBTuTVPUGJ3/3t6QvO+9hat3Zg=; b=cpjV5TXJlM7qldAzDxgsqnJ0nv5KuR+qteJAO+UwI2VOaWFcbEq8OPWr95K/kzvue+hugF8TkaNKOQsVinNazqeEmaa+tFopNTjjhEmU6DDBtRJSyg7j88jOJ/acDZg1HjTiuuIABLnXKC3X6j4PbnlXZzaIgtNkosZOcLFBpdw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308848978607.2567885088683; Thu, 18 Jul 2024 06:20:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3q-0008F5-Oa; Thu, 18 Jul 2024 09:20:42 -0400 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 1sUR3l-0007td-4l for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3i-0004Sw-O2 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:36 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2eefc3d707dso10106351fa.0 for ; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308832; x=1721913632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yCmmBscXHr7DP5v15ZBTuTVPUGJ3/3t6QvO+9hat3Zg=; b=ZXzWSJwmIXu4ps812/7Zlkt10i+g9PzqVVi66timp6scgeqeoEAARK14HUg1o5aMme 2DmLEJ/ekfpXmsJNPtWMx5TXQhfStM9bjlgNO8y6Bigox4NRH12Mrmlquejv7+N2NZgu KAvebyV02Cg0+49/YiJNDz/KgiTbLo9lNPWTIpbeOEbTIfkR3NCTBQwNEBmbLdbgbCOu gOsKOW3MKQSnauVVn2iXdESSS2ApziWYakhwCx1Bb+btmYeG3SAw+mWF5UDlHWI7IEwV lCPXoL0tEH0IUizLdxmV4OMPN9HXzcbzImqmQloMvxo2K6KH/iNp/uDUygLfJlY99bQH Rv8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308832; x=1721913632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yCmmBscXHr7DP5v15ZBTuTVPUGJ3/3t6QvO+9hat3Zg=; b=Lg3pYg4zqSxGO0/EPLdJ7uOG6dKZTXaEHdYBlP3j0psp/2PAwKdIEMoDxKMJS2zvzs ntytLZO9+7ui6omTxTjdAvBiOhX+iYq2JEr5BN9qLCwTvISb3BIZOD8v+etq/m8hb2Jt kzC12XhURQ7dGQvBIYtUCLboH88v/SRglXP9KrEE0ylLxCAbQOqhzFKnfmEoP3qyWolo MQG7QPvXiOxCvZW60uPFFxU6mDzG6rGWgSzyV20svRQiGW7aGT7nJKV/M2JbVAdSMnry h7/xDOX4OQw2vnok47NYl66zYfi1lxIjF3efj4avTQyq/6dn7jfiJrNutZMl2lSuRL7J odbA== X-Gm-Message-State: AOJu0YwyitLTObNa0EeFNAsa7tm4pYn7xRpg5K3m2FXoAQJXNDeUFIVG n5XGskD7Wu+a5rCPLgAA+QSydJl7zPg17RcQLYKHO6qLsjAC3apnW1ObNg8eHmdtuyIMqhdDu1L C X-Google-Smtp-Source: AGHT+IGXHxxehFhsnAbj/v7cuJHva1NVc/GuH2A/0X/pXU8X7lqr4E6BEnfn0LdDAA/p5t0ytO/+/A== X-Received: by 2002:a2e:7314:0:b0:2ee:bd1b:84c with SMTP id 38308e7fff4ca-2ef05996013mr16963951fa.0.1721308831557; Thu, 18 Jul 2024 06:20:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/26] hw/display/bcm2835_fb: fix fb_use_offsets condition Date: Thu, 18 Jul 2024 14:20:05 +0100 Message-Id: <20240718132028.697927-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x236.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308853338116600 From: SamJakob It is common practice when implementing double-buffering on VideoCore to do so by multiplying the height of the virtual buffer by the number of virtual screens desired (i.e., two - in the case of double-bufferring). At present, this won't work in QEMU because the logic in fb_use_offsets require that both the virtual width and height exceed their physical counterparts. This appears to be unintentional/a typo and indeed the comment states; "Experimentally, the hardware seems to do this only if the viewport size is larger than the physical screen". The viewport/virtual size would be larger than the physical size if either virtual dimension were larger than their physical counterparts and not necessarily both. Signed-off-by: SamJakob Message-id: 20240713160353.62410-1-me@samjakob.com Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Peter Maydell --- hw/display/bcm2835_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c index e40ed2d2e18..650db3da82c 100644 --- a/hw/display/bcm2835_fb.c +++ b/hw/display/bcm2835_fb.c @@ -145,7 +145,7 @@ static bool fb_use_offsets(BCM2835FBConfig *config) * viewport size is larger than the physical screen. (It doesn't * prevent the guest setting this silly viewport setting, though...) */ - return config->xres_virtual > config->xres && + return config->xres_virtual > config->xres || config->yres_virtual > config->yres; } =20 --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309027; cv=none; d=zohomail.com; s=zohoarc; b=mheLkIy2FL7yFq1qoP5IZ2lS5dI9GPBhwZkoyFfw/WT+BfP8rmL2x6EKK5kH9PI6/Zve4pLEPctGe9FoQ8JVagbbsSWKXI+kDKn1gALm29f0MO0xkdizDfnJIKRbZcZwIb17AeXbmrHztz+9vFPshK9CQmkmvXt1LmUN7pxzBVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309027; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=pRKxvd6QDFtj0h8zygsVf3aO3dQYQl8x7QbADWP6Qss=; b=H3JPvafaCzd8WWiLRON66pZgJF4a5PL3YLOn7nMRYo9+UZ0silwMiNSz5pVv3ntCGe1JZ5rzHAA2iU/G0vx/mLHRmrtsU0Dj4ropGuQhPy9yIPjZTp/48U2/l1lfKu2Jo192TLsnYzy/K41svPAxv9avlKVkOyMmrfM91A+MoiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172130902738840.49976509213445; Thu, 18 Jul 2024 06:23:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR42-00011e-F6; Thu, 18 Jul 2024 09:20:54 -0400 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 1sUR3l-0007tZ-4i for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 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 1sUR3h-0004Sz-JD for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:36 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4266ea6a412so2811195e9.1 for ; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308832; x=1721913632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=pRKxvd6QDFtj0h8zygsVf3aO3dQYQl8x7QbADWP6Qss=; b=EuGQ7zxgEZvNmgRmQi9XtzdcytVB1aVVs2j8fM4J7pzjrsp6EkOlQV+S22guKOWnOw nt9BKtsC+Cfh1eKb9CYM71i3RYcmm8eTP2+5uxQkoS+7obYY8z16j5W3W/nGO8JR+2DZ sFnRpW25odVfclcyWD/I+WNpm1LBnFr9EjEwlOn3ANG+R0l/bKRztzhUUXmNdOQOGgJJ YlfOQt8GbGIcmJMz82qPBEXLsMvUBySAeGnrFH8SHyW7rRKuu90ZlCdfV3TklLXIa1nV Dot02H06OWZROauNNORtNjwkMrA8JlUYPzIC7L2A+3JMtf4lbaEEmsHf4KlqUYk3/FhK Jpkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308832; x=1721913632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pRKxvd6QDFtj0h8zygsVf3aO3dQYQl8x7QbADWP6Qss=; b=mK6Hx49XzOY5GpqSDDXOKBOofa2QOmBRtXp8ccz9DYwzRdo4eqUpNLI1Zwn94u+0hr nhsRJuGadTt1enARDNPSwu5iHlhPkpJKOZJqURGXnHGJo1sbj23gs4oHgZA2BdzgN5dB x1LCIspO5gs9pqWvxTjtV6UfRI+a0AVcnLLCd9EYffjHjfccuhnuSfgojphDK4AQbYnL dtY13qNTaahA7v4g2YfnI/+na82fCFT0d6D7JZUVeKYaFJvxtF0AON0F/bhot2qqFfiG Vnbvj25WHDWzb9vbKwizw6h6DQwsUTLQ9idd6Y9OF4c85vMPbmBrPupcCtYobScWlINg kflA== X-Gm-Message-State: AOJu0YwXAEmCGa+SwHp7rdOkFJSeDY0enz12hthJT30UKHc3BoUntbcB H6KXcpIcBvdGF5ccjS0Sw3tqFuYOkxXuUw5XlG0LHTeec9dCqODYK9IHTzRNe9d9AqdXUD4o7Fe S X-Google-Smtp-Source: AGHT+IFK/uLh2Il3j2JaBwRdA+EgpU9JpU3GDyx9GRGTeteoYsJlyyydbdllWNGQpXceIfGKewqbKQ== X-Received: by 2002:a05:600c:34d0:b0:426:54c9:dfe5 with SMTP id 5b1f17b1804b1-427c2cb8c45mr35891495e9.10.1721308832049; Thu, 18 Jul 2024 06:20:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/26] hw/arm/smmu-common: Add missing size check for stage-1 Date: Thu, 18 Jul 2024 14:20:06 +0100 Message-Id: <20240718132028.697927-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=peter.maydell@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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309029029116600 From: Mostafa Saleh According to the SMMU architecture specification (ARM IHI 0070 F.b), in =E2=80=9C3.4 Address sizes=E2=80=9D The address output from the translation causes a stage 1 Address Size fault if it exceeds the range of the effective IPA size for the given C= D. However, this check was missing. There is already a similar check for stage-2 against effective PA. Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Message-id: 20240715084519.1189624-2-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmu-common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index b6601cc102e..e81b684d06c 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -381,6 +381,16 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, goto error; } =20 + /* + * The address output from the translation causes a stage 1 Address + * Size fault if it exceeds the range of the effective IPA size for + * the given CD. + */ + if (gpa >=3D (1ULL << cfg->oas)) { + info->type =3D SMMU_PTW_ERR_ADDR_SIZE; + goto error; + } + tlbe->entry.translated_addr =3D gpa; tlbe->entry.iova =3D iova & ~mask; tlbe->entry.addr_mask =3D mask; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308890; cv=none; d=zohomail.com; s=zohoarc; b=QAg50UUytvVWs7L+sG//nX+knANNqtiHs3ZWC5dLLNn9Ht5HTlWxvRaKY8hj75n8lECaQLLoHPmqPNrdX+r0psvUBlcduFcy3v6Y8Yg11gJp51iVubXCVAkq1IHdA4p8HS9ZyHZ4DRKYM7v/SWO7NQ3FX+Soc4MkW6YHKQD5gi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308890; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=v9HD9ARg19Jqe83BWvMljdXei9HAy93M0+v9flXqPJQ=; b=ZdoOMCpNsp05A7x1fWL0XcUsUvzGcXxpJC1h5B7UwmvtHlOY+Wx5/QmxJHrjVPnCnnn/yj9m4xo3XYnEM6fQ/R+7S1fbJk1UIrr9DAae/RPrTwf9wxbobfo0/UgosAnegx5p/Xs4UJPv/7bbH2llrgIX1QwM/RbMm1mmsqEIdyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308890838471.97872525978926; Thu, 18 Jul 2024 06:21:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR4A-000204-V1; Thu, 18 Jul 2024 09:21:02 -0400 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 1sUR3n-00085I-0z for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3i-0004TC-O4 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:37 -0400 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2eeb1ba0468so11465821fa.0 for ; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308832; x=1721913632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=v9HD9ARg19Jqe83BWvMljdXei9HAy93M0+v9flXqPJQ=; b=K3ooLbL/4O7X8tEWY9qor/yiDmOB/eRbguIsSJQyVYNViXHvFf39heNva1CRScgUM1 544fm+GZ+oNRDB2Vg/SAg4zsF0nm3IY/84Is79E+1+29j8d6g9rrh7rTh5W8Jv9gm3uA /LGs+lcGAr7PeFV531CuaBIf2iuv6StElHK6kKTQy7ZHgTTAtLPnZVZcNtviNZriJIoJ qKg16x54qQQnZodrbcJjNb4dOvw/5kU35Mu439YRZzNKGQLsGMGX9FJ6ajtgida51A0S MzNgT6/3eCoV3ut9gWFf8RuRTBP/dFLulfnZwFksFLXElJ71FMhgltO166vP0+7Dyj2x iXCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308832; x=1721913632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v9HD9ARg19Jqe83BWvMljdXei9HAy93M0+v9flXqPJQ=; b=UJ58N8NYEcQnq9m67QGuoM2/citDO8Ky48/3kYVhLKz981996Ieb5d/cZ6I5kKJ6CC 2E4YgHdjao97bvxm3RJsS8cEX6NOags0FSu47iYPNSJtN7l4Hhocv87AChzmEiMvvY46 8UqwNcegMdr0aDJLgZ7U5oK/d5sgdlWHHdw037a4gXFgSABvY7CbSi3+ZhsqfAqhQg/q M7CokF8Y1DFpcW20A/YT5GXl+rMyi37+zH8Sz7B3JAFJuHXAMvZkOka2p27d2o3gL3Vm 7buZuCYc6W0cWf0nhoBDdzwWfhPLfqq+DJqKWd6OcIeHReq6cFgY3va7Mzg3YhD6Sk9U MpAQ== X-Gm-Message-State: AOJu0Yx/33ARx/6W2Mh9vkQ94zNbrQTsRuZ+s88I81n5amn0+dA3KPOx 2sEeMzgifGGbWU0fZaoIhwFDq/xB6A06VnRPXMfFvOIneLA2eMjB3hsxu2+3KL8IxFltrO+v/7x h X-Google-Smtp-Source: AGHT+IH/HcLT9iXrBqLy0X+P+SJ9nmkUh/djx72ZDktpqrqSu9uqZMZXSogjepbEAm8aGLRHUF3S6w== X-Received: by 2002:a2e:a304:0:b0:2ee:8ce9:3037 with SMTP id 38308e7fff4ca-2ef05d27e3emr17883461fa.37.1721308832561; Thu, 18 Jul 2024 06:20:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/26] hw/arm/smmu: Fix IPA for stage-2 events Date: Thu, 18 Jul 2024 14:20:07 +0100 Message-Id: <20240718132028.697927-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x229.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308895641116600 From: Mostafa Saleh For the following events (ARM IHI 0070 F.b - 7.3 Event records): - F_TRANSLATION - F_ACCESS - F_PERMISSION - F_ADDR_SIZE If fault occurs at stage 2, S2 =3D=3D 1 and: - If translating an IPA for a transaction (whether by input to stage 2-only configuration, or after successful stage 1 translation), CLASS =3D=3D IN, and IPA is provided. At the moment only CLASS =3D=3D IN is used which indicates input translation. However, this was not implemented correctly, as for stage 2, the code only sets the S2 bit but not the IPA. This field has the same bits as FetchAddr in F_WALK_EABT which is populated correctly, so we don=E2=80=99t change that. The setting of this field should be done from the walker as the IPA address wouldn't be known in case of nesting. For stage 1, the spec says: If fault occurs at stage 1, S2 =3D=3D 0 and: CLASS =3D=3D IN, IPA is UNKNOWN. So, no need to set it to for stage 1, as ptw_info is initialised by zero in smmuv3_translate(). Fixes: e703f7076a =E2=80=9Chw/arm/smmuv3: Add page table walk for stage-2= =E2=80=9D Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Message-id: 20240715084519.1189624-3-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmu-common.c | 10 ++++++---- hw/arm/smmuv3.c | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index e81b684d06c..e8cdbcd8aef 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -448,7 +448,7 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, */ if (ipa >=3D (1ULL << inputsize)) { info->type =3D SMMU_PTW_ERR_TRANSLATION; - goto error; + goto error_ipa; } =20 while (level < VMSA_LEVELS) { @@ -494,13 +494,13 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, */ if (!PTE_AF(pte) && !cfg->s2cfg.affd) { info->type =3D SMMU_PTW_ERR_ACCESS; - goto error; + goto error_ipa; } =20 s2ap =3D PTE_AP(pte); if (is_permission_fault_s2(s2ap, perm)) { info->type =3D SMMU_PTW_ERR_PERMISSION; - goto error; + goto error_ipa; } =20 /* @@ -509,7 +509,7 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, */ if (gpa >=3D (1ULL << cfg->s2cfg.eff_ps)) { info->type =3D SMMU_PTW_ERR_ADDR_SIZE; - goto error; + goto error_ipa; } =20 tlbe->entry.translated_addr =3D gpa; @@ -522,6 +522,8 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, } info->type =3D SMMU_PTW_ERR_TRANSLATION; =20 +error_ipa: + info->addr =3D ipa; error: info->stage =3D 2; tlbe->entry.perm =3D IOMMU_NONE; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 445e04ddf7c..cab545a0b46 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -949,6 +949,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, if (PTW_RECORD_FAULT(cfg)) { event.type =3D SMMU_EVT_F_TRANSLATION; event.u.f_translation.addr =3D addr; + event.u.f_translation.addr2 =3D ptw_info.addr; event.u.f_translation.rnw =3D flag & 0x1; } break; @@ -956,6 +957,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, if (PTW_RECORD_FAULT(cfg)) { event.type =3D SMMU_EVT_F_ADDR_SIZE; event.u.f_addr_size.addr =3D addr; + event.u.f_addr_size.addr2 =3D ptw_info.addr; event.u.f_addr_size.rnw =3D flag & 0x1; } break; @@ -963,6 +965,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, if (PTW_RECORD_FAULT(cfg)) { event.type =3D SMMU_EVT_F_ACCESS; event.u.f_access.addr =3D addr; + event.u.f_access.addr2 =3D ptw_info.addr; event.u.f_access.rnw =3D flag & 0x1; } break; @@ -970,6 +973,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, if (PTW_RECORD_FAULT(cfg)) { event.type =3D SMMU_EVT_F_PERMISSION; event.u.f_permission.addr =3D addr; + event.u.f_permission.addr2 =3D ptw_info.addr; event.u.f_permission.rnw =3D flag & 0x1; } break; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309023; cv=none; d=zohomail.com; s=zohoarc; b=V9oW+lqbjntry2IcISrD0YyK10tPYgNuBXeXHXBioHvatZ8Xi78RQBknv5C3zFkO6Sm+zR6/+MbgJ7PmjW8cASC/RXuj6OvwQVFqkcQMSA7x9wYISPpDPfF4jbW/EqWXbLv5qKruNvigZ79OWosoLHHy15BXyN+Qn6+rCPUVOHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309023; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=7RaBXCOatE5DqPcmVv9n/BxPiIh3u0gJg6RupfAUz/Y=; b=n3/+TD8c76KEF+8ujXya8N9f4zVuG4/NQrEW6zBLqAECGeEH8uj952WxkSjsMuK7f29xfwNi8s1ChOAJnYz6vS1E9eZ1l7fZXsslXIUH2Y3xaVMtQGOrPC5d1V8es3Y5hWL5Fe/OrRU6xLdSbQdnT/mTOOybePIjX1FGEkCzwxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309023906941.8223739539595; Thu, 18 Jul 2024 06:23:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR42-000101-CF; Thu, 18 Jul 2024 09:20:54 -0400 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 1sUR3n-00085N-13 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3i-0004TN-Q2 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-367963ea053so635843f8f.2 for ; Thu, 18 Jul 2024 06:20:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308833; x=1721913633; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7RaBXCOatE5DqPcmVv9n/BxPiIh3u0gJg6RupfAUz/Y=; b=Kk43L181VuZsiZo8pvVkUChCn6cNWdSvy7CgBhw6lgNcJQ9VXBik3JKgdhlpdOV4LH 1bK8rdbg7A+A79LfJDrvRIjzfO79AB1rfqaK+1U8AwUHCmrxH/bzBMHNJmpRIb+DYFEg 4zROykzcTCcDVNR0l8pGyCKrmj2X4LaU0UxJ6AjwM6yugjZyOluGJGefQNmcX5u9Atti fMJgHCz88PwuUHB9vGv8RtUEISeExuaLxNJve0A108R500MwD77w8o5z4okZgTDNyZYw Xe65kt/LDTI8Ckfrg6bYM1zS0v0Rpjc6Zd6BvxwEBGg5WxdO/Y3Y4rC0nZWyXE/fGm6A j0Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308833; x=1721913633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7RaBXCOatE5DqPcmVv9n/BxPiIh3u0gJg6RupfAUz/Y=; b=A46EYN4pwV2pHeEcugItIEpfXDIS6mzGTJBgf31bbzA7plzNbvQxuCwD587bJOU/eJ wYDhw6a16Di95CifMJBOgD+y6kVCFeyoLvjQyD2rNXQQ/Yzy3ytAQaSLqli+R6u+SzFn F7Eu+ZNlbnFet1SFvQYd7JeA7sCnPZvJ4zW+jUS6s4hNPt0+veFEFPBxLCvOivp16lpf ME7aukv0XdXVfsJL7MEJ5KIyuAO0XQuXxc+xQpVnKF6AvIp5DjKQQ231/pRclhyIcfwl ZqGxXn0S2rzQA8h4SMGiknYm3CkNw52ZZ446JKXl7rbK4ligG5nxggDdAfLs1ECHISPQ GM1w== X-Gm-Message-State: AOJu0YznSyX5ZyYZxACiCn/MuGbyNxYmeqyQ93Aqf+KSUPhOUPj8Wuac Z/kQwvnW3RRc+7tayWZ9NHwloGN/3xhX8r5S+p5qjiyBNb5iUbebpkb8CTgYJvxdXA5EHhhDNfO d X-Google-Smtp-Source: AGHT+IF095s4kL8Xk0D/LvYekwMlrugXWXpfrQRz9NQ4DLrk92WvMzfrt22TW6intW8K3ETk6/yd/g== X-Received: by 2002:adf:e9cb:0:b0:368:4489:8efb with SMTP id ffacd0b85a97d-368448990bamr2837952f8f.40.1721308833041; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/26] hw/arm/smmuv3: Fix encoding of CLASS in events Date: Thu, 18 Jul 2024 14:20:08 +0100 Message-Id: <20240718132028.697927-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309025086116600 From: Mostafa Saleh The SMMUv3 spec (ARM IHI 0070 F.b - 7.3 Event records) defines the class of events faults as: CLASS: The class of the operation that caused the fault: - 0b00: CD, CD fetch. - 0b01: TTD, Stage 1 translation table fetch. - 0b10: IN, Input address However, this value was not set and left as 0 which means CD and not IN (0b10). Another problem was that stage-2 class is considered IN not TT for EABT, according to the spec: Translation of an IPA after successful stage 1 translation (or, in stage 2-only configuration, an input IPA) - S2 =3D=3D 1 (stage 2), CLASS =3D=3D IN (Input to stage) This would change soon when nested translations are supported. While at it, add an enum for class as it would be used for nesting. However, at the moment stage-1 and stage-2 use the same class values, except for EABT. Fixes: 9bde7f0674 =E2=80=9Chw/arm/smmuv3: Implement translate callback=E2= =80=9D Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Message-id: 20240715084519.1189624-4-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3-internal.h | 6 ++++++ hw/arm/smmuv3.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index e4dd11e1e62..0f3ecec804d 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -32,6 +32,12 @@ typedef enum SMMUTranslationStatus { SMMU_TRANS_SUCCESS, } SMMUTranslationStatus; =20 +typedef enum SMMUTranslationClass { + SMMU_CLASS_CD, + SMMU_CLASS_TT, + SMMU_CLASS_IN, +} SMMUTranslationClass; + /* MMIO Registers */ =20 REG32(IDR0, 0x0) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index cab545a0b46..472fdf2e5fd 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -942,7 +942,9 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.type =3D SMMU_EVT_F_WALK_EABT; event.u.f_walk_eabt.addr =3D addr; event.u.f_walk_eabt.rnw =3D flag & 0x1; - event.u.f_walk_eabt.class =3D 0x1; + /* Stage-2 (only) is class IN while stage-1 is class TT */ + event.u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D 2) ? + SMMU_CLASS_IN : SMMU_CLASS_TT; event.u.f_walk_eabt.addr2 =3D ptw_info.addr; break; case SMMU_PTW_ERR_TRANSLATION: @@ -950,6 +952,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.type =3D SMMU_EVT_F_TRANSLATION; event.u.f_translation.addr =3D addr; event.u.f_translation.addr2 =3D ptw_info.addr; + event.u.f_translation.class =3D SMMU_CLASS_IN; event.u.f_translation.rnw =3D flag & 0x1; } break; @@ -958,6 +961,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.type =3D SMMU_EVT_F_ADDR_SIZE; event.u.f_addr_size.addr =3D addr; event.u.f_addr_size.addr2 =3D ptw_info.addr; + event.u.f_translation.class =3D SMMU_CLASS_IN; event.u.f_addr_size.rnw =3D flag & 0x1; } break; @@ -966,6 +970,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.type =3D SMMU_EVT_F_ACCESS; event.u.f_access.addr =3D addr; event.u.f_access.addr2 =3D ptw_info.addr; + event.u.f_translation.class =3D SMMU_CLASS_IN; event.u.f_access.rnw =3D flag & 0x1; } break; @@ -974,6 +979,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.type =3D SMMU_EVT_F_PERMISSION; event.u.f_permission.addr =3D addr; event.u.f_permission.addr2 =3D ptw_info.addr; + event.u.f_translation.class =3D SMMU_CLASS_IN; event.u.f_permission.rnw =3D flag & 0x1; } break; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308985; cv=none; d=zohomail.com; s=zohoarc; b=ZBe4+QOBwB0ie/PtRcrin8ZR6HU9cJE1SzTVx2N5MGEgfxB5Drmrnhr8wjYNwhBf6kY/uml3zyCUTl3qNlxFQUFPdc6en8vokpjIbg1pNQmjA3B0CTFdoCvHBpYJ78SQBxLU2OeUgrUi9GfWkKd3Xl1N4hVSPFi0ynDDzd18fj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308985; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=jDUV0xWI972uNTpKqh58Pmu4q+0S5yiM8R6kVw2B+/k=; b=AwtMx1rDQHGzopYGfI8FjShEBkR64/Qhwij33NZI1RreqAWHQVY/qmmbI50j/hT3nC5w29kJE3oAkn9CDizeC+C9cyOW0pLDf7JLTh+X8G8581XzjcloYwwAY5MzmQnpr9Wn5ISKp8BM+DF/wwQXWXz/cNKoiNuT/7zqld7MbY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308985938709.211584095972; Thu, 18 Jul 2024 06:23:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3x-0000Km-Mv; Thu, 18 Jul 2024 09:20:49 -0400 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 1sUR3n-00085O-1O for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3j-0004TU-6T for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4266f344091so2728235e9.0 for ; Thu, 18 Jul 2024 06:20:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308834; x=1721913634; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jDUV0xWI972uNTpKqh58Pmu4q+0S5yiM8R6kVw2B+/k=; b=Ya4BdNngX9na7znvUoFDY82iLmuMRYnap7+j6OLULKPfySR6nA6NNmgSRsfp3FFjFl +bVbxkrVtkyk44eCCrftXCUQqPGXZqCQYJuWQW2RP74woW2KJYvlwdJAT19KOqDdQhh5 tbeqSSPSQtjDIwKOa/r+h/W0WokKT0GdScNLFYEhJas7dSuuZe87BxkHbR1PpEkhh3IA ijwuXc3a69IORyqM2mjucVl6Yr+XaGtg0/jFJ3Zf/5w7E4mOLIAZmOit+zSrY/nd3hR3 nNgjhwPrIm3couW1t22e6VynLdGWGTi2laiHStSgl6G5d4JgfYkSpDT5HOZAk7i9/n5n PKmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308834; x=1721913634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jDUV0xWI972uNTpKqh58Pmu4q+0S5yiM8R6kVw2B+/k=; b=HH4Z6G+pIN0JVXj7LFqJLkRWV7VJljSBTBwyGNTAHIdsZGuedb8AvnLmPkhkwryIdJ 8CIIjaFIsvId/aIED1bbtillcAIMvPUgE60UbS8a4ZRbwzQQQvTVFRlyLg1Gl4Q2RGZz dIxS2G7LfPIak+EzmuB50L1YbVjzBm6VshvhdCzXIMJGQz44bxX8Le40NMNdIqMmTYTs tCgA/SOKuYK6pS8++XQVsh9MUAgkE0LrIqH8foD6E9ICBukNpnhQO+Emlotk9nthsFhc CSA5FyPT6H0g6t0ORzQ+35WsCfechQhjnlrNlg4AQHfjA2g/1xZEe3uq5715YhlLE7FY H++Q== X-Gm-Message-State: AOJu0YyWCdm/sTJSVxRTGYU3a5bMvbNexHd5fxJaU40kyQRNTD0tV2ER 1XfQF4Tg6Uvrbof84WBmPdBvNNiCJUrmHPm4LAXhyN5+Xq6tm6WfRJzqKYvQR4k9WqUSzm7ndqA V X-Google-Smtp-Source: AGHT+IHtzMh3nhU8SWgJqnlfEDdTvDKMOvnuhcVkSbB0XF7iUMyUcedW+99JdTGV2suMDpNcuBJigg== X-Received: by 2002:a05:600c:1d8b:b0:426:5e1c:1ad0 with SMTP id 5b1f17b1804b1-427c2d00164mr31993905e9.37.1721308833658; Thu, 18 Jul 2024 06:20:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/26] hw/arm/smmu: Use enum for SMMU stage Date: Thu, 18 Jul 2024 14:20:09 +0100 Message-Id: <20240718132028.697927-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308986936116600 From: Mostafa Saleh Currently, translation stage is represented as an int, where 1 is stage-1 a= nd 2 is stage-2, when nested is added, 3 would be confusing to represent nesti= ng, so we use an enum instead. While keeping the same values, this is useful for: - Doing tricks with bit masks, where BIT(0) is stage-1 and BIT(1) is stage-2 and both is nested. - Tracing, as stage is printed as int. Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Message-id: 20240715084519.1189624-5-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 11 +++++++++-- hw/arm/smmu-common.c | 14 +++++++------- hw/arm/smmuv3.c | 17 +++++++++-------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 687b7ca132d..260582089e0 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -49,8 +49,15 @@ typedef enum { SMMU_PTW_ERR_PERMISSION, /* Permission fault */ } SMMUPTWEventType; =20 +/* SMMU Stage */ +typedef enum { + SMMU_STAGE_1 =3D 1, + SMMU_STAGE_2, + SMMU_NESTED, +} SMMUStage; + typedef struct SMMUPTWEventInfo { - int stage; + SMMUStage stage; SMMUPTWEventType type; dma_addr_t addr; /* fetched address that induced an abort, if any */ } SMMUPTWEventInfo; @@ -88,7 +95,7 @@ typedef struct SMMUS2Cfg { */ typedef struct SMMUTransCfg { /* Shared fields between stage-1 and stage-2. */ - int stage; /* translation stage */ + SMMUStage stage; /* translation stage */ bool disabled; /* smmu is disabled */ bool bypassed; /* translation is bypassed */ bool aborted; /* translation is aborted */ diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index e8cdbcd8aef..408fc4efcae 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -304,7 +304,7 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) { dma_addr_t baseaddr, indexmask; - int stage =3D cfg->stage; + SMMUStage stage =3D cfg->stage; SMMUTransTableInfo *tt =3D select_tt(cfg, iova); uint8_t level, granule_sz, inputsize, stride; =20 @@ -402,7 +402,7 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, info->type =3D SMMU_PTW_ERR_TRANSLATION; =20 error: - info->stage =3D 1; + info->stage =3D SMMU_STAGE_1; tlbe->entry.perm =3D IOMMU_NONE; return -EINVAL; } @@ -425,7 +425,7 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, dma_addr_t ipa, IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) { - const int stage =3D 2; + const SMMUStage stage =3D SMMU_STAGE_2; int granule_sz =3D cfg->s2cfg.granule_sz; /* ARM DDI0487I.a: Table D8-7. */ int inputsize =3D 64 - cfg->s2cfg.tsz; @@ -525,7 +525,7 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, error_ipa: info->addr =3D ipa; error: - info->stage =3D 2; + info->stage =3D SMMU_STAGE_2; tlbe->entry.perm =3D IOMMU_NONE; return -EINVAL; } @@ -544,9 +544,9 @@ error: int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) { - if (cfg->stage =3D=3D 1) { + if (cfg->stage =3D=3D SMMU_STAGE_1) { return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info); - } else if (cfg->stage =3D=3D 2) { + } else if (cfg->stage =3D=3D SMMU_STAGE_2) { /* * If bypassing stage 1(or unimplemented), the input address is pa= ssed * directly to stage 2 as IPA. If the input address of a transacti= on @@ -555,7 +555,7 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUA= ccessFlags perm, */ if (iova >=3D (1ULL << cfg->oas)) { info->type =3D SMMU_PTW_ERR_ADDR_SIZE; - info->stage =3D 1; + info->stage =3D SMMU_STAGE_1; tlbe->entry.perm =3D IOMMU_NONE; return -EINVAL; } diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 472fdf2e5fd..aab09df23ec 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -34,7 +34,8 @@ #include "smmuv3-internal.h" #include "smmu-internal.h" =20 -#define PTW_RECORD_FAULT(cfg) (((cfg)->stage =3D=3D 1) ? (cfg)->record_f= aults : \ +#define PTW_RECORD_FAULT(cfg) (((cfg)->stage =3D=3D SMMU_STAGE_1) ? \ + (cfg)->record_faults : \ (cfg)->s2cfg.record_faults) =20 /** @@ -402,7 +403,7 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8_= t t0sz, uint8_t gran) =20 static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) { - cfg->stage =3D 2; + cfg->stage =3D SMMU_STAGE_2; =20 if (STE_S2AA64(ste) =3D=3D 0x0) { qemu_log_mask(LOG_UNIMP, @@ -678,7 +679,7 @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEve= ntInfo *event) =20 /* we support only those at the moment */ cfg->aa64 =3D true; - cfg->stage =3D 1; + cfg->stage =3D SMMU_STAGE_1; =20 cfg->oas =3D oas2bits(CD_IPS(cd)); cfg->oas =3D MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); @@ -762,7 +763,7 @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, = SMMUTransCfg *cfg, return ret; } =20 - if (cfg->aborted || cfg->bypassed || (cfg->stage =3D=3D 2)) { + if (cfg->aborted || cfg->bypassed || (cfg->stage =3D=3D SMMU_STAGE_2))= { return 0; } =20 @@ -882,7 +883,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, goto epilogue; } =20 - if (cfg->stage =3D=3D 1) { + if (cfg->stage =3D=3D SMMU_STAGE_1) { /* Select stage1 translation table. */ tt =3D select_tt(cfg, addr); if (!tt) { @@ -919,7 +920,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, * nesting is not supported. So it is sufficient to check the * translation stage to know the TLB stage for now. */ - event.u.f_walk_eabt.s2 =3D (cfg->stage =3D=3D 2); + event.u.f_walk_eabt.s2 =3D (cfg->stage =3D=3D SMMU_STAGE_2); if (PTW_RECORD_FAULT(cfg)) { event.type =3D SMMU_EVT_F_PERMISSION; event.u.f_permission.addr =3D addr; @@ -935,7 +936,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, =20 if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) { /* All faults from PTW has S2 field. */ - event.u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D 2); + event.u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D SMMU_STAGE_2); g_free(cached_entry); switch (ptw_info.type) { case SMMU_PTW_ERR_WALK_EABT: @@ -943,7 +944,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion= *mr, hwaddr addr, event.u.f_walk_eabt.addr =3D addr; event.u.f_walk_eabt.rnw =3D flag & 0x1; /* Stage-2 (only) is class IN while stage-1 is class TT */ - event.u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D 2) ? + event.u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D SMMU_STAG= E_2) ? SMMU_CLASS_IN : SMMU_CLASS_TT; event.u.f_walk_eabt.addr2 =3D ptw_info.addr; break; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308998; cv=none; d=zohomail.com; s=zohoarc; b=H1Gnz2TJpGuTwTf090n7Q1ckNwB11Bbssmd7c4NfKCSxgPMizrvymBVk48nm/q5ZqFXZYgVRXppl/i45IlpUQheQD3Gd48V9N381IPhWE/Ps2thxlCCtiwY0rNYim7l+RTf5y6WLGOcYgqExBKh5Qj2WcqKZhh7kKQDWKaFOo7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308998; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ooY44phW/Xou/7sIWqHum0Y8AK3FNuRlgo65/WUB5WM=; b=R0iEFPVybpp1WFHrPT7Kfrur5RKTRNfSE+4vbAO91CPSfxYiOnq46hCEfkJIXNewDGwVg7pynOBgKSLrZTUTXSHy+0sD7/exxBEREIUF+yRFmwfzySF7FGC+m1hX9idTAMehK/SJhJyRwbWHVatQKTAXF7PBuKMxVbdDyU0w7Kg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308997939620.9227246650662; Thu, 18 Jul 2024 06:23:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR46-0001Ur-Hx; Thu, 18 Jul 2024 09:20:58 -0400 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 1sUR3n-0008A4-Sc for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3k-0004Ta-QH for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:39 -0400 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-52ed741fe46so496968e87.0 for ; Thu, 18 Jul 2024 06:20:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308834; x=1721913634; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ooY44phW/Xou/7sIWqHum0Y8AK3FNuRlgo65/WUB5WM=; b=dAbKMC1rJ1zYJKPS3Fl6jOHfrZBfpVQeOoP13piocGPftT0DkbC7xzVabJzi6IABOX bqRJHwXeG2PS4Vlb8/dG/CZNG4JKaVlg/3+AIUPPFZbYu0ESfy0hiQIT9swLq9Zkfo9X 95o4ZAp42K8x4i5mmyxQ+8ggXTUYeoyT25OsYue4jnmcpxTF5du73zEWrH1qLSKF1i32 uADdqDFlYo+MgX9E9NWvtqw+gISGKWRcAxlU613nbwoOFqR4rsM1T8IJg0yHYraiRXsH fHv/jTORTXZqS0k2UpSh4G1GiJohjmdvTwtK3VIyPgfA3wOV+Ova22xddWzFvlYFn2lG x8yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308834; x=1721913634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ooY44phW/Xou/7sIWqHum0Y8AK3FNuRlgo65/WUB5WM=; b=PC2eItK2SCGZu+cmjRenYbFLGvDBmBT5gc7G0ewCOWAjGLTROQ1pFDw7XxV5H846Hi IIrLADRW5jW5gMBCUR6v/DUs5kG3OqItI7cNatoX0i4MSJFH5X75NU46QE7NOP5W0exg Crrh2uToKSLdKluy+FLXJHhNdmAb3+SgiwrYp5dDShI0x082/DOhQqCeNlhb7yuvhzDc EJBpAeAk9VpfJC6yeASjpA7emHWw8CCcdiO+xnEUD8UQ8ZSFw8ettwnrOCstQjQsi0C1 qHS/vnO1fQsl3md+lNKeT5zd/qrLIqRiQZcTbrQtWnWh2vWp/+iFpMvUcg80ZkyfbRp6 U6cQ== X-Gm-Message-State: AOJu0YwKqQcpzwWx+CsCeFIvfngSLlGrUPvgcy0muKI9VUSjb735AKfQ /DA+X1AqbgEPbK3k90hB0J51T4ER5o9gP+6fcuNk0djTp3UhgJNJZsLMzb5dO5YzVik56dk/Ryw K X-Google-Smtp-Source: AGHT+IFkNvmSykyl2OZkhyBhFZ88zyF2DWZp0k9wrKTcabmUWXbvsOFAQl719FFSOWJ89SPn1ZGRJg== X-Received: by 2002:a05:6512:280c:b0:52e:764b:b20d with SMTP id 2adb3069b0e04-52ee53dbc96mr3755344e87.28.1721308834151; Thu, 18 Jul 2024 06:20:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/26] hw/arm/smmu: Split smmuv3_translate() Date: Thu, 18 Jul 2024 14:20:10 +0100 Message-Id: <20240718132028.697927-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12a; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12a.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308999246116600 From: Mostafa Saleh smmuv3_translate() does everything from STE/CD parsing to TLB lookup and PTW. Soon, when nesting is supported, stage-1 data (tt, CD) needs to be translated using stage-2. Split smmuv3_translate() to 3 functions: - smmu_translate(): in smmu-common.c, which does the TLB lookup, PTW, TLB insertion, all the functions are already there, this just puts them together. This also simplifies the code as it consolidates event generation in case of TLB lookup permission failure or in TT selection. - smmuv3_do_translate(): in smmuv3.c, Calls smmu_translate() and does the event population in case of errors. - smmuv3_translate(), now calls smmuv3_do_translate() for translation while the rest is the same. Also, add stage in trace_smmuv3_translate_success() Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-6-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 8 ++ hw/arm/smmu-common.c | 59 +++++++++++ hw/arm/smmuv3.c | 194 +++++++++++++---------------------- hw/arm/trace-events | 2 +- 4 files changed, 142 insertions(+), 121 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 260582089e0..366b53be778 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -183,6 +183,14 @@ static inline uint16_t smmu_get_sid(SMMUDevice *sdev) int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info); =20 + +/* + * smmu_translate - Look for a translation in TLB, if not, do a PTW. + * Returns NULL on PTW error or incase of TLB permission errors. + */ +SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t = addr, + IOMMUAccessFlags flag, SMMUPTWEventInfo *info= ); + /** * select_tt - compute which translation table shall be used according to * the input iova and translation config and return the TT specific info diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 408fc4efcae..8d52472863b 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -566,6 +566,65 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMU= AccessFlags perm, g_assert_not_reached(); } =20 +SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t = addr, + IOMMUAccessFlags flag, SMMUPTWEventInfo *info) +{ + uint64_t page_mask, aligned_addr; + SMMUTLBEntry *cached_entry =3D NULL; + SMMUTransTableInfo *tt; + int status; + + /* + * Combined attributes used for TLB lookup, as only one stage is suppo= rted, + * it will hold attributes based on the enabled stage. + */ + SMMUTransTableInfo tt_combined; + + if (cfg->stage =3D=3D SMMU_STAGE_1) { + /* Select stage1 translation table. */ + tt =3D select_tt(cfg, addr); + if (!tt) { + info->type =3D SMMU_PTW_ERR_TRANSLATION; + info->stage =3D SMMU_STAGE_1; + return NULL; + } + tt_combined.granule_sz =3D tt->granule_sz; + tt_combined.tsz =3D tt->tsz; + + } else { + /* Stage2. */ + tt_combined.granule_sz =3D cfg->s2cfg.granule_sz; + tt_combined.tsz =3D cfg->s2cfg.tsz; + } + + /* + * TLB lookup looks for granule and input size for a translation stage, + * as only one stage is supported right now, choose the right values + * from the configuration. + */ + page_mask =3D (1ULL << tt_combined.granule_sz) - 1; + aligned_addr =3D addr & ~page_mask; + + cached_entry =3D smmu_iotlb_lookup(bs, cfg, &tt_combined, aligned_addr= ); + if (cached_entry) { + if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { + info->type =3D SMMU_PTW_ERR_PERMISSION; + info->stage =3D cfg->stage; + return NULL; + } + return cached_entry; + } + + cached_entry =3D g_new0(SMMUTLBEntry, 1); + status =3D smmu_ptw(cfg, aligned_addr, flag, cached_entry, info); + if (status) { + g_free(cached_entry); + return NULL; + } + smmu_iotlb_insert(bs, cfg, cached_entry); + return cached_entry; +} + /** * The bus number is used for lookup when SID based invalidation occurs. * In that case we lazily populate the SMMUPciBus array from the bus hash diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index aab09df23ec..76d9969c93e 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -827,6 +827,76 @@ static void smmuv3_flush_config(SMMUDevice *sdev) g_hash_table_remove(bc->configs, sdev); } =20 +/* Do translation with TLB lookup. */ +static SMMUTranslationStatus smmuv3_do_translate(SMMUv3State *s, hwaddr ad= dr, + SMMUTransCfg *cfg, + SMMUEventInfo *event, + IOMMUAccessFlags flag, + SMMUTLBEntry **out_entry) +{ + SMMUPTWEventInfo ptw_info =3D {}; + SMMUState *bs =3D ARM_SMMU(s); + SMMUTLBEntry *cached_entry =3D NULL; + + cached_entry =3D smmu_translate(bs, cfg, addr, flag, &ptw_info); + if (!cached_entry) { + /* All faults from PTW has S2 field. */ + event->u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D SMMU_STAGE_2); + switch (ptw_info.type) { + case SMMU_PTW_ERR_WALK_EABT: + event->type =3D SMMU_EVT_F_WALK_EABT; + event->u.f_walk_eabt.addr =3D addr; + event->u.f_walk_eabt.rnw =3D flag & 0x1; + event->u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D SMMU_STA= GE_2) ? + SMMU_CLASS_IN : SMMU_CLASS_TT; + event->u.f_walk_eabt.addr2 =3D ptw_info.addr; + break; + case SMMU_PTW_ERR_TRANSLATION: + if (PTW_RECORD_FAULT(cfg)) { + event->type =3D SMMU_EVT_F_TRANSLATION; + event->u.f_translation.addr =3D addr; + event->u.f_translation.addr2 =3D ptw_info.addr; + event->u.f_translation.class =3D SMMU_CLASS_IN; + event->u.f_translation.rnw =3D flag & 0x1; + } + break; + case SMMU_PTW_ERR_ADDR_SIZE: + if (PTW_RECORD_FAULT(cfg)) { + event->type =3D SMMU_EVT_F_ADDR_SIZE; + event->u.f_addr_size.addr =3D addr; + event->u.f_addr_size.addr2 =3D ptw_info.addr; + event->u.f_addr_size.class =3D SMMU_CLASS_IN; + event->u.f_addr_size.rnw =3D flag & 0x1; + } + break; + case SMMU_PTW_ERR_ACCESS: + if (PTW_RECORD_FAULT(cfg)) { + event->type =3D SMMU_EVT_F_ACCESS; + event->u.f_access.addr =3D addr; + event->u.f_access.addr2 =3D ptw_info.addr; + event->u.f_access.class =3D SMMU_CLASS_IN; + event->u.f_access.rnw =3D flag & 0x1; + } + break; + case SMMU_PTW_ERR_PERMISSION: + if (PTW_RECORD_FAULT(cfg)) { + event->type =3D SMMU_EVT_F_PERMISSION; + event->u.f_permission.addr =3D addr; + event->u.f_permission.addr2 =3D ptw_info.addr; + event->u.f_permission.class =3D SMMU_CLASS_IN; + event->u.f_permission.rnw =3D flag & 0x1; + } + break; + default: + g_assert_not_reached(); + } + return SMMU_TRANS_ERROR; + } + *out_entry =3D cached_entry; + return SMMU_TRANS_SUCCESS; +} + +/* Entry point to SMMU, does everything. */ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, IOMMUAccessFlags flag, int iommu_idx) { @@ -836,12 +906,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegio= n *mr, hwaddr addr, SMMUEventInfo event =3D {.type =3D SMMU_EVT_NONE, .sid =3D sid, .inval_ste_allowed =3D false}; - SMMUPTWEventInfo ptw_info =3D {}; SMMUTranslationStatus status; - SMMUState *bs =3D ARM_SMMU(s); - uint64_t page_mask, aligned_addr; - SMMUTLBEntry *cached_entry =3D NULL; - SMMUTransTableInfo *tt; SMMUTransCfg *cfg =3D NULL; IOMMUTLBEntry entry =3D { .target_as =3D &address_space_memory, @@ -850,11 +915,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegio= n *mr, hwaddr addr, .addr_mask =3D ~(hwaddr)0, .perm =3D IOMMU_NONE, }; - /* - * Combined attributes used for TLB lookup, as only one stage is suppo= rted, - * it will hold attributes based on the enabled stage. - */ - SMMUTransTableInfo tt_combined; + SMMUTLBEntry *cached_entry =3D NULL; =20 qemu_mutex_lock(&s->mutex); =20 @@ -883,115 +944,7 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegi= on *mr, hwaddr addr, goto epilogue; } =20 - if (cfg->stage =3D=3D SMMU_STAGE_1) { - /* Select stage1 translation table. */ - tt =3D select_tt(cfg, addr); - if (!tt) { - if (cfg->record_faults) { - event.type =3D SMMU_EVT_F_TRANSLATION; - event.u.f_translation.addr =3D addr; - event.u.f_translation.rnw =3D flag & 0x1; - } - status =3D SMMU_TRANS_ERROR; - goto epilogue; - } - tt_combined.granule_sz =3D tt->granule_sz; - tt_combined.tsz =3D tt->tsz; - - } else { - /* Stage2. */ - tt_combined.granule_sz =3D cfg->s2cfg.granule_sz; - tt_combined.tsz =3D cfg->s2cfg.tsz; - } - /* - * TLB lookup looks for granule and input size for a translation stage, - * as only one stage is supported right now, choose the right values - * from the configuration. - */ - page_mask =3D (1ULL << tt_combined.granule_sz) - 1; - aligned_addr =3D addr & ~page_mask; - - cached_entry =3D smmu_iotlb_lookup(bs, cfg, &tt_combined, aligned_addr= ); - if (cached_entry) { - if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { - status =3D SMMU_TRANS_ERROR; - /* - * We know that the TLB only contains either stage-1 or stage-= 2 as - * nesting is not supported. So it is sufficient to check the - * translation stage to know the TLB stage for now. - */ - event.u.f_walk_eabt.s2 =3D (cfg->stage =3D=3D SMMU_STAGE_2); - if (PTW_RECORD_FAULT(cfg)) { - event.type =3D SMMU_EVT_F_PERMISSION; - event.u.f_permission.addr =3D addr; - event.u.f_permission.rnw =3D flag & 0x1; - } - } else { - status =3D SMMU_TRANS_SUCCESS; - } - goto epilogue; - } - - cached_entry =3D g_new0(SMMUTLBEntry, 1); - - if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) { - /* All faults from PTW has S2 field. */ - event.u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D SMMU_STAGE_2); - g_free(cached_entry); - switch (ptw_info.type) { - case SMMU_PTW_ERR_WALK_EABT: - event.type =3D SMMU_EVT_F_WALK_EABT; - event.u.f_walk_eabt.addr =3D addr; - event.u.f_walk_eabt.rnw =3D flag & 0x1; - /* Stage-2 (only) is class IN while stage-1 is class TT */ - event.u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D SMMU_STAG= E_2) ? - SMMU_CLASS_IN : SMMU_CLASS_TT; - event.u.f_walk_eabt.addr2 =3D ptw_info.addr; - break; - case SMMU_PTW_ERR_TRANSLATION: - if (PTW_RECORD_FAULT(cfg)) { - event.type =3D SMMU_EVT_F_TRANSLATION; - event.u.f_translation.addr =3D addr; - event.u.f_translation.addr2 =3D ptw_info.addr; - event.u.f_translation.class =3D SMMU_CLASS_IN; - event.u.f_translation.rnw =3D flag & 0x1; - } - break; - case SMMU_PTW_ERR_ADDR_SIZE: - if (PTW_RECORD_FAULT(cfg)) { - event.type =3D SMMU_EVT_F_ADDR_SIZE; - event.u.f_addr_size.addr =3D addr; - event.u.f_addr_size.addr2 =3D ptw_info.addr; - event.u.f_translation.class =3D SMMU_CLASS_IN; - event.u.f_addr_size.rnw =3D flag & 0x1; - } - break; - case SMMU_PTW_ERR_ACCESS: - if (PTW_RECORD_FAULT(cfg)) { - event.type =3D SMMU_EVT_F_ACCESS; - event.u.f_access.addr =3D addr; - event.u.f_access.addr2 =3D ptw_info.addr; - event.u.f_translation.class =3D SMMU_CLASS_IN; - event.u.f_access.rnw =3D flag & 0x1; - } - break; - case SMMU_PTW_ERR_PERMISSION: - if (PTW_RECORD_FAULT(cfg)) { - event.type =3D SMMU_EVT_F_PERMISSION; - event.u.f_permission.addr =3D addr; - event.u.f_permission.addr2 =3D ptw_info.addr; - event.u.f_translation.class =3D SMMU_CLASS_IN; - event.u.f_permission.rnw =3D flag & 0x1; - } - break; - default: - g_assert_not_reached(); - } - status =3D SMMU_TRANS_ERROR; - } else { - smmu_iotlb_insert(bs, cfg, cached_entry); - status =3D SMMU_TRANS_SUCCESS; - } + status =3D smmuv3_do_translate(s, addr, cfg, &event, flag, &cached_ent= ry); =20 epilogue: qemu_mutex_unlock(&s->mutex); @@ -1002,7 +955,8 @@ epilogue: (addr & cached_entry->entry.addr_mask); entry.addr_mask =3D cached_entry->entry.addr_mask; trace_smmuv3_translate_success(mr->parent_obj.name, sid, addr, - entry.translated_addr, entry.perm); + entry.translated_addr, entry.perm, + cfg->stage); break; case SMMU_TRANS_DISABLE: entry.perm =3D flag; diff --git a/hw/arm/trace-events b/hw/arm/trace-events index f1a54a02dfc..cc12924a84a 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -37,7 +37,7 @@ smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool = is_write) "%s sid=3D0x%x bypass (smmu disabled) iova:0x%"PRIx64" is_write= =3D%d" smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool i= s_write) "%s sid=3D0x%x STE bypass iova:0x%"PRIx64" is_write=3D%d" smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is= _write) "%s sid=3D0x%x abort on iova:0x%"PRIx64" is_write=3D%d" -smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint6= 4_t translated, int perm) "%s sid=3D0x%x iova=3D0x%"PRIx64" translated=3D0x= %"PRIx64" perm=3D0x%x" +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint6= 4_t translated, int perm, int stage) "%s sid=3D0x%x iova=3D0x%"PRIx64" tran= slated=3D0x%"PRIx64" perm=3D0x%x stage=3D%d" smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 smmuv3_decode_cd(uint32_t oas) "oas=3D%d" smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz= , bool had) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d had:%d" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308988; cv=none; d=zohomail.com; s=zohoarc; b=TgyLbgYXjw6K319Nr36Jh0aPEwOjAKnjf9AJA4MLMZJdQMHowgHZNyrpta1+zpy4NYpss48vCLzGyjWa5/X+JLViyDRjPBcEN6pPsYAO0kaApJ01R7N8p00P/1dwrBLtzPK6b1ANhqda5qjbHNhe33OuNAnheCga9Ubjd78NG28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308988; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=fQR13XT9VDhcBY8spm2JM5I6IhE7k7yNucwEDGm4s9I=; b=JW/BtWGREIsvaw8zg3wl4MDv42ccntgNcLajGUaGGWCmTuTC05HAVAwi6riwZDy+baJ/SrXu68hS85hLvFXXiexOQuipp2KBeZYBMLPu+26T3tHXby0ieVdqJFlidhiIE7FBk2pb3YGq0yU3cmANBRCj7iloE7gjpIBMhMxpUh0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308988589559.2474725999639; Thu, 18 Jul 2024 06:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3z-0000hq-6R; Thu, 18 Jul 2024 09:20:51 -0400 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 1sUR3n-00087Q-7i for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3k-0004Ti-R8 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4266ea6a412so2811625e9.1 for ; Thu, 18 Jul 2024 06:20:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308835; x=1721913635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fQR13XT9VDhcBY8spm2JM5I6IhE7k7yNucwEDGm4s9I=; b=gdfN3VO1paV3FAeD02sseyCYL9SF6Hht/vB02NxjnSlb6ATZh6D2qLvReCtP6E/mF9 nuMr6D5u5xXFC4IlxwPmtrlZcb4qhoehPgXuh6JuCVosqpVzzEb08CL4J+RTo96pN3du HF+GkJS9fyEWT9p508ssPdojTz9p8jTUa+ot5xtavJ9tCtHl9CiN+eTHGhTU9Gi+gbU/ /fpNM/BJT3y+Qlz+RDepk+bn5t+xP0n6qvbxG04G2L0MIYz4ns7bynP5NCVTISKeSp3R zY6+hVc0/dh4yWl76Y3Ip9daSheqZz40h1H4m8R9em+Cy79VyztShunGni9fe39tH82B itFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308835; x=1721913635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fQR13XT9VDhcBY8spm2JM5I6IhE7k7yNucwEDGm4s9I=; b=Iq6hwMs1mLlJ7+gVX7n0k6Q78bwitt0pgAeKOsBURujNmTKi4duDy8Sh5aSuv+e52W hkngHfi+FQN5EXPxjNyqX37AY7HWt6Jv5y37oQ2BGUlc/9QaXvsmfu2j9hoN4luzSfxk Wrm3AAuPbbrPZdX968S6uM9r1JzRbNgqqo3TelJhUrjvMag6HGEnTvGCeAbh07tJgEyY DoRVwo2DG5dJ5B01LSOaHg89N0k5MjEqOhIcBs9NfvUslNU5J5Yn8G6BLGJcQydQUZZ1 KG9pGtpEPnFuGAQOOwXWKhrVK/9W56uMfsvauhGtG+mwkGsHfRh//6Lplhqns2PWenwQ tXFQ== X-Gm-Message-State: AOJu0YxErHeYru5KMeTkAcws8iEboPaTjOgpsWyfKkc5n0MFieuaCXhM Z9xiqC0GmEUXQMuST5iaZuosN56BJsUSh6iJwgzyg5xIOhKvHyej0lIArA3dvA6hl3ZbUr7Y5EK t X-Google-Smtp-Source: AGHT+IH9QSFfu40W4eTsfiZ7FyzuyepIpSmyiqOHhGuM6vDc6jbMJwMzbqFBiCm0WvgwNOuldnee9A== X-Received: by 2002:a05:600c:35d5:b0:427:9922:4526 with SMTP id 5b1f17b1804b1-427c2cadebfmr32709665e9.7.1721308834660; Thu, 18 Jul 2024 06:20:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/26] hw/arm/smmu: Consolidate ASID and VMID types Date: Thu, 18 Jul 2024 14:20:11 +0100 Message-Id: <20240718132028.697927-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308988930116601 From: Mostafa Saleh ASID and VMID used to be uint16_t in the translation config, however, in other contexts they can be int as -1 in case of TLB invalidation, to represent all (don=E2=80=99t care). When stage-2 was added asid was set to -1 in stage-2 and vmid to -1 in stage-1 configs. However, that meant they were set as (65536), this was not an issue as nesting was not supported and no commands/lookup uses both. With nesting, it=E2=80=99s critical to get this right as translation must be tagged correctly with ASID/VMID, and with ASID=3D-1 meaning stage-2. Represent ASID/VMID everywhere as int. Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-7-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 14 +++++++------- hw/arm/smmu-common.c | 10 +++++----- hw/arm/smmuv3.c | 4 ++-- hw/arm/trace-events | 18 +++++++++--------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 366b53be778..5cb30244646 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -84,7 +84,7 @@ typedef struct SMMUS2Cfg { bool record_faults; /* Record fault events (S2R) */ uint8_t granule_sz; /* Granule page shift (based on S2TG) */ uint8_t eff_ps; /* Effective PA output range (based on S2PS) */ - uint16_t vmid; /* Virtual Machine ID (S2VMID) */ + int vmid; /* Virtual Machine ID (S2VMID) */ uint64_t vttb; /* Address of translation table base (S2TTB) */ } SMMUS2Cfg; =20 @@ -108,7 +108,7 @@ typedef struct SMMUTransCfg { uint64_t ttb; /* TT base address */ uint8_t oas; /* output address width */ uint8_t tbi; /* Top Byte Ignore */ - uint16_t asid; + int asid; SMMUTransTableInfo tt[2]; /* Used by stage-2 only. */ struct SMMUS2Cfg s2cfg; @@ -132,8 +132,8 @@ typedef struct SMMUPciBus { =20 typedef struct SMMUIOTLBKey { uint64_t iova; - uint16_t asid; - uint16_t vmid; + int asid; + int vmid; uint8_t tg; uint8_t level; } SMMUIOTLBKey; @@ -205,11 +205,11 @@ SMMUDevice *smmu_find_sdev(SMMUState *s, uint32_t sid= ); SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, SMMUTransTableInfo *tt, hwaddr iova); void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *ent= ry); -SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iov= a, +SMMUIOTLBKey smmu_get_iotlb_key(int asid, int vmid, uint64_t iova, uint8_t tg, uint8_t level); void smmu_iotlb_inv_all(SMMUState *s); -void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); -void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid); +void smmu_iotlb_inv_asid(SMMUState *s, int asid); +void smmu_iotlb_inv_vmid(SMMUState *s, int vmid); void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl); =20 diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 8d52472863b..7fbf8e22fe0 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -57,7 +57,7 @@ static gboolean smmu_iotlb_key_equal(gconstpointer v1, gc= onstpointer v2) (k1->vmid =3D=3D k2->vmid); } =20 -SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iov= a, +SMMUIOTLBKey smmu_get_iotlb_key(int asid, int vmid, uint64_t iova, uint8_t tg, uint8_t level) { SMMUIOTLBKey key =3D {.asid =3D asid, .vmid =3D vmid, .iova =3D iova, @@ -130,7 +130,7 @@ void smmu_iotlb_inv_all(SMMUState *s) static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, gpointer user_data) { - uint16_t asid =3D *(uint16_t *)user_data; + int asid =3D *(int *)user_data; SMMUIOTLBKey *iotlb_key =3D (SMMUIOTLBKey *)key; =20 return SMMU_IOTLB_ASID(*iotlb_key) =3D=3D asid; @@ -139,7 +139,7 @@ static gboolean smmu_hash_remove_by_asid(gpointer key, = gpointer value, static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value, gpointer user_data) { - uint16_t vmid =3D *(uint16_t *)user_data; + int vmid =3D *(int *)user_data; SMMUIOTLBKey *iotlb_key =3D (SMMUIOTLBKey *)key; =20 return SMMU_IOTLB_VMID(*iotlb_key) =3D=3D vmid; @@ -191,13 +191,13 @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, int = vmid, dma_addr_t iova, &info); } =20 -void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) +void smmu_iotlb_inv_asid(SMMUState *s, int asid) { trace_smmu_iotlb_inv_asid(asid); g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); } =20 -void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid) +void smmu_iotlb_inv_vmid(SMMUState *s, int vmid) { trace_smmu_iotlb_inv_vmid(vmid); g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid); diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 76d9969c93e..e71b842162a 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1240,7 +1240,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) } case SMMU_CMD_TLBI_NH_ASID: { - uint16_t asid =3D CMD_ASID(&cmd); + int asid =3D CMD_ASID(&cmd); =20 if (!STAGE1_SUPPORTED(s)) { cmd_error =3D SMMU_CERROR_ILL; @@ -1273,7 +1273,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) break; case SMMU_CMD_TLBI_S12_VMALL: { - uint16_t vmid =3D CMD_VMID(&cmd); + int vmid =3D CMD_VMID(&cmd); =20 if (!STAGE2_SUPPORTED(s)) { cmd_error =3D SMMU_CERROR_ILL; diff --git a/hw/arm/trace-events b/hw/arm/trace-events index cc12924a84a..09ccd39548f 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -11,13 +11,13 @@ smmu_ptw_page_pte(int stage, int level, uint64_t iova,= uint64_t baseaddr, uint6 smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t ptead= dr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=3D%d le= vel=3D%d base@=3D0x%"PRIx64" pte@=3D0x%"PRIx64" pte=3D0x%"PRIx64" iova=3D0x= %"PRIx64" block address =3D 0x%"PRIx64" block size =3D %d MiB" smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte)= "baseaddr=3D0x%"PRIx64" index=3D0x%x, pteaddr=3D0x%"PRIx64", pte=3D0x%"PRI= x64 smmu_iotlb_inv_all(void) "IOTLB invalidate all" -smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=3D%d" -smmu_iotlb_inv_vmid(uint16_t vmid) "IOTLB invalidate vmid=3D%d" -smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid= =3D%d addr=3D0x%"PRIx64 +smmu_iotlb_inv_asid(int asid) "IOTLB invalidate asid=3D%d" +smmu_iotlb_inv_vmid(int vmid) "IOTLB invalidate vmid=3D%d" +smmu_iotlb_inv_iova(int asid, uint64_t addr) "IOTLB invalidate asid=3D%d a= ddr=3D0x%"PRIx64 smmu_inv_notifiers_mr(const char *name) "iommu mr=3D%s" -smmu_iotlb_lookup_hit(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_= t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=3D%d vmid=3D%d addr= =3D0x%"PRIx64" hit=3D%d miss=3D%d hit rate=3D%d" -smmu_iotlb_lookup_miss(uint16_t asid, uint16_t vmid, uint64_t addr, uint32= _t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=3D%d vmid=3D%d ad= dr=3D0x%"PRIx64" hit=3D%d miss=3D%d hit rate=3D%d" -smmu_iotlb_insert(uint16_t asid, uint16_t vmid, uint64_t addr, uint8_t tg,= uint8_t level) "IOTLB ++ asid=3D%d vmid=3D%d addr=3D0x%"PRIx64" tg=3D%d le= vel=3D%d" +smmu_iotlb_lookup_hit(int asid, int vmid, uint64_t addr, uint32_t hit, uin= t32_t miss, uint32_t p) "IOTLB cache HIT asid=3D%d vmid=3D%d addr=3D0x%"PRI= x64" hit=3D%d miss=3D%d hit rate=3D%d" +smmu_iotlb_lookup_miss(int asid, int vmid, uint64_t addr, uint32_t hit, ui= nt32_t miss, uint32_t p) "IOTLB cache MISS asid=3D%d vmid=3D%d addr=3D0x%"P= RIx64" hit=3D%d miss=3D%d hit rate=3D%d" +smmu_iotlb_insert(int asid, int vmid, uint64_t addr, uint8_t tg, uint8_t l= evel) "IOTLB ++ asid=3D%d vmid=3D%d addr=3D0x%"PRIx64" tg=3D%d level=3D%d" =20 # smmuv3.c smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "= addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" @@ -48,12 +48,12 @@ smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, ui= nt32_t misses, uint32_t p smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uin= t32_t perc) "Config cache MISS for sid=3D0x%x (hits=3D%d, misses=3D%d, hit = rate=3D%d)" smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t= num_pages, uint8_t ttl, bool leaf) "vmid=3D%d asid=3D%d addr=3D0x%"PRIx64"= tg=3D%d num_pages=3D0x%"PRIx64" ttl=3D%d leaf=3D%d" smmuv3_cmdq_tlbi_nh(void) "" -smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=3D%d" -smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=3D%d" +smmuv3_cmdq_tlbi_nh_asid(int asid) "asid=3D%d" +smmuv3_cmdq_tlbi_s12_vmid(int vmid) "vmid=3D%d" smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=3D0x%x" smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu= mr=3D%s" smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu= mr=3D%s" -smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, = uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=3D%s asid=3D%d vmi= d=3D%d iova=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 +smmuv3_inv_notifiers_iova(const char *name, int asid, int vmid, uint64_t i= ova, uint8_t tg, uint64_t num_pages) "iommu mr=3D%s asid=3D%d vmid=3D%d iov= a=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 =20 # strongarm.c strongarm_uart_update_parameters(const char *label, int speed, char parity= , int data_bits, int stop_bits) "%s speed=3D%d parity=3D%c data=3D%d stop= =3D%d" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309028; cv=none; d=zohomail.com; s=zohoarc; b=cI3V190ZK/ih6laSt7054xFPFFXsCo2tRms7F9ql4APhN7E6skzND5TpirphFH00ADX2RpO5ZtKmCXRWbammW+xIhmzXveK94EBJrRFiHxf7TfSLt6tIt5d6GMWIrEb4BUBysawVhoTjwyBWlEmRx2fPv4noNyB3ITt8Q+8EqLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309028; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=ycUSfPxeZiE10T7Yl9GNK03Kd/Z6QrsxLJrBkHZa9cQ=; b=m18kUAqxE7OgTdODgbJKOnCjGwGqiI5ER4t8VKph8Rfh3/JQ9DnWb/KhUcViBPB0vSJ6PA5ShfFS5Aau0WfpYNJIWVBMewlgFcJvcqhcr1iITbA7d56pyxMDgYM+kMGe1TYthyb9fP0UAYaNd9OYp4JNGcgsAmoLb17FU8sAB58= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309028241568.8326421571103; Thu, 18 Jul 2024 06:23:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR44-0001Cx-3r; Thu, 18 Jul 2024 09:20:56 -0400 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 1sUR3n-00087O-7U for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3k-0004Tu-UC for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:38 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2eeb1051360so9681751fa.0 for ; Thu, 18 Jul 2024 06:20:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308835; x=1721913635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ycUSfPxeZiE10T7Yl9GNK03Kd/Z6QrsxLJrBkHZa9cQ=; b=ONyu/4QlJR0LIPxZRLRAbRT0xL14BV4lKsouSKPjhzato+ksdG3KsUIE0PDhRZZSpu igHBN0lSzmUgYWZjTcTIChJVg0F+dhGESuVoM5KoELFYySpvz5qF8jyKC19QGsxZvKFH HYU+c5DmFAXCVxrsjCxgcnPWJfpBCnoFmVsHxi9gBoJ0QwB3K0JO3RyhgiUEyPxdPTKB BoYtaHQRCiDl2tuwSh/QAgS3Ct7OqvzCJSBxHLz4b0koKq57P+KX1LGVtlKEkSmfK7aW VtfFku/H5AbvhaocbPziFwb9TdMW+7DKzbccAIujRn06ZKxdeWKmE5bz15OqCGUt6Fqf Daww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308835; x=1721913635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ycUSfPxeZiE10T7Yl9GNK03Kd/Z6QrsxLJrBkHZa9cQ=; b=Y4clY3izNBgp+6rAgfzAOb2QOBjsU2lM7cda8R12ZR3zNm7lAiVTcEe1KJSxzZucIU 7jJZ6CoGxRt4pzRENqPfBbrhSp4fsp5n23sjVjJISoDFAtX+9EUX+Dirx0A81yx9WPV4 wYWynpWn5U83ECz3IRAmaMWtO8nx5jnFIKvvcP774ZZi2ICxMfiXEooHXWfdV8GRr9YS FCmHYnZmn7vyVgIIpN3txKQRP0rLkBI4tX8zKMtOPzHb++amh7+YmyCjD+A9PDYzjZz2 JnrjJaKxa1DtyKatSllE8PHH0OD9QVa5WCqvcoYPSxjKbDlHaFVMVgiuYDtcIP8Q8CGd a0kw== X-Gm-Message-State: AOJu0YwH7sY6Oj7TxDkCvRA7f3rgHVsiojCci39asoHBh0+ycjP2nHlJ /Zkr5CP43XYbk2LvnRN3PgrnEWXZwULIVlvCkB+wSblr4uLhGkCMxo+MJ8WXluWjnkFfWRQtDR6 S X-Google-Smtp-Source: AGHT+IFfEwO0aeb6EwFvVVFZ/5CtU8pNCPE9TvJKx5wRGVYv+gdeHjRW9gqBcCGNV9tsteLFCCqXHQ== X-Received: by 2002:a2e:909a:0:b0:2ec:1810:e50a with SMTP id 38308e7fff4ca-2ef05d25f33mr16399411fa.32.1721308835241; Thu, 18 Jul 2024 06:20:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/26] hw/arm/smmu: Introduce CACHED_ENTRY_TO_ADDR Date: Thu, 18 Jul 2024 14:20:12 +0100 Message-Id: <20240718132028.697927-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x236.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309029040116600 From: Mostafa Saleh Soon, smmuv3_do_translate() will be used to translate the CD and the TTBx, instead of re-writting the same logic to convert the returned cached entry to an address, add a new macro CACHED_ENTRY_TO_ADDR. Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-8-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 3 +++ hw/arm/smmuv3.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 5cb30244646..f793b54388d 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -37,6 +37,9 @@ #define VMSA_IDXMSK(isz, strd, lvl) ((1ULL << \ VMSA_BIT_LVL(isz, strd, lvl))= - 1) =20 +#define CACHED_ENTRY_TO_ADDR(ent, addr) ((ent)->entry.translated_addr= + \ + ((addr) & (ent)->entry.addr_m= ask)) + /* * Page table walk error types */ diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index e71b842162a..dc63e07d683 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -951,8 +951,7 @@ epilogue: switch (status) { case SMMU_TRANS_SUCCESS: entry.perm =3D cached_entry->entry.perm; - entry.translated_addr =3D cached_entry->entry.translated_addr + - (addr & cached_entry->entry.addr_mask); + entry.translated_addr =3D CACHED_ENTRY_TO_ADDR(cached_entry, addr); entry.addr_mask =3D cached_entry->entry.addr_mask; trace_smmuv3_translate_success(mr->parent_obj.name, sid, addr, entry.translated_addr, entry.perm, --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308915; cv=none; d=zohomail.com; s=zohoarc; b=JRy8pwOjPrc0m0Ww00XcwSzAKkJOkrkslEn8qETmsh9zhJMJtI3dPFW+0TA0v0fkK+tXg2yL8HUMuxPhosqw50Lkd5LT4GL0Ei0JCMDg4bFNYPHJkkfTPqJkHEJFduZjR9ik7pu77eeF+Ap750YJOSclmpUTp1uGbVeDepFlNJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308915; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=D810Dx8frc2vW1zCIoJr9KDHLMBTCs78RFKDiRd8O1g=; b=i9R2Bvly0lL6EV8uUZNK/HHJEdHmLqMXqePLljtQu5lnwNp+D2+456vsvBuAMZvZId9hLu/sZ5IZ0PoNDWg2DxHEVUBCE361PkNsWemd11ggO/OdkwWk8dX4RWLonm89Cpi3wytsUX79prFYApd6U3r7B3SF4O3Ibju438jOcQE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308915647710.845710849075; Thu, 18 Jul 2024 06:21:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR43-0001Cg-Vr; Thu, 18 Jul 2024 09:20:56 -0400 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 1sUR3p-0008FZ-1Z for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3m-0004U2-NA for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-426636ef8c9so2640585e9.2 for ; Thu, 18 Jul 2024 06:20:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308836; x=1721913636; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D810Dx8frc2vW1zCIoJr9KDHLMBTCs78RFKDiRd8O1g=; b=I/NJ1XlQZFzucj3Gt09lVnDkNH1vYWCD/NP2/5tBBntFB6/in33/6enj3AHEBAzcj7 d6OJLjXxu6dKP/EXm1VS5uWL8OzoPqQJ+VZWWbdzGhGRRhKPgbP+DzynrXjt59+bF3IE u9U/yBUKSBJb2bd8y4SbXy2K8zTMYFd64UiLeglsVoXCVh+MH7nkPLpAoZfVA1HOcwHR 7sOd3iyLDtqdLJLhi/Bgr28iNMkrMsqrfPny44+fdTOhWG1fXe2aqpklRvvcnzrOwL+X ITpjuTrXoNSpP7HdblsUAKthwPLqVg+TwGyEEeYZFWbek0dJyFa21RHXD1ceIDPTE6tj RRzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308836; x=1721913636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D810Dx8frc2vW1zCIoJr9KDHLMBTCs78RFKDiRd8O1g=; b=gngM0iXHjKPGqZKZmoq5n878+HwH7vyC1Bu+1S45kDtz/WlGs4F1O0FIovw5CwuU0Q LIGFRlnlHQTKQ3/k0PObXdpg9aaYhYmzVGNMhGCTdKIRlZ6x+4d3YCa1aI01KfkncAIn GH1xcSjLKpPBmwoxt81zfr5Q+x/BJOyEc6VasPlYZ+F+3vvPaJ7XnF0ODKBP1is32MhY PjOPk7HSFFxePEdVNON5E5CKLOspSkgYdQbciuN0xW8mFwA5uI69QfqdQ86pp57IFuSU ZpIS3CsnB9s9RufR7Ya0IjcismvLtdV6SjE0XWWszIZkV2E3+FQ+y7Lj+1S4CXTDTLJm spgA== X-Gm-Message-State: AOJu0Yx6rIsytWx5WqRGpKdTKeQCIVZCmLuGm06cvrMZL5KIY0Fu8/Ik eJoQrIU1G/I1ZHst+4Jk781qj1DyvVgHfd20JC7qCCw+jSMaiXRVOprrRCVo8QfolCXvzdXQmG7 + X-Google-Smtp-Source: AGHT+IFdNU0vBG7fuqtRknxK3HQcMQx4RxHzpJqc4Se9Ga1iCEVfSdpF7XQtDAvqDGJeYx7SYqHzdQ== X-Received: by 2002:a05:600c:3b8c:b0:427:abf6:f0e6 with SMTP id 5b1f17b1804b1-427c2cb0878mr35155145e9.9.1721308835758; Thu, 18 Jul 2024 06:20:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/26] hw/arm/smmuv3: Translate CD and TT using stage-2 table Date: Thu, 18 Jul 2024 14:20:13 +0100 Message-Id: <20240718132028.697927-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308919134116600 From: Mostafa Saleh According to ARM SMMU architecture specification (ARM IHI 0070 F.b), In "5.2 Stream Table Entry": [51:6] S1ContextPtr If Config[1] =3D=3D 1 (stage 2 enabled), this pointer is an IPA translated= by stage 2 and the programmed value must be within the range of the IAS. In "5.4.1 CD notes": The translation table walks performed from TTB0 or TTB1 are always perform= ed in IPA space if stage 2 translations are enabled. This patch implements translation of the S1 context descriptor pointer and TTBx base addresses through the S2 stage (IPA -> PA) smmuv3_do_translate() is updated to have one arg which is translation class, this is useful to: - Decide wether a translation is stage-2 only or use the STE config. - Populate the class in case of faults, WALK_EABT is left unchanged for stage-1 as it is always IN, while stage-2 would match the used class (TT, IN, CD), this will change slightly when the ptw supports nested translation as it can also issue TT event with class IN. In case for stage-2 only translation, used in the context of nested translation, the stage and asid are saved and restored before and after calling smmu_translate(). Translating CD or TTBx can fail for the following reasons: 1) Large address size: This is described in (3.4.3 Address sizes of SMMU-originated accesses) - For CD ptr larger than IAS, for SMMUv3.1, it can trigger either C_BAD_STE or Translation fault, we implement the latter as it requires no extra code. - For TTBx, if larger than the effective stage 1 output address size, it triggers C_BAD_CD. 2) Faults from PTWs (7.3 Event records) - F_ADDR_SIZE: large address size after first level causes stage 2 Addre= ss Size fault (Also in 3.4.3 Address sizes of SMMU-originated accesses) - F_PERMISSION: Same as an address translation. However, when CLASS =3D=3D CD, the access is implicitly Data and a read. - F_ACCESS: Same as an address translation. - F_TRANSLATION: Same as an address translation. - F_WALK_EABT: Same as an address translation. These are already implemented in the PTW logic, so no extra handling required. As in CD and TTBx translation context, the iova is not known, setting the InputAddr was removed from "smmuv3_do_translate" and set after from "smmuv3_translate" with the new function "smmuv3_fixup_event" Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-9-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 120 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 103 insertions(+), 17 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index dc63e07d683..5c5fee27997 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -337,14 +337,35 @@ static int smmu_get_ste(SMMUv3State *s, dma_addr_t ad= dr, STE *buf, =20 } =20 +static SMMUTranslationStatus smmuv3_do_translate(SMMUv3State *s, hwaddr ad= dr, + SMMUTransCfg *cfg, + SMMUEventInfo *event, + IOMMUAccessFlags flag, + SMMUTLBEntry **out_entry, + SMMUTranslationClass clas= s); /* @ssid > 0 not supported yet */ -static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid, - CD *buf, SMMUEventInfo *event) +static int smmu_get_cd(SMMUv3State *s, STE *ste, SMMUTransCfg *cfg, + uint32_t ssid, CD *buf, SMMUEventInfo *event) { dma_addr_t addr =3D STE_CTXPTR(ste); int ret, i; + SMMUTranslationStatus status; + SMMUTLBEntry *entry; =20 trace_smmuv3_get_cd(addr); + + if (cfg->stage =3D=3D SMMU_NESTED) { + status =3D smmuv3_do_translate(s, addr, cfg, event, + IOMMU_RO, &entry, SMMU_CLASS_CD); + + /* Same PTW faults are reported but with CLASS =3D CD. */ + if (status !=3D SMMU_TRANS_SUCCESS) { + return -EINVAL; + } + + addr =3D CACHED_ENTRY_TO_ADDR(entry, addr); + } + /* TODO: guarantee 64-bit single-copy atomicity */ ret =3D dma_memory_read(&address_space_memory, addr, buf, sizeof(*buf), MEMTXATTRS_UNSPECIFIED); @@ -659,10 +680,13 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, return 0; } =20 -static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEventInfo *event) +static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, + CD *cd, SMMUEventInfo *event) { int ret =3D -EINVAL; int i; + SMMUTranslationStatus status; + SMMUTLBEntry *entry; =20 if (!CD_VALID(cd) || !CD_AARCH64(cd)) { goto bad_cd; @@ -713,9 +737,26 @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEv= entInfo *event) =20 tt->tsz =3D tsz; tt->ttb =3D CD_TTB(cd, i); + if (tt->ttb & ~(MAKE_64BIT_MASK(0, cfg->oas))) { goto bad_cd; } + + /* Translate the TTBx, from IPA to PA if nesting is enabled. */ + if (cfg->stage =3D=3D SMMU_NESTED) { + status =3D smmuv3_do_translate(s, tt->ttb, cfg, event, IOMMU_R= O, + &entry, SMMU_CLASS_TT); + /* + * Same PTW faults are reported but with CLASS =3D TT. + * If TTBx is larger than the effective stage 1 output addres + * size, it reports C_BAD_CD, which is handled by the above ca= se. + */ + if (status !=3D SMMU_TRANS_SUCCESS) { + return -EINVAL; + } + tt->ttb =3D CACHED_ENTRY_TO_ADDR(entry, tt->ttb); + } + tt->had =3D CD_HAD(cd, i); trace_smmuv3_decode_cd_tt(i, tt->tsz, tt->ttb, tt->granule_sz, tt-= >had); } @@ -767,12 +808,12 @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr= , SMMUTransCfg *cfg, return 0; } =20 - ret =3D smmu_get_cd(s, &ste, 0 /* ssid */, &cd, event); + ret =3D smmu_get_cd(s, &ste, cfg, 0 /* ssid */, &cd, event); if (ret) { return ret; } =20 - return decode_cd(cfg, &cd, event); + return decode_cd(s, cfg, &cd, event); } =20 /** @@ -832,58 +873,80 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMU= v3State *s, hwaddr addr, SMMUTransCfg *cfg, SMMUEventInfo *event, IOMMUAccessFlags flag, - SMMUTLBEntry **out_entry) + SMMUTLBEntry **out_entry, + SMMUTranslationClass clas= s) { SMMUPTWEventInfo ptw_info =3D {}; SMMUState *bs =3D ARM_SMMU(s); SMMUTLBEntry *cached_entry =3D NULL; + int asid, stage; + bool desc_s2_translation =3D class !=3D SMMU_CLASS_IN; + + /* + * The function uses the argument class to identify which stage is use= d: + * - CLASS =3D IN: Means an input translation, determine the stage fro= m STE. + * - CLASS =3D CD: Means the addr is an IPA of the CD, and it would be + * translated using the stage-2. + * - CLASS =3D TT: Means the addr is an IPA of the stage-1 translation= table + * and it would be translated using the stage-2. + * For the last 2 cases instead of having intrusive changes in the com= mon + * logic, we modify the cfg to be a stage-2 translation only in case of + * nested, and then restore it after. + */ + if (desc_s2_translation) { + asid =3D cfg->asid; + stage =3D cfg->stage; + cfg->asid =3D -1; + cfg->stage =3D SMMU_STAGE_2; + } =20 cached_entry =3D smmu_translate(bs, cfg, addr, flag, &ptw_info); + + if (desc_s2_translation) { + cfg->asid =3D asid; + cfg->stage =3D stage; + } + if (!cached_entry) { /* All faults from PTW has S2 field. */ event->u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D SMMU_STAGE_2); switch (ptw_info.type) { case SMMU_PTW_ERR_WALK_EABT: event->type =3D SMMU_EVT_F_WALK_EABT; - event->u.f_walk_eabt.addr =3D addr; event->u.f_walk_eabt.rnw =3D flag & 0x1; event->u.f_walk_eabt.class =3D (ptw_info.stage =3D=3D SMMU_STA= GE_2) ? - SMMU_CLASS_IN : SMMU_CLASS_TT; + class : SMMU_CLASS_TT; event->u.f_walk_eabt.addr2 =3D ptw_info.addr; break; case SMMU_PTW_ERR_TRANSLATION: if (PTW_RECORD_FAULT(cfg)) { event->type =3D SMMU_EVT_F_TRANSLATION; - event->u.f_translation.addr =3D addr; event->u.f_translation.addr2 =3D ptw_info.addr; - event->u.f_translation.class =3D SMMU_CLASS_IN; + event->u.f_translation.class =3D class; event->u.f_translation.rnw =3D flag & 0x1; } break; case SMMU_PTW_ERR_ADDR_SIZE: if (PTW_RECORD_FAULT(cfg)) { event->type =3D SMMU_EVT_F_ADDR_SIZE; - event->u.f_addr_size.addr =3D addr; event->u.f_addr_size.addr2 =3D ptw_info.addr; - event->u.f_addr_size.class =3D SMMU_CLASS_IN; + event->u.f_addr_size.class =3D class; event->u.f_addr_size.rnw =3D flag & 0x1; } break; case SMMU_PTW_ERR_ACCESS: if (PTW_RECORD_FAULT(cfg)) { event->type =3D SMMU_EVT_F_ACCESS; - event->u.f_access.addr =3D addr; event->u.f_access.addr2 =3D ptw_info.addr; - event->u.f_access.class =3D SMMU_CLASS_IN; + event->u.f_access.class =3D class; event->u.f_access.rnw =3D flag & 0x1; } break; case SMMU_PTW_ERR_PERMISSION: if (PTW_RECORD_FAULT(cfg)) { event->type =3D SMMU_EVT_F_PERMISSION; - event->u.f_permission.addr =3D addr; event->u.f_permission.addr2 =3D ptw_info.addr; - event->u.f_permission.class =3D SMMU_CLASS_IN; + event->u.f_permission.class =3D class; event->u.f_permission.rnw =3D flag & 0x1; } break; @@ -896,6 +959,27 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv= 3State *s, hwaddr addr, return SMMU_TRANS_SUCCESS; } =20 +/* + * Sets the InputAddr for an SMMU_TRANS_ERROR, as it can't be + * set from all contexts, as smmuv3_get_config() can return + * translation faults in case of nested translation (for CD + * and TTBx). But in that case the iova is not known. + */ +static void smmuv3_fixup_event(SMMUEventInfo *event, hwaddr iova) +{ + switch (event->type) { + case SMMU_EVT_F_WALK_EABT: + case SMMU_EVT_F_TRANSLATION: + case SMMU_EVT_F_ADDR_SIZE: + case SMMU_EVT_F_ACCESS: + case SMMU_EVT_F_PERMISSION: + event->u.f_walk_eabt.addr =3D iova; + break; + default: + break; + } +} + /* Entry point to SMMU, does everything. */ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, IOMMUAccessFlags flag, int iommu_idx) @@ -944,7 +1028,8 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegio= n *mr, hwaddr addr, goto epilogue; } =20 - status =3D smmuv3_do_translate(s, addr, cfg, &event, flag, &cached_ent= ry); + status =3D smmuv3_do_translate(s, addr, cfg, &event, flag, + &cached_entry, SMMU_CLASS_IN); =20 epilogue: qemu_mutex_unlock(&s->mutex); @@ -975,6 +1060,7 @@ epilogue: entry.perm); break; case SMMU_TRANS_ERROR: + smmuv3_fixup_event(&event, addr); qemu_log_mask(LOG_GUEST_ERROR, "%s translation failed for iova=3D0x%"PRIx64" (%s)\n= ", mr->parent_obj.name, addr, smmu_event_string(event.t= ype)); --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308954; cv=none; d=zohomail.com; s=zohoarc; b=VBpk5h22znQIjJxFciw9PrL9gdfzABEuItu91L71rpPjhBuZBjtCI4HWCPpW76O0Ron/Edc62zeq9Gv1cfqAY5WwzzHzO22JdCl9GBWRKZim/yvf7d4whsKuC3MvgmLhcO1M8c+gpKsQrcSui6S4UC27NGZ4VNCKeYU04Sh248I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308954; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=X2AcFwMwmG8CuilTxkX1QR6WPC1ZxLwj44sonDWX5Es=; b=KsPwdeY8KbA3CwBPsycQQ1ppc+4coEaoWbnI5pidkVJ365tlIPbzf46J/NjVg/R1c/pEwIFD4jf1tCA9y7quFXvTNPoj03MQr6WPambN41c1JfN0WHYp1ro7fu6naGlC6UPAZlxC4HOind5U5nbiCBwYes99AB3hs1gy3LaFaIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308954542150.0290151348454; Thu, 18 Jul 2024 06:22:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR47-0001bt-Fu; Thu, 18 Jul 2024 09:20:59 -0400 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 1sUR3o-0008EW-TD for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3m-0004US-NP for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-427b4c621b9so2497655e9.1 for ; Thu, 18 Jul 2024 06:20:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308836; x=1721913636; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X2AcFwMwmG8CuilTxkX1QR6WPC1ZxLwj44sonDWX5Es=; b=BNNkDjgFl80e1fh5MKk7eUlFv69FlCM+1ExZTTPvgtHx06Sc/I4ErYvtHvghLgfIeI IQT7o3QgSKhys6BYswG1gEMj+eavmrI6wmnaOOG2Zh+m+2FUm/6amPgUeV12Jnu+uLWU YMtP+uaNXhRPq2u3d9EbYxMSzHQrRYYVKiHz/G0NJyHPV1xMYMvnAvlDW9/kCRRqJa5L oNDXsJHmkn4cyAz7OTXWLWgjpd41sAGJe0/kPySzUKULyyp1H8fQJer4tTF6oOOM8/TF zObp9SC3K7wPJ67LnHUJShxQOIsxuDZ/8xyLO9N07LJI/W3bVByiZzOzgT6gmDfc2V1y 1OLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308836; x=1721913636; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X2AcFwMwmG8CuilTxkX1QR6WPC1ZxLwj44sonDWX5Es=; b=Tkcz2NeC3QVt4cWDVYxZ0stkoioLWu3/XeGF1mVyH21Ah9QyGzO9FDaYT1DpzkQDmq 2BR/1mTyq88MKUU968I93hBkXMgoyxzA9d1E4/hWSPwVwqHqHjwN+HMIzUjNHpl1VEc6 gP1iHMS6xk0GIovQiQ+u1H42b4DGDwpjxtH/NIONZpI7894L3CsNnuWJhhdE9q4OJ4Bk +tOiDBdYWmUesZeuXfR+BqlK/mrZz1Dq7RKDnl9qs7MSJn0vUQ4BF2yXpqCgsht9NuyU 7iSU1haYkURlS9DCeR5AyKLCDkmzvR6/cmlClptnXVc5RQx0vRz1ZZ7OT+cVvId1alTc odNA== X-Gm-Message-State: AOJu0YzFbDLtMo7o8xNhkSDHXsKtvehDNrP2RFmIUSiHd0hgHRTFTXEh PXemsunbN81k3dqvC/m9D5EmN+5bvryJM2ZFRrHbblolMSJTDa0UKJVu5vcvjyhoo/JqC/ogFq2 r X-Google-Smtp-Source: AGHT+IG8V51hCMrejrvL15SLFjRqU4d0MaVUnFCqvfL4L7QcMvjMCnxg1nqOfdIUvPSCQNX90MwPkA== X-Received: by 2002:a05:600c:4fd5:b0:426:5f8f:51a4 with SMTP id 5b1f17b1804b1-427c2cb08a0mr34368815e9.12.1721308836428; Thu, 18 Jul 2024 06:20:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/26] hw/arm/smmu-common: Rework TLB lookup for nesting Date: Thu, 18 Jul 2024 14:20:14 +0100 Message-Id: <20240718132028.697927-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308956744116600 From: Mostafa Saleh In the next patch, combine_tlb() will be added which combines 2 TLB entries into one for nested translations, which chooses the granule and level from the smallest entry. This means that with nested translation, an entry can be cached with the granule of stage-2 and not stage-1. However, currently, the lookup for an IOVA is done with input stage granule, which is stage-1 for nested configuration, which will not work with the above logic. This patch reworks lookup in that case, so it falls back to stage-2 granule if no entry is found using stage-1 granule. Also, drop aligning the iova to avoid over-aligning in case the iova is cached with a smaller granule, the TLB lookup will align the iova anyway for each granule and level, and the page table walker doesn't consider the page offset bits. Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-10-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmu-common.c | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 7fbf8e22fe0..e374cae0db6 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -66,8 +66,10 @@ SMMUIOTLBKey smmu_get_iotlb_key(int asid, int vmid, uint= 64_t iova, return key; } =20 -SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, - SMMUTransTableInfo *tt, hwaddr iova) +static SMMUTLBEntry *smmu_iotlb_lookup_all_levels(SMMUState *bs, + SMMUTransCfg *cfg, + SMMUTransTableInfo *tt, + hwaddr iova) { uint8_t tg =3D (tt->granule_sz - 10) / 2; uint8_t inputsize =3D 64 - tt->tsz; @@ -88,6 +90,36 @@ SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTrans= Cfg *cfg, } level++; } + return entry; +} + +/** + * smmu_iotlb_lookup - Look up for a TLB entry. + * @bs: SMMU state which includes the TLB instance + * @cfg: Configuration of the translation + * @tt: Translation table info (granule and tsz) + * @iova: IOVA address to lookup + * + * returns a valid entry on success, otherwise NULL. + * In case of nested translation, tt can be updated to include + * the granule of the found entry as it might different from + * the IOVA granule. + */ +SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, + SMMUTransTableInfo *tt, hwaddr iova) +{ + SMMUTLBEntry *entry =3D NULL; + + entry =3D smmu_iotlb_lookup_all_levels(bs, cfg, tt, iova); + /* + * For nested translation also try the s2 granule, as the TLB will ins= ert + * it if the size of s2 tlb entry was smaller. + */ + if (!entry && (cfg->stage =3D=3D SMMU_NESTED) && + (cfg->s2cfg.granule_sz !=3D tt->granule_sz)) { + tt->granule_sz =3D cfg->s2cfg.granule_sz; + entry =3D smmu_iotlb_lookup_all_levels(bs, cfg, tt, iova); + } =20 if (entry) { cfg->iotlb_hits++; @@ -569,18 +601,21 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMM= UAccessFlags perm, SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t = addr, IOMMUAccessFlags flag, SMMUPTWEventInfo *info) { - uint64_t page_mask, aligned_addr; SMMUTLBEntry *cached_entry =3D NULL; SMMUTransTableInfo *tt; int status; =20 /* - * Combined attributes used for TLB lookup, as only one stage is suppo= rted, - * it will hold attributes based on the enabled stage. + * Combined attributes used for TLB lookup, holds the attributes for + * the input stage. */ SMMUTransTableInfo tt_combined; =20 - if (cfg->stage =3D=3D SMMU_STAGE_1) { + if (cfg->stage =3D=3D SMMU_STAGE_2) { + /* Stage2. */ + tt_combined.granule_sz =3D cfg->s2cfg.granule_sz; + tt_combined.tsz =3D cfg->s2cfg.tsz; + } else { /* Select stage1 translation table. */ tt =3D select_tt(cfg, addr); if (!tt) { @@ -590,22 +625,9 @@ SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransC= fg *cfg, dma_addr_t addr, } tt_combined.granule_sz =3D tt->granule_sz; tt_combined.tsz =3D tt->tsz; - - } else { - /* Stage2. */ - tt_combined.granule_sz =3D cfg->s2cfg.granule_sz; - tt_combined.tsz =3D cfg->s2cfg.tsz; } =20 - /* - * TLB lookup looks for granule and input size for a translation stage, - * as only one stage is supported right now, choose the right values - * from the configuration. - */ - page_mask =3D (1ULL << tt_combined.granule_sz) - 1; - aligned_addr =3D addr & ~page_mask; - - cached_entry =3D smmu_iotlb_lookup(bs, cfg, &tt_combined, aligned_addr= ); + cached_entry =3D smmu_iotlb_lookup(bs, cfg, &tt_combined, addr); if (cached_entry) { if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { info->type =3D SMMU_PTW_ERR_PERMISSION; @@ -616,7 +638,7 @@ SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCf= g *cfg, dma_addr_t addr, } =20 cached_entry =3D g_new0(SMMUTLBEntry, 1); - status =3D smmu_ptw(cfg, aligned_addr, flag, cached_entry, info); + status =3D smmu_ptw(cfg, addr, flag, cached_entry, info); if (status) { g_free(cached_entry); return NULL; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309038; cv=none; d=zohomail.com; s=zohoarc; b=B4+zSySmdXLaNXtf/Sn+AI3c/sleY7tCtFmmgAd2vToUOoNlJpdqjk1E8zD6sHybF6Ild3U/zuNr+vA+uhxR3f/FYV2Ht4S268Z/9xwiDBwPViO80B4gQre+Cmbtw7hxPGfP4XhIlexyP9xLT1NUQtdFLmwFUTJwuLU+2Ca2DP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309038; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=6dTvjxai6uiJYWxFa2VnT/h+ITwv1YE0ztLSMd17uDg=; b=SZlC/GPACPYSp2ESXzjQJzKKNGSv5F90HrT5l1meE21+N2yCzwY6tt1GDljyzXALeIpxtq/35tXSHhEc6zShoz9zpnkGnxNdCvk5C+i0cp/vt4aeiMfSxkv/E5eB3DWxUNfzGo+smg2A3zSmISrm1c2JRbd7XE7B5VMl3Xm+5Ys= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309038153801.4719219155581; Thu, 18 Jul 2024 06:23:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR46-0001QC-0r; Thu, 18 Jul 2024 09:20:58 -0400 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 1sUR3o-0008Ey-Tp for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3m-0004Uf-Ne for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4267345e746so2778935e9.0 for ; Thu, 18 Jul 2024 06:20:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308837; x=1721913637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6dTvjxai6uiJYWxFa2VnT/h+ITwv1YE0ztLSMd17uDg=; b=rf9zhmep8ClTsKZ96s22WqkH+2AM9rHs9darOnXL/3+5gqJxrwfpeW/GwHNAAdS6az 61HkdRvoD6YZSyr9VaBu3F+PEAUH+m77jH/et8k46CNAmi22waTjxTrXER4GoXPz6qqk vSRI8NvWtPEGXoe+2b+/Z6wZhkdJFykBQeENF4r1gUkFYkf7AAG/Qz5w3P8wpJ+neCHI ZWnUQmEWauFnKikeTOEqWM6RZSIwMhdaLgnpSmQc7KVdsoXVSHJ32iPW+/NFaAT2VxU6 7eaKBNepLB2e7mt+PdGbzU+499Qtc3JOLIKU/XdSt+3t5FNiyv4EHDrJg57CQmnSyeF8 cbgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308837; x=1721913637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6dTvjxai6uiJYWxFa2VnT/h+ITwv1YE0ztLSMd17uDg=; b=qc8QCLdpmNON0T5VShtsD8+EotvaUCnmIiJITe83r2/SQhToWWqEySjk+MCGmnzQsR Mu+P75obQGs/Bp1wQOxcuwBy8hLti9mC3VXEtLOI7Bg+3eOZfZWY2pw6zmXOxmhq+FIM EtUebRIHcY61/W9fhdC5qeXfoV4gLdDoSkecol1/7yyVKTvk4Lo971N3S4JJM55wYCWX 1X+ChnM6wlugZiB1onUq1Ej0/nOOSocx7+kKpnSqfl69UmiYvh5CIEMpAbuL0UnwVyI7 XGy58LiKaN81pXnsD8lR/mhFd+Fsj6zwXKrkVl4z7Y42Xbh0F9z0DDh7z+7N1joNkpyQ k3aA== X-Gm-Message-State: AOJu0Yx9UYZu9VAKkrW68Rqs1rAUjFGDjpLV1PCxzpCV7+qq6O5zpfz8 7yupr/7RB8Sw6FXuwRkKmBbb+48rSc9ovM1M9511YF9GeTfyO33V2FUdmKL5mlr97IU9fWE39pw u X-Google-Smtp-Source: AGHT+IGa8PWjPGz6zqt+YQpzonEoyL/w5O0j6qsh+S1q4bBpa4maJzO8APMvpi32O7gGHbR+A3V1/A== X-Received: by 2002:a05:600c:154c:b0:426:67f0:b4f3 with SMTP id 5b1f17b1804b1-427c2d1c6cfmr30194275e9.26.1721308836913; Thu, 18 Jul 2024 06:20:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/26] hw/arm/smmu-common: Add support for nested TLB Date: Thu, 18 Jul 2024 14:20:15 +0100 Message-Id: <20240718132028.697927-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309039042116600 From: Mostafa Saleh This patch adds support for nested (combined) TLB entries. The main function combine_tlb() is not used here but in the next patches, but to simplify the patches it is introduced first. Main changes: 1) New field added in the SMMUTLBEntry struct: parent_perm, for nested TLB, holds the stage-2 permission, this can be used to know the origin of a permission fault from a cached entry as caching the =E2=80=9Cand=E2=80=9D of the permissions loses this information. SMMUPTWEventInfo is used to hold information about PTW faults so the event can be populated, the value of stage used to be set based on the current stage for TLB permission faults, however with the parent_perm, it is now set based on which perm has the missing permission When nesting is not enabled it has the same value as perm which doesn't change the logic. 2) As combined TLB implementation is used, the combination logic chooses: - tg and level from the entry which has the smallest addr_mask. - Based on that the iova that would be cached is recalculated. - Translated_addr is chosen from stage-2. Reviewed-by: Eric Auger Reviewed-by: Jean-Philippe Brucker Signed-off-by: Mostafa Saleh Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-11-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 1 + hw/arm/smmu-common.c | 37 ++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index f793b54388d..08775364723 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -77,6 +77,7 @@ typedef struct SMMUTLBEntry { IOMMUTLBEntry entry; uint8_t level; uint8_t granule; + IOMMUAccessFlags parent_perm; } SMMUTLBEntry; =20 /* Stage-2 configuration. */ diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index e374cae0db6..bf55b9c5a42 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -426,7 +426,8 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, tlbe->entry.translated_addr =3D gpa; tlbe->entry.iova =3D iova & ~mask; tlbe->entry.addr_mask =3D mask; - tlbe->entry.perm =3D PTE_AP_TO_PERM(ap); + tlbe->parent_perm =3D PTE_AP_TO_PERM(ap); + tlbe->entry.perm =3D tlbe->parent_perm; tlbe->level =3D level; tlbe->granule =3D granule_sz; return 0; @@ -547,7 +548,8 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, tlbe->entry.translated_addr =3D gpa; tlbe->entry.iova =3D ipa & ~mask; tlbe->entry.addr_mask =3D mask; - tlbe->entry.perm =3D s2ap; + tlbe->parent_perm =3D s2ap; + tlbe->entry.perm =3D tlbe->parent_perm; tlbe->level =3D level; tlbe->granule =3D granule_sz; return 0; @@ -562,6 +564,30 @@ error: return -EINVAL; } =20 +/* + * combine S1 and S2 TLB entries into a single entry. + * As a result the S1 entry is overriden with combined data. + */ +static void __attribute__((unused)) combine_tlb(SMMUTLBEntry *tlbe, + SMMUTLBEntry *tlbe_s2, + dma_addr_t iova, + SMMUTransCfg *cfg) +{ + if (tlbe_s2->entry.addr_mask < tlbe->entry.addr_mask) { + tlbe->entry.addr_mask =3D tlbe_s2->entry.addr_mask; + tlbe->granule =3D tlbe_s2->granule; + tlbe->level =3D tlbe_s2->level; + } + + tlbe->entry.translated_addr =3D CACHED_ENTRY_TO_ADDR(tlbe_s2, + tlbe->entry.translated_addr); + + tlbe->entry.iova =3D iova & ~tlbe->entry.addr_mask; + /* parent_perm has s2 perm while perm keeps s1 perm. */ + tlbe->parent_perm =3D tlbe_s2->entry.perm; + return; +} + /** * smmu_ptw - Walk the page tables for an IOVA, according to @cfg * @@ -629,9 +655,12 @@ SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransC= fg *cfg, dma_addr_t addr, =20 cached_entry =3D smmu_iotlb_lookup(bs, cfg, &tt_combined, addr); if (cached_entry) { - if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { + if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & + cached_entry->parent_perm & IOMMU_WO)) { info->type =3D SMMU_PTW_ERR_PERMISSION; - info->stage =3D cfg->stage; + info->stage =3D !(cached_entry->entry.perm & IOMMU_WO) ? + SMMU_STAGE_1 : + SMMU_STAGE_2; return NULL; } return cached_entry; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308903; cv=none; d=zohomail.com; s=zohoarc; b=LZezpzjKzkJ67/K2qerzaCqF9GXF4xEco17UDyT9tF1A12Ii8VYNgHcnZoIkc+8yBZ+U+19QX+ozG1eBJLGt9kaH1gZYm6nHiZ1hSNTDuxJ6ZjzBRqz7ZynYdiqPRkAfJhA/ogiGqH61xkCX3So7UHdd+5PZQOCdHQbCWwnoOJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308903; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=wmpf63yo5K0dFoH42GioZzE5DZ52sf+lBkHwuB49yuw=; b=hINnGCwt4xNfqHgwF2nuxw/b/Ff4xMcdpcjdV2Bpt8NUaTOfoUIfUlI4K3I8oA9EJfJ3IYpWIwsptO3ps7YpM+oJ3TnLXDhFLDKhniF+0SKuXXG5ngTdRU6hz6tOFs5Xv3x/hETK4ST0mKpjVA7cE722JP7U92zpkvesQXAo75Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308903558928.7331369412784; Thu, 18 Jul 2024 06:21:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR4A-0001xM-Fr; Thu, 18 Jul 2024 09:21:02 -0400 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 1sUR3q-0008NV-VC for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3n-0004Uk-LB for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2ee920b0781so10537141fa.1 for ; Thu, 18 Jul 2024 06:20:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308837; x=1721913637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wmpf63yo5K0dFoH42GioZzE5DZ52sf+lBkHwuB49yuw=; b=yGhAmYzPOhY6q4Lenp8Iy/nrmyaoIjP2UhQqo95w0ocHbVoyeuClxLNnjFEOI2OpRg nIJ06VpIIjh48yhiiEcfREkXegB6PTPHGEsVxW2MNanlagYplkoCTCuleFhZocbQu1h2 A2usw0Ixzlnh2Mb00XX20FQicUjd3fpC9aOSyY8BRdmJsmKEc2TRFI+iic75782P2ca5 d3qPvw3X0NGow8kZZL9QP1+QzIvZwLL4ZWlSN2uyN2v5mVy51KFhWAOpDuFwNXxWMZq9 CdA3F5q71yJRunhp3djXM8kNXzIWh6GZqp/Mz5I26GGS7iToQIBAxgdeZw9iAgJdoRqa KDgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308837; x=1721913637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmpf63yo5K0dFoH42GioZzE5DZ52sf+lBkHwuB49yuw=; b=GNZNUpz2FLsx0eJ+ToLb358X3ajfdwBgyWmaoxq056QiYynN1fybmjG8HBtQGEbLnY lsweqdRRUdCpkDdKLaPsI7U6epCiYfXlsOdglctKEktVGsjfpjueG9jumw4L09qXFhWB PMzQ0+xkZyr2X2u14mNGbiLPEQeUJBsCE+qpPTNWSgU5hwlyvtA0d8gl0ERHRtHqF+CJ iWTRtmunSHgiiiBVpg3HyrOFvEOQjw+8MoMsJdGKmCG8JQYJL4hAEQ5861ZClUpIlAMt hJrm2LIWS04kginhVT5Du6Lbh2jXhVnZXK6FVEc3tkfhOSZTK5SVYpGJwUtF81bopCC0 X7Qg== X-Gm-Message-State: AOJu0Ywdm8ZOULInVbU4MLi6VEBdX3r+avXy9EV2ZiolrDf6OPCxmPlK pdL6nyw6JnyLAV3sZobN7I1Fj3Ve0g5PPjOfUEp71IsffgzGIlAeYvTqk9FTaj7ZpWmJeiLfVnZ Q X-Google-Smtp-Source: AGHT+IHK5pG/rkgLd4fkn5paDdEgkzm5RVUZptce9d/PL4/jUoS/XF0krJyimfbifF8PsO3d68GnNQ== X-Received: by 2002:a2e:b88d:0:b0:2ec:42db:96a2 with SMTP id 38308e7fff4ca-2ef05c9d964mr20833451fa.29.1721308837332; Thu, 18 Jul 2024 06:20:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/26] hw/arm/smmu-common: Support nested translation Date: Thu, 18 Jul 2024 14:20:16 +0100 Message-Id: <20240718132028.697927-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::229; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x229.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308907755116600 From: Mostafa Saleh When nested translation is requested, do the following: - Translate stage-1 table address IPA into PA through stage-2. - Translate stage-1 table walk output (IPA) through stage-2. - Create a single TLB entry from stage-1 and stage-2 translations using logic introduced before. smmu_ptw() has a new argument SMMUState which include the TLB as stage-1 table address can be cached in there. Also in smmu_ptw(), a separate path used for nesting to simplify the code, although some logic can be combined. With nested translation class of translation fault can be different, from the class of the translation, as faults from translating stage-1 tables are considered as CLASS_TT and not CLASS_IN, a new member "is_ipa_descriptor" added to "SMMUPTWEventInfo" to differ faults from walking stage 1 translation table and faults from translating an IPA for a transaction. Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-12-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 7 ++-- hw/arm/smmu-common.c | 74 +++++++++++++++++++++++++++++++----- hw/arm/smmuv3.c | 14 +++++++ 3 files changed, 82 insertions(+), 13 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 08775364723..a51005e8b84 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -63,6 +63,7 @@ typedef struct SMMUPTWEventInfo { SMMUStage stage; SMMUPTWEventType type; dma_addr_t addr; /* fetched address that induced an abort, if any */ + bool is_ipa_descriptor; /* src for fault in nested translation. */ } SMMUPTWEventInfo; =20 typedef struct SMMUTransTableInfo { @@ -184,9 +185,9 @@ static inline uint16_t smmu_get_sid(SMMUDevice *sdev) * smmu_ptw - Perform the page table walk for a given iova / access flags * pair, according to @cfg translation config */ -int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, - SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info); - +int smmu_ptw(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t iova, + IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, + SMMUPTWEventInfo *info); =20 /* * smmu_translate - Look for a translation in TLB, if not, do a PTW. diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index bf55b9c5a42..912b89b5eeb 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -318,8 +318,41 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_a= ddr_t iova) return NULL; } =20 +/* Translate stage-1 table address using stage-2 page table. */ +static inline int translate_table_addr_ipa(SMMUState *bs, + dma_addr_t *table_addr, + SMMUTransCfg *cfg, + SMMUPTWEventInfo *info) +{ + dma_addr_t addr =3D *table_addr; + SMMUTLBEntry *cached_entry; + int asid; + + /* + * The translation table walks performed from TTB0 or TTB1 are always + * performed in IPA space if stage 2 translations are enabled. + */ + asid =3D cfg->asid; + cfg->stage =3D SMMU_STAGE_2; + cfg->asid =3D -1; + cached_entry =3D smmu_translate(bs, cfg, addr, IOMMU_RO, info); + cfg->asid =3D asid; + cfg->stage =3D SMMU_NESTED; + + if (cached_entry) { + *table_addr =3D CACHED_ENTRY_TO_ADDR(cached_entry, addr); + return 0; + } + + info->stage =3D SMMU_STAGE_2; + info->addr =3D addr; + info->is_ipa_descriptor =3D true; + return -EINVAL; +} + /** * smmu_ptw_64_s1 - VMSAv8-64 Walk of the page tables for a given IOVA + * @bs: smmu state which includes TLB instance * @cfg: translation config * @iova: iova to translate * @perm: access type @@ -331,7 +364,7 @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_ad= dr_t iova) * Upon success, @tlbe is filled with translated_addr and entry * permission rights. */ -static int smmu_ptw_64_s1(SMMUTransCfg *cfg, +static int smmu_ptw_64_s1(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) { @@ -381,6 +414,11 @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, goto error; } baseaddr =3D get_table_pte_address(pte, granule_sz); + if (cfg->stage =3D=3D SMMU_NESTED) { + if (translate_table_addr_ipa(bs, &baseaddr, cfg, info)) { + goto error; + } + } level++; continue; } else if (is_page_pte(pte, level)) { @@ -568,10 +606,8 @@ error: * combine S1 and S2 TLB entries into a single entry. * As a result the S1 entry is overriden with combined data. */ -static void __attribute__((unused)) combine_tlb(SMMUTLBEntry *tlbe, - SMMUTLBEntry *tlbe_s2, - dma_addr_t iova, - SMMUTransCfg *cfg) +static void combine_tlb(SMMUTLBEntry *tlbe, SMMUTLBEntry *tlbe_s2, + dma_addr_t iova, SMMUTransCfg *cfg) { if (tlbe_s2->entry.addr_mask < tlbe->entry.addr_mask) { tlbe->entry.addr_mask =3D tlbe_s2->entry.addr_mask; @@ -591,6 +627,7 @@ static void __attribute__((unused)) combine_tlb(SMMUTLB= Entry *tlbe, /** * smmu_ptw - Walk the page tables for an IOVA, according to @cfg * + * @bs: smmu state which includes TLB instance * @cfg: translation configuration * @iova: iova to translate * @perm: tentative access type @@ -599,11 +636,15 @@ static void __attribute__((unused)) combine_tlb(SMMUT= LBEntry *tlbe, * * return 0 on success */ -int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, - SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) +int smmu_ptw(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t iova, + IOMMUAccessFlags perm, SMMUTLBEntry *tlbe, SMMUPTWEventInfo *= info) { + int ret; + SMMUTLBEntry tlbe_s2; + dma_addr_t ipa; + if (cfg->stage =3D=3D SMMU_STAGE_1) { - return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info); + return smmu_ptw_64_s1(bs, cfg, iova, perm, tlbe, info); } else if (cfg->stage =3D=3D SMMU_STAGE_2) { /* * If bypassing stage 1(or unimplemented), the input address is pa= ssed @@ -621,7 +662,20 @@ int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMU= AccessFlags perm, return smmu_ptw_64_s2(cfg, iova, perm, tlbe, info); } =20 - g_assert_not_reached(); + /* SMMU_NESTED. */ + ret =3D smmu_ptw_64_s1(bs, cfg, iova, perm, tlbe, info); + if (ret) { + return ret; + } + + ipa =3D CACHED_ENTRY_TO_ADDR(tlbe, iova); + ret =3D smmu_ptw_64_s2(cfg, ipa, perm, &tlbe_s2, info); + if (ret) { + return ret; + } + + combine_tlb(tlbe, &tlbe_s2, iova, cfg); + return 0; } =20 SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCfg *cfg, dma_addr_t = addr, @@ -667,7 +721,7 @@ SMMUTLBEntry *smmu_translate(SMMUState *bs, SMMUTransCf= g *cfg, dma_addr_t addr, } =20 cached_entry =3D g_new0(SMMUTLBEntry, 1); - status =3D smmu_ptw(cfg, addr, flag, cached_entry, info); + status =3D smmu_ptw(bs, cfg, addr, flag, cached_entry, info); if (status) { g_free(cached_entry); return NULL; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 5c5fee27997..0faa08c8d8b 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -910,6 +910,20 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv= 3State *s, hwaddr addr, if (!cached_entry) { /* All faults from PTW has S2 field. */ event->u.f_walk_eabt.s2 =3D (ptw_info.stage =3D=3D SMMU_STAGE_2); + /* + * Fault class is set as follows based on "class" input to + * the function and to "ptw_info" from "smmu_translate()" + * For stage-1: + * - EABT =3D> CLASS_TT (hardcoded) + * - other events =3D> CLASS_IN (input to function) + * For stage-2 =3D> CLASS_IN (input to function) + * For nested, for all events: + * - CD fetch =3D> CLASS_CD (input to function) + * - walking stage 1 translation table =3D> CLASS_TT (from + * is_ipa_descriptor or input in case of TTBx) + * - s2 translation =3D> CLASS_IN (input to function) + */ + class =3D ptw_info.is_ipa_descriptor ? SMMU_CLASS_TT : class; switch (ptw_info.type) { case SMMU_PTW_ERR_WALK_EABT: event->type =3D SMMU_EVT_F_WALK_EABT; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309021; cv=none; d=zohomail.com; s=zohoarc; b=e+FCvVTIDKn3ReW4A3O7W6H2/IkwQgsza2F6L76jFYBt0xlF7v29DeqVFmcVFgzAoDbh37WX2ShOIXOHYoNz5hUxT4+yZIB8D0dWpLuMnaIoVuGezXCPMCSPneJc+TORQZMhHgwSW5bRxzExZtJXdJzBS3vWlxCAPldj/I/45PA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309021; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=c1fMPYzgCA2DuMUlUIDYiJmgobhZB3k3qf0MZrgR6xo=; b=NnSJLdY84bA0Q+kGd4ctqC/9zNXhYlLmuEu79NwKzxZtgLpFHmC6U5NTMSOO+BBF0YRsCqo975fAwHievN3MpDvrd4yzKI1ogpfvoebbQhwGJVAR9eM9/i09tGRN/PWTbvrnonvs3LoGcxAZTvF7PwFzhbXBgEBr9qhzYyT0XMI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309021320711.6657441992834; Thu, 18 Jul 2024 06:23:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR46-0001V4-J0; Thu, 18 Jul 2024 09:20:58 -0400 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 1sUR3q-0008NQ-UQ for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3n-0004Uq-L8 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4266f535e82so2693395e9.1 for ; Thu, 18 Jul 2024 06:20:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308838; x=1721913638; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=c1fMPYzgCA2DuMUlUIDYiJmgobhZB3k3qf0MZrgR6xo=; b=hNy974+eltWfo6pxlWh44OnfoccAgo9p1nG+gywIFk0c9oKZBLv8ocBnBQ/TgSGfzK 2M43BufzPD7WFFfqSXdKXy5oo498aLA9qXETx/+64ZXJd1fL2rTo90/KACSkq7OPZjK+ vK81OF3XhvKtbTXeh1MUwbeOkvgLZZ9rMmvSgF/11NsxcNKaThNWJVlQKLtodadOPJeM R58aHfp8rRItTC+CJU43csCn3Bs3odoPr5hbYgG1snMcqq6WB3vo9GBXpCmlDoDSqSQH DuhEpChIwcLPTl0BeF1WghwrxNRv8TcZPjdAmEqmk1FcdKsAekqdu8h7dm4CK8NVnMy2 +hHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308838; x=1721913638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c1fMPYzgCA2DuMUlUIDYiJmgobhZB3k3qf0MZrgR6xo=; b=NibgEeXgKjfauBvRBzZ016jGKMkOZaAIZsFf+DDM2DfwYeHSuHO2FMWTxhUc2Hcnl/ DW3NhWHDzVHVIxFTsTlJZOCrYulLQoawHhg9FaZaQBRpu+S09iKFsz0H62ZvfM8d+cPH DPo/L0efT4xSiHzRxxs286W8G/l8fg+qa1ma3J+MWWfZCI3ZqPxQgElxQeIR+XlATHF7 vhTYtN8pTPubOYEOqRgoC+v1xRcYJG3bWrUjjABHCa5p8wLSJlnYsFSZAumPrEzZ32J/ kJur3pG0niDSUiQ+PewVJ/zq1BjUJBpuDYjn2Wc2ok7Lbxst5s2PutBvjcPz7lakvGrI 38mg== X-Gm-Message-State: AOJu0YzUJoSOxWqugfs9jpRc0RAVQEpTuAOle1NH0IpCrZnWhDhKkA5y rE1vE3pvldpG7jEeUvs1kJGIE3lDamZV5vZqMwWTfAHrRSPzII1/cZ2+pau+oBSmOExBBE8EA5m r X-Google-Smtp-Source: AGHT+IHFPR0b+8bziwlYILmJV5YP2neILXf5Kl5THDcQjNX+y93aDGENYEBQt2bJo217FYQpnoCqaw== X-Received: by 2002:a05:600c:4fc6:b0:426:5de3:2ae5 with SMTP id 5b1f17b1804b1-427c2cb0d7bmr39062965e9.10.1721308837814; Thu, 18 Jul 2024 06:20:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/26] hw/arm/smmu: Support nesting in smmuv3_range_inval() Date: Thu, 18 Jul 2024 14:20:17 +0100 Message-Id: <20240718132028.697927-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309022999116600 From: Mostafa Saleh With nesting, we would need to invalidate IPAs without over-invalidating stage-1 IOVAs. This can be done by distinguishing IPAs in the TLBs by having ASID=3D-1. To achieve that, rework the invalidation for IPAs to have a separate function, while for IOVA invalidation ASID=3D-1 means invalidate for all ASIDs. Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-13-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 3 ++- hw/arm/smmu-common.c | 47 ++++++++++++++++++++++++++++++++++++ hw/arm/smmuv3.c | 23 ++++++++++++------ hw/arm/trace-events | 2 +- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index a51005e8b84..da9ff45fb5a 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -217,7 +217,8 @@ void smmu_iotlb_inv_asid(SMMUState *s, int asid); void smmu_iotlb_inv_vmid(SMMUState *s, int vmid); void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl); - +void smmu_iotlb_inv_ipa(SMMUState *s, int vmid, dma_addr_t ipa, uint8_t tg, + uint64_t num_pages, uint8_t ttl); /* Unmap the range of all the notifiers registered to any IOMMU mr */ void smmu_inv_notifiers_all(SMMUState *s); =20 diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 912b89b5eeb..4b0857ab4d7 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -195,6 +195,25 @@ static gboolean smmu_hash_remove_by_asid_vmid_iova(gpo= inter key, gpointer value, ((entry->iova & ~info->mask) =3D=3D info->iova); } =20 +static gboolean smmu_hash_remove_by_vmid_ipa(gpointer key, gpointer value, + gpointer user_data) +{ + SMMUTLBEntry *iter =3D (SMMUTLBEntry *)value; + IOMMUTLBEntry *entry =3D &iter->entry; + SMMUIOTLBPageInvInfo *info =3D (SMMUIOTLBPageInvInfo *)user_data; + SMMUIOTLBKey iotlb_key =3D *(SMMUIOTLBKey *)key; + + if (SMMU_IOTLB_ASID(iotlb_key) >=3D 0) { + /* This is a stage-1 address. */ + return false; + } + if (info->vmid !=3D SMMU_IOTLB_VMID(iotlb_key)) { + return false; + } + return ((info->iova & ~entry->addr_mask) =3D=3D entry->iova) || + ((entry->iova & ~info->mask) =3D=3D info->iova); +} + void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl) { @@ -223,6 +242,34 @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, int v= mid, dma_addr_t iova, &info); } =20 +/* + * Similar to smmu_iotlb_inv_iova(), but for Stage-2, ASID is always -1, + * in Stage-1 invalidation ASID =3D -1, means don't care. + */ +void smmu_iotlb_inv_ipa(SMMUState *s, int vmid, dma_addr_t ipa, uint8_t tg, + uint64_t num_pages, uint8_t ttl) +{ + uint8_t granule =3D tg ? tg * 2 + 10 : 12; + int asid =3D -1; + + if (ttl && (num_pages =3D=3D 1)) { + SMMUIOTLBKey key =3D smmu_get_iotlb_key(asid, vmid, ipa, tg, ttl); + + if (g_hash_table_remove(s->iotlb, &key)) { + return; + } + } + + SMMUIOTLBPageInvInfo info =3D { + .iova =3D ipa, + .vmid =3D vmid, + .mask =3D (num_pages << granule) - 1}; + + g_hash_table_foreach_remove(s->iotlb, + smmu_hash_remove_by_vmid_ipa, + &info); +} + void smmu_iotlb_inv_asid(SMMUState *s, int asid) { trace_smmu_iotlb_inv_asid(asid); diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 0faa08c8d8b..ebf29f3adf7 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1168,7 +1168,7 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, i= nt asid, int vmid, } } =20 -static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) +static void smmuv3_range_inval(SMMUState *s, Cmd *cmd, SMMUStage stage) { dma_addr_t end, addr =3D CMD_ADDR(cmd); uint8_t type =3D CMD_TYPE(cmd); @@ -1193,9 +1193,13 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cm= d) } =20 if (!tg) { - trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); + trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf, stage= ); smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1); - smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); + if (stage =3D=3D SMMU_STAGE_1) { + smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); + } else { + smmu_iotlb_inv_ipa(s, vmid, addr, tg, 1, ttl); + } return; } =20 @@ -1211,9 +1215,14 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cm= d) uint64_t mask =3D dma_aligned_pow2_mask(addr, end, 64); =20 num_pages =3D (mask + 1) >> granule; - trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, lea= f); + trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, + ttl, leaf, stage); smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages); - smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); + if (stage =3D=3D SMMU_STAGE_1) { + smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); + } else { + smmu_iotlb_inv_ipa(s, vmid, addr, tg, num_pages, ttl); + } addr +=3D mask + 1; } } @@ -1368,7 +1377,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) cmd_error =3D SMMU_CERROR_ILL; break; } - smmuv3_range_inval(bs, &cmd); + smmuv3_range_inval(bs, &cmd, SMMU_STAGE_1); break; case SMMU_CMD_TLBI_S12_VMALL: { @@ -1393,7 +1402,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) * As currently only either s1 or s2 are supported * we can reuse same function for s2. */ - smmuv3_range_inval(bs, &cmd); + smmuv3_range_inval(bs, &cmd, SMMU_STAGE_2); break; case SMMU_CMD_TLBI_EL3_ALL: case SMMU_CMD_TLBI_EL3_VA: diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 09ccd39548f..7d9c1703da1 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -46,7 +46,7 @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=3D0= x%x - end=3D0x%x" smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=3D0x%x" smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint= 32_t perc) "Config cache HIT for sid=3D0x%x (hits=3D%d, misses=3D%d, hit ra= te=3D%d)" smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uin= t32_t perc) "Config cache MISS for sid=3D0x%x (hits=3D%d, misses=3D%d, hit = rate=3D%d)" -smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t= num_pages, uint8_t ttl, bool leaf) "vmid=3D%d asid=3D%d addr=3D0x%"PRIx64"= tg=3D%d num_pages=3D0x%"PRIx64" ttl=3D%d leaf=3D%d" +smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t= num_pages, uint8_t ttl, bool leaf, int stage) "vmid=3D%d asid=3D%d addr=3D= 0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64" ttl=3D%d leaf=3D%d stage=3D%d" smmuv3_cmdq_tlbi_nh(void) "" smmuv3_cmdq_tlbi_nh_asid(int asid) "asid=3D%d" smmuv3_cmdq_tlbi_s12_vmid(int vmid) "vmid=3D%d" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308901; cv=none; d=zohomail.com; s=zohoarc; b=S2KpUFC2gltQFDznbA32cZMy6kIb7THxZj99r3Xwpn/ROdpJj25dRoWBu07x+QZ6YqT4HSX0WiqfsV5FlVZLbd1S5hjVDWf/DdHwZJCDb6ro2daEVHvlCFsEJAxO3MonIQbW7/4mXDGcs+TBhNYiZsiV4h62wdZr6JvVFo1Y6rE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308901; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=sA1K5/Oeol4qp2eoj4lcjjemIJtuASvZg2EHT+nPS3A=; b=a1e9EWKaDjbjDGUUfP+IW3TzKIpZFs9OYVnZBaVLP4ScHIzV4zQcntDQqgEugIoxts/dH8Lwj2TjtMENhCXu4eaYaSA6c4cXWb0lg9q8ZhdB1nu5cfHmHR7vrGKni74HOZw1M0MRhVSEi928lp7n0VICaWzREK5yR7w2UwABTHk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308901111105.08411204391916; Thu, 18 Jul 2024 06:21:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR49-0001pR-Cz; Thu, 18 Jul 2024 09:21:01 -0400 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 1sUR3q-0008Nb-Vo for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3o-0004V2-Iq for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4272738eb9eso2687385e9.3 for ; Thu, 18 Jul 2024 06:20:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308838; x=1721913638; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sA1K5/Oeol4qp2eoj4lcjjemIJtuASvZg2EHT+nPS3A=; b=SAzlInyZ7HieFRSNQYa9FZTeZpLPRPPNYNx7lPwXIXB0uPEkmZIVdyAzCfYqZrVdAy VFb4YFORKiIRf0xq2k7QsChMhCAytuXBsO0OyuAqbNr66M/vqowa2VFjxZGAdrZrGcwA TNG95dkA6V0spMsv8RCotAQm/7k/Ct9GHS8+AC8hIOGfBBn2viwNGPf4Z2K5b0210deH lyBccN1CGdLBCZaZUOCO7p5J8gkF5oLTYTRkBpWLzb5TmKnIXu8kKqtXy6t+3ZGzT9Fn ZWTHIq2Yfn3ASvWOoTFYfUDxHcHzePCl+kwGBszHV/ur+QjSrwvqLanctxNVwSa03SNi WOGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308838; x=1721913638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sA1K5/Oeol4qp2eoj4lcjjemIJtuASvZg2EHT+nPS3A=; b=MVn3l1wZtNPjqthAduhc4f/CL50EpTYl7/WgFvyOX00FsQJmdMXMRgejlcOKPmod3w F2VpVOlqJHbBgcAR58K+ktrwWM3NrBi/1CGiEf1i1OwCgvmMsNZblb1mt2HiTTxacrO8 UXtMIlFOffBA/Kn92igd2k1okRsKI0z+FvTaC+b4KTdIAorEDaUvEeCQaf405TNc0kpy NP/TB3YshQXAig7WvU0GtOePbdcoJNZB5D2F6jp9H00YXhKMNMKBekucs+aJW/PIiL7d TuVpWFXUGPZ+aThJCAO5bTTI4/2cpnXnfwkGoHy8atXOamsBtUjl9PHleGSRz5r7gKpJ K0Ng== X-Gm-Message-State: AOJu0YxilnN5s0RKsKvqqnIHqNdRSTEwbZPaNGcSmZS2WFSXQ3UZVbP7 OV4l2G347lACub87CqSkYDs1hygABJ5ZF5hwtfvp4Km61LCpPk46xZQXSr5RVgQDpRPGNtAjAAc M X-Google-Smtp-Source: AGHT+IHQzqjAA469010/g1HtMi0tQKIAS8p3PqpaURCKfGx6mGa8S5TsMjQo32Jwig3WwkgK9moE2A== X-Received: by 2002:a05:600c:4e92:b0:426:5c34:b19b with SMTP id 5b1f17b1804b1-427c2cc33damr30765765e9.20.1721308838254; Thu, 18 Jul 2024 06:20:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/26] hw/arm/smmu: Introduce smmu_iotlb_inv_asid_vmid Date: Thu, 18 Jul 2024 14:20:18 +0100 Message-Id: <20240718132028.697927-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32e.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308903757116600 From: Mostafa Saleh Soon, Instead of doing TLB invalidation by ASID only, VMID will be also required. Add smmu_iotlb_inv_asid_vmid() which invalidates by both ASID and VMID. However, at the moment this function is only used in SMMU_CMD_TLBI_NH_ASID which is a stage-1 command, so passing VMID =3D -1 keeps the original behaviour. Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-14-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 2 +- hw/arm/smmu-common.c | 20 +++++++++++++------- hw/arm/smmuv3.c | 2 +- hw/arm/trace-events | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index da9ff45fb5a..eaee867e45c 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -213,7 +213,7 @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg= , SMMUTLBEntry *entry); SMMUIOTLBKey smmu_get_iotlb_key(int asid, int vmid, uint64_t iova, uint8_t tg, uint8_t level); void smmu_iotlb_inv_all(SMMUState *s); -void smmu_iotlb_inv_asid(SMMUState *s, int asid); +void smmu_iotlb_inv_asid_vmid(SMMUState *s, int asid, int vmid); void smmu_iotlb_inv_vmid(SMMUState *s, int vmid); void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl); diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 4b0857ab4d7..e7f9c758fa6 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -159,13 +159,14 @@ void smmu_iotlb_inv_all(SMMUState *s) g_hash_table_remove_all(s->iotlb); } =20 -static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, - gpointer user_data) +static gboolean smmu_hash_remove_by_asid_vmid(gpointer key, gpointer value, + gpointer user_data) { - int asid =3D *(int *)user_data; + SMMUIOTLBPageInvInfo *info =3D (SMMUIOTLBPageInvInfo *)user_data; SMMUIOTLBKey *iotlb_key =3D (SMMUIOTLBKey *)key; =20 - return SMMU_IOTLB_ASID(*iotlb_key) =3D=3D asid; + return (SMMU_IOTLB_ASID(*iotlb_key) =3D=3D info->asid) && + (SMMU_IOTLB_VMID(*iotlb_key) =3D=3D info->vmid); } =20 static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value, @@ -270,10 +271,15 @@ void smmu_iotlb_inv_ipa(SMMUState *s, int vmid, dma_a= ddr_t ipa, uint8_t tg, &info); } =20 -void smmu_iotlb_inv_asid(SMMUState *s, int asid) +void smmu_iotlb_inv_asid_vmid(SMMUState *s, int asid, int vmid) { - trace_smmu_iotlb_inv_asid(asid); - g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); + SMMUIOTLBPageInvInfo info =3D { + .asid =3D asid, + .vmid =3D vmid, + }; + + trace_smmu_iotlb_inv_asid_vmid(asid, vmid); + g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid_vmid, &= info); } =20 void smmu_iotlb_inv_vmid(SMMUState *s, int vmid) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index ebf29f3adf7..847fc566762 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1357,7 +1357,7 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) =20 trace_smmuv3_cmdq_tlbi_nh_asid(asid); smmu_inv_notifiers_all(&s->smmu_state); - smmu_iotlb_inv_asid(bs, asid); + smmu_iotlb_inv_asid_vmid(bs, asid, -1); break; } case SMMU_CMD_TLBI_NH_ALL: diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 7d9c1703da1..4aa71b1b196 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -11,7 +11,7 @@ smmu_ptw_page_pte(int stage, int level, uint64_t iova, u= int64_t baseaddr, uint6 smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t ptead= dr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=3D%d le= vel=3D%d base@=3D0x%"PRIx64" pte@=3D0x%"PRIx64" pte=3D0x%"PRIx64" iova=3D0x= %"PRIx64" block address =3D 0x%"PRIx64" block size =3D %d MiB" smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte)= "baseaddr=3D0x%"PRIx64" index=3D0x%x, pteaddr=3D0x%"PRIx64", pte=3D0x%"PRI= x64 smmu_iotlb_inv_all(void) "IOTLB invalidate all" -smmu_iotlb_inv_asid(int asid) "IOTLB invalidate asid=3D%d" +smmu_iotlb_inv_asid_vmid(int asid, int vmid) "IOTLB invalidate asid=3D%d v= mid=3D%d" smmu_iotlb_inv_vmid(int vmid) "IOTLB invalidate vmid=3D%d" smmu_iotlb_inv_iova(int asid, uint64_t addr) "IOTLB invalidate asid=3D%d a= ddr=3D0x%"PRIx64 smmu_inv_notifiers_mr(const char *name) "iommu mr=3D%s" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308988; cv=none; d=zohomail.com; s=zohoarc; b=YD90IXrRk9OHzeSiYwJdrQOeCYm4HbQiu1vsbxhXwBG1/qjdxVLIfNXqN6gYFwnogj+riBxxEYHaSw8QDNFx2QsQAvCccmVMoaXpxYa6tP44HJvQPKIGx3nnLzbzvqGLkS7GcvWcwZXe1mMCro2Y0aJzQu6xYhdiVf5GxUFZzKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308988; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=+FR9ItM1E+ZFzcj4FqnB5x/ksRo36l8sRb32O5wsYr8=; b=dViA+9MQ656727/LX/0xRS/Ro1tcMIolIWVPUeoyQEfGphhLJ0MwSu0BduCZlmX1tDkIXuGp+fgP6LN+FiqwUm05TZdDURyNB/hlwVC74kSfjMjyV9OX3+/j7/+BeYLPeDitDLisG8MrmNuGWTJQqX50Vt+WvtrxiPf7OsRyjUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308988200186.1086729807222; Thu, 18 Jul 2024 06:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR40-0000pv-Ek; Thu, 18 Jul 2024 09:20:52 -0400 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 1sUR3q-0008NO-Ut for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3o-0004VP-JF for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4266ea6a488so3125705e9.1 for ; Thu, 18 Jul 2024 06:20:39 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308838; x=1721913638; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+FR9ItM1E+ZFzcj4FqnB5x/ksRo36l8sRb32O5wsYr8=; b=lETkxEMVcqp2NopLM15J1FEY0tsfo2zxaS5OKWxtdav/OhFYfo/daU5oQaYYy4M71n sUp7vLNwpPxeKWy0GqR8l8dlQuwWqWqOhkaVf4C4NPamIyuTjI/1czUun9Yc+ocG1sQN /zi1+3Q+oZPjjhF6I5pwbj8CCIZoy0lQPt+hNk0+vaYxGihbCK5RcGkEAXQTTzhgyXez 3i9tVrTKHDcyCTTFgPukBQ7PvjQuXw0Z4e4/Ye9GCM41Bpk224rcLpIiLaEyXjcBQBlz 86yRg9ZoatfkZLpB/6SCdUWUJE57KG+fnGs9Slhf75gsYZ7SQbAkDswgDAhmmbSO4ggK Ebug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308838; x=1721913638; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+FR9ItM1E+ZFzcj4FqnB5x/ksRo36l8sRb32O5wsYr8=; b=K+OBV1YvIOfjzcXjinuHUQj+OpeUx+4JH/gusbxymlm0tlUAJNyU0B+Sd1CxGuhiHU TxqUx2h3c48q1gbVW2wWpzq5p2IhA81+4ICXUNoxmi56b7vAbwgJoRW4eNxqFKIOBN+b iKkMDSGeIwwIXsRG/V6VMvSS0msdKxqlw/z2fWL9GjKSlVQlpd5KVDSkRPHHwlLzdl93 F1YTIruX3rSocuR3nNVn4HzCgLRwbYeM2lcIehwY5wgesFEAqQv8gc+/8QET47hX6ig7 luI1ErhRs8QaNaPAmcc0LWdaPmLoARYhocdhH9btWbdREOXfQm2J1iLGt+jm6H0L9E4t O+KQ== X-Gm-Message-State: AOJu0Yz4Z480KTfwmUiiqBAW1td+tLl1lzVEcDDX2UKs3f2Ak83NpE8f 0kL7a8KtCjMSP+jLcV+0gLjwEeV1O1kfa1YtoJL/jdfL5xgyC6sG56EKqupV5oJp18ep9EUz9rZ F X-Google-Smtp-Source: AGHT+IEjIVo1VXpz2TKA2akunUSc38fBsxVdKE5U8n+kcvuiFXGCEdWYk5kaXA8Ts2DxZw4tQR6C9Q== X-Received: by 2002:a05:600c:1d20:b0:426:6ed5:fcb with SMTP id 5b1f17b1804b1-427c2cad3c2mr41347395e9.4.1721308838723; Thu, 18 Jul 2024 06:20:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/26] hw/arm/smmu: Support nesting in the rest of commands Date: Thu, 18 Jul 2024 14:20:19 +0100 Message-Id: <20240718132028.697927-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308988930116600 From: Mostafa Saleh Some commands need rework for nesting, as they used to assume S1 and S2 are mutually exclusive: - CMD_TLBI_NH_ASID: Consider VMID if stage-2 is supported - CMD_TLBI_NH_ALL: Consider VMID if stage-2 is supported, otherwise invalidate everything, this required a new vmid invalidation function for stage-1 only (ASID >=3D 0) Also, rework trace events to reflect the new implementation. Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-15-smostafa@google.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 1 + hw/arm/smmu-common.c | 16 ++++++++++++++++ hw/arm/smmuv3.c | 28 ++++++++++++++++++++++++++-- hw/arm/trace-events | 4 +++- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index eaee867e45c..d1a4a64551d 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -215,6 +215,7 @@ SMMUIOTLBKey smmu_get_iotlb_key(int asid, int vmid, uin= t64_t iova, void smmu_iotlb_inv_all(SMMUState *s); void smmu_iotlb_inv_asid_vmid(SMMUState *s, int asid, int vmid); void smmu_iotlb_inv_vmid(SMMUState *s, int vmid); +void smmu_iotlb_inv_vmid_s1(SMMUState *s, int vmid); void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl); void smmu_iotlb_inv_ipa(SMMUState *s, int vmid, dma_addr_t ipa, uint8_t tg, diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index e7f9c758fa6..00d7579cd3d 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -178,6 +178,16 @@ static gboolean smmu_hash_remove_by_vmid(gpointer key,= gpointer value, return SMMU_IOTLB_VMID(*iotlb_key) =3D=3D vmid; } =20 +static gboolean smmu_hash_remove_by_vmid_s1(gpointer key, gpointer value, + gpointer user_data) +{ + int vmid =3D *(int *)user_data; + SMMUIOTLBKey *iotlb_key =3D (SMMUIOTLBKey *)key; + + return (SMMU_IOTLB_VMID(*iotlb_key) =3D=3D vmid) && + (SMMU_IOTLB_ASID(*iotlb_key) >=3D 0); +} + static gboolean smmu_hash_remove_by_asid_vmid_iova(gpointer key, gpointer = value, gpointer user_data) { @@ -288,6 +298,12 @@ void smmu_iotlb_inv_vmid(SMMUState *s, int vmid) g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid); } =20 +inline void smmu_iotlb_inv_vmid_s1(SMMUState *s, int vmid) +{ + trace_smmu_iotlb_inv_vmid_s1(vmid); + g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid_s1, &vm= id); +} + /* VMSAv8-64 Translation */ =20 /** diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 847fc566762..b05f2ab929b 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1349,25 +1349,49 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) case SMMU_CMD_TLBI_NH_ASID: { int asid =3D CMD_ASID(&cmd); + int vmid =3D -1; =20 if (!STAGE1_SUPPORTED(s)) { cmd_error =3D SMMU_CERROR_ILL; break; } =20 + /* + * VMID is only matched when stage 2 is supported, otherwise s= et it + * to -1 as the value used for stage-1 only VMIDs. + */ + if (STAGE2_SUPPORTED(s)) { + vmid =3D CMD_VMID(&cmd); + } + trace_smmuv3_cmdq_tlbi_nh_asid(asid); smmu_inv_notifiers_all(&s->smmu_state); - smmu_iotlb_inv_asid_vmid(bs, asid, -1); + smmu_iotlb_inv_asid_vmid(bs, asid, vmid); break; } case SMMU_CMD_TLBI_NH_ALL: + { + int vmid =3D -1; + if (!STAGE1_SUPPORTED(s)) { cmd_error =3D SMMU_CERROR_ILL; break; } + + /* + * If stage-2 is supported, invalidate for this VMID only, oth= erwise + * invalidate the whole thing. + */ + if (STAGE2_SUPPORTED(s)) { + vmid =3D CMD_VMID(&cmd); + trace_smmuv3_cmdq_tlbi_nh(vmid); + smmu_iotlb_inv_vmid_s1(bs, vmid); + break; + } QEMU_FALLTHROUGH; + } case SMMU_CMD_TLBI_NSNH_ALL: - trace_smmuv3_cmdq_tlbi_nh(); + trace_smmuv3_cmdq_tlbi_nsnh(); smmu_inv_notifiers_all(&s->smmu_state); smmu_iotlb_inv_all(bs); break; diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 4aa71b1b196..593cc571da7 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -13,6 +13,7 @@ smmu_get_pte(uint64_t baseaddr, int index, uint64_t ptead= dr, uint64_t pte) "base smmu_iotlb_inv_all(void) "IOTLB invalidate all" smmu_iotlb_inv_asid_vmid(int asid, int vmid) "IOTLB invalidate asid=3D%d v= mid=3D%d" smmu_iotlb_inv_vmid(int vmid) "IOTLB invalidate vmid=3D%d" +smmu_iotlb_inv_vmid_s1(int vmid) "IOTLB invalidate vmid=3D%d" smmu_iotlb_inv_iova(int asid, uint64_t addr) "IOTLB invalidate asid=3D%d a= ddr=3D0x%"PRIx64 smmu_inv_notifiers_mr(const char *name) "iommu mr=3D%s" smmu_iotlb_lookup_hit(int asid, int vmid, uint64_t addr, uint32_t hit, uin= t32_t miss, uint32_t p) "IOTLB cache HIT asid=3D%d vmid=3D%d addr=3D0x%"PRI= x64" hit=3D%d miss=3D%d hit rate=3D%d" @@ -47,7 +48,8 @@ smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=3D0x%x" smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint= 32_t perc) "Config cache HIT for sid=3D0x%x (hits=3D%d, misses=3D%d, hit ra= te=3D%d)" smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uin= t32_t perc) "Config cache MISS for sid=3D0x%x (hits=3D%d, misses=3D%d, hit = rate=3D%d)" smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t= num_pages, uint8_t ttl, bool leaf, int stage) "vmid=3D%d asid=3D%d addr=3D= 0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64" ttl=3D%d leaf=3D%d stage=3D%d" -smmuv3_cmdq_tlbi_nh(void) "" +smmuv3_cmdq_tlbi_nh(int vmid) "vmid=3D%d" +smmuv3_cmdq_tlbi_nsnh(void) "" smmuv3_cmdq_tlbi_nh_asid(int asid) "asid=3D%d" smmuv3_cmdq_tlbi_s12_vmid(int vmid) "vmid=3D%d" smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=3D0x%x" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309055; cv=none; d=zohomail.com; s=zohoarc; b=MdwAv5OQXKpBC14MA1j4rPYBmQIrM89inP28rvhvqUjMphS2s7jKSyFUZl3Sqd9iEtSFrets5xY2LZwHy+VEnRkVS/BC6iVjtTu5cLQxY/FrIkIZgHU5DtDiBbXFr19OjizK4w8UrUwbrDadQrjufISqkhFbdew744nUuvYnnjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309055; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=4YsbRAcT7lsG9lpifKyGsg4DpvurXs++XIcvW/WT4VE=; b=bXlxs7ZJS64fOVnzreynUe6g9Tf8fFdCyMg3vUcp08Jiss9KALs8t2/N/0x7ruYV+2oPbsE0UzxPaVxMfIm+SjswAK1ARhoI5i8V1enbP1VeGkAZ0mt4/7VxkHitWBO6lYn5ncuvw1kaD32kbQPtMt0/8OHT7afVnT/S4n++aVU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309055064819.7000642668339; Thu, 18 Jul 2024 06:24:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR47-0001Yf-1I; Thu, 18 Jul 2024 09:20:59 -0400 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 1sUR3q-0008NM-UQ for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3o-0004VW-JN for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:42 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so2146005e9.1 for ; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308839; x=1721913639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4YsbRAcT7lsG9lpifKyGsg4DpvurXs++XIcvW/WT4VE=; b=e7kniiFF0YxsDIRtdbc5fI58HmBgQe1uHLjWHj9xUg7D/HTVXQkHfikP/IVClxaGnh 2o96e1lVujRvKBmP9RlO5N2DGo/uyBkrZb6o5V08LRH6wup93+CA/xL+v/g+moF7j73E bWq7mCe9I/bWwPUwDpUeSPLvR4h068125X6HA1E+Z3nsciWfk3FKjTrM/k4jJ48vLB0p SU9PjWmvTKYIU+FsgcJOfEjRKeb22p5a/hI0znPaaJTxV/10xBh2HZCNAXemIqOdqHJq WtxdL3zNLLpOeZ7gWX3RYmTMxwDLlVBYYykk7aIeteNwbLbLr5aPR3uf5vxdPthkDat2 tMeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308839; x=1721913639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YsbRAcT7lsG9lpifKyGsg4DpvurXs++XIcvW/WT4VE=; b=j06HytmQ3sR2a1QjnnbQBCieSYeZqFVdtdLLxMAM0snQxxTXDYpc5DbwvbT4NqIGq+ BnNdOZYanOGjv32lf/VyVNwl9MltJR+NAmZOCl0HYhvIbKThXCUI4qMpX2kWrBP/hiVE pKdhErdAVzZgfw5YMErwutNjEl3XJZA5KNCUCI1dUQFL31iKiVT7p92w74VUIOZki3N4 7p52LcDmf3nlI+axMq+14jfV2U4EQsJ9YcucUV2eFZY3BO1FOdg0k/K2qgHKon8lNQnO 3ALvYF2Im7NZXE4g5U66XoLokzwUe0n672NxEx/I732CL1CaMz9xeiV5Qv7G1utyGhnR DPRg== X-Gm-Message-State: AOJu0Yz1PSV3KRZzW+LAUCnJG35eoXvsG+xR4ujkKbYzlsJibfEhkHeg kYQN/8DAjs+99APnoMtC5BnTlObC2zfk6wQREZEjtUuQhxOSx5hwPF/xuG4RJuKJPfJIyO3XZxv P X-Google-Smtp-Source: AGHT+IELByD129jrn92+nEn/guWZSL3W7OQj9S94rUKJUXUeSDMjQN1u4yns51cYXRWvmQ8BRbYIHw== X-Received: by 2002:a05:600c:4e88:b0:424:8be4:f2c with SMTP id 5b1f17b1804b1-427d2b35b6amr6643885e9.2.1721308839117; Thu, 18 Jul 2024 06:20:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/26] hw/arm/smmuv3: Support nested SMMUs in smmuv3_notify_iova() Date: Thu, 18 Jul 2024 14:20:20 +0100 Message-Id: <20240718132028.697927-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309057157116600 From: Mostafa Saleh IOMMUTLBEvent only understands IOVA, for stage-1 or stage-2 SMMU instances we consider the input address as the IOVA, but when nesting is used, we can't mix stage-1 and stage-2 addresses, so for nesting only stage-1 is considered the IOVA and would be notified. Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-16-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 39 +++++++++++++++++++++++++-------------- hw/arm/trace-events | 2 +- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index b05f2ab929b..a3cb30501e6 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -1096,27 +1096,38 @@ epilogue: * @iova: iova * @tg: translation granule (if communicated through range invalidation) * @num_pages: number of @granule sized pages (if tg !=3D 0), otherwise 1 + * @stage: Which stage(1 or 2) is used */ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, IOMMUNotifier *n, int asid, int vmid, dma_addr_t iova, uint8_t tg, - uint64_t num_pages) + uint64_t num_pages, int stage) { SMMUDevice *sdev =3D container_of(mr, SMMUDevice, iommu); + SMMUEventInfo eventinfo =3D {.inval_ste_allowed =3D true}; + SMMUTransCfg *cfg =3D smmuv3_get_config(sdev, &eventinfo); IOMMUTLBEvent event; uint8_t granule; - SMMUv3State *s =3D sdev->smmu; + + if (!cfg) { + return; + } + + /* + * stage is passed from TLB invalidation commands which can be either + * stage-1 or stage-2. + * However, IOMMUTLBEvent only understands IOVA, for stage-1 or stage-2 + * SMMU instances we consider the input address as the IOVA, but when + * nesting is used, we can't mix stage-1 and stage-2 addresses, so for + * nesting only stage-1 is considered the IOVA and would be notified. + */ + if ((stage =3D=3D SMMU_STAGE_2) && (cfg->stage =3D=3D SMMU_NESTED)) + return; =20 if (!tg) { - SMMUEventInfo eventinfo =3D {.inval_ste_allowed =3D true}; - SMMUTransCfg *cfg =3D smmuv3_get_config(sdev, &eventinfo); SMMUTransTableInfo *tt; =20 - if (!cfg) { - return; - } - if (asid >=3D 0 && cfg->asid !=3D asid) { return; } @@ -1125,7 +1136,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, return; } =20 - if (STAGE1_SUPPORTED(s)) { + if (stage =3D=3D SMMU_STAGE_1) { tt =3D select_tt(cfg, iova); if (!tt) { return; @@ -1151,7 +1162,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, /* invalidate an asid/vmid/iova range tuple in all mr's */ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, uint8_t tg, - uint64_t num_pages) + uint64_t num_pages, int stage) { SMMUDevice *sdev; =20 @@ -1160,10 +1171,10 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s,= int asid, int vmid, IOMMUNotifier *n; =20 trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, vmid, - iova, tg, num_pages); + iova, tg, num_pages, stage); =20 IOMMU_NOTIFIER_FOREACH(n, mr) { - smmuv3_notify_iova(mr, n, asid, vmid, iova, tg, num_pages); + smmuv3_notify_iova(mr, n, asid, vmid, iova, tg, num_pages, sta= ge); } } } @@ -1194,7 +1205,7 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd= , SMMUStage stage) =20 if (!tg) { trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf, stage= ); - smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1); + smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1, stage); if (stage =3D=3D SMMU_STAGE_1) { smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); } else { @@ -1217,7 +1228,7 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd= , SMMUStage stage) num_pages =3D (mask + 1) >> granule; trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf, stage); - smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages); + smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages, stag= e); if (stage =3D=3D SMMU_STAGE_1) { smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); } else { diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 593cc571da7..be6c8f720bc 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -55,7 +55,7 @@ smmuv3_cmdq_tlbi_s12_vmid(int vmid) "vmid=3D%d" smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=3D0x%x" smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu= mr=3D%s" smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu= mr=3D%s" -smmuv3_inv_notifiers_iova(const char *name, int asid, int vmid, uint64_t i= ova, uint8_t tg, uint64_t num_pages) "iommu mr=3D%s asid=3D%d vmid=3D%d iov= a=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 +smmuv3_inv_notifiers_iova(const char *name, int asid, int vmid, uint64_t i= ova, uint8_t tg, uint64_t num_pages, int stage) "iommu mr=3D%s asid=3D%d vm= id=3D%d iova=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64" stage=3D%d" =20 # strongarm.c strongarm_uart_update_parameters(const char *label, int speed, char parity= , int data_bits, int stop_bits) "%s speed=3D%d parity=3D%c data=3D%d stop= =3D%d" --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308995; cv=none; d=zohomail.com; s=zohoarc; b=PzJpM6wwPSJEVfktVSysyBqjxGQ2xyuQDD3QxCgEv6dXe6+UfQAa7+7kwPh7EIEbHB1KVxjecUGxKyAPp1xR+uQIu7J1nD1Ang3Za0tVsVdE/hN9rxDDXjWJMGy7KXeHSWLzNCB72qYO0IQLs7CcingKNZqaRvfrwl53Xatj2P4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308995; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=473+GlrFF1Yqb20TfeBPPe8vI6MkXX76Ali6gu23ymc=; b=gxRl2IJLlXNy1J/ovZtsxfljiCOVwuPtQUluTWuy7zkhfJtMQ0OWaXWXq2VS1HYCVbuKnNosIAV2IW4uiZwHeo/N/Miz950JrrZBriUfyz43e4aGI0bKeskjMYGjo0/8VOzJiIdOlFGjboZq0v8PHlVNNI5vOy/dUmUvv/oQ5Mo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308995455731.1594345407821; Thu, 18 Jul 2024 06:23:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3y-0000aJ-Ao; Thu, 18 Jul 2024 09:20:50 -0400 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 1sUR3s-0008RV-13 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3p-0004Vg-Ms for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:43 -0400 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2eeb1051360so9682681fa.0 for ; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308839; x=1721913639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=473+GlrFF1Yqb20TfeBPPe8vI6MkXX76Ali6gu23ymc=; b=BuXgPGCTjVv/fahBIoYaQc5bdECtg2qOTOrVDTSjqxqAkKzMoHIdp7y6mO3lDTNRyq wJLVWLNpShsjat3x95yzpRHHBebZV0WSSyZ0Jiz5GoHkyQQ3f6jbRC+IObGdlIZKqhFy YX430SP/eWirZoONcwJXQnJfJOowgYaIJGrQmJ7oX1XUCfqFJRovS3LEyBohXE4a4keG iEVc3NvHvbLOo2SxmWGr/ZdzMLnxnu9aunqZbnNapY7YbN6yr3Hg/6qhhlJ139MoFjv/ M+qJtJwPmeTp9zi8q2CV9qdEgDPmveyr05y2pHyvRIZeHZxforle7P7NWzg+8zmdQrvT Tkxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308839; x=1721913639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=473+GlrFF1Yqb20TfeBPPe8vI6MkXX76Ali6gu23ymc=; b=va0bRaUuOD3hqC1avRXeCwuYjhEuizVHmXTZtVuDpIJRAhAD0PhzG7GNlO2jxT+IfH +hS+6SxQl0GqE2xX0vldCs4VHb58BBoUl9FOIHzluWRIL1dobY+RVwZXNJhPOFrV88CG NxD7EtDd5eROS1m18GuSnnjewSEJTxbP5FYX0hp1nvnny8oZfWa7PaC782Uqo4Bwnm1B x+HZV4hJ0K+OK+lqHamxyj2snR9hezRL1FEP77P2mx5Np1jRUx0mij0XDUVOrQ53zIII 2ZnYCyRnOZUpxrlyucaIz+UznHn3k/v8H0SpQF2L8NPDm4BSDyMnQ6KMyYPE8fdgtdLK I9kw== X-Gm-Message-State: AOJu0YzSHvCTIabzRXeC4hnAhEGo87OBbXjandcB8Us4G6ChM38Btxb8 1ZLwFFu6c0iIJTi2Erhrgf7nPQ0FOEEyDFO/Q7Aa/JW6GLwMWJBdpyEbN5SoqkCh3LSAkvocTAa O X-Google-Smtp-Source: AGHT+IF2Ppsmubl2G4DlpEHnZ1veH8zF5WnDEU3bN+8QqWxpdig1hV8Q1pq+q74B6t1IDWiRmr02VA== X-Received: by 2002:a2e:a212:0:b0:2ec:5c94:3d99 with SMTP id 38308e7fff4ca-2ef05c4fb41mr16986391fa.2.1721308839602; Thu, 18 Jul 2024 06:20:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/26] hw/arm/smmuv3: Handle translation faults according to SMMUPTWEventInfo Date: Thu, 18 Jul 2024 14:20:21 +0100 Message-Id: <20240718132028.697927-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22b; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x22b.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308996859116600 From: Mostafa Saleh Previously, to check if faults are enabled, it was sufficient to check the current stage of translation and check the corresponding record_faults flag. However, with nesting, it is possible for stage-1 (nested) translation to trigger a stage-2 fault, so we check SMMUPTWEventInfo as it would have the correct stage set from the page table walk. Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-17-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index a3cb30501e6..2d61637aed5 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -34,9 +34,10 @@ #include "smmuv3-internal.h" #include "smmu-internal.h" =20 -#define PTW_RECORD_FAULT(cfg) (((cfg)->stage =3D=3D SMMU_STAGE_1) ? \ - (cfg)->record_faults : \ - (cfg)->s2cfg.record_faults) +#define PTW_RECORD_FAULT(ptw_info, cfg) (((ptw_info).stage =3D=3D SMMU_STA= GE_1 && \ + (cfg)->record_faults) || \ + ((ptw_info).stage =3D=3D SMMU_STAG= E_2 && \ + (cfg)->s2cfg.record_faults)) =20 /** * smmuv3_trigger_irq - pulse @irq if enabled and update @@ -933,7 +934,7 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv3= State *s, hwaddr addr, event->u.f_walk_eabt.addr2 =3D ptw_info.addr; break; case SMMU_PTW_ERR_TRANSLATION: - if (PTW_RECORD_FAULT(cfg)) { + if (PTW_RECORD_FAULT(ptw_info, cfg)) { event->type =3D SMMU_EVT_F_TRANSLATION; event->u.f_translation.addr2 =3D ptw_info.addr; event->u.f_translation.class =3D class; @@ -941,7 +942,7 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv3= State *s, hwaddr addr, } break; case SMMU_PTW_ERR_ADDR_SIZE: - if (PTW_RECORD_FAULT(cfg)) { + if (PTW_RECORD_FAULT(ptw_info, cfg)) { event->type =3D SMMU_EVT_F_ADDR_SIZE; event->u.f_addr_size.addr2 =3D ptw_info.addr; event->u.f_addr_size.class =3D class; @@ -949,7 +950,7 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv3= State *s, hwaddr addr, } break; case SMMU_PTW_ERR_ACCESS: - if (PTW_RECORD_FAULT(cfg)) { + if (PTW_RECORD_FAULT(ptw_info, cfg)) { event->type =3D SMMU_EVT_F_ACCESS; event->u.f_access.addr2 =3D ptw_info.addr; event->u.f_access.class =3D class; @@ -957,7 +958,7 @@ static SMMUTranslationStatus smmuv3_do_translate(SMMUv3= State *s, hwaddr addr, } break; case SMMU_PTW_ERR_PERMISSION: - if (PTW_RECORD_FAULT(cfg)) { + if (PTW_RECORD_FAULT(ptw_info, cfg)) { event->type =3D SMMU_EVT_F_PERMISSION; event->u.f_permission.addr2 =3D ptw_info.addr; event->u.f_permission.class =3D class; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309053; cv=none; d=zohomail.com; s=zohoarc; b=D2iIXWKGko4ENVLsqZM5EWwlHty1FR3WS5Z1uF/pzCqv6Bt2jdCdcKqHcM/6fZ583f8sr4XgaqmKX9NiBqfoWIxvFGxEz4PwKxtr0guyhmtzHIFnyWzAD6fZ2C0HcIUocCJB6M+ciWGFtWETodRNxMGFNORmp1f+FH4RKp8sq1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309053; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; b=DfIIlCmmerFa11nspVc2c/F1U3BMoZvpR8Bypbx5c7AhZzBSbx/eKzn36ZCDa0Y1LNbaxkH2Q6ehKXEY6kp8O/lLZOk2d6gJqNJnS9F0yVpzHGgEul4n1Uax0OmVKZ0bNsX8XymRS1JDdh+Jqm+PMPlis9HlGNorN2XKSQdtiXw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309053556652.8793870972008; Thu, 18 Jul 2024 06:24:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR45-0001My-Cp; Thu, 18 Jul 2024 09:20:57 -0400 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 1sUR3s-0008Rd-2V for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3p-0004Vl-NK for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:43 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4272738eb9eso2687695e9.3 for ; Thu, 18 Jul 2024 06:20:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308840; x=1721913640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; b=Rm31zhUZMc7NKy0ZWXjXBgdpisKe8y/VXVB8Lp08dKb7ZjySs/POUaEVG3+cY2OhYR fZMKtzazvulFzao8SqE5lUNU0JwviVAVfwLEEHLXgWH8xQlS0GPFsQkRhgZls7wfr672 jCDiWKwPbHec/jHrsBWlsiWmhFON8SRCEtsmqWB8HDIayJbsw6x0J3j1xmYCresg7raJ CfRj63X3h9nM74wuDRgjqGxdwxNTouExUct5xj+BN0vNiAqZ42S54CJH/3wlNWzH1A6L nec7VO82RQ3t/QJ3ynWfWHOlupcKIWkO0473Hf5xdtm3kWIfXwCB0rdCeDQmkn/jAEvF U0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308840; x=1721913640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; b=MpcikM805iaa/itKHY9qt7C4iwW1zLvqZDCWAoY0VCO4xjdqdHtUDzIHsG0Qtg6+8i XwvpFJe3H+wANh8UlmQvM83JYTcBCIVmluwFUWLx9BuMP8HwZwHZ5QxWyDmLJS/Ld/Tz g1T8Haw9sXm5Usm38nrvXdU1Kkt3RIS5ZaY41++uiq0JLBfNQsca51rAJ4dswuIR06xE sLIac6XbqjaN0cgfQp114LwNyix5KIFngnJdpQlnsmEpaEsNvDc310BDXu5OTKPTGDO5 5kDpdmemZZbN7bzsEODX8C4g6t0aDv2L35XhnxJ7I2xsJa97zaOATEFpLaTnqYtU8IMv 3n1w== X-Gm-Message-State: AOJu0YxiNCnDa89nnqDZjkmOr8jPg1AUmbG8dLssyOknbBOnTVd8vv5U d110/8irqSec68tN7xU0envHCUF03d32muiZMCrSfIU/fpVQekSik28z5znHDHpA9wLBbsCeQ8Z Q X-Google-Smtp-Source: AGHT+IHk5cvAO8Rusaph6UsGfDL+21K326TrHCgJjKGo8+3nYyRd/38/HKDhc/Q4G7FmsuClZpdUAg== X-Received: by 2002:a05:600c:4707:b0:426:5f7d:addc with SMTP id 5b1f17b1804b1-427c2d107edmr32788725e9.37.1721308840025; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/26] hw/arm/smmuv3: Support and advertise nesting Date: Thu, 18 Jul 2024 14:20:22 +0100 Message-Id: <20240718132028.697927-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309055153116600 From: Mostafa Saleh Everything is in place, consolidate parsing of STE cfg and setting translation stage. Advertise nesting if stage requested is "nested". Reviewed-by: Jean-Philippe Brucker Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-18-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 2d61637aed5..3db6c7c1357 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -261,6 +261,9 @@ static void smmuv3_init_regs(SMMUv3State *s) /* Based on sys property, the stages supported in smmu will be adverti= sed.*/ if (s->stage && !strcmp("2", s->stage)) { s->idr[0] =3D FIELD_DP32(s->idr[0], IDR0, S2P, 1); + } else if (s->stage && !strcmp("nested", s->stage)) { + s->idr[0] =3D FIELD_DP32(s->idr[0], IDR0, S1P, 1); + s->idr[0] =3D FIELD_DP32(s->idr[0], IDR0, S2P, 1); } else { s->idr[0] =3D FIELD_DP32(s->idr[0], IDR0, S1P, 1); } @@ -425,8 +428,6 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8_= t t0sz, uint8_t gran) =20 static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) { - cfg->stage =3D SMMU_STAGE_2; - if (STE_S2AA64(ste) =3D=3D 0x0) { qemu_log_mask(LOG_UNIMP, "SMMUv3 AArch32 tables not supported\n"); @@ -509,6 +510,27 @@ bad_ste: return -EINVAL; } =20 +static void decode_ste_config(SMMUTransCfg *cfg, uint32_t config) +{ + + if (STE_CFG_ABORT(config)) { + cfg->aborted =3D true; + return; + } + if (STE_CFG_BYPASS(config)) { + cfg->bypassed =3D true; + return; + } + + if (STE_CFG_S1_ENABLED(config)) { + cfg->stage =3D SMMU_STAGE_1; + } + + if (STE_CFG_S2_ENABLED(config)) { + cfg->stage |=3D SMMU_STAGE_2; + } +} + /* Returns < 0 in case of invalid STE, 0 otherwise */ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, STE *ste, SMMUEventInfo *event) @@ -525,13 +547,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cf= g, =20 config =3D STE_CONFIG(ste); =20 - if (STE_CFG_ABORT(config)) { - cfg->aborted =3D true; - return 0; - } + decode_ste_config(cfg, config); =20 - if (STE_CFG_BYPASS(config)) { - cfg->bypassed =3D true; + if (cfg->aborted || cfg->bypassed) { return 0; } =20 @@ -704,7 +722,6 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, =20 /* we support only those at the moment */ cfg->aa64 =3D true; - cfg->stage =3D SMMU_STAGE_1; =20 cfg->oas =3D oas2bits(CD_IPS(cd)); cfg->oas =3D MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308964; cv=none; d=zohomail.com; s=zohoarc; b=fi/xMsHgpGCsvgrpfWzFT+7TZPexLA85+S4J/1SetWzi/PMxUNmiT4MoA2fQb3PAieGOGA/Y9jlkjfRi2d6Tb+KqcmF/BP6bYqNdmpd9Gn2gD/6agq9jE4xkSGW85J6WEzM2JyOciB4H355xh0xbv1KzNQaDr239pqtzY7Mq6fk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308964; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=VHN7yV4WQNrP5rcth7Yx1n5W3KiVohowsfOYtErcpFU=; b=AMpjdUWDu6Ejh1VQDJZgK7rd1LDOYE4D5SBIIqJvfoTsiHylAsE3re4LiKm+GSgGAu4lld3Y7a6AzqVI/u39fTEc2DujElAga3yUrbINNGdF9IyRT7v0lusUzPmPqLYzhoag7w3uci0wPI7q6qMIcBaiG1HYXO7JC4gGMr1uvxk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721308964616881.0028427199572; Thu, 18 Jul 2024 06:22:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR40-0000sS-Rn; Thu, 18 Jul 2024 09:20:52 -0400 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 1sUR3s-0008T0-En for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3p-0004WB-V2 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:44 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4279ca8af51so2722855e9.3 for ; Thu, 18 Jul 2024 06:20:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308840; x=1721913640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=VHN7yV4WQNrP5rcth7Yx1n5W3KiVohowsfOYtErcpFU=; b=VJXaVvphLY5CBlMclALVIHiHiKrLAnmX5zkoRyjd/mmK9AWoulhxPPIO5ARDxcBENj B8Rei/Sfdk5znX7CKxkLBw7sHj3By4/nd6IsTT/SnrJCqyZm0q/6LMTXnmA2PrTGmWMW GOt+YAV4EWuRmIRP6i2i6XL+A4YmCFDWb6Iv7sQZ8ZxhJvJfzVjH+30IgRd4Roui1Ca5 2puy+Yxib/brjgxShPdpgfU4Ze2WdSDJH4QXQNCY99loeOHuB0YlxMbyO1QluadgwDMr RzaldaWq9I0Hyg3PzzflhQLDaZ/0jIMLft7RQP3zmQtfsZ/uqA1y+ywymoQOxE76MRpw /v/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308840; x=1721913640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VHN7yV4WQNrP5rcth7Yx1n5W3KiVohowsfOYtErcpFU=; b=wdpxpUBVGLNWkyXmwKL52EJ+2AskfhTvB1Fp9NWO0/O6qeyCl8oaoeiFw7KSGq7L6t z4n8sK8a5W7840BKPfbGKOli11TnjpVA/sTSoXs440yJVJaAXi46mbQUBjFy3k4TOpgC b96N+B2tmXgBgnN3Ar6L9dhTf4JDnqwNvrd7QJox7RLmUNnRQVVBYxrmuZiY96zbRQUd x3NAlAcTvTGkzbMd/WbZTyP1+RYm6E+vVM+wxNVtqbLaLoNGRlAjgZ7SHUBvqj+nTwn2 ES3UqPm1Vk9zo1OON8+AnPRWP4gpaY5zsGo9SBDQXUfngq/gZfqkWNgMmm4KS36cfNvu 0B3Q== X-Gm-Message-State: AOJu0YzAEYSvsQGhcKZPzX7VXuLhuFamv+cTrzr8RP6GsIBJGn3zUK4/ 9Cfyr0mbMNjG1jTwFDEC1X4WS441Rj50+y7ys+9S6e98Dkbpst65DKCLTKVk1zgUSwZAfN5aDXC 6 X-Google-Smtp-Source: AGHT+IHTFeFL0/FKXZYuv0eKgw4/YmxwakVGfN7lIk3hnBat580XJutN0G9tYylfjZMPhpuP7iCm3w== X-Received: by 2002:a05:600c:1547:b0:426:593c:9351 with SMTP id 5b1f17b1804b1-427c2cc9965mr36675245e9.6.1721308840457; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/26] hw/arm/smmu: Refactor SMMU OAS Date: Thu, 18 Jul 2024 14:20:23 +0100 Message-Id: <20240718132028.697927-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308966811116600 From: Mostafa Saleh SMMUv3 OAS is currently hardcoded in the code to 44 bits, for nested configurations that can be a problem, as stage-2 might be shared with the CPU which might have different PARANGE, and according to SMMU manual ARM IHI 0070F.b: 6.3.6 SMMU_IDR5, OAS must match the system physical address size. This patch doesn't change the SMMU OAS, but refactors the code to make it easier to do that: - Rely everywhere on IDR5 for reading OAS instead of using the SMMU_IDR5_OAS macro, so, it is easier just to change IDR5 and it propagages correctly. - Add additional checks when OAS is greater than 48bits. - Remove unused functions/macros: pa_range/MAX_PA. Reviewed-by: Eric Auger Signed-off-by: Mostafa Saleh Reviewed-by: Jean-Philippe Brucker Reviewed-by: Alex Benn=C3=A9e Message-id: 20240715084519.1189624-19-smostafa@google.com Signed-off-by: Peter Maydell --- hw/arm/smmuv3-internal.h | 13 ------------- hw/arm/smmu-common.c | 7 ++++--- hw/arm/smmuv3.c | 35 ++++++++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index 0f3ecec804d..0ebf2eebcff 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -602,19 +602,6 @@ static inline int oas2bits(int oas_field) return -1; } =20 -static inline int pa_range(STE *ste) -{ - int oas_field =3D MIN(STE_S2PS(ste), SMMU_IDR5_OAS); - - if (!STE_S2AA64(ste)) { - return 40; - } - - return oas2bits(oas_field); -} - -#define MAX_PA(ste) ((1 << pa_range(ste)) - 1) - /* CD fields */ =20 #define CD_VALID(x) extract32((x)->word[0], 31, 1) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 00d7579cd3d..d73ad622113 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -452,7 +452,8 @@ static int smmu_ptw_64_s1(SMMUState *bs, SMMUTransCfg *= cfg, inputsize =3D 64 - tt->tsz; level =3D 4 - (inputsize - 4) / stride; indexmask =3D VMSA_IDXMSK(inputsize, stride, level); - baseaddr =3D extract64(tt->ttb, 0, 48); + + baseaddr =3D extract64(tt->ttb, 0, cfg->oas); baseaddr &=3D ~indexmask; =20 while (level < VMSA_LEVELS) { @@ -576,8 +577,8 @@ static int smmu_ptw_64_s2(SMMUTransCfg *cfg, * Get the ttb from concatenated structure. * The offset is the idx * size of each ttb(number of ptes * (sizeof(p= te)) */ - uint64_t baseaddr =3D extract64(cfg->s2cfg.vttb, 0, 48) + (1 << stride= ) * - idx * sizeof(uint64_t); + uint64_t baseaddr =3D extract64(cfg->s2cfg.vttb, 0, cfg->s2cfg.eff_ps)= + + (1 << stride) * idx * sizeof(uint64_t); dma_addr_t indexmask =3D VMSA_IDXMSK(inputsize, stride, level); =20 baseaddr &=3D ~indexmask; diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 3db6c7c1357..39719763897 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -402,10 +402,10 @@ static bool s2t0sz_valid(SMMUTransCfg *cfg) } =20 if (cfg->s2cfg.granule_sz =3D=3D 16) { - return (cfg->s2cfg.tsz >=3D 64 - oas2bits(SMMU_IDR5_OAS)); + return (cfg->s2cfg.tsz >=3D 64 - cfg->s2cfg.eff_ps); } =20 - return (cfg->s2cfg.tsz >=3D MAX(64 - oas2bits(SMMU_IDR5_OAS), 16)); + return (cfg->s2cfg.tsz >=3D MAX(64 - cfg->s2cfg.eff_ps, 16)); } =20 /* @@ -426,8 +426,11 @@ static bool s2_pgtable_config_valid(uint8_t sl0, uint8= _t t0sz, uint8_t gran) return nr_concat <=3D VMSA_MAX_S2_CONCAT; } =20 -static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) +static int decode_ste_s2_cfg(SMMUv3State *s, SMMUTransCfg *cfg, + STE *ste) { + uint8_t oas =3D FIELD_EX32(s->idr[5], IDR5, OAS); + if (STE_S2AA64(ste) =3D=3D 0x0) { qemu_log_mask(LOG_UNIMP, "SMMUv3 AArch32 tables not supported\n"); @@ -460,7 +463,15 @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *s= te) } =20 /* For AA64, The effective S2PS size is capped to the OAS. */ - cfg->s2cfg.eff_ps =3D oas2bits(MIN(STE_S2PS(ste), SMMU_IDR5_OAS)); + cfg->s2cfg.eff_ps =3D oas2bits(MIN(STE_S2PS(ste), oas)); + /* + * For SMMUv3.1 and later, when OAS =3D=3D IAS =3D=3D 52, the stage 2 = input + * range is further limited to 48 bits unless STE.S2TG indicates a + * 64KB granule. + */ + if (cfg->s2cfg.granule_sz !=3D 16) { + cfg->s2cfg.eff_ps =3D MIN(cfg->s2cfg.eff_ps, 48); + } /* * It is ILLEGAL for the address in S2TTB to be outside the range * described by the effective S2PS value. @@ -536,6 +547,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, STE *ste, SMMUEventInfo *event) { uint32_t config; + uint8_t oas =3D FIELD_EX32(s->idr[5], IDR5, OAS); int ret; =20 if (!STE_VALID(ste)) { @@ -579,8 +591,8 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, * Stage-1 OAS defaults to OAS even if not enabled as it would be = used * in input address check for stage-2. */ - cfg->oas =3D oas2bits(SMMU_IDR5_OAS); - ret =3D decode_ste_s2_cfg(cfg, ste); + cfg->oas =3D oas2bits(oas); + ret =3D decode_ste_s2_cfg(s, cfg, ste); if (ret) { goto bad_ste; } @@ -706,6 +718,7 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, int i; SMMUTranslationStatus status; SMMUTLBEntry *entry; + uint8_t oas =3D FIELD_EX32(s->idr[5], IDR5, OAS); =20 if (!CD_VALID(cd) || !CD_AARCH64(cd)) { goto bad_cd; @@ -724,7 +737,7 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, cfg->aa64 =3D true; =20 cfg->oas =3D oas2bits(CD_IPS(cd)); - cfg->oas =3D MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); + cfg->oas =3D MIN(oas2bits(oas), cfg->oas); cfg->tbi =3D CD_TBI(cd); cfg->asid =3D CD_ASID(cd); cfg->affd =3D CD_AFFD(cd); @@ -753,6 +766,14 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, goto bad_cd; } =20 + /* + * An address greater than 48 bits in size can only be output from= a + * TTD when, in SMMUv3.1 and later, the effective IPS is 52 and a = 64KB + * granule is in use for that translation table + */ + if (tt->granule_sz !=3D 16) { + cfg->oas =3D MIN(cfg->oas, 48); + } tt->tsz =3D tsz; tt->ttb =3D CD_TTB(cd, i); =20 --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309027; cv=none; d=zohomail.com; s=zohoarc; b=kOq3ogIB0G/FMt6FqYdzGUiIlJx6jocTiZJHIcK7a1XHsQ8t4WuH73dBJq5o6ArlNEQwofpShJxdmhOF//RIybJ8fhxvQsOifyihvaQxpT4u6/dTBtd2ttRIuNFCRQBXRVIpjFmCoSxWuI2g5j47/MIAfxVTywVWeNCfdXK19qM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309027; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Pucdh4Y0p96kGpjxvklaJQ0uqOO6+PMhEJIHOFnGpA0=; b=aeraNC5PGxiXiHhpcqHgSUekg5IaHVW/OMDBDGPvdjxQdbZVSKzZ6OR3HP9Clm9k3OYhv0WnjUyDNZt1kDcrvURc9VZyllFH1CjxXFwikEFY366DGbnk5bD9ehprU+S/nWQzg+uBCNVkD7WQsIU73XnUw+xOh2kiWM5ugm4JnsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309027713172.68756839842968; Thu, 18 Jul 2024 06:23:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR3y-0000f7-Uv; Thu, 18 Jul 2024 09:20:51 -0400 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 1sUR3s-0008TV-JF for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3q-0004WM-Lo for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:44 -0400 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2eedebccfa4so9043141fa.1 for ; Thu, 18 Jul 2024 06:20:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308841; x=1721913641; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Pucdh4Y0p96kGpjxvklaJQ0uqOO6+PMhEJIHOFnGpA0=; b=mo5XrrAcjINsyxBJHssI//08vrOr5q7TkFXNhjkjFI5sthn2DWSeZZ0/wWfRf1OcLG eIEUFyzGq4yV7GMVvrngex0yUcRCEn80tc/PEhB3VoqUxc5q3SRseDYpDEw+P96ldW7G Lt+yP8GhZ/LI/kHjhCg4BUMxUtSAYYhW4325fd6m1BrqgKFj66Obi5Dhiy1L1Ht6whHx qgqLg2fF39RDuOPp2yQkPajAayD5P+82YGg9FrYbi69KffnqGdwarO4sdburEjLNdeiM z583f/s22Rw61e6ec8/RyY5PbPwDp3NJZr27unzvnhZU0vcYalWX4pndYvchKHy9VZOj Ye/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308841; x=1721913641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pucdh4Y0p96kGpjxvklaJQ0uqOO6+PMhEJIHOFnGpA0=; b=V45ATMFMyL6ak3B4+mRaxX9oLeW+WdyFE8aIyNuRQvfI/5jqRzN/qb8NRcVrpIsxjL e/GzFbvZf65+8LpHlMCljivO98mF0E/RaM5/dZxgnHyQJ2Ay8ILMAirmcfHFo/SRgqiM wvpYkF+SjwJLNqkG4sXRIwoBnrh/AImOW3ch7FE3Ess40AXOuYQdpEQ6yl3/gUjURYrc YNqS46egaUFw9D9pSwjEqjvK08Af1Ig8EFhbCKh1Ph3uB61923D8NfjYzWCyxw9J3yOn z0ywz6C/C2jr3pbtT/aA9JzT6BOYxp0QhOTQyyf1voeVn/FzgDtxldfeSnL0+eX0ZkXA UbgQ== X-Gm-Message-State: AOJu0Yy7gvi6DPUtVjQXGtzWHWwBRtQQ1Q814FvEUeELVl5ymyy9v1jF 0jvBaroInvgqJeIU3goRsJ8OCkdF99yKKPpJAkbz2NB6mg/2LoL3Xw9j1oeISp1ulFvRtKaKo4j A X-Google-Smtp-Source: AGHT+IHKNb3GwlhBTr3uGh2zxy+vvLoztyJdzu74gXiGr3Iap6CbqJaIJYj7ulVtOhlkiTk/Hs9MYA== X-Received: by 2002:a2e:8813:0:b0:2ee:8aed:ddba with SMTP id 38308e7fff4ca-2ef05c552bbmr21127021fa.4.1721308840866; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/26] target/arm: Use float_status copy in sme_fmopa_s Date: Thu, 18 Jul 2024 14:20:24 +0100 Message-Id: <20240718132028.697927-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22e; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x22e.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309029021116600 From: Daniyal Khan We made a copy above because the fp exception flags are not propagated back to the FPST register, but then failed to use the copy. Cc: qemu-stable@nongnu.org Fixes: 558e956c719 ("target/arm: Implement FMOPA, FMOPS (non-widening)") Signed-off-by: Daniyal Khan Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Message-id: 20240717060149.204788-2-richard.henderson@linaro.org [rth: Split from a larger patch] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell --- target/arm/tcg/sme_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c index e2e05750399..5a6dd76489f 100644 --- a/target/arm/tcg/sme_helper.c +++ b/target/arm/tcg/sme_helper.c @@ -916,7 +916,7 @@ void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vz= m, void *vpn, if (pb & 1) { uint32_t *a =3D vza_row + H1_4(col); uint32_t *m =3D vzm + H1_4(col); - *a =3D float32_muladd(n, *m, *a, 0, vst); + *a =3D float32_muladd(n, *m, *a, 0, &fpst); } col +=3D 4; pb >>=3D 4; --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309028; cv=none; d=zohomail.com; s=zohoarc; b=V7VuxaiGZdZ+jHGQeSTZzznDixlvI3QDIXfR7/vMiPAArbZ41yAx6k01qiAcX6sG/egkh1juKdle3soSpdEdmmxoyT2+jT2OMmnhoayP0R665cV0MgaI2a2VXDfgCXWXVevof3ILYHTs3FHvnohzLpw33lWMYpjge/i/vCjFez8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309028; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Gacol05z2j4g3ezomPw5aWtTptIdBc2mH3bQ/0FLyGY=; b=LCBPQAr+uSoHtwF/mle4VJghAgbKptuhzU1kruFAamdV+Fy200/xV2xo6qGxQ19x0tqPEyKHDU/lfWzPe3k2LpM89uaELqZUX/3xhrRRFnTKXFFtBQ8pCT7xJ3ohe0ksQCEAz3NEVl+yVFxpohs0j4ckVOJTkzIt1YdqiTJS/UQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309028200343.63528544038525; Thu, 18 Jul 2024 06:23:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR48-0001kP-EV; Thu, 18 Jul 2024 09:21:00 -0400 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 1sUR3t-00004r-Dk for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3q-0004WP-R2 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:45 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4266fd39527so2761195e9.1 for ; Thu, 18 Jul 2024 06:20:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308841; x=1721913641; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Gacol05z2j4g3ezomPw5aWtTptIdBc2mH3bQ/0FLyGY=; b=tdXlTC6AYiD0x8+Du6jTgVJoFHZdwwpzpajsGimWfe3Evxm3Fk1YEP6QIWVi3LWwEZ YYBcMzlhVMQY+WYnZBYUYWmfJeHyWcSYo+x3z1jBTq1KLQ53R1cqpiEMdX0iUvJCKHbW bCDbWo3AmrxC2ZdL7L5mCGKcBle+pFnm4Jy0+UJxwA0JZfzEE6ukDoUUCVMJr/6LfjBE dXw+goUMCk3g3TgdVKRQX3o6ya0oTRJ5rHGuqtGUCmQSS2BlqT1SUJZUyc3rIuLrLtRL p18v7wVci1BEnnBByRyD95vXjh2RH8TLOgRfXIg2yso3ezKttMuI7bQV/m4r7ID6+r2o ck3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308841; x=1721913641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gacol05z2j4g3ezomPw5aWtTptIdBc2mH3bQ/0FLyGY=; b=cwtjuMM0PDsul1sGsBzmXBdOsJftKF+LaagKlGjofG5zmBlp1grFDqoveJRwc8PtMw Qtjq7eJfKIrcEwLuO4HLhbwwbc0gWJYqlcSce9QxtRna4ATNzzXY8zVONihaYFEeyLZX /Z3ha6KOwx0yD1hK7XkzocmMkwu3t7QmA0IyzBwPu9NcsgzDJ26VpII6Tw4RDbrokevm U1+yLORMU22s0OFRRnwnJg9dSgH4x7ZOkeNuxH2iGsQ1X8iF88ghXYx9CR4v4ejmUaw1 WDqiLWzthWlyLiqx0hXZ8qte3Xcr08fs2pTOhhstdwDWrNQyN8CHSlCBv79tpR/W2OQZ jbXQ== X-Gm-Message-State: AOJu0YwUV5x7h/2jHTO84AbE0Un1/TBgNBylxcksvEQfS33fqhm40WCc xSu8r+8JzxjEly1c7v5XgwyqcvAf/9Ndac6S1QpZf+9QJroEBqGQAJDeu6l5qvGZnjykHfp9SZN o X-Google-Smtp-Source: AGHT+IG60+CeDbPIpSsoEVVgQbHc+U3TRS3HC00dJ+L3HlHL1DZgcTnPcWTixIXcwWd8MPQOIM6Kvg== X-Received: by 2002:a05:600c:3553:b0:426:6455:f11c with SMTP id 5b1f17b1804b1-427c2cfc33fmr36642255e9.25.1721308841276; Thu, 18 Jul 2024 06:20:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/26] target/arm: Use FPST_F16 for SME FMOPA (widening) Date: Thu, 18 Jul 2024 14:20:25 +0100 Message-Id: <20240718132028.697927-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309029024116600 From: Richard Henderson This operation has float16 inputs and thus must use the FZ16 control not the FZ control. Cc: qemu-stable@nongnu.org Fixes: 3916841ac75 ("target/arm: Implement FMOPA, FMOPS (widening)") Reported-by: Daniyal Khan Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20240717060149.204788-3-richard.henderson@linaro.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2374 Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell --- target/arm/tcg/translate-sme.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c index 46c7fce8b4e..185a8a917b0 100644 --- a/target/arm/tcg/translate-sme.c +++ b/target/arm/tcg/translate-sme.c @@ -304,6 +304,7 @@ static bool do_outprod(DisasContext *s, arg_op *a, MemO= p esz, } =20 static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz, + ARMFPStatusFlavour e_fpst, gen_helper_gvec_5_ptr *fn) { int svl =3D streaming_vec_reg_size(s); @@ -319,15 +320,18 @@ static bool do_outprod_fpst(DisasContext *s, arg_op *= a, MemOp esz, zm =3D vec_full_reg_ptr(s, a->zm); pn =3D pred_full_reg_ptr(s, a->pn); pm =3D pred_full_reg_ptr(s, a->pm); - fpst =3D fpstatus_ptr(FPST_FPCR); + fpst =3D fpstatus_ptr(e_fpst); =20 fn(za, zn, zm, pn, pm, fpst, tcg_constant_i32(desc)); return true; } =20 -TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fm= opa_h) -TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fm= opa_s) -TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper= _sme_fmopa_d) +TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, + MO_32, FPST_FPCR_F16, gen_helper_sme_fmopa_h) +TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, + MO_32, FPST_FPCR, gen_helper_sme_fmopa_s) +TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, + MO_64, FPST_FPCR, gen_helper_sme_fmopa_d) =20 /* TODO: FEAT_EBF16 */ TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa) --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309008; cv=none; d=zohomail.com; s=zohoarc; b=P/Q8Tcgd9c1piRDycdqi8I+qDnva/xvvJ56hchMnUScs/07EQTcXXWJa6yCU5LX65piNBmr7K0E++H2iDw3+l7fgfx6rOYGlOMEhJE2rjedAG8Ymi/blrdae7k+rurxteViJx3V8yjInbB/RejMkTJ2nXOP7709JQL//cVIXtQM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309008; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=yDhjBwtmOOJHxvon8Ehvv2T5x4XcBgN5wG00aOhg5yA=; b=cm2dw1TaaakwxbRcV4V0XbAKH73GjrFg4WtVr7zLv60Euwpxtyj1Cw694QZRU4TOeiPHYA4rUlaKcjqKGC0KsDhdCZssyQckc1Cv2Ek9xPeDQSHlArtfe5n8P9+BPtIYoXPTyzG0qlQdz2e6OTlxOJYukTDyIHH1FloYMv2uMPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309007875786.1304431724341; Thu, 18 Jul 2024 06:23:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR40-0000rd-OT; Thu, 18 Jul 2024 09:20:52 -0400 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 1sUR3t-00009B-QI for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3r-0004Wh-Ly for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:45 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3685afd0c56so349058f8f.1 for ; Thu, 18 Jul 2024 06:20:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308842; x=1721913642; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yDhjBwtmOOJHxvon8Ehvv2T5x4XcBgN5wG00aOhg5yA=; b=rHWNZVQLbfc5eiFnRLcctNFDPNEI1lyG97fREleOGDJ+aY/eVmWxsLLU1wj4O9lCNL Aep7ZXTESkY9pR2aeio0NF1cVBq0Fy4zdu+JOfrJFA6P5d5N1FPriPBNMe1jp0VqDZRI rEP2oIr6AK6DYNvti3P4VjxJXwuEy7EvdkvkymzZefMGKjjbnn7MWABwbqsX+0ZGN1S8 Tb0j+2e1Myyy+dcd78FuRQgkoztDRh4vcRWd4reV9vkis0ZIMlHEeCcbPYtCFdlavEVs Gm1w9QPnPQT0ihNzPzqm9rCZhGj6Qa/H1BO+8CjdgKM+cLvjbyNLcBJc9+pSnyIetVOs +whw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308842; x=1721913642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yDhjBwtmOOJHxvon8Ehvv2T5x4XcBgN5wG00aOhg5yA=; b=saakLv6PZ/MycRNE5tk4JYDBZHl4j05e5KjdDvTvdpV3xEuMgMtpYlBG1axGer5I/z khxzsizPa6ggaKUx0D/AqzlRIqtmn7llXrcqwkt/9kNnT9dtLzcJRBkfIeknQXTc7W24 XfJuhyNNagN/V1fwBOrrSIcfdcnQpZvXxKpbjSboYtVzoeUye25o+6PFsqzTDlayye1s zxJASDLRaZZnARsL/By9RBRDHUwuWHSXvaIhhx6yspj0510M1laPr8+8Ed00XoUAw4EI JzZT1QalpClFhtrpveVL4VzUsDVmrPmPagsu6MHChhw+ZbvQvErMHLLD2a8T4x3I0kNs hnLw== X-Gm-Message-State: AOJu0YwOsWtfemU0qpMyahuQ4oDPOVG1qOeF1JYZj8nGzuA3jyU4TeZx SMICtdngn45hXV4JLAVcSVllwGb8icFztIvEEBmomUljumMp4yxSntqhQnYU8Lh3iwUqvYZ8f06 Y X-Google-Smtp-Source: AGHT+IGoeRIepqV9R2aLNKQRoRzGlZ2DahRSPPgE7Vb1G6O9H+R64kxbRrVmqaGeCUU6hjmB5vcAbQ== X-Received: by 2002:adf:f746:0:b0:364:aafb:6020 with SMTP id ffacd0b85a97d-36831654ad5mr3329907f8f.14.1721308841756; Thu, 18 Jul 2024 06:20:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/26] tests/tcg/aarch64: Add test cases for SME FMOPA (widening) Date: Thu, 18 Jul 2024 14:20:26 +0100 Message-Id: <20240718132028.697927-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309009034116600 From: Daniyal Khan Signed-off-by: Daniyal Khan Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Message-id: 20240717060149.204788-4-richard.henderson@linaro.org Message-Id: 172090222034.13953.16888708708822922098-1@git.sr.ht [rth: Split test from a larger patch, tidy assembly] Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Peter Maydell --- tests/tcg/aarch64/sme-fmopa-1.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-2.c | 56 +++++++++++++++++++++++++++ tests/tcg/aarch64/sme-fmopa-3.c | 63 +++++++++++++++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 5 ++- 4 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/aarch64/sme-fmopa-1.c create mode 100644 tests/tcg/aarch64/sme-fmopa-2.c create mode 100644 tests/tcg/aarch64/sme-fmopa-3.c diff --git a/tests/tcg/aarch64/sme-fmopa-1.c b/tests/tcg/aarch64/sme-fmopa-= 1.c new file mode 100644 index 00000000000..652c4ea0902 --- /dev/null +++ b/tests/tcg/aarch64/sme-fmopa-1.c @@ -0,0 +1,63 @@ +/* + * SME outer product, 1 x 1. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include + +static void foo(float *dst) +{ + asm(".arch_extension sme\n\t" + "smstart\n\t" + "ptrue p0.s, vl4\n\t" + "fmov z0.s, #1.0\n\t" + /* + * An outer product of a vector of 1.0 by itself should be a matri= x of 1.0. + * Note that we are using tile 1 here (za1.s) rather than tile 0. + */ + "zero {za}\n\t" + "fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n\t" + /* + * Read the first 4x4 sub-matrix of elements from tile 1: + * Note that za1h should be interchangeable here. + */ + "mov w12, #0\n\t" + "mova z0.s, p0/m, za1v.s[w12, #0]\n\t" + "mova z1.s, p0/m, za1v.s[w12, #1]\n\t" + "mova z2.s, p0/m, za1v.s[w12, #2]\n\t" + "mova z3.s, p0/m, za1v.s[w12, #3]\n\t" + /* + * And store them to the input pointer (dst in the C code): + */ + "st1w {z0.s}, p0, [%0]\n\t" + "add x0, x0, #16\n\t" + "st1w {z1.s}, p0, [x0]\n\t" + "add x0, x0, #16\n\t" + "st1w {z2.s}, p0, [x0]\n\t" + "add x0, x0, #16\n\t" + "st1w {z3.s}, p0, [x0]\n\t" + "smstop" + : : "r"(dst) + : "x12", "d0", "d1", "d2", "d3", "memory"); +} + +int main() +{ + float dst[16] =3D { }; + + foo(dst); + + for (int i =3D 0; i < 16; i++) { + if (dst[i] !=3D 1.0f) { + goto failure; + } + } + /* success */ + return 0; + + failure: + for (int i =3D 0; i < 16; i++) { + printf("%f%c", dst[i], i % 4 =3D=3D 3 ? '\n' : ' '); + } + return 1; +} diff --git a/tests/tcg/aarch64/sme-fmopa-2.c b/tests/tcg/aarch64/sme-fmopa-= 2.c new file mode 100644 index 00000000000..15f0972d835 --- /dev/null +++ b/tests/tcg/aarch64/sme-fmopa-2.c @@ -0,0 +1,56 @@ +/* + * SME outer product, FZ vs FZ16 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include + +static void test_fmopa(uint32_t *result) +{ + asm(".arch_extension sme\n\t" + "smstart\n\t" /* Z*, P* and ZArray cleared */ + "ptrue p2.b, vl16\n\t" /* Limit vector length to 16 */ + "ptrue p5.b, vl16\n\t" + "movi d0, #0x00ff\n\t" /* fp16 denormal */ + "movi d16, #0x00ff\n\t" + "mov w15, #0x0001000000\n\t" /* FZ=3D1, FZ16=3D0 */ + "msr fpcr, x15\n\t" + "fmopa za3.s, p2/m, p5/m, z16.h, z0.h\n\t" + "mov w15, #0\n\t" + "st1w {za3h.s[w15, 0]}, p2, [%0]\n\t" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t" + "mov w15, #2\n\t" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 0]}, p2, [%0]\n\t" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t" + "smstop" + : "+r"(result) : + : "x15", "x16", "p2", "p5", "d0", "d16", "memory"); +} + +int main(void) +{ + uint32_t result[4 * 4] =3D { }; + + test_fmopa(result); + + if (result[0] !=3D 0x2f7e0100) { + printf("Test failed: Incorrect output in first 4 bytes\n" + "Expected: %08x\n" + "Got: %08x\n", + 0x2f7e0100, result[0]); + return 1; + } + + for (int i =3D 1; i < 16; ++i) { + if (result[i] !=3D 0) { + printf("Test failed: Non-zero word at position %d\n", i); + return 1; + } + } + + return 0; +} diff --git a/tests/tcg/aarch64/sme-fmopa-3.c b/tests/tcg/aarch64/sme-fmopa-= 3.c new file mode 100644 index 00000000000..3bfec34914c --- /dev/null +++ b/tests/tcg/aarch64/sme-fmopa-3.c @@ -0,0 +1,63 @@ +/* + * SME outer product, [ 1 2 3 4 ] squared + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include +#include + +static const float i_1234[4] =3D { + 1.0f, 2.0f, 3.0f, 4.0f +}; + +static const float expected[4] =3D { + 4.515625f, 5.750000f, 6.984375f, 8.218750f +}; + +static void test_fmopa(float *result) +{ + asm(".arch_extension sme\n\t" + "smstart\n\t" /* ZArray cleared */ + "ptrue p2.b, vl16\n\t" /* Limit vector length to 16 */ + "ld1w {z0.s}, p2/z, [%1]\n\t" + "mov w15, #0\n\t" + "mov za3h.s[w15, 0], p2/m, z0.s\n\t" + "mov za3h.s[w15, 1], p2/m, z0.s\n\t" + "mov w15, #2\n\t" + "mov za3h.s[w15, 0], p2/m, z0.s\n\t" + "mov za3h.s[w15, 1], p2/m, z0.s\n\t" + "msr fpcr, xzr\n\t" + "fmopa za3.s, p2/m, p2/m, z0.h, z0.h\n\t" + "mov w15, #0\n\t" + "st1w {za3h.s[w15, 0]}, p2, [%0]\n" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t" + "mov w15, #2\n\t" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 0]}, p2, [%0]\n\t" + "add %0, %0, #16\n\t" + "st1w {za3h.s[w15, 1]}, p2, [%0]\n\t" + "smstop" + : "+r"(result) : "r"(i_1234) + : "x15", "x16", "p2", "d0", "memory"); +} + +int main(void) +{ + float result[4 * 4] =3D { }; + int ret =3D 0; + + test_fmopa(result); + + for (int i =3D 0; i < 4; i++) { + float actual =3D result[i]; + if (fabsf(actual - expected[i]) > 0.001f) { + printf("Test failed at element %d: Expected %f, got %f\n", + i, expected[i], actual); + ret =3D 1; + } + } + return ret; +} diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile= .target index b53218e1156..8cc62eb4561 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -70,8 +70,9 @@ endif =20 # SME Tests ifneq ($(CROSS_AS_HAS_ARMV9_SME),) -AARCH64_TESTS +=3D sme-outprod1 sme-smopa-1 sme-smopa-2 -sme-outprod1 sme-smopa-1 sme-smopa-2: CFLAGS +=3D $(CROSS_AS_HAS_ARMV9_SME) +SME_TESTS =3D sme-outprod1 sme-smopa-1 sme-smopa-2 sme-fmopa-1 sme-fmopa-2= sme-fmopa-3 +AARCH64_TESTS +=3D $(SME_TESTS) +$(SME_TESTS): CFLAGS +=3D $(CROSS_AS_HAS_ARMV9_SME) endif =20 # System Registers Tests --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721309039; cv=none; d=zohomail.com; s=zohoarc; b=g60umY8rqPdFKn0VHMvQqjsaKZal5I+nbxw11cvhnlT/EbqqS1ttQW7f3Q7jq2ir46/vMwC+hFdugY9UavWRVjhOs6LEsTDt5ShzgzhaqjJOf9sabp8NAZ/quQJCJX8S3f4VGPbBhz51flSokD0IlfsNt94XakHAcxEOlTkgf6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721309039; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=o7iLSHvSys+f0c7jEjjDGMSoZe/hp7+J3/pSi3SDPcI=; b=k1YFqmek5Ot/veFeSC9DypIiGsAg2vt5ZbFQDFFlFyjCAJa0OWRy4blDw8MerwdBVkf+Dcqzp4dPJEVgcqlk76PcuMavnJ4WLULsMsVSXt0NYZxu/l6Z5Ro7aXjyYSQGGyQwjllXKKBjzjjic/WzI5APGQqWhT7znTJp/HgHHpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721309039467984.2726097232538; Thu, 18 Jul 2024 06:23:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR45-0001MN-Ay; Thu, 18 Jul 2024 09:20:57 -0400 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 1sUR3t-00008Q-P2 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3r-0004X4-UE for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:45 -0400 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso12347241fa.1 for ; Thu, 18 Jul 2024 06:20:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308842; x=1721913642; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=o7iLSHvSys+f0c7jEjjDGMSoZe/hp7+J3/pSi3SDPcI=; b=Gj5Ucd4rrTa3eO+4Sc5Ef3+Id6+FclLA3J/k5KVdZGu/tdUCMCYN4oUmnmi5gqlLqc bmpwueEIOxeJ5y5Rh2YSTCjFG2JQnfR9YfiuaPtgggNkHOEp4pF/HN9U1ulFq9uSCvPQ I3Q5927RA7h5o++RyjufVKpHj3xj3lMl8i446xfCtO2QbofOXpDEL/5g/7vDlTP3Cb2j fAfsK8wjxA4hmeehEkSXS4ZWVcPpUDb66ceNNcJ7GjXS8hXPSSUxj9RtLyQNIiEJRr7R FndcXu3pQD9DauOyY0o58xC0MrSp/0mCbBdi6XVFpMZxCHmZHffiHEk19ZPZZWNw4N9g cf0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308842; x=1721913642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o7iLSHvSys+f0c7jEjjDGMSoZe/hp7+J3/pSi3SDPcI=; b=vPz/epKA7W/MixwsdH9V0FbeGP7tv/Fqt6UOSFu5bOpct7FNOzigO0RJy0WTUBSmyz 4bbmATKwRIrytKhvnTzZshIHYbTQumC/78Ss2EUpUDaNn993ALEa3XZE2C5a8wN0/0yw 4WhYreEMirja1evInLPYdiq527Yf3QuYXgYPZlfac/zPmRvXMJkwgI7rKiJWt35LRHxV eC7c7AR8aiWnpAkp5znY3wHCwm3F84WQ/PQD2bRGoRm+4d8aHcFHU/tWg5L0Pyt/9++N kNQsM8t+XZKZDNPaCanZUD1FQ1duT5wVCKoWuTPpzStzuZUi83VjBmd2JVGOB8I6wXqa MZOQ== X-Gm-Message-State: AOJu0Yz+ZAy1N0/77rrN6+dDaiqEM3VqDglIjL8qofxcYUrr+JvwY0vH E7L9CKv3NelNIboorV2CHjtDwUR0YWZlzzrApiX3JRDKVBgPL7nMxU3GRTYjT8kHd7IrHJmwlQ2 R X-Google-Smtp-Source: AGHT+IGHP8UHTqaSOPj8NzBnlXYUl4UmNeDIPJfKy96AoVYRJouK1aU7uD4DsnVSx3N5sv31RFQ0rA== X-Received: by 2002:a2e:96d1:0:b0:2e1:2169:a5cc with SMTP id 38308e7fff4ca-2ef05c79cb4mr18185591fa.15.1721308842245; Thu, 18 Jul 2024 06:20:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/26] tests/arm-cpu-features: Do not assume PMU availability Date: Thu, 18 Jul 2024 14:20:27 +0100 Message-Id: <20240718132028.697927-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x22c.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721309041162116600 From: Akihiko Odaki Asahi Linux supports KVM but lacks PMU support. Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20240716-pmu-v3-1-8c7c1858a227@daynix.com Signed-off-by: Peter Maydell --- tests/qtest/arm-cpu-features.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c index 966c65d5c3e..cfd6f773535 100644 --- a/tests/qtest/arm-cpu-features.c +++ b/tests/qtest/arm-cpu-features.c @@ -509,6 +509,7 @@ static void test_query_cpu_model_expansion_kvm(const vo= id *data) assert_set_feature(qts, "host", "kvm-no-adjvtime", false); =20 if (g_str_equal(qtest_get_arch(), "aarch64")) { + bool kvm_supports_pmu; bool kvm_supports_steal_time; bool kvm_supports_sve; char max_name[8], name[8]; @@ -537,11 +538,6 @@ static void test_query_cpu_model_expansion_kvm(const v= oid *data) =20 assert_has_feature_enabled(qts, "host", "aarch64"); =20 - /* Enabling and disabling pmu should always work. */ - assert_has_feature_enabled(qts, "host", "pmu"); - assert_set_feature(qts, "host", "pmu", false); - assert_set_feature(qts, "host", "pmu", true); - /* * Some features would be enabled by default, but they're disabled * because this instance of KVM doesn't support them. Test that the @@ -551,11 +547,18 @@ static void test_query_cpu_model_expansion_kvm(const = void *data) assert_has_feature(qts, "host", "sve"); =20 resp =3D do_query_no_props(qts, "host"); + kvm_supports_pmu =3D resp_get_feature(resp, "pmu"); kvm_supports_steal_time =3D resp_get_feature(resp, "kvm-steal-time= "); kvm_supports_sve =3D resp_get_feature(resp, "sve"); vls =3D resp_get_sve_vls(resp); qobject_unref(resp); =20 + if (kvm_supports_pmu) { + /* If we have pmu then we should be able to toggle it. */ + assert_set_feature(qts, "host", "pmu", false); + assert_set_feature(qts, "host", "pmu", true); + } + if (kvm_supports_steal_time) { /* If we have steal-time then we should be able to toggle it. = */ assert_set_feature(qts, "host", "kvm-steal-time", false); --=20 2.34.1 From nobody Mon Sep 16 19:12:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1721308941; cv=none; d=zohomail.com; s=zohoarc; b=nBKA+zZe1B9SUVkvCVcGP0KUqCvVUJDeaxelBRH2EQlRD2c8K+nZtWX3OGbMlT0uWQtwyzOcIzetJyXKsh2bcBNMvxF6yWW0Rj7RSPrFm71JpqrzmsrhQh3dAs0YLcFZqys5DrFZx812kHpabXeJxDmdQdg03kDYaq08PpYIsp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721308941; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=79yCY4ObJ0UJwhXu8mzRzCS0V2zPCSrYq+jeYyYlXHs=; b=gZ1Nh8y1aLyMbuCLRqqn2UkqjwriqSeWPLdjNdeO5pJ+ovV4PcHf604TEJLzCVtzwnCJkyKf2XNT99pctpgsI3K27ijWNfmmc8rD/scUyodOZ7cbwkyeHucIkOcydGGffUwbw5GXaxJjcsA10/NID/ZzKWOemMEOAUa32U/NUjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172130894190529.101617832184502; Thu, 18 Jul 2024 06:22:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR4B-00022T-DX; Thu, 18 Jul 2024 09:21:03 -0400 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 1sUR3t-00009q-V4 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3s-0004XF-5q for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:45 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3684e8220f9so398649f8f.1 for ; Thu, 18 Jul 2024 06:20:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308842; x=1721913642; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=79yCY4ObJ0UJwhXu8mzRzCS0V2zPCSrYq+jeYyYlXHs=; b=Dxt2Kyh3FZG1zc8IuuyQ7T1RYfsysRAJaIded8TsEn3Qdg+CQR1lGmv4lRWEPKgjOn W/JRBpZ6RXpSVDHalJMkZFdYwkEWPq7nhKOu8OHmpKzjJoDTkid4zDFQBg2Wa3jWtzvb 3rKNTCl8J7ogM61aiT6GANoRP9Rp1l1QuChZWbR+LJsq/WyeoYMTQfBrUoFu0znOT1Sr Rw/YVGfQOS1CoQU4a+1H6srC7glAX3v4lj7dm7lwYgK74N1HNVRgx+0j9/UnC4JAtamM adr+bu6bqtF9J4vn5PYqvfz2Jc3wovYMnJ6/Uex7Ba2vt2sCPnmzhOxCq0T7k0tSt/y8 RNfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308842; x=1721913642; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=79yCY4ObJ0UJwhXu8mzRzCS0V2zPCSrYq+jeYyYlXHs=; b=YB4qSO1lZT2pM4WBKxRpNV/QVNLMUtfRIOaK+osxyhVoFVbQE1vmC81DIHGsu1wXZU GlfsMbC1UHIG4llORcDhtVVZRMzNZy6srzDeiTiXIfnskeoafV7VXhf+xPbZIbSrBcNV 9gZJ1TccoIcVdh+mCIOwCoJMFs90VoBpvgthQhbs1/IqGQjR44UK+LG7jzyaPvVmk8fY 5ays9aZ6rICaGRdfrkE5uBs8v849oUvtHF3hGY1+/MWm/FMhtyWfcM1L6FyZeiEWSDoe HE+HvOXBOTOEa+Y+7La59xoRdOYJRnEOqMhn1Eeu/cxRxuP2y3ByZFml96Swbi9Unb/D hwpA== X-Gm-Message-State: AOJu0Yy3i2voq8NlHwwy9UEzi0DPU7U6MllGQDxp6gD173cZdj1TB+68 0ysGIHPiP7A6oN+agJTUyoKvFNkwP8UiaYWNhSxF7eEZSvKZ+1sWzGoVGv35/krqCEABh6tiS/M y X-Google-Smtp-Source: AGHT+IEiuB71/4W1eCZIUp/EuIk3SDnoj+ndXnhXyNhBT2VQujocRzhOQNOafpSvtxZ5mu9z+XzDRQ== X-Received: by 2002:adf:a11b:0:b0:368:37aa:50b3 with SMTP id ffacd0b85a97d-3684b3e3543mr2156357f8f.24.1721308842720; Thu, 18 Jul 2024 06:20:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/26] hvf: arm: Do not advance PC when raising an exception Date: Thu, 18 Jul 2024 14:20:28 +0100 Message-Id: <20240718132028.697927-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x429.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=ham 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1721308942668116600 Content-Type: text/plain; charset="utf-8" From: Akihiko Odaki hvf did not advance PC when raising an exception for most unhandled system registers, but it mistakenly advanced PC when raising an exception for GICv3 registers. Cc: qemu-stable@nongnu.org Fixes: a2260983c655 ("hvf: arm: Add support for GICv3") Signed-off-by: Akihiko Odaki Message-id: 20240716-pmu-v3-4-8c7c1858a227@daynix.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/hvf/hvf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index ef9bc42738d..eb090e67a2f 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -1278,6 +1278,7 @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t re= g, uint32_t rt) /* Call the TCG sysreg handler. This is only safe for GICv3 regs. = */ if (!hvf_sysreg_read_cp(cpu, reg, &val)) { hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized()); + return 1; } break; case SYSREG_DBGBVR0_EL1: --=20 2.34.1