From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a01:111:f400:fe08::827; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03olkn0827.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::827]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 55095203B85A2 for ; Wed, 9 May 2018 01:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9g4YddMDC8l1BvcoDKnXm2RgFJHglQorwlMe1dIXbIY=; b=gYgj4prsaGxk7HwMEAhkB/JaIUn5NRd6hFa/GKo3Xrn+ffzl3fi9MkoLbpK+HYdC1/K9EKBS3ktXOsFG789RM2fFzLhvjaHKauANgRezOoWx8ANT7KPfqOTTDcNGElxph/NA2FYKAF3yFDgsQmOjaz7IWDLCVB87ZAd57UgUayypA8WeHEeudenKLmjqnpB2/R2t2pVLrTb9XN1wFzQ6rppFH8SRSqlGwyQSpON0EGW+SyEpfmqggwVtCSz2uT8YhRfTsq+0Pm6dN3jAF09MFxS2bm52oNnSFTeDlciRANE3fgafTGNq8xeI5dmu8OhJ3uPQQV4EYOo7a4oqZilQAA== Received: from AM5EUR03FT039.eop-EUR03.prod.protection.outlook.com (10.152.16.53) by AM5EUR03HT072.eop-EUR03.prod.protection.outlook.com (10.152.17.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.735.16; Wed, 9 May 2018 08:44:35 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.16.57) by AM5EUR03FT039.mail.protection.outlook.com (10.152.17.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.735.16 via Frontend Transport; Wed, 9 May 2018 08:44:35 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7c79:584b:2e12:783e]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7c79:584b:2e12:783e%17]) with mapi id 15.20.0755.012; Wed, 9 May 2018 08:44:35 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: Tim Lewis , "Yao, Jiewen" Thread-Topic: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c Thread-Index: AdPnJWlKcshriHOETXuZ755wb8JLiwAAiYkAAAAKWvAAALKYAAAABwWQAABldgAAAi7xgAAOgd1g Date: Wed, 9 May 2018 08:44:35 +0000 Message-ID: References: <74D8A39837DF1E4DA445A8C0B3885C503AB98291@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AB98303@shsmsx102.ccr.corp.intel.com> <74D8A39837DF1E4DA445A8C0B3885C503AB983CA@shsmsx102.ccr.corp.intel.com> <003701d3e734$f31a7770$d94f6650$@insyde.com> In-Reply-To: <003701d3e734$f31a7770$d94f6650$@insyde.com> Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:459415ED9679DBFD07645FBEC892224C7AB3647FD7BE7ACE8E55A2F41D3583F3; UpperCasedChecksum:F1EC701CFEE48998E6E1D8C67C9966DBEF1554C801F2D01F9FC74F02F9862FF3; SizeAsReceived:7643; Count:46 x-tmn: [ERRVdfMpobiqC86yFrPsC1n1Vwbf1Qyy] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM5EUR03HT072; 7:MhXs9z3zytKUOfKjRxmnXSHweRIxjel+hxJvWFyaiczVfqHQmanjst3ZY9Y4RHpb37c88Frh3bAS6sYr1uPYCUrkdz2YzBaeUw3ITxY4yYXYFb5SKA4kGWMpk6Sp8+muTRLIHmDSpaBWq/S4Ip849GWLEGfIMSnIXGHtWTHxMF/wKxLdk/Kc+cwaT3YhUIDoypmFzP377S9HdpzKWzrxvCeVFxe5DSOIEIed8FugzVXZcW8SThAYZ9PxLy/7oICW x-incomingheadercount: 46 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125420)(1701031045); SRVR:AM5EUR03HT072; x-ms-traffictypediagnostic: AM5EUR03HT072: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:AM5EUR03HT072; BCL:0; PCL:0; RULEID:; SRVR:AM5EUR03HT072; x-forefront-prvs: 0667289FF8 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(13464003)(199004)(189003)(51444003)(99286004)(54906003)(6436002)(33656002)(8936002)(81156014)(229853002)(82202002)(6916009)(8676002)(76176011)(106356001)(20460500001)(93886005)(105586002)(86362001)(59450400001)(53546011)(102836004)(3660700001)(6346003)(3280700002)(26005)(74316002)(25786009)(4326008)(87572001)(305945005)(1720100001)(2351001)(2900100001)(5250100002)(97736004)(104016004)(45080400002)(966005)(6306002)(476003)(68736007)(72206003)(2501003)(55016002)(6246003)(446003)(5660300001)(7696005)(486006)(53376002)(11346002)(426003)(5640700003)(14454004)(19627235001); DIR:OUT; SFP:1901; SCL:1; SRVR:AM5EUR03HT072; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Marvin.Haeuser@outlook.com; x-microsoft-antispam-message-info: fM0yGvWUJia6RkXkEiDSABaIFGSXFST5TR44mfiSZiRo5RWBhLRjPXlr5I/3PjLlV9SIInyuiJmnHf8NjVPpjmgwLbJCdLPIfV/XuT+458/TJWhljFxFwIsb5yRkHZDKO09yx+l/JhncstVP5LiiNkETkKf1DHeCYuYnvYIGbwAEK6qDELKDQd4ispwjHxQZ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7cf469a6-f37d-4603-8d92-08d5b58917a4 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 7cf469a6-f37d-4603-8d92-08d5b58917a4 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 09 May 2018 08:44:35.3506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5EUR03HT072 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 08:44:44 -0000 Content-Language: de-DE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey Tim, The compiler has no information regarding the size of the stack and hence c= annot determine an overflow. This is basically a warning that stack of a single function is big enough t= o reach past the Guard Page and ensures it will be accessed. Yao, I just realized there already is Stack protection code in edk2, I was only = aware of Heap protection. Wouldn't a proper implementation make sense now to maybe not expand the sta= ck, but at least runtime-error? Regards, Marvin > -----Original Message----- > From: Tim Lewis > Sent: Wednesday, May 9, 2018 3:28 AM > To: 'Yao, Jiewen' ; Marvin.Haeuser@outlook.com; > edk2-devel@lists.01.org > Subject: RE: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c >=20 > I think that this is a fatal error in EDK2. It basically says, "we are ou= t of stack > space." The alternative is: the system hangs in an unexpected way since t= he > stack overflows into other pages. >=20 > Tim >=20 > -----Original Message----- > From: edk2-devel On Behalf Of Yao, > Jiewen > Sent: Tuesday, May 8, 2018 5:25 PM > To: Marvin.Haeuser@outlook.com; edk2-devel@lists.01.org > Subject: Re: [edk2] [PATCH] MdePkg/BaseLib: Globally include ChkStk.c >=20 > We discussed internally in Intel. >=20 > The quick workaround is: use /Gs65536. :-) >=20 > At the same time, our recommendation is to revisit the code which trigger= s > this error. Why this function need such a big stack? And try to reduce th= e > local stack usage. >=20 > What is why we still use /Gs32768 as default, instead of /Gs65536. >=20 > Thank you > Yao Jiewen >=20 >=20 > > -----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 > > > > Oh, if you are prefering a good implementation, I will be all for > > that. This was just a 'quick workaround', same as currently done for GC= C. > > 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 free 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. > > > > Thanks, > > Marvin > > > > > -----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/+/b094d6c4bf572654a03 > > > 1e 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 stack 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 stack > > > 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, if 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 > > > > > > for 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 > > > > > > > > the function for all compilers and all architectures. This > > > > > > > > is done as huge variables on the stack may cause the > > > > > > > > generation of calls to this intrinsic function for > > > > > > > > Microsoft compilers, even 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 > > > > _______________________________________________ > > 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