Received: by 2002:a19:ad09:0:0:0:0:0 with SMTP id t9csp816604lfc; Wed, 26 Aug 2020 07:41:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjBD1515xr9aN7Wcr2TpTbBaUtZ4Ina3uOCAmmM9j1pGeLvdQ9JEW3nFpNLSY2u2ARcuKO X-Received: by 2002:a25:b83:: with SMTP id 125mr22857577ybl.173.1598452917731; Wed, 26 Aug 2020 07:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452917; cv=none; d=google.com; s=arc-20160816; b=dRI4+4f2AL76zCwylKDQ1saKondFsElVscdTSp6rWPwA8Oim/JbJYBkkAQt/rVM7bq u6KAEyP5oV7sdej9diKVMdBvfNKwkjKckd7aYz+0xWQg7p5DsZO/+qxgyLB2tvfKrgU6 HeW4TKvJv3UkctYTPpVJSfdAxjT5XpbsuJU3ntuy1a6Zpa+Fq8Jp0cIjC03mGT99chDh Gg5oGPctFELlo2PtXxl47J/uMNBahZlH9YG5QybkgBL0ZbUfwWnhzYP/MQ7jw6G0HYYW xlEJVJLDaxg6WAdUx+EN9o9PbgoSkrnP4M48Hwv7oEAwAEVXnrYeSkkpVd3sbhT+ihCw FZww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=EGQyeizi6c03BkZMJryn0YpKUk6Yr5XbAqCcSwva5kE=; b=uU23u+yG604CZeKkApFBMBjvq5XFsL2HTjs7spo52wDtf4Mm2aXrpg955Cj2/jAwlG JkQOz/M6Nm6qmc6eb64MQI8Q14ABpimO2fQ9QK1+ZtFsZ+aE/oAQwx/fWJmI7/SJwHVt fUHqNMbskjzx8ODJ8SnoIDTyuhdyGf7iGQyOk+ARH4iuIagJ7+go21gbHb1ywEN44Czs 6M9zieCleEa5Ik7Rk/uS6ultKau6lVO3BkIMVy65xrbeXu3Gs2q6WNxVpBq8T/zgqx0E iKCnWhvlJ3pmUH+uFy3Xy59ZpR3D+bsy+8pEODp5krnTzkV6BkYHKlzlFzmJT/nHx+Zx uRLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b="Efw/8vi0"; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d82si2510902ybd.421.2020.08.26.07.41.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Aug 2020 07:41:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b="Efw/8vi0"; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:36548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAwcf-0005bn-1l for alex.bennee@linaro.org; Wed, 26 Aug 2020 10:41:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAwat-00028i-GH for qemu-arm@nongnu.org; Wed, 26 Aug 2020 10:40:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kAwar-0006VA-Kv for qemu-arm@nongnu.org; Wed, 26 Aug 2020 10:40:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598452804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EGQyeizi6c03BkZMJryn0YpKUk6Yr5XbAqCcSwva5kE=; b=Efw/8vi0grKZt8SaLF2r/P0KUKa9VsSeHPNsnOCe1QwC/lZknBYmtXZAwZA/P8/UIRZkoQ k3MPSzQiUlh9CYEygwUYmVw2POrtPJW4SKUd4awv6yZYSSqCJ11ub0HvmqRASAEpFEaqOD Qo1+K3Ami4G8LGrKkKqdBllmcNEEgYs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-8T_E3lobOGGAeIU2wMT3vw-1; Wed, 26 Aug 2020 10:40:01 -0400 X-MC-Unique: 8T_E3lobOGGAeIU2wMT3vw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD4B218BE165; Wed, 26 Aug 2020 14:39:57 +0000 (UTC) Received: from eperezma.remote.csb (ovpn-115-59.ams2.redhat.com [10.36.115.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7577C7E46F; Wed, 26 Aug 2020 14:39:04 +0000 (UTC) From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org, Peter Xu Subject: [RFC v6 11/13] memory: Add IOMMU_DEVIOTLB_UNMAP IOMMUTLBNotificationType Date: Wed, 26 Aug 2020 16:36:49 +0200 Message-Id: <20200826143651.7915-12-eperezma@redhat.com> In-Reply-To: <20200826143651.7915-1-eperezma@redhat.com> References: <20200625191651.5817-1-eperezma@redhat.com> <20200826143651.7915-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eperezma@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=63.128.21.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/26 06:53:10 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.959, 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Aleksandar Rikalo , Yan Zhao , Eduardo Habkost , Juan Quintela , Jason Wang , "Michael S. Tsirkin" , Eric Auger , qemu-arm@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Avi Kivity , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: 6g2v6JIKKPyk Adapt intel and vhost to use this new notification type Signed-off-by: Eugenio Pérez --- hw/i386/intel_iommu.c | 2 +- hw/virtio/vhost.c | 2 +- include/exec/memory.h | 9 ++++++--- softmmu/memory.c | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 0b3399874f..ddb828da1f 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2467,7 +2467,7 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s, entry.iova = addr; entry.perm = IOMMU_NONE; entry.translated_addr = 0; - entry.type = IOMMU_IOTLB_UNMAP; + entry.type = IOMMU_DEVIOTLB_UNMAP; memory_region_notify_iommu(&vtd_dev_as->iommu, 0, entry); done: diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1a1384e7a6..6ca168b47e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -729,7 +729,7 @@ static void vhost_iommu_region_add(MemoryListener *listener, iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr, MEMTXATTRS_UNSPECIFIED); iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify, - IOMMU_NOTIFIER_UNMAP, + IOMMU_NOTIFIER_DEVIOTLB, section->offset_within_region, int128_get64(end), iommu_idx); diff --git a/include/exec/memory.h b/include/exec/memory.h index f6d91c54aa..477c3af24c 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -60,9 +60,10 @@ struct ReservedRegion { typedef struct IOMMUTLBEntry IOMMUTLBEntry; typedef enum { - IOMMU_IOTLB_NONE = 0, - IOMMU_IOTLB_UNMAP = 1, - IOMMU_IOTLB_MAP = 2, + IOMMU_IOTLB_NONE = 0, + IOMMU_IOTLB_UNMAP = 1, + IOMMU_IOTLB_MAP = 2, + IOMMU_DEVIOTLB_UNMAP = 3, } IOMMUTLBNotificationType; /* See address_space_translate: bit 0 is read, bit 1 is write. */ @@ -94,6 +95,8 @@ typedef enum { IOMMU_NOTIFIER_UNMAP = 0x1, /* Notify entry changes (newly created entries) */ IOMMU_NOTIFIER_MAP = 0x2, + /* Notify changes on device IOTLB entries */ + IOMMU_NOTIFIER_DEVIOTLB = 0x04, } IOMMUNotifierFlag; #define IOMMU_NOTIFIER_ALL (IOMMU_NOTIFIER_MAP | IOMMU_NOTIFIER_UNMAP) diff --git a/softmmu/memory.c b/softmmu/memory.c index 3e68442ca6..4ed63f4d0d 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1892,7 +1892,8 @@ void memory_region_unregister_iommu_notifier(MemoryRegion *mr, static IOMMUNotifierFlag notifier_type_iommu(const IOMMUNotifier *notifier) { - return notifier->notifier_flags & IOMMU_NOTIFIER_ALL; + return notifier->notifier_flags & + (IOMMU_NOTIFIER_ALL | IOMMU_NOTIFIER_DEVIOTLB); } static bool memory_region_notify(const IOMMUNotifier *notifier, @@ -1903,6 +1904,8 @@ static bool memory_region_notify(const IOMMUNotifier *notifier, return notifier_type_iommu(notifier) == IOMMU_NOTIFIER_MAP; case IOMMU_IOTLB_UNMAP: return notifier_type_iommu(notifier) == IOMMU_NOTIFIER_UNMAP; + case IOMMU_DEVIOTLB_UNMAP: + return notifier_type_iommu(notifier) == IOMMU_NOTIFIER_DEVIOTLB; default: return false; }; -- 2.18.1