linux-user/microblaze: Remove non-rt signal frames
[qemu/ar7.git] / target / ppc / mmu-book3s-v3.h
blob0f3c9d09c6c0e31ad06810cbb3e2810332a68d40
1 /*
2 * PowerPC ISAV3 BookS emulation generic mmu definitions for qemu.
4 * Copyright (c) 2017 Suraj Jitindar Singh, IBM Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef PPC_MMU_BOOK3S_V3_H
21 #define PPC_MMU_BOOK3S_V3_H
23 #include "mmu-hash64.h"
25 #ifndef CONFIG_USER_ONLY
28 * Partition table definitions
30 #define PTCR_PATB 0x0FFFFFFFFFFFF000ULL /* Partition Table Base */
31 #define PTCR_PATS 0x000000000000001FULL /* Partition Table Size */
33 /* Partition Table Entry Fields */
34 #define PATE0_HR 0x8000000000000000
37 * WARNING: This field doesn't actually exist in the final version of
38 * the architecture and is unused by hardware. However, qemu uses it
39 * as an indication of a radix guest in the pseudo-PATB entry that it
40 * maintains for SPAPR guests and in the migration stream, so we need
41 * to keep it around
43 #define PATE1_GR 0x8000000000000000
45 /* Process Table Entry */
46 struct prtb_entry {
47 uint64_t prtbe0, prtbe1;
50 #ifdef TARGET_PPC64
52 static inline bool ppc64_use_proc_tbl(PowerPCCPU *cpu)
54 return !!(cpu->env.spr[SPR_LPCR] & LPCR_UPRT);
57 bool ppc64_v3_get_pate(PowerPCCPU *cpu, target_ulong lpid,
58 ppc_v3_pate_t *entry);
61 * The LPCR:HR bit is a shortcut that avoids having to
62 * dig out the partition table in the fast path. This is
63 * also how the HW uses it.
65 static inline bool ppc64_v3_radix(PowerPCCPU *cpu)
67 return !!(cpu->env.spr[SPR_LPCR] & LPCR_HR);
70 hwaddr ppc64_v3_get_phys_page_debug(PowerPCCPU *cpu, vaddr eaddr);
72 int ppc64_v3_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,
73 int mmu_idx);
75 static inline hwaddr ppc_hash64_hpt_base(PowerPCCPU *cpu)
77 uint64_t base;
79 if (cpu->vhyp) {
80 return 0;
82 if (cpu->env.mmu_model == POWERPC_MMU_3_00) {
83 ppc_v3_pate_t pate;
85 if (!ppc64_v3_get_pate(cpu, cpu->env.spr[SPR_LPIDR], &pate)) {
86 return 0;
88 base = pate.dw0;
89 } else {
90 base = cpu->env.spr[SPR_SDR1];
92 return base & SDR_64_HTABORG;
95 static inline hwaddr ppc_hash64_hpt_mask(PowerPCCPU *cpu)
97 uint64_t base;
99 if (cpu->vhyp) {
100 PPCVirtualHypervisorClass *vhc =
101 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp);
102 return vhc->hpt_mask(cpu->vhyp);
104 if (cpu->env.mmu_model == POWERPC_MMU_3_00) {
105 ppc_v3_pate_t pate;
107 if (!ppc64_v3_get_pate(cpu, cpu->env.spr[SPR_LPIDR], &pate)) {
108 return 0;
110 base = pate.dw0;
111 } else {
112 base = cpu->env.spr[SPR_SDR1];
114 return (1ULL << ((base & SDR_64_HTABSIZE) + 18 - 7)) - 1;
117 #endif /* TARGET_PPC64 */
119 #endif /* CONFIG_USER_ONLY */
121 #endif /* PPC_MMU_BOOK3S_V3_H */