diff --git a/runtime/aub/aub_helper.cpp b/runtime/aub/aub_helper.cpp index 3ecd1ee6f1..9c5853a5f7 100644 --- a/runtime/aub/aub_helper.cpp +++ b/runtime/aub/aub_helper.cpp @@ -24,7 +24,13 @@ #include "runtime/aub_mem_dump/aub_mem_dump.h" namespace OCLRT { + int AubHelper::getMemTrace(uint64_t pdEntryBits) { return AubMemDump::AddressSpaceValues::TraceNonlocal; } + +uint64_t AubHelper::getPTEntryBits(uint64_t pdEntryBits) { + return pdEntryBits; +} + } // namespace OCLRT diff --git a/runtime/aub/aub_helper.h b/runtime/aub/aub_helper.h index 642063cced..331785e684 100644 --- a/runtime/aub/aub_helper.h +++ b/runtime/aub/aub_helper.h @@ -38,5 +38,6 @@ class AubHelper { } } static int getMemTrace(uint64_t pdEntryBits); + static uint64_t getPTEntryBits(uint64_t pdEntryBits); }; } // namespace OCLRT diff --git a/runtime/aub_mem_dump/CMakeLists.txt b/runtime/aub_mem_dump/CMakeLists.txt index 2952fecfde..c61b7b49cb 100644 --- a/runtime/aub_mem_dump/CMakeLists.txt +++ b/runtime/aub_mem_dump/CMakeLists.txt @@ -26,6 +26,7 @@ set(RUNTIME_SRCS_AUB_MEM_DUMP ${CMAKE_CURRENT_SOURCE_DIR}/aub_mem_dump.h ${CMAKE_CURRENT_SOURCE_DIR}/aub_mem_dump.inl ${CMAKE_CURRENT_SOURCE_DIR}/aub_services.h + ${CMAKE_CURRENT_SOURCE_DIR}/page_table_entry_bits.h ) target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_AUB_MEM_DUMP}) set_property(GLOBAL PROPERTY RUNTIME_SRCS_AUB_MEM_DUMP ${RUNTIME_SRCS_AUB_MEM_DUMP}) diff --git a/runtime/aub_mem_dump/aub_mem_dump.inl b/runtime/aub_mem_dump/aub_mem_dump.inl index f1f40b5346..dd6e350d42 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.inl +++ b/runtime/aub_mem_dump/aub_mem_dump.inl @@ -174,7 +174,7 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; while (currPDE <= endPDE) { - auto pde = physPage | additionalBits; + auto pde = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); stream.writePTE(start_address, pde); start_address += sizeof(pde); @@ -238,7 +238,7 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre auto currPML4 = startPML4; auto physPage = BaseClass::getPDPAddress(startPDP) & g_pageMask; while (currPML4 <= endPML4) { - auto pml4 = physPage | additionalBits; + auto pml4 = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); stream.writePTE(start_address, pml4); start_address += sizeof(pml4); @@ -258,7 +258,7 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre auto currPDP = startPDP; auto physPage = BaseClass::getPDEAddress(startPDE) & g_pageMask; while (currPDP <= endPDP) { - auto pdp = physPage | additionalBits; + auto pdp = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); stream.writePTE(start_address, pdp); start_address += sizeof(pdp); @@ -278,7 +278,7 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; while (currPDE <= endPDE) { - auto pde = physPage | additionalBits; + auto pde = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); stream.writePTE(start_address, pde); start_address += sizeof(pde); diff --git a/runtime/aub_mem_dump/page_table_entry_bits.h b/runtime/aub_mem_dump/page_table_entry_bits.h new file mode 100644 index 0000000000..ba82dcd78a --- /dev/null +++ b/runtime/aub_mem_dump/page_table_entry_bits.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 - 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#pragma once + +#include + +namespace PageTableEntry { +const uint32_t presentBit = 0; +const uint32_t writableBit = 1; +const uint32_t userSupervisorBit = 2; +} // namespace PageTableEntry diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 3514c78b7a..6c18657350 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -22,6 +22,7 @@ #include "hw_cmds.h" #include "runtime/aub/aub_helper.h" +#include "runtime/aub_mem_dump/page_table_entry_bits.h" #include "runtime/command_stream/aub_subcapture.h" #include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" @@ -685,7 +686,7 @@ uint32_t AUBCommandStreamReceiverHw::getGUCWorkQueueItemHeader(Engine template uint64_t AUBCommandStreamReceiverHw::getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation) { - return 7; + return BIT(PageTableEntry::presentBit) | BIT(PageTableEntry::writableBit) | BIT(PageTableEntry::userSupervisorBit); } template diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 4464200df0..5a5eb9245d 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -21,6 +21,7 @@ */ #include "hw_cmds.h" +#include "runtime/aub_mem_dump/page_table_entry_bits.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/debug_helpers.h" #include "runtime/helpers/ptr_math.h" @@ -403,7 +404,7 @@ void TbxCommandStreamReceiverHw::waitBeforeMakingNonResidentWhenRequi template uint64_t TbxCommandStreamReceiverHw::getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation) { - return 7; + return BIT(PageTableEntry::presentBit) | BIT(PageTableEntry::writableBit) | BIT(PageTableEntry::userSupervisorBit); } template diff --git a/unit_tests/aub/aub_helper_tests.cpp b/unit_tests/aub/aub_helper_tests.cpp index 3ca72af5e4..222e79447f 100644 --- a/unit_tests/aub/aub_helper_tests.cpp +++ b/unit_tests/aub/aub_helper_tests.cpp @@ -23,6 +23,7 @@ #include "gtest/gtest.h" #include "runtime/aub/aub_helper.h" #include "runtime/aub_mem_dump/aub_mem_dump.h" +#include "runtime/aub_mem_dump/page_table_entry_bits.h" using namespace OCLRT; @@ -30,3 +31,11 @@ TEST(AubHelper, WhenGetMemTraceIsCalledWithZeroPDEntryBitsThenTraceNonLocalIsRet int hint = AubHelper::getMemTrace(0u); EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceNonlocal, hint); } + +TEST(AubHelper, WhenGetPTEntryBitsIsCalledThenEntryBitsAreNotMasked) { + uint64_t entryBits = BIT(PageTableEntry::presentBit) | + BIT(PageTableEntry::writableBit) | + BIT(PageTableEntry::userSupervisorBit); + uint64_t maskedEntryBits = AubHelper::getPTEntryBits(entryBits); + EXPECT_EQ(entryBits, maskedEntryBits); +}