From patchwork Thu Oct 19 07:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 735525 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378539wro; Thu, 19 Oct 2023 00:19:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVoyKGb+KO09/DosFRDT5HPPRSxH+yHe3hAfYgIKZDbtOtIUdlod9v+syUUgg86p3I43HF X-Received: by 2002:ac8:5bcf:0:b0:418:1272:7c6e with SMTP id b15-20020ac85bcf000000b0041812727c6emr1508164qtb.7.1697699988606; Thu, 19 Oct 2023 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699988; cv=none; d=google.com; s=arc-20160816; b=autyboZ0tg/2FfZcR1doveYxeMDgYqgtP/W3cZfYu/Ad9e/UI+kqkTaiINLh91a/fc Vq1v1WKeP4uTXXYDf07To4tmwYsi1XKubxexHKiDsDmae50W/SphEdeGp6PsfqXMT+kz flYITgLANxesnpHo9BrTWVE8Q/gPwK42UlO4MQ+WOp95nvjoMm58eCIe50qMp96MrvQ9 /VTe6s0lCuyuxaZH3uTV1tOhwSpAm0qLsDeQPtgwUrsk+Reqi9UQKaqFiXCKWKfGubfs L229FzDmSKMFdU9CvqXhA+yZ4oko+DkrbZRF/b7Xuz+SpcyyGz9a+kvI92JT0LHSYF6H ZTlA== 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:cc:to :from:dkim-signature; bh=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=LCV45oe3nmaXs8xlG48Wgnri3zOfBLlviCshw5SZ67lqPzKFkpGEVeIHU2AcGRYs66 hRQvKLhm3hdUAIDNPhJkGqC/gAFaWoGs6fkdGQOVeaiByqWMRz9ttuBSXImX1l4dkvLW d/F4ShxcU+OzHCYPXDJCLFpOHgxvLSq1YfNvRpZqr4C/EBYEw0lIgdc8eJfyAhhmdxZ6 SGKz69YkTeeUl4lrJ3eNrwfKqwOkWHCfkF+8wkfuXFIZ+epWv+cJNpKm6s0aIwpEd04Z a2VjVnWHE+SoA17/xExteFAWM1t/nS/BqWKWCE0ehaaFZuYNG6VCI97ec+KFxvSgovaf fXDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JiiiZJX2; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h14-20020ac85e0e000000b0041983f51b2esi1149456qtx.67.2023.10.19.00.19.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19: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=JiiiZJX2; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtNGu-0004s3-4R; Thu, 19 Oct 2023 03:16:44 -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 1qtNGt-0004rZ-25 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:43 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNGq-0003Ao-Do for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:42 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32db8924201so3002238f8f.1 for ; Thu, 19 Oct 2023 00:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699799; x=1698304599; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; b=JiiiZJX2Ul0XFeys+tTH56OyMyqLueNy/2tqHDb0lNtj0AWpJiGsUTR1k3CXGVtbwV UUbQDwMxmtDknDnLBgaWXp+ByJ3RM3C750Bp1pFu1oWWbvmgrCGLxfCi4KmvaOam3iGK bsI8rxL/6a9kSuTNyCNY9eYarRW038iqRyfFn2Kq/cT+tYsaz5Iqkphu0yiG22EmyM8+ hWs9p8Sio9fur8zvbrEEP0rIMc6V/GytAkHJZuJMK5nbWgGP9eP0twgyigFWKjxgmvcY c1Vpxcai1SPM825bZO94Dk58PbbWiIG4wW128/oAXEVh/+E5sOAby8BN/sl5R5KLtAw3 CHPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699799; x=1698304599; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; b=d4oGaHtqChv+kHwLp3oxkN3KenJ6Vb0kTMn+jqGWucAyoWhve8c2u6xnjghQR4udK9 /dsKsGwVlq2GM2B/mI+EfMkO8oW668jUby/KTDcP4jQLl6VB6in7xmRQcEBhEg1psO14 3E1wjQBXQyu3hA8GIKTQgXXMftBEc1uwlkS6ze86/uUhOmPSEYsvrJCew4cuTlQQ5HLP RVrlGpooQJ1Do+hyaw1+uGN5B2ki/VnwVKIouHrBwm+DsNFqb8S/3jKodzonTfTLkavE 1HOL8pkU8G/a/6cVllK3Ht5Re+6QxLeIz+ru0Sm3WGpweU9O0FSFTa9UdEFzAf+jQ5xJ WGRg== X-Gm-Message-State: AOJu0Yzk4W+gHfUpWy+XtISNRdX9rrU/EOfY2LEZp2kIBcQZzEaUuM0W yFlFmW268JccaU87POsUiEfP+bizFCQdIiOwkW+AzA== X-Received: by 2002:adf:f682:0:b0:32d:8cfd:5780 with SMTP id v2-20020adff682000000b0032d8cfd5780mr918954wrp.27.1697699798766; Thu, 19 Oct 2023 00:16:38 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id i3-20020a5d6303000000b0032db4e660d9sm3755308wru.56.2023.10.19.00.16.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:16:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 02/12] hw/i386/intel_iommu: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 09:16:00 +0200 Message-ID: <20231019071611.98885-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is no point in exposing an internal MMIO region via SysBus and directly mapping it in the very same device. Just map it without using the SysBus API. Transformation done using the following coccinelle script: @@ expression sbdev; expression index; expression addr; expression subregion; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map(sbdev, index, addr); + memory_region_add_subregion(get_system_memory(), addr, subregion); Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Reviewed-by: Zhao Liu --- hw/i386/intel_iommu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2c832ab68b..e4f6cedcb1 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4134,6 +4134,8 @@ static void vtd_realize(DeviceState *dev, Error **errp) qemu_mutex_init(&s->iommu_lock); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); + memory_region_add_subregion(get_system_memory(), + Q35_HOST_BRIDGE_IOMMU_ADDR, &s->csrmem); /* Create the shared memory regions by all devices */ memory_region_init(&s->mr_nodmar, OBJECT(s), "vtd-nodmar", @@ -4148,15 +4150,12 @@ static void vtd_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_nodmar, VTD_INTERRUPT_ADDR_FIRST, &s->mr_ir, 1); - - sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); /* No corresponding destroy */ s->iotlb = g_hash_table_new_full(vtd_iotlb_hash, vtd_iotlb_equal, g_free, g_free); s->vtd_address_spaces = g_hash_table_new_full(vtd_as_hash, vtd_as_equal, g_free, g_free); vtd_init(s); - sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR); pci_setup_iommu(bus, vtd_host_dma_iommu, dev); /* Pseudo address space under root PCI bus. */ x86ms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC);