From nobody Tue Nov 26 08:33:43 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708535914; cv=none; d=zohomail.com; s=zohoarc; b=IBantv7xOn7SLh/TCoV04N2mW+ZwpIU2ZAg73IgTTe2LyoX+RW3nXqXX3QzmrGAXIugf0ExIae15zinDbdtjEnO1Lkv5WEVya6wKqdKeWEcBp+3a6KoLDp+PlHfy7GQbW4TG1oFJR3MQcNETECN8MKuBALfQwJ453MzqvKybdAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708535914; h=Content-Type:Cc:Cc: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; bh=X/FmD0tvEMB0vrU/lqftU698V2aAgtD4PqSjN/oj0ik=; b=CG+Xyzd0yO68LIosXhImsUHONlESEaw1lGqp5naxdzMwqYE7JZX5fB8k/rwg7q7uRpVppy0+r0fNR/7FrsxDH5L8GFrZQsVBG1UKslp6UU7mmxFCejiM6h95uqpCbGKWjUCCVU8bEu5oRLEc/w/xPKg+5n+7iFCsPqMQVrqVIao= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708535914054555.4514230701179; Wed, 21 Feb 2024 09:18:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcqDt-0000UB-SD; Wed, 21 Feb 2024 12:17:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3ITDWZQwKChA3qryxu89uvq3w44w1u.s426u2A-tuBu1343w3A.47w@flex--nabihestefan.bounces.google.com>) id 1rcqDr-0000Tm-Np for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:31 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3ITDWZQwKChA3qryxu89uvq3w44w1u.s426u2A-tuBu1343w3A.47w@flex--nabihestefan.bounces.google.com>) id 1rcqDj-0007i9-0c for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:30 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dc746178515so11409832276.2 for ; Wed, 21 Feb 2024 09:17:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708535841; x=1709140641; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=X/FmD0tvEMB0vrU/lqftU698V2aAgtD4PqSjN/oj0ik=; b=NP0af65uwwiHhY/3RPZvgU8y9Tn/cVaA1kvRbA5wX8koklj09r1ZEHPCykW6pikKQ5 07Jw4nX7mB38TXjR6HXcyp2m7m0ou6795wZPLxE8rU2eFaAvS3I4bo7+TYvMNLDO5Q0i eXOZc5Nob17Z2ySltYYFNnk7coZVglCiT8f+ia+iqn4VdgVrqEBmaQ4nWUmn9OHNgyjF Sn50UGosTPLNwwi/IQkTJKnY4m6LYHuqqeGW6yqbL56NCKJCfrGyJzVtt68fs4+zIaS8 hNBqgbfHjtGYyyPQXBzmD/4ptw8wWOopxZ45d5aA0n40FB2LTyYw4FVJ7HXfuNPGsrbs mIyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708535841; x=1709140641; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=X/FmD0tvEMB0vrU/lqftU698V2aAgtD4PqSjN/oj0ik=; b=Q43kZYnYnhwK5CVsPQSO6Zu3mEY+OiwXZ+aoksXQj1TdwNOBnJOjYPavyh0TKeLjyP gxBoY97wnpyCpfMTayhm5yrfaN/LuIRoP9tfSetiZ6408brvOrrkOyAwOhppq+rmZm5C Rde0yv2LpaGGNQb7cJVpqT1sgNb3iFZjaSoMCR9PwSZI3xBP+xq8rN/DnNKXyA4mEDqO k1gG6G0PC2XvQuN88gJyY0O9eOZFRbPS8Xa5J03+Ww4jOvJpzM+bzzK+0dNR8SQ2PsCY Ep+TRT2NUXZWTbhOTO+QH3BOmqsB/l+g3slNkJQcUvqMsD2SEDchUZldQYpF87RxljtC O+Hg== X-Forwarded-Encrypted: i=1; AJvYcCWFSpqbS6fU/BMzFZ62271UprHnMcqeJ5jCQb79L9h3kJLclr8iNpSLJ5iMlJg6TXW1ie3Z68DKI+XlJ2oyNWurcqbrjIs= X-Gm-Message-State: AOJu0YzUqgLs7ER4FdNi6xbfCpQHXSosGrBrv4XarGh8TLqDLSoFdZ5d aPva+XwcemVafmcPQQ1UJnlhs6IRxG1pTFP7vxRpg8KmrLZulH7NqZWd7S6Hz5zFKVZr8lFWqYo doqSwwWAxe4emPN5/PoMC9dxEcg== X-Google-Smtp-Source: AGHT+IEhGM5FLCTGtFXsQwxMDuaGkuJ6MYzn1t9csUFbuRHUGHgg+LsRvr8l4PJu+zO0B/ZCtjUK56p+pa+bSg1TNb8= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a05:6902:1208:b0:dc6:53c3:bcbd with SMTP id s8-20020a056902120800b00dc653c3bcbdmr4675123ybu.7.1708535841023; Wed, 21 Feb 2024 09:17:21 -0800 (PST) Date: Wed, 21 Feb 2024 17:17:15 +0000 In-Reply-To: <20240221171716.1260192-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240221171716.1260192-1-nabihestefan@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221171716.1260192-2-nabihestefan@google.com> Subject: [PATCH 1/2] hw/arm/smmuv3: Check StreamIDs against SMMU_IDR1.SIDSIZE value From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, its@irrelevant.dk, kbusch@kernel.org, eric.auger@redhat.com, roqueh@google.com, nabihestefan@google.com 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=2607:f8b0:4864:20::b49; envelope-from=3ITDWZQwKChA3qryxu89uvq3w44w1u.s426u2A-tuBu1343w3A.47w@flex--nabihestefan.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01, T_SPF_TEMPERROR=0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708535914850100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Roque Arcudia Hernandez Current implementation checks the StreamIDs against STRTAB_BASE_CFG.LOG2SIZE register field value and a constant SMMU_IDR1_SIDSIZE which is also used as initial value for field SMMU_IDR1.SIDSIZE. This limits the possibility of extending the SMMUv3 by inheritance and redefining the value of SMMU_IDR1.SIDSIZE because the check is hardcoded to= the constant SMMU_IDR1_SIDSIZE rather than the register value. Signed-off-by: Roque Arcudia Hernandez Signed-off-by: Nabih Estefan Reviewed-by: Eric Auger --- hw/arm/smmuv3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 9eb56a70f3..a01031821a 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -580,15 +580,17 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, { dma_addr_t addr, strtab_base; uint32_t log2size; + uint32_t idr1_sidsize; int strtab_size_shift; int ret; =20 trace_smmuv3_find_ste(sid, s->features, s->sid_split); log2size =3D FIELD_EX32(s->strtab_base_cfg, STRTAB_BASE_CFG, LOG2SIZE); + idr1_sidsize =3D FIELD_EX32(s->idr[1], IDR1, SIDSIZE); /* * Check SID range against both guest-configured and implementation li= mits */ - if (sid >=3D (1 << MIN(log2size, SMMU_IDR1_SIDSIZE))) { + if (sid >=3D (1 << MIN(log2size, idr1_sidsize))) { event->type =3D SMMU_EVT_C_BAD_STREAMID; return -EINVAL; } --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Tue Nov 26 08:33:43 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708535914; cv=none; d=zohomail.com; s=zohoarc; b=XhiWCojg/KagZrRyDfUOA0ZX+B04x3XeGZMhnE3a8oIPo8IBQhbDhr7zvt5Z6t6Tbb81hPnLP9UNRHfbPW0akvl73PJLf6/NSpzfQSlvApStvZybLlH2zwoQ2Y4xRb0MBhb6nKJfeXvlnWh6upPM7IBO4QP+VyylIJPZV+GugGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708535914; h=Content-Type:Cc:Cc: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; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=LnfyL2lvg+ZR2ufSZa/NC/Uj0WtH9qGHbMipf5FkmKB8FjZ/5P1VCgGiW4tyQ/ft4B4fXLtEST0gjXd/e00XGhjdTNZ2EeMCmxLU+coOdV/PhS0t6VdqheYuozJXD8oToxQVD07NefLzV8uZEJ3xXT4wiDncrbJoR4l3ddt7684= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708535914897769.7031129518709; Wed, 21 Feb 2024 09:18:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcqDz-0000VN-KX; Wed, 21 Feb 2024 12:17:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com>) id 1rcqDy-0000V8-4C for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:38 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com>) id 1rcqDj-0007iu-Ck for qemu-devel@nongnu.org; Wed, 21 Feb 2024 12:17:37 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dc64e0fc7c8so9572231276.2 for ; Wed, 21 Feb 2024 09:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708535842; x=1709140642; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=EaR/Jenplj9N9FDsmbKtqww0IcMUblXUHo0vdW47/hqHAeP9tFzGj/szxoashm3Xdg 3f4LED0Wt/eiKrd06x1A+jGYhAGoYyu3dUsX2zOxS1/h9HTOx+lzO8UFzt8dfaDiTobr QJpFZy+ihpz+JbH6kNMvuiK9bQESySra52Une+lm2g6w05XWw3pIdzfyBZTvuGRed4Ej LDQoR6Eb7kMAd3hglvFOnytpYExIyaF7XemnuDUy/p9WIz09oKPWw976F61DEU6vhOn/ 8URjgM/RvK1wcSw3rX0T/du/nOWGa8Foa0HHgizPAx0GdBZ/j3FK3TfszqI6DDIsft2i 0esg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708535842; x=1709140642; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7LpRySPaP0CHOH79hBVtR1tsWRZD/BKE7TKJiIenQ5A=; b=fY5d4MpCNcsFmZsel4yKbIdLWUM7WaZDFmaUkzWGXc5RaI7JbDP+xoZjI4pxMYx624 VAyrWqEibkxw3wC1HbelZ7TJO7C0Tufd8mLyitJBi8YuK/FfaRaFQTfhzAV1W6bFCNNN 4ra3O0lQGTuhMmVDbl9ckcs+5pDi1ai7NhQqZszTdUkuKbIxc2OIwl9B0z1WMr1bDZ1G H1SRSFuLBAEzJxCcqjm3l4AoMGmnO7Hr6+S1BsJrW3o3hIhZPsIlr+igqNkad8XfhUGz OyTm/H0cvsNaoie43zB+fpxNgb1iSu5Os9w0U6zg4xes4/iN/cnAP1aKj4NqaVpUD5EI XhmQ== X-Forwarded-Encrypted: i=1; AJvYcCU8W1JbEcisBqD+07pXpiOvZ4otowPZNydzDS7B54h7fumcxcI0Ya+WxqqjWaiYTK3DXNsjaCVRtC3J5ZLzk1xqmt6z6Tg= X-Gm-Message-State: AOJu0YxqXueC8j2aBw6N8GfITCYRQAtF75szyv9meP/YzYkQ48wd2+ru 9jKUV6vcL+aKJzwvZxlne8MGhSNCa49zYQtl+AyRNJPXRIGi4H3Olb7rZyOSm16f2hmQTsdKtjZ 8cEF6u9m3AtV/4o2JJYq4wCuWQw== X-Google-Smtp-Source: AGHT+IFq05j1ZDpzfKSBRyL0w7k2B6acgaENYw7bFsnKtGNTF3koo0OHtMD+T3OvgaYx4KwOs4IFD5Xe88DNY4IjC4E= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a05:6902:1001:b0:dcc:79ab:e522 with SMTP id w1-20020a056902100100b00dcc79abe522mr778978ybt.11.1708535842359; Wed, 21 Feb 2024 09:17:22 -0800 (PST) Date: Wed, 21 Feb 2024 17:17:16 +0000 In-Reply-To: <20240221171716.1260192-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20240221171716.1260192-1-nabihestefan@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221171716.1260192-3-nabihestefan@google.com> Subject: [PATCH 2/2] hw/arm/smmu-common: Create virtual function for implementation defined StreamID From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-block@nongnu.org, its@irrelevant.dk, kbusch@kernel.org, eric.auger@redhat.com, roqueh@google.com, nabihestefan@google.com 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=2607:f8b0:4864:20::b49; envelope-from=3IjDWZQwKChE4rszyv9Avwr4x55x2v.t537v3B-uvCv2454x4B.58x@flex--nabihestefan.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708535916541100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Roque Arcudia Hernandez According to the SMMU specification the StreamID construction and size is IMPLEMENTATION DEFINED, the size being between 0 and 32 bits. This patch creates virtual functions get_sid and get_iommu_mr to allow diff= erent implementations of how the StreamID is constructed via inheritance. The def= ault implementation of these functions will match the current ones where the BDF= is used directly as StreamID. Signed-off-by: Roque Arcudia Hernandez Signed-off-by: Nabih Estefan --- hw/arm/smmu-common.c | 12 ++++++++++++ include/hw/arm/smmu-common.h | 16 +++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 4caedb4998..14b3240a88 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -621,6 +621,11 @@ static const PCIIOMMUOps smmu_ops =3D { }; =20 IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid) +{ + return ARM_SMMU_GET_CLASS(s)->get_iommu_mr(s, sid); +} + +static IOMMUMemoryRegion *smmu_base_iommu_mr(SMMUState *s, uint32_t sid) { uint8_t bus_n, devfn; SMMUPciBus *smmu_bus; @@ -659,6 +664,11 @@ void smmu_inv_notifiers_all(SMMUState *s) } } =20 +static uint32_t smmu_base_get_sid(SMMUDevice *sdev) +{ + return PCI_BUILD_BDF(pci_bus_num(sdev->bus), sdev->devfn); +} + static void smmu_base_realize(DeviceState *dev, Error **errp) { SMMUState *s =3D ARM_SMMU(dev); @@ -709,6 +719,8 @@ static void smmu_base_class_init(ObjectClass *klass, vo= id *data) device_class_set_parent_realize(dc, smmu_base_realize, &sbc->parent_realize); rc->phases.hold =3D smmu_base_reset_hold; + sbc->get_sid =3D smmu_base_get_sid; + sbc->get_iommu_mr =3D smmu_base_iommu_mr; } =20 static const TypeInfo smmu_base_info =3D { diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index 5ec2e6c1a4..d53121fe37 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -131,6 +131,9 @@ typedef struct SMMUIOTLBKey { uint8_t level; } SMMUIOTLBKey; =20 +#define TYPE_ARM_SMMU "arm-smmu" +OBJECT_DECLARE_TYPE(SMMUState, SMMUBaseClass, ARM_SMMU) + struct SMMUState { /* */ SysBusDevice dev; @@ -147,6 +150,9 @@ struct SMMUState { PCIBus *primary_bus; }; =20 +typedef uint32_t GetSidFunc(SMMUDevice *obj); +typedef IOMMUMemoryRegion *GetIommuMr(SMMUState *s, uint32_t sid); + struct SMMUBaseClass { /* */ SysBusDeviceClass parent_class; @@ -154,19 +160,19 @@ struct SMMUBaseClass { /*< public >*/ =20 DeviceRealize parent_realize; + GetSidFunc *get_sid; + GetIommuMr *get_iommu_mr; =20 }; =20 -#define TYPE_ARM_SMMU "arm-smmu" -OBJECT_DECLARE_TYPE(SMMUState, SMMUBaseClass, ARM_SMMU) - /* Return the SMMUPciBus handle associated to a PCI bus number */ SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num); =20 /* Return the stream ID of an SMMU device */ -static inline uint16_t smmu_get_sid(SMMUDevice *sdev) +static inline uint32_t smmu_get_sid(SMMUDevice *sdev) { - return PCI_BUILD_BDF(pci_bus_num(sdev->bus), sdev->devfn); + SMMUState *s =3D sdev->smmu; + return ARM_SMMU_GET_CLASS(s)->get_sid(sdev); } =20 /** --=20 2.44.0.rc0.258.g7320e95886-goog