@@ -3793,6 +3793,8 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
int32_t va_size = 32;
int32_t tbi = 0;
+ qemu_log("--------------------------------------\n");
+ qemu_log("%s: looking up %lx\n", __func__, address);
if (arm_el_is_aa64(env, 1)) {
va_size = 64;
if (extract64(address, 55, 1))
@@ -3905,6 +3907,11 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
descaddr |= (address >> (granule_sz * (4 - level))) & descmask;
descaddr &= ~7ULL;
descriptor = ldq_phys(cs->as, descaddr);
+ qemu_log("%s: l%d descr %lx (%s,%s,%s,%s)\n", __func__, level, descriptor,
+ descriptor & (1UL<<60) ? "XNTable" : "!XNTable",
+ descriptor & (1UL<<59) ? "PXNTable" : "!PXNTable",
+ descriptor & (1UL<<54) ? "XN" : "!XN",
+ descriptor & (1UL<<53) ? "PXN" : "!PXN");
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
/* Invalid, or the Reserved level 3 encoding */
@@ -3929,13 +3936,23 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
page_size = (1 << ((granule_sz * (4 - level)) + 3));
descaddr |= (address & (page_size - 1));
/* Extract attributes from the descriptor and merge with table attrs */
- if (arm_feature(env, ARM_FEATURE_V8)) {
+ if (/*0 &&*/ arm_feature(env, ARM_FEATURE_V8)) {
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 53, 11) << 10);
+ qemu_log("attrs: lower %lx upper %lx (V8 style, 2..11, 53..63)\n",
+ extract64(descriptor, 2, 10),
+ extract64(descriptor, 53, 11));
} else {
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
+ qemu_log("attrs: lower %lx upper %lx (V7 style, 2..11, 52..63)\n",
+ extract64(descriptor, 2, 10),
+ extract64(descriptor, 52, 12));
}
+ qemu_log("attrs %x | %x => %x (merging from tableattrs %x)\n",
+ attrs, extract32(tableattrs, 0, 2) << 11,
+ attrs | extract32(tableattrs, 0, 2) << 11,
+ tableattrs);
attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */
/* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
@@ -3961,13 +3978,22 @@ static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
goto do_fault;
}
*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
+#if 1
if (attrs & (1 << 12) || (!is_user && (attrs & (1 << 11)))) {
/* XN or PXN */
if (access_type == 2) {
+ qemu_log("%s: fault with attrs %x, is_user %d, access_type %d, level %d\n", __func__,
+ attrs, is_user, access_type, level);
+ qemu_log("%s: tableattrs %x\n", __func__, tableattrs);
+ qemu_log("%s: XN == %x %s, PXN == %x %s\n", __func__,
+ 1<<12, (attrs & (1<<12)) ? "yes" : "no",
+ 1<<11, (attrs & (1<<11)) ? "yes" : "no");
+ abort();
goto do_fault;
}
*prot &= ~PAGE_EXEC;
}
+#endif
if (attrs & (1 << 5)) {
/* Write access forbidden */
if (access_type == 1) {