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