Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1004743imm; Wed, 11 Jul 2018 15:13:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe1D/TNRc21fNRQ31za3f+so/JS9Ogzi9OwMJOeebpjOfX+UbmxPkhSDdGdWAlMtBKci19n X-Received: by 2002:a17:902:5381:: with SMTP id c1-v6mr354219pli.137.1531347189824; Wed, 11 Jul 2018 15:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531347189; cv=none; d=google.com; s=arc-20160816; b=hrZEI9s2ZViUstwzi+CtRiQiUEH572ytUnmbCafoxnBDp8bJt88+sOqYSiR+holzAe A1GbLIpGDYJGUGiv4PC9nO748d3BvzjuwDgGgmpOjTJ7+JJdbqkVPg5PNOAOcDRPUlvD Oo+QoXeH6/OqTx8IP/ZpS68xaMC3CnxTkg8bgm5JzL1Jv5NwbCqTNyp8DMC4bQgpuZUT vJA2SLnUG6Tim4omK/rH2UlxdwCW7t3PHqANkbhFEtm3x255VdwZIRVOWAQ+pbBiIAyL nNYYsfvKhehRInDe/8+urEJFjncnDzugJhk/rIxbhugrQ/9DcE905LAuPoLjiyEKBcYZ cLmw== 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 :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=uiPdhNFj/UsW2QsYbb2HTwGNpLSeEe3vIpXlpVDqaq8=; b=R4wOMZxQl9EtHWLup5PTGs2QOskzes4dKdcvqJH6ivCHxigKODhRCAA0yl1wQBBRmP D64Bx75gkhgQHDtyO1+P9jzpbnKsZVJyFm4XokNFfyk6pGpo2qlpYqm5Ig1gzkUIgNha ckQCpiGBx6Ef7z7gm8WWi7LbvPJxpAQJcXcscNTZmPXK3m4BoZ8jOXiCgI9qLukwE9mr nTK+xRO59cn/nqOC41QTRI+yRSCST3h85lvPEIhwEB6rkytELgySOQ8G+az63sD9W2nX huFHlbF52rjZRAZNUpAq0SHbybX+kuf6H2dEP/KJDloonL7op32ur22qVqLnP2o2F+a4 2djQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17-v6si19578732plq.221.2018.07.11.15.12.54; Wed, 11 Jul 2018 15:13:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387739AbeGKQTv (ORCPT + 99 others); Wed, 11 Jul 2018 12:19:51 -0400 Received: from mga03.intel.com ([134.134.136.65]:16374 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbeGKQTv (ORCPT ); Wed, 11 Jul 2018 12:19:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2018 09:14:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,338,1526367600"; d="scan'208";a="70522785" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga004.fm.intel.com with ESMTP; 11 Jul 2018 09:14:40 -0700 Message-ID: <1531325463.13297.30.camel@intel.com> Subject: Re: [RFC PATCH v2 14/27] mm: Handle THP/HugeTLB shadow stack page fault From: Yu-cheng Yu To: Peter Zijlstra Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , "Ravi V. Shankar" , Vedvyas Shanbhogue Date: Wed, 11 Jul 2018 09:11:03 -0700 In-Reply-To: <20180711091022.GT2476@hirez.programming.kicks-ass.net> References: <20180710222639.8241-1-yu-cheng.yu@intel.com> <20180710222639.8241-15-yu-cheng.yu@intel.com> <20180711091022.GT2476@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-07-11 at 11:10 +0200, Peter Zijlstra wrote: > On Tue, Jul 10, 2018 at 03:26:26PM -0700, Yu-cheng Yu wrote: > > > > diff --git a/mm/memory.c b/mm/memory.c > > index a2695dbc0418..f7c46d61eaea 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -4108,7 +4108,13 @@ static int __handle_mm_fault(struct > > vm_area_struct *vma, unsigned long address, > >   if (pmd_protnone(orig_pmd) && > > vma_is_accessible(vma)) > >   return do_huge_pmd_numa_page(&vmf, > > orig_pmd); > >   > > - if (dirty && !pmd_write(orig_pmd)) { > > + /* > > +  * Shadow stack trans huge PMDs are copy- > > on-access, > > +  * so wp_huge_pmd() on them no mater if we > > have a > > +  * write fault or not. > > +  */ > > + if (is_shstk_mapping(vma->vm_flags) || > > +     (dirty && !pmd_write(orig_pmd))) { > >   ret = wp_huge_pmd(&vmf, orig_pmd); > >   if (!(ret & VM_FAULT_FALLBACK)) > >   return ret; > Can't we do this (and the do_wp_page thing) by setting > FAULT_FLAG_WRITE > in the arch fault handler on shadow stack faults? This can work.  I don't know if that will create other issues. Let me think about that. Yu-cheng