1 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 * Copyright (C) 2001 Mike Corrigan IBM Corporation
6 #ifndef _ASM_POWERPC_LPPACA_H
7 #define _ASM_POWERPC_LPPACA_H
12 * These definitions relate to hypervisors that only exist when using
13 * a server type processor
15 #ifdef CONFIG_PPC_BOOK3S
18 * This control block contains the data that is shared between the
19 * hypervisor and the OS.
21 #include <linux/cache.h>
22 #include <linux/threads.h>
23 #include <asm/types.h>
25 #include <asm/firmware.h>
29 * The lppaca is the "virtual processor area" registered with the hypervisor,
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).
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.
41 /* cacheline 1 contains read-only data */
43 __be32 desc
; /* Eye catcher 0xD397D781 */
44 __be16 size
; /* Size of this struct */
46 u8 __old_status
; /* Old status, including shared proc */
48 volatile __be32 dyn_hw_node_id
; /* Dynamic hardware node id */
49 volatile __be32 dyn_hw_proc_id
; /* Dynamic hardware proc id */
51 volatile u8 vphn_assoc_counts
[8]; /* Virtual processor home node */
52 /* associativity change counters */
55 /* cacheline 2 contains local read-write data */
61 u8 dtl_enable_mask
; /* Dispatch Trace Log mask */
62 u8 donate_dedicated_cpu
; /* Donate dedicated CPU cycles */
65 u8 l2_counters_enable
; /* Enable usage of counters for KVM guest */
67 __be64 wait_state_cycles
; /* Wait cycles for this proc */
69 __be16 slb_count
; /* # of SLBs to maintain */
70 u8 idle
; /* Indicate OS is idle */
73 /* cacheline 3 is shared with other processors */
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.
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 */
95 __be32 page_ins
; /* CMO Hint - # page ins by OS */
97 volatile __be64 l1_to_l2_cs_tb
;
98 volatile __be64 l2_to_l1_cs_tb
;
99 volatile __be64 l2_runtime_tb
;
101 volatile __be64 dtl_idx
; /* Dispatch Trace Log head index */
103 } ____cacheline_aligned
;
105 #define lppaca_of(cpu) (*paca_ptrs[cpu]->lppaca_ptr)
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.
112 #define LPPACA_OLD_SHARED_PROC 2
114 #ifdef CONFIG_PPC_PSERIES
116 * All CPUs should have the same shared proc value, so directly access the PACA
117 * to avoid false positives from DEBUG_PREEMPT.
119 static inline bool lppaca_shared_proc(void)
121 struct lppaca
*l
= local_paca
->lppaca_ptr
;
123 if (!firmware_has_feature(FW_FEATURE_SPLPAR
))
125 return !!(l
->__old_status
& LPPACA_OLD_SHARED_PROC
);
128 #define get_lppaca() (get_paca()->lppaca_ptr)
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.
137 __be32 persistent
; /* Number of persistent SLBs */
138 __be32 buffer_length
; /* Total shadow buffer length */
143 } save_area
[SLB_NUM_BOLTED
];
144 } ____cacheline_aligned
;
146 #endif /* CONFIG_PPC_BOOK3S */
147 #endif /* __KERNEL__ */
148 #endif /* _ASM_POWERPC_LPPACA_H */