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 X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A280C43463 for ; Fri, 18 Sep 2020 01:53:58 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29F8520872 for ; Fri, 18 Sep 2020 01:53:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="0n1kgcoB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29F8520872 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7D2BD148ED497; Thu, 17 Sep 2020 18:53:57 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::642; helo=mail-ej1-x642.google.com; envelope-from=dan.j.williams@intel.com; receiver= Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D7E9A13568225 for ; Thu, 17 Sep 2020 18:53:55 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id j11so6001241ejk.0 for ; Thu, 17 Sep 2020 18:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GC2uboF6NMZuC9/ZByaXp1KFBIoZjwLF73X8h59tMWs=; b=0n1kgcoBcO/MRG9AAQs28nlby+4uxxdWNINGwW2Okw2teha+5tUcRRM1S51DHvxjbe R8Cq+ItKHDbs5yC2r01vwPHgrzycwMkOBbRrsESuJbMdrF8xDKW+v6w7S1lQVw6CX4P9 M9/7dgueosqWOddYA7f6ndQv2GVxNDfUmiVHE9QYX1uxi2bJty6xyL5m9lsyI5Tr0Ip5 vxRKjnhcKMG6MwVZlo/19T+6Z8bhvWhZgkjv7bAiYeodgKLsWm9r4VxuokZiIFVcibHq AM6HBNJxSr8ACewbKnPZO1qmqRKpaxVJT1GKpdKqb7WgNxAmeZKt4bXcW8QyoirezqiZ fWug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GC2uboF6NMZuC9/ZByaXp1KFBIoZjwLF73X8h59tMWs=; b=uVH859xwSsd+AAzOxFfhpzD8uT6hnLu91Rj8MeW/5RlC2M79hcsKz7NXKVGqqNwIvE RULyg8Ljy8Es5awzir7K+oXXcGZvstyWlJA+TXiNzLh8VdxQk0xN95UZEmlj7KAQIRLH 3R1twbCB11aYX2T+4VsY7wBwxux542fNwQlHPxZlyF8lRP3dMFahWZEZzs/1/4/OFkBu FN2rsf5QEhWp0dMEO7U1ET65UyWjnrV46J8+WlNe3eoHnxtsIae89cC7RjpAKnO/gjzL AIng8LlISbfQQ3wT0sDa+gWn1SJfuIeFwrRRymwHEtgeJ6kpWyPzMcbQwNvhoRb4+dBC HDAA== X-Gm-Message-State: AOAM533S49kjPGVQsX7YGriZSgKnPQYpHuawgopHPCAAWR8ZWTsCRMpR 8lZaKfBs8IoqyTls3i4wAoO4NCr3LR6rFW4RQLCK5g== X-Google-Smtp-Source: ABdhPJy7DFdMdaS97xMoxRqS6WmXgsRrt5dbwajDW1OzguEa9uaz85Fv52jSvKPNcbb4yTlLVhfIEfhmycxKE179n6U= X-Received: by 2002:a17:906:8143:: with SMTP id z3mr33115785ejw.323.1600394032604; Thu, 17 Sep 2020 18:53:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dan Williams Date: Thu, 17 Sep 2020 18:53:41 -0700 Message-ID: Subject: Re: [PATCH] pmem: fix __copy_user_flushcache To: Mikulas Patocka Message-ID-Hash: 7S2PZH5CIHFNKWBVYUCMOX7IVCIGX3I3 X-Message-ID-Hash: 7S2PZH5CIHFNKWBVYUCMOX7IVCIGX3I3 X-MailFrom: dan.j.williams@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Linus Torvalds , Alexander Viro , Andrew Morton , Matthew Wilcox , Jan Kara , Eric Sandeen , Dave Chinner , "Tadakamadla, Rajesh (DCIG/CDI/HPS Perf)" , Linux Kernel Mailing List , linux-fsdevel , linux-nvdimm X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Wed, Sep 16, 2020 at 11:57 AM Mikulas Patocka wrote: > > > > On Wed, 16 Sep 2020, Dan Williams wrote: > > > On Wed, Sep 16, 2020 at 10:24 AM Mikulas Patocka wrote: > > > > > > > > > > > > On Wed, 16 Sep 2020, Dan Williams wrote: > > > > > > > On Wed, Sep 16, 2020 at 3:57 AM Mikulas Patocka wrote: > > > > > > > > > > > > > > > > > > > > I'm submitting this patch that adds the required exports (so that we could > > > > > use __copy_from_user_flushcache on x86, arm64 and powerpc). Please, queue > > > > > it for the next merge window. > > > > > > > > Why? This should go with the first user, and it's not clear that it > > > > needs to be relative to the current dax_operations export scheme. > > > > > > Before nvfs gets included in the kernel, I need to distribute it as a > > > module. So, it would make my maintenance easier. But if you don't want to > > > export it now, no problem, I can just copy __copy_user_flushcache from the > > > kernel to the module. > > > > That sounds a better plan than exporting symbols with no in-kernel consumer. > > BTW, this function is buggy. Here I'm submitting the patch. > > > > From: Mikulas Patocka > > If we copy less than 8 bytes and if the destination crosses a cache line, > __copy_user_flushcache would invalidate only the first cache line. This > patch makes it invalidate the second cache line as well. Good catch. > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org > > --- > arch/x86/lib/usercopy_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/arch/x86/lib/usercopy_64.c > =================================================================== > --- linux-2.6.orig/arch/x86/lib/usercopy_64.c 2020-09-05 10:01:27.000000000 +0200 > +++ linux-2.6/arch/x86/lib/usercopy_64.c 2020-09-16 20:48:31.000000000 +0200 > @@ -120,7 +120,7 @@ long __copy_user_flushcache(void *dst, c > */ > if (size < 8) { > if (!IS_ALIGNED(dest, 4) || size != 4) > - clean_cache_range(dst, 1); > + clean_cache_range(dst, size); > } else { > if (!IS_ALIGNED(dest, 8)) { > dest = ALIGN(dest, boot_cpu_data.x86_clflush_size); > You can add: Fixes: 0aed55af8834 ("x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations") Reviewed-by: Dan Williams _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org 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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DEFEC43464 for ; Fri, 18 Sep 2020 01:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1008520872 for ; Fri, 18 Sep 2020 01:53:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=intel-com.20150623.gappssmtp.com header.i=@intel-com.20150623.gappssmtp.com header.b="0n1kgcoB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726218AbgIRBxy (ORCPT ); Thu, 17 Sep 2020 21:53:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgIRBxy (ORCPT ); Thu, 17 Sep 2020 21:53:54 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 177E1C061756 for ; Thu, 17 Sep 2020 18:53:54 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id e23so5947161eja.3 for ; Thu, 17 Sep 2020 18:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GC2uboF6NMZuC9/ZByaXp1KFBIoZjwLF73X8h59tMWs=; b=0n1kgcoBcO/MRG9AAQs28nlby+4uxxdWNINGwW2Okw2teha+5tUcRRM1S51DHvxjbe R8Cq+ItKHDbs5yC2r01vwPHgrzycwMkOBbRrsESuJbMdrF8xDKW+v6w7S1lQVw6CX4P9 M9/7dgueosqWOddYA7f6ndQv2GVxNDfUmiVHE9QYX1uxi2bJty6xyL5m9lsyI5Tr0Ip5 vxRKjnhcKMG6MwVZlo/19T+6Z8bhvWhZgkjv7bAiYeodgKLsWm9r4VxuokZiIFVcibHq AM6HBNJxSr8ACewbKnPZO1qmqRKpaxVJT1GKpdKqb7WgNxAmeZKt4bXcW8QyoirezqiZ fWug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GC2uboF6NMZuC9/ZByaXp1KFBIoZjwLF73X8h59tMWs=; b=iYLeN8GDAiMuHtBokwiogo7YUalpPOogPZiHqkqajHy9+b5orJ2xja9BJ5JY9WdjEz ceLB2j6V7F8Ww0vPEFjkkDKGfCnrFs48b3J/sT8dXYNHpyuS86p0nX0gRb+kOFXVYX42 Hyvzcz0i1ZFp01F+MbAaNwx84QYNOrHLcz+x/2rZC31JuRIjj3zMG3Ra9F6D8T+MACad dCc2L0/dOfmKPSvznfkDpvUwj4UR3mJTT/sGtUdgxLcioCfOqMLTaA2zIFe/VjV3gPou G74oiyklp8cRVH6+dYziNddF1XnQ1/TirrhURhIIP6xwVhtTYT+5jsGz0ADPfhm4bRoE bM5g== X-Gm-Message-State: AOAM53021XDYEr1pwF0XLw+MuFrY77eqX1CrzFO49ozBXFU5lJC63VnO lGlURBD2tSkALXqS8S+8IomCVs6oxYchwWLtfmMUxg== X-Google-Smtp-Source: ABdhPJy7DFdMdaS97xMoxRqS6WmXgsRrt5dbwajDW1OzguEa9uaz85Fv52jSvKPNcbb4yTlLVhfIEfhmycxKE179n6U= X-Received: by 2002:a17:906:8143:: with SMTP id z3mr33115785ejw.323.1600394032604; Thu, 17 Sep 2020 18:53:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dan Williams Date: Thu, 17 Sep 2020 18:53:41 -0700 Message-ID: Subject: Re: [PATCH] pmem: fix __copy_user_flushcache To: Mikulas Patocka Cc: Linus Torvalds , Alexander Viro , Andrew Morton , Vishal Verma , Dave Jiang , Ira Weiny , Matthew Wilcox , Jan Kara , Eric Sandeen , Dave Chinner , "Kani, Toshi" , "Norton, Scott J" , "Tadakamadla, Rajesh (DCIG/CDI/HPS Perf)" , Linux Kernel Mailing List , linux-fsdevel , linux-nvdimm Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 16, 2020 at 11:57 AM Mikulas Patocka wrote: > > > > On Wed, 16 Sep 2020, Dan Williams wrote: > > > On Wed, Sep 16, 2020 at 10:24 AM Mikulas Patocka wrote: > > > > > > > > > > > > On Wed, 16 Sep 2020, Dan Williams wrote: > > > > > > > On Wed, Sep 16, 2020 at 3:57 AM Mikulas Patocka wrote: > > > > > > > > > > > > > > > > > > > > I'm submitting this patch that adds the required exports (so that we could > > > > > use __copy_from_user_flushcache on x86, arm64 and powerpc). Please, queue > > > > > it for the next merge window. > > > > > > > > Why? This should go with the first user, and it's not clear that it > > > > needs to be relative to the current dax_operations export scheme. > > > > > > Before nvfs gets included in the kernel, I need to distribute it as a > > > module. So, it would make my maintenance easier. But if you don't want to > > > export it now, no problem, I can just copy __copy_user_flushcache from the > > > kernel to the module. > > > > That sounds a better plan than exporting symbols with no in-kernel consumer. > > BTW, this function is buggy. Here I'm submitting the patch. > > > > From: Mikulas Patocka > > If we copy less than 8 bytes and if the destination crosses a cache line, > __copy_user_flushcache would invalidate only the first cache line. This > patch makes it invalidate the second cache line as well. Good catch. > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org > > --- > arch/x86/lib/usercopy_64.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/arch/x86/lib/usercopy_64.c > =================================================================== > --- linux-2.6.orig/arch/x86/lib/usercopy_64.c 2020-09-05 10:01:27.000000000 +0200 > +++ linux-2.6/arch/x86/lib/usercopy_64.c 2020-09-16 20:48:31.000000000 +0200 > @@ -120,7 +120,7 @@ long __copy_user_flushcache(void *dst, c > */ > if (size < 8) { > if (!IS_ALIGNED(dest, 4) || size != 4) > - clean_cache_range(dst, 1); > + clean_cache_range(dst, size); > } else { > if (!IS_ALIGNED(dest, 8)) { > dest = ALIGN(dest, boot_cpu_data.x86_clflush_size); > You can add: Fixes: 0aed55af8834 ("x86, uaccess: introduce copy_from_iter_flushcache for pmem / cache-bypass operations") Reviewed-by: Dan Williams