18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 48c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 58c2ecf20Sopenharmony_ci * for more details. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 88c2ecf20Sopenharmony_ci * Copyright (C) 2013 Cavium, Inc. 98c2ecf20Sopenharmony_ci * Authors: Sanjay Lal <sanjayl@kymasys.com> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __LINUX_KVM_MIPS_H 138c2ecf20Sopenharmony_ci#define __LINUX_KVM_MIPS_H 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/types.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* 188c2ecf20Sopenharmony_ci * KVM MIPS specific structures and definitions. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Some parts derived from the x86 version of this file. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* 248c2ecf20Sopenharmony_ci * for KVM_GET_REGS and KVM_SET_REGS 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * If Config[AT] is zero (32-bit CPU), the register contents are 278c2ecf20Sopenharmony_ci * stored in the lower 32-bits of the struct kvm_regs fields and sign 288c2ecf20Sopenharmony_ci * extended to 64-bits. 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_cistruct kvm_regs { 318c2ecf20Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 328c2ecf20Sopenharmony_ci __u64 gpr[32]; 338c2ecf20Sopenharmony_ci __u64 hi; 348c2ecf20Sopenharmony_ci __u64 lo; 358c2ecf20Sopenharmony_ci __u64 pc; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* 398c2ecf20Sopenharmony_ci * for KVM_GET_FPU and KVM_SET_FPU 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_cistruct kvm_fpu { 428c2ecf20Sopenharmony_ci}; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various 478c2ecf20Sopenharmony_ci * registers. The id field is broken down as follows: 488c2ecf20Sopenharmony_ci * 498c2ecf20Sopenharmony_ci * bits[63..52] - As per linux/kvm.h 508c2ecf20Sopenharmony_ci * bits[51..32] - Must be zero. 518c2ecf20Sopenharmony_ci * bits[31..16] - Register set. 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * Register set = 0: GP registers from kvm_regs (see definitions below). 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * Register set = 1: CP0 registers. 568c2ecf20Sopenharmony_ci * bits[15..8] - Must be zero. 578c2ecf20Sopenharmony_ci * bits[7..3] - Register 'rd' index. 588c2ecf20Sopenharmony_ci * bits[2..0] - Register 'sel' index. 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * Register set = 2: KVM specific registers (see definitions below). 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * Register set = 3: FPU / MSA registers (see definitions below). 638c2ecf20Sopenharmony_ci * 648c2ecf20Sopenharmony_ci * Other sets registers may be added in the future. Each set would 658c2ecf20Sopenharmony_ci * have its own identifier in bits[31..16]. 668c2ecf20Sopenharmony_ci */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_GP (KVM_REG_MIPS | 0x0000000000000000ULL) 698c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_CP0 (KVM_REG_MIPS | 0x0000000000010000ULL) 708c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_KVM (KVM_REG_MIPS | 0x0000000000020000ULL) 718c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FPU (KVM_REG_MIPS | 0x0000000000030000ULL) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* 758c2ecf20Sopenharmony_ci * KVM_REG_MIPS_GP - General purpose registers from kvm_regs. 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R0 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 0) 798c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R1 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 1) 808c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R2 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 2) 818c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R3 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 3) 828c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R4 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 4) 838c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R5 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 5) 848c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R6 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 6) 858c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R7 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 7) 868c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R8 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 8) 878c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R9 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 9) 888c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R10 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10) 898c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R11 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11) 908c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R12 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12) 918c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R13 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13) 928c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R14 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14) 938c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R15 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15) 948c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R16 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16) 958c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R17 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17) 968c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R18 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18) 978c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R19 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19) 988c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R20 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20) 998c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R21 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21) 1008c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R22 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22) 1018c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R23 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23) 1028c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R24 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24) 1038c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R25 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25) 1048c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R26 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26) 1058c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R27 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27) 1068c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R28 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28) 1078c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R29 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29) 1088c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R30 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30) 1098c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_R31 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31) 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_HI (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32) 1128c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_LO (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33) 1138c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_PC (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* 1178c2ecf20Sopenharmony_ci * KVM_REG_MIPS_KVM - KVM specific control registers. 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci/* 1218c2ecf20Sopenharmony_ci * CP0_Count control 1228c2ecf20Sopenharmony_ci * DC: Set 0: Master disable CP0_Count and set COUNT_RESUME to now 1238c2ecf20Sopenharmony_ci * Set 1: Master re-enable CP0_Count with unchanged bias, handling timer 1248c2ecf20Sopenharmony_ci * interrupts since COUNT_RESUME 1258c2ecf20Sopenharmony_ci * This can be used to freeze the timer to get a consistent snapshot of 1268c2ecf20Sopenharmony_ci * the CP0_Count and timer interrupt pending state, while also resuming 1278c2ecf20Sopenharmony_ci * safely without losing time or guest timer interrupts. 1288c2ecf20Sopenharmony_ci * Other: Reserved, do not change. 1298c2ecf20Sopenharmony_ci */ 1308c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_COUNT_CTL (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0) 1318c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_COUNT_CTL_DC 0x00000001 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci/* 1348c2ecf20Sopenharmony_ci * CP0_Count resume monotonic nanoseconds 1358c2ecf20Sopenharmony_ci * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master 1368c2ecf20Sopenharmony_ci * disable). Any reads and writes of Count related registers while 1378c2ecf20Sopenharmony_ci * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is 1388c2ecf20Sopenharmony_ci * cleared again (master enable) any timer interrupts since this time will be 1398c2ecf20Sopenharmony_ci * emulated. 1408c2ecf20Sopenharmony_ci * Modifications to times in the future are rejected. 1418c2ecf20Sopenharmony_ci */ 1428c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_COUNT_RESUME (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1) 1438c2ecf20Sopenharmony_ci/* 1448c2ecf20Sopenharmony_ci * CP0_Count rate in Hz 1458c2ecf20Sopenharmony_ci * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without 1468c2ecf20Sopenharmony_ci * discontinuities in CP0_Count. 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_COUNT_HZ (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2) 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/* 1528c2ecf20Sopenharmony_ci * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers. 1538c2ecf20Sopenharmony_ci * 1548c2ecf20Sopenharmony_ci * bits[15..8] - Register subset (see definitions below). 1558c2ecf20Sopenharmony_ci * bits[7..5] - Must be zero. 1568c2ecf20Sopenharmony_ci * bits[4..0] - Register number within register subset. 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FPR (KVM_REG_MIPS_FPU | 0x0000000000000000ULL) 1608c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FCR (KVM_REG_MIPS_FPU | 0x0000000000000100ULL) 1618c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_MSACR (KVM_REG_MIPS_FPU | 0x0000000000000200ULL) 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* 1648c2ecf20Sopenharmony_ci * KVM_REG_MIPS_FPR - Floating point / Vector registers. 1658c2ecf20Sopenharmony_ci */ 1668c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FPR_32(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32 | (n)) 1678c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FPR_64(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64 | (n)) 1688c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_VEC_128(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n)) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* 1718c2ecf20Sopenharmony_ci * KVM_REG_MIPS_FCR - Floating point control registers. 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FCR_IR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 0) 1748c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_FCR_CSR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31) 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci/* 1778c2ecf20Sopenharmony_ci * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers. 1788c2ecf20Sopenharmony_ci */ 1798c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_MSA_IR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 0) 1808c2ecf20Sopenharmony_ci#define KVM_REG_MIPS_MSA_CSR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 1) 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci/* 1848c2ecf20Sopenharmony_ci * KVM MIPS specific structures and definitions 1858c2ecf20Sopenharmony_ci * 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_cistruct kvm_debug_exit_arch { 1888c2ecf20Sopenharmony_ci __u64 epc; 1898c2ecf20Sopenharmony_ci}; 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/* for KVM_SET_GUEST_DEBUG */ 1928c2ecf20Sopenharmony_cistruct kvm_guest_debug_arch { 1938c2ecf20Sopenharmony_ci}; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci/* definition of registers in kvm_run */ 1968c2ecf20Sopenharmony_cistruct kvm_sync_regs { 1978c2ecf20Sopenharmony_ci}; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* dummy definition */ 2008c2ecf20Sopenharmony_cistruct kvm_sregs { 2018c2ecf20Sopenharmony_ci}; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistruct kvm_mips_interrupt { 2048c2ecf20Sopenharmony_ci /* in */ 2058c2ecf20Sopenharmony_ci __u32 cpu; 2068c2ecf20Sopenharmony_ci __u32 irq; 2078c2ecf20Sopenharmony_ci}; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#endif /* __LINUX_KVM_MIPS_H */ 210