* [PATCH V2] x86/sev-es: Fix SEV-ES OUT/IN immediate opcode vc handling
@ 2021-01-05 16:33 Peter Gonda
2021-01-05 18:05 ` [tip: x86/urgent] " tip-bot2 for Peter Gonda
0 siblings, 1 reply; 2+ messages in thread
From: Peter Gonda @ 2021-01-05 16:33 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Borislav Petkov
Cc: Peter Gonda, Joerg Roedel, Tom Lendacky, linux-kernel, x86,
David Rientjes
The IN and OUT immediate instructions only use an 8-bit immediate. The
current VC handler uses the entire 32-bit immediate value. These
instructions only set the first bytes.
Tested with a loop back port with "outb %0,$0xe0". Before the port seen
by KVM was 0xffffffffffffffe0 instead of 0xe0. After the correct port
was seen by KVM and the guests loop back OUT then IN were equal.
Fixes: 25189d08e5168 ("x86/sev-es: Add support for handling IOIO exceptions")
Signed-off-by: Peter Gonda <pgonda@google.com>
Acked-by: David Rientjes <rientjes@google.com>
---
arch/x86/kernel/sev-es-shared.c | 8 ++++++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/sev-es-shared.c b/arch/x86/kernel/sev-es-shared.c
index 7d04b356d44d..6c790377c55c 100644
--- a/arch/x86/kernel/sev-es-shared.c
+++ b/arch/x86/kernel/sev-es-shared.c
@@ -305,14 +305,14 @@ static enum es_result vc_ioio_exitinfo(struct es_em_ctxt *ctxt, u64 *exitinfo)
case 0xe4:
case 0xe5:
*exitinfo |= IOIO_TYPE_IN;
- *exitinfo |= (u64)insn->immediate.value << 16;
+ *exitinfo |= (u8)insn->immediate.value << 16;
break;
/* OUT immediate opcodes */
case 0xe6:
case 0xe7:
*exitinfo |= IOIO_TYPE_OUT;
- *exitinfo |= (u64)insn->immediate.value << 16;
+ *exitinfo |= (u8)insn->immediate.value << 16;
break;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip: x86/urgent] x86/sev-es: Fix SEV-ES OUT/IN immediate opcode vc handling
2021-01-05 16:33 [PATCH V2] x86/sev-es: Fix SEV-ES OUT/IN immediate opcode vc handling Peter Gonda
@ 2021-01-05 18:05 ` tip-bot2 for Peter Gonda
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Peter Gonda @ 2021-01-05 18:05 UTC (permalink / raw)
To: linux-tip-commits
Cc: Peter Gonda, Borislav Petkov, David Rientjes, x86, linux-kernel
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: a8f7e08a81708920a928664a865208fdf451c49f
Gitweb: https://git.kernel.org/tip/a8f7e08a81708920a928664a865208fdf451c49f
Author: Peter Gonda <pgonda@google.com>
AuthorDate: Tue, 05 Jan 2021 08:33:11 -08:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 05 Jan 2021 18:55:00 +01:00
x86/sev-es: Fix SEV-ES OUT/IN immediate opcode vc handling
The IN and OUT instructions with port address as an immediate operand
only use an 8-bit immediate (imm8). The current VC handler uses the
entire 32-bit immediate value but these instructions only set the first
bytes.
Cast the operand to an u8 for that.
[ bp: Massage commit message. ]
Fixes: 25189d08e5168 ("x86/sev-es: Add support for handling IOIO exceptions")
Signed-off-by: Peter Gonda <pgonda@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: David Rientjes <rientjes@google.com>
Link: https://lkml.kernel.org/r/20210105163311.221490-1-pgonda@google.com
---
arch/x86/kernel/sev-es-shared.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/sev-es-shared.c b/arch/x86/kernel/sev-es-shared.c
index 7d04b35..cdc04d0 100644
--- a/arch/x86/kernel/sev-es-shared.c
+++ b/arch/x86/kernel/sev-es-shared.c
@@ -305,14 +305,14 @@ static enum es_result vc_ioio_exitinfo(struct es_em_ctxt *ctxt, u64 *exitinfo)
case 0xe4:
case 0xe5:
*exitinfo |= IOIO_TYPE_IN;
- *exitinfo |= (u64)insn->immediate.value << 16;
+ *exitinfo |= (u8)insn->immediate.value << 16;
break;
/* OUT immediate opcodes */
case 0xe6:
case 0xe7:
*exitinfo |= IOIO_TYPE_OUT;
- *exitinfo |= (u64)insn->immediate.value << 16;
+ *exitinfo |= (u8)insn->immediate.value << 16;
break;
/* IN register opcodes */
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-05 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 16:33 [PATCH V2] x86/sev-es: Fix SEV-ES OUT/IN immediate opcode vc handling Peter Gonda
2021-01-05 18:05 ` [tip: x86/urgent] " tip-bot2 for Peter Gonda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).