From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=15.241.48.73; helo=g9t5009.houston.hpe.com; envelope-from=brian.johnson@hpe.com; receiver=edk2-devel@lists.01.org Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) (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 9BAC322283539 for ; Mon, 5 Mar 2018 16:39:50 -0800 (PST) Received: from G2W6311.americas.hpqcorp.net (g2w6311.austin.hp.com [16.197.64.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5009.houston.hpe.com (Postfix) with ESMTPS id BBFD373; Tue, 6 Mar 2018 00:46:02 +0000 (UTC) Received: from G4W8062.americas.hpqcorp.net (16.208.40.79) by G2W6311.americas.hpqcorp.net (16.197.64.53) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 6 Mar 2018 00:46:02 +0000 Received: from G9W9209.americas.hpqcorp.net (2002:10dc:429c::10dc:429c) by G4W8062.americas.hpqcorp.net (2002:10d0:284f::10d0:284f) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 6 Mar 2018 00:46:02 +0000 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (15.241.52.10) by G9W9209.americas.hpqcorp.net (16.220.66.156) with Microsoft SMTP Server (TLS) id 15.0.1178.4 via Frontend Transport; Tue, 6 Mar 2018 00:46:01 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brian.johnson@hpe.com; Received: from [10.0.2.15] (192.48.154.5) by CS1PR84MB0213.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Tue, 6 Mar 2018 00:45:55 +0000 To: Laszlo Ersek , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , Andrew Fish CC: , Peter Jones , Jiewen Yao , QEMU , "Javier Martinez Canillas" References: <20180223132311.26555-1-marcandre.lureau@redhat.com> <20180223132311.26555-4-marcandre.lureau@redhat.com> <91D51528-C2CA-41DF-921F-DBD5C2EC028C@apple.com> <26353964-066c-5664-1d67-6a79a3d21ac9@redhat.com> From: "Brian J. Johnson" Message-ID: <5a8e107d-15f5-0278-9f89-5efb60de2719@hpe.com> Date: Mon, 5 Mar 2018 18:45:47 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <26353964-066c-5664-1d67-6a79a3d21ac9@redhat.com> X-Originating-IP: [192.48.154.5] X-ClientProxiedBy: DM5PR15CA0028.namprd15.prod.outlook.com (10.174.245.142) To CS1PR84MB0213.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.148) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b81ada99-6f94-4c95-2988-08d582fba135 X-Microsoft-Antispam: UriScan:(222181515654134); BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989060)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(8990040)(2017052603328)(7153060)(7193020); SRVR:CS1PR84MB0213; X-Microsoft-Exchange-Diagnostics: 1; CS1PR84MB0213; 3:dD5UGefMN9vwAIQLUcWbipglU2omIYbcodu5+EbeEo2yzuyc+c5dNLkwWkMxqtQ/K6pt8ZLW77H8h79xH8tFa5jnUN0iRW1yLyYI59yYWq9gOUjo8zJedYxf0rhh+VYTHXpzXh7ZSu64wDtHiZKBI9WImhE7zaKmV38AIMaEUEJE4bNP3ev1WFMNhiX8+iZpWG9fDQJJ5UEJh3emKs58HYugn4FUlz9GsRS4i6hSlTkH5A8SWbmhDuGeHnWPsFtenLKebCHLlYccaAu8rl2Y/uOVBqqPAh43ChS28PIF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sSo4oYk86llFrMcDnwpW2PUO89EkKg0234edaHj+TCtXlFUAvvdQ64DEXU09dEGOoZ3tIBXYP/LkTPdRr2IvKAHMjfvlWU3VHE; 4:JIZIHFb4ATIANs2qvw5t/HbPTaoh/qH7tzHyrLq6rqISnGHh65CEnEpBCPs0qX4eU+18nvp3kWvozwGGSk+EmeMUuriZAnBHGGOzRahtiWf5M29ckPaMmXvGlSplc4zTVJ8YUFxT1TYnj9qgQHPk0ESyCwwajTo1FCFP5ZlRVMdj2n96eYjJJMQLqAojgdaKkQGb9s83wBLVk0uULSTZR3UbQq3ipKNaMMLr7A/HZ7HKLXA1aeRGHq5ps3oqUMFbThTyAArfb/voNzkJqeh/jBz+kqhr312hm+hJQZrUFF53n5bLOUGdMsmYefis6YC2iYE4lSmDwxca5QLkh2p6cRduthRZHuWodcOJe5NE4F4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(227479698468861)(222181515654134); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(3231220)(944501244)(52105095)(10201501046)(6055026)(6041288)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:CS1PR84MB0213; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0213; X-Forefront-PRVS: 06036BD506 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6049001)(39860400002)(376002)(346002)(396003)(366004)(39380400002)(189003)(199004)(2906002)(50466002)(7736002)(68736007)(16576012)(53546011)(386003)(316002)(47776003)(478600001)(59450400001)(23676004)(65956001)(305945005)(2486003)(65806001)(52146003)(4326008)(31696002)(66066001)(230700001)(97736004)(93886005)(86362001)(36756003)(106356001)(5660300001)(31686004)(6246003)(64126003)(58126008)(81156014)(81166006)(6116002)(26005)(3846002)(110136005)(54906003)(65826007)(8666007)(8676002)(52116002)(39060400002)(2950100002)(76176011)(25786009)(186003)(16526019)(77096007)(6666003)(6486002)(229853002)(53936002)(8936002)(67846002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0213; H:[10.0.2.15]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDUzFQUjg0TUIwMjEzOzIzOjRTemJvWnJKNjhHV3c4K1gxaitIVVMyZ1pr?= =?utf-8?B?c0RrMmlHVDlrc0lZNFpjV1ZFMnVEUXQxbFlWNks2S2haSWt2VjZMOWZlb05r?= =?utf-8?B?d2cyVEhBMWlpeFlyTWYvWmx5aEJDRWtDd0p0MmlIMzZqbGhLY3N0RmNLd1JE?= =?utf-8?B?YzZNOWZYSXJEMnZ3MFgxdjdnZW03NytzY2M2MGYzRUE2OGNKWWZQcmJ6OTdJ?= =?utf-8?B?TFVyMXNsTUpTT2cxMmpEbi9PTWFnSEJyRU9SanpVNWw4SDZLbks4c0ZrZHc1?= =?utf-8?B?U0RmaW1WTWdQelk5b2NQQ1FqUDJnSkNIWFlyK2JDdFp2M3MyalR2b0Zkakw0?= =?utf-8?B?N0hmbGc2T2xKR24rK1dsM29icnV6MXlaamNJVHk2MHZQd2Fvd01ZOGJLNW11?= =?utf-8?B?aWllQ001bnZvZkJHOFducDR3QTc2Rit0S21SMFlOa3FkMjBHU3o4SlZiRmU1?= =?utf-8?B?cFVEUGVhTlBGc3kzNkphaG96Qzc2aE50dmpSa2x6U0JMdFhuNENoYVVUZU04?= =?utf-8?B?bk5oVGlKV21xNTA2VWJsOHMwSWdzMGcyTjdaR0VYNXlPMEhhVWRON0hnWjdz?= =?utf-8?B?NW5xMVN4MSsydDNKUE1XMjJldGRGRkpLVTFWYkRNSHg3YjBTOVBSRC9xRXdm?= =?utf-8?B?aElxdWdnQUV4NTlEU1QzM2U3T3dHVURJTk55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MI8BOoNrWLkHwxYaIOmXH65Y7Oq9Rnc/I=; 5:wQyabic0zudil+znUJOc17ZKiaXXSKDfepmTV5w7td5JQT2TIv4+gf5bPw6cmoKfjdP8/hGOKwzgnYQ3b8Ku9fnHEZDRQGRuvTX79udQS4UZ5D1tJaOYF7mZVmXrprCuL2+LNFDO5FdzNb6jis0lH9H6Qgj61U5qJ5Euz63GHOs=; 24:jvXKuBNaJX7Bqr8rv3dpbrFcG8DI9K0mPe/LCgByFW9dftpS3NhmolGQyRU0P6B6Ha5Ld512wkgDCDczpZ4vtnyRYgEs2+3js4UKbO+aGlI=; 7:7SxYQQitMpAJMy4eS+SeBED7ljQJiKvI2VhIGMfGCkqpQqDi/WqoayDNMn1ANJUm4XBO94+ILFENGIkoKdoxG52520ooNFGiIv0wkL3zJK3I+gH5jZn1+Sr4wV/F61x3GNz0qmGDPhLyTt52Ad25Z8Le8SXta7I1/0EFiuNeqPofInJhgovHcmoJAK+ptqKBrSjxmVHz5Fi/RKH1okS9APtjjPUVRjuAtT0PL+GKI/+iHWSZNpBnJivoPw5w2F3Z SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2018 00:45:55.0183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b81ada99-6f94-4c95-2988-08d582fba135 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0213 X-OriginatorOrg: hpe.com Subject: Re: [PATCH 3/7] HACK: HobLib: workaround infinite loop X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2018 00:39:51 -0000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 03/05/2018 12:22 PM, Laszlo Ersek wrote: > PEIMs generally "execute in place" (XIP), i.e. they run from flash, not > RAM. In this status they use "temporary RAM" (e.g. CPU caches configured > like RAM) for stack & heap; whatever HOBs they produce are stored in > "temp RAM" as well. Then one of the PEIMs "discovers permanent RAM" > (basically it programs the memory controller and publishes the RAM > ranges). In turn the PEI core "migrates" PEIMs from temporary to > permanent RAM, including the HOB list. > > Before the temporary RAM migration (when still executing in place from > flash), PEIMs cannot have writeable global variables. For example, > dynamic PCDs are also maintained in a HOB (the PCD HOB). > > A PEIM normally cannot (and shouldn't) tell whether it is dispatched > before or after permanent RAM is published. If needed, a PEIM can > advertise that it depends on permanent RAM (for example because it needs > a lot of heap memory) by including "gEfiPeiMemoryDiscoveredPpiGuid" in > its DEPEX. > > Finally, it seems like a PEIM can also express, "I'm fine with being > dispatched from both flash (XIP) vs. permanent RAM, just the PEI core > tell me whichever it is". Apparently, if the PEIM is dispatched from > flash (before permanent RAM is available), its call to > RegisterForShadow() returns EFI_SUCCESS (and then its entry point > function will be invoked for a 2nd time, after the temp RAM migration). > And when a PEIM is dispatched from RAM (either for the very first time, > or for the second time, after being dispatched from flash first), the > same call returns EFI_ALREADY_STARTED. > > Honestly, I'm unsure what this is good for (both in general, and > specifically for Tcg2Pei). Apparently, Tcg2Pei needs permanent RAM for > doing the measurements (which makes sense); I just wonder what exactly > it does so that it cannot simply specify > "gEfiPeiMemoryDiscoveredPpiGuid" in its DEPEX. I haven't looked at this particular PEIM. But one case where registering for shadowing is useful is for improving performance when running from permanent RAM, where writable global variables are available. For instance, when running from flash, a ReportStatusCode PEIM may need to go through a slow process to locate an output hardware device on every PPI call. This may involve traversing the HOB list, consulting other PPIs, even probing hardware addresses. But once it's shadowed to RAM, it can locate the device once, then cache its address in a global. Not to mention that the code itself is far, far faster when run from RAM vs. flash. (That's probably a key difference between a real machine and a VM.) Also, I've personally written a PEIM which saves a bunch of internal state in a HOB, since that's the main writable storage when running from flash. That state includes pointers to other data (in flash.) Once the data is all shadowed to RAM, it updates the HOB to point to the data in RAM. That way it's a lot faster to access the data. I also have other PEIMs which are constrained (via DEPEX) to run *only* from RAM, since they have larger memory requirements than can be satisfied from temporary cache-as-RAM. That's certainly a valid technique as well. RegisterForShadow() is a useful tool for making the most of the restricted PEI environment. And having it standardized like this is, as Andrew said, a lot better than the hacks people had to use beforehand. Thanks, -- Brian J. Johnson Enterprise X86 Lab Hewlett Packard Enterprise brian.johnson@hpe.com