<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div>
<div>
<div dir="ltr" style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Please fix this:</div>
<div dir="ltr" style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="caret-color: rgb(0, 0, 0); font-family: -apple-system, HelveticaNeue; font-size: 14.666666984558105px; display: inline !important">> \ No newline at end of file</span><br>
</div>
</div>
<div><br>
</div>
<div class="ms-outlook-ios-signature">
<div style="direction: ltr;">thanks,</div>
<div style="direction: ltr;">ray</div>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Wu, Jiaxin <jiaxin.wu@intel.com><br>
<b>Sent:</b> Thursday, April 1, 2021 9:50:29 PM<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io>; Wu, Jiaxin <jiaxin.wu@intel.com><br>
<b>Cc:</b> Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Zhang, Hongbin1 <hongbin1.zhang@intel.com><br>
<b>Subject:</b> Re: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the XSETBV instruction</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi Liming and Jiewen,<br>
<br>
Could you help review the patch?<br>
<br>
Thanks,<br>
Jiaxin<br>
<br>
<br>
<br>
> -----Original Message-----<br>
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu,<br>
> Jiaxin<br>
> Sent: Wednesday, March 31, 2021 3:54 PM<br>
> To: devel@edk2.groups.io<br>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao<br>
> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; Yao,<br>
> Jiewen <jiewen.yao@intel.com>; Zhang, Hongbin1<br>
> <hongbin1.zhang@intel.com><br>
> Subject: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the<br>
> XSETBV instruction<br>
> <br>
> <a href="https://bugzilla.tianocore.org/show_bug.cgi?id=3284">https://bugzilla.tianocore.org/show_bug.cgi?id=3284</a><br>
> <br>
> This patch is to support XSETBV instruction so as to support<br>
> Extended Control Register(XCR) write.<br>
> <br>
> Extended Control Register(XCR) read has already been supported<br>
> by below commit to support XGETBV instruction:<br>
> 9b3ca509abd4e45439bbdfe2c2fa8780c950320a<br>
> <br>
> Cc: Michael D Kinney <michael.d.kinney@intel.com><br>
> Cc: Liming Gao <gaoliming@byosoft.com.cn><br>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com><br>
> Cc: Yao Jiewen <jiewen.yao@intel.com><br>
> Signed-off-by: Jiaxin Wu <Jiaxin.wu@intel.com><br>
> Signed-off-by: Zhang Hongbin1 <hongbin1.zhang@intel.com><br>
> ---<br>
>  MdePkg/Include/Library/BaseLib.h        | 25 +++++++++++++++++++++++-<br>
>  MdePkg/Library/BaseLib/BaseLib.inf      |  4 +++-<br>
>  MdePkg/Library/BaseLib/Ia32/XSetBv.nasm | 34<br>
> +++++++++++++++++++++++++++++++++<br>
>  MdePkg/Library/BaseLib/X64/XSetBv.nasm  | 34<br>
> +++++++++++++++++++++++++++++++++<br>
>  4 files changed, 95 insertions(+), 2 deletions(-)<br>
>  create mode 100644 MdePkg/Library/BaseLib/Ia32/XSetBv.nasm<br>
>  create mode 100644 MdePkg/Library/BaseLib/X64/XSetBv.nasm<br>
> <br>
> diff --git a/MdePkg/Include/Library/BaseLib.h<br>
> b/MdePkg/Include/Library/BaseLib.h<br>
> index 1171a0ffb5..035d6b655d 100644<br>
> --- a/MdePkg/Include/Library/BaseLib.h<br>
> +++ b/MdePkg/Include/Library/BaseLib.h<br>
> @@ -1,10 +1,10 @@<br>
>  /** @file<br>
>    Provides string functions, linked list functions, math functions,<br>
> synchronization<br>
>    functions, file path functions, and CPU architecture-specific functions.<br>
> <br>
> -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR><br>
> +Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR><br>
>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR><br>
>  Copyright (c) Microsoft Corporation.<BR><br>
>  Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All<br>
> rights reserved.<BR><br>
> <br>
>  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> @@ -7436,10 +7436,33 @@ UINT64<br>
>  EFIAPI<br>
>  AsmXGetBv (<br>
>    IN UINT32  Index<br>
>    );<br>
> <br>
> +/**<br>
> +  Executes a XSETBV instruction to write a 64-bit value to a Extended Control<br>
> Register(XCR),<br>
> +  and returns the value.<br>
> +<br>
> +  Writes the 64-bit value specified by Value to the XCR specified by Index.<br>
> The<br>
> +  64-bit value written to the XCR is returned. No parameter checking is<br>
> +  performed on Index or Value, and some of these may cause CPU<br>
> exceptions. The<br>
> +  caller must either guarantee that Index and Value are valid, or the caller<br>
> +  must establish proper exception handlers. This function is only available on<br>
> +  IA-32 and x64.<br>
> +<br>
> +  @param  Index The 32-bit XCR index to write.<br>
> +  @param  Value The 64-bit value to write to the XCR.<br>
> +<br>
> +  @return Value<br>
> +<br>
> +**/<br>
> +UINT64<br>
> +EFIAPI<br>
> +AsmXSetBv (<br>
> +  IN UINT32  Index,<br>
> +  IN UINT64  Value<br>
> +  );<br>
> <br>
>  /**<br>
>    Executes a VMGEXIT instruction (VMMCALL with a REP prefix)<br>
> <br>
>    Executes a VMGEXIT instruction. This function is only available on IA-32 and<br>
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf<br>
> b/MdePkg/Library/BaseLib/BaseLib.inf<br>
> index 3b85c56c3c..fe8f68bbcf 100644<br>
> --- a/MdePkg/Library/BaseLib/BaseLib.inf<br>
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf<br>
> @@ -1,9 +1,9 @@<br>
>  ## @file<br>
>  #  Base Library implementation.<br>
>  #<br>
> -#  Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR><br>
> +#  Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR><br>
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR><br>
>  #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR><br>
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights<br>
> reserved.<BR><br>
>  #<br>
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> @@ -182,10 +182,11 @@<br>
>    Ia32/LShiftU64.nasm| GCC<br>
>    Ia32/EnableCache.nasm| GCC<br>
>    Ia32/DisableCache.nasm| GCC<br>
>    Ia32/RdRand.nasm<br>
>    Ia32/XGetBv.nasm<br>
> +  Ia32/XSetBv.nasm<br>
>    Ia32/VmgExit.nasm<br>
> <br>
>    Ia32/DivS64x64Remainder.c<br>
>    Ia32/InternalSwitchStack.c | MSFT<br>
>    Ia32/InternalSwitchStack.nasm | GCC<br>
> @@ -316,10 +317,11 @@<br>
>    X64/GccInlinePriv.c | GCC<br>
>    X64/EnableDisableInterrupts.nasm<br>
>    X64/DisablePaging64.nasm<br>
>    X64/RdRand.nasm<br>
>    X64/XGetBv.nasm<br>
> +  X64/XSetBv.nasm<br>
>    X64/VmgExit.nasm<br>
>    ChkStkGcc.c  | GCC<br>
> <br>
>  [Sources.EBC]<br>
>    Ebc/CpuBreakpoint.c<br>
> diff --git a/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm<br>
> b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm<br>
> new file mode 100644<br>
> index 0000000000..9fa2f761cd<br>
> --- /dev/null<br>
> +++ b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm<br>
> @@ -0,0 +1,34 @@<br>
> +;------------------------------------------------------------------------------<br>
> +;<br>
> +; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR><br>
> +; SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +;<br>
> +; Module Name:<br>
> +;<br>
> +;   XSetBv.nasm<br>
> +;<br>
> +; Abstract:<br>
> +;<br>
> +;   AsmXSetBv function<br>
> +;<br>
> +; Notes:<br>
> +;<br>
> +;------------------------------------------------------------------------------<br>
> +<br>
> +    SECTION .text<br>
> +<br>
> +;------------------------------------------------------------------------------<br>
> +; UINT64<br>
> +; EFIAPI<br>
> +; AsmXSetBv (<br>
> +;   IN UINT32  Index,<br>
> +;   IN UINT64  Value<br>
> +;   );<br>
> +;------------------------------------------------------------------------------<br>
> +global ASM_PFX(AsmXSetBv)<br>
> +ASM_PFX(AsmXSetBv):<br>
> +    mov     edx, [esp + 12]<br>
> +    mov     eax, [esp + 8]<br>
> +    mov     ecx, [esp + 4]<br>
> +    xsetbv<br>
> +    ret<br>
> \ No newline at end of file<br>
> diff --git a/MdePkg/Library/BaseLib/X64/XSetBv.nasm<br>
> b/MdePkg/Library/BaseLib/X64/XSetBv.nasm<br>
> new file mode 100644<br>
> index 0000000000..aa72419e7f<br>
> --- /dev/null<br>
> +++ b/MdePkg/Library/BaseLib/X64/XSetBv.nasm<br>
> @@ -0,0 +1,34 @@<br>
> +;------------------------------------------------------------------------------<br>
> +;<br>
> +; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR><br>
> +; SPDX-License-Identifier: BSD-2-Clause-Patent<br>
> +;<br>
> +; Module Name:<br>
> +;<br>
> +;   XSetBv.nasm<br>
> +;<br>
> +; Abstract:<br>
> +;<br>
> +;   AsmXSetBv function<br>
> +;<br>
> +; Notes:<br>
> +;<br>
> +;------------------------------------------------------------------------------<br>
> +<br>
> +    DEFAULT REL<br>
> +    SECTION .text<br>
> +<br>
> +;------------------------------------------------------------------------------<br>
> +; UINT64<br>
> +; EFIAPI<br>
> +; AsmXSetBv (<br>
> +;   IN UINT32  Index,<br>
> +;   IN UINT64  Value<br>
> +;   );<br>
> +;------------------------------------------------------------------------------<br>
> +global ASM_PFX(AsmXSetBv)<br>
> +ASM_PFX(AsmXSetBv):<br>
> +    mov     rax, rdx                    ; meanwhile, rax <- return value<br>
> +    shr     rdx, 0x20                    ; edx:eax contains the value to write<br>
> +    xsetbv<br>
> +    ret<br>
> \ No newline at end of file<br>
> --<br>
> 2.16.2.windows.1<br>
> <br>
> <br>
> <br>
> <br>
> <br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
</span></font></div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/73628">View/Reply Online (#73628)</a> |    |  <a target="_blank" href="https://groups.io/mt/81744813/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>