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.web12.10908.1647132088165160377 for ; Sat, 12 Mar 2022 16:41:47 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MzIu6bwl; 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=1647132107; x=1678668107; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4Kcc86iFGJxpFkq4bGDpUHGF8XU2GOa6qH1y6ynJzBo=; b=MzIu6bwlx7rN/v95B+aZtMLmmbZC6a8fPxLpgGSgB6+KnTIcUVv3JeYy isCATNSYzDKJpF+7diPTzXqPbhIJ4t0vhwdDsz2ohw8jk1Mjd7IG+n26H f873qzwpI7iuhROEQXIAgO4aBlDsZKzbyD1O7uuXPzisEWZW8wLdEO0hz ESgHBJAX/iUAjoyq58R8hwQpqqC+K+F1+ZlD3izuKoaBCkdaC8R38Raj6 93WeY91Lr8ex3ymwMa78IG2zWFPrLFr9D/uGaj8ZNT75ExrY3GH0L3O2F wxXzRH2sc6VRp00zFw96whMR9IlqgO8OA46elc0K2rujvyfXG/bb7CpsT w==; X-IronPort-AV: E=McAfee;i="6200,9189,10284"; a="319056930" X-IronPort-AV: E=Sophos;i="5.90,177,1643702400"; d="scan'208";a="319056930" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2022 16:41:47 -0800 X-IronPort-AV: E=Sophos;i="5.90,177,1643702400"; d="scan'208";a="539479362" Received: from xshi3x-mobl.ccr.corp.intel.com (HELO mxu9-mobl1.ccr.corp.intel.com) ([10.249.171.182]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2022 16:41:44 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Michael D Kinney , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [PATCH V5 07/10] OvmfPkg/IncompatiblePciDeviceSupportDxe: Refine the configuration Date: Sun, 13 Mar 2022 08:41:08 +0800 Message-Id: <20220313004111.388-8-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 In-Reply-To: <20220313004111.388-1-min.m.xu@intel.com> References: <20220313004111.388-1-min.m.xu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 MMIO64_PREFERENCE is a fixed length data structure which contains one AddressSpaceDesc and one EndDesc. This patch removes MMIO64_PREFERENCE and create AddressSpaceDesc and EndDesc respectively. This change gives the chance to add more AddressSpaceDesc when CheckDevice is called. Cc: Michael D Kinney Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Signed-off-by: Min Xu --- .../IncompatiblePciDeviceSupport.c | 64 ++++++++++--------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c index 8730874613f8..f5c03bdf6dd6 100644 --- a/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c +++ b/OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.c @@ -9,6 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include +#include #include #include @@ -40,49 +42,38 @@ STATIC EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL // This structure is interpreted by the UpdatePciInfo() function in the edk2 // PCI Bus UEFI_DRIVER. // -#pragma pack (1) -typedef struct { - EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR AddressSpaceDesc; - EFI_ACPI_END_TAG_DESCRIPTOR EndDesc; -} MMIO64_PREFERENCE; -#pragma pack () - -STATIC CONST MMIO64_PREFERENCE mConfiguration = { - // - // AddressSpaceDesc - // - { - ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc - (UINT16)( // Len +// This structure looks like: +// AddressDesc-1 + AddressDesc-2 + ... + AddressDesc-n + EndDesc +// +STATIC CONST EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mMmio64Configuration = { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + (UINT16)( // Len sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - OFFSET_OF ( EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR, ResType ) ), - ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType - 0, // GenFlag - 0, // SpecificFlag - 64, // AddrSpaceGranularity: + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 64, // AddrSpaceGranularity: // aperture selection hint // for BAR allocation - 0, // AddrRangeMin - 0, // AddrRangeMax: + 0, // AddrRangeMin + 0, // AddrRangeMax: // no special alignment // for affected BARs - MAX_UINT64, // AddrTranslationOffset: + MAX_UINT64, // AddrTranslationOffset: // hint covers all // eligible BARs - 0 // AddrLen: + 0 // AddrLen: // use probed BAR size - }, - // - // EndDesc - // - { - ACPI_END_TAG_DESCRIPTOR, // Desc - 0 // Checksum: to be ignored - } +}; + +STATIC CONST EFI_ACPI_END_TAG_DESCRIPTOR mEndDesc = { + ACPI_END_TAG_DESCRIPTOR, // Desc + 0 // Checksum: to be ignored }; // @@ -203,6 +194,8 @@ CheckDevice ( ) { mCheckDeviceCalled = TRUE; + UINTN Length; + UINT8 *Ptr; // // Unlike the general description of this protocol member suggests, there is @@ -232,7 +225,10 @@ CheckDevice ( // the edk2 PCI Bus UEFI_DRIVER actually handles error codes; see the // UpdatePciInfo() function. // - *Configuration = AllocateCopyPool (sizeof mConfiguration, &mConfiguration); + Length = sizeof mMmio64Configuration + sizeof mEndDesc; + + *Configuration = AllocateZeroPool (Length); + if (*Configuration == NULL) { DEBUG (( DEBUG_WARN, @@ -245,6 +241,12 @@ CheckDevice ( return EFI_OUT_OF_RESOURCES; } + Ptr = (UINT8 *)(UINTN)*Configuration; + CopyMem (Ptr, &mMmio64Configuration, sizeof mMmio64Configuration); + Length = sizeof mMmio64Configuration; + + CopyMem (Ptr + Length, &mEndDesc, sizeof mEndDesc); + return EFI_SUCCESS; } -- 2.29.2.windows.2