From e466fcd7be2f62ef43d36d27b93f95cc5406186e Mon Sep 17 00:00:00 2001 From: Kacper Nowak Date: Wed, 12 Jul 2023 15:03:57 +0000 Subject: [PATCH] feature(zebin): Re-introduce support for validation using PRODUCT_CONFIG value Related-To: IGC-6300 Signed-off-by: Kacper Nowak --- .../zebin/zebin_decoder.cpp | 3 ++ .../zebin_decoder_tests.cpp | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/shared/source/device_binary_format/zebin/zebin_decoder.cpp b/shared/source/device_binary_format/zebin/zebin_decoder.cpp index 546bcb5aad..b347035f91 100644 --- a/shared/source/device_binary_format/zebin/zebin_decoder.cpp +++ b/shared/source/device_binary_format/zebin/zebin_decoder.cpp @@ -124,6 +124,9 @@ bool validateTargetDevice(const Elf::Elf &elf, const TargetDevice &targ break; } case Elf::IntelGTSectionType::ProductConfig: { + DEBUG_BREAK_IF(sizeof(uint32_t) != intelGTNote.data.size()); + auto productConfigData = reinterpret_cast(intelGTNote.data.begin()); + productConfig = static_cast(*productConfigData); break; } case Elf::IntelGTSectionType::vISAAbiVersion: { diff --git a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp index a7f631570c..a83245a2d5 100644 --- a/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp +++ b/shared/test/unit_test/device_binary_format/zebin_decoder_tests.cpp @@ -5580,6 +5580,38 @@ TEST_F(IntelGTNotesFixture, WhenValidatingTargetDeviceGivenValidTargetDeviceAndV EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator)); } +TEST_F(IntelGTNotesFixture, givenAotConfigInIntelGTNotesSectionWhenValidatingTargetDeviceThenUseOnlyItForValidation) { + NEO::HardwareIpVersion aotConfig = {0}; + aotConfig.value = 0x00001234; + + TargetDevice targetDevice; + targetDevice.maxPointerSizeInBytes = 8u; + ASSERT_EQ(IGFX_UNKNOWN, targetDevice.productFamily); + ASSERT_EQ(IGFX_UNKNOWN_CORE, targetDevice.coreFamily); + targetDevice.aotConfig.value = aotConfig.value; + + NEO::Elf::ElfNoteSection elfNoteSection; + elfNoteSection.descSize = 4u; + elfNoteSection.nameSize = 8u; + elfNoteSection.type = Zebin::Elf::IntelGTSectionType::ProductConfig; + + uint8_t productConfigData[4]; + memcpy_s(productConfigData, 4, &aotConfig.value, 4); + + auto sectionDataSize = sizeof(NEO::Elf::ElfNoteSection) + elfNoteSection.nameSize + elfNoteSection.descSize; + auto noteIntelGTSectionData = std::make_unique(sectionDataSize); + appendSingleIntelGTSectionData(elfNoteSection, noteIntelGTSectionData.get(), productConfigData, NEO::Zebin::Elf::IntelGTNoteOwnerName.data(), sectionDataSize); + zebin.appendSection(NEO::Elf::SHT_NOTE, Zebin::Elf::SectionNames::noteIntelGT, ArrayRef::fromAny(noteIntelGTSectionData.get(), sectionDataSize)); + + std::string outErrReason, outWarning; + auto elf = NEO::Elf::decodeElf(zebin.storage, outErrReason, outWarning); + EXPECT_TRUE(outWarning.empty()); + EXPECT_TRUE(outErrReason.empty()); + GeneratorType generator{}; + + EXPECT_TRUE(validateTargetDevice(elf, targetDevice, outErrReason, outWarning, generator)); +} + TEST(ValidateTargetDevice32BitZebin, Given32BitZebinAndValidIntelGTNotesWhenValidatingTargetDeviceThenReturnTrue) { TargetDevice targetDevice; targetDevice.productFamily = productFamily;