Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp237944ybg; Thu, 17 Oct 2019 22:09:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwKsaJZRFxfDbDeCdsvPBt/jsp0nQ7TxcV4hXjh+m8I7+PXsgp/B4/0H9wpIvPvfEGaXMO X-Received: by 2002:a17:906:4757:: with SMTP id j23mr6594638ejs.174.1571375383701; Thu, 17 Oct 2019 22:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571375383; cv=none; d=google.com; s=arc-20160816; b=VAGQb6HiytEw1ZMvnkmQtjnQ1l/1URxYoAxoPCSyKmtr2W3IhhHeR2x2qUhdFkGVBo GjCLsuoSZTjSQ2ERUT2VEo4RmPyBYzfxfm4QUepoKU9FZBI1pVe/VC1i0RSIuHw1VoSd hGoufNX9DH16lCwj6ijDMjgj6O22irmxc/CfnJiFAEb6WWgQXZ40/KppTBXHNglALEt2 ZwIZ0V3PM5JaLoIUmz6LkoQFtVVA4YHfeyoJ5PXiXkTOgADu7Au5oIgSUsLbS/BxyxsN wkiB6EBDFe2FLtWLs1OCq7t4jMqoCwTMT0L+ijhS97wlmkLAHNItEYdh7v/BRTcq2LyR 9hVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date; bh=HsCb3Mo3Xna7EYoMwhTJhD9MwGz7SJTZ9CRewHqki9A=; b=IndswiOqWyoQ/bZ+sSldYv0fTSgaH7O5QdmdMmG9T1nhudIbJVLHe3CFfb5mpQH3n7 PiVU31Pz4jnyezcL3nd6mTMK1ZTa8gArb6hb/KIvh3wpj983ki/ES14t9oDa/ylDbRhj gDFxF7T9acoUp3ZXnMkph/CLO8AaM1YBxJTr7wD3iqnlV9egiu+8R2+Yh1A22HaPAtLG wrjEiqapTwPPZMRXbpmeRR2mbjCbxpAqa9DYQRsBPN6qVyLMMos/pjDtOcW/sbCQmIYp QdXmLAK1WGP3/2v9jrccnFxp2EMiSGxDh3Pu7loXscboLaBxfgM2xsmRCODAkt6JlA1f 91Og== 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 n3si3717998edc.151.2019.10.17.22.09.20; Thu, 17 Oct 2019 22:09:43 -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 S2387534AbfJPXWD (ORCPT + 99 others); Wed, 16 Oct 2019 19:22:03 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:41669 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbfJPXWC (ORCPT ); Wed, 16 Oct 2019 19:22:02 -0400 Received: by mail-pl1-f194.google.com with SMTP id t10so157342plr.8 for ; Wed, 16 Oct 2019 16:22:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=HsCb3Mo3Xna7EYoMwhTJhD9MwGz7SJTZ9CRewHqki9A=; b=Q0Kx9JeOMNVUkBPzSNv5QZZU1f4aIDPw8d1AHvxDbkZn918Ikj4/YOMB1uyCvXnJu2 okw1jfABGV+FPbvUvZo6G+Wz04bXbrFlUQIFL0reKeEWt57yWgq8hXkbibrr+/LZzXp3 SdlhTio/X4GNUg2pOuzET7+pY3KCW8C6eGy8V/pfDOx5YAI2kReiFIMxjB7e5vfQrjQu EMC5Jzy0PkB7NNJw3ssyM3o1m7mdBb76Foa3mIN4ShDwr2W6dpSwELdY/O1DR3hAqwI7 Ol6BXi0OHIcZp7WwUWgmraWFqMJ+fM3IwWYgYp7fCKmcl5K07CpkmJ2Q1S3g1Thu0tCc mv2g== X-Gm-Message-State: APjAAAW2HSFDu1hb5hTagl/2ehlZpmnn1nVZOt+qDREwxgaFk23yJkk/ MLwHPFjAzSYSXUKF64EbK09KnA== X-Received: by 2002:a17:902:122:: with SMTP id 31mr749931plb.274.1571268119937; Wed, 16 Oct 2019 16:21:59 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id 14sm167819pfn.21.2019.10.16.16.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 16:21:59 -0700 (PDT) Date: Wed, 16 Oct 2019 16:21:59 -0700 (PDT) X-Google-Original-Date: Wed, 16 Oct 2019 16:21:55 PDT (-0700) Subject: Re: [PATCH v10 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared In-Reply-To: <20191008123943.j7q6dlu2qb2az6xa@willie-the-truck> CC: Justin.He@arm.com, Catalin.Marinas@arm.com, Mark.Rutland@arm.com, James.Morse@arm.com, maz@kernel.org, willy@infradead.org, kirill.shutemov@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, punitagrawal@gmail.com, tglx@linutronix.de, akpm@linux-foundation.org, hejianet@gmail.com, Kaly.Xin@arm.com, nd@arm.com From: Palmer Dabbelt To: will@kernel.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 08 Oct 2019 05:39:44 PDT (-0700), will@kernel.org wrote: > On Tue, Oct 08, 2019 at 02:19:05AM +0000, Justin He (Arm Technology China) wrote: >> > -----Original Message----- >> > From: Will Deacon >> > Sent: 2019年10月1日 20:54 >> > To: Justin He (Arm Technology China) >> > Cc: Catalin Marinas ; 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; Punit Agrawal ; Thomas >> > Gleixner ; Andrew Morton > > foundation.org>; hejianet@gmail.com; Kaly Xin (Arm Technology China) >> > >> > Subject: Re: [PATCH v10 3/3] mm: fix double page fault on arm64 if PTE_AF >> > is cleared >> > >> > On Mon, Sep 30, 2019 at 09:57:40AM +0800, Jia He wrote: >> > > diff --git a/mm/memory.c b/mm/memory.c >> > > index b1ca51a079f2..1f56b0118ef5 100644 >> > > --- a/mm/memory.c >> > > +++ b/mm/memory.c >> > > @@ -118,6 +118,13 @@ int randomize_va_space __read_mostly = >> > > 2; >> > > #endif >> > > >> > > +#ifndef arch_faults_on_old_pte >> > > +static inline bool arch_faults_on_old_pte(void) >> > > +{ >> > > + return false; >> > > +} >> > > +#endif >> > >> > Kirill has acked this, so I'm happy to take the patch as-is, however isn't >> > it the case that /most/ architectures will want to return true for >> > arch_faults_on_old_pte()? In which case, wouldn't it make more sense for >> > that to be the default, and have x86 and arm64 provide an override? For >> > example, aren't most architectures still going to hit the double fault >> > scenario even with your patch applied? >> >> No, after applying my patch series, only those architectures which don't provide >> setting access flag by hardware AND don't implement their arch_faults_on_old_pte >> will hit the double page fault. >> >> The meaning of true for arch_faults_on_old_pte() is "this arch doesn't have the hardware >> setting access flag way, it might cause page fault on an old pte" >> I don't want to change other architectures' default behavior here. So by default, >> arch_faults_on_old_pte() is false. > > ...and my complaint is that this is the majority of supported architectures, > so you're fixing something for arm64 which also affects arm, powerpc, > alpha, mips, riscv, ... > > Chances are, they won't even realise they need to implement > arch_faults_on_old_pte() until somebody runs into the double fault and > wastes lots of time debugging it before they spot your patch. If I understand the semantics correctly, we should have this set to true. I don't have any context here, but we've got /* * The kernel assumes that TLBs don't cache invalid * entries, but in RISC-V, SFENCE.VMA specifies an * ordering constraint, not a cache flush; it is * necessary even after writing invalid entries. */ local_flush_tlb_page(addr); in do_page_fault(). >> Btw, currently I only observed this double pagefault on arm64's guest >> (host is ThunderX2). On X86 guest (host is Intel(R) Core(TM) i7-4790 CPU >> @ 3.60GHz ), there is no such double pagefault. It has the similar setting >> access flag way by hardware. > > Right, and that's why I'm not concerned about x86 for this problem. > > Will