1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
4 ; Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
6 ; This program and the accompanying materials are licensed and made available
7 ; under the terms and conditions of the BSD License which accompanies this
8 ; distribution. The full text of the license may be found at
9 ; http://opensource.org/licenses/bsd-license.php.
11 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 ;------------------------------------------------------------------------------
18 ;------------------------------------------------------------------------------
19 ; Check whether we need to unroll the String I/O under SEV guest
21 ; Return // eax (1 - unroll, 0 - no unroll)
22 ;------------------------------------------------------------------------------
23 global ASM_PFX(SevNoRepIo)
26 ; CPUID clobbers ebx, ecx and edx
31 ; Check if we are running under hypervisor
38 ; Check if we have Memory encryption CPUID leaf
44 ; Check for memory encryption feature:
45 ; CPUID Fn8000_001F[EAX] - Bit 1
52 ; Check if memory encryption is enabled
53 ; MSR_0xC0010131 - Bit 0 (SEV enabled)
54 ; MSR_0xC0010131 - Bit 1 (SEV-ES enabled)
58 ; Check for (SevEsEnabled == 0 && SevEnabled == 1)
72 ;------------------------------------------------------------------------------
80 ;------------------------------------------------------------------------------
81 global ASM_PFX(IoReadFifo8)
88 ; Check if we need to unroll String I/O
89 call ASM_PFX(SevNoRepIo)
91 jnz @IoReadFifo8_NoRep
98 jecxz @IoReadFifo8_Done
104 loop @IoReadFifo8_Loop
110 ;------------------------------------------------------------------------------
118 ;------------------------------------------------------------------------------
119 global ASM_PFX(IoReadFifo16)
120 ASM_PFX(IoReadFifo16):
126 ; Check if we need to unroll String I/O
127 call ASM_PFX(SevNoRepIo)
129 jnz @IoReadFifo16_NoRep
133 jmp @IoReadFifo16_Done
136 jecxz @IoReadFifo16_Done
142 loop @IoReadFifo16_Loop
148 ;------------------------------------------------------------------------------
156 ;------------------------------------------------------------------------------
157 global ASM_PFX(IoReadFifo32)
158 ASM_PFX(IoReadFifo32):
164 ; Check if we need to unroll String I/O
165 call ASM_PFX(SevNoRepIo)
167 jnz @IoReadFifo32_NoRep
171 jmp @IoReadFifo32_Done
174 jecxz @IoReadFifo32_Done
180 loop @IoReadFifo32_Loop
186 ;------------------------------------------------------------------------------
194 ;------------------------------------------------------------------------------
195 global ASM_PFX(IoWriteFifo8)
196 ASM_PFX(IoWriteFifo8):
202 ; Check if we need to unroll String I/O
203 call ASM_PFX(SevNoRepIo)
205 jnz @IoWriteFifo8_NoRep
209 jmp @IoWriteFifo8_Done
212 jecxz @IoWriteFifo8_Done
218 loop @IoWriteFifo8_Loop
224 ;------------------------------------------------------------------------------
232 ;------------------------------------------------------------------------------
233 global ASM_PFX(IoWriteFifo16)
234 ASM_PFX(IoWriteFifo16):
240 ; Check if we need to unroll String I/O
241 call ASM_PFX(SevNoRepIo)
243 jnz @IoWriteFifo16_NoRep
247 jmp @IoWriteFifo16_Done
249 @IoWriteFifo16_NoRep:
250 jecxz @IoWriteFifo16_Done
256 loop @IoWriteFifo16_Loop
262 ;------------------------------------------------------------------------------
270 ;------------------------------------------------------------------------------
271 global ASM_PFX(IoWriteFifo32)
272 ASM_PFX(IoWriteFifo32):
278 ; Check if we need to unroll String I/O
279 call ASM_PFX(SevNoRepIo)
281 jnz @IoWriteFifo32_NoRep
285 jmp @IoWriteFifo32_Done
287 @IoWriteFifo32_NoRep:
288 jecxz @IoWriteFifo32_Done
294 loop @IoWriteFifo32_Loop