@ -7,6 +7,7 @@
#define MSR_LE 0x1
#define MSR_LE 0x1
#define MSR_DR 0x10
#define MSR_DR 0x10
#define MSR_IR 0x20
#define MSR_IR 0x20
#define MSR_HV 0x1000000000000000ul
#define MSR_SF 0x8000000000000000ul
#define MSR_SF 0x8000000000000000ul
extern int test_read(long *addr, long *ret, long init);
extern int test_read(long *addr, long *ret, long init);
@ -450,11 +451,11 @@ int mmu_test_11(void)
unsigned long ptr = 0x523000;
unsigned long ptr = 0x523000;
/* this should fail */
/* this should fail */
if (test_exec(0, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(0, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != (long) ptr ||
if (mfspr(SRR0) != (long) ptr ||
mfspr(SRR1) != (MSR_SF | 0x40000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x40000000 | MSR_IR | MSR_LE))
return 2;
return 2;
return 0;
return 0;
}
}
@ -468,12 +469,12 @@ int mmu_test_12(void)
/* create PTE */
/* create PTE */
map((void *)ptr, (void *)mem, PERM_EX | REF);
map((void *)ptr, (void *)mem, PERM_EX | REF);
/* this should succeed and be a cache miss */
/* this should succeed and be a cache miss */
if (!test_exec(0, ptr, MSR_SF | MSR_IR | MSR_LE))
if (!test_exec(0, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* create a second PTE */
/* create a second PTE */
map((void *)ptr2, (void *)mem, PERM_EX | REF);
map((void *)ptr2, (void *)mem, PERM_EX | REF);
/* this should succeed and be a cache hit */
/* this should succeed and be a cache hit */
if (!test_exec(0, ptr2, MSR_SF | MSR_IR | MSR_LE))
if (!test_exec(0, ptr2, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 2;
return 2;
return 0;
return 0;
}
}
@ -487,18 +488,18 @@ int mmu_test_13(void)
/* create a PTE */
/* create a PTE */
map((void *)ptr, (void *)mem, PERM_EX | REF);
map((void *)ptr, (void *)mem, PERM_EX | REF);
/* this should succeed */
/* this should succeed */
if (!test_exec(1, ptr, MSR_SF | MSR_IR | MSR_LE))
if (!test_exec(1, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* invalidate the PTE */
/* invalidate the PTE */
unmap((void *)ptr);
unmap((void *)ptr);
/* install a second PTE */
/* install a second PTE */
map((void *)ptr2, (void *)mem, PERM_EX | REF);
map((void *)ptr2, (void *)mem, PERM_EX | REF);
/* this should fail */
/* this should fail */
if (test_exec(1, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(1, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 2;
return 2;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != (long) ptr ||
if (mfspr(SRR0) != (long) ptr ||
mfspr(SRR1) != (MSR_SF | 0x40000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x40000000 | MSR_IR | MSR_LE))
return 3;
return 3;
return 0;
return 0;
}
}
@ -513,16 +514,16 @@ int mmu_test_14(void)
/* create a PTE */
/* create a PTE */
map((void *)ptr, (void *)mem, PERM_EX | REF);
map((void *)ptr, (void *)mem, PERM_EX | REF);
/* this should fail due to second page not being mapped */
/* this should fail due to second page not being mapped */
if (test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != ptr2 ||
if (mfspr(SRR0) != ptr2 ||
mfspr(SRR1) != (MSR_SF | 0x40000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x40000000 | MSR_IR | MSR_LE))
return 2;
return 2;
/* create a PTE for the second page */
/* create a PTE for the second page */
map((void *)ptr2, (void *)mem2, PERM_EX | REF);
map((void *)ptr2, (void *)mem2, PERM_EX | REF);
/* this should succeed */
/* this should succeed */
if (!test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (!test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 3;
return 3;
return 0;
return 0;
}
}
@ -535,11 +536,11 @@ int mmu_test_15(void)
/* create a PTE without execute permission */
/* create a PTE without execute permission */
map((void *)ptr, (void *)mem, DFLT_PERM);
map((void *)ptr, (void *)mem, DFLT_PERM);
/* this should fail */
/* this should fail */
if (test_exec(0, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(0, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != ptr ||
if (mfspr(SRR0) != ptr ||
mfspr(SRR1) != (MSR_SF | 0x10000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x10000000 | MSR_IR | MSR_LE))
return 2;
return 2;
return 0;
return 0;
}
}
@ -556,16 +557,16 @@ int mmu_test_16(void)
/* create a PTE for the second page without execute permission */
/* create a PTE for the second page without execute permission */
map((void *)ptr2, (void *)mem2, PERM_RD | REF);
map((void *)ptr2, (void *)mem2, PERM_RD | REF);
/* this should fail due to second page being no-execute */
/* this should fail due to second page being no-execute */
if (test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != ptr2 ||
if (mfspr(SRR0) != ptr2 ||
mfspr(SRR1) != (MSR_SF | 0x10000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x10000000 | MSR_IR | MSR_LE))
return 2;
return 2;
/* create a PTE for the second page with execute permission */
/* create a PTE for the second page with execute permission */
map((void *)ptr2, (void *)mem2, PERM_RD | PERM_EX | REF);
map((void *)ptr2, (void *)mem2, PERM_RD | PERM_EX | REF);
/* this should succeed */
/* this should succeed */
if (!test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (!test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 3;
return 3;
return 0;
return 0;
}
}
@ -578,22 +579,22 @@ int mmu_test_17(void)
/* create a PTE without the ref bit set */
/* create a PTE without the ref bit set */
map((void *)ptr, (void *)mem, PERM_EX);
map((void *)ptr, (void *)mem, PERM_EX);
/* this should fail */
/* this should fail */
if (test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
if (mfspr(SRR0) != (long) ptr ||
if (mfspr(SRR0) != (long) ptr ||
mfspr(SRR1) != (MSR_SF | 0x00040000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x00040000 | MSR_IR | MSR_LE))
return 2;
return 2;
/* create a PTE without ref or execute permission */
/* create a PTE without ref or execute permission */
unmap((void *)ptr);
unmap((void *)ptr);
map((void *)ptr, (void *)mem, 0);
map((void *)ptr, (void *)mem, 0);
/* this should fail */
/* this should fail */
if (test_exec(2, ptr, MSR_SF | MSR_IR | MSR_LE))
if (test_exec(2, ptr, MSR_SF | MSR_HV | MSR_IR | MSR_LE))
return 1;
return 1;
/* SRR0 and SRR1 should be set correctly */
/* SRR0 and SRR1 should be set correctly */
/* RC update fail bit should not be set */
/* RC update fail bit should not be set */
if (mfspr(SRR0) != (long) ptr ||
if (mfspr(SRR0) != (long) ptr ||
mfspr(SRR1) != (MSR_SF | 0x10000000 | MSR_IR | MSR_LE))
mfspr(SRR1) != (MSR_SF | MSR_HV | 0x10000000 | MSR_IR | MSR_LE))
return 2;
return 2;
return 0;
return 0;
}
}