]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseIoLibIntrinsic: fix SEV (=unrolled) variants of IoWriteFifoXX()
authorLaszlo Ersek <lersek@redhat.com>
Mon, 4 Sep 2017 15:09:18 +0000 (17:09 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Mon, 11 Sep 2017 20:28:05 +0000 (22:28 +0200)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm
MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm

index 3e80c17d04a33b9d52051f9d59a719061e03ec4c..4b2af807cff8e87f34d14639b972dd126e51ead8 100644 (file)
@@ -212,7 +212,7 @@ ASM_PFX(IoWriteFifo8):
     jecxz   @IoWriteFifo8_Done\r
 \r
 @IoWriteFifo8_Loop:\r
-    mov     byte [esi], al\r
+    mov     al, byte [esi]\r
     out     dx, al\r
     inc     esi\r
     loop    @IoWriteFifo8_Loop\r
@@ -250,7 +250,7 @@ ASM_PFX(IoWriteFifo16):
     jecxz   @IoWriteFifo16_Done\r
 \r
 @IoWriteFifo16_Loop:\r
-    mov     word [esi], ax\r
+    mov     ax, word [esi]\r
     out     dx, ax\r
     add     esi, 2\r
     loop    @IoWriteFifo16_Loop\r
@@ -288,7 +288,7 @@ ASM_PFX(IoWriteFifo32):
     jecxz   @IoWriteFifo32_Done\r
 \r
 @IoWriteFifo32_Loop:\r
-    mov     dword [esi], eax\r
+    mov     eax, dword [esi]\r
     out     dx, eax\r
     add     esi, 4\r
     loop    @IoWriteFifo32_Loop\r
index 26e016625b722f31813f47cc59c5d60e64732e51..4d86a6cd5330f678c8b046545ead2aa70dcc02a8 100644 (file)
@@ -205,7 +205,7 @@ ASM_PFX(IoWriteFifo8):
     jrcxz   @IoWriteFifo8_Done\r
 \r
 @IoWriteFifo8_Loop:\r
-    mov     byte [rsi], al\r
+    mov     al, byte [rsi]\r
     out     dx, al\r
     inc     rsi\r
     loop    @IoWriteFifo8_Loop\r
@@ -241,7 +241,7 @@ ASM_PFX(IoWriteFifo16):
     jrcxz   @IoWriteFifo16_Done\r
 \r
 @IoWriteFifo16_Loop:\r
-    mov     word [rsi], ax\r
+    mov     ax, word [rsi]\r
     out     dx, ax\r
     add     rsi, 2\r
     loop    @IoWriteFifo16_Loop\r
@@ -277,7 +277,7 @@ ASM_PFX(IoWriteFifo32):
     jrcxz   @IoWriteFifo32_Done\r
 \r
 @IoWriteFifo32_Loop:\r
-    mov     dword [rsi], eax\r
+    mov     eax, dword [rsi]\r
     out     dx, eax\r
     add     rsi, 4\r
     loop    @IoWriteFifo32_Loop\r