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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 DC814C433E2 for ; Wed, 16 Sep 2020 18:57:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7390120732 for ; Wed, 16 Sep 2020 18:57:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hMFEdL3c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727700AbgIPS5P (ORCPT ); Wed, 16 Sep 2020 14:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48054 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727387AbgIPS4r (ORCPT ); Wed, 16 Sep 2020 14:56:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600282606; 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=RskhOddlyzxn2O1hiGiO8qkIeVUodbG095OhCxUszWY=; b=hMFEdL3cyOid+2xH9cNYyUI7CjAd/IGXWtGOI13YB/rKNOfYKpDkxNiOdwfxdjZXEmNLrs 8gNVuIldeRrkJKmcdDTrv1BKAuhOuBugODVgxIptAaahJceR9+gEX/0xD7ZmA/0YGNqTVs 7mUPz6IlHRV9FDM7yk5eH2Xub3SRHxI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-kILKsbndN-GspIYu-UxDow-1; Wed, 16 Sep 2020 14:56:42 -0400 X-MC-Unique: kILKsbndN-GspIYu-UxDow-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33309873081; Wed, 16 Sep 2020 18:56:40 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD88C5C22D; Wed, 16 Sep 2020 18:56:39 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 08GIudmJ025956; Wed, 16 Sep 2020 14:56:39 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 08GIuc6o025952; Wed, 16 Sep 2020 14:56:39 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 16 Sep 2020 14:56:38 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Dan Williams 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 Subject: [PATCH] pmem: fix __copy_user_flushcache In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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);