From nobody Tue Nov 26 10:24:36 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