]>
Commit | Line | Data |
---|---|---|
b2899495 SJS |
1 | /* |
2 | * PowerPC ISAV3 BookS emulation generic mmu definitions for qemu. | |
3 | * | |
4 | * Copyright (c) 2017 Suraj Jitindar Singh, IBM Corporation | |
5 | * | |
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. | |
10 | * | |
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. | |
15 | * | |
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/>. | |
18 | */ | |
19 | ||
58ea30f5 MA |
20 | #ifndef PPC_MMU_BOOK3S_V3_H |
21 | #define PPC_MMU_BOOK3S_V3_H | |
b2899495 | 22 | |
3367c62f BH |
23 | #include "mmu-hash64.h" |
24 | ||
b2899495 SJS |
25 | #ifndef CONFIG_USER_ONLY |
26 | ||
4a7518e0 CLG |
27 | /* |
28 | * Partition table definitions | |
29 | */ | |
30 | #define PTCR_PATB 0x0FFFFFFFFFFFF000ULL /* Partition Table Base */ | |
31 | #define PTCR_PATS 0x000000000000001FULL /* Partition Table Size */ | |
32 | ||
b2899495 | 33 | /* Partition Table Entry Fields */ |
79825f4d BH |
34 | #define PATE0_HR 0x8000000000000000 |
35 | ||
36 | /* | |
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 | |
42 | */ | |
43 | #define PATE1_GR 0x8000000000000000 | |
b2899495 | 44 | |
d5fee0bb SJS |
45 | /* Process Table Entry */ |
46 | struct prtb_entry { | |
47 | uint64_t prtbe0, prtbe1; | |
48 | }; | |
49 | ||
b2899495 SJS |
50 | #ifdef TARGET_PPC64 |
51 | ||
52 | static inline bool ppc64_use_proc_tbl(PowerPCCPU *cpu) | |
53 | { | |
54 | return !!(cpu->env.spr[SPR_LPCR] & LPCR_UPRT); | |
55 | } | |
56 | ||
3367c62f BH |
57 | bool ppc64_v3_get_pate(PowerPCCPU *cpu, target_ulong lpid, |
58 | ppc_v3_pate_t *entry); | |
59 | ||
38c784a1 BH |
60 | /* |
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. | |
64 | */ | |
65 | static inline bool ppc64_v3_radix(PowerPCCPU *cpu) | |
b2899495 | 66 | { |
38c784a1 | 67 | return !!(cpu->env.spr[SPR_LPCR] & LPCR_HR); |
b2899495 SJS |
68 | } |
69 | ||
38c784a1 BH |
70 | hwaddr ppc64_v3_get_phys_page_debug(PowerPCCPU *cpu, vaddr eaddr); |
71 | ||
b2899495 SJS |
72 | int ppc64_v3_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, |
73 | int mmu_idx); | |
74 | ||
3367c62f BH |
75 | static inline hwaddr ppc_hash64_hpt_base(PowerPCCPU *cpu) |
76 | { | |
77 | uint64_t base; | |
78 | ||
79 | if (cpu->vhyp) { | |
80 | return 0; | |
81 | } | |
82 | if (cpu->env.mmu_model == POWERPC_MMU_3_00) { | |
83 | ppc_v3_pate_t pate; | |
84 | ||
85 | if (!ppc64_v3_get_pate(cpu, cpu->env.spr[SPR_LPIDR], &pate)) { | |
86 | return 0; | |
87 | } | |
88 | base = pate.dw0; | |
89 | } else { | |
90 | base = cpu->env.spr[SPR_SDR1]; | |
91 | } | |
92 | return base & SDR_64_HTABORG; | |
93 | } | |
94 | ||
95 | static inline hwaddr ppc_hash64_hpt_mask(PowerPCCPU *cpu) | |
96 | { | |
97 | uint64_t base; | |
98 | ||
99 | if (cpu->vhyp) { | |
100 | PPCVirtualHypervisorClass *vhc = | |
101 | PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); | |
102 | return vhc->hpt_mask(cpu->vhyp); | |
103 | } | |
104 | if (cpu->env.mmu_model == POWERPC_MMU_3_00) { | |
105 | ppc_v3_pate_t pate; | |
106 | ||
107 | if (!ppc64_v3_get_pate(cpu, cpu->env.spr[SPR_LPIDR], &pate)) { | |
108 | return 0; | |
109 | } | |
110 | base = pate.dw0; | |
111 | } else { | |
112 | base = cpu->env.spr[SPR_SDR1]; | |
113 | } | |
114 | return (1ULL << ((base & SDR_64_HTABSIZE) + 18 - 7)) - 1; | |
115 | } | |
116 | ||
b2899495 SJS |
117 | #endif /* TARGET_PPC64 */ |
118 | ||
119 | #endif /* CONFIG_USER_ONLY */ | |
120 | ||
58ea30f5 | 121 | #endif /* PPC_MMU_BOOK3S_V3_H */ |