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 6F8E421E3EA76 for ; Mon, 4 Sep 2017 18:37:39 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 04 Sep 2017 18:40:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,477,1498546800"; d="scan'208";a="148090783" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga006.fm.intel.com with ESMTP; 04 Sep 2017 18:40:27 -0700 Received: from fmsmsx126.amr.corp.intel.com (10.18.125.43) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Sep 2017 18:40:27 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX126.amr.corp.intel.com (10.18.125.43) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 4 Sep 2017 18:40:27 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.39]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.219]) with mapi id 14.03.0319.002; Tue, 5 Sep 2017 09:40:25 +0800 From: "Gao, Liming" To: Laszlo Ersek , edk2-devel-01 CC: "Kinney, Michael D" , "Justen, Jordan L" Thread-Topic: [edk2] [PATCH 1/2] MdePkg/BaseIoLibIntrinsic: fix SEV (=unrolled) variants of IoWriteFifoXX() Thread-Index: AQHTJZaQF0LEmVZWIE6FdmkYZ2O37KKlhLIg Date: Tue, 5 Sep 2017 01:40:24 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D7892CD@shsmsx102.ccr.corp.intel.com> References: <20170904155717.31591-1-lersek@redhat.com> <20170904155717.31591-2-lersek@redhat.com> In-Reply-To: <20170904155717.31591-2-lersek@redhat.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 1/2] MdePkg/BaseIoLibIntrinsic: fix SEV (=unrolled) variants of IoWriteFifoXX() 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: Tue, 05 Sep 2017 01:37:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of >Laszlo Ersek >Sent: Monday, September 04, 2017 11:57 PM >To: edk2-devel-01 >Cc: Kinney, Michael D ; Justen, Jordan L >; Gao, Liming >Subject: [edk2] [PATCH 1/2] MdePkg/BaseIoLibIntrinsic: fix SEV (=3Dunrolle= d) >variants of IoWriteFifoXX() > >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 >Cc: Jordan Justen >Cc: Liming Gao >Cc: Michael D Kinney >Fixes: b6d11d7c467810ea7f2e2eda46ef0bdc57bf1475 >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Laszlo Ersek >--- > 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 > > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel