Skip to contentSkip to conversation

qemu-system-hppa: Raise exception 26 on emulated hardware

PATCH Applied Helge Deller 2 participants 2 messages Oct 7, 2018 – Oct 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu-system-hppa: Raise exception 26 on emulated hardware

On PCXS chips (PA7000, pa 1.1a), trap #18 is raised on memory faults, while all later chips (>= PA7100) generate either trap #26, #27 or #28 (depending on the fault type).

Since the current qemu emulation emulates a B160L machine (with a PA7300LC PCX-L2 chip, we should raise trap #26 (EXCP_DMAR) instead of #18 (EXCP_DMP) on access faults by the Linux kernel to page zero.

With the patch we now get the correct output (I tested against real hardware):
Kernel Fault: Code=26 (Data memory access rights trap) (Addr=00000004)
instead of:
Kernel Fault: Code=18 (Data memory protection/unaligned access trap) (Addr=00000004)

target/hppa/mem_helper.c +2 -1
index ab160c2a74..aecf3075f6 100644
@@ -137,7 +137,8 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
 
     if (unlikely(!(prot & type))) {
         /* The access isn't allowed -- Inst/Data Memory Protection Fault.  */
-        ret = (type & PAGE_EXEC ? EXCP_IMP : EXCP_DMP);
+        ret = (type & PAGE_EXEC ? EXCP_IMP :
+               prot & PAGE_READ ? EXCP_DMP : EXCP_DMAR);
         goto egress;
     }
 
#1 lore raw
Quoted 8 lines · Helge Deller

On PCXS chips (PA7000, pa 1.1a), trap #18 is raised on memory faults, while all later chips (>= PA7100) generate either trap #26, #27 or #28 (depending on the fault type).

Since the current qemu emulation emulates a B160L machine (with a PA7300LC PCX-L2 chip, we should raise trap #26 (EXCP_DMAR) instead of #18 (EXCP_DMP) on access faults by the Linux kernel to page zero.

Quoted 7 lines

With the patch we now get the correct output (I tested against real hardware):
Kernel Fault: Code=26 (Data memory access rights trap) (Addr=00000004)
instead of:
Kernel Fault: Code=18 (Data memory protection/unaligned access trap) (Addr=00000004)

Queued, thanks.

r~