Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp243144ybg; Thu, 17 Oct 2019 22:15:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqx57TuOHyrJmVdswW3wa5k+FhpJSwHqDgGvyvdsAPRXmXBUkI6BlmLsOkhCvwqZmgTZLI4O X-Received: by 2002:a50:ab10:: with SMTP id s16mr7664356edc.118.1571375721955; Thu, 17 Oct 2019 22:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571375721; cv=none; d=google.com; s=arc-20160816; b=gf54DhOkn0gI1viEQOWQPDXgodyTd5A962LyocPMuUfWS9ECwSHOFAVeij87F0b5uO IINqPgCL/DofbSla2QmXq4Kr0V3gpAAGvsZNuDPUbudQTNcR+9nAFLT/w13pArDSzfu+ eV1jf4ufYCijKqqkkXuQtVEl7PojEGNPCRbeAAsVRFNou7GR4087qwLetcWjDWKXJzbQ NA2Z5SYFo9+4fDR48yGrxHR92a2PS3YmJHISsTxebYyLZ1fCdtxIOfxcRCYvOY6bnBZ1 aPdDSwct+GQhFB+0xAdGuh7lMLOxeha2kowvFItiiAwhU6BkZM6FAM6laJZMb1Qbj35a K+Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IC0vqO02JH6KUo+KJ7H2QGWlMmp8E3+UjHxdNn8uVYs=; b=otQ1NxtxuO238LyCnU5NTqHFYLL0MvUqRT6L5AaodzTiimhd4kqeHMmIa625Ktk1+T 7wZ+idJ06kFHqwPYiJIQhkcLcszIbol7EsZBZ9eF/LoDbZ1xT5whf8Q+Za0WVDzlVmkH qU9ChvX228BgfmYSLJj1s8w7pF/17Z4nj4tiFZScDzaJxWZ2SypVXXN/BTXaookRxYYS RrdauwEoDw4m6aZZKNbaCTfVu3cuDdaoQkXr6tGqLXs5dfDi1OlmowrPPmC4JXBsaGLL WeHO45onvtP+PBTdUXjw16d8UKvWAfypxrU4AzsMn51k6E88tLaMPK/vS6OSolXSQjAa dBOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z6Qx+Yjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nh5si2811303ejb.154.2019.10.17.22.14.58; Thu, 17 Oct 2019 22:15:21 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Z6Qx+Yjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393755AbfJPXqP (ORCPT + 99 others); Wed, 16 Oct 2019 19:46:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:57328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbfJPXqP (ORCPT ); Wed, 16 Oct 2019 19:46:15 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 971AB20659; Wed, 16 Oct 2019 23:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571269574; bh=1d+anmR89+BsXGTeKAeDSQMGxC4eYRI2kxsjcdlZMTE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z6Qx+YjtJmpoUVU8R7/jtOToPUmweQ91tIuV2pHkqKBannSmtgnxpD10pvX/mMjBb aThIrnvXcv4Y9U1Lf5Ly6vCeEKvNk3pFBM/Q3I9LjbuPY0fNPzxbINylySRKYve0BK mkq4d9FNRSMXljwo1DSsWbBB9x0S6XLS2cSludn0= Date: Thu, 17 Oct 2019 00:46:08 +0100 From: Will Deacon To: Palmer Dabbelt 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 Subject: Re: [PATCH v10 3/3] mm: fix double page fault on arm64 if PTE_AF is cleared Message-ID: <20191016234607.626nzv5kf5fgz25x@willie-the-truck> References: <20191008123943.j7q6dlu2qb2az6xa@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Palmer, On Wed, Oct 16, 2019 at 04:21:59PM -0700, Palmer Dabbelt wrote: > 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: > > > > 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(). Ok, although I think this is really about whether or not your hardware can make a pte young when accessed, or whether you take a fault and do it by updating the pte explicitly. v12 of the patches did change the default, so you should be "safe" with those either way: http://lists.infradead.org/pipermail/linux-arm-kernel/2019-October/686030.html Will