Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1513333ybl; Tue, 13 Aug 2019 14:04:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmg2989iEoKUd/JUBmlZH4IPCjL1dXFIchNq5H/NvLVnYmw9ocf6XhqkvZ2R3mkDbRS194 X-Received: by 2002:a17:902:b089:: with SMTP id p9mr3405101plr.269.1565730273811; Tue, 13 Aug 2019 14:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565730273; cv=none; d=google.com; s=arc-20160816; b=weHqeYpHOV5nWG9x/V1ZyGDxzwyE90zsumJZPSvXNOUxaTI6LlrdhPQE4G1zNuPzXM Km1L08SGTJ93CPERu3OpSbvxJCnzB8OcJ8itUt9/cvcWEos9viRXHIrjRIpqRlc6f78a UhsSbuDbr/OcPUyoeJ3tthfKWalZFTX/u11zWuO+jv/JhxmzD4MLQaIi++v7CTErnE/4 w4aVAIB5iEtqJ/jpyO68Y5m0QNRWhtljDpje0Ua3sopUktJ37Zilez4yE+4u8PckvBTi U5bmTzrFwcQbe82Nts1awEtDJYhKMH4mbwmOpPBeRXLGg8MWB6ObTbehBwNo5ZTh9j7k p/0Q== 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=CGApdEfbLA6KPbGGTj01Y2iinw07G0g/iIQ7oByjF2E=; b=08ZAdAm60ZvAwFC0ywgibC99GHj5XHEEQ16KXfHqZi2thWl8q0xTI0FgeKRUA9O7k4 Q9PMV5rp4uh27eSQFwWE1gdHNw2aLNJzkO0bAOjNFX6t78EjkdjYlqEG/OAR0F19VJgG kLQOtTlZmJR3QtrwICfgElZWmOteS0b78pGPmV2vBbrcpS66vlB2dSQfF09hKJzTIYBz txwZXxXNhDW62TzJ5PhdZePbl6CIrPSYCLLgwXHu74sFam8QydJiEk9pjlaP1yWiPuDd xkG+TomnqKOHvLCYsf7IOs2tv3txo9E9heZ/sPGBTbSwEPUxEvFVS9L5+LCJKYdBn0cC TSwg== 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 y8si68416716pgk.594.2019.08.13.14.04.18; Tue, 13 Aug 2019 14:04:33 -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 S1727082AbfHMVDM (ORCPT + 99 others); Tue, 13 Aug 2019 17:03:12 -0400 Received: from mga06.intel.com ([134.134.136.31]:16085 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfHMVDJ (ORCPT ); Tue, 13 Aug 2019 17:03:09 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 14:03:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="187901550" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga002.jf.intel.com with ESMTP; 13 Aug 2019 14:03:07 -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 , Borislav Petkov , 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 , Dave Martin Cc: Yu-cheng Yu Subject: [PATCH v8 25/27] mm/mmap: Add Shadow stack pages to memory accounting Date: Tue, 13 Aug 2019 13:52:23 -0700 Message-Id: <20190813205225.12032-26-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190813205225.12032-1-yu-cheng.yu@intel.com> References: <20190813205225.12032-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. 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 b1a921c0de63..1acded00f003 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1703,6 +1703,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; } @@ -3319,6 +3322,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->stack_vm += npages; } static vm_fault_t special_mapping_fault(struct vm_fault *vmf); -- 2.17.1