Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2323774imm; Thu, 7 Jun 2018 08:47:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKiNfG49DG8XLWdInOLlzcZWQEDTXEY0EB6BHCMjBgfGkyq93yawBoKnkH/tQjmfaVEnOA9 X-Received: by 2002:a65:5c46:: with SMTP id v6-v6mr2024395pgr.127.1528386460149; Thu, 07 Jun 2018 08:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386460; cv=none; d=google.com; s=arc-20160816; b=OyWIT9d5SkXbYLDzz53IhKlIeFdRMMY/mpRctRM2L1K0CsfpYVwmRJc83C1DcO5c8g YrMSFbFU1sfZsle2epR4hm3hLJOC1m4vpfyPEDD7S346DEDXXgQJksHDNXXpXVtF/y23 g4TgKeLSO3+8pTB5UgSi3Cid+sLCI5u5AS3ydAG8vxApzvSsIMHVyPlG1IsYlkGvID5i Dg22RDniKQMOtSRCs0YcLLy6Cg1uT86h6673m3oeOwA/SdQV4w1NQxFvd/zGONPbXRl1 bN56jLTUmYkniJp3zjjghJ9MlNnpvkbCh2EcaX/UsQM44myE0BwErImv0BQoGJJJn3c9 gTrA== 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=uykaDMcpqeoA5WJe89EKlnsNTr7InlN+MhMLbfxaFQM=; b=LDRYkLq/VkqKESo+p/hi/wx7OaV+QfpbWtHPRIVRHwQxJhiZrVzDz1N3AAFmGZPvX9 lTo0EG2EdYv9+RwTKPTe95Oc0IDTz2Yh2fkCT51CKTunI8xBYO0i9VctFNySKutd3cXT xofFyZYonV6TCRBMAminFr0Y9j/ShPYNH7BQO/fttKlZKydXa3/jXxCBJVm1deJWwqS/ IIpgunhJ1iVI5EPsjiOj6KI2RrCz77IcC0lAT/RjwCIUvv7GQwhfhYjmLtcIefFt8wKU 3tKb/0/aSBNHhOfgkuHNbOLlDZ8pcddgJneLe1XnTxw66uNcLtYc4O1PSJhKc8DeHBN3 3IxQ== 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 e1-v6si55740229plk.397.2018.06.07.08.47.25; Thu, 07 Jun 2018 08:47:40 -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 S934807AbeFGPqP (ORCPT + 99 others); Thu, 7 Jun 2018 11:46:15 -0400 Received: from mga09.intel.com ([134.134.136.24]:36283 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934492AbeFGOke (ORCPT ); Thu, 7 Jun 2018 10:40:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 07:40:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="47542292" Received: from 2b52.sc.intel.com ([143.183.136.51]) by orsmga008.jf.intel.com with ESMTP; 07 Jun 2018 07:40:32 -0700 From: Yu-cheng Yu To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , "H.J. Lu" , Vedvyas Shanbhogue , "Ravi V. Shankar" , Dave Hansen , Andy Lutomirski , Jonathan Corbet , Oleg Nesterov , Arnd Bergmann , Mike Kravetz Cc: Yu-cheng Yu Subject: [PATCH 3/9] mm: Introduce VM_SHSTK for shadow stack memory Date: Thu, 7 Jun 2018 07:36:59 -0700 Message-Id: <20180607143705.3531-4-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180607143705.3531-1-yu-cheng.yu@intel.com> References: <20180607143705.3531-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. A shadow stack PTE must be read-only and dirty. For non shadow stack, we use a spare bit of the 64-bit PTE for dirty. The PTE changes are in the next patch. There is no more spare bit in the 32-bit PTE (except for PAE) and the shadow stack is not implemented for the 32-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 02a616e2f17d..bf4388a8cc41 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -221,11 +221,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 */ #if defined(CONFIG_X86) @@ -257,6 +259,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 502d14189794..44c64711a309 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.15.1