VMM - touch_page stops at P2 for huge pages
This commit is contained in:
parent
e68698ff80
commit
96a877c95b
@ -73,6 +73,9 @@ int touch_page(void *P4, uintptr_t addr, uint16_t flags)
|
|||||||
{
|
{
|
||||||
if(!P4) return -1;
|
if(!P4) return -1;
|
||||||
|
|
||||||
|
int huge=(flags & PAGE_HUGE)?1:0;
|
||||||
|
flags ^= PAGE_HUGE*huge;
|
||||||
|
|
||||||
if((!P4e(P4, addr).present)
|
if((!P4e(P4, addr).present)
|
||||||
&& (!(P4e(P4, addr).value = pmm_alloc())))
|
&& (!(P4e(P4, addr).value = pmm_alloc())))
|
||||||
return -1;
|
return -1;
|
||||||
@ -83,6 +86,8 @@ int touch_page(void *P4, uintptr_t addr, uint16_t flags)
|
|||||||
return -1;
|
return -1;
|
||||||
P3e(P4, addr).value |= flags | PAGE_PRESENT;
|
P3e(P4, addr).value |= flags | PAGE_PRESENT;
|
||||||
|
|
||||||
|
if(huge) return 0;
|
||||||
|
|
||||||
if((!P2e(P4, addr).present)
|
if((!P2e(P4, addr).present)
|
||||||
&& (!(P2e(P4, addr).value = pmm_alloc())))
|
&& (!(P2e(P4, addr).value = pmm_alloc())))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -143,9 +143,9 @@ TEST(touch_page_adds_P1)
|
|||||||
}
|
}
|
||||||
TEST(touch_page_sets_flags)
|
TEST(touch_page_sets_flags)
|
||||||
{
|
{
|
||||||
touch_page(p4, 0, 0x123);
|
touch_page(p4, 0, PAGE_WRITE);
|
||||||
|
|
||||||
ASSERT_EQ_PTR(p2[0], (uintptr_t)p1 | 0x123 | PAGE_PRESENT);
|
ASSERT_EQ_PTR(p2[0], (uintptr_t)p1 | PAGE_WRITE | PAGE_PRESENT);
|
||||||
}
|
}
|
||||||
TEST(touch_page_fails_if_out_of_pages)
|
TEST(touch_page_fails_if_out_of_pages)
|
||||||
{
|
{
|
||||||
@ -153,6 +153,11 @@ TEST(touch_page_fails_if_out_of_pages)
|
|||||||
int retval = touch_page(p4, 0, 0);
|
int retval = touch_page(p4, 0, 0);
|
||||||
ASSERT_NEQ_INT(retval, 0);
|
ASSERT_NEQ_INT(retval, 0);
|
||||||
}
|
}
|
||||||
|
TEST(touch_page_stops_at_P2_for_huge_pages)
|
||||||
|
{
|
||||||
|
touch_page(p4, 0, PAGE_HUGE);
|
||||||
|
ASSERT_EQ_PTR(p2[0], 0);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(free_page_unsets_page)
|
TEST(free_page_unsets_page)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user