From patchwork Mon Jun 26 12:30:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1799900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PWA2nQHq; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QqSBm5scGz20XS for ; Mon, 26 Jun 2023 22:41:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qDlO2-0007fC-H1; Mon, 26 Jun 2023 08:32:06 -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 1qDlMT-0005iA-Cn for qemu-devel@nongnu.org; Mon, 26 Jun 2023 08:30:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qDlMR-0003aG-Bw for qemu-devel@nongnu.org; Mon, 26 Jun 2023 08:30:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687782626; 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: in-reply-to:in-reply-to:references:references; bh=Y/mhZ4QWgJNUg3jo6CnB3dDNtW+V95gDB4rMrHURtvQ=; b=PWA2nQHqAO0QEIPLm20seSTmZlzfipmZWHHh0WIkoMlkeF04K7isBEFoojS3GsZeXY61c8 aG1eU2U8N5obBeTYU3seb83gbtNu5Yzrk9grIE/XyBEM8MjTeHXjF3amT8j5opluMxgIQE cWJXIssIx3BmnpMZIpHbAQOJ5BR928w= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-R4e_EnHsOrGjaCmaOi417g-1; Mon, 26 Jun 2023 08:30:25 -0400 X-MC-Unique: R4e_EnHsOrGjaCmaOi417g-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3128319d532so2450596f8f.2 for ; Mon, 26 Jun 2023 05:30:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687782624; x=1690374624; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Y/mhZ4QWgJNUg3jo6CnB3dDNtW+V95gDB4rMrHURtvQ=; b=D7tYjBX6W7AMBgMwk4ntjakZC7Um1QMS+z3uVwpiitGQJE5mBdwvOUR4EfOZDo8MBw ZCeG9oTOdBKtgZ8OGP+J1N7DI3lq8Tt87N+yEeZACHOsvgRiyn4OFfnbmcL/WsVvzUcp Aor8A5jHwxd3dY3YOx2VPqYQaQnS3216rJzAi/nutmPP9j9Ky8Gpnt5jgZjWRAeVIFN4 wL8sTt6mROIpd2ZUdUDXjMgqmPCv7+1hSc0kh/5GoxIdhsTuqI+aiiZozoCGR35tPXi1 pwMnuoTeCzR3mPkKzC3BMJxzpeNvImU6uTElZg1cmEMl/Hpd/GGNlViT7U7gPPhVNusJ VZ+g== X-Gm-Message-State: AC+VfDy9lesbFiohoZXjvzYVb/CBPeIxlQBGpqgLjg0x4s1eQmmdwVm0 9yXTqSj18ANzXkJT6vh2kk4sAdkQ8krfMBk4RSMPhkaziUL/kbG7ozFUyV3Fzo7fOQ1tk763L6n +9zrtq1IvpQb/9bNhSZdSpTQOV49gyo07+zWzKFeNKG8/C2xJKBF1nCqaEhviea/PHaWS X-Received: by 2002:a05:6000:42:b0:313:e2c4:7bd1 with SMTP id k2-20020a056000004200b00313e2c47bd1mr5649805wrx.42.1687782623974; Mon, 26 Jun 2023 05:30:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TV1EBgns2sFka4Z9o4Hklnhp5jXOiTWmJori+94UHuWt1NGhCKQNiCQ7dz3MQqqZ7zRit2g== X-Received: by 2002:a05:6000:42:b0:313:e2c4:7bd1 with SMTP id k2-20020a056000004200b00313e2c47bd1mr5649787wrx.42.1687782623652; Mon, 26 Jun 2023 05:30:23 -0700 (PDT) Received: from redhat.com ([2.52.156.102]) by smtp.gmail.com with ESMTPSA id u14-20020adfdb8e000000b003112ab916cdsm7357579wri.73.2023.06.26.05.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 05:30:23 -0700 (PDT) Date: Mon, 26 Jun 2023 08:30:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Peter Xu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 51/53] intel_iommu: Fix address space unmap Message-ID: <0dd5bcd98d5a89f833c7d06b28ad92965874bc72.1687782442.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhenzhong Duan During address space unmap, corresponding IOVA tree entries are also removed. But DMAMap is set beyond notifier's scope by 1, so in theory there is possibility to remove a continuous entry above the notifier's scope but falling in adjacent notifier's scope. There is no issue currently as no use cases allocate notifiers continuously, but let's be robust. Signed-off-by: Zhenzhong Duan Reviewed-by: Peter Xu Message-Id: <20230615032626.314476-4-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index f046f85913..dcc334060c 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3791,7 +3791,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) n->start, size); map.iova = n->start; - map.size = size; + map.size = size - 1; /* Inclusive */ iova_tree_remove(as->iova_tree, map); }