| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012 Linaro Limited. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 6 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | | - * (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | | - * |
|---|
| 14 | | - * You should have received a copy of the GNU General Public License along |
|---|
| 15 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 16 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 17 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 202 | 189 | ENDPROC(__hyp_stub_install_secondary) |
|---|
| 203 | 190 | |
|---|
| 204 | 191 | __hyp_stub_do_trap: |
|---|
| 192 | +#ifdef ZIMAGE |
|---|
| 205 | 193 | teq r0, #HVC_SET_VECTORS |
|---|
| 206 | 194 | bne 1f |
|---|
| 195 | + /* Only the ZIMAGE stubs can change the HYP vectors */ |
|---|
| 207 | 196 | mcr p15, 4, r1, c12, c0, 0 @ set HVBAR |
|---|
| 208 | 197 | b __hyp_stub_exit |
|---|
| 198 | +#endif |
|---|
| 209 | 199 | |
|---|
| 210 | 200 | 1: teq r0, #HVC_SOFT_RESTART |
|---|
| 211 | | - bne 1f |
|---|
| 201 | + bne 2f |
|---|
| 212 | 202 | bx r1 |
|---|
| 213 | 203 | |
|---|
| 214 | | -1: teq r0, #HVC_RESET_VECTORS |
|---|
| 215 | | - beq __hyp_stub_exit |
|---|
| 216 | | - |
|---|
| 217 | | - ldr r0, =HVC_STUB_ERR |
|---|
| 204 | +2: ldr r0, =HVC_STUB_ERR |
|---|
| 218 | 205 | __ERET |
|---|
| 219 | 206 | |
|---|
| 220 | 207 | __hyp_stub_exit: |
|---|
| .. | .. |
|---|
| 223 | 210 | ENDPROC(__hyp_stub_do_trap) |
|---|
| 224 | 211 | |
|---|
| 225 | 212 | /* |
|---|
| 226 | | - * __hyp_set_vectors: Call this after boot to set the initial hypervisor |
|---|
| 227 | | - * vectors as part of hypervisor installation. On an SMP system, this should |
|---|
| 228 | | - * be called on each CPU. |
|---|
| 229 | | - * |
|---|
| 230 | | - * r0 must be the physical address of the new vector table (which must lie in |
|---|
| 231 | | - * the bottom 4GB of physical address space. |
|---|
| 232 | | - * |
|---|
| 233 | | - * r0 must be 32-byte aligned. |
|---|
| 234 | | - * |
|---|
| 235 | | - * Before calling this, you must check that the stub hypervisor is installed |
|---|
| 236 | | - * everywhere, by waiting for any secondary CPUs to be brought up and then |
|---|
| 237 | | - * checking that BOOT_CPU_MODE_HAVE_HYP(__boot_cpu_mode) is true. |
|---|
| 238 | | - * |
|---|
| 239 | | - * If not, there is a pre-existing hypervisor, some CPUs failed to boot, or |
|---|
| 240 | | - * something else went wrong... in such cases, trying to install a new |
|---|
| 241 | | - * hypervisor is unlikely to work as desired. |
|---|
| 242 | | - * |
|---|
| 243 | | - * When you call into your shiny new hypervisor, sp_hyp will contain junk, |
|---|
| 244 | | - * so you will need to set that to something sensible at the new hypervisor's |
|---|
| 245 | | - * initialisation entry point. |
|---|
| 213 | + * __hyp_set_vectors is only used when ZIMAGE must bounce between HYP |
|---|
| 214 | + * and SVC. For the kernel itself, the vectors are set once and for |
|---|
| 215 | + * all by the stubs. |
|---|
| 246 | 216 | */ |
|---|
| 247 | 217 | ENTRY(__hyp_set_vectors) |
|---|
| 248 | 218 | mov r1, r0 |
|---|
| .. | .. |
|---|
| 257 | 227 | __HVC(0) |
|---|
| 258 | 228 | ret lr |
|---|
| 259 | 229 | ENDPROC(__hyp_soft_restart) |
|---|
| 260 | | - |
|---|
| 261 | | -ENTRY(__hyp_reset_vectors) |
|---|
| 262 | | - mov r0, #HVC_RESET_VECTORS |
|---|
| 263 | | - __HVC(0) |
|---|
| 264 | | - ret lr |
|---|
| 265 | | -ENDPROC(__hyp_reset_vectors) |
|---|
| 266 | 230 | |
|---|
| 267 | 231 | #ifndef ZIMAGE |
|---|
| 268 | 232 | .align 2 |
|---|