x86/sev-es: Remove subtraction of res variable
Borislav Petkov
maintainerPATCH 1/1 x86/sev-es: Remove subtraction of res variable
From: Borislav Petkov <[email protected]>
vc_decode_insn() calls copy_from_kernel_nofault() by way of vc_fetch_insn_kernel() to fetch 15 bytes max of opcodes to decode.
copy_from_kernel_nofault() returns negative on error and 0 on success. The error case is handled by returning ES_EXCEPTION.
In the success case, the ret variable which contains the return value is 0 so there's no need to subtract it from MAX_INSN_SIZE when initializing the insn buffer for further decoding. Remove it.
No functional changes.
--- arch/x86/kernel/sev-es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/sev-es.c +1 -1
@@ -267,7 +267,7 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)return ES_EXCEPTION ; } -insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE - res,1 ); +insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE ,1 );insn_get_length (&ctxt->insn); }
Signature · 1 line
2.29.2
Quoted 8 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
vc_decode_insn()callscopy_from_kernel_nofault()by way ofvc_fetch_insn_kernel()to fetch 15 bytes max of opcodes to decode.
copy_from_kernel_nofault()returns negative on error and 0 on success. The error case is handled by returningES_EXCEPTION.
Quoted 7 lines
In the success case, the ret variable which contains the return value is 0 so there's no need to subtract it from
MAX_INSN_SIZEwhen initializing the insn buffer for further decoding. Remove it.No functional changes.
Signed-off-by Borislav Petkov <[email protected]>
Quoted 19 lines
--- arch/x86/kernel/sev-es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kernel/sev-es.c +1
-1@@ -267,7 +267,7 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)return ES_EXCEPTION ; } -insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE - res,1 ); +insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE ,1 );insn_get_length (&ctxt->insn); }Signature · 1 line
2.29.2
The following commit has been merged into the x86/seves branch of tip:
The following commit has been merged into the x86/seves branch of tip:
Commit-ID: bb8dc26937d51b3421b26d9d91cdad3484c34b7e Gitweb: https://git.kernel.org/tip/bb8dc26937d51b3421b26d9d91cdad3484c34b7e Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 23 Feb 2021 12:03:19 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Mon, 01 Mar 2021 12:40:22 +01:00
x86/sev-es: Remove subtraction of res variable
vc_decode_insn() calls copy_from_kernel_nofault() by way of vc_fetch_insn_kernel() to fetch 15 bytes max of opcodes to decode.
copy_from_kernel_nofault() returns negative on error and 0 on success. The error case is handled by returning ES_EXCEPTION.
In the success case, the ret variable which contains the return value is 0 so there's no need to subtract it from MAX_INSN_SIZE when initializing the insn buffer for further decoding. Remove it.
No functional changes.
--- arch/x86/kernel/sev-es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/sev-es.c +1 -1
@@ -267,7 +267,7 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)return ES_EXCEPTION ; } -insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE - res,1 ); +insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE ,1 );insn_get_length (&ctxt->insn); }
The following commit has been merged into the x86/seves branch of tip:
The following commit has been merged into the x86/seves branch of tip:
Commit-ID: f3db3365c069c2a8505cdee8033fe3d22d2fe6c0 Gitweb: https://git.kernel.org/tip/f3db3365c069c2a8505cdee8033fe3d22d2fe6c0 Author: Borislav Petkov <[email protected]> AuthorDate: Tue, 23 Feb 2021 12:03:19 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Sat, 06 Mar 2021 12:08:53 +01:00
x86/sev-es: Remove subtraction of res variable
vc_decode_insn() calls copy_from_kernel_nofault() by way of vc_fetch_insn_kernel() to fetch 15 bytes max of opcodes to decode.
copy_from_kernel_nofault() returns negative on error and 0 on success. The error case is handled by returning ES_EXCEPTION.
In the success case, the ret variable which contains the return value is 0 so there's no need to subtract it from MAX_INSN_SIZE when initializing the insn buffer for further decoding. Remove it.
No functional changes.
--- arch/x86/kernel/sev-es.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/sev-es.c +1 -1
@@ -267,7 +267,7 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt)return ES_EXCEPTION ; } -insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE - res,1 ); +insn_init (&ctxt->insn, buffer,MAX_INSN_SIZE ,1 );insn_get_length (&ctxt->insn); }