From patchwork Thu Sep 5 13:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 825652 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp288317wrb; Thu, 5 Sep 2024 06:05:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX7unvYIN26rX57AN7loLbl76mySv1Oo7X4JY2ptWMFOgt43boGFErs98TjxFads77x2mCSrQ==@linaro.org X-Google-Smtp-Source: AGHT+IGhHTK4LJ98g/lRilIeS8kua3kx+gbSCmCwC7ji72FiPUx4+PVSkEojMfOBWyTiQ+x1UmAD X-Received: by 2002:a05:620a:472b:b0:79c:c3d:9c22 with SMTP id af79cd13be357-7a98888f53bmr1060917685a.8.1725541548737; Thu, 05 Sep 2024 06:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725541548; cv=none; d=google.com; s=arc-20240605; b=EsSIdN9rz7fUzZkN/0yhqu30vtpeqIW/BNNd9I8n5AwlCKSTZ/DpShLzqHxIQmMHIS 3uChWOfac4OhnVV+CPNoX2/GwacvS7kXHciWjtc3T9u9f1EANutdEwXATipht86TjtsI Z1TSCSxzMnWR8vz44+I181Lor/4wlQ+CTdiw2uZHjPig0F3yG+5COIOkEGyhe38g58J6 uV7kcgOlZV+yqrkAjfPpGv/+TlLS+IywisW+Q93INN4d52whZ8cc8/3GQNWUj/qJgfNg G+99RBiiABTZicScS8rjqdCIoT1eb/L3docXzTDGtkW1VHDceaMOda+wFofub4v27d68 beHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=nOfGgKkVr27UMgs8upuHdRZMRcRcWoHqPVmmA3MjBFY=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=dD5T7Gn/BLT4btcjb4uWowXx9Rqlm8xVTVr+L7LV4teESRICslBLyfweOv73Kmpucb Wo+IJV2Z/n4R8Ardc5Pnj4HiPv9lecbTXDaiamu5xB3vLe8pz/EBovHR3mXi7fi3cxXG 0ivjTNuSX/KdPDxLdYI4lXaNbZnr1ecm2u6+OdTRvIlUIixKEpDKbsmaKb5cxhdL4TOy FEpsBjsQtTF+m2ePhRjkv35aShRPNRPis/ooSYEF1H04nQSCXWItXEHunf0rzvpxMVDn UaTmnPH1aZftdAfzM25qNxeB72KuYM/GG4jd+RvC+DY8hWvywvZzgX4d5YhXQtguIISP mQHA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sEh+tkn7; 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 af79cd13be357-7a98efe938asi190400785a.310.2024.09.05.06.05.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Sep 2024 06:05:48 -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=sEh+tkn7; 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 1smC6y-00015h-7i; Thu, 05 Sep 2024 09:01:20 -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 1smC6u-0000yO-AV for qemu-devel@nongnu.org; Thu, 05 Sep 2024 09:01:17 -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 1smC6s-0001kG-6P for qemu-devel@nongnu.org; Thu, 05 Sep 2024 09:01:15 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42bfb50e4e6so5750995e9.2 for ; Thu, 05 Sep 2024 06:01:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725541271; x=1726146071; 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=nOfGgKkVr27UMgs8upuHdRZMRcRcWoHqPVmmA3MjBFY=; b=sEh+tkn73fMHovuQCep3341CFzCCs0l/sNNZQx+0qFVPg+HYXhh6/Iyz6c8JXSGyuR oP7xY65TMsy/VGob3naAVE4Lr02eiAQvsrEGDjQB1dy8uBHdF1OoBfXHwv37p9X9KJLc SNPI9w3xBOAH12x58MUcKfefmFJDC7W/wr6Wjfder30r/51vi6q3yigBeI7/cs9OsIOf WM9J9ILWBw2VRW9WJqBzjXbbzfQMPTd7/D2OXgXTZLSvSQ3m+AlSbUk+Jjs939/uAJ8i 6Br6H+xQ3G5z5/EPsw+ulMMmDd8zCi6h9jcE7o5jvH9JJg/n6ez3nwsQI+A/ADIVMcfw K72w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725541271; x=1726146071; 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=nOfGgKkVr27UMgs8upuHdRZMRcRcWoHqPVmmA3MjBFY=; b=XBxEnLrBsd4ulI/f1hLviXLjNBGDAphlFDdW87vlw6SG9zuxnl86Vrry2QJFUWwTnx AMjwLL2VGmYpts6Cad7PrzFm3BvIyQ0CKNbH31qip1rtqs0Ysz7p07oQFyLlbfgfDG7B /9k9QFPsLP2qBoea77H+mDN417hglDaMoHgc8+B/9Na0OQTo+6zVzM6ZkMXFsdW1IVLr daiBTBd3Uh8zfRf0nUPfCo/O4dHoP0h68eSZ52xaSuj/Vz7TstmT6iLhvnwpmuL00SxK S7CYQr8v4qM6B+djAeqJFF1pkTcxLE4Yw0nteH1ZWQOpWp3ckun1rWxt1HtCHU3YrCXX i3Sg== X-Gm-Message-State: AOJu0YxiMAcWANh6a/h9Ivwrfd99IhGYoyTqw/HApmnnT1LJMRPCo/ww T9pMA9+H5/GOYFFm3T63taK7LL5E9na+/qg5GhZjVNzrBTXWvWXCEx9wnAm4MlpY5SM42quEyMe p X-Received: by 2002:a05:600c:474c:b0:42b:ac80:52ea with SMTP id 5b1f17b1804b1-42bb02c1098mr181247685e9.6.1725541271427; Thu, 05 Sep 2024 06:01:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42bb6e355dfsm232251365e9.46.2024.09.05.06.01.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 06:01:11 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/25] hw/arm/virt: Default to two-stage SMMU from virt-9.2 Date: Thu, 5 Sep 2024 14:00:47 +0100 Message-Id: <20240905130100.298768-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240905130100.298768-1-peter.maydell@linaro.org> References: <20240905130100.298768-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, T_SCC_BODY_TEXT_LINE=-0.01 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 Now that our SMMU model supports enabling both stages of translation at once, we can enable this in the virt board. This is no change in behaviour for guests, because if they simply ignore stage 2 and never configure it then it has no effect. For the usual backwards compatibility reasons we enable this only for machine types starting with 9.2. (Note that the SMMU is disabled by default on the virt board and is only created if the user passes the 'iommu=smmuv3' machine option.) Signed-off-by: Peter Maydell Reviewed-by: Eric Auger Reviewed-by: Daniel P. Berrangé Message-id: 20240816161350.3706332-4-peter.maydell@linaro.org --- include/hw/arm/virt.h | 1 + hw/arm/virt.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a4d937ed45a..aca4f8061b1 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -134,6 +134,7 @@ struct VirtMachineClass { bool no_cpu_topology; bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; + bool no_nested_smmu; }; struct VirtMachineState { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a5d3ad9bf9e..7934b236516 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1408,6 +1408,7 @@ static void create_pcie_irq_map(const MachineState *ms, static void create_smmu(const VirtMachineState *vms, PCIBus *bus) { + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); char *node; const char compat[] = "arm,smmu-v3"; int irq = vms->irqmap[VIRT_SMMU]; @@ -1424,6 +1425,9 @@ static void create_smmu(const VirtMachineState *vms, dev = qdev_new(TYPE_ARM_SMMUV3); + if (!vmc->no_nested_smmu) { + object_property_set_str(OBJECT(dev), "stage", "nested", &error_fatal); + } object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus), &error_abort); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); @@ -3308,8 +3312,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(9, 2) static void virt_machine_9_1_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_9_2_options(mc); compat_props_add(mc->compat_props, hw_compat_9_1, hw_compat_9_1_len); + /* 9.1 and earlier have only a stage-1 SMMU, not a nested s1+2 one */ + vmc->no_nested_smmu = true; } DEFINE_VIRT_MACHINE(9, 1)