From nobody Thu Sep 19 01:58:12 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=1721033302; cv=none; d=zohomail.com; s=zohoarc; b=SokcrTzQNw5igoBSt6eNMb9Xu8XaIDy3gHSlPcC24HnjXcAXInpMyFD+LVtfWF3thbOLKSpqWpSgybISTcKBo6rKbnDbgQa4sJ8yKeleNHGz5jutgv9sKuPzuZu6cVihXbXzdFqhKqSaweIYUFX8XfyXpFDYvQSUJNrUgG1HhBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721033302; 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=0SzSfEc0SLDVHh1GJe0Fzz1n1p2oM3+UJXhVVnM1uKM=; b=jJ5not2kVwnPjEkq2eH+p/zEUipIlCpYRFTCuf8UqRfhXvtaDEZ3fs1z2xQLFpm4VNLP/P6v86LUZ+1NkyH/wXZmxOBDFoizRtD3cBE9uraheMORubQiFzHT5b8oTv/h2KVIGPEwhf1Px5p79ogkhhgIz19/Az+vVmLYnD3O8dA= 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 1721033302464100.42606316769252; Mon, 15 Jul 2024 01:48:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTHLi-0007CS-1b; Mon, 15 Jul 2024 04:46:22 -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 <3z-GUZggKCiIQKMQR8D8EMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--smostafa.bounces.google.com>) id 1sTHLX-0006Ed-5k for qemu-devel@nongnu.org; Mon, 15 Jul 2024 04:46:11 -0400 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3z-GUZggKCiIQKMQR8D8EMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--smostafa.bounces.google.com>) id 1sTHLV-00048f-Fy for qemu-devel@nongnu.org; Mon, 15 Jul 2024 04:46:10 -0400 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-e0353b731b8so6937288276.2 for ; Mon, 15 Jul 2024 01:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721033167; x=1721637967; 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=0SzSfEc0SLDVHh1GJe0Fzz1n1p2oM3+UJXhVVnM1uKM=; b=vQWcltHzsShdi9mSY2BbH4iyo+4AhpPvCDm+hofFyh/TiOM45GmzdvJ3v3R3SR6VwA HqDf3aMLfMjUMLDBwJCVkAVrMKX0KV3FJJgQfxdcRxRSs7weHzZ12JKps9lyfOVv6Lz5 g3eKimvQe6z/xgvEBzGFSAyh3LSlPDL0UFu9hvSHkxlpXSw6gAHvWZ+HqyEJc6P40ADw sLT4M8UMPX+4oTQreo8nD5lNIytEEeWLFxdZBCn3UbfJd4YboG9dDpH9tqMC/dSG0edO O8ZQlOvWIexhRWzxw9t2gTKx6XDvxhdT1e4jKHKvZb7aNBs/c4KomLVZSdtIHJYtOyQK uT6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721033167; x=1721637967; 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=0SzSfEc0SLDVHh1GJe0Fzz1n1p2oM3+UJXhVVnM1uKM=; b=HImMHVjXJNdNoUm6iSMtxWGxhuXEgnxLuEUR7di6tQNxCxUgybqt7AftcTX8UQ+3sg 7xP9W8H2Jgae8ya0ScRbol1uwf3cFPMSAiDnQRi3oWm/rTQekEiUgF9UhpttHnD32Xop GCkqAOEh/eDCidPg4+kevurbizQtxBoQ6kRxmVVkuiA/hMEEy98QQxXhKBcwtj1ie33/ NWTTVNlW+TQGujjAYfnxayFuf2o8N4atd06a59gf64n+rcIb+dGLkU1wjEEo7SGYb9hy tAWnNV6H+JsjTq24HA0hKhm3MhG57S398e9phjk+ZhD0IU7M4F31FUP0vlLtn1YZwQGg Ilkw== X-Forwarded-Encrypted: i=1; AJvYcCUnLSwsirDFZaouyH3sSbRU5LLMGCrIBdC80fQmK5YYG5+3D8LhOvIo5h/r2HHtMZi/YGZ3byo16EtZgoE9E8KLzlRpH/E= X-Gm-Message-State: AOJu0YyN7r9bhZZoEt5RDaOup0l4YLHUW4co0JUW8xQzCJ2VdHXK+7pb ZUOBf+B9ZwIfyVF0+wc93ei/gEkzc9HmP2mbj7fnjvC5UgMz2GlBH0PEyLEL67qLLurezh7yR9f 0yzXOWg21kA== X-Google-Smtp-Source: AGHT+IG2pk0XWFiODdVXCH3m1dD+tWhY1SoheTx2eYfNnAcE0pgm1XQjh6XKF/9ZNzXwaO/lKLw82rAKXlWz5A== X-Received: from mostafa.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:333c]) (user=smostafa job=sendgmr) by 2002:a05:6902:240a:b0:e03:a2f7:739 with SMTP id 3f1490d57ef6-e041b134c1bmr30803276.8.1721033167057; Mon, 15 Jul 2024 01:46:07 -0700 (PDT) Date: Mon, 15 Jul 2024 08:45:17 +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-18-smostafa@google.com> Subject: [PATCH v5 17/18] hw/arm/smmuv3: Support and advertise nesting 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 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::b4a; envelope-from=3z-GUZggKCiIQKMQR8D8EMMEJC.AMKOCKS-BCTCJLMLELS.MPE@flex--smostafa.bounces.google.com; helo=mail-yb1-xb4a.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=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 @google.com) X-ZM-MESSAGEID: 1721033302866116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 d052a2ba24..32b1f4cb75 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.45.2.993.g49e7a77208-goog