Skip to content

Commit 0240f23

Browse files
downorCompute-Runtime-Automation
authored andcommitted
check if the whole object region is in 32Bit address space boundary
checks the address + size of buffer object to determine whether the object is located within 32bit address space boundary. v2: changed end year to 2019 in ther license term v3: added unit test for checking of flag when size of bo is given. v4: two different unit tests are created to cover two different case separately Change-Id: Ie2df6025fc116aca679dcfe88d858ff240278c39 Signed-off-by: dongwonk <dongwon.kim@intel.com>
1 parent 856e0cc commit 0240f23

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

runtime/os_interface/linux/drm_buffer_object.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -114,7 +114,8 @@ void BufferObject::fillExecObject(drm_i915_gem_exec_object2 &execObject, uint32_
114114
execObject.offset = this->isSoftpin ? this->offset64 : 0;
115115
execObject.flags = this->isSoftpin ? EXEC_OBJECT_PINNED : 0;
116116
#ifdef __x86_64__
117-
execObject.flags |= reinterpret_cast<uint64_t>(this->address) & MemoryConstants::zoneHigh ? EXEC_OBJECT_SUPPORTS_48B_ADDRESS : 0;
117+
// set EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag if whole object resides in 32BIT address space boundary
118+
execObject.flags |= (reinterpret_cast<uint64_t>(this->address) + this->size) & MemoryConstants::zoneHigh ? EXEC_OBJECT_SUPPORTS_48B_ADDRESS : 0;
118119
#endif
119120
execObject.rsvd1 = drmContextId;
120121
execObject.rsvd2 = 0;

unit_tests/os_interface/linux/drm_buffer_object_tests.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -29,6 +29,10 @@ class TestedBufferObject : public BufferObject {
2929
execObjectPointerFilled = &execObject;
3030
}
3131

32+
void setSize(size_t size) {
33+
this->size = size;
34+
}
35+
3236
drm_i915_gem_exec_object2 *execObjectPointerFilled = nullptr;
3337
};
3438

@@ -94,19 +98,25 @@ TEST_F(DrmBufferObjectTest, setTiling_ioctlFailed) {
9498
EXPECT_FALSE(ret);
9599
}
96100

97-
TEST_F(DrmBufferObjectTest, testExecObjectFlags) {
101+
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedCrosses32BitBoundaryWhenExecIsCalledThen48BitFlagIsSet) {
98102
drm_i915_gem_exec_object2 execObject;
99103

100-
#ifdef __x86_64__
101104
memset(&execObject, 0, sizeof(execObject));
102-
bo->setAddress((void *)((uint64_t)1u << 34)); //anything above 4GB
105+
bo->setAddress((void *)(((uint64_t)1u << 32) - 0x1000u));
106+
bo->setSize(0x1000);
103107
bo->fillExecObject(execObject, 1);
108+
//base address + size > size of 32bit address space
104109
EXPECT_TRUE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
105-
#endif
110+
}
111+
112+
TEST_F(DrmBufferObjectTest, givenAddressThatWhenSizeIsAddedWithin32BitBoundaryWhenExecIsCalledThen48BitFlagIsNotSet) {
113+
drm_i915_gem_exec_object2 execObject;
106114

107115
memset(&execObject, 0, sizeof(execObject));
108-
bo->setAddress((void *)((uint64_t)1u << 31)); //anything below 4GB
116+
bo->setAddress((void *)(((uint64_t)1u << 32) - 0x1000u));
117+
bo->setSize(0xFFF);
109118
bo->fillExecObject(execObject, 1);
119+
//base address + size < size of 32bit address space
110120
EXPECT_FALSE(execObject.flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS);
111121
}
112122

0 commit comments

Comments
 (0)