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