lkml.org 
[lkml]   [2022]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[patch 30/38] x86/retbleed: Add SKL call thunk
Date
Add the actual SKL call thunk for call depth accounting.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/callthunks.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -52,6 +52,24 @@ struct thunk_desc {

static struct thunk_desc callthunk_desc __ro_after_init;

+asm (
+ ".pushsection .rodata \n"
+ ".global skl_call_thunk_template \n"
+ "skl_call_thunk_template: \n"
+ __stringify(INCREMENT_CALL_DEPTH)" \n"
+ ".global skl_call_thunk_tail \n"
+ "skl_call_thunk_tail: \n"
+ ".popsection \n"
+);
+
+extern u8 skl_call_thunk_template[];
+extern u8 skl_call_thunk_tail[];
+
+#define SKL_TMPL_SIZE \
+ ((unsigned int)(skl_call_thunk_tail - skl_call_thunk_template))
+#define SKL_CALLTHUNK_CODE_SIZE (SKL_TMPL_SIZE + JMP32_INSN_SIZE + INT3_INSN_SIZE)
+#define SKL_CALLTHUNK_SIZE roundup_pow_of_two(SKL_CALLTHUNK_CODE_SIZE)
+
struct thunk_mem {
void *base;
unsigned int size;
@@ -447,6 +465,12 @@ static __init noinline void callthunks_i
{
int ret;

+ if (cpu_feature_enabled(X86_FEATURE_CALL_DEPTH)) {
+ callthunk_desc.template = skl_call_thunk_template;
+ callthunk_desc.template_size = SKL_TMPL_SIZE;
+ callthunk_desc.thunk_size = SKL_CALLTHUNK_SIZE;
+ }
+
if (!callthunk_desc.template)
return;

\
 
 \ /
  Last update: 2022-07-17 01:20    [W:0.520 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site