Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|---|
| 2 | /* |
| 3 | * lppaca.h |
| 4 | * Copyright (C) 2001 Mike Corrigan IBM Corporation |
| 5 | */ |
| 6 | #ifndef _ASM_POWERPC_LPPACA_H |
| 7 | #define _ASM_POWERPC_LPPACA_H |
| 8 | |
| 9 | #ifdef __KERNEL__ |
| 10 | |
| 11 | /* |
| 12 | * These definitions relate to hypervisors that only exist when using |
| 13 | * a server type processor |
| 14 | */ |
| 15 | #ifdef CONFIG_PPC_BOOK3S |
| 16 | |
| 17 | /* |
| 18 | * This control block contains the data that is shared between the |
| 19 | * hypervisor and the OS. |
| 20 | */ |
| 21 | #include <linux/cache.h> |
| 22 | #include <linux/threads.h> |
| 23 | #include <asm/types.h> |
| 24 | #include <asm/mmu.h> |
| 25 | #include <asm/firmware.h> |
| 26 | #include <asm/paca.h> |
| 27 | |
| 28 | /* |
| 29 | * The lppaca is the "virtual processor area" registered with the hypervisor, |
| 30 | * H_REGISTER_VPA etc. |
| 31 | * |
| 32 | * According to PAPR, the structure is 640 bytes long, must be L1 cache line |
| 33 | * aligned, and must not cross a 4kB boundary. Its size field must be at |
| 34 | * least 640 bytes (but may be more). |
| 35 | * |
| 36 | * Pre-v4.14 KVM hypervisors reject the VPA if its size field is smaller than |
| 37 | * 1kB, so we dynamically allocate 1kB and advertise size as 1kB, but keep |
| 38 | * this structure as the canonical 640 byte size. |
| 39 | */ |
| 40 | struct lppaca { |
| 41 | /* cacheline 1 contains read-only data */ |
| 42 | |
| 43 | __be32 desc; /* Eye catcher 0xD397D781 */ |
| 44 | __be16 size; /* Size of this struct */ |
| 45 | u8 reserved1[3]; |
| 46 | u8 __old_status; /* Old status, including shared proc */ |
| 47 | u8 reserved3[14]; |
| 48 | volatile __be32 dyn_hw_node_id; /* Dynamic hardware node id */ |
| 49 | volatile __be32 dyn_hw_proc_id; /* Dynamic hardware proc id */ |
| 50 | u8 reserved4[56]; |
| 51 | volatile u8 vphn_assoc_counts[8]; /* Virtual processor home node */ |
| 52 | /* associativity change counters */ |
| 53 | u8 reserved5[32]; |
| 54 | |
| 55 | /* cacheline 2 contains local read-write data */ |
| 56 | |
| 57 | u8 reserved6[48]; |
| 58 | u8 cede_latency_hint; |
| 59 | u8 ebb_regs_in_use; |
| 60 | u8 reserved7[6]; |
| 61 | u8 dtl_enable_mask; /* Dispatch Trace Log mask */ |
| 62 | u8 donate_dedicated_cpu; /* Donate dedicated CPU cycles */ |
| 63 | u8 fpregs_in_use; |
| 64 | u8 pmcregs_in_use; |
| 65 | u8 l2_counters_enable; /* Enable usage of counters for KVM guest */ |
| 66 | u8 reserved8[27]; |
| 67 | __be64 wait_state_cycles; /* Wait cycles for this proc */ |
| 68 | u8 reserved9[28]; |
| 69 | __be16 slb_count; /* # of SLBs to maintain */ |
| 70 | u8 idle; /* Indicate OS is idle */ |
| 71 | u8 vmxregs_in_use; |
| 72 | |
| 73 | /* cacheline 3 is shared with other processors */ |
| 74 | |
| 75 | /* |
| 76 | * This is the yield_count. An "odd" value (low bit on) means that |
| 77 | * the processor is yielded (either because of an OS yield or a |
| 78 | * hypervisor preempt). An even value implies that the processor is |
| 79 | * currently executing. |
| 80 | * NOTE: Even dedicated processor partitions can yield so this |
| 81 | * field cannot be used to determine if we are shared or dedicated. |
| 82 | */ |
| 83 | volatile __be32 yield_count; |
| 84 | volatile __be32 dispersion_count; /* dispatch changed physical cpu */ |
| 85 | volatile __be64 cmo_faults; /* CMO page fault count */ |
| 86 | volatile __be64 cmo_fault_time; /* CMO page fault time */ |
| 87 | u8 reserved10[64]; /* [S]PURR expropriated/donated */ |
| 88 | volatile __be64 enqueue_dispatch_tb; /* Total TB enqueue->dispatch */ |
| 89 | volatile __be64 ready_enqueue_tb; /* Total TB ready->enqueue */ |
| 90 | volatile __be64 wait_ready_tb; /* Total TB wait->ready */ |
| 91 | u8 reserved11[16]; |
| 92 | |
| 93 | /* cacheline 4-5 */ |
| 94 | |
| 95 | __be32 page_ins; /* CMO Hint - # page ins by OS */ |
| 96 | u8 reserved12[28]; |
| 97 | volatile __be64 l1_to_l2_cs_tb; |
| 98 | volatile __be64 l2_to_l1_cs_tb; |
| 99 | volatile __be64 l2_runtime_tb; |
| 100 | u8 reserved13[96]; |
| 101 | volatile __be64 dtl_idx; /* Dispatch Trace Log head index */ |
| 102 | u8 reserved14[96]; |
| 103 | } ____cacheline_aligned; |
| 104 | |
| 105 | #define lppaca_of(cpu) (*paca_ptrs[cpu]->lppaca_ptr) |
| 106 | |
| 107 | /* |
| 108 | * We are using a non architected field to determine if a partition is |
| 109 | * shared or dedicated. This currently works on both KVM and PHYP, but |
| 110 | * we will have to transition to something better. |
| 111 | */ |
| 112 | #define LPPACA_OLD_SHARED_PROC 2 |
| 113 | |
| 114 | #ifdef CONFIG_PPC_PSERIES |
| 115 | /* |
| 116 | * All CPUs should have the same shared proc value, so directly access the PACA |
| 117 | * to avoid false positives from DEBUG_PREEMPT. |
| 118 | */ |
| 119 | static inline bool lppaca_shared_proc(void) |
| 120 | { |
| 121 | struct lppaca *l = local_paca->lppaca_ptr; |
| 122 | |
| 123 | if (!firmware_has_feature(FW_FEATURE_SPLPAR)) |
| 124 | return false; |
| 125 | return !!(l->__old_status & LPPACA_OLD_SHARED_PROC); |
| 126 | } |
| 127 | |
| 128 | #define get_lppaca() (get_paca()->lppaca_ptr) |
| 129 | #endif |
| 130 | |
| 131 | /* |
| 132 | * SLB shadow buffer structure as defined in the PAPR. The save_area |
| 133 | * contains adjacent ESID and VSID pairs for each shadowed SLB. The |
| 134 | * ESID is stored in the lower 64bits, then the VSID. |
| 135 | */ |
| 136 | struct slb_shadow { |
| 137 | __be32 persistent; /* Number of persistent SLBs */ |
| 138 | __be32 buffer_length; /* Total shadow buffer length */ |
| 139 | __be64 reserved; |
| 140 | struct { |
| 141 | __be64 esid; |
| 142 | __be64 vsid; |
| 143 | } save_area[SLB_NUM_BOLTED]; |
| 144 | } ____cacheline_aligned; |
| 145 | |
| 146 | #endif /* CONFIG_PPC_BOOK3S */ |
| 147 | #endif /* __KERNEL__ */ |
| 148 | #endif /* _ASM_POWERPC_LPPACA_H */ |
| 149 |
Warning: This file is not a C or C++ file. It does not have highlighting.
