Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp35624imm; Thu, 30 Aug 2018 07:45:56 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb8Lj8djgfWQAOb7b4YI5vtblFzd53T+dyVki+ZuDhEsdlErGyEO0f5+r78ef8F2/BqUust X-Received: by 2002:a62:2119:: with SMTP id h25-v6mr10991937pfh.112.1535640356442; Thu, 30 Aug 2018 07:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640356; cv=none; d=google.com; s=arc-20160816; b=IcRonxxVwA9TUG6o7e71RoEB85a9bsk5CBTCzJ6t3BvswaC52NqaCU1AqiLnzSnD07 NmFfnTYpDcosdWlt3yyRvIKo33MKdLPql8gwUXewANdy318OHCAEQa5b5z5fP2BDP9IY 2oHvFacESWYKzcc+Q3ArP6hN8fcnCy99rA+jX1ZL4nzqQq4GvitGHx3SIIEFxBjftgVi YlsYKQgp2wY/TCR99FkZttAy2v1GI9rkLGHuqg4bPq6h8n0LQWHDoQ5d5fBszWGpVfEP kG3NNv38zj3Sjpyv/052VuFq38zxugFLsxIpZP1oPeXPxWRkIT/6QVm+JlMXROev0eWF rLTg== 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:arc-authentication-results; bh=OC+LuoybN9nY4mL1+dVBYqXduCqRpQbUrL1Rlsz3TUM=; b=UYcUqTbDWDpOGRj+1nMBYp3Tlukjgl2m0abEWJ/1jK/PfhNdp/HfBqSpR0CzFH5+fN K5fsIKEetfVsz14//SHyfOd4V9++yaJsOO1LcCiVkaog3OGmRdxJwZ5DTvS8obs9z5cM dmB+4CXlg7NPwMM/SNNT0nnZSqAtnfdxd8QuTjTRnAkvOMbt/u/q5Emtg0CzMko2o6+I 1lqFuTKoU053FfjbCm6aonWbjBWUnWvy2GeytJyZdqS6hhntrrBsDrnRvs8ldD9sOfiT l58XG0+vjQWmEFh14ueeXXB2tOEaYQiBK70y0coFNETb7edaoZIg1Ph/QU4MqpLlbFGA 7c1g== 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 s24-v6si6586295plr.346.2018.08.30.07.45.41; Thu, 30 Aug 2018 07:45:56 -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 S1729467AbeH3SqN (ORCPT + 99 others); Thu, 30 Aug 2018 14:46:13 -0400 Received: from mga17.intel.com ([192.55.52.151]:62771 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbeH3SqN (ORCPT ); Thu, 30 Aug 2018 14:46:13 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:43:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="67186704" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga008.fm.intel.com with ESMTP; 30 Aug 2018 07:43:40 -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 , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v3 08/24] mm: Introduce VM_SHSTK for shadow stack memory Date: Thu, 30 Aug 2018 07:38:48 -0700 Message-Id: <20180830143904.3168-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830143904.3168-1-yu-cheng.yu@intel.com> References: <20180830143904.3168-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 VM_SHSTK indicates a shadow stack memory area. The shadow stack is implemented only for the 64-bit kernel. Signed-off-by: Yu-cheng Yu --- include/linux/mm.h | 8 ++++++++ mm/internal.h | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index a61ebe8ad4ca..f40387ecd920 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -224,11 +224,13 @@ extern unsigned int kobjsize(const void *objp); #define VM_HIGH_ARCH_BIT_2 34 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_3 35 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_BIT_4 36 /* bit only usable on 64-bit architectures */ +#define VM_HIGH_ARCH_BIT_5 37 /* bit only usable on 64-bit architectures */ #define VM_HIGH_ARCH_0 BIT(VM_HIGH_ARCH_BIT_0) #define VM_HIGH_ARCH_1 BIT(VM_HIGH_ARCH_BIT_1) #define VM_HIGH_ARCH_2 BIT(VM_HIGH_ARCH_BIT_2) #define VM_HIGH_ARCH_3 BIT(VM_HIGH_ARCH_BIT_3) #define VM_HIGH_ARCH_4 BIT(VM_HIGH_ARCH_BIT_4) +#define VM_HIGH_ARCH_5 BIT(VM_HIGH_ARCH_BIT_5) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS @@ -266,6 +268,12 @@ extern unsigned int kobjsize(const void *objp); # define VM_MPX VM_NONE #endif +#ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER +# define VM_SHSTK VM_HIGH_ARCH_5 +#else +# define VM_SHSTK VM_NONE +#endif + #ifndef VM_GROWSUP # define VM_GROWSUP VM_NONE #endif diff --git a/mm/internal.h b/mm/internal.h index 87256ae1bef8..d5ee0c04a6c4 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -280,6 +280,14 @@ static inline bool is_data_mapping(vm_flags_t flags) return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE; } +/* + * Shadow stack area + */ +static inline bool is_shstk_mapping(vm_flags_t flags) +{ + return (flags & VM_SHSTK); +} + /* mm/util.c */ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma, struct vm_area_struct *prev, struct rb_node *rb_parent); -- 2.17.1