From nobody Thu Nov 28 08:37:51 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1693814960; cv=none; d=zohomail.com; s=zohoarc; b=mraN+Mm6capp2NlBnRDskMNQWPSb/b+95KLRVtqJ9ACtvA0FZx8Ky079cBdY9q6ZZp47tsCSBkV0PrxHcVkyD4pXOPxHEWDQwKeKtf4+zi10eYV4bcum2u+bXXqE+vvf4JpS+2NT0ZNxqrBTe0lS8wc6D+YibdFDBeWJqeB6SwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693814960; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+oWpFb2g/83VBCkX6ZRLRafCOFZTt914xW2uQS8bpf0=; b=gSE4xmNIfRhOxyMWmPd2uAfJ0mItTR0hgeZHAvwLIX1cXtEyhQ5vFgWiJZ0keGQrMf8zD4RoUCA3CgYG2Rn75SG3CdrXHVYInzM9bHzq+XNAEhOP7Uj3oUMr74F03MPRpwugzbnoJEZoeVgAhbRij0Wl8sIftlQr1WLXyp+ENqs= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693814960391176.3751703735312; Mon, 4 Sep 2023 01:09:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qd4c5-0002MR-La; Mon, 04 Sep 2023 04:07:13 -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 1qd4c0-0002Av-BK for qemu-devel@nongnu.org; Mon, 04 Sep 2023 04:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qd4bu-0006XF-JI for qemu-devel@nongnu.org; Mon, 04 Sep 2023 04:07:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-153-lWseRNySNoaqT0zV_E8IzQ-1; Mon, 04 Sep 2023 04:05:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C542F925FD4; Mon, 4 Sep 2023 08:05:26 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.192.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F2F740ED77D; Mon, 4 Sep 2023 08:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693814821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+oWpFb2g/83VBCkX6ZRLRafCOFZTt914xW2uQS8bpf0=; b=VMsHE4w8uesobl4JTVm5uzhqrXh/KbM6bLRCMsWx9TaT1VIukGwhuGHqS4lDd1LM03FDYt KJaFFdv0c2AQM7ApIJozS59hdVQhc53MZ1x3E0qUGw8aqLmb75oFzMCTNiwGScUXWFmv44 APHYzFcjIjJw9PlAiVqCs7C2iKcMF7w= X-MC-Unique: lWseRNySNoaqT0zV_E8IzQ-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, alex.williamson@redhat.com, clg@redhat.com, jean-philippe@linaro.org, mst@redhat.com, pbonzini@redhat.com Cc: peter.maydell@linaro.org, peterx@redhat.com, david@redhat.com, philmd@linaro.org Subject: [PATCH 10/13] virtio-iommu: Consolidate host reserved regions and property set ones Date: Mon, 4 Sep 2023 10:03:53 +0200 Message-ID: <20230904080451.424731-11-eric.auger@redhat.com> In-Reply-To: <20230904080451.424731-1-eric.auger@redhat.com> References: <20230904080451.424731-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1693814961112100001 Content-Type: text/plain; charset="utf-8" Up to now we were exposing to the RESV_MEM probe requests the reserved memory regions set though the reserved-regions array property. Combine those with the host reserved memory regions if any. Those latter are tagged as RESERVED. We don't have more information about them besides then cannot be mapped. Reserved regions set by property have higher priority. Signed-off-by: Eric Auger --- hw/virtio/virtio-iommu.c | 17 ++++++++++++++++- hw/virtio/trace-events | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 02f1a59d57..d260235078 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -21,6 +21,7 @@ #include "qemu/log.h" #include "qemu/iov.h" #include "qemu/range.h" +#include "qemu/reserved-region.h" #include "exec/target_page.h" #include "hw/qdev-properties.h" #include "hw/virtio/virtio.h" @@ -630,11 +631,25 @@ static int consolidate_resv_regions(IOMMUDevice *sdev) VirtIOIOMMU *s =3D sdev->viommu; int i; =20 + /* First add host reserved regions if any, all tagged as RESERVED */ + for (i =3D 0; i < sdev->nr_host_resv_regions; i++) { + ReservedRegion *reg =3D g_new0(ReservedRegion, 1); + reg->range =3D sdev->host_resv_regions[i]; + reg->type =3D VIRTIO_IOMMU_RESV_MEM_T_RESERVED; + sdev->resv_regions =3D resv_region_list_insert(sdev->resv_regions,= reg); + trace_virtio_iommu_host_resv_regions(sdev->iommu_mr.parent_obj.nam= e, i, + range_lob(®->range), + range_upb(®->range)); + } + /* + * then add higher priority reserved regions set through properties by= the + * machine + */ for (i =3D 0; i < s->nr_prop_resv_regions; i++) { ReservedRegion *reg =3D g_new0(ReservedRegion, 1); =20 *reg =3D s->prop_resv_regions[i]; - sdev->resv_regions =3D g_list_append(sdev->resv_regions, reg); + sdev->resv_regions =3D resv_region_list_insert(sdev->resv_regions,= reg); } return 0; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 7109cf1a3b..796574b0f3 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -134,6 +134,7 @@ virtio_iommu_notify_flag_add(const char *name) "add not= ifier to mr %s" virtio_iommu_notify_flag_del(const char *name) "del notifier from mr %s" virtio_iommu_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, b= ool on) "Device %02x:%02x.%x switching address space (iommu enabled=3D%d)" virtio_iommu_freeze_granule(uint64_t page_size_mask) "granule set to 0x%"P= RIx64 +virtio_iommu_host_resv_regions(const char *name, uint32_t index, uint64_t = lob, uint64_t upb) "mr=3D%s host-resv-reg[%d] =3D [0x%"PRIx64",0x%"PRIx64"]" =20 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=3D%" PRIu16 --=20 2.41.0