public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: Cheng-Chieh Huang <chengchieh@google.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: gaoliming <gaoliming@byosoft.com.cn>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Subject: Re: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation
Date: Fri, 23 Jul 2021 18:38:20 +0000	[thread overview]
Message-ID: <CO1PR11MB4929EDF0D699A07B3067E96AD2E59@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CANtkA9bXQX1QNL2WRMZZvwgEdXHeRx81eRFM=Zg=3bYXo-diPg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6671 bytes --]

As long as those flags are supported or ignored by the GCC5 compilers, then there should be not harm in adding them to the GCC5 profile.

Mike

From: Cheng-Chieh Huang <chengchieh@google.com>
Sent: Friday, July 23, 2021 10:17 AM
To: Kinney, Michael D <michael.d.kinney@intel.com>
Cc: gaoliming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation

Hi,

This is not about UefiPayload. I did not have GCC5 in my environment, so I use a newer GCC to compile. However, in newer gcc (let's say GCC8), it generates floating point instructions in each function and system will crash as you mentioned that we did not handle it in UEFI.

I uploaded this patch because many people from our group use newer GCC and it will be more convenient if we can disable it with a flag (otherwise, we need to maintain a local patch). I guess the real fix (bigger work) is for EDK2 to support the newer GCC version in its toolchain (create something like *_GCC8_*).

Back to the question, I think it should be no harm to add these flags to tool_defs.txt if EDK2 did not expect the compiler to generate MMX/SSE instructions in the first place.

--
Cheng-Chieh

On Sat, Jul 24, 2021 at 12:46 AM Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>> wrote:
Can you provide details on why this flag was needed in the UefiPayloadPkg use case?

If the newer versions of the GCC compilers are injecting use of MMX/SSE instructions from optimization of C code, then we need to unconditionally disable that usage in tools_def.txt.  The only place MMX/SSE instructions can be used is in NASM files with proper save/restore of the MMX/SSE state.

Here is an example with use of xmm0 that is saved/restored on the stack.

https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseMemoryLibSse2/X64/CopyMem.nasm

Mike

From: Cheng-Chieh Huang <chengchieh@google.com<mailto:chengchieh@google.com>>
Sent: Friday, July 23, 2021 4:17 AM
To: gaoliming <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
Subject: Re: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation

I got what you mean by "Tools_def.txt doesn’t support build flag" now. I thought the parser does support some sort of if/else condition, but it seems to be not the case. Alternatively, we can do this during the copy (from template to tools_def.txt), but everytime we need to recreate tools_def.txt which is not ideal).

In that case, I think we should just roll back to only doing this in UefiPayloadPkg.dsc. If other packs want to add these flags, they will need to do it on their own.

On Fri, Jul 23, 2021 at 6:29 PM gaoliming <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>> wrote:
How do you add this support in tools_def? Can you give the proposal for it?

Thanks
Liming
发件人: Cheng-Chieh Huang <chengchieh@google.com<mailto:chengchieh@google.com>>
发送时间: 2021年7月22日 10:35
收件人: gaoliming <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>>
抄送: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
主题: Re: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation

I mean, I will submit a patch to support DISABLE_GCC_MMX_SSE in tools_def. What do you think?

--
Cheng-Chieh

On Thu, Jul 22, 2021 at 9:28 AM gaoliming <gaoliming@byosoft.com.cn<mailto:gaoliming@byosoft.com.cn>> wrote:
Tools_def.txt doesn’t support build flag DISABLE_GCC_MMX_SSE. If this flag is moved into BaseTools\Conf\tools_def.template, -mno-mmx -mno-sse option will be the default GCC options. That means all platforms will apply them.

Thanks
Liming
发件人: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> 代表 Cheng-Chieh Huang via groups.io<http://groups.io>
发送时间: 2021年7月22日 1:43
收件人: Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>>
抄送: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
主题: Re: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation

Yes, we can. I will drop this patch for this  uefipayload batch and send another one for support DISABLE_GCC_MMX_SSE in tools_de.txt.

--
Cheng-Chieh
On Thu, Jul 22, 2021, 12:35 AM Kinney, Michael D <michael.d.kinney@intel.com<mailto:michael.d.kinney@intel.com>> wrote:
Are those flags needed for all packages that build with GCC?

Should this be moved into tools_def.txt?

Mike

> -----Original Message-----
> From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Cheng-Chieh Huang via groups.io<http://groups.io>
> Sent: Wednesday, July 21, 2021 6:23 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
> Cc: Cheng-Chieh Huang <chengchieh@google.com<mailto:chengchieh@google.com>>
> Subject: [edk2-devel] [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation
>
> This will allow we compile payload using gcc8
>
> Signed-off-by: Cheng-Chieh Huang <chengchieh@google.com<mailto:chengchieh@google.com>>
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 8aa5f18cd35c..fa41c5a24af5 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -30,6 +30,8 @@ [Defines]
>    DEFINE PS2_KEYBOARD_ENABLE          = FALSE
>    DEFINE UNIVERSAL_PAYLOAD            = FALSE
>
> +  DEFINE DISABLE_MMX_SSE              = FALSE
> +
>    #
>    # SBL:      UEFI payload for Slim Bootloader
>    # COREBOOT: UEFI payload for coreboot
> @@ -96,6 +98,9 @@ [BuildOptions]
>    *_*_*_CC_FLAGS                 = -D DISABLE_NEW_DEPRECATED_INTERFACES
>  !if $(BOOTLOADER) == "LINUXBOOT"
>    *_*_*_CC_FLAGS                 = -D LINUXBOOT_PAYLOAD
> +!endif
> +!if $(DISABLE_MMX_SSE)
> +  *_*_*_CC_FLAGS                 = -mno-mmx -mno-sse
>  !endif
>    GCC:*_UNIXGCC_*_CC_FLAGS       = -DMDEPKG_NDEBUG
>    GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG
> --
> 2.32.0.402.g57bb445576-goog
>
>
>
>
>


[-- Attachment #2: Type: text/html, Size: 57333 bytes --]

  reply	other threads:[~2021-07-23 18:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 13:23 [PATCH 0/6] UefiPayloadPkg: LinuxBoot Support in UefiPayload Cheng-Chieh Huang
2021-07-21 13:23 ` [PATCH v1 1/6] UefiPayloadPkg: Add LINUXBOOT payload target Cheng-Chieh Huang
2021-08-04  2:41   ` [edk2-devel] " Guo Dong
2021-07-21 13:23 ` [PATCH v1 2/6] UefiPayloadPkg: Use legacy timer in Linuxboot payload Cheng-Chieh Huang
2021-08-04  2:22   ` [edk2-devel] " Guo Dong
     [not found]   ` <1697F93BEFA774AB.32148@groups.io>
2021-08-04  2:52     ` Guo Dong
2021-07-21 13:23 ` [PATCH v1 3/6] UefiPayloadPkg: Update maximum logic processor to 256 Cheng-Chieh Huang
2021-08-04  2:22   ` [edk2-devel] " Guo Dong
     [not found]   ` <1697F92B243CA725.1963@groups.io>
2021-08-04  2:51     ` Guo Dong
2021-07-21 13:23 ` [PATCH v1 4/6] UefiPayloadPkg: Reserve Payload config in runtime services data Cheng-Chieh Huang
2021-08-04  2:44   ` [edk2-devel] " Guo Dong
2021-08-04  6:23     ` Cheng-Chieh Huang
2021-08-04 13:37       ` Guo Dong
2021-07-21 13:23 ` [PATCH v1 5/6] UefiPayloadPkg: Add DISABLE_MMX_SSE to avoid generating floating points operation Cheng-Chieh Huang
2021-07-21 16:34   ` [edk2-devel] " Michael D Kinney
2021-07-21 17:42     ` Cheng-Chieh Huang
2021-07-22  1:28       ` 回复: " gaoliming
2021-07-22  2:35         ` Cheng-Chieh Huang
2021-07-23 10:28           ` 回复: " gaoliming
2021-07-23 11:16             ` Cheng-Chieh Huang
2021-07-23 16:45               ` Michael D Kinney
2021-07-23 17:17                 ` Cheng-Chieh Huang
2021-07-23 18:38                   ` Michael D Kinney [this message]
2021-07-21 13:23 ` [PATCH v1 6/6] UefiPayloadPkg: LinuxBoot: use a text format for the configuration block Cheng-Chieh Huang
2021-07-21 17:09   ` [edk2-devel] " Marvin Häuser
2021-07-22 13:48     ` Cheng-Chieh Huang
2021-08-04  3:00   ` Guo Dong
2021-08-07 13:53     ` Cheng-Chieh Huang
2021-07-22  1:29 ` 回复: [edk2-devel] [PATCH 0/6] UefiPayloadPkg: LinuxBoot Support in UefiPayload gaoliming
2021-07-22  3:40   ` Cheng-Chieh Huang
2021-07-22  1:44 ` Ni, Ray
2021-07-22  1:58   ` Daniel Schaefer
2021-07-22  2:48     ` Cheng-Chieh Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB4929EDF0D699A07B3067E96AD2E59@CO1PR11MB4929.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox