From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CCDEB21A0483A for ; Wed, 12 Apr 2017 22:24:03 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 12 Apr 2017 22:24:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,193,1488873600"; d="scan'208";a="1155196256" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 12 Apr 2017 22:24:02 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 12 Apr 2017 22:24:01 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Thu, 13 Apr 2017 13:23:59 +0800 From: "Gao, Liming" To: Leo Duran , "edk2-devel@ml01.01.org" CC: "Kinney, Michael D" , Brijesh Singh Thread-Topic: [PATCH v8] MdePkg: BaseIoLibIntrinsic (IoLib class) library Thread-Index: AQHSs5zayo1sA9A0Cky91n/surI/GqHCxQYg Date: Thu, 13 Apr 2017 05:23:58 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D71DDF6@shsmsx102.ccr.corp.intel.com> References: <1492008923-6566-1-git-send-email-leo.duran@amd.com> <1492008923-6566-2-git-send-email-leo.duran@amd.com> In-Reply-To: <1492008923-6566-2-git-send-email-leo.duran@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v8] MdePkg: BaseIoLibIntrinsic (IoLib class) library X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Apr 2017 05:24:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Push edk2 at b6d11d7c467810ea7f2e2eda46ef0bdc57bf1475.=20 >-----Original Message----- >From: Leo Duran [mailto:leo.duran@amd.com] >Sent: Wednesday, April 12, 2017 10:55 PM >To: edk2-devel@ml01.01.org >Cc: Leo Duran ; Kinney, Michael D >; Gao, Liming ; Brijesh >Singh >Subject: [PATCH v8] MdePkg: BaseIoLibIntrinsic (IoLib class) library > >This patch adds an SEV-specific .INF and corresponding assembly >files, to unroll REP INSx/OUTSx on IoRead/WriteFifo#() routines >when the SEV feature is enabled under a hypervisor environment. > >The new .INF only supports the IA32 and X64 architectures. > >Cc: Michael D Kinney >Cc: Liming Gao >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Brijesh Singh >Signed-off-by: Leo Duran >Reviewed-by: Liming Gao >--- > .../BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf | 59 ++++ > .../Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm | 299 >+++++++++++++++++++++ > .../Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm | 288 >++++++++++++++++++++ > MdePkg/MdePkg.dsc | 1 + > 4 files changed, 647 insertions(+) > create mode 100644 >MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf > create mode 100644 MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm > create mode 100644 MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm > >diff --git a/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf >b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf >new file mode 100644 >index 0000000..0eec896 >--- /dev/null >+++ b/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf >@@ -0,0 +1,59 @@ >+## @file >+# Instance of I/O Library using compiler intrinsics. >+# >+# I/O Library that uses compiler intrinsics to perform IN and OUT instru= ctions >+# for IA-32 and x64. >+# >+# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
>+# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. >+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
>+# >+# This program and the accompanying materials >+# are licensed and made available under the terms and conditions of the >BSD License >+# which accompanies this distribution. The full text of the license may = be >found at >+# http://opensource.org/licenses/bsd-license.php. >+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" >BASIS, >+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER >EXPRESS OR IMPLIED. >+# >+## >+ >+[Defines] >+ INF_VERSION =3D 0x00010005 >+ BASE_NAME =3D BaseIoLibIntrinsicSev >+ MODULE_UNI_FILE =3D BaseIoLibIntrinsic.uni >+ FILE_GUID =3D 93742f95-6e71-4581-b600-8e1da443f95a >+ MODULE_TYPE =3D BASE >+ VERSION_STRING =3D 1.0 >+ LIBRARY_CLASS =3D IoLib >+ >+ >+# >+# VALID_ARCHITECTURES =3D IA32 X64 >+# >+ >+[Sources] >+ IoLibMmioBuffer.c >+ BaseIoLibIntrinsicInternal.h >+ IoHighLevel.c >+ >+[Sources.IA32] >+ IoLibGcc.c | GCC >+ IoLibMsc.c | MSFT >+ IoLibIcc.c | INTEL >+ IoLib.c >+ Ia32/IoFifoSev.nasm >+ >+[Sources.X64] >+ IoLibGcc.c | GCC >+ IoLibMsc.c | MSFT >+ IoLibIcc.c | INTEL >+ IoLib.c >+ X64/IoFifoSev.nasm >+ >+[Packages] >+ MdePkg/MdePkg.dec >+ >+[LibraryClasses] >+ DebugLib >+ BaseLib >+ >diff --git a/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm >b/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm >new file mode 100644 >index 0000000..3e80c17 >--- /dev/null >+++ b/MdePkg/Library/BaseIoLibIntrinsic/Ia32/IoFifoSev.nasm >@@ -0,0 +1,299 @@ >+;------------------------------------------------------------------------= ------ >+; >+; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
>+; Copyright (c) 2017, AMD Incorporated. All rights reserved.
>+; >+; This program and the accompanying materials are licensed and made >available >+; under the terms and conditions of the BSD License which accompanies thi= s >+; distribution. The full text of the license may be found at >+; http://opensource.org/licenses/bsd-license.php. >+; >+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" >BASIS, >+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER >EXPRESS OR IMPLIED. >+; >+;------------------------------------------------------------------------= ------ >+ >+ SECTION .text >+ >+;------------------------------------------------------------------------= ------ >+; Check whether we need to unroll the String I/O under SEV guest >+; >+; Return // eax (1 - unroll, 0 - no unroll) >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(SevNoRepIo) >+ASM_PFX(SevNoRepIo): >+ >+ ; CPUID clobbers ebx, ecx and edx >+ push ebx >+ push ecx >+ push edx >+ >+ ; Check if we are running under hypervisor >+ ; CPUID(1).ECX Bit 31 >+ mov eax, 1 >+ cpuid >+ bt ecx, 31 >+ jnc @UseRepIo >+ >+ ; Check if we have Memory encryption CPUID leaf >+ mov eax, 0x80000000 >+ cpuid >+ cmp eax, 0x8000001f >+ jl @UseRepIo >+ >+ ; Check for memory encryption feature: >+ ; CPUID Fn8000_001F[EAX] - Bit 1 >+ ; >+ mov eax, 0x8000001f >+ cpuid >+ bt eax, 1 >+ jnc @UseRepIo >+ >+ ; Check if memory encryption is enabled >+ ; MSR_0xC0010131 - Bit 0 (SEV enabled) >+ ; MSR_0xC0010131 - Bit 1 (SEV-ES enabled) >+ mov ecx, 0xc0010131 >+ rdmsr >+ >+ ; Check for (SevEsEnabled =3D=3D 0 && SevEnabled =3D=3D 1) >+ and eax, 3 >+ cmp eax, 1 >+ je @SevNoRepIo_Done >+ >+@UseRepIo: >+ xor eax, eax >+ >+@SevNoRepIo_Done: >+ pop edx >+ pop ecx >+ pop ebx >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo8 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; OUT VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo8) >+ASM_PFX(IoReadFifo8): >+ push edi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov edi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo8_NoRep >+ >+ cld >+ rep insb >+ jmp @IoReadFifo8_Done >+ >+@IoReadFifo8_NoRep: >+ jecxz @IoReadFifo8_Done >+ >+@IoReadFifo8_Loop: >+ in al, dx >+ mov byte [edi], al >+ inc edi >+ loop @IoReadFifo8_Loop >+ >+@IoReadFifo8_Done: >+ pop edi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo16 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; OUT VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo16) >+ASM_PFX(IoReadFifo16): >+ push edi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov edi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo16_NoRep >+ >+ cld >+ rep insw >+ jmp @IoReadFifo16_Done >+ >+@IoReadFifo16_NoRep: >+ jecxz @IoReadFifo16_Done >+ >+@IoReadFifo16_Loop: >+ in ax, dx >+ mov word [edi], ax >+ add edi, 2 >+ loop @IoReadFifo16_Loop >+ >+@IoReadFifo16_Done: >+ pop edi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo32 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; OUT VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo32) >+ASM_PFX(IoReadFifo32): >+ push edi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov edi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo32_NoRep >+ >+ cld >+ rep insd >+ jmp @IoReadFifo32_Done >+ >+@IoReadFifo32_NoRep: >+ jecxz @IoReadFifo32_Done >+ >+@IoReadFifo32_Loop: >+ in eax, dx >+ mov dword [edi], eax >+ add edi, 4 >+ loop @IoReadFifo32_Loop >+ >+@IoReadFifo32_Done: >+ pop edi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo8 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; IN VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo8) >+ASM_PFX(IoWriteFifo8): >+ push esi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov esi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo8_NoRep >+ >+ cld >+ rep outsb >+ jmp @IoWriteFifo8_Done >+ >+@IoWriteFifo8_NoRep: >+ jecxz @IoWriteFifo8_Done >+ >+@IoWriteFifo8_Loop: >+ mov byte [esi], al >+ out dx, al >+ inc esi >+ loop @IoWriteFifo8_Loop >+ >+@IoWriteFifo8_Done: >+ pop esi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo16 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; IN VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo16) >+ASM_PFX(IoWriteFifo16): >+ push esi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov esi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo16_NoRep >+ >+ cld >+ rep outsw >+ jmp @IoWriteFifo16_Done >+ >+@IoWriteFifo16_NoRep: >+ jecxz @IoWriteFifo16_Done >+ >+@IoWriteFifo16_Loop: >+ mov word [esi], ax >+ out dx, ax >+ add esi, 2 >+ loop @IoWriteFifo16_Loop >+ >+@IoWriteFifo16_Done: >+ pop esi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo32 ( >+; IN UINTN Port, >+; IN UINTN Size, >+; IN VOID *Buffer >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo32) >+ASM_PFX(IoWriteFifo32): >+ push esi >+ mov dx, [esp + 8] >+ mov ecx, [esp + 12] >+ mov esi, [esp + 16] >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo32_NoRep >+ >+ cld >+ rep outsd >+ jmp @IoWriteFifo32_Done >+ >+@IoWriteFifo32_NoRep: >+ jecxz @IoWriteFifo32_Done >+ >+@IoWriteFifo32_Loop: >+ mov dword [esi], eax >+ out dx, eax >+ add esi, 4 >+ loop @IoWriteFifo32_Loop >+ >+@IoWriteFifo32_Done: >+ pop esi >+ ret >+ >diff --git a/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm >b/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm >new file mode 100644 >index 0000000..26e0166 >--- /dev/null >+++ b/MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm >@@ -0,0 +1,288 @@ >+;------------------------------------------------------------------------= ------ >+; >+; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
>+; Copyright (c) 2017, AMD Incorporated. All rights reserved.
>+; >+; This program and the accompanying materials are licensed and made >available >+; under the terms and conditions of the BSD License which accompanies thi= s >+; distribution. The full text of the license may be found at >+; http://opensource.org/licenses/bsd-license.php. >+; >+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" >BASIS, >+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER >EXPRESS OR IMPLIED. >+; >+;------------------------------------------------------------------------= ------ >+ >+ DEFAULT REL >+ SECTION .text >+ >+;------------------------------------------------------------------------= ------ >+; Check whether we need to unroll the String I/O in SEV guest >+; >+; Return // eax (1 - unroll, 0 - no unroll) >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(SevNoRepIo) >+ASM_PFX(SevNoRepIo): >+ >+ ; CPUID clobbers ebx, ecx and edx >+ push rbx >+ push rcx >+ push rdx >+ >+ ; Check if we are runing under hypervisor >+ ; CPUID(1).ECX Bit 31 >+ mov eax, 1 >+ cpuid >+ bt ecx, 31 >+ jnc @UseRepIo >+ >+ ; Check if we have Memory encryption CPUID leaf >+ mov eax, 0x80000000 >+ cpuid >+ cmp eax, 0x8000001f >+ jl @UseRepIo >+ >+ ; Check for memory encryption feature: >+ ; CPUID Fn8000_001F[EAX] - Bit 1 >+ ; >+ mov eax, 0x8000001f >+ cpuid >+ bt eax, 1 >+ jnc @UseRepIo >+ >+ ; Check if memory encryption is enabled >+ ; MSR_0xC0010131 - Bit 0 (SEV enabled) >+ ; MSR_0xC0010131 - Bit 1 (SEV-ES enabled) >+ mov ecx, 0xc0010131 >+ rdmsr >+ >+ ; Check for (SevEsEnabled =3D=3D 0 && SevEnabled =3D=3D 1) >+ and eax, 3 >+ cmp eax, 1 >+ je @SevNoRepIo_Done >+ >+@UseRepIo: >+ xor eax, eax >+ >+@SevNoRepIo_Done: >+ pop rdx >+ pop rcx >+ pop rbx >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo8 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; OUT VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo8) >+ASM_PFX(IoReadFifo8): >+ xchg rcx, rdx >+ xchg rdi, r8 ; rdi: buffer address; r8: save rdi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo8_NoRep >+ >+ cld >+ rep insb >+ jmp @IoReadFifo8_Done >+ >+@IoReadFifo8_NoRep: >+ jrcxz @IoReadFifo8_Done >+ >+@IoReadFifo8_Loop: >+ in al, dx >+ mov byte [rdi], al >+ inc rdi >+ loop @IoReadFifo8_Loop >+ >+@IoReadFifo8_Done: >+ mov rdi, r8 ; restore rdi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo16 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; OUT VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo16) >+ASM_PFX(IoReadFifo16): >+ xchg rcx, rdx >+ xchg rdi, r8 ; rdi: buffer address; r8: save rdi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo16_NoRep >+ >+ cld >+ rep insw >+ jmp @IoReadFifo16_Done >+ >+@IoReadFifo16_NoRep: >+ jrcxz @IoReadFifo16_Done >+ >+@IoReadFifo16_Loop: >+ in ax, dx >+ mov word [rdi], ax >+ add rdi, 2 >+ loop @IoReadFifo16_Loop >+ >+@IoReadFifo16_Done: >+ mov rdi, r8 ; restore rdi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoReadFifo32 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; OUT VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoReadFifo32) >+ASM_PFX(IoReadFifo32): >+ xchg rcx, rdx >+ xchg rdi, r8 ; rdi: buffer address; r8: save rdi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoReadFifo32_NoRep >+ >+ cld >+ rep insd >+ jmp @IoReadFifo32_Done >+ >+@IoReadFifo32_NoRep: >+ jrcxz @IoReadFifo32_Done >+ >+@IoReadFifo32_Loop: >+ in eax, dx >+ mov dword [rdi], eax >+ add rdi, 4 >+ loop @IoReadFifo32_Loop >+ >+@IoReadFifo32_Done: >+ mov rdi, r8 ; restore rdi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo8 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; IN VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo8) >+ASM_PFX(IoWriteFifo8): >+ xchg rcx, rdx >+ xchg rsi, r8 ; rsi: buffer address; r8: save rsi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo8_NoRep >+ >+ cld >+ rep outsb >+ jmp @IoWriteFifo8_Done >+ >+@IoWriteFifo8_NoRep: >+ jrcxz @IoWriteFifo8_Done >+ >+@IoWriteFifo8_Loop: >+ mov byte [rsi], al >+ out dx, al >+ inc rsi >+ loop @IoWriteFifo8_Loop >+ >+@IoWriteFifo8_Done: >+ mov rsi, r8 ; restore rsi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo16 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; IN VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo16) >+ASM_PFX(IoWriteFifo16): >+ xchg rcx, rdx >+ xchg rsi, r8 ; rsi: buffer address; r8: save rsi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo16_NoRep >+ >+ cld >+ rep outsw >+ jmp @IoWriteFifo16_Done >+ >+@IoWriteFifo16_NoRep: >+ jrcxz @IoWriteFifo16_Done >+ >+@IoWriteFifo16_Loop: >+ mov word [rsi], ax >+ out dx, ax >+ add rsi, 2 >+ loop @IoWriteFifo16_Loop >+ >+@IoWriteFifo16_Done: >+ mov rsi, r8 ; restore rsi >+ ret >+ >+;------------------------------------------------------------------------= ------ >+; VOID >+; EFIAPI >+; IoWriteFifo32 ( >+; IN UINTN Port, // rcx >+; IN UINTN Size, // rdx >+; IN VOID *Buffer // r8 >+; ); >+;------------------------------------------------------------------------= ------ >+global ASM_PFX(IoWriteFifo32) >+ASM_PFX(IoWriteFifo32): >+ xchg rcx, rdx >+ xchg rsi, r8 ; rsi: buffer address; r8: save rsi >+ >+ ; Check if we need to unroll String I/O >+ call ASM_PFX(SevNoRepIo) >+ test eax, eax >+ jnz @IoWriteFifo32_NoRep >+ >+ cld >+ rep outsd >+ jmp @IoWriteFifo32_Done >+ >+@IoWriteFifo32_NoRep: >+ jrcxz @IoWriteFifo32_Done >+ >+@IoWriteFifo32_Loop: >+ mov dword [rsi], eax >+ out dx, eax >+ add rsi, 4 >+ loop @IoWriteFifo32_Loop >+ >+@IoWriteFifo32_Done: >+ mov rsi, r8 ; restore rsi >+ ret >+ >diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc >index 2144979..8b69de3 100644 >--- a/MdePkg/MdePkg.dsc >+++ b/MdePkg/MdePkg.dsc >@@ -134,6 +134,7 @@ > > [Components.IA32, Components.X64] > MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf >+ MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf > MdePkg/Library/BaseMemoryLibMmx/BaseMemoryLibMmx.inf > MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf > MdePkg/Library/BaseMemoryLibOptPei/BaseMemoryLibOptPei.inf >-- >2.7.4