From nobody Mon May 20 03:18:08 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1575467916; cv=none; d=zohomail.com; s=zohoarc; b=Eot6pocfMNMmsfiw4+aiI7Xz0fpac6E8VuHb7ObeEsv59kr6dVE9DG+WVsgBWndUle1phpgfHkITrAIi8dui6pIPFY17vktUmgqSRLi7ipczs/kRxGsLAvzM90tiDeUerQH+11tqYBG+X+CGubL5XhbieyaJUXi+R8L2akMzCDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575467916; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qj63OZvgUd2blMa1aPgiv5NYnxSXE+CuB5YhjLWxvAQ=; b=lETTlTDlfyt5ekau5xAiNLHd1eyh1WL96GNBx9nWtzK2r92cHspsIgqZ9ot5ov4opRS0mgDCKzaDtyV98oENXkq/8akj5tNmbr5xYacA0my5Nq5qq2lmXS0dJPQZUd+FcB0TOQPjSRe5DPePufgTyar0ztpbh5j2DlgTc2ygHjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575467916428483.6420413195889; Wed, 4 Dec 2019 05:58:36 -0800 (PST) Received: from localhost ([::1]:39282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVAo-0006wj-9t for importer@patchew.org; Wed, 04 Dec 2019 08:58:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38394) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icV8j-000576-4W for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icV8i-0005D1-2j for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:25 -0500 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:42197) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icV8f-00058h-N0; Wed, 04 Dec 2019 08:56:21 -0500 Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 04 Dec 2019 13:56:19 +0000 Received: from sveith-desktop.aka.corp.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-1c1b5cdd.us-west-2.amazon.com (Postfix) with ESMTPS id 09EB5A1DCA; Wed, 4 Dec 2019 13:56:17 +0000 (UTC) Received: from sveith-desktop.aka.corp.amazon.com (localhost [127.0.0.1]) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id xB4DuG4i029360; Wed, 4 Dec 2019 14:56:16 +0100 Received: (from sveith@localhost) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Submit) id xB4DuG1e029358; Wed, 4 Dec 2019 14:56:16 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575467782; x=1607003782; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=qj63OZvgUd2blMa1aPgiv5NYnxSXE+CuB5YhjLWxvAQ=; b=TJAKTEAf9mBVF6OR39gakACdYNs24NTz0lAPMf6D0rVo0oIG+hd++2qf KuITrx/F/AVCuQH8WFv35c1ISiTFr7Hgo8ywZliCWOEvbSYcSmK9oUiwi BTWOPXwG2gn3wXiaAIBayUjjmdyfPc437IIgLihMQtgkyA8R1u20y0NGd w=; IronPort-SDR: 9XWlbc6AWrPk3Sj3AkLAH72XL5hyTn7zSX2aKM1OSxlEtUk5upywo/vxwyze+8OM3TAF/7Xmah 3NCeQZ6lGfYQ== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="7621879" From: Simon Veith To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Simon Veith , Eric Auger Subject: [PATCH 1/5] hw/arm/smmuv3: Apply address mask to linear strtab base address Date: Wed, 4 Dec 2019 14:55:44 +0100 Message-Id: <1575467748-28898-2-git-send-email-sveith@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575467748-28898-1-git-send-email-sveith@amazon.de> References: <1575467748-28898-1-git-send-email-sveith@amazon.de> Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 52.95.48.154 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the SMMU_STRTAB_BASE register, the stream table base address only occupies bits [51:6]. Other bits, such as RA (bit [62]), must be masked out to obtain the base address. The branch for 2-level stream tables correctly applies this mask by way of SMMU_BASE_ADDR_MASK, but the one for linear stream tables does not. Apply the missing mask in that case as well so that the correct stream base address is used by guests which configure a linear stream table. Linux guests are unaffected by this change because they choose a 2-level stream table layout for the QEMU SMMUv3, based on the size of its stream ID space. ref. ARM IHI 0070C, section 6.3.23. Signed-off-by: Simon Veith Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger --- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index e2fbb83..eef9a18 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -429,7 +429,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, = STE *ste, } addr =3D l2ptr + l2_ste_offset * sizeof(*ste); } else { - addr =3D s->strtab_base + sid * sizeof(*ste); + addr =3D (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*st= e); } =20 if (smmu_get_ste(s, addr, ste, event)) { --=20 2.7.4 From nobody Mon May 20 03:18:08 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1575467949; cv=none; d=zohomail.com; s=zohoarc; b=nVEEB6Ayr5GrraLM1DqAzxt/nn60aRj1LohIa5kVNa+5HtJIEZ9hJ7I4pyaZVLnszckdumSn7Q9GgUB+3OtjdaUZZR2j6VIBsy/OuWUndVqC7o45vFSo1boPodP6WmflgKxUfLsRRFpsngc3WM57MW+tDA9oe2VJQpQmX+CDIT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575467949; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=mGz2Hs159Z/4+8pT881Ub7PtsnSyXxiUtbVakc2yFWM=; b=Ex1VStmXaaFtyMY55w2xXGinE/OMah3EeOUGJospC0Q3t1njcUImBRro63aJP11rHUtWMq/rhqJ7MBLlQQw/zkmXsr4qhuMLnmNp93rBZBd5awRf2y7supZyiSduM0CsCNfsOUtdtITDdN0khjsuBXO3/hKTNhVeH/JB3qMyce0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575467949670775.3575907912887; Wed, 4 Dec 2019 05:59:09 -0800 (PST) Received: from localhost ([::1]:39288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVBM-0007jO-0Y for importer@patchew.org; Wed, 04 Dec 2019 08:59:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icV8m-0005Bc-Ap for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icV8l-0005ML-4A for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:28 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:9490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icV8i-0005BH-HB; Wed, 04 Dec 2019 08:56:24 -0500 Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 04 Dec 2019 13:56:22 +0000 Received: from sveith-desktop.aka.corp.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2b-8cc5d68b.us-west-2.amazon.com (Postfix) with ESMTPS id 19EF7A2330; Wed, 4 Dec 2019 13:56:20 +0000 (UTC) Received: from sveith-desktop.aka.corp.amazon.com (localhost [127.0.0.1]) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id xB4DuJbQ029389; Wed, 4 Dec 2019 14:56:19 +0100 Received: (from sveith@localhost) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Submit) id xB4DuJ65029388; Wed, 4 Dec 2019 14:56:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575467784; x=1607003784; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=mGz2Hs159Z/4+8pT881Ub7PtsnSyXxiUtbVakc2yFWM=; b=F01Fw8CDIdq4GZyQntiadzGH2NBKnZufGKnyhlu0SaepjkVzIj2ywRhF LKkillroCAZhyWJ936gRjDDt6Z0uclr8LHaB8a8EJB1qJ9JQhPQz5aW9W oNpYkA8djhq8YcDRt0rAZOjqmMFoRQ008YA+nwZs0p8slBUziq1UPUA3z g=; IronPort-SDR: 6smuSj9Iia7aCLpemJErFU3iL5nFjvhmsp19zr4FoSQ1qTYGbMstT+LPjGnZTaJLRGtz6d5vZL L9Kv8Oo6K72Q== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="3177677" From: Simon Veith To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Simon Veith , Eric Auger Subject: [PATCH 2/5] hw/arm/smmuv3: Check stream IDs against actual table LOG2SIZE Date: Wed, 4 Dec 2019 14:55:45 +0100 Message-Id: <1575467748-28898-3-git-send-email-sveith@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575467748-28898-1-git-send-email-sveith@amazon.de> References: <1575467748-28898-1-git-send-email-sveith@amazon.de> Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 207.171.184.25 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When checking whether a stream ID is in range of the stream table, we have so far been only checking it against our implementation limit (SMMU_IDR1_SIDSIZE). However, the guest can program the STRTAB_BASE_CFG.LOG2SIZE field to a size that is smaller than this limit. Check the stream ID against this limit as well to match the hardware behavior of raising C_BAD_STREAMID events in case the limit is exceeded. ref. ARM IHI 0070C, section 6.3.24. Signed-off-by: Simon Veith Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org --- hw/arm/smmuv3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index eef9a18..aad4639 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -377,11 +377,15 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, SMMUEventInfo *event) { dma_addr_t addr; + uint32_t log2size; int ret; =20 trace_smmuv3_find_ste(sid, s->features, s->sid_split); - /* Check SID range */ - if (sid > (1 << SMMU_IDR1_SIDSIZE)) { + log2size =3D FIELD_EX32(s->strtab_base_cfg, STRTAB_BASE_CFG, LOG2SIZE); + /* + * Check SID range against both guest-configured and implementation li= mits + */ + if (sid > (1 << MIN(log2size, SMMU_IDR1_SIDSIZE))) { event->type =3D SMMU_EVT_C_BAD_STREAMID; return -EINVAL; } --=20 2.7.4 From nobody Mon May 20 03:18:08 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1575468150; cv=none; d=zohomail.com; s=zohoarc; b=Te9epJmaClJx4jHPWDSpeLRov20CVN+kk+nFPcLXeu1QJmElz740L+WxuNayp0uF6OcRITNVafnqkPXpBa0hVb9QhmioctZ3zKlQbO4Pjl52Jr2AGRBN+MgHUsXpG3TfPzuvojZ3mt0dLtumTTMCNKA5Ejj3aUE8SVW2p6vnrcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575468150; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=903Oin9iiuc+khCz3xboU318uHpQzskDGrltjVjcCSM=; b=Z66y+orPTCh1qAJa/xaybGM1GHBO7ng8zN2uLc1V0I6Kfo0IFqY1JGpynxo4R3EX0lZOhGNvZgn/PVhDrvGrnNevjBGIkJ1Po0rdUUGjM0rBCJJz/bGVnWxPBLKZWMDjaAYOzbXddTF/o87LfbtRvXcRuPgr1qHsOArkkwUuIS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575468150746849.1065986865367; Wed, 4 Dec 2019 06:02:30 -0800 (PST) Received: from localhost ([::1]:39348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVEX-0002XX-D7 for importer@patchew.org; Wed, 04 Dec 2019 09:02:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38480) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icV8n-0005Dn-H3 for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icV8m-0005O8-9v for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:29 -0500 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:42197) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icV8j-00058h-Pi; Wed, 04 Dec 2019 08:56:25 -0500 Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 04 Dec 2019 13:56:25 +0000 Received: from sveith-desktop.aka.corp.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com (Postfix) with ESMTPS id 292F1A1FA7; Wed, 4 Dec 2019 13:56:23 +0000 (UTC) Received: from sveith-desktop.aka.corp.amazon.com (localhost [127.0.0.1]) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id xB4DuMZO029396; Wed, 4 Dec 2019 14:56:22 +0100 Received: (from sveith@localhost) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Submit) id xB4DuMcV029395; Wed, 4 Dec 2019 14:56:22 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575467786; x=1607003786; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=903Oin9iiuc+khCz3xboU318uHpQzskDGrltjVjcCSM=; b=FfLvHL4rlHS3OTiics/U3hMmZjFuBmt6+Mx/jDoVpOWeE04uCSpgsZvU 4TqaJ0Uu0kt19Z0o2DVqQqvFn8tYIiEDySqUi/HUckopc0cInm3/OF9ds 4dvnk4WFnk2nyJ0Y2lkf3I3b8OyHhdnwWAaUAysi1P+ryZK936629hjUt Q=; IronPort-SDR: 14zrM5qDK+M1wIRKinaJl1On6utbiyQqfM9hpWiDqLLMvFtDYSLempEbZ898yszACoWOIFSjRH onZAOInhjG7w== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="7621894" From: Simon Veith To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Simon Veith , Eric Auger Subject: [PATCH 3/5] hw/arm/smmuv3: Align stream table base address to table size Date: Wed, 4 Dec 2019 14:55:46 +0100 Message-Id: <1575467748-28898-4-git-send-email-sveith@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575467748-28898-1-git-send-email-sveith@amazon.de> References: <1575467748-28898-1-git-send-email-sveith@amazon.de> Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 52.95.48.154 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Per the specification, and as observed in hardware, the SMMUv3 aligns the SMMU_STRTAB_BASE address to the size of the table by masking out the respective least significant bits in the ADDR field. Apply this masking logic to our smmu_find_ste() lookup function per the specification. ref. ARM IHI 0070C, section 6.3.23. Signed-off-by: Simon Veith Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org --- hw/arm/smmuv3.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index aad4639..2d6c275 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -376,8 +376,9 @@ bad_ste: static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event) { - dma_addr_t addr; + dma_addr_t addr, strtab_base; uint32_t log2size; + int strtab_size_shift; int ret; =20 trace_smmuv3_find_ste(sid, s->features, s->sid_split); @@ -391,10 +392,23 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, } if (s->features & SMMU_FEATURE_2LVL_STE) { int l1_ste_offset, l2_ste_offset, max_l2_ste, span; - dma_addr_t strtab_base, l1ptr, l2ptr; + dma_addr_t l1ptr, l2ptr; STEDesc l1std; =20 - strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK; + /* + * Align strtab base address to table size. For this purpose, assu= me it + * is not bounded by SMMU_IDR1_SIDSIZE. + */ + strtab_size_shift =3D log2size - s->sid_split - 1 + 3; + if (strtab_size_shift < DMA_ADDR_BITS) { + if (strtab_size_shift < 5) { + strtab_size_shift =3D 5; + } + strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK & + ~((1ULL << strtab_size_shift) - 1); + } else { + strtab_base =3D 0; + } l1_ste_offset =3D sid >> s->sid_split; l2_ste_offset =3D sid & ((1 << s->sid_split) - 1); l1ptr =3D (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std)= ); @@ -433,7 +447,14 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid,= STE *ste, } addr =3D l2ptr + l2_ste_offset * sizeof(*ste); } else { - addr =3D (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*st= e); + strtab_size_shift =3D log2size + 5; + if (strtab_size_shift < DMA_ADDR_BITS) { + strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK & + ~((1ULL << strtab_size_shift) - 1); + } else { + strtab_base =3D 0; + } + addr =3D strtab_base + sid * sizeof(*ste); } =20 if (smmu_get_ste(s, addr, ste, event)) { --=20 2.7.4 From nobody Mon May 20 03:18:08 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1575467933; cv=none; d=zohomail.com; s=zohoarc; b=aJAS64lH7mdBYBD8gq/4lKuO3LYiS/zoEr/sZFsV+RTfZYTcQciQllitHU2bpQivl8KqtC1b0k+GJPr9rdruNgnVOV9Jh3VggBmdZMVrwuEQ95qnnq3MZddvJb89Ir/7zg0vv5ZzQwWdvUX5Ip2jt/9Wpd6inobiVgWt4rx1Jyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575467933; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=ZJTN+ohaJEyJa5Mz38YWX2orkNnDr5ayiRkSEay2Bdo=; b=SFcnKYRbS2+h+86+CqXcqrlk5eXwERu9YFMEABwo0+s75CW5fMmbFLXoLP2Pb8nDH+XpaREs1S1qOPxqXL7CwAycT5LY2w0qLluzqvPmpns7aauvq5P7/pSksjT5Uf+WNEhoESxedJxc2Y5p6PIG0FnkNYnC1wRanri4luV0zVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575467933125711.876529273339; Wed, 4 Dec 2019 05:58:53 -0800 (PST) Received: from localhost ([::1]:39286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVB5-0007LO-ID for importer@patchew.org; Wed, 04 Dec 2019 08:58:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38528) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icV8s-0005Lu-AO for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icV8r-0005RR-7w for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:34 -0500 Received: from smtp-fw-2101.amazon.com ([72.21.196.25]:62079) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icV8o-0005PN-UN; Wed, 04 Dec 2019 08:56:31 -0500 Received: from iad6-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com) ([10.124.125.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 04 Dec 2019 13:56:29 +0000 Received: from sveith-desktop.aka.corp.amazon.com (pdx2-ws-svc-lb17-vlan2.amazon.com [10.247.140.66]) by email-inbound-relay-2c-6f38efd9.us-west-2.amazon.com (Postfix) with ESMTPS id DF7E8A1FAE; Wed, 4 Dec 2019 13:56:27 +0000 (UTC) Received: from sveith-desktop.aka.corp.amazon.com (localhost [127.0.0.1]) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id xB4DuQXE029431; Wed, 4 Dec 2019 14:56:26 +0100 Received: (from sveith@localhost) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Submit) id xB4DuQPZ029429; Wed, 4 Dec 2019 14:56:26 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575467791; x=1607003791; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZJTN+ohaJEyJa5Mz38YWX2orkNnDr5ayiRkSEay2Bdo=; b=Jb+yjW7WmxhOiBvSEB8HwP8Zi/Wdac+eksxvj7s/Wv5AQO12vILGGXg2 6cSq1q7qci2B/F0pamc4TDE9FNipZcajTaNOkfIQtvii+XZFNDExseP5h FvtmEb5lIs5zy03zaLHW0yw0B3aHJtdR05mqPdqaG4NRe/B4s5WVCm0yM 4=; IronPort-SDR: xAghjvXNYNirL+e0jZsjnDzVKkEodVBF1T9JaUN3H8Slhdwps/MZLMCnBH+oh0CIHOOs/1woY2 yi3yNajWEnlg== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="7106992" From: Simon Veith To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Simon Veith , Eric Auger Subject: [PATCH 4/5] hw/arm/smmuv3: Use correct bit positions in EVT_SET_ADDR2 macro Date: Wed, 4 Dec 2019 14:55:47 +0100 Message-Id: <1575467748-28898-5-git-send-email-sveith@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575467748-28898-1-git-send-email-sveith@amazon.de> References: <1575467748-28898-1-git-send-email-sveith@amazon.de> Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 72.21.196.25 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The bit offsets in the EVT_SET_ADDR2 macro do not match those specified in the ARM SMMUv3 Architecture Specification. In all events that use this macro, e.g. F_WALK_EABT, the faulting fetch address or IPA actually occupies the 32-bit words 6 and 7 in the event record contiguously, with the upper and lower unused bits clear due to alignment or maximum supported address bits. How many bits are clear depends on the individual event type. Update the macro to write to the correct words in the event record so that guest drivers can obtain accurate address information on events. ref. ARM IHI 0070C, sections 7.3.12 through 7.3.16. Signed-off-by: Simon Veith Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger --- hw/arm/smmuv3-internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index d190181..eb275e2 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -461,8 +461,8 @@ typedef struct SMMUEventInfo { } while (0) #define EVT_SET_ADDR2(x, addr) \ do { \ - (x)->word[7] =3D deposit32((x)->word[7], 3, 29, addr >> 16); = \ - (x)->word[7] =3D deposit32((x)->word[7], 0, 16, addr & 0xffff)= ;\ + (x)->word[7] =3D (uint32_t)(addr >> 32); \ + (x)->word[6] =3D (uint32_t)(addr & 0xffffffff); \ } while (0) =20 void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event); --=20 2.7.4 From nobody Mon May 20 03:18:08 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from=amazon.de ARC-Seal: i=1; a=rsa-sha256; t=1575468154; cv=none; d=zohomail.com; s=zohoarc; b=ADEE5awcrlLOV8FfS1w8QWBhiyXvueMUmq4n/JmGG/g10MEpn+l5bhdlGduWNMwLaMvlKbBi52sT0bdSUMoGezeeerlrJFlzHTT+qRilKDs8yHThC8jYFt/hFbMPq9IfaZOumtGqUK7ZBJxvX3vVYDSlFi+VnDEzzwRF0pKKVAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575468154; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=uThbvtPQAz4aUcOeaWmIN//ZqDzYZn0zQCbaxFwdtm0=; b=OhIc8mSW+BwVVfuR+7a0vsnwJ3ZgFH8qi+oLhIrfeuCsP2jXuWgX1yB7XwDOH0cb0yFGUpR07dfBMyNwKnbsnMaXGMgKWXN8fEXVdJX1gA62zjyJkr+R2zhV6rVlVrRDW83uHeDXsuK+ZoLLTgDLztuDyVWl5bapdblLynlVhq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@amazon.de; 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=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575468154900836.3888446052628; Wed, 4 Dec 2019 06:02:34 -0800 (PST) Received: from localhost ([::1]:39350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icVEf-0002cI-Mj for importer@patchew.org; Wed, 04 Dec 2019 09:02:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38549) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icV8u-0005Pl-Iv for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icV8t-0005Sz-IT for qemu-devel@nongnu.org; Wed, 04 Dec 2019 08:56:36 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:9536) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icV8r-0005QG-6e; Wed, 04 Dec 2019 08:56:33 -0500 Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-119b4f96.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 04 Dec 2019 13:56:32 +0000 Received: from sveith-desktop.aka.corp.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-119b4f96.us-west-2.amazon.com (Postfix) with ESMTPS id BA66F1A11D5; Wed, 4 Dec 2019 13:56:31 +0000 (UTC) Received: from sveith-desktop.aka.corp.amazon.com (localhost [127.0.0.1]) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id xB4DuUkY029462; Wed, 4 Dec 2019 14:56:30 +0100 Received: (from sveith@localhost) by sveith-desktop.aka.corp.amazon.com (8.15.2/8.15.2/Submit) id xB4DuUrM029461; Wed, 4 Dec 2019 14:56:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1575467793; x=1607003793; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=uThbvtPQAz4aUcOeaWmIN//ZqDzYZn0zQCbaxFwdtm0=; b=FEZpZAsTEgUabUqIqUochmBbsfGJ9UvVqT7JWHO3eLSokf10badQzn5y gZUGy8gNbWzLFChaB+Zfyrz3+jgyfWgGTv19UidtKkZEUOFv3KoRxGkpO tWDTHk/mBYDC488mbJqqiaJ3Bqg7fVJfEKDl4x2lXJJCJjU9E2bWV+iPx c=; IronPort-SDR: 99aAc83sA2OgyShNxfulzAYj5fH+VfXXffUGMHdweV+0Iuyx7LbWzGx1DrSMd9TbQzfj+YgX+/ 8qH33e89q97w== X-IronPort-AV: E=Sophos;i="5.69,277,1571702400"; d="scan'208";a="3177723" From: Simon Veith To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Cc: Simon Veith , Eric Auger Subject: [PATCH 5/5] hw/arm/smmuv3: Report F_STE_FETCH fault address in correct word position Date: Wed, 4 Dec 2019 14:55:48 +0100 Message-Id: <1575467748-28898-6-git-send-email-sveith@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575467748-28898-1-git-send-email-sveith@amazon.de> References: <1575467748-28898-1-git-send-email-sveith@amazon.de> Precedence: Bulk X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 207.171.184.25 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @amazon.de) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The smmuv3_record_event() function that generates the F_STE_FETCH error uses the EVT_SET_ADDR macro to record the fetch address, placing it in 32-bit words 4 and 5. The correct position for this address is in words 6 and 7, per the SMMUv3 Architecture Specification. Update the function to use the EVT_SET_ADDR2 macro instead, which is the macro intended for writing to these words. ref. ARM IHI 0070C, section 7.3.4. Signed-off-by: Simon Veith Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger --- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 2d6c275..125e47d 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -172,7 +172,7 @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo = *info) case SMMU_EVT_F_STE_FETCH: EVT_SET_SSID(&evt, info->u.f_ste_fetch.ssid); EVT_SET_SSV(&evt, info->u.f_ste_fetch.ssv); - EVT_SET_ADDR(&evt, info->u.f_ste_fetch.addr); + EVT_SET_ADDR2(&evt, info->u.f_ste_fetch.addr); break; case SMMU_EVT_C_BAD_STE: EVT_SET_SSID(&evt, info->u.c_bad_ste.ssid); --=20 2.7.4