Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp782179imm; Fri, 21 Sep 2018 08:12:51 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb6yOVVP0idrsXrG0KgPZkD6QXM0Ep/8OpdKHrgQxxXG/ysnBkCFTUrn1IA4wiFw6NZZt50 X-Received: by 2002:a63:f657:: with SMTP id u23-v6mr40017264pgj.258.1537542770949; Fri, 21 Sep 2018 08:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537542770; cv=none; d=google.com; s=arc-20160816; b=FZxkJJdnkKYHJaU4xz8ckrFipz+pYv6gJJt04/XFSk303E1MXi+sSX5BMLXmgncq7w MmMExjVzSiwT1ga/bHtsMN+RRs6sJs2mU7c2F4tNBDBNtRQERFYbuoDNAQ94xTkV3Dei kYWP1ElnOoi+Rxll5YHA1g0XCElE5HgYsnuMMAW4x6t+uKZ4Bvq5RtTOQwlflQXeV6Ii UZscgUoxIaQs3VjJA22sqxtYnR9VHw6qytx7MM7/+t+BMUcx6jmQckcOU+1CZkCODJpj 7tL4AYB4ZY8MA+7flpWO6QZdEs7y5WSwqy2NtjZa3YPHkemq1+dZdZIeRvq7fH8+PS+f G8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+hAwkPRrWa1SdzA9lzXBTpLorf0142oXjZbO3utwlJg=; b=F5FGDTMVgoe0PPi3pidpt5hcDwJ9A/RDngX1S36louMAowENY2rV1ZbxLgAUASc2W8 nqoZsB4253fIk5NahNMe86L135ser7fJ3ZqEwxnOOdEB4oCwW63lgSwV+R1LsYsZDQtr xRyDtERETbz0oUPOiAmPTlyvk8pzpF96lbcQKoT8bgRPkk//zx0EYLnPBbNRtMx+HXp1 STIo9IdS4I7zzZYv22qtOf0e7tq/BnTcMeG9GFpGRQxYCJcWNp21DYeQ3KYLY4BQxFLJ j8SNpBqIm7Hsugs9IItMF11IMKc7NEwWyYeije/PEdaW32AG7//lVZePYv6mhsGfFBBy cTcQ== 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 g92-v6si2289426plg.445.2018.09.21.08.12.33; Fri, 21 Sep 2018 08:12:50 -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 S2390807AbeIUU7n (ORCPT + 99 others); Fri, 21 Sep 2018 16:59:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:13761 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbeIUU7m (ORCPT ); Fri, 21 Sep 2018 16:59:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 08:10:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71856865" Received: from 2b52.sc.intel.com ([143.183.136.51]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 08:09:53 -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 , 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: [RFC PATCH v4 23/27] mm/map: Add Shadow stack pages to memory accounting Date: Fri, 21 Sep 2018 08:03:47 -0700 Message-Id: <20180921150351.20898-24-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921150351.20898-1-yu-cheng.yu@intel.com> References: <20180921150351.20898-1-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add shadow stack pages to memory accounting. Also check if the system has enough memory before enabling CET. 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 5f2b2b184c60..de2d0faa1c61 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1671,6 +1671,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; } @@ -3261,6 +3264,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); -- 2.17.1