From 7c297de8956e934ee0bf3608bc8d6535f8d8e2f4 Mon Sep 17 00:00:00 2001 From: hanliyang Date: Mon, 20 May 2024 08:18:59 +0000 Subject: [PATCH] Fix failure to recognize block device in CSV3 guest The commit 049695a0b1 ("MdeModulePkg/PciBusDxe: Add feedback status for PciIoMap") has adds feedback with the status of SetAttribute () return value in PciIoMap (), it is necessary to implement SetAttribute () for CsvIoMmu to fix the CSV3 boot up failure issue. Signed-off-by: hanliyang --- ...e-Implement-SetAttribute-of-CsvIoMmu.patch | 82 +++++++++++++++++++ edk2.spec | 6 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 0021-OvmfPkg-IoMmuDxe-Implement-SetAttribute-of-CsvIoMmu.patch diff --git a/0021-OvmfPkg-IoMmuDxe-Implement-SetAttribute-of-CsvIoMmu.patch b/0021-OvmfPkg-IoMmuDxe-Implement-SetAttribute-of-CsvIoMmu.patch new file mode 100644 index 0000000..a36b96f --- /dev/null +++ b/0021-OvmfPkg-IoMmuDxe-Implement-SetAttribute-of-CsvIoMmu.patch @@ -0,0 +1,82 @@ +From e8084565f3e41b55a0e1637b5fd948502fbec043 Mon Sep 17 00:00:00 2001 +From: Xin Jiang +Date: Mon, 20 May 2024 13:53:17 +0800 +Subject: [PATCH] OvmfPkg/IoMmuDxe: Implement SetAttribute() of CsvIoMmu + +As PciIoMap() adds feedback with the status of SetAttribute () +return value, it is necessary to implement SetAttribute () for +CsvIoMmu to fix the CSV3 boot up failure issue. + +Signed-off-by: Xin Jiang +Signed-off-by: hanliyang +--- + OvmfPkg/IoMmuDxe/CsvIoMmu.c | 53 ++++++++++++++++++++++++++++++++++++- + 1 file changed, 52 insertions(+), 1 deletion(-) + +diff --git a/OvmfPkg/IoMmuDxe/CsvIoMmu.c b/OvmfPkg/IoMmuDxe/CsvIoMmu.c +index 2a46e98..755ef06 100644 +--- a/OvmfPkg/IoMmuDxe/CsvIoMmu.c ++++ b/OvmfPkg/IoMmuDxe/CsvIoMmu.c +@@ -539,7 +539,58 @@ CsvIoMmuSetAttribute ( + IN UINT64 IoMmuAccess + ) + { +- return EFI_UNSUPPORTED; ++ MAP_INFO *MapInfo; ++ EFI_STATUS Status; ++ ++ DEBUG ((DEBUG_VERBOSE, "%a: Mapping=0x%p Access=%lu\n", __func__, Mapping, IoMmuAccess)); ++ ++ if (Mapping == NULL) { ++ return EFI_INVALID_PARAMETER; ++ } ++ ++ Status = EFI_SUCCESS; ++ ++ // ++ // An IoMmuAccess value of 0 is always accepted, validate any non-zero value. ++ // ++ if (IoMmuAccess != 0) { ++ MapInfo = (MAP_INFO *)Mapping; ++ ++ // ++ // The mapping operation already implied the access mode. Validate that ++ // the supplied access mode matches operation access mode. ++ // ++ switch (MapInfo->Operation) { ++ case EdkiiIoMmuOperationBusMasterRead: ++ case EdkiiIoMmuOperationBusMasterRead64: ++ if (IoMmuAccess != EDKII_IOMMU_ACCESS_READ) { ++ Status = EFI_INVALID_PARAMETER; ++ } ++ ++ break; ++ ++ case EdkiiIoMmuOperationBusMasterWrite: ++ case EdkiiIoMmuOperationBusMasterWrite64: ++ if (IoMmuAccess != EDKII_IOMMU_ACCESS_WRITE) { ++ Status = EFI_INVALID_PARAMETER; ++ } ++ ++ break; ++ ++ case EdkiiIoMmuOperationBusMasterCommonBuffer: ++ case EdkiiIoMmuOperationBusMasterCommonBuffer64: ++ if (IoMmuAccess != (EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE)) { ++ Status = EFI_INVALID_PARAMETER; ++ } ++ ++ break; ++ ++ default: ++ Status = EFI_UNSUPPORTED; ++ } ++ } ++ ++ return Status; + } + + EDKII_IOMMU_PROTOCOL mCsv = { +-- +2.31.1 + diff --git a/edk2.spec b/edk2.spec index a533ab4..3e8dabe 100644 --- a/edk2.spec +++ b/edk2.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 4 %undefine _auto_set_build_flags ExclusiveArch: x86_64 aarch64 loongarch64 @@ -80,6 +80,7 @@ Patch0017: 0017-OvmfPkg-AmdSevDxe-Add-support-for-SEV-live-migration.patch Patch0018: 0018-OvmfPkg-BaseMemcryptSevLib-Correct-the-calculation-o.patch Patch0019: 0019-OvmfPkg-BaseMemEncryptLib-Return-SUCCESS-if-not-supp.patch Patch0020: 0020-OvmfPkg-BaseMemEncryptLib-Save-memory-encrypt-status.patch +Patch0021: 0021-OvmfPkg-IoMmuDxe-Implement-SetAttribute-of-CsvIoMmu.patch BuildRequires: python3-devel BuildRequires: libuuid-devel @@ -479,6 +480,9 @@ install -m 0644 \ %changelog +* Mon May 20 2024 Liyang Han - 202402-4 +- Fix failure to recognize block device in CSV3 guest + * Fri May 17 2024 Xiaotian Wu - 202402-3 - Fix json file to match loongarch64 machine. -- Gitee