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>
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
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
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
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
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
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