162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 462306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 562306a36Sopenharmony_ci * for more details. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved. 862306a36Sopenharmony_ci * Copyright (C) 2013 Cavium, Inc. 962306a36Sopenharmony_ci * Authors: Sanjay Lal <sanjayl@kymasys.com> 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#ifndef __LINUX_KVM_MIPS_H 1362306a36Sopenharmony_ci#define __LINUX_KVM_MIPS_H 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include <linux/types.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* 1862306a36Sopenharmony_ci * KVM MIPS specific structures and definitions. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * Some parts derived from the x86 version of this file. 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define __KVM_HAVE_READONLY_MEM 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci/* 2862306a36Sopenharmony_ci * for KVM_GET_REGS and KVM_SET_REGS 2962306a36Sopenharmony_ci * 3062306a36Sopenharmony_ci * If Config[AT] is zero (32-bit CPU), the register contents are 3162306a36Sopenharmony_ci * stored in the lower 32-bits of the struct kvm_regs fields and sign 3262306a36Sopenharmony_ci * extended to 64-bits. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_cistruct kvm_regs { 3562306a36Sopenharmony_ci /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 3662306a36Sopenharmony_ci __u64 gpr[32]; 3762306a36Sopenharmony_ci __u64 hi; 3862306a36Sopenharmony_ci __u64 lo; 3962306a36Sopenharmony_ci __u64 pc; 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * for KVM_GET_FPU and KVM_SET_FPU 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_cistruct kvm_fpu { 4662306a36Sopenharmony_ci}; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci/* 5062306a36Sopenharmony_ci * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various 5162306a36Sopenharmony_ci * registers. The id field is broken down as follows: 5262306a36Sopenharmony_ci * 5362306a36Sopenharmony_ci * bits[63..52] - As per linux/kvm.h 5462306a36Sopenharmony_ci * bits[51..32] - Must be zero. 5562306a36Sopenharmony_ci * bits[31..16] - Register set. 5662306a36Sopenharmony_ci * 5762306a36Sopenharmony_ci * Register set = 0: GP registers from kvm_regs (see definitions below). 5862306a36Sopenharmony_ci * 5962306a36Sopenharmony_ci * Register set = 1: CP0 registers. 6062306a36Sopenharmony_ci * bits[15..8] - COP0 register set. 6162306a36Sopenharmony_ci * 6262306a36Sopenharmony_ci * COP0 register set = 0: Main CP0 registers. 6362306a36Sopenharmony_ci * bits[7..3] - Register 'rd' index. 6462306a36Sopenharmony_ci * bits[2..0] - Register 'sel' index. 6562306a36Sopenharmony_ci * 6662306a36Sopenharmony_ci * COP0 register set = 1: MAARs. 6762306a36Sopenharmony_ci * bits[7..0] - MAAR index. 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * Register set = 2: KVM specific registers (see definitions below). 7062306a36Sopenharmony_ci * 7162306a36Sopenharmony_ci * Register set = 3: FPU / MSA registers (see definitions below). 7262306a36Sopenharmony_ci * 7362306a36Sopenharmony_ci * Other sets registers may be added in the future. Each set would 7462306a36Sopenharmony_ci * have its own identifier in bits[31..16]. 7562306a36Sopenharmony_ci */ 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#define KVM_REG_MIPS_GP (KVM_REG_MIPS | 0x0000000000000000ULL) 7862306a36Sopenharmony_ci#define KVM_REG_MIPS_CP0 (KVM_REG_MIPS | 0x0000000000010000ULL) 7962306a36Sopenharmony_ci#define KVM_REG_MIPS_KVM (KVM_REG_MIPS | 0x0000000000020000ULL) 8062306a36Sopenharmony_ci#define KVM_REG_MIPS_FPU (KVM_REG_MIPS | 0x0000000000030000ULL) 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* 8462306a36Sopenharmony_ci * KVM_REG_MIPS_GP - General purpose registers from kvm_regs. 8562306a36Sopenharmony_ci */ 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define KVM_REG_MIPS_R0 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 0) 8862306a36Sopenharmony_ci#define KVM_REG_MIPS_R1 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 1) 8962306a36Sopenharmony_ci#define KVM_REG_MIPS_R2 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 2) 9062306a36Sopenharmony_ci#define KVM_REG_MIPS_R3 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 3) 9162306a36Sopenharmony_ci#define KVM_REG_MIPS_R4 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 4) 9262306a36Sopenharmony_ci#define KVM_REG_MIPS_R5 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 5) 9362306a36Sopenharmony_ci#define KVM_REG_MIPS_R6 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 6) 9462306a36Sopenharmony_ci#define KVM_REG_MIPS_R7 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 7) 9562306a36Sopenharmony_ci#define KVM_REG_MIPS_R8 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 8) 9662306a36Sopenharmony_ci#define KVM_REG_MIPS_R9 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 9) 9762306a36Sopenharmony_ci#define KVM_REG_MIPS_R10 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10) 9862306a36Sopenharmony_ci#define KVM_REG_MIPS_R11 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11) 9962306a36Sopenharmony_ci#define KVM_REG_MIPS_R12 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12) 10062306a36Sopenharmony_ci#define KVM_REG_MIPS_R13 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13) 10162306a36Sopenharmony_ci#define KVM_REG_MIPS_R14 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14) 10262306a36Sopenharmony_ci#define KVM_REG_MIPS_R15 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15) 10362306a36Sopenharmony_ci#define KVM_REG_MIPS_R16 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16) 10462306a36Sopenharmony_ci#define KVM_REG_MIPS_R17 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17) 10562306a36Sopenharmony_ci#define KVM_REG_MIPS_R18 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18) 10662306a36Sopenharmony_ci#define KVM_REG_MIPS_R19 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19) 10762306a36Sopenharmony_ci#define KVM_REG_MIPS_R20 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20) 10862306a36Sopenharmony_ci#define KVM_REG_MIPS_R21 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21) 10962306a36Sopenharmony_ci#define KVM_REG_MIPS_R22 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22) 11062306a36Sopenharmony_ci#define KVM_REG_MIPS_R23 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23) 11162306a36Sopenharmony_ci#define KVM_REG_MIPS_R24 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24) 11262306a36Sopenharmony_ci#define KVM_REG_MIPS_R25 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25) 11362306a36Sopenharmony_ci#define KVM_REG_MIPS_R26 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26) 11462306a36Sopenharmony_ci#define KVM_REG_MIPS_R27 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27) 11562306a36Sopenharmony_ci#define KVM_REG_MIPS_R28 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28) 11662306a36Sopenharmony_ci#define KVM_REG_MIPS_R29 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29) 11762306a36Sopenharmony_ci#define KVM_REG_MIPS_R30 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30) 11862306a36Sopenharmony_ci#define KVM_REG_MIPS_R31 (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31) 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define KVM_REG_MIPS_HI (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32) 12162306a36Sopenharmony_ci#define KVM_REG_MIPS_LO (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33) 12262306a36Sopenharmony_ci#define KVM_REG_MIPS_PC (KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* 12662306a36Sopenharmony_ci * KVM_REG_MIPS_CP0 - Coprocessor 0 registers. 12762306a36Sopenharmony_ci */ 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci#define KVM_REG_MIPS_MAAR (KVM_REG_MIPS_CP0 | (1 << 8)) 13062306a36Sopenharmony_ci#define KVM_REG_MIPS_CP0_MAAR(n) (KVM_REG_MIPS_MAAR | \ 13162306a36Sopenharmony_ci KVM_REG_SIZE_U64 | (n)) 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci/* 13562306a36Sopenharmony_ci * KVM_REG_MIPS_KVM - KVM specific control registers. 13662306a36Sopenharmony_ci */ 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* 13962306a36Sopenharmony_ci * CP0_Count control 14062306a36Sopenharmony_ci * DC: Set 0: Master disable CP0_Count and set COUNT_RESUME to now 14162306a36Sopenharmony_ci * Set 1: Master re-enable CP0_Count with unchanged bias, handling timer 14262306a36Sopenharmony_ci * interrupts since COUNT_RESUME 14362306a36Sopenharmony_ci * This can be used to freeze the timer to get a consistent snapshot of 14462306a36Sopenharmony_ci * the CP0_Count and timer interrupt pending state, while also resuming 14562306a36Sopenharmony_ci * safely without losing time or guest timer interrupts. 14662306a36Sopenharmony_ci * Other: Reserved, do not change. 14762306a36Sopenharmony_ci */ 14862306a36Sopenharmony_ci#define KVM_REG_MIPS_COUNT_CTL (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0) 14962306a36Sopenharmony_ci#define KVM_REG_MIPS_COUNT_CTL_DC 0x00000001 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci/* 15262306a36Sopenharmony_ci * CP0_Count resume monotonic nanoseconds 15362306a36Sopenharmony_ci * The monotonic nanosecond time of the last set of COUNT_CTL.DC (master 15462306a36Sopenharmony_ci * disable). Any reads and writes of Count related registers while 15562306a36Sopenharmony_ci * COUNT_CTL.DC=1 will appear to occur at this time. When COUNT_CTL.DC is 15662306a36Sopenharmony_ci * cleared again (master enable) any timer interrupts since this time will be 15762306a36Sopenharmony_ci * emulated. 15862306a36Sopenharmony_ci * Modifications to times in the future are rejected. 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_ci#define KVM_REG_MIPS_COUNT_RESUME (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1) 16162306a36Sopenharmony_ci/* 16262306a36Sopenharmony_ci * CP0_Count rate in Hz 16362306a36Sopenharmony_ci * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without 16462306a36Sopenharmony_ci * discontinuities in CP0_Count. 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_ci#define KVM_REG_MIPS_COUNT_HZ (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2) 16762306a36Sopenharmony_ci 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/* 17062306a36Sopenharmony_ci * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers. 17162306a36Sopenharmony_ci * 17262306a36Sopenharmony_ci * bits[15..8] - Register subset (see definitions below). 17362306a36Sopenharmony_ci * bits[7..5] - Must be zero. 17462306a36Sopenharmony_ci * bits[4..0] - Register number within register subset. 17562306a36Sopenharmony_ci */ 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci#define KVM_REG_MIPS_FPR (KVM_REG_MIPS_FPU | 0x0000000000000000ULL) 17862306a36Sopenharmony_ci#define KVM_REG_MIPS_FCR (KVM_REG_MIPS_FPU | 0x0000000000000100ULL) 17962306a36Sopenharmony_ci#define KVM_REG_MIPS_MSACR (KVM_REG_MIPS_FPU | 0x0000000000000200ULL) 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/* 18262306a36Sopenharmony_ci * KVM_REG_MIPS_FPR - Floating point / Vector registers. 18362306a36Sopenharmony_ci */ 18462306a36Sopenharmony_ci#define KVM_REG_MIPS_FPR_32(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32 | (n)) 18562306a36Sopenharmony_ci#define KVM_REG_MIPS_FPR_64(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64 | (n)) 18662306a36Sopenharmony_ci#define KVM_REG_MIPS_VEC_128(n) (KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n)) 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci/* 18962306a36Sopenharmony_ci * KVM_REG_MIPS_FCR - Floating point control registers. 19062306a36Sopenharmony_ci */ 19162306a36Sopenharmony_ci#define KVM_REG_MIPS_FCR_IR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 0) 19262306a36Sopenharmony_ci#define KVM_REG_MIPS_FCR_CSR (KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31) 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ci/* 19562306a36Sopenharmony_ci * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers. 19662306a36Sopenharmony_ci */ 19762306a36Sopenharmony_ci#define KVM_REG_MIPS_MSA_IR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 0) 19862306a36Sopenharmony_ci#define KVM_REG_MIPS_MSA_CSR (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 | 1) 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci/* 20262306a36Sopenharmony_ci * KVM MIPS specific structures and definitions 20362306a36Sopenharmony_ci * 20462306a36Sopenharmony_ci */ 20562306a36Sopenharmony_cistruct kvm_debug_exit_arch { 20662306a36Sopenharmony_ci __u64 epc; 20762306a36Sopenharmony_ci}; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci/* for KVM_SET_GUEST_DEBUG */ 21062306a36Sopenharmony_cistruct kvm_guest_debug_arch { 21162306a36Sopenharmony_ci}; 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* definition of registers in kvm_run */ 21462306a36Sopenharmony_cistruct kvm_sync_regs { 21562306a36Sopenharmony_ci}; 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci/* dummy definition */ 21862306a36Sopenharmony_cistruct kvm_sregs { 21962306a36Sopenharmony_ci}; 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_cistruct kvm_mips_interrupt { 22262306a36Sopenharmony_ci /* in */ 22362306a36Sopenharmony_ci __u32 cpu; 22462306a36Sopenharmony_ci __u32 irq; 22562306a36Sopenharmony_ci}; 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci#endif /* __LINUX_KVM_MIPS_H */ 228