AUB CSR: Ensured PTE bits be set correctly for Global GTT

This commit fixes the issue with setting reserved bits in PTE for GGTT.

Change-Id: I08582e20914419a3363c9e61085dcf03ba355a61
This commit is contained in:
Milczarek, Slawomir
2018-06-21 14:54:59 +02:00
committed by sys_ocldev
parent 3e65a39c62
commit fb10f666e9
9 changed files with 45 additions and 15 deletions

View File

@@ -25,6 +25,5 @@
struct AubGTTData {
bool present;
bool writable;
bool userSupervisor;
bool localMemory;
};

View File

@@ -79,7 +79,18 @@ union IAPageTableEntry {
uint64_t uiData;
};
typedef IAPageTableEntry MiGttEntry;
union MiGttEntry {
struct
{
uint64_t Present : 1; //[0]
uint64_t LocalMemory : 1; //[1]
uint64_t FunctionNumber : 10; //[11:2]
uint64_t PhysicalAddress : 35; //[46:12]
uint64_t Ignored : 17; //[63:47]
} pageConfig;
uint32_t dwordData[2];
uint64_t uiData;
};
// Use the latest DeviceValues enumerations available
typedef CmdServicesMemTraceVersion::DeviceValues DeviceValues;
@@ -282,7 +293,7 @@ struct AubDump : public TypeSelector<AubPageTableHelper32<TraitsIn>, AubPageTabl
static uint64_t reserveAddressGGTT(Stream &stream, uint32_t addr, size_t size, uint64_t physStart, AubGTTData data);
static uint64_t reserveAddressGGTT(Stream &stream, const void *memory, size_t size, uint64_t physStart, AubGTTData data);
static void reserveAddressGGTTAndWriteMmeory(Stream &stream, uintptr_t gfxAddress, const void *memory, uint64_t physAddress, size_t size, size_t offset, uint64_t additionalBits);
static void setGttEntry(IAPageTableEntry &entry, uint64_t address, AubGTTData data);
static void setGttEntry(MiGttEntry &entry, uint64_t address, AubGTTData data);
private:
static uint64_t reserveAddress(Stream &stream, uint32_t addr, size_t size, unsigned int addressSpace /* = AddressSpaceValues::TraceGttEntry*/, uint64_t physStart, AubGTTData data);

View File

@@ -141,12 +141,11 @@ void AubDump<Traits>::reserveAddressGGTTAndWriteMmeory(typename Traits::Stream &
}
template <typename Traits>
void AubDump<Traits>::setGttEntry(IAPageTableEntry &entry, uint64_t address, AubGTTData data) {
void AubDump<Traits>::setGttEntry(MiGttEntry &entry, uint64_t address, AubGTTData data) {
entry.uiData = 0;
entry.pageConfig.PhysicalAddress = address / 4096;
entry.pageConfig.Present = data.present;
entry.pageConfig.Writable = data.writable;
entry.pageConfig.UserSupervisor = data.userSupervisor;
entry.pageConfig.LocalMemory = data.localMemory;
}
template <typename Traits>

View File

@@ -627,8 +627,7 @@ uint64_t AUBCommandStreamReceiverHw<GfxFamily>::getPPGTTAdditionalBits(GraphicsA
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::getGTTData(void *memory, AubGTTData &data) {
data.present = true;
data.writable = true;
data.userSupervisor = true;
data.localMemory = false;
}
} // namespace OCLRT

View File

@@ -395,7 +395,6 @@ uint64_t TbxCommandStreamReceiverHw<GfxFamily>::getPPGTTAdditionalBits(GraphicsA
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::getGTTData(void *memory, AubGTTData &data) {
data.present = true;
data.writable = true;
data.userSupervisor = true;
data.localMemory = false;
}
} // namespace OCLRT

View File

@@ -109,7 +109,7 @@ HWTEST_F(AubMemDumpTests, writeVerifyOneByteGGTT) {
uint8_t byte = 0xbf;
uint64_t physAddress = reinterpret_cast<uint64_t>(&byte) & 0xFFFFFFFF;
AubGTTData data = {true, true, true};
AubGTTData data = {true, false};
AUB::reserveAddressGGTT(aubFile, &byte, sizeof(byte), physAddress, data);
AUB::addMemoryWrite(aubFile, physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal);
aubFile.expectMemory(physAddress, &byte, sizeof(byte));
@@ -153,7 +153,7 @@ HWTEST_F(AubMemDumpTests, writeVerifySevenBytesGGTT) {
uint8_t bytes[] = {0, 1, 2, 3, 4, 5, 6};
uint64_t physAddress = reinterpret_cast<uint64_t>(bytes) & 0xFFFFFFFF;
AubGTTData data = {true, true, true};
AubGTTData data = {true, false};
AUB::reserveAddressGGTT(aubFile, bytes, sizeof(bytes), physAddress, data);
AUB::addMemoryWrite(aubFile, physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal);
aubFile.expectMemory(physAddress, bytes, sizeof(bytes));

View File

@@ -63,7 +63,7 @@ void setupAUB(const OCLRT::Device *pDevice, OCLRT::EngineType engineType) {
auto pGlobalHWStatusPage = alignedMalloc(sizeHWSP, alignHWSP);
uint32_t ggttGlobalHardwareStatusPage = (uint32_t)((uintptr_t)pGlobalHWStatusPage);
AubGTTData data = {true, true, true};
AubGTTData data = {true, false};
AUB::reserveAddressGGTT(aubFile, ggttGlobalHardwareStatusPage, sizeHWSP, physAddress, data);
physAddress += sizeHWSP;

View File

@@ -52,7 +52,7 @@ void setupAUBWithBatchBuffer(const OCLRT::Device *pDevice, OCLRT::EngineType eng
auto pGlobalHWStatusPage = alignedMalloc(sizeHWSP, alignHWSP);
uint32_t ggttGlobalHardwareStatusPage = (uint32_t)((uintptr_t)pGlobalHWStatusPage);
AubGTTData data = {true, true, true};
AubGTTData data = {true, false};
AUB::reserveAddressGGTT(aubFile, ggttGlobalHardwareStatusPage, sizeHWSP, physAddress, data);
physAddress += sizeHWSP;

View File

@@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/aub_mem_dump/aub_mem_dump.h"
#include "runtime/command_stream/aub_command_stream_receiver_hw.h"
#include "runtime/helpers/dispatch_info.h"
#include "runtime/helpers/flat_batch_buffer_helper_hw.h"
@@ -1543,6 +1544,28 @@ HWTEST_F(AubCommandStreamReceiverTests, givenDbgDeviceIdFlagIsSetWhenAubCsrIsCre
EXPECT_EQ(9u, aubCsr->aubDeviceId);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetGTTDataIsCalledThenLocalMemoryShouldBeDisabled) {
const HardwareInfo &hwInfoIn = *platformDevices[0];
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(hwInfoIn, true));
AubGTTData data = {};
aubCsr->getGTTData(nullptr, data);
EXPECT_TRUE(data.present);
EXPECT_FALSE(data.localMemory);
}
HWTEST_F(AubCommandStreamReceiverTests, givenPhysicalAddressWhenSetGttEntryIsCalledThenGttEntrysBitFieldsShouldBePopulated) {
typedef typename AUBFamilyMapper<FamilyType>::AUB AUB;
AubMemDump::MiGttEntry entry = {};
uint64_t address = 0x0123456789;
AubGTTData data = {true, false};
AUB::setGttEntry(entry, address, data);
EXPECT_EQ(entry.pageConfig.PhysicalAddress, address / 4096);
EXPECT_TRUE(entry.pageConfig.Present);
EXPECT_FALSE(entry.pageConfig.LocalMemory);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif