From nobody Thu Sep 19 01:41:32 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=1721033347; cv=none; d=zohomail.com; s=zohoarc; b=LirOy3l4LVeIX2Dtm8JNBQxBO/efALFuygLjsj1BYqYzYw/Q3hCUJe6uOc5dWnMOyj2drOPnOec3azFHA4dcBszOee+6hoaSXNxIEOg7L+5O5wPK0mmsoitaeAUu0+RkVqpvo5rYV9OrMXvfrKb574wVZFKG+azdTGXNshn9JqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721033347; h=Content-Type:Content-Transfer-Encoding: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=xKw3mGktA92OXzn4f9adqHYmUJCgi3sm+YL6zF4rMAc=; b=PdTFF5rTv+ICcIktB1xmtyFbaQlEwfnT9wTggOy1ZeFAahC0KBLlzD6/PDJKDgG3SanJEnztBRQCUxDJjfeUkvjZV6/+L8ZAuppiOvrcayVpzH5mkY1T2V3QGp60UCQrvjrue6+yGztzazWnPJRBsIHTFgrGAT6jq4UQc3F+UUI= 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 1721033347894776.3059558721365; Mon, 15 Jul 2024 01:49:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTHL1-00046N-O6; Mon, 15 Jul 2024 04:45:39 -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 <3qeGUZggKCvouoquvchciqqing.eqosgow-fgxgnpqpipw.qti@flex--smostafa.bounces.google.com>) id 1sTHL0-00040l-BG for qemu-devel@nongnu.org; Mon, 15 Jul 2024 04:45:38 -0400 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 <3qeGUZggKCvouoquvchciqqing.eqosgow-fgxgnpqpipw.qti@flex--smostafa.bounces.google.com>) id 1sTHKu-000415-9H for qemu-devel@nongnu.org; Mon, 15 Jul 2024 04:45:38 -0400 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-e03b3f48c65so7048300276.0 for ; Mon, 15 Jul 2024 01:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721033130; x=1721637930; darn=nongnu.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=xKw3mGktA92OXzn4f9adqHYmUJCgi3sm+YL6zF4rMAc=; b=eemPsofqFojIQcrZ6M23/JiO1riJb2ZPxFhBlbZxr2oupYrVlJEku18y4B0XrfFQHS ahkZcyL7M5c6xOGh+JbazTqgw76MIjCKoly6DKlpB78opH0e+IoLV+maOfdnpTItKhKV BQUpgPT6shbqGZLX7WDW3rvjXHeDCtJQ5QOSHMAMWD2LCiotXnyDZkfzECGXZcBMiu1l vxVx7fGbjwwVf755y0PBd4KxCoLz+XY/8qSNVZ29x6gHE0d9gQkmLqprHBiQbHtDwN8X roPazfLQrRAgR5TcJddvCJerat0BkE4tp4301Yw/vGdw+lAxiKQtLl2SAuobTVOrNu5N v29Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721033130; x=1721637930; h=content-transfer-encoding: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=xKw3mGktA92OXzn4f9adqHYmUJCgi3sm+YL6zF4rMAc=; b=CjIWZdzf7WLl21W5sMZpvJ4EuFFfeYkWiTmH+IIag2FuxcCFmj5NUuJbFzF/w+7SZu mWDKeN0caKQ8cXFouBkmowu9cBeXLkdgDrvvuCRW+xVIL0bU86mq77W7h05AYyRgyICL NCTrOrldkSHuwAqM+YepVx1Dsp0dnoOBipT62l0g8tP7XeFRyK+/zgKkdO7yqoNScWcQ WManJNY5+SpwZysBl9FLM4UDvWzkTRaoslYeHXw5YhvaS3cmMH+xev1g/dZe2rKJtD0s q4bmQaXvM+eXnk5dCB1kLPFdgxlIajzCY6i1s2HbzvWjdL5zfFWAl7mplv40YKSN0MCw z9dg== X-Forwarded-Encrypted: i=1; AJvYcCXCyrQcKNY84CKDd4LqMAB3OPMUCaP4K15PWBnOMAAbDLObjcmITXy3ksgcT+O85/m1C1yrzihy56r/XllGAROSjfgc9QI= X-Gm-Message-State: AOJu0YxYFjJOmnBvNQncU+eJWHeiykYhutrx7MaTOGKlsGB3d4bh7IJP YggQtLHwHBVzfo4GoeRkCibY/+WYF8jRIw+bR2oGzL1G0ncL/rB/KWacgM5/dx9LiBeDdD0Fkaf diDwO7oqXIg== X-Google-Smtp-Source: AGHT+IGO0KcFyjN1gRosAk+SCnqkSdSUonL59FPP5CWTEaYBqM6PQ0MfE0m95/y1oqm8vANJpUZqv2OIt8y87g== X-Received: from mostafa.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:333c]) (user=smostafa job=sendgmr) by 2002:a05:6902:114b:b0:e05:74ca:70ce with SMTP id 3f1490d57ef6-e0574ca77fbmr537739276.4.1721033129837; Mon, 15 Jul 2024 01:45:29 -0700 (PDT) Date: Mon, 15 Jul 2024 08:45:01 +0000 In-Reply-To: <20240715084519.1189624-1-smostafa@google.com> Mime-Version: 1.0 References: <20240715084519.1189624-1-smostafa@google.com> X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Message-ID: <20240715084519.1189624-2-smostafa@google.com> Subject: [PATCH v5 01/18] hw/arm/smmu-common: Add missing size check for stage-1 From: Mostafa Saleh To: qemu-arm@nongnu.org, eric.auger@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Cc: jean-philippe@linaro.org, alex.bennee@linaro.org, maz@kernel.org, nicolinc@nvidia.com, julien@xen.org, richard.henderson@linaro.org, marcin.juszkiewicz@linaro.org, Mostafa Saleh 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=2607:f8b0:4864:20::b49; envelope-from=3qeGUZggKCvouoquvchciqqing.eqosgow-fgxgnpqpipw.qti@flex--smostafa.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: 1721033349096116600 Content-Type: text/plain; charset="utf-8" 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 --- 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 1ce706bf94..eb2356bc35 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.45.2.993.g49e7a77208-goog