Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp848596pxk; Thu, 17 Sep 2020 18:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeXhDPzD0IgimUB/wLS/fWO22nhxRluoRWcy5K90xu5+iFT01k7yfakPUH0YuFc4/dxi0r X-Received: by 2002:a17:907:72c2:: with SMTP id du2mr34795286ejc.512.1600394255598; Thu, 17 Sep 2020 18:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394255; cv=none; d=google.com; s=arc-20160816; b=AHIZTrhVkBuC85ZPHa3QwlGmtANd0MioAFormBnWt/quO9NbXaJpsb5Ws7ZjSKW0Tc WtUnN7Yk2h+B1I4OvBW0evtc5CSlujrEwzWs9WcEyzmxHoDHF0ILp2wz73BtYViOdnNx 7SuU6MmH4R9xx7TpVd7A7Fn2nb/YTdbTUfen2nXXkzIXo40IdMAXssgsYlyspp9bxedr x23X9L/J8QwhOe42hJCx74g0RMTuTXflzWnLXSequpsYRIfQQRCQbg5fQqSidMD95vv/ CLwq/bpgrZWa2vnCIw+VLIiUdGFmfna4TUskZwIIROdtLoVkNyNeD33pcSXEdqLBPUuN Sgww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GC2uboF6NMZuC9/ZByaXp1KFBIoZjwLF73X8h59tMWs=; b=d+ekTgGMX1yOEMrY7YILbXNgLexr7YeCN9r4kLVw6zu2/DfXjcvJa609J/hA/asNtS x3d5krZtG/neIWTVzCHrNXmP4CDfYE957gVsSvvNxEJWtt13dmJE2E68B6O+spkyk5v6 Z5XDmIXFu8cx6xJPhkk9D7RMLibnl1FlxySfhTdl9XbTXh53cDWpfZKy7aN34VSU7Gfg LWBqyY1urYYQ22Pn9pwTbjIZy3dLWevRU64rfrM+9j+9MOj1sVGXBwyHAEz9iJCMx9/g ZsXmhiOnwpHDCVnqLG9W1tOcAJPXpOqwBQyjiljW4PbKq3IcDinZ/rAEmxmPIb3cp8J6 9TAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0n1kgcoB; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si1194334ejv.425.2020.09.17.18.57.11; Thu, 17 Sep 2020 18:57:35 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=0n1kgcoB; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726199AbgIRBxy (ORCPT + 99 others); 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-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