From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.4209.1646706992182166839 for ; Mon, 07 Mar 2022 18:36:45 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ESu7iHHn; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646707004; x=1678243004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZYfj9fXhavl8B0wn03+tCb64zKWpNHcL68O6AiciY5U=; b=ESu7iHHnXrz8QooFQr9Pb2kLDSCQDcudWPzJ/lFKTdtpsgu1NeCFnany g+pk2IGXSDnhGP35tQaJmzA9W6ufJjHx8L6+aXELD3qHEARM1Lt1RsbQH g5NEW+4Fu1FYLSWzp+8DKCXZHNg6IGgN5LnKi9CB6Ajgf9UJgPHd+DM3n kNw87TIR5EpxOjz+Xn+vy5lGyyrATu9bjwC7y0QaZ6xU880zEKFvraKgF kze8NzmUg7cWXkpERTsTPMLQp+kdphMOQumjuxYYlnQIHVjb1woNBFuvJ RcuzFTniw73Ba2MRgsKfZ0SWbz4ZZ3AUbkImwwoEVICPmP+CU8Ubd9U0c A==; X-IronPort-AV: E=McAfee;i="6200,9189,10279"; a="317801022" X-IronPort-AV: E=Sophos;i="5.90,163,1643702400"; d="scan'208";a="317801022" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 18:36:44 -0800 X-IronPort-AV: E=Sophos;i="5.90,163,1643702400"; d="scan'208";a="553432649" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.2.184]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 18:36:40 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann , Sebastien Boeuf Subject: [PATCH 04/14] OvmfPkg/PlatformPei: Refactor MiscInitialization Date: Tue, 8 Mar 2022 10:36:05 +0800 Message-Id: X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 In MiscInitialization Microvm looks a little weird. Other platforms call PcdSet16S to set the PcdOvmfHostBridgePciDevId with the value same as PlatformInfoHob->HostBridgeDevId. But Microvm doesn't follow this way. In switch-case 0xffff is Microvm, but set with MICROVM_PSEUDO_DEVICE_ID. So we have to add a new function ( MiscInitializationForMicrovm ) for Microvm and delete the code in MiscInitialization. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Cc: Sebastien Boeuf Signed-off-by: Min Xu --- OvmfPkg/PlatformPei/Platform.c | 46 ++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 80eb4cc9adcd..af9e72cd7a98 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -304,6 +304,36 @@ MicrovmInitialization ( *FdtHobData = (UINTN)NewBase; } +VOID +MiscInitializationForMicrovm ( + IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + RETURN_STATUS PcdStatus; + + ASSERT (PlatformInfoHob->HostBridgeDevId == 0xffff); + + DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__)); + // + // Disable A20 Mask + // + IoOr8 (0x92, BIT1); + + // + // Build the CPU HOB with guest RAM size dependent address width and 16-bits + // of IO space. (Side note: unlike other HOBs, the CPU HOB is needed during + // S3 resume as well, so we build it unconditionally.) + // + BuildCpuHob (PlatformInfoHob->PhysMemAddressWidth, 16); + + MicrovmInitialization (); + PcdStatus = PcdSet16S ( + PcdOvmfHostBridgePciDevId, + MICROVM_PSEUDO_DEVICE_ID + ); + ASSERT_RETURN_ERROR (PcdStatus); +} + VOID MiscInitialization ( IN EFI_HOB_PLATFORM_INFO *PlatformInfoHob @@ -349,15 +379,6 @@ MiscInitialization ( AcpiCtlReg = POWER_MGMT_REGISTER_Q35 (ICH9_ACPI_CNTL); AcpiEnBit = ICH9_ACPI_CNTL_ACPI_EN; break; - case 0xffff: /* microvm */ - DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__)); - MicrovmInitialization (); - PcdStatus = PcdSet16S ( - PcdOvmfHostBridgePciDevId, - MICROVM_PSEUDO_DEVICE_ID - ); - ASSERT_RETURN_ERROR (PcdStatus); - return; case CLOUDHV_DEVICE_ID: DEBUG ((DEBUG_INFO, "%a: Cloud Hypervisor host bridge\n", __FUNCTION__)); PcdStatus = PcdSet16S ( @@ -762,7 +783,12 @@ InitializePlatform ( InstallClearCacheCallback (); AmdSevInitialize (); - MiscInitialization (&mPlatformInfoHob); + if (mPlatformInfoHob.HostBridgeDevId == 0xffff) { + MiscInitializationForMicrovm (&mPlatformInfoHob); + } else { + MiscInitialization (&mPlatformInfoHob); + } + InstallFeatureControlCallback (); return EFI_SUCCESS; -- 2.29.2.windows.2