提交 da82c73a 编写于 作者: S Suraj Jitindar Singh 提交者: David Gibson

target/ppc: Rework hash mmu page fault code and add defines for clarity

The hash mmu page fault handling code is responsible for generating ISIs
and DSIs when access permissions cause an access to fail. Part of this
involves setting the srr1 or dsisr registers to indicate what causes the
access to fail. Add defines for the bit fields of these registers and
rework the code to use these new defines in order to improve readability
and code clarity.

While we're here, update what is logged when an access fails to include
information as to what caused to access to fail for debug purposes.
Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
[dwg: Moved constants to cpu.h since they're not MMUv3 specific]
Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
上级 07a68f99
...@@ -473,11 +473,21 @@ struct ppc_slb_t { ...@@ -473,11 +473,21 @@ struct ppc_slb_t {
#endif #endif
#endif #endif
/* DSISR */
#define DSISR_NOPTE 0x40000000
/* Not permitted by access authority of encoded access authority */
#define DSISR_PROTFAULT 0x08000000
#define DSISR_ISSTORE 0x02000000
/* Not permitted by virtual page class key protection */
#define DSISR_AMR 0x00200000
/* SRR1 error code fields */ /* SRR1 error code fields */
#define SRR1_NOPTE DSISR_NOPTE
/* Not permitted due to no-execute or guard bit set */
#define SRR1_NOEXEC_GUARD 0x10000000 #define SRR1_NOEXEC_GUARD 0x10000000
#define SRR1_PROTFAULT 0x08000000 #define SRR1_PROTFAULT DSISR_PROTFAULT
#define SRR1_IAMR 0x00200000 #define SRR1_IAMR DSISR_AMR
/* Facility Status and Control (FSCR) bits */ /* Facility Status and Control (FSCR) bits */
#define FSCR_EBB (63 - 56) /* Event-Based Branch Facility */ #define FSCR_EBB (63 - 56) /* Event-Based Branch Facility */
......
...@@ -701,7 +701,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, ...@@ -701,7 +701,7 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,
hwaddr ptex; hwaddr ptex;
ppc_hash_pte64_t pte; ppc_hash_pte64_t pte;
int exec_prot, pp_prot, amr_prot, prot; int exec_prot, pp_prot, amr_prot, prot;
uint64_t new_pte1, dsisr; uint64_t new_pte1;
const int need_prot[] = {PAGE_READ, PAGE_WRITE, PAGE_EXEC}; const int need_prot[] = {PAGE_READ, PAGE_WRITE, PAGE_EXEC};
hwaddr raddr; hwaddr raddr;
...@@ -742,11 +742,11 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, ...@@ -742,11 +742,11 @@ int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr,
} else { } else {
/* The access failed, generate the approriate interrupt */ /* The access failed, generate the approriate interrupt */
if (rwx == 2) { if (rwx == 2) {
ppc_hash64_set_isi(cs, env, 0x08000000); ppc_hash64_set_isi(cs, env, SRR1_PROTFAULT);
} else { } else {
dsisr = 0x08000000; int dsisr = DSISR_PROTFAULT;
if (rwx == 1) { if (rwx == 1) {
dsisr |= 0x02000000; dsisr |= DSISR_ISSTORE;
} }
ppc_hash64_set_dsi(cs, env, eaddr, dsisr); ppc_hash64_set_dsi(cs, env, eaddr, dsisr);
} }
...@@ -784,19 +784,19 @@ skip_slb_search: ...@@ -784,19 +784,19 @@ skip_slb_search:
/* 3. Check for segment level no-execute violation */ /* 3. Check for segment level no-execute violation */
if ((rwx == 2) && (slb->vsid & SLB_VSID_N)) { if ((rwx == 2) && (slb->vsid & SLB_VSID_N)) {
ppc_hash64_set_isi(cs, env, 0x10000000); ppc_hash64_set_isi(cs, env, SRR1_NOEXEC_GUARD);
return 1; return 1;
} }
/* 4. Locate the PTE in the hash table */ /* 4. Locate the PTE in the hash table */
ptex = ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift); ptex = ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift);
if (ptex == -1) { if (ptex == -1) {
dsisr = 0x40000000;
if (rwx == 2) { if (rwx == 2) {
ppc_hash64_set_isi(cs, env, dsisr); ppc_hash64_set_isi(cs, env, SRR1_NOPTE);
} else { } else {
int dsisr = DSISR_NOPTE;
if (rwx == 1) { if (rwx == 1) {
dsisr |= 0x02000000; dsisr |= DSISR_ISSTORE;
} }
ppc_hash64_set_dsi(cs, env, eaddr, dsisr); ppc_hash64_set_dsi(cs, env, eaddr, dsisr);
} }
...@@ -827,15 +827,15 @@ skip_slb_search: ...@@ -827,15 +827,15 @@ skip_slb_search:
} }
ppc_hash64_set_isi(cs, env, srr1); ppc_hash64_set_isi(cs, env, srr1);
} else { } else {
dsisr = 0; int dsisr = 0;
if (need_prot[rwx] & ~pp_prot) { if (need_prot[rwx] & ~pp_prot) {
dsisr |= 0x08000000; dsisr |= DSISR_PROTFAULT;
} }
if (rwx == 1) { if (rwx == 1) {
dsisr |= 0x02000000; dsisr |= DSISR_ISSTORE;
} }
if (need_prot[rwx] & ~amr_prot) { if (need_prot[rwx] & ~amr_prot) {
dsisr |= 0x00200000; dsisr |= DSISR_AMR;
} }
ppc_hash64_set_dsi(cs, env, eaddr, dsisr); ppc_hash64_set_dsi(cs, env, eaddr, dsisr);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册