Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp602792pxk; Wed, 16 Sep 2020 11:58:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcbRZA0eLnOiUCgWr+jg0KH9DjCxsoicYrPXv7Chl2ZLOfwHxNpHhK0Zms+1WEK4C5jWFS X-Received: by 2002:aa7:d88a:: with SMTP id u10mr29420745edq.217.1600282682886; Wed, 16 Sep 2020 11:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600282682; cv=none; d=google.com; s=arc-20160816; b=rSmhxaF6GO0TFI12QrnEhuGqvwPGoMQOs7WsznpMCnzmJHC8TaBsoXFqW/+bFMXilx eM1Z29ZrdjSnKhvKHJCJc8EdhYbT3ZHVuouoBHLMqizGOjQMcmH1GVdM8Rik+QuGWmsY yEyKRwzL/UeCtykhIixc0HcNA0x0WFQQTyxcxBzh3s3v/tobXsWWk6aqIMTHJMj7jyYe XGTP9OTSiqY9dJ/iUgPLjTSSlC4T06XVZJ9FTMNDuCcNMMIR0nZ/frCfay7PhLVqQVFX T61zUYULiQllLB1p90mH3uM+6o4ZO9wto9Bj5BjsWNUIRiT4dijPxUfn74cgY2OmpAlk 1WFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=RskhOddlyzxn2O1hiGiO8qkIeVUodbG095OhCxUszWY=; b=qq9+3EwikB0E+34Y2Ns2L2qinTmtxX+py2GPdX5AvI2d8wCdbScVk2OljZOx569iYX jdwD+tpvqsp07UGQLODtsjE6nRG7eikwdAQTqewT/XnD6UmGqvyJsQHtf/RbfMJYIPGi 7y34WVoiCPStlafCRr53zVvjy/lI5aRCPvkxaD+Ea9pv2kU1mFqQbL8cRHIgxFPv6R/U W7OYgedRd/DAlMTE+kmHBeA0zeUZPjYVsIU0UvszelWus2dxysmF0bx6b1rI6N8Tbt7Z yme0OQDr8gPakw5QhZmOcN7fYnDwGVZl8/7BYAWKaciXM4RC5NbaMMPHZJu/V0MsMdDQ XCiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hMFEdL3c; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce12si12055837ejb.719.2020.09.16.11.57.40; Wed, 16 Sep 2020 11:58:02 -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=@redhat.com header.s=mimecast20190719 header.b=hMFEdL3c; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727969AbgIPS5B (ORCPT + 99 others); Wed, 16 Sep 2020 14:57:01 -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);