From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1275645AE1 for ; Tue, 8 Oct 2024 11:04:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 024BA406B6; Tue, 8 Oct 2024 11:04:45 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 587FA4021E for ; Tue, 8 Oct 2024 11:04:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728378282; 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=UCYd2uJQMCVswJMSHaFTnp7u+ODCu2sFR8ddd1iNzoQ=; b=HGIhkR1gsKGhMIqAaklqDknud5HQFTzCKoRUdYwpta3NpRNoUGvbLV1hnqk0zptBrVjFF+ fzzHhzvOiuRBRrKRLZefRywSHABco7RbMTO/iDyOY3j4NJQF/U7qMut02bgJqWI20Q1IMZ 5at1hfWu+RJCZBwqi8tLzFUDDLyjpow= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-lJffZnsGOwma6mGGBs-uBg-1; Tue, 08 Oct 2024 05:04:41 -0400 X-MC-Unique: lJffZnsGOwma6mGGBs-uBg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5398b9176dcso4643533e87.2 for ; Tue, 08 Oct 2024 02:04:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728378279; x=1728983079; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UCYd2uJQMCVswJMSHaFTnp7u+ODCu2sFR8ddd1iNzoQ=; b=ZWvvymYIaaflJpl1SNZXfMg23Q+W4at3PlapuSyCBV8ZXO6rMVoMd0+lZu+JwN5w+S b0lTCEf6BX+GcUiztK5dsru2gKuWdPjnv3XZ6Wq5NLF7lOL76fzK6Gxk7KRwheNKBUsP Q+wN5ystbnRH/BbhjJq17c/2V/vclvbVBPKLone3FyU4Tws5TxBHsHlQpm7Lr1SUXUE5 Z3fUTY0yse16wKt0MPzeCSWx0Xj5gmNSDLa3ojmMraNoCNocWRdxY4Z8omDXbq70ApXb jp5oAIdEYWrC0P4vml2Bj+wnuvISzfM5LNlRFwkpv/K04dz7E6H7IgDphWHOIAz47i+D 0KGQ== X-Forwarded-Encrypted: i=1; AJvYcCWHj77Mxqeh7SOlkYcBRk9Tnw465v3QjOdWxaI742JFjT+ENd2QkRWi9e4LQF4Om4/zWGJglqk=@dpdk.org X-Gm-Message-State: AOJu0YwJA5/LyH82AMi7l7KRIxno2QelUDNujBNRPKnb1ZqPI/YLOc+D PYrd6LwvNWSzRQO0FS8wFCH21HNgsOrWRtaEIgazc0rrweDaYGHZJ6X5xYxlo1894Q911Ayw70D C2RseH/2+QF1eZwbLONDjHoaon6evY6nVoH3XDHZJ/K2x/6x0wfZf7eryZxSOMdwYf5R0gRJZNF UvdxLZUV2JjiGTo1Xp2Kk= X-Received: by 2002:a05:6512:2395:b0:539:9155:e8bf with SMTP id 2adb3069b0e04-539ab84a5b5mr6814279e87.12.1728378279216; Tue, 08 Oct 2024 02:04:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbloupgJ2MPkR5jAgFtl+J28g/dScYL7tuP2IKkj35GUAunn+75DbyBCOLeQ/Iw5fZurDQScPpOWJX+KHVpGM= X-Received: by 2002:a05:6512:2395:b0:539:9155:e8bf with SMTP id 2adb3069b0e04-539ab84a5b5mr6814257e87.12.1728378278828; Tue, 08 Oct 2024 02:04:38 -0700 (PDT) MIME-Version: 1.0 References: <1725974338-56108-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: <1725974338-56108-1-git-send-email-wangyunjian@huawei.com> From: David Marchand Date: Tue, 8 Oct 2024 11:04:27 +0200 Message-ID: Subject: Re: [PATCH v2] vfio: check iova if already mapped before do map To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Yunjian Wang , xiawei40@huawei.com, luyicai@huawei.com, Lipei Liang , stable@dpdk.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hello Anatoly, On Tue, Sep 10, 2024 at 3:19=E2=80=AFPM Yunjian Wang wrote: > > From: Lipei Liang > > When mapping two adjacent memory areas A and B, the current implementatio= n > merges them into one segment, known as area C. However, if areas A and B > are mapped again, there will be separate entries for A, C, and B in the > memory maps, as C divides A and B. This means that if A and B are mapped > twice, there will be two map entries for each. When partially unmapping > A and B, the entry for C will remain in the memory maps. If we then map > area D, which has a different size than A but falls within area C, the > find_user_mem_maps function may mistakenly identify C when attempting to > unmap D. This is because A and C have different chunk sizes, resulting in > a failure to unmap D. > > To fix this issue, we can add a check for the iova before performing the > dma mapping. If the iova is already mapped, we should not perform the vfi= o > mapping. If the iova overlaps with an entry in the memory maps, we should > return an error code of -1 with the ENOTSUP error. However, if the iova > does not overlap with any entry in the memory maps, we can proceed with > the dma mapping. > > Fixes: 56259f7fc010 ("vfio: allow partially unmapping adjacent memory") > Cc: stable@dpdk.org > > Signed-off-by: Lipei Liang Review, please. --=20 David Marchand