From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=k3YGIiZm; spf=pass (domain: virtuozzo.com, ip: 52.101.131.13, mailfrom: rkagan@virtuozzo.com) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [52.101.131.13]) by groups.io with SMTP; Fri, 16 Aug 2019 10:00:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BkRzTKq1OkpvpT4G/htO3cTqBBXPkfbnJvp2bXMLApm5IXfP91twT+bbgfiBzy6jSZ/KTzpvaT3pPkV5Q8CyagYChDQ82eZsFRCvg9aMA9FvLdL0RlcQDk9lAtL+ynlvI81qnKQ1b+FtbAqTXASMxHFUfRvLk91jW410EieUOkwqFmqpQ9o/MkPe10VJtrdFEjMPN74OZnskk3jGz7DkFJxeXe4rT8yktwM5PHntMb4lnhyEJ9vLLyi429cNYxkhgf16wKM77Ew9z/YJMVOYaNWyQDhSM4G7xwR6oVSIvD2GlvYxrWsp10P5LWbsTuOUjgQgiulBRBOFbX3hXEAC5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hQLH7Isg6zP3PGnf2InIzskpGnYQpMrlbQliQqA0k4o=; b=jotDoQ4YDZRk9lQO2eCRBHQNHT3so32s/D97QhE1m5MsR+AOIXUcHdtYxCPLPm42/7h/O3kG0MNCKSHIv7o06wJ0EFo6liFIdHuZjBbJPl0vRQ8TmUwgYe3/RiK0HRbMloI75JRScOe0j6AQcN6/nWUL2xTWqm4BH7MIFqLr4nlTz8I84ttK4B1NUujHwNUS+7RlIE8PyxWrwlQJdkHcGWCvU9zX0WCE0VF+m2I+Dq9/eheFrw+6GaVCIU2JZQaFc2jgMuWJQjh0efSDAfnYVa5Tl66+vk+L7Oqcjf8cwVKwQJXam6au5Mfj2CGvcbWJVUMsjVsnC3FSA0NV8xsJiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hQLH7Isg6zP3PGnf2InIzskpGnYQpMrlbQliQqA0k4o=; b=k3YGIiZmPmibaEaTo31Z2ezlI9sAaZyXNZV+IyuLR161Sx+XHqxGtQvAX2J6xVO6KSf8dnePGzLloq4KMeNQINN6PIN0gbJ3tMbNJDS324OXnvy0Ir+zCuJnRL92eVtXWByVPWCZpWwTSGk7pnmeLAJEv/N78ivuW5hTW8r48wQ= Received: from AM6PR08MB3160.eurprd08.prod.outlook.com (52.135.163.161) by AM6PR08MB4341.eurprd08.prod.outlook.com (20.179.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Fri, 16 Aug 2019 17:00:10 +0000 Received: from AM6PR08MB3160.eurprd08.prod.outlook.com ([fe80::2c2c:c46e:bdfd:b872]) by AM6PR08MB3160.eurprd08.prod.outlook.com ([fe80::2c2c:c46e:bdfd:b872%6]) with mapi id 15.20.2157.022; Fri, 16 Aug 2019 17:00:10 +0000 From: "Roman Kagan" To: "devel@edk2.groups.io" , "afish@apple.com" CC: Laszlo Ersek , David Woodhouse Subject: Re: [edk2-devel] static data in dxe_runtime modules Thread-Topic: [edk2-devel] static data in dxe_runtime modules Thread-Index: AQHVSJ2bQrdLTZ7e0UaPDsZ6ZQsRb6borfAAgAOvAoCAA50IAIAAA28AgAGRvwCAAXiMgIAE4pyAgADyWYCAACUSAIAB04sAgAAToYCAAy36gA== Date: Fri, 16 Aug 2019 17:00:10 +0000 Message-ID: <20190816170007.GA10136@rkaganb.sw.ru> References: <20190805101813.GA27171@rkaganb.sw.ru> <406f2250-41e2-9925-b570-38b99a5f6e41@redhat.com> <0A900AFC-C9A0-4A4C-8EBA-9A6F75B3EE25@apple.com> <5d03c05d-24c2-f825-c42e-4371a87d76a1@redhat.com> <15B94CD6CF07DEE2.13696@groups.io> <20190812184303.GA4212@rkaganb.sw.ru> <62712b07-31c1-a19f-1660-12da0d7bac50@redhat.com> <20190813112308.GB4212@rkaganb.sw.ru> In-Reply-To: Accept-Language: en-US, ru-RU X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Mutt/1.12.1 (2019-06-15) mail-followup-to: Roman Kagan , devel@edk2.groups.io, afish@apple.com, Laszlo Ersek , David Woodhouse x-originating-ip: [185.231.240.5] x-clientproxiedby: HE1PR0101CA0014.eurprd01.prod.exchangelabs.com (2603:10a6:3:77::24) To AM6PR08MB3160.eurprd08.prod.outlook.com (2603:10a6:209:45::33) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b79bec55-92d6-496e-8421-08d7226b3292 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:AM6PR08MB4341; x-ms-traffictypediagnostic: AM6PR08MB4341:|AM6PR08MB4341: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:608; x-forefront-prvs: 0131D22242 x-forefront-antispam-report: SFV:SPM;SFS:(10019020)(376002)(346002)(136003)(366004)(39830400003)(396003)(199004)(189003)(229853002)(5660300002)(6116002)(3846002)(6512007)(86362001)(2906002)(36756003)(305945005)(9686003)(6486002)(6436002)(7736002)(11346002)(486006)(26005)(476003)(186003)(446003)(66446008)(66946007)(66476007)(66556008)(6506007)(102836004)(386003)(64756008)(33656002)(76176011)(52116002)(6246003)(53936002)(256004)(4326008)(316002)(478600001)(25786009)(54906003)(99286004)(1076003)(14444005)(2501003)(110136005)(58126008)(14454004)(71190400001)(71200400001)(8936002)(66066001)(8676002)(81156014)(81166006)(30126002);DIR:OUT;SFP:1501;SCL:5;SRVR:AM6PR08MB4341;H:AM6PR08MB3160.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-ms-exchange-transport-forked: True x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: SkArsmX2BjwZ19Ai/X5hgYhyLnPL0tDcp6vWqdHzfTDTbdQRrgXxc9oT3YpwonU/iDKLlkdmKHPtuhgFWn4oGLBDr0NBwh/8IPmCFOxlw8Fxfwji8mkKn++rn3676MP+1FryLxVbL59pAkBRWq2cqAB7y2bSp6nWs0NKyL2r1ipFqiP2G4gOo98LMS/1eLVxDHgOzOMWkUH0yrWlMUQKSfgq/OPd90dxW34+Ob91M0r5hujzLTh0kX7FajVjIbcl7ntMAfrRovwkm3opStukosp42AF0QeXLLbdvzR1hUe597D+gd0buzb3AD+nZY/qGS5kjt62rh2K8sJmMkLRFd542l5nO7VWBvK7XLf+9ywd+dz9TEgRtYxoVs7hGQU+2497HAP/6w8ahh2fl+8/x5WSddq43RGxjeiMDyxtWZzW1kjX0QQtIiNypyHjSTGKEbcqAjTMPXAgt8JXA5jfUoY5wVaKhgkeHBYIcHqfeCyVtA1UiqbpcD2pm1AdIu6yd MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b79bec55-92d6-496e-8421-08d7226b3292 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2019 17:00:10.3901 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5lfRbL50pPTfj6sPX3jAef8oVmumfe+jF/ZLWXZXQI2HTRmq3yEH98ujGmC29y5ui/8bd0WqLrxyvQznZIs/Fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-ID: On Wed, Aug 14, 2019 at 09:26:47AM -0700, Andrew Fish via Groups.Io wrote: > Every runtime driver I've every seen usually works like this: > 1) Loads as an EFI driver and uses EFI Boot Services in its constructor (gBS, gDS, AllocatePool(), etc.) > 2) You use the EFI Boot Service to register the ExitBootServices Event. > 3) SetVirtualAddressMap event fires and converts all the pointers > 4) After all the ExitBootServices events have been processed the DXE Runtime driver re-relocates the Runtime Driver > 5) The next code that runs is a call from the kernel virtual mapping, and the system is at runtime > > It is important to remember that when gRT->SetVirtualAddressMap() is > called by the OS Loader (or early kernel) that gBS->ExitBootServices() > has already been called. So by the time you get 3) almost all of EFI > is gone. The only services that remain are gRT. Note you find the > location of gRT by using the gST passed into the entry point of the > driver. So here is lies the problem the entry point is passed a Handle > (EFI Boot Services concept) and a pointer to gST (another boot > services table). So you can't really reload a module and expect it to > work. Indeed. My hope was that the particular VariableRuntimeDxe module was just a bunch of self-contained code that accesses all the data it needs through the arguments it's passed. Having now looked at the code, this assumption is certainly wrong: the module depends on a lot of private data that is initialized at boot services time. Thanks and sorry for the noise, Roman.