Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3972613pxk; Tue, 8 Sep 2020 07:31:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNhwwHa1EnzpNGZ4nE/bSgGYzPFfJq2ZXSeL+9Yj7aI9ucg2ykcwKzo1U8GxDbwfx9HBxY X-Received: by 2002:a17:906:cec9:: with SMTP id si9mr25657487ejb.351.1599575514924; Tue, 08 Sep 2020 07:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599575514; cv=none; d=google.com; s=arc-20160816; b=ATk7IBlDNh178KwGLgmFPWhoaLYyyb1R4WmD0rryMTqaFM0c0tP/WveRBiwuzweuT7 67KUNG014rVZZcuOkITQsPwFpZCvqLPyPTx812tql+7W2872Avy9GxSmDe1Zes+z33vx ndIET3REaig3wMw0L6Bqi89WXZNvSSwb+pZZdKXJ6pma36trQyhmKtdiWT1tXkzdcqp2 liYolGYkiLEU1GjBltf+gU6/YbZeIgjNYoLDPfrvqhgB8qlXGhblQziAijuQjcgmGkyx f2yYLz7P9Jb5XWCC2VHZJn7YPKYjBhQmp9NDUYhug325IMXfboJU6ojpEKZMc1aIZ51J 8rOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=MRNHF44CAYOkJjhPrSraBrOXUax8UfRKQ7Met8605TY=; b=pxa6PU+NHvOMlZ88gDfwm82ouco1saZ/yfyzaQkDlqrGektcfQbVsseOGBwaa25lo1 LFUlsQuMV/Xy4VfRVvIFCpViqioeh9eyCkjb4KMxLfAflmkHqJhGVAyHznCrn2wnrhml gmToAgsSTeWnHvQHGBbKaZhiuSWMHdYnz38RBzF4Yl4Ybkfh7lgNlhcLIlaldNMa9EdF A38lZaxTijcMdp6GDBBeUBPiKrS5PikikA9nm4q3rKXuWrUcHAm1d7q94CU5xyGb6oTM rUSkCrYlBkguDMjXBrQcgEf39AXvtYcRRU5rd86RTQN2jFhL0zYAAgkPkreBGd15WT9S eDqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si1115377eju.615.2020.09.08.07.31.31; Tue, 08 Sep 2020 07:31:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729961AbgIHO3g (ORCPT + 99 others); Tue, 8 Sep 2020 10:29:36 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:35692 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729725AbgIHOY4 (ORCPT ); Tue, 8 Sep 2020 10:24:56 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4Bm4Vr1mvXz9tysg; Tue, 8 Sep 2020 14:40:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id cIMhaNVcmlrN; Tue, 8 Sep 2020 14:40:20 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4Bm4Vr0fBLz9tysZ; Tue, 8 Sep 2020 14:40:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5BBAE8B7C1; Tue, 8 Sep 2020 14:40:21 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id xwRqAZ7QC05H; Tue, 8 Sep 2020 14:40:21 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B7AA88B7BE; Tue, 8 Sep 2020 14:40:18 +0200 (CEST) Subject: Re: [RFC PATCH v2 1/3] mm/gup: fix gup_fast with dynamic page table folding To: Christian Borntraeger , Gerald Schaefer , Jason Gunthorpe , John Hubbard Cc: Peter Zijlstra , Dave Hansen , linux-mm , Paul Mackerras , linux-sparc , Alexander Gordeev , Claudio Imbrenda , Will Deacon , linux-arch , linux-s390 , Vasily Gorbik , Richard Weinberger , linux-x86 , Russell King , Ingo Molnar , Catalin Marinas , Andrey Ryabinin , Heiko Carstens , Arnd Bergmann , Jeff Dike , linux-um , Borislav Petkov , Andy Lutomirski , Thomas Gleixner , linux-arm , linux-power , LKML , Andrew Morton , Linus Torvalds , Mike Rapoport References: <20200907180058.64880-1-gerald.schaefer@linux.ibm.com> <20200907180058.64880-2-gerald.schaefer@linux.ibm.com> <82fbe8f9-f199-5fc2-4168-eb43ad0b0346@csgroup.eu> <70a3dcb5-5ed1-6efa-6158-d0573d6927da@de.ibm.com> From: Christophe Leroy Message-ID: <96b80926-cf5b-1afa-9b7a-949a2188e61f@csgroup.eu> Date: Tue, 8 Sep 2020 14:40:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <70a3dcb5-5ed1-6efa-6158-d0573d6927da@de.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 08/09/2020 à 14:09, Christian Borntraeger a écrit : > > > On 08.09.20 07:06, Christophe Leroy wrote: >> >> >> Le 07/09/2020 à 20:00, Gerald Schaefer a écrit : >>> From: Alexander Gordeev >>> >>> Commit 1a42010cdc26 ("s390/mm: convert to the generic get_user_pages_fast >>> code") introduced a subtle but severe bug on s390 with gup_fast, due to >>> dynamic page table folding. >>> >>> The question "What would it require for the generic code to work for s390" >>> has already been discussed here >>> https://lkml.kernel.org/r/20190418100218.0a4afd51@mschwideX1 >>> and ended with a promising approach here >>> https://lkml.kernel.org/r/20190419153307.4f2911b5@mschwideX1 >>> which in the end unfortunately didn't quite work completely. >>> >>> We tried to mimic static level folding by changing pgd_offset to always >>> calculate top level page table offset, and do nothing in folded pXd_offset. >>> What has been overlooked is that PxD_SIZE/MASK and thus pXd_addr_end do >>> not reflect this dynamic behaviour, and still act like static 5-level >>> page tables. >>> >> >> [...] >> >>> >>> Fix this by introducing new pXd_addr_end_folded helpers, which take an >>> additional pXd entry value parameter, that can be used on s390 >>> to determine the correct page table level and return corresponding >>> end / boundary. With that, the pointer iteration will always >>> happen in gup_pgd_range for s390. No change for other architectures >>> introduced. >> >> Not sure pXd_addr_end_folded() is the best understandable name, allthough I don't have any alternative suggestion at the moment. >> Maybe could be something like pXd_addr_end_fixup() as it will disappear in the next patch, or pXd_addr_end_gup() ? >> >> Also, if it happens to be acceptable to get patch 2 in stable, I think you should switch patch 1 and patch 2 to avoid the step through pXd_addr_end_folded() > > given that this fixes a data corruption issue, wouldnt it be the best to go forward > with this patch ASAP and then handle the other patches on top with all the time that > we need? I have no strong opinion on this, but I feel rather tricky to have to change generic part of GUP to use a new fonction then revert that change in the following patch, just because you want the first patch in stable and not the second one. Regardless, I was wondering, why do we need a reference to the pXd at all when calling pXd_addr_end() ? Couldn't S390 retrieve the pXd by using the pXd_offset() dance with the passed addr ? Christophe