From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.68]) by mx.groups.io with SMTP id smtpd.web10.3256.1678870515178961867 for ; Wed, 15 Mar 2023 01:55:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@suse.com header.s=selector1 header.b=ZqW4gkPq; spf=pass (domain: suse.com, ip: 40.107.6.68, mailfrom: jlee@suse.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cgCjViXxZtblriK0IdhcPmbCUpFSKU2WNV1XduSFnF07U/WQXAYauMyrU2WynMCJgD5X5kCdRPpEZ8Day7oG4QCQpKUN/IGMe5cqMUIC5NWKRDISQbKm8Jkojnpcd+vH0M1ggGLlSgZFz9Fg8sMbr4Jy7t4ICE2ugzlj0ATFmyj9wKe2k01Emxntmg2b/Te8htBWwRA8QD164Y2v792K8yioeN1yn/6KBG0xjmKIg7kbY3e3+etUuPyh3R1JCDg0yafvu4o5fS6ttGG3cQ+rhYvSwHUkqQ4RYVCOdWFaPbZOXGL6NlbMKC63NeftpIV6Z3kOhuIQ+wRQvPofu8tqWQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9Zbqw5LIrkHBOB3pGmYGGrQVolC2gvWtg1syHKm4/Mg=; b=RipQHm2CKVvb+O6QdjMO0gARFh24N60cRI3kOpe7rx5N2/NNBZufVOp0ZrESWkWTvxTgqU80oNyq+VgDXM/81vBxzvquuwZbDohuf/wWQLJ5ckhnJzYtqD9pBizAveJrwEocOJ+npOaNcw6sG8oPKLRNDu0b1bnYlVGJpSi6UdLUJZgwKgh3kdI1nD40Erb2vGMC8Yt0Oud5HNEy3JOzwaF82GjTuOP/xpEWW1+pzv7eHoR4L1DwX4XmS8r7+vVvcx81XScbeKUKgt9nA0Q9Si0zIVpM4RstlSDxQKy8iJKW2+pqaexIWbgITZqBTJvVkF9o/Q5XAQF01LABY+ClIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Zbqw5LIrkHBOB3pGmYGGrQVolC2gvWtg1syHKm4/Mg=; b=ZqW4gkPqNEFPPU+dDBaHxm9k6dqkrmfoqHRR1tBkWY+UbzobdIXPoI7LSyzzYKb7IA0RxklmfQwQDfTXQJvT6xq+PYyAMF9KDrKhNuCMheYt2d3LzoNXXwewSoK1REUEmPguLjx0VnldJAmVFhWrnooZXjqGC5anbmuEHugOqt7gYl+1PxEVJsiEo0qksI7KOPhS2ZENB4sRK+mCKRmOGrH4seuKoRMNjzHm/FQkT/7tG+aldGp087QaTahgT4DLDvMa3yodgNBJSU6rzlOfpWvR42J5LLwMTGsiLGNRXQWR1uRZCz0l4NgbKDjGXpXXSvUB8/6WsMUZc14lAKS0hw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) by AM7PR04MB6774.eurprd04.prod.outlook.com (2603:10a6:20b:104::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.29; Wed, 15 Mar 2023 08:55:12 +0000 Received: from DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::ea33:6d90:451b:6a1c]) by DB8PR04MB7164.eurprd04.prod.outlook.com ([fe80::ea33:6d90:451b:6a1c%7]) with mapi id 15.20.6178.029; Wed, 15 Mar 2023 08:55:12 +0000 Date: Wed, 15 Mar 2023 16:54:58 +0800 From: "joeyli" To: devel@edk2.groups.io, kraxel@redhat.com Cc: Jordan Justen , Pawel Polawski , Jiewen Yao , Oliver Steffen , Ard Biesheuvel Subject: Re: [edk2-devel] [PATCH v2 3/4] OvmfPkg/PlatformInitLib: dynamic mmio window size Message-ID: <20230315085458.GP8116@linux-l9pv.suse> References: <20221004134728.55499-1-kraxel@redhat.com> <20221004134728.55499-4-kraxel@redhat.com> In-Reply-To: <20221004134728.55499-4-kraxel@redhat.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-ClientProxiedBy: TYWP286CA0018.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::8) To DB8PR04MB7164.eurprd04.prod.outlook.com (2603:10a6:10:129::23) Return-Path: JLee@suse.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR04MB7164:EE_|AM7PR04MB6774:EE_ X-MS-Office365-Filtering-Correlation-Id: bd59a5cd-2927-44b0-1851-08db2532fc1a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VUQpzfCbAF2C4ohyexTi6ZsQ0MXtsZrkSDqGY3/HGs900tS+Qv46kWzr5Rs3lltmbRFxEhizxUf/IoruCmBy9Rc3FH89GQcUawm8bPWhRPi8EIb9tMMwkxCcp6ZBOKMTB2njjJpSESb8/HG+4T1fG0ybUZ1j8CpHy205YsmxqblsTmPXzxNdmqkHDwtjnr6NMdjjYZ1Fh7bTYcDH5X7sPOKwfaigU9U3UXdXcQWLJZcfuXxiEIr6exVFipmp17hNVsyvZRCCMSFSDNUrB3sepprzHFe/+IwdUVWFcIux6K8fG9Yuf5uZi8Fv3rYKSkxkz4Uns1VAmjvejKlakRjwSBFygcb2Lz3wQnVMFIO57mt3JQw8IfZU7L1H22OSz9/TrCJ/KB6BHoRVkDca9qirVcikvx3ItZt36QTbn5ykXtwwfcOHDCWHLaVKRXTd81vQtpVve1XW0BV6HS/jo+qjjn55GjsGl5BqO6dMxEfgsBctDbCAuo0ZL2PcWROSZqgRLwDllIBvAH9O1FvATED1gfnba9Kc30QgmAHhk9j2OdHAV3ll8XlryzNxsYgm+i/XXRTGNdmLM6YFufNJ0NgxbdgcesfKxfG0vDA8cL1hBmFV5MXJhWlQtp4N8aIh4BQF9Sf/o7q2nHotTpl5KpUhAugd5MSsxPVKOqo0PESbGzSh6HvfG1ysyoo0V3APlo8KkrIx7jsQVdlixrBhq3f2Xw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB7164.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(396003)(346002)(136003)(376002)(39860400002)(366004)(451199018)(36756003)(5660300002)(83380400001)(478600001)(8676002)(6666004)(1076003)(966005)(9686003)(6506007)(6512007)(6486002)(26005)(186003)(66476007)(66946007)(66556008)(33656002)(8936002)(41300700001)(4326008)(86362001)(54906003)(316002)(38100700002)(2906002)(66899018)(43062005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/GnMG4hV2QSN8yeDpITWFcgoFcKm6NZ+OBN61Wds7N4mecj4oYGJOxPP0pQM?= =?us-ascii?Q?k4cFgXxTvnhqqHcSwZPmN8ytVb3MLdAjOUL6Co4JmRvg3oisyzBAFDWRM1I5?= =?us-ascii?Q?SMEWwPrBhZpdTkToK5Z2T5HHiAjmZSyofdxd58MyGisHLi76DOczesjc+bKc?= =?us-ascii?Q?1y0vNsHzgXafQ5idYEVFUL2XC3ySBjWSyKnr1nZRzrIxGYT1trg5ChefaMb4?= =?us-ascii?Q?7MBM9x9MCqsx2ZNSZnXqCgKrisdztdProjlDG5ToL6ceouInB9T/sNemh1Ie?= =?us-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Zdhcc7V/d2g4QQwalR4G3M?= =?us-ascii?Q?TihR6cZbR+CB8CdkWsWCN1RsoSq3mFnAYJCU/qS6wu8hAQclbFdX6A9au6fN?= =?us-ascii?Q?FIovvLHbm5ALBOCB5lR2KxCWg9YqlW1LM+mXdNLicpj5/LAscRpLnpMZwpmK?= =?us-ascii?Q?2W5zXRH9GeVy+IFSfYX4U0jozSubEA/iAu8HO7YKuXHw8tLny+Zd0ZLZ3uXK?= =?us-ascii?Q?8VM4dQQVT+x1RtEBp34ZfapVf1PW+ZWFQG9p2SaoMYMQTVzh3iHol+Rs0j70?= =?us-ascii?Q?wYJECpqGlghfFryKVp8v4Jm1cjFmbpZknjWXga5JkRVVWPuGdp34osn5LExa?= =?us-ascii?Q?MjyXZs2pdbNA4UF8DuRCtWesBOoOGXRAhMsgRThrYccda5OZAm3IbkBhdHol?= =?us-ascii?Q?/OGU/244VAtiahnTjwaM431nemGugayTWtEWevcB?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd59a5cd-2927-44b0-1851-08db2532fc1a X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB7164.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2023 08:55:11.9008 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O+Q6ErOINDoiR4vryLWPho0y6RaLGRxXYJjUeo2amLV9x3FnKo3gXckaXRIIAodF X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR04MB6774 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Gerd, I got a page-fault in CpuIo2Dxe.dll when using edk2-stable202211 ovmf with qemu-kvm: !!!! X64 Exception Type - 0E(#PF - Page-Fault) CPU Apic ID - 00000000 !!!! ExceptionData - 000000000000000B I:0 R:1 U:0 W:1 P:1 PK:0 SS:0 SGX:0 RIP - 000000007F2CB5E8, CS - 0000000000000038, RFLAGS - 0000000000010246 RAX - 0000000000000000, RCX - 0000000000000001, RDX - 000000007F2CC5D0 RBX - 0000038280000014, RSP - 000000007FF04710, RBP - 000000007FF04790 RSI - 0000000000000000, RDI - 0000000000000000 R8 - 000000007FF04938, R9 - 0000000000000001, R10 - 0000000000000001 R11 - 0000000000000000, R12 - 000000007FF04938, R13 - 0000000000000001 R14 - 0000000000000001, R15 - 000000007F2CC3EC DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 GS - 0000000000000030, SS - 0000000000000030 CR0 - 0000000080010033, CR2 - 0000038280000014, CR3 - 000000007FC01000 CR4 - 0000000000000668, CR8 - 0000000000000000 DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 GDTR - 000000007F9DC000 0000000000000047, LDTR - 0000000000000000 IDTR - 000000007F2CD018 0000000000000FFF, TR - 0000000000000000 FXSAVE_STATE - 000000007FF04370 !!!! Find image based on IP(0x7F2CB5E8) /home/joeyli/source_code-git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe/DEBUG/CpuIo2Dxe.dll (ImageBase=000000007F2CA000, EntryPoint=000000007F2CBDE8) !!!! After reverted this ecb778d0ac62 patch, the page-fault is gone. And edk2-stable202311 can also reproduce this CpuIo2Dxe.dll page-fault. I have filed a edk2 bug against this situation: Bug 4373 - Got Page-Fault in CpuIo2Dxe.dll when using edk2-stable202211 ovmf with qemi-kvm https://bugzilla.tianocore.org/show_bug.cgi?id=4373 Do you have any idea? Thanks a lot! Joey Lee On Tue, Oct 04, 2022 at 03:47:27PM +0200, Gerd Hoffmann via groups.io wrote: > In case we have a reliable PhysMemAddressWidth use that to dynamically > size the 64bit address window. Allocate 1/8 of the physical address > space and place the window at the upper end of the address space. > > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/Library/PlatformInitLib/MemDetect.c | 28 +++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c > index 16ecbfadc30c..ae217d0242ed 100644 > --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c > +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c > @@ -604,6 +604,33 @@ PlatformAddressWidthFromCpuid ( > } > } > > +VOID > +EFIAPI > +PlatformDynamicMmioWindow ( > + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob > + ) > +{ > + UINT64 AddrSpace, MmioSpace; > + > + AddrSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); > + MmioSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth - 3); > + > + if ((PlatformInfoHob->PcdPciMmio64Size < MmioSpace) && > + (PlatformInfoHob->PcdPciMmio64Base + MmioSpace < AddrSpace)) > + { > + DEBUG ((DEBUG_INFO, "%a: using dynamic mmio window\n", __func__)); > + DEBUG ((DEBUG_INFO, "%a: Addr Space 0x%Lx (%Ld GB)\n", __func__, AddrSpace, RShiftU64 (AddrSpace, 30))); > + DEBUG ((DEBUG_INFO, "%a: MMIO Space 0x%Lx (%Ld GB)\n", __func__, MmioSpace, RShiftU64 (MmioSpace, 30))); > + PlatformInfoHob->PcdPciMmio64Size = MmioSpace; > + PlatformInfoHob->PcdPciMmio64Base = AddrSpace - MmioSpace; > + } else { > + DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__)); > + } > + > + DEBUG ((DEBUG_INFO, "%a: Pci64 Base 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Base)); > + DEBUG ((DEBUG_INFO, "%a: Pci64 Size 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Size)); > +} > + > /** > Iterate over the PCI host bridges resources information optionally provided > in fw-cfg and find the highest address contained in the PCI MMIO windows. If > @@ -765,6 +792,7 @@ PlatformAddressWidthInitialization ( > if (PlatformInfoHob->PhysMemAddressWidth != 0) { > // physical address width is known > PlatformInfoHob->FirstNonAddress = FirstNonAddress; > + PlatformDynamicMmioWindow (PlatformInfoHob); > return; > } > > -- > 2.37.3 > > > > >