Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6378396ybn; Sun, 29 Sep 2019 18:58:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV5MfIyzucvbi6ZgmJqVFbibMgT1z3F2tcyEFRU6HNdxzoelMK3+IsUXU1GyAXOb0Jwcyc X-Received: by 2002:a17:906:9381:: with SMTP id l1mr17160121ejx.93.1569808703638; Sun, 29 Sep 2019 18:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569808703; cv=none; d=google.com; s=arc-20160816; b=jlnpq027CHx8TcPotKuv+Xx2hduhnQnwpQ7pRq5petIssQnHNQXBkG5Q7/mAa7YufS mV7JOOTsQU2eI5K/Zc7flt3pDmqSmOsnC9ZveTVj9FnwmQZg5WUVMXLbOIp7v+vCu1uJ /oZcAOTnAHppVPvNOFGln3oe1fbN9gB/ZyxTuiP9hUIRVjh2NwhyydauHJgSE/E2BMNP JaCYte/y446n937Pxjv3LnO3Ou9meRy5LhWET1RZcAYvPiMUAXF4+6tGOqowGp63lrxD +kYFPf75kb+10WIVw2JVHQvc/rR26U4awZyQeEECyqbC3bDQm+/OdHya/1EEFVMXGn8T iipg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=wCz76JtjZBwOZHPIpz2i4MOqPO835H42Uq+cOP8GRSE=; b=hFHVYAfQOM57iGTrm1IBMN1HiksfDGxbULjXM/JqtoeyVkMae0mEfoSsn/cIcwKC8q D3l9lzVTjDlj8SshaJdCtWUOfvzV7nyjExoAM9H6nh2iKM2RsJSQQMU97UOImJ/dBuWu 8FmzANp+LpotxXgpBEDEXlK71gPiMxOV63tzFu3J+brrIDCA0hI8G6UoKPeSOUDYdIlv /JIu7egCSAroblCbSP9z7DaVTuv8Do9HmFEiAY/K8xpREutsMKn2WZbnr/Evg8I2xLWM 6/uxVFUtfKUXBsq5oK1rz9OIBNJSAYp6V4XPKtgxHXxqhfXEhQJPr3oqn5XiPUj4EsL5 kZ6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si6173865ede.131.2019.09.29.18.57.58; Sun, 29 Sep 2019 18:58:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729032AbfI3B5y (ORCPT + 99 others); Sun, 29 Sep 2019 21:57:54 -0400 Received: from foss.arm.com ([217.140.110.172]:45362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfI3B5y (ORCPT ); Sun, 29 Sep 2019 21:57:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3ECE828; Sun, 29 Sep 2019 18:57:53 -0700 (PDT) Received: from localhost.localdomain (entos-thunderx2-02.shanghai.arm.com [10.169.40.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6F8103F706; Sun, 29 Sep 2019 18:57:49 -0700 (PDT) From: Jia He To: Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Marc Zyngier , Matthew Wilcox , "Kirill A. Shutemov" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Punit Agrawal , Thomas Gleixner , Andrew Morton , hejianet@gmail.com, Kaly Xin , Jia He Subject: [PATCH v10 0/3] fix double page fault on arm64 Date: Mon, 30 Sep 2019 09:57:37 +0800 Message-Id: <20190930015740.84362-1-justin.he@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we tested pmdk unit test vmmalloc_fork TEST1 in arm64 guest, there will be a double page fault in __copy_from_user_inatomic of cow_user_page. As told by Catalin: "On arm64 without hardware Access Flag, copying from user will fail because the pte is old and cannot be marked young. So we always end up with zeroed page after fork() + CoW for pfn mappings. we don't always have a hardware-managed access flag on arm64." Changes v10: add r-b from Catalin and a-b from Kirill in PATCH 03 remoe Reported-by in PATCH 01 v9: refactor cow_user_page for indention optimization (Catalin) hold the ptl longer (Catalin) v8: change cow_user_page's return type (Matthew) v7: s/pte_spinlock/pte_offset_map_lock (Kirill) v6: fix error case of returning with spinlock taken (Catalin) move kmap_atomic to avoid handling kunmap_atomic v5: handle the case correctly when !pte_same fix kbuild test failed v4: introduce cpu_has_hw_af (Suzuki) bail out if !pte_same (Kirill) v3: add vmf->ptl lock/unlock (Kirill A. Shutemov) add arch_faults_on_old_pte (Matthew, Catalin) v2: remove FAULT_FLAG_WRITE when setting pte access flag (Catalin) Jia He (3): arm64: cpufeature: introduce helper cpu_has_hw_af() arm64: mm: implement arch_faults_on_old_pte() on arm64 mm: fix double page fault on arm64 if PTE_AF is cleared arch/arm64/include/asm/cpufeature.h | 10 +++ arch/arm64/include/asm/pgtable.h | 14 ++++ mm/memory.c | 99 ++++++++++++++++++++++++----- 3 files changed, 108 insertions(+), 15 deletions(-) -- 2.17.1