xref: /openbmc/qemu/target/ppc/mmu-book3s-v3.h (revision 93b799fafd9170da3a79a533ea6f73a18de82e22)
1b2899495SSuraj Jitindar Singh /*
2b2899495SSuraj Jitindar Singh  *  PowerPC ISAV3 BookS emulation generic mmu definitions for qemu.
3b2899495SSuraj Jitindar Singh  *
4b2899495SSuraj Jitindar Singh  *  Copyright (c) 2017 Suraj Jitindar Singh, IBM Corporation
5b2899495SSuraj Jitindar Singh  *
6b2899495SSuraj Jitindar Singh  * This library is free software; you can redistribute it and/or
7b2899495SSuraj Jitindar Singh  * modify it under the terms of the GNU Lesser General Public
8b2899495SSuraj Jitindar Singh  * License as published by the Free Software Foundation; either
96bd039cdSChetan Pant  * version 2.1 of the License, or (at your option) any later version.
10b2899495SSuraj Jitindar Singh  *
11b2899495SSuraj Jitindar Singh  * This library is distributed in the hope that it will be useful,
12b2899495SSuraj Jitindar Singh  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13b2899495SSuraj Jitindar Singh  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14b2899495SSuraj Jitindar Singh  * Lesser General Public License for more details.
15b2899495SSuraj Jitindar Singh  *
16b2899495SSuraj Jitindar Singh  * You should have received a copy of the GNU Lesser General Public
17b2899495SSuraj Jitindar Singh  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18b2899495SSuraj Jitindar Singh  */
19b2899495SSuraj Jitindar Singh 
2058ea30f5SMarkus Armbruster #ifndef PPC_MMU_BOOK3S_V3_H
2158ea30f5SMarkus Armbruster #define PPC_MMU_BOOK3S_V3_H
22b2899495SSuraj Jitindar Singh 
23b2899495SSuraj Jitindar Singh #ifndef CONFIG_USER_ONLY
24b2899495SSuraj Jitindar Singh 
254a7518e0SCédric Le Goater /*
264a7518e0SCédric Le Goater  * Partition table definitions
274a7518e0SCédric Le Goater  */
284a7518e0SCédric Le Goater #define PTCR_PATB               0x0FFFFFFFFFFFF000ULL /* Partition Table Base */
294a7518e0SCédric Le Goater #define PTCR_PATS               0x000000000000001FULL /* Partition Table Size */
304a7518e0SCédric Le Goater 
31b2899495SSuraj Jitindar Singh /* Partition Table Entry Fields */
3279825f4dSBenjamin Herrenschmidt #define PATE0_HR 0x8000000000000000
3379825f4dSBenjamin Herrenschmidt 
3479825f4dSBenjamin Herrenschmidt /*
3579825f4dSBenjamin Herrenschmidt  * WARNING: This field doesn't actually exist in the final version of
3679825f4dSBenjamin Herrenschmidt  * the architecture and is unused by hardware. However, qemu uses it
3779825f4dSBenjamin Herrenschmidt  * as an indication of a radix guest in the pseudo-PATB entry that it
3879825f4dSBenjamin Herrenschmidt  * maintains for SPAPR guests and in the migration stream, so we need
3979825f4dSBenjamin Herrenschmidt  * to keep it around
4079825f4dSBenjamin Herrenschmidt  */
4179825f4dSBenjamin Herrenschmidt #define PATE1_GR 0x8000000000000000
42b2899495SSuraj Jitindar Singh 
43d5fee0bbSSuraj Jitindar Singh /* Process Table Entry */
44d5fee0bbSSuraj Jitindar Singh struct prtb_entry {
45d5fee0bbSSuraj Jitindar Singh     uint64_t prtbe0, prtbe1;
46d5fee0bbSSuraj Jitindar Singh };
47d5fee0bbSSuraj Jitindar Singh 
48b2899495SSuraj Jitindar Singh #ifdef TARGET_PPC64
49b2899495SSuraj Jitindar Singh 
50*e7beaea5SLeandro Lupori /*
51*e7beaea5SLeandro Lupori  * tlbie[l] helper flags
52*e7beaea5SLeandro Lupori  *
53*e7beaea5SLeandro Lupori  * RIC, PRS, R and local are passed as flags in the last argument.
54*e7beaea5SLeandro Lupori  */
55*e7beaea5SLeandro Lupori #define TLBIE_F_RIC_SHIFT       0
56*e7beaea5SLeandro Lupori #define TLBIE_F_PRS_SHIFT       2
57*e7beaea5SLeandro Lupori #define TLBIE_F_R_SHIFT         3
58*e7beaea5SLeandro Lupori #define TLBIE_F_LOCAL_SHIFT     4
59*e7beaea5SLeandro Lupori 
60*e7beaea5SLeandro Lupori #define TLBIE_F_RIC_MASK        (3 << TLBIE_F_RIC_SHIFT)
61*e7beaea5SLeandro Lupori #define TLBIE_F_PRS             (1 << TLBIE_F_PRS_SHIFT)
62*e7beaea5SLeandro Lupori #define TLBIE_F_R               (1 << TLBIE_F_R_SHIFT)
63*e7beaea5SLeandro Lupori #define TLBIE_F_LOCAL           (1 << TLBIE_F_LOCAL_SHIFT)
64*e7beaea5SLeandro Lupori 
ppc64_use_proc_tbl(PowerPCCPU * cpu)65b2899495SSuraj Jitindar Singh static inline bool ppc64_use_proc_tbl(PowerPCCPU *cpu)
66b2899495SSuraj Jitindar Singh {
67b2899495SSuraj Jitindar Singh     return !!(cpu->env.spr[SPR_LPCR] & LPCR_UPRT);
68b2899495SSuraj Jitindar Singh }
69b2899495SSuraj Jitindar Singh 
703367c62fSBenjamin Herrenschmidt bool ppc64_v3_get_pate(PowerPCCPU *cpu, target_ulong lpid,
713367c62fSBenjamin Herrenschmidt                        ppc_v3_pate_t *entry);
723367c62fSBenjamin Herrenschmidt 
7338c784a1SBenjamin Herrenschmidt /*
7438c784a1SBenjamin Herrenschmidt  * The LPCR:HR bit is a shortcut that avoids having to
7538c784a1SBenjamin Herrenschmidt  * dig out the partition table in the fast path. This is
7638c784a1SBenjamin Herrenschmidt  * also how the HW uses it.
7738c784a1SBenjamin Herrenschmidt  */
ppc64_v3_radix(PowerPCCPU * cpu)7838c784a1SBenjamin Herrenschmidt static inline bool ppc64_v3_radix(PowerPCCPU *cpu)
79b2899495SSuraj Jitindar Singh {
8038c784a1SBenjamin Herrenschmidt     return !!(cpu->env.spr[SPR_LPCR] & LPCR_HR);
81b2899495SSuraj Jitindar Singh }
82b2899495SSuraj Jitindar Singh 
83b2899495SSuraj Jitindar Singh #endif /* TARGET_PPC64 */
84b2899495SSuraj Jitindar Singh 
85b2899495SSuraj Jitindar Singh #endif /* CONFIG_USER_ONLY */
86b2899495SSuraj Jitindar Singh 
8758ea30f5SMarkus Armbruster #endif /* PPC_MMU_BOOK3S_V3_H */
88