From patchwork Thu Mar 25 15:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12164501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_BASE64_TEXT, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04123C433DB for ; Thu, 25 Mar 2021 15:48:04 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BC556619A3 for ; Thu, 25 Mar 2021 15:48:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC556619A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.101435.194091 (Exim 4.92) (envelope-from ) id 1lPSD2-000821-Om; Thu, 25 Mar 2021 15:47:44 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 101435.194091; Thu, 25 Mar 2021 15:47:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lPSD2-00081q-J6; Thu, 25 Mar 2021 15:47:44 +0000 Received: by outflank-mailman (input) for mailman id 101435; Thu, 25 Mar 2021 15:47:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lPSD1-0007aB-FS for xen-devel@lists.xenproject.org; Thu, 25 Mar 2021 15:47:43 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 24bc23c7-a82f-4d74-a313-cf5a4ff99df6; Thu, 25 Mar 2021 15:47:27 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 24bc23c7-a82f-4d74-a313-cf5a4ff99df6 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1616687247; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9NIhmInwFrEyRfF/0lSClNIrgZWInTJXzd/zYMEZRIY=; b=ZAr701+KvOpLohM4d9X2X4uGGhN85izEGHT9REjZC22LJTkMvndNqpxS djRk/LvYzNHCSP03jKb8QsrPmhTZ+WEja1EV7ytLvkQEAN1/rqb8Vn6WJ sMwb8ZJWAuPDLGS3xynYvguac2UYeEDV61Y6QYd+2ZLdz0eo0TT/9RvK3 M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: QFQ1b6fWFHLgb+DjGLN6WF/XkBqAje0fgdLo8kJXuhuKCfvWyOq3oikI8sgAanJR2P6PbS+qPy 3D28XJzkRYLzcu9J6FEThhoIDDWo+6oK091dtrda6s5mu0ZATAr1qzD99MTmqCwp3jhvurbvs3 HYAA2NnMLNv7MnOBI6QqIXzkA/YXx1HTt6LIxi+exNDftkR796KphVIQ3dJLIw6z7U1WgEm8C0 HCOBYP4/jRSQxbKCPsWvZnnlG1f89jNHrBnPHZ8RX6W6kuJqdadUMjsfEfnXPFJ2OwWfrk3YXB mGM= X-SBRS: 5.1 X-MesageID: 40123477 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:5QOVKqEOtvtoO/FZpLqFOpHXdLJzesId70hD6mlYVQFVfsuEl8 qngfQc0lvOhCwMXWw78OrsBICrSxrnlaJdy48XILukQU3aqHKlRbsSibfK7h/BP2nF9uBb3b p9aKQWMrfNJHVzkMqS2maFOvk6xt3vys6VrMP/61socg1wcaFn6G5Ce2OmO2l7XhNPC5Z8NL f03LslmxOadX4abtu2CxA+NoCum/TxmI/7ehlDPhY76WC15g+A0qLwEBSTw34lIlFy6IolmF KlryXJop+Nntv+4R/a2m/V4f1t6abc4+oGPuOgoIw4Lj3tjyyheYhuXaaT1QpF3N2H2RIRv/ Tn5zsmIsRv+1PdF1vF3ifF6k3b/xsFr1/k1FOCjnPoraXCNUwHIvsEv611WF/9ySMbzbZB+Z MO5U21nd5rKCmFuyLH693BR3hR5zGJiEtnq8E/pThiS4cEAYUhy7A3zQduP7orOjn104wjGP kGNrCn2N9mNWmXaH3UpQBUsaWRd0V2Gh+HR34LsdCO3w5Xm2hkz1AZyNZ3pAZ5yK4A X-IronPort-AV: E=Sophos;i="5.81,277,1610427600"; d="scan'208";a="40123477" From: Anthony PERARD To: CC: , Jordan Justen , Anthony PERARD , "Ard Biesheuvel" , Laszlo Ersek , Julien Grall Subject: [PATCH v2 7/7] OvmfPkg/OvmfXen: Set PcdFSBClock Date: Thu, 25 Mar 2021 15:47:13 +0000 Message-ID: <20210325154713.670104-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210325154713.670104-1-anthony.perard@citrix.com> References: <20210325154713.670104-1-anthony.perard@citrix.com> MIME-Version: 1.0 Update gEfiMdePkgTokenSpaceGuid.PcdFSBClock so it can have the correct value when SecPeiDxeTimerLibCpu start to use it for the APIC timer. Currently, nothing appear to use the value in PcdFSBClock before XenPlatformPei had a chance to set it even though TimerLib is included in modules runned before XenPlatformPei. XenPlatformPei doesn't use any of the functions that would use that value. No other modules in the PEI phase seems to use the TimerLib before PcdFSBClock is set. There are currently two other modules in the PEI phase that needs the TimerLib: - S3Resume2Pei, but only because LocalApicLib needs it, but nothing is using the value from PcdFSBClock. - CpuMpPei, but I believe it only runs after XenPlatformPei Before the PEI phase, there's the SEC phase, and SecMain needs TimerLib because of LocalApicLib. And it initialise the APIC timers for the debug agent. But I don't think any of the DebugLib that OvmfXen could use are actually using the *Delay functions in TimerLib, and so would not use the value from PcdFSBClock which would be uninitialised. A simple runtime test showed that TimerLib doesn't use PcdFSBClock value before it is set. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2490 Signed-off-by: Anthony PERARD Reviewed-by: Laszlo Ersek Reviewed-by: Laszlo Ersek --- Notes: v2: - keep the default value of PcdFSBClock because that is part of the syntax. OvmfPkg/OvmfXen.dsc | 4 +--- OvmfPkg/XenPlatformPei/XenPlatformPei.inf | 1 + OvmfPkg/XenPlatformPei/Xen.c | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 507029404f0b..faf3930ace04 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -442,9 +442,6 @@ [PcdsFixedAtBuild] # Point to the MdeModulePkg/Application/UiApp/UiApp.inf gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } - ## Xen vlapic's frequence is 100 MHz - gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000 - # We populate DXE IPL tables with 1G pages preferably on Xen gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE @@ -471,6 +468,7 @@ [PcdsDynamicDefault] gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0 gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000 + gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000 gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|0 # Set video resolution for text setup. diff --git a/OvmfPkg/XenPlatformPei/XenPlatformPei.inf b/OvmfPkg/XenPlatformPei/XenPlatformPei.inf index 5732d2188871..87dd4b24679a 100644 --- a/OvmfPkg/XenPlatformPei/XenPlatformPei.inf +++ b/OvmfPkg/XenPlatformPei/XenPlatformPei.inf @@ -85,6 +85,7 @@ [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask + gEfiMdePkgTokenSpaceGuid.PcdFSBClock gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress diff --git a/OvmfPkg/XenPlatformPei/Xen.c b/OvmfPkg/XenPlatformPei/Xen.c index 7524aaa11a29..a29b4e04086e 100644 --- a/OvmfPkg/XenPlatformPei/Xen.c +++ b/OvmfPkg/XenPlatformPei/Xen.c @@ -632,5 +632,9 @@ CalibrateLapicTimer ( Freq = DivU64x64Remainder (Dividend, TscTick2 - TscTick, NULL); DEBUG ((DEBUG_INFO, "APIC Freq % 8lu Hz\n", Freq)); + ASSERT (Freq <= MAX_UINT32); + Status = PcdSet32S (PcdFSBClock, Freq); + ASSERT_RETURN_ERROR (Status); + UnmapXenPage (SharedInfo); }