From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EFC6ECAAD5 for ; Fri, 2 Sep 2022 20:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbiIBUf5 (ORCPT ); Fri, 2 Sep 2022 16:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbiIBUfz (ORCPT ); Fri, 2 Sep 2022 16:35:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 341F8F63E5 for ; Fri, 2 Sep 2022 13:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662150952; 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=fn+Zoib7z+3jWmLDklpcVUHy37Y7jPpJPmAY6A3wSS4=; b=EUBE6q1XBNfPmHpqV9iK4CAr3YVmw2q8Hvb16kUSWbBhctMGRmUb5xfMsCA0n0kMdeJtVj mmpJ9FSK275fcJzdIiASnv1ZuDFrWlyaR5uM58tiL5TJT+h4ERLGk4RtmRQE7nsUsgpbqY nH+fj6xbj5wL+309RbRqfY/U9a0lII8= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-395-m3gmaiD0M36f4ugvP4_h5g-1; Fri, 02 Sep 2022 16:35:51 -0400 X-MC-Unique: m3gmaiD0M36f4ugvP4_h5g-1 Received: by mail-qk1-f200.google.com with SMTP id br15-20020a05620a460f00b006bc58c26501so2864303qkb.0 for ; Fri, 02 Sep 2022 13:35:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=fn+Zoib7z+3jWmLDklpcVUHy37Y7jPpJPmAY6A3wSS4=; b=4F8gnmw92VFtvj1xKo1m6lA7vx0XXtUxj39LbhbMJCNyZfHdOiQWhcndYe2jHIH/MP c28xqArA9T3Zkzzb3GoHAI3EZyBdJXrmRwwXiUukKQrmcvZCXtBQ8T0Ed5pPFIadNw8W I59jC0bqsXSbn87lNRKGvg5yc5HVpL4yqhuWbZNsmQLyd42TdhWksa0K0bUBZhojlii0 wbJtFEtbegr4xGr/GAcx9/VsjUcih6lmbO6RrzDM/XxJH3BYPb5QVdHYgUpw9BoFm7fb Zws4RpbQDSiXIBv+rfSIMlt7otazJArbyQZveU2B8UyqoaADBS9CB5Mm7kFe6ihKU4G8 6Cmw== X-Gm-Message-State: ACgBeo0XiSJ+jhjeiVACskauXZHkriwLz10AykuJ9pXFFezjCF5JVy3N mC9ZeuTsgPw1uWREwfhaj/eQYJnksAJ6T70WMXhP5pIYZhFD8vpvocGART7XT9aAC1pOFHFzcLF y+ZpDE4dINu9OSov9lbejRb7Y X-Received: by 2002:a05:6214:cca:b0:499:216a:bb53 with SMTP id 10-20020a0562140cca00b00499216abb53mr12361609qvx.98.1662150950663; Fri, 02 Sep 2022 13:35:50 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kIdR84rwbeR6TPg15NwPgQnYmK4+injhS/K8qL1Ci4QeM6ILUyA6WUnfYAugNgzwk5mCQRQ== X-Received: by 2002:a05:6214:cca:b0:499:216a:bb53 with SMTP id 10-20020a0562140cca00b00499216abb53mr12361578qvx.98.1662150950432; Fri, 02 Sep 2022 13:35:50 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id i7-20020a05620a404700b006b5cc25535fsm2262614qko.99.2022.09.02.13.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:35:50 -0700 (PDT) Date: Fri, 2 Sep 2022 16:35:47 -0400 From: Peter Xu To: Alistair Popple Cc: linux-mm@kvack.org, akpm@linux-foundation.org, Nadav Amit , huang ying , LKML , "Sierra Guiza, Alejandro (Alex)" , Felix Kuehling , Jason Gunthorpe , John Hubbard , David Hildenbrand , Ralph Campbell , Matthew Wilcox , Karol Herbst , Lyude Paul , Ben Skeggs , Logan Gunthorpe , paulus@ozlabs.org, linuxppc-dev@lists.ozlabs.org, "Huang, Ying" , stable@vger.kernel.org Subject: Re: [PATCH v4 1/4] mm/migrate_device.c: Flush TLB while holding PTL Message-ID: References: <9f801e9d8d830408f2ca27821f606e09aa856899.1662078528.git-series.apopple@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9f801e9d8d830408f2ca27821f606e09aa856899.1662078528.git-series.apopple@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 10:35:51AM +1000, Alistair Popple wrote: > When clearing a PTE the TLB should be flushed whilst still holding the > PTL to avoid a potential race with madvise/munmap/etc. For example > consider the following sequence: > > CPU0 CPU1 > ---- ---- > > migrate_vma_collect_pmd() > pte_unmap_unlock() > madvise(MADV_DONTNEED) > -> zap_pte_range() > pte_offset_map_lock() > [ PTE not present, TLB not flushed ] > pte_unmap_unlock() > [ page is still accessible via stale TLB ] > flush_tlb_range() > > In this case the page may still be accessed via the stale TLB entry > after madvise returns. Fix this by flushing the TLB while holding the > PTL. > > Signed-off-by: Alistair Popple > Reported-by: Nadav Amit > Reviewed-by: "Huang, Ying" > Fixes: 8c3328f1f36a ("mm/migrate: migrate_vma() unmap page from vma while collecting pages") > Cc: stable@vger.kernel.org Acked-by: Peter Xu -- Peter Xu