lkml.org 
[lkml]   [2020]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 40/62] x86/sev-es: Filter exceptions not supported from user-space
Date
From: Joerg Roedel <jroedel@suse.de>

Currently only CPUID caused #VC exceptions are supported from
user-space. Filter the others out early.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
arch/x86/kernel/sev-es.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c
index d128a9397639..84b5b8f7897a 100644
--- a/arch/x86/kernel/sev-es.c
+++ b/arch/x86/kernel/sev-es.c
@@ -209,6 +209,26 @@ static enum es_result handle_vc_exception(struct es_em_ctxt *ctxt,
return result;
}

+static enum es_result context_filter(struct pt_regs *regs, long exit_code)
+{
+ enum es_result r = ES_OK;
+
+ if (user_mode(regs)) {
+ switch (exit_code) {
+ /* List of #VC exit-codes we support in user-space */
+ case SVM_EXIT_EXCP_BASE ... SVM_EXIT_LAST_EXCP:
+ case SVM_EXIT_CPUID:
+ r = ES_OK;
+ break;
+ default:
+ r = ES_UNSUPPORTED;
+ break;
+ }
+ }
+
+ return r;
+}
+
static void forward_exception(struct es_em_ctxt *ctxt)
{
long error_code = ctxt->fi.error_code;
@@ -245,6 +265,10 @@ dotraplinkage void do_vmm_communication(struct pt_regs *regs, unsigned long exit
ghcb_invalidate(ghcb);
result = init_em_ctxt(&ctxt, regs, exit_code);

+ /* Check if the exception is supported in the context we came from. */
+ if (result == ES_OK)
+ result = context_filter(regs, exit_code);
+
if (result == ES_OK)
result = handle_vc_exception(&ctxt, ghcb, exit_code);

--
2.17.1
\
 
 \ /
  Last update: 2020-02-11 14:54    [W:0.216 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site