Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1734058pxb; Wed, 9 Feb 2022 03:24:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW/firMas7grEeayrG/sWTcJzC+1zJfeRehmSuIeD8aIYvgwm+c/Tq+QkcZFCUcHHmBSQw X-Received: by 2002:a17:90a:1c10:: with SMTP id s16mr2926809pjs.115.1644405894450; Wed, 09 Feb 2022 03:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644405894; cv=none; d=google.com; s=arc-20160816; b=US8cPV37ObOJCmHV1Zq8Q6Z219moAV52HlR0mQQBc/A3JQuOlmA5k/ktGGzt55TJYa 6+NGtk/KgGR5uzLxs0kxsf9fttEC/hNAUjq991U8mkunJRhiEvdjVxUyYWc5KMhzN3UR mBPqgGo32DDGzBTEVVQzjtpfYRNYcg2Tz6KzSa8w2KslsDm/Y1e0d1AAy25vO33TX3iT rUsjTi6vXW0/FYF7p8fra8cZgWhmwxdT6u4LjJQyQVaqTPbOajcx/FJFPziNeF67ZkNp fdoeQa6JQxa23gfV8i2mQ8NnyzykZ8TexZCpGMVtw2/JwrzqcI+bGcnhrbByglrJT4YV I1HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/rv2PEt6IIiPLW9lZEeUjxxgQpIiSoXGPYPSbKMenEs=; b=mvWGeaJfPIPZigva1WBEMOw/IRvefxW71Mv+DkkqSpsxOMpDgwin4V2+3K5FM6wKbx nzBGvO/kUg/ADN0Nf9W1jojVJsmiIVXMo24DfFdxzRQ1Yyk5K5woW5hrSOyylE2abOOL rvTviTrpaVo46Px4/Tw/oAxVRWjVuxVB6ej08nyCi6jP33EVGzHOGLsftqbeOCYJFcjQ vgNm/lEnN7xVAvGTXQrKf31iGtfIa//EE0zR1zBorxdh9DGBy0Pth5OKMzINMvAmHjAM NvK+Zv6URSqka4f96dFA+rC9aS5gRh63uEHOkV99ZEBw5eLf7nyZVb/QjAl6u8VrBCIa MIcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=mWirpXFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 206si17680300pgb.396.2022.02.09.03.24.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 03:24:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=mWirpXFE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B9F7CE01A23A; Wed, 9 Feb 2022 01:48:55 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348340AbiBHHg6 (ORCPT + 99 others); Tue, 8 Feb 2022 02:36:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348333AbiBHHgw (ORCPT ); Tue, 8 Feb 2022 02:36:52 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB365C0401F1 for ; Mon, 7 Feb 2022 23:36:51 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id n32so17430505pfv.11 for ; Mon, 07 Feb 2022 23:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/rv2PEt6IIiPLW9lZEeUjxxgQpIiSoXGPYPSbKMenEs=; b=mWirpXFETjjymQb9FwJYTXT9RWcZSQSLT5Nsh/1DBOfuh2Biuy/KM+f9R5CeJIlYYC GDwg8fBYZTDlssF3zNfvwJnkHHLbN9g9hR/k68bwOWP4LlYKrolMPPGjF06x1diK+Vpg Oeq7EOUsr9mUAe81PFskxE4Owu3enMTWXolrKTdSt0ZY2vd98WKWzyNREyikVcUun4xE SyrT606wjX2rhlV21mzXjz0B6XCMwG0ldcYNkSV1MewRFtJ3CeKOt8uPKd04zxFdx6ft e8aAg8sn9SGEQdDo3KLTRL2+fX4oI1DR15XPBg91kF7l+/phcejECxxqPkHZHbrWx/sK 7lKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/rv2PEt6IIiPLW9lZEeUjxxgQpIiSoXGPYPSbKMenEs=; b=Sz6wIAjKTllQtKMOlGo/Z/qmeCGGGCs4DOqmcWuQhYoEksutlioJXZgsx/0fw1m9Zj bmbAwoCa37sLJa0Irz3dXicRuKVZttarzy0uHvGt4WE9ClBUPKytwcqCk9NfjpMQO7Pg gDIb3e/Kwm2u7S7EaGXBZS0L95IC1no0t1Ay9PiFDEDwVbP+RIKuyBBM6ibTeUlxS9eb LzxSAx/ll9GwsDBRXtc24Ut+4TxMxW6gi29D9308tDokt9U2BPVgi+L6kJHKWGaiv6NO 1wyfVsN33hwr6TYHvnpnB+1IQCc5xQln+QjNBWHc7fh/tagpMQISK98exxRd31diUmXx /e9Q== X-Gm-Message-State: AOAM532du9Dhd8RE4VHJaNPGP85CMAN0ijwW9Nbb/1wbKGlixvdP4Gf/ gG11/b8eFvHVI5noMHrlfARhyw== X-Received: by 2002:a05:6a00:1253:: with SMTP id u19mr3314465pfi.8.1644305811236; Mon, 07 Feb 2022 23:36:51 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id gx10sm1621017pjb.7.2022.02.07.23.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:36:50 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com, rientjes@google.com, lars.persson@axis.com, mike.kravetz@oracle.com, ziy@nvidia.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, Muchun Song Subject: [PATCH v4 4/5] mm: hugetlb: fix missing cache flush in hugetlb_mcopy_atomic_pte() Date: Tue, 8 Feb 2022 15:36:16 +0800 Message-Id: <20220208073617.70342-5-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220208073617.70342-1-songmuchun@bytedance.com> References: <20220208073617.70342-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org folio_copy() will copy the data from one page to the target page, then the target page will be mapped to the user space address, which might have an alias issue with the kernel address used to copy the data from the page to. There are 2 ways to fix this issue. 1) insert flush_dcache_page() after folio_copy(). 2) replace folio_copy() with copy_user_huge_page() which already considers the cache maintenance. We chose 2) way to fix the issue since architectures can optimize this situation. Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") Signed-off-by: Muchun Song --- mm/hugetlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a1baa198519a..eba7681d15d0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5818,7 +5818,8 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, *pagep = NULL; goto out; } - folio_copy(page_folio(page), page_folio(*pagep)); + copy_user_huge_page(page, *pagep, dst_addr, dst_vma, + pages_per_huge_page(h)); put_page(*pagep); *pagep = NULL; } -- 2.11.0