Add function to get Page Table entry bits

This commit adds a helper function to get Page Table entry bits
and control a configuration of first levels page walks (non-PTE).

Change-Id: I85666ffae8e89a193d1ac4a065c2b84b814d47ec
This commit is contained in:
Milczarek, Slawomir
2018-09-11 10:26:39 +02:00
committed by sys_ocldev
parent 1530d7832f
commit 991bbddeba
8 changed files with 56 additions and 6 deletions

View File

@@ -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

View File

@@ -38,5 +38,6 @@ class AubHelper {
}
}
static int getMemTrace(uint64_t pdEntryBits);
static uint64_t getPTEntryBits(uint64_t pdEntryBits);
};
} // namespace OCLRT

View File

@@ -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})

View File

@@ -174,7 +174,7 @@ uint64_t AubPageTableHelper32<Traits>::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<Traits>::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<Traits>::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<Traits>::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);

View File

@@ -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 <stdint.h>
namespace PageTableEntry {
const uint32_t presentBit = 0;
const uint32_t writableBit = 1;
const uint32_t userSupervisorBit = 2;
} // namespace PageTableEntry

View File

@@ -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<GfxFamily>::getGUCWorkQueueItemHeader(Engine
template <typename GfxFamily>
uint64_t AUBCommandStreamReceiverHw<GfxFamily>::getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation) {
return 7;
return BIT(PageTableEntry::presentBit) | BIT(PageTableEntry::writableBit) | BIT(PageTableEntry::userSupervisorBit);
}
template <typename GfxFamily>

View File

@@ -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<GfxFamily>::waitBeforeMakingNonResidentWhenRequi
template <typename GfxFamily>
uint64_t TbxCommandStreamReceiverHw<GfxFamily>::getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation) {
return 7;
return BIT(PageTableEntry::presentBit) | BIT(PageTableEntry::writableBit) | BIT(PageTableEntry::userSupervisorBit);
}
template <typename GfxFamily>

View File

@@ -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);
}