From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 84886203B85B3 for ; Tue, 8 May 2018 17:25:22 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2018 17:25:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,379,1520924400"; d="scan'208";a="226969520" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga006.fm.intel.com with ESMTP; 08 May 2018 17:25:21 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 8 May 2018 17:25:21 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 8 May 2018 17:25:21 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.210]) with mapi id 14.03.0319.002; Wed, 9 May 2018 08:25:19 +0800 From: "Yao, Jiewen" To: "Marvin.Haeuser@outlook.com" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c Thread-Index: AdPnJWlK0BO4vdQ7tUOW3NfrcoDhygAAEJtQ//9/MgD//3mZ4IAAjQgA//95jeA= Date: Wed, 9 May 2018 00:25:18 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AB983CA@shsmsx102.ccr.corp.intel.com> References: <74D8A39837DF1E4DA445A8C0B3885C503AB98291@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AB98303@shsmsx102.ccr.corp.intel.com> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzdjZGFmYWEtMjEzZC00NjEzLThmOWEtYzU4MzhiMDg2YmNlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJUa3V1SVBVSFJOSFBxSFFWR1ZHRkNWRWlsUWtUN1g5aGRFdFF3Z1dvb05UXC94N0QrVlpiWVJkVmIraEdGUnpHbyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 May 2018 00:25:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable We discussed internally in Intel. The quick workaround is: use /Gs65536. :-) At the same time, our recommendation is to revisit the code which triggers = this error. Why this function need such a big stack? And try to reduce the = local stack usage. What is why we still use /Gs32768 as default, instead of /Gs65536. Thank you Yao Jiewen > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Marvin H?user > Sent: Tuesday, May 8, 2018 5:21 PM > To: edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c >=20 > Oh, if you are prefering a good implementation, I will be all for that. T= his was just > a 'quick workaround', same as currently done for GCC. > I'm actually unsure whether a good implementation is possible with a flat > memory model. It will likely be mere luck whether there is enough space f= ree > below the stack, except for maybe when it's located very high (preferably= past > the 32-bit space). > Has there been any prior discussion on this topic? Would be interested to= follow > up if there was. >=20 > Thanks, > Marvin >=20 > > -----Original Message----- > > From: Yao, Jiewen > > Sent: Wednesday, May 9, 2018 2:13 AM > > To: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org > > Cc: Gao, Liming > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c > > > > There are some open source implementation: > > MSVC: https://github.com/ispc/ispc/issues/542 > > GCC: > > https://android.googlesource.com/toolchain/gcc/+/b094d6c4bf572654a031e > > cc4afe675154c886dc5/gcc-4.4.3/gcc/config/i386/chkstk.asm > > > > The compiler generated code assumes the stack is enlarged after we can > > chkstk. > > > > I agree empty function can make build pass. > > But more important, we need make it work if there is a need to increase= the > > stack. > > The potential issue is that the later code (after chkstk) assumes the s= tack is > > increased, but actually it is not. > > > > That is why I ask how this is validated. > > > > Thank you > > Yao Jiewen > > > > > > > -----Original Message----- > > > From: Marvin H=E4user [mailto:Marvin.Haeuser@outlook.com] > > > Sent: Tuesday, May 8, 2018 4:58 PM > > > To: edk2-devel@lists.01.org > > > Cc: Yao, Jiewen ; Gao, Liming > > > > > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c > > > > > > Hey Yao, > > > > > > As far as I am aware, all __chkstk does is access the stack in 4 KB > > > intervals from the current location to the maximum requested location > > > to eventually hit the Windows Guard Page, which then triggers the sta= ck > > increase. > > > Because I do not know of any equivalent concept in edk2 and the > > > intrinsic was already disabled for GCC, I supposed it was a good idea > > > to do so globally. Are the potential issues I am not aware of? > > > > > > Thanks, > > > Marvin. > > > > > > > -----Original Message----- > > > > From: Yao, Jiewen > > > > Sent: Wednesday, May 9, 2018 1:52 AM > > > > To: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org > > > > Cc: Gao, Liming > > > > Subject: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c > > > > > > > > HI Marvin > > > > Would you mind to share the information on how you test this update= ? > > > > > > > > > > > > Per my experience, chkstk not only does the check but also does the > > > > real work to allocate more stack. > > > > > > > > /Gs can be used to indicate the size (/Gs[num] control stack > > > > checking calls) > > > > > > > > We use /Gs32768 by default, see tools_def.txt. > > > > > > > > Usually, we just increase this value to override the default one, i= f > > > > we hit this issue. > > > > > > > > Thank you > > > > Yao Jiewen > > > > > > > > > -----Original Message----- > > > > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On > > > > > Behalf Of Marvin H?user > > > > > Sent: Tuesday, May 8, 2018 4:37 PM > > > > > To: edk2-devel@lists.01.org > > > > > Cc: Gao, Liming > > > > > Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include > > > > > ChkStk.c > > > > > > > > > > Hey Liming, > > > > > > > > > > According to the MSDN documentation, the call will be inserted fo= r > > > > > a stack usage past a defined threshold - 4 KB for IA32, 8 KB for = X64 > > (source: > > > > > https://msdn.microsoft.com/en-us/library/ms648426(v=3Dvs.85).aspx= ). > > > > > > > > > > Thanks, > > > > > Marvin > > > > > > > > > > > -----Urspr=FCngliche Nachricht----- > > > > > > Von: Gao, Liming > > > > > > Gesendet: Montag, 7. Mai 2018 14:16 > > > > > > An: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org > > > > > > Cc: Kinney, Michael D > > > > > > Betreff: RE: [PATCH] MdePkg/BaseLib: Globally include ChkStk.c > > > > > > > > > > > > Marvin: > > > > > > In VS compiler, what case will trig this intrinsic function? > > > > > > > > > > > > Thanks > > > > > > Liming > > > > > > > -----Original Message----- > > > > > > > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On > > > > > > > Behalf Of Marvin H?user > > > > > > > Sent: Saturday, May 5, 2018 10:25 PM > > > > > > > To: edk2-devel@lists.01.org > > > > > > > Cc: Kinney, Michael D ; Gao, > > > > > > > Liming > > > > > > > Subject: [edk2] [PATCH] MdePkg/BaseLib: Globally include > > > > > > > ChkStk.c > > > > > > > > > > > > > > Initially added for GCC build support, this patch includes th= e > > > > > > > function for all compilers and all architectures. This is don= e > > > > > > > as huge variables on the stack may cause the generation of > > > > > > > calls to this intrinsic function for Microsoft compilers, eve= n > > > > > > > for the IA32 architecture, too. > > > > > > > > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > > > > > Signed-off-by: Marvin Haeuser > > > > > > > --- > > > > > > > MdePkg/Library/BaseLib/{ChkStkGcc.c =3D> ChkStk.c} | 48 > > > > > > > ++++++++++------ > > > > > > ---- > > > > > > > MdePkg/Library/BaseLib/BaseLib.inf | 4 +- > > > > > > > 2 files changed, 26 insertions(+), 26 deletions(-) > > > > > > > > > > > > > > diff --git a/MdePkg/Library/BaseLib/ChkStkGcc.c > > > > > > > b/MdePkg/Library/BaseLib/ChkStk.c similarity index 74% rename > > > > > > > from MdePkg/Library/BaseLib/ChkStkGcc.c > > > > > > > rename to MdePkg/Library/BaseLib/ChkStk.c index > > > > > > > ecba3853b159..59e6d73f9331 100644 > > > > > > > --- a/MdePkg/Library/BaseLib/ChkStkGcc.c > > > > > > > +++ b/MdePkg/Library/BaseLib/ChkStk.c > > > > > > > @@ -1,24 +1,24 @@ > > > > > > > -/** @file > > > > > > > - Provides hack function for passng GCC build. > > > > > > > - > > > > > > > - Copyright (c) 2006 - 2008, Intel Corporation. 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. > > > > > > > - > > > > > > > -**/ > > > > > > > - > > > > > > > -#include "BaseLibInternals.h" > > > > > > > - > > > > > > > -/** > > > > > > > - Hack function for passing GCC build. > > > > > > > -**/ > > > > > > > -VOID > > > > > > > -__chkstk() > > > > > > > -{ > > > > > > > -} > > > > > > > - > > > > > > > +/** @file > > > > > > > + Provides hack function for passing build. > > > > > > > + > > > > > > > + Copyright (c) 2006 - 2018, Intel Corporation. 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. > > > > > > > + > > > > > > > +**/ > > > > > > > + > > > > > > > +#include "BaseLibInternals.h" > > > > > > > + > > > > > > > +/** > > > > > > > + Hack function for passing build. > > > > > > > +**/ > > > > > > > +VOID > > > > > > > +__chkstk() > > > > > > > +{ > > > > > > > +} > > > > > > > + > > > > > > > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf > > > > > > > b/MdePkg/Library/BaseLib/BaseLib.inf > > > > > > > index 5fbbd02a94b6..d23a6db2581a 100644 > > > > > > > --- a/MdePkg/Library/BaseLib/BaseLib.inf > > > > > > > +++ b/MdePkg/Library/BaseLib/BaseLib.inf > > > > > > > @@ -1,7 +1,7 @@ > > > > > > > ## @file > > > > > > > # Base Library implementation. > > > > > > > # > > > > > > > -# Copyright (c) 2007 - 2016, Intel Corporation. All rights > > > > > > > reserved.
> > > > > > > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights > > > > > > > +reserved.
> > > > > > > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights > > > > > > > reserved.
# Portions copyright (c) 2011 - 2013, ARM Ltd= . > > > > > > > All rights reserved.
# @@ -64,6 +64,7 @@ [Sources] > > > > > > > SafeString.c > > > > > > > String.c > > > > > > > FilePaths.c > > > > > > > + ChkStk.c > > > > > > > BaseLibInternals.h > > > > > > > > > > > > > > [Sources.Ia32] > > > > > > > @@ -781,7 +782,6 @@ [Sources.X64] > > > > > > > X64/DisableCache.S | GCC > > > > > > > X64/RdRand.nasm| GCC > > > > > > > X64/RdRand.S | GCC > > > > > > > - ChkStkGcc.c | GCC > > > > > > > > > > > > > > [Sources.IPF] > > > > > > > Ipf/AccessGp.s > > > > > > > -- > > > > > > > 2.17.0.windows.1 > > > > > > > > > > > > > > _______________________________________________ > > > > > > > edk2-devel mailing list > > > > > > > edk2-devel@lists.01.org > > > > > > > https://lists.01.org/mailman/listinfo/edk2-devel > > > > > _______________________________________________ > > > > > edk2-devel mailing list > > > > > edk2-devel@lists.01.org > > > > > https://lists.01.org/mailman/listinfo/edk2-devel >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel