From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@lists.01.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Liming Gao <liming.gao@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>
Subject: [PATCH 1/2] MdePkg/BaseIoLibIntrinsic: fix SEV (=unrolled) variants of IoWriteFifoXX()
Date: Mon, 4 Sep 2017 17:57:16 +0200 [thread overview]
Message-ID: <20170904155717.31591-2-lersek@redhat.com> (raw)
In-Reply-To: <20170904155717.31591-1-lersek@redhat.com>
In commit b6d11d7c4678 ("MdePkg: BaseIoLibIntrinsic (IoLib class)
library", 2017-04-12), the MOV instructions in the write loops were
probably copied from the read loops. However, the operand order was not
adjusted.
As a result, the IoWriteFifoXX() routines, when invoked in SEV guests, now
overwrite the source buffer with value 0x01 / 0x0001 / 0x00000001 -- the
SevNoRepIo() function returns value 1 in EAX, in SEV guests --, and write
the same value to the target IO port.
Fix this by putting the target operand (AL / AX / EAX) first, and the
source operand (BYTE / WORD / DWORD [ESI/RSI]) second.
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Fixes: b6d11d7c467810ea7f2e2eda46ef0bdc57bf1475
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm | 6 +++---
MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm b/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm
index 3e80c17d04a3..4b2af807cff8 100644
--- a/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm
+++ b/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm
@@ -212,7 +212,7 @@ ASM_PFX(IoWriteFifo8):
jecxz @IoWriteFifo8_Done
@IoWriteFifo8_Loop:
- mov byte [esi], al
+ mov al, byte [esi]
out dx, al
inc esi
loop @IoWriteFifo8_Loop
@@ -250,7 +250,7 @@ ASM_PFX(IoWriteFifo16):
jecxz @IoWriteFifo16_Done
@IoWriteFifo16_Loop:
- mov word [esi], ax
+ mov ax, word [esi]
out dx, ax
add esi, 2
loop @IoWriteFifo16_Loop
@@ -288,7 +288,7 @@ ASM_PFX(IoWriteFifo32):
jecxz @IoWriteFifo32_Done
@IoWriteFifo32_Loop:
- mov dword [esi], eax
+ mov eax, dword [esi]
out dx, eax
add esi, 4
loop @IoWriteFifo32_Loop
diff --git a/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm b/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm
index 26e016625b72..4d86a6cd5330 100644
--- a/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm
+++ b/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm
@@ -205,7 +205,7 @@ ASM_PFX(IoWriteFifo8):
jrcxz @IoWriteFifo8_Done
@IoWriteFifo8_Loop:
- mov byte [rsi], al
+ mov al, byte [rsi]
out dx, al
inc rsi
loop @IoWriteFifo8_Loop
@@ -241,7 +241,7 @@ ASM_PFX(IoWriteFifo16):
jrcxz @IoWriteFifo16_Done
@IoWriteFifo16_Loop:
- mov word [rsi], ax
+ mov ax, word [rsi]
out dx, ax
add rsi, 2
loop @IoWriteFifo16_Loop
@@ -277,7 +277,7 @@ ASM_PFX(IoWriteFifo32):
jrcxz @IoWriteFifo32_Done
@IoWriteFifo32_Loop:
- mov dword [rsi], eax
+ mov eax, dword [rsi]
out dx, eax
add rsi, 4
loop @IoWriteFifo32_Loop
--
2.14.1.3.gb7cf6e02401b
next prev parent reply other threads:[~2017-09-04 15:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 15:57 [PATCH 0/2] MdePkg, OvmfPkg: fix IoWriteFifo8(), and print debug messages with it Laszlo Ersek
2017-09-04 15:57 ` Laszlo Ersek [this message]
2017-09-05 1:40 ` [PATCH 1/2] MdePkg/BaseIoLibIntrinsic: fix SEV (=unrolled) variants of IoWriteFifoXX() Gao, Liming
2017-09-05 14:32 ` Brijesh Singh
2017-09-04 15:57 ` [PATCH 2/2] OvmfPkg/PlatformDebugLibIoPort: write messages with IoWriteFifo8() Laszlo Ersek
2017-09-05 14:33 ` Brijesh Singh
2017-09-11 20:30 ` [PATCH 0/2] MdePkg, OvmfPkg: fix IoWriteFifo8(), and print debug messages with it Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170904155717.31591-2-lersek@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox