Commit 5e32c64b authored by Borislav Petkov's avatar Borislav Petkov

x86/sev-es: Convert to insn_decode()

Simplify code, no functional changes.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210304174237.31945-14-bp@alien8.de
parent 99e4b0de
...@@ -254,7 +254,6 @@ static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt, ...@@ -254,7 +254,6 @@ static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt,
static enum es_result __vc_decode_user_insn(struct es_em_ctxt *ctxt) static enum es_result __vc_decode_user_insn(struct es_em_ctxt *ctxt)
{ {
char buffer[MAX_INSN_SIZE]; char buffer[MAX_INSN_SIZE];
enum es_result ret;
int res; int res;
res = insn_fetch_from_user_inatomic(ctxt->regs, buffer); res = insn_fetch_from_user_inatomic(ctxt->regs, buffer);
...@@ -268,16 +267,16 @@ static enum es_result __vc_decode_user_insn(struct es_em_ctxt *ctxt) ...@@ -268,16 +267,16 @@ static enum es_result __vc_decode_user_insn(struct es_em_ctxt *ctxt)
if (!insn_decode_from_regs(&ctxt->insn, ctxt->regs, buffer, res)) if (!insn_decode_from_regs(&ctxt->insn, ctxt->regs, buffer, res))
return ES_DECODE_FAILED; return ES_DECODE_FAILED;
ret = ctxt->insn.immediate.got ? ES_OK : ES_DECODE_FAILED; if (ctxt->insn.immediate.got)
return ES_OK;
return ret; else
return ES_DECODE_FAILED;
} }
static enum es_result __vc_decode_kern_insn(struct es_em_ctxt *ctxt) static enum es_result __vc_decode_kern_insn(struct es_em_ctxt *ctxt)
{ {
char buffer[MAX_INSN_SIZE]; char buffer[MAX_INSN_SIZE];
enum es_result ret; int res, ret;
int res;
res = vc_fetch_insn_kernel(ctxt, buffer); res = vc_fetch_insn_kernel(ctxt, buffer);
if (res) { if (res) {
...@@ -287,12 +286,11 @@ static enum es_result __vc_decode_kern_insn(struct es_em_ctxt *ctxt) ...@@ -287,12 +286,11 @@ static enum es_result __vc_decode_kern_insn(struct es_em_ctxt *ctxt)
return ES_EXCEPTION; return ES_EXCEPTION;
} }
insn_init(&ctxt->insn, buffer, MAX_INSN_SIZE, 1); ret = insn_decode(&ctxt->insn, buffer, MAX_INSN_SIZE, INSN_MODE_64);
insn_get_length(&ctxt->insn); if (ret < 0)
return ES_DECODE_FAILED;
ret = ctxt->insn.immediate.got ? ES_OK : ES_DECODE_FAILED; else
return ES_OK;
return ret;
} }
static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt) static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment