| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * lppaca.h |
|---|
| 3 | 4 | * Copyright (C) 2001 Mike Corrigan IBM Corporation |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 7 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | | - * (at your option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program; if not, write to the Free Software |
|---|
| 17 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | 5 | */ |
|---|
| 19 | 6 | #ifndef _ASM_POWERPC_LPPACA_H |
|---|
| 20 | 7 | #define _ASM_POWERPC_LPPACA_H |
|---|
| 8 | + |
|---|
| 9 | +/* |
|---|
| 10 | + * The below VPHN macros are outside the __KERNEL__ check since these are |
|---|
| 11 | + * used for compiling the vphn selftest in userspace |
|---|
| 12 | + */ |
|---|
| 13 | + |
|---|
| 14 | +/* The H_HOME_NODE_ASSOCIATIVITY h_call returns 6 64-bit registers. */ |
|---|
| 15 | +#define VPHN_REGISTER_COUNT 6 |
|---|
| 16 | + |
|---|
| 17 | +/* |
|---|
| 18 | + * 6 64-bit registers unpacked into up to 24 be32 associativity values. To |
|---|
| 19 | + * form the complete property we have to add the length in the first cell. |
|---|
| 20 | + */ |
|---|
| 21 | +#define VPHN_ASSOC_BUFSIZE (VPHN_REGISTER_COUNT*sizeof(u64)/sizeof(u16) + 1) |
|---|
| 22 | + |
|---|
| 23 | +/* |
|---|
| 24 | + * The H_HOME_NODE_ASSOCIATIVITY hcall takes two values for flags: |
|---|
| 25 | + * 1 for retrieving associativity information for a guest cpu |
|---|
| 26 | + * 2 for retrieving associativity information for a host/hypervisor cpu |
|---|
| 27 | + */ |
|---|
| 28 | +#define VPHN_FLAG_VCPU 1 |
|---|
| 29 | +#define VPHN_FLAG_PCPU 2 |
|---|
| 30 | + |
|---|
| 21 | 31 | #ifdef __KERNEL__ |
|---|
| 22 | 32 | |
|---|
| 23 | 33 | /* |
|---|
| .. | .. |
|---|
| 35 | 45 | #include <asm/types.h> |
|---|
| 36 | 46 | #include <asm/mmu.h> |
|---|
| 37 | 47 | #include <asm/firmware.h> |
|---|
| 48 | +#include <asm/paca.h> |
|---|
| 38 | 49 | |
|---|
| 39 | 50 | /* |
|---|
| 40 | 51 | * The lppaca is the "virtual processor area" registered with the hypervisor, |
|---|
| .. | .. |
|---|
| 113 | 124 | */ |
|---|
| 114 | 125 | #define LPPACA_OLD_SHARED_PROC 2 |
|---|
| 115 | 126 | |
|---|
| 116 | | -static inline bool lppaca_shared_proc(struct lppaca *l) |
|---|
| 127 | +#ifdef CONFIG_PPC_PSERIES |
|---|
| 128 | +/* |
|---|
| 129 | + * All CPUs should have the same shared proc value, so directly access the PACA |
|---|
| 130 | + * to avoid false positives from DEBUG_PREEMPT. |
|---|
| 131 | + */ |
|---|
| 132 | +static inline bool lppaca_shared_proc(void) |
|---|
| 117 | 133 | { |
|---|
| 134 | + struct lppaca *l = local_paca->lppaca_ptr; |
|---|
| 135 | + |
|---|
| 118 | 136 | if (!firmware_has_feature(FW_FEATURE_SPLPAR)) |
|---|
| 119 | 137 | return false; |
|---|
| 120 | 138 | return !!(l->__old_status & LPPACA_OLD_SHARED_PROC); |
|---|
| 121 | 139 | } |
|---|
| 140 | + |
|---|
| 141 | +#define get_lppaca() (get_paca()->lppaca_ptr) |
|---|
| 142 | +#endif |
|---|
| 122 | 143 | |
|---|
| 123 | 144 | /* |
|---|
| 124 | 145 | * SLB shadow buffer structure as defined in the PAPR. The save_area |
|---|
| .. | .. |
|---|
| 135 | 156 | } save_area[SLB_NUM_BOLTED]; |
|---|
| 136 | 157 | } ____cacheline_aligned; |
|---|
| 137 | 158 | |
|---|
| 138 | | -/* |
|---|
| 139 | | - * Layout of entries in the hypervisor's dispatch trace log buffer. |
|---|
| 140 | | - */ |
|---|
| 141 | | -struct dtl_entry { |
|---|
| 142 | | - u8 dispatch_reason; |
|---|
| 143 | | - u8 preempt_reason; |
|---|
| 144 | | - __be16 processor_id; |
|---|
| 145 | | - __be32 enqueue_to_dispatch_time; |
|---|
| 146 | | - __be32 ready_to_enqueue_time; |
|---|
| 147 | | - __be32 waiting_to_ready_time; |
|---|
| 148 | | - __be64 timebase; |
|---|
| 149 | | - __be64 fault_addr; |
|---|
| 150 | | - __be64 srr0; |
|---|
| 151 | | - __be64 srr1; |
|---|
| 152 | | -}; |
|---|
| 153 | | - |
|---|
| 154 | | -#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */ |
|---|
| 155 | | -#define N_DISPATCH_LOG (DISPATCH_LOG_BYTES / sizeof(struct dtl_entry)) |
|---|
| 156 | | - |
|---|
| 157 | | -extern struct kmem_cache *dtl_cache; |
|---|
| 158 | | - |
|---|
| 159 | | -/* |
|---|
| 160 | | - * When CONFIG_VIRT_CPU_ACCOUNTING_NATIVE = y, the cpu accounting code controls |
|---|
| 161 | | - * reading from the dispatch trace log. If other code wants to consume |
|---|
| 162 | | - * DTL entries, it can set this pointer to a function that will get |
|---|
| 163 | | - * called once for each DTL entry that gets processed. |
|---|
| 164 | | - */ |
|---|
| 165 | | -extern void (*dtl_consumer)(struct dtl_entry *entry, u64 index); |
|---|
| 159 | +extern long hcall_vphn(unsigned long cpu, u64 flags, __be32 *associativity); |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | #endif /* CONFIG_PPC_BOOK3S */ |
|---|
| 168 | 162 | #endif /* __KERNEL__ */ |
|---|