From patchwork Thu Oct 11 15:15:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10636891 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBB7617E1 for ; Thu, 11 Oct 2018 15:22:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D82CE2BA37 for ; Thu, 11 Oct 2018 15:22:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC0A62BA33; Thu, 11 Oct 2018 15:22:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C3722BA21 for ; Thu, 11 Oct 2018 15:22:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3E246B028F; Thu, 11 Oct 2018 11:21:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6473D6B0285; Thu, 11 Oct 2018 11:21:02 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BE766B0285; Thu, 11 Oct 2018 11:21:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 6CE7E6B0276 for ; Thu, 11 Oct 2018 11:21:01 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id s15-v6so6275016pgv.9 for ; Thu, 11 Oct 2018 08:21:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=V56ObHxpVBzvq9rlMW5IthWJ0mE9AdzBQaFBjAUSUvE=; b=rdVz+Y3mud67sAQ5zA7Ff2yk2vBXjWXfZHql3YWJc/sfxf5JBzUf68F43s+vk1DOkj EHIgh028bS/2xsN+zK1qWMP1D9WD8Yo3/tATnON7H0ph+XJaJhZswzwbKKdNf94pjMCe TKzfRVM1Wa4K6gb3vJJKbohrr+fMqB5zjkvw4WZjSWGb1VIRK3oFULLW0lMbUhWZ2+Jr wfg26V6cVjumbgXxH6uXCtj0tDQ8pue38NWxHwJj3DA0qJizG5Iw/ktQN8Z1+6pGfOox jsUlma/W7BBaKhcmWBbSk6oMoCyQtMzEiGFxjk7/XIlRysVg63Mb3yyMQy6TvSLbGuQL fyBA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfojzsDgaqc1Atg4jvPb6hlTDOJ5yB5nHw6Q9HD+A3p5GIl/3m1DT pTXJIfyHUqfNmBWh958aHCKCU1k3g9AEQGjnSSylHw1uPEtSN+Dqw82+6Bch1PSXsZ7rRvSakN/ 7E0dQXlPcYPl6flPYWI7L72hL6DdPpKdJYs7PX9cW28m6MnY8PhW6u7R9IAHfxiFb1g== X-Received: by 2002:a17:902:6b03:: with SMTP id o3-v6mr1999834plk.333.1539271261137; Thu, 11 Oct 2018 08:21:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV60aq797aLrvWyfwlwaREoVqvS/zGAQeziJA7u5qgi44WDv/QxqLin8J3Se275GKbQDoa9cp X-Received: by 2002:a17:902:6b03:: with SMTP id o3-v6mr1999809plk.333.1539271260529; Thu, 11 Oct 2018 08:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271260; cv=none; d=google.com; s=arc-20160816; b=SqgaMWxokRIaAb6PpKMfR6BjPN1fPjd4k1xQ4ZTI/Rn4DXmG/ecHnX8mmp9VFqz/YE wmx/AsGT2WVNAXOxZNPgu1x3ApRieM5hVTlRf1Q8ZcA+OYQEzZson767yLRgckP9CRPY FVre7K5+r1qjua7IKKuESEnJtcRRxPP1506Yr/cnj7QRpriuWeIhEAevbMmMCS/Z7Tol +cSHLHG3CzeAyPL7Q4mVK/5LgpliqEkuLJOWmIXjEuPkPMCllNzf7jR2yDMNz3oNAEcR tAPkc7k9MtdaHSXGjduTiFQm55hk8jVvysNoF3f0rS0N3O2ebUSl1AMh9+Nir5Dyg3UM OWpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=V56ObHxpVBzvq9rlMW5IthWJ0mE9AdzBQaFBjAUSUvE=; b=ZKrr+9MDY+2/a70Ypa48AeQ9KjOGpxlQ0GOouLkZuZdr0dAx3SGCqb6BDYtsNy5nZu 8PVu65xam1alKxSTRv/LJOSzn2M+aEhfharWiclABznH6P5MQkQA7+NIFQffBhtwq22b 30eiVkn0cTY0rVuFdaVZFmpmBltUd81ETAdIPplH9gMI/TH6igNLNJHJicpjmcwEDMcT I9ots5aTGvp/qxzSZYF2JfDBGg5RtqQ66Kt/JI3hx6H40MPfo+qVlR5CRlONV3t6G0as 5RQM9ag64ONJBoXiLTm2W/8Hv6vpmtzUBpdItR/cNOoihBjSroH3ME7IH8ASBcmZp0QW 9C7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga06.intel.com (mga06.intel.com. [134.134.136.31]) by mx.google.com with ESMTPS id y62-v6si29748088pfy.139.2018.10.11.08.21.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:21:00 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.31 as permitted sender) client-ip=134.134.136.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.31 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:20:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="78019172" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga008.fm.intel.com with ESMTP; 11 Oct 2018 08:20:47 -0700 From: Yu-cheng Yu To: 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 , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [PATCH v5 25/27] mm/mmap: Add Shadow stack pages to memory accounting Date: Thu, 11 Oct 2018 08:15:21 -0700 Message-Id: <20181011151523.27101-26-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151523.27101-1-yu-cheng.yu@intel.com> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Add shadow stack pages to memory accounting. Signed-off-by: Yu-cheng Yu --- mm/mmap.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/mmap.c b/mm/mmap.c index b85292014ec9..fa581ced3f56 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1677,6 +1677,9 @@ static inline int accountable_mapping(struct file *file, vm_flags_t vm_flags) if (file && is_file_hugepages(file)) return 0; + if (arch_copy_pte_mapping(vm_flags)) + return 1; + return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; } @@ -3267,6 +3270,8 @@ void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages) mm->stack_vm += npages; else if (is_data_mapping(flags)) mm->data_vm += npages; + else if (arch_copy_pte_mapping(flags)) + mm->data_vm += npages; } static vm_fault_t special_mapping_fault(struct vm_fault *vmf);