From patchwork Thu Jul 18 13:20:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 813193 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp291271wro; Thu, 18 Jul 2024 06:24:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWPceByXQWXRDaMCcBdDezufEsMOE91YvoPy9TVanRxMN7zrThsf/pZhqk8rG3yjoEIxJdhUNMsJL/uiRPTW/gl X-Google-Smtp-Source: AGHT+IG4kDsjxoWQbNLLZgWwcN8A8uJwe1o1k5Yp/tWFulzoTY0JZh5w0a0Ta5dJlCxHNIPg7WIc X-Received: by 2002:a05:6902:2386:b0:e05:f270:aa6 with SMTP id 3f1490d57ef6-e05fec0239amr3004708276.46.1721309053282; Thu, 18 Jul 2024 06:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721309053; cv=none; d=google.com; s=arc-20160816; b=AylFQdh7tDrp/HrJJ3RtTmjOZsOTYBpRhMtebmCAwYnt7tL43YOuvlFiQEzTz9RNvT y3eWI38EebUnie4qNRV8SJ+P1FZKKzP67h1LPkqNhNCRMwd0S+V7tOP0T8gy87EF+fAW 8QP2Q/3O/gaSMq2G+OiScnc+RdDtQGOFVFOa8jfQRxQc7qdlc10uZWIbKHy9WcvDF9YH aWeXnwiZoYo0cjUz8tFV2XPNoNnDQaPpzH91/xyy2Et86WiAycDurmCh31ISqDMoUHrt pkByLcIPMKF6qn6+lxP0XTHKTNBxHuGTsvJwDUM5JhPbnpNB8mkDwgqLUjBOIVNZUa3b Vfww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=kAk+xXnGWgyO0HNANbsUCXpYZkqBmayN5+8OzJpHyYKqZ4hhRdVKLa5QXeRGEKLg/C kiD1R7pCojPI7068ycP7ugpUONeVKe+ySQ4MZQAGNGz1M1d4S7w48YkOwKPjjc3gZLn0 j8NpeeFXsX0qK77d+n8DO5U9dc8fABbGMYovIljJmxH3EcgtDRUjJPmyOWN481xUlgXk zgJwjWeN7/iPGAq1hocLJA/PsVsmE9DBcI7B6TOTOax1ImY8Qy3jiDdgGJ+8FxB0stmu j+RHg/ALbr6nIgbGuWx44KxasvSiP2IVIZ/AAdJOFWvQTcffVhrAgkAXNR1Ar1m12HZs Py5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rm31zhUZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6b79c7d4314si19813656d6.336.2024.07.18.06.24.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 06:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rm31zhUZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUR45-0001My-Cp; Thu, 18 Jul 2024 09:20:57 -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 ) id 1sUR3s-0008Rd-2V for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:46 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUR3p-0004Vl-NK for qemu-devel@nongnu.org; Thu, 18 Jul 2024 09:20:43 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4272738eb9eso2687695e9.3 for ; Thu, 18 Jul 2024 06:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721308840; x=1721913640; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; b=Rm31zhUZMc7NKy0ZWXjXBgdpisKe8y/VXVB8Lp08dKb7ZjySs/POUaEVG3+cY2OhYR fZMKtzazvulFzao8SqE5lUNU0JwviVAVfwLEEHLXgWH8xQlS0GPFsQkRhgZls7wfr672 jCDiWKwPbHec/jHrsBWlsiWmhFON8SRCEtsmqWB8HDIayJbsw6x0J3j1xmYCresg7raJ CfRj63X3h9nM74wuDRgjqGxdwxNTouExUct5xj+BN0vNiAqZ42S54CJH/3wlNWzH1A6L nec7VO82RQ3t/QJ3ynWfWHOlupcKIWkO0473Hf5xdtm3kWIfXwCB0rdCeDQmkn/jAEvF U0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721308840; x=1721913640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PslsTW2CuNXZBgCWQhwf4uOsn1nScOUybIYhJNiQ/EI=; b=MpcikM805iaa/itKHY9qt7C4iwW1zLvqZDCWAoY0VCO4xjdqdHtUDzIHsG0Qtg6+8i XwvpFJe3H+wANh8UlmQvM83JYTcBCIVmluwFUWLx9BuMP8HwZwHZ5QxWyDmLJS/Ld/Tz g1T8Haw9sXm5Usm38nrvXdU1Kkt3RIS5ZaY41++uiq0JLBfNQsca51rAJ4dswuIR06xE sLIac6XbqjaN0cgfQp114LwNyix5KIFngnJdpQlnsmEpaEsNvDc310BDXu5OTKPTGDO5 5kDpdmemZZbN7bzsEODX8C4g6t0aDv2L35XhnxJ7I2xsJa97zaOATEFpLaTnqYtU8IMv 3n1w== X-Gm-Message-State: AOJu0YxiNCnDa89nnqDZjkmOr8jPg1AUmbG8dLssyOknbBOnTVd8vv5U d110/8irqSec68tN7xU0envHCUF03d32muiZMCrSfIU/fpVQekSik28z5znHDHpA9wLBbsCeQ8Z Q X-Received: by 2002:a05:600c:4707:b0:426:5f7d:addc with SMTP id 5b1f17b1804b1-427c2d107edmr32788725e9.37.1721308840025; Thu, 18 Jul 2024 06:20:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427d2a8e420sm14059315e9.35.2024.07.18.06.20.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 06:20:39 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/26] hw/arm/smmuv3: Support and advertise nesting Date: Thu, 18 Jul 2024 14:20:22 +0100 Message-Id: <20240718132028.697927-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240718132028.697927-1-peter.maydell@linaro.org> References: <20240718132028.697927-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Mostafa Saleh 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 Reviewed-by: Alex Bennée Message-id: 20240715084519.1189624-18-smostafa@google.com Signed-off-by: Peter Maydell --- 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 2d61637aed5..3db6c7c1357 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 advertised.*/ if (s->stage && !strcmp("2", s->stage)) { s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); + } else if (s->stage && !strcmp("nested", s->stage)) { + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); } else { s->idr[0] = 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) static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) { - cfg->stage = SMMU_STAGE_2; - if (STE_S2AA64(ste) == 0x0) { qemu_log_mask(LOG_UNIMP, "SMMUv3 AArch32 tables not supported\n"); @@ -509,6 +510,27 @@ bad_ste: return -EINVAL; } +static void decode_ste_config(SMMUTransCfg *cfg, uint32_t config) +{ + + if (STE_CFG_ABORT(config)) { + cfg->aborted = true; + return; + } + if (STE_CFG_BYPASS(config)) { + cfg->bypassed = true; + return; + } + + if (STE_CFG_S1_ENABLED(config)) { + cfg->stage = SMMU_STAGE_1; + } + + if (STE_CFG_S2_ENABLED(config)) { + cfg->stage |= 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 *cfg, config = STE_CONFIG(ste); - if (STE_CFG_ABORT(config)) { - cfg->aborted = true; - return 0; - } + decode_ste_config(cfg, config); - if (STE_CFG_BYPASS(config)) { - cfg->bypassed = true; + if (cfg->aborted || cfg->bypassed) { return 0; } @@ -704,7 +722,6 @@ static int decode_cd(SMMUv3State *s, SMMUTransCfg *cfg, /* we support only those at the moment */ cfg->aa64 = true; - cfg->stage = SMMU_STAGE_1; cfg->oas = oas2bits(CD_IPS(cd)); cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas);