Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3670721ybd; Fri, 28 Jun 2019 12:52:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw26UCOSfm7gBUkhr75KhTZ5jdwIuVqhu5M93MbaMMq9FnLgSzYmYOYGx+EXMCWXsXXj8ky X-Received: by 2002:a17:902:7c8e:: with SMTP id y14mr12786436pll.298.1561751569539; Fri, 28 Jun 2019 12:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561751569; cv=none; d=google.com; s=arc-20160816; b=J1eJW/0jrUxGxlwHfclOmt8amWhO09tIWHzb/UBbRH5x4DSyH4cGumRuY8NQUVWUbX K7bu/yz6dphIIZlg3xudUvWq0OEFRCDEmewRTgGoSpBnMjrrGukhXmBX9hhe95SrFWa8 7u2UH9L6sY/Vpc1fIdrqcYdEBih7C3ELfU4rTuqR1hdP6Z4wcIznJXr0VssoyISCEUu0 eInCNhIDGJVBPtolZIv3ZAtO0u6M5D88wBBSf03ViIffzo1e0cDXUlQQUJGf50ZYUIVL FMiw8lkegoJ5zjv2w5dt7l+RylyH9njMj4sVypdTO/c87TRfnFSO/vGRY+de1f/oZL4u bGNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=OdQ9J3Abw5fE03GEt4uo8Rr+djgBr/SQIpVAY9l/fgk=; b=TmsBl6vVSfI1VkX+OXpcfU9lFzIHCi5zKI0TpSlbCSrX7aQ3+0n0mueVakYCXAAoE8 1YzHg9maiLSy+37icxW1D3xtGUo70rQrEYaao2WckHneOSHcNi5uGww+GmISewBLDtxr xEubgNz01d1ArDw/J4m5iRPOVSb7sQd4QlAiLQdEkf75os4fd2p4XHHYVmGzBiZB1KrL VVatln0DnblJpG+6EsqZR+5S0z0xMnb4CitIwSGV+8zCMDypXBgL3vE+r5ORQlgbZ+7e WtWmCS8gulHNBwEEKyid/bGte+qsumfnb1PTHRJgRyz1tb0PgAAIm3npTPI2I3GXoctP zAvw== 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 q19si2791251pgv.180.2019.06.28.12.52.33; Fri, 28 Jun 2019 12:52:49 -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 S1727095AbfF1Tu2 (ORCPT + 99 others); Fri, 28 Jun 2019 15:50:28 -0400 Received: from mga05.intel.com ([192.55.52.43]:42462 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726819AbfF1Tu1 (ORCPT ); Fri, 28 Jun 2019 15:50:27 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jun 2019 12:50:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,428,1557212400"; d="scan'208";a="164756004" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by fmsmga007.fm.intel.com with ESMTP; 28 Jun 2019 12:50:26 -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: [RFC PATCH 1/3] mm: Introduce VM_IBT for CET legacy code bitmap Date: Fri, 28 Jun 2019 12:41:56 -0700 Message-Id: <20190628194158.2431-1-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The previous discussion of the IBT legacy code bitmap is here: https://lkml.org/lkml/2019/6/6/1032 When CET Indirect Branch Tracking (IBT) is enabled, the processor expects every branch target is an ENDBR instruction, or the target's address is marked as legacy in the legacy code bitmap. The bitmap covers the whole user-mode address space (TASK_SIZE_MAX for 64-bit, TASK_SIZE for IA32), and each bit represents one page of linear address range. This patch introduces VM_IBT for the bitmap. Signed-off-by: Yu-cheng Yu --- fs/proc/task_mmu.c | 3 +++ include/linux/mm.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 66725e262a77..d707390285d3 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -663,6 +663,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) #endif /* CONFIG_ARCH_HAS_PKEYS */ #ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER [ilog2(VM_SHSTK)] = "ss", +#endif +#ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER + [ilog2(VM_IBT)] = "bt", #endif }; size_t i; diff --git a/include/linux/mm.h b/include/linux/mm.h index 921bae5fa7ab..a8da5bdfd7c9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -299,12 +299,14 @@ extern unsigned int kobjsize(const void *objp); #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_BIT_6 38 /* 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) +#define VM_HIGH_ARCH_6 BIT(VM_HIGH_ARCH_BIT_6) #endif /* CONFIG_ARCH_USES_HIGH_VMA_FLAGS */ #ifdef CONFIG_ARCH_HAS_PKEYS @@ -348,6 +350,12 @@ extern unsigned int kobjsize(const void *objp); # define VM_SHSTK VM_NONE #endif +#ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER +# define VM_IBT VM_HIGH_ARCH_6 +#else +# define VM_IBT VM_NONE +#endif + #ifndef VM_GROWSUP # define VM_GROWSUP VM_NONE #endif -- 2.17.1