lkml.org 
[lkml]   [2020]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v15 5/7] x86/cet/ibt: Update arch_prctl functions for Indirect Branch Tracking
Date
From: "H.J. Lu" <hjl.tools@gmail.com>

Update ARCH_X86_CET_STATUS and ARCH_X86_CET_DISABLE for Indirect Branch
Tracking.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
---
arch/x86/kernel/cet_prctl.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cet_prctl.c b/arch/x86/kernel/cet_prctl.c
index bd5ad11763e4..0af1ec5d028f 100644
--- a/arch/x86/kernel/cet_prctl.c
+++ b/arch/x86/kernel/cet_prctl.c
@@ -22,6 +22,9 @@ static int copy_status_to_user(struct cet_status *cet, u64 arg2)
buf[2] = (u64)cet->shstk_size;
}

+ if (cet->ibt_enabled)
+ buf[0] |= GNU_PROPERTY_X86_FEATURE_1_IBT;
+
return copy_to_user((u64 __user *)arg2, buf, sizeof(buf));
}

@@ -42,7 +45,8 @@ int prctl_cet(int option, u64 arg2)
if (option == ARCH_X86_CET_STATUS)
return copy_status_to_user(cet, arg2);

- if (!static_cpu_has(X86_FEATURE_SHSTK))
+ if (!static_cpu_has(X86_FEATURE_SHSTK) &&
+ !static_cpu_has(X86_FEATURE_IBT))
return -EOPNOTSUPP;

switch (option) {
@@ -56,6 +60,8 @@ int prctl_cet(int option, u64 arg2)
return -EINVAL;
if (features & GNU_PROPERTY_X86_FEATURE_1_SHSTK)
cet_disable_shstk();
+ if (features & GNU_PROPERTY_X86_FEATURE_1_IBT)
+ cet_disable_ibt();
return 0;

case ARCH_X86_CET_LOCK:
--
2.21.0
\
 
 \ /
  Last update: 2020-11-10 17:25    [W:0.055 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site