1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Copyright (C) 2020-2023 Loongson Technology Corporation Limited 4 */ 5 6 #ifndef __UAPI_ASM_LOONGARCH_KVM_H 7 #define __UAPI_ASM_LOONGARCH_KVM_H 8 9 #include <linux/types.h> 10 11 /* 12 * KVM LoongArch specific structures and definitions. 13 * 14 * Some parts derived from the x86 version of this file. 15 */ 16 17 #define __KVM_HAVE_READONLY_MEM 18 19 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 20 #define KVM_DIRTY_LOG_PAGE_OFFSET 64 21 22 /* 23 * for KVM_GET_REGS and KVM_SET_REGS 24 */ 25 struct kvm_regs { 26 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */ 27 __u64 gpr[32]; 28 __u64 pc; 29 }; 30 31 /* 32 * for KVM_GET_FPU and KVM_SET_FPU 33 */ 34 struct kvm_fpu { 35 __u32 fcsr; 36 __u64 fcc; /* 8x8 */ 37 struct kvm_fpureg { 38 __u64 val64[4]; 39 } fpr[32]; 40 }; 41 42 /* 43 * For LoongArch, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various 44 * registers. The id field is broken down as follows: 45 * 46 * bits[63..52] - As per linux/kvm.h 47 * bits[51..32] - Must be zero. 48 * bits[31..16] - Register set. 49 * 50 * Register set = 0: GP registers from kvm_regs (see definitions below). 51 * 52 * Register set = 1: CSR registers. 53 * 54 * Register set = 2: KVM specific registers (see definitions below). 55 * 56 * Register set = 3: FPU / SIMD registers (see definitions below). 57 * 58 * Other sets registers may be added in the future. Each set would 59 * have its own identifier in bits[31..16]. 60 */ 61 62 #define KVM_REG_LOONGARCH_GPR (KVM_REG_LOONGARCH | 0x00000ULL) 63 #define KVM_REG_LOONGARCH_CSR (KVM_REG_LOONGARCH | 0x10000ULL) 64 #define KVM_REG_LOONGARCH_KVM (KVM_REG_LOONGARCH | 0x20000ULL) 65 #define KVM_REG_LOONGARCH_FPSIMD (KVM_REG_LOONGARCH | 0x30000ULL) 66 #define KVM_REG_LOONGARCH_CPUCFG (KVM_REG_LOONGARCH | 0x40000ULL) 67 #define KVM_REG_LOONGARCH_MASK (KVM_REG_LOONGARCH | 0x70000ULL) 68 #define KVM_CSR_IDX_MASK 0x7fff 69 #define KVM_CPUCFG_IDX_MASK 0x7fff 70 71 /* 72 * KVM_REG_LOONGARCH_KVM - KVM specific control registers. 73 */ 74 75 #define KVM_REG_LOONGARCH_COUNTER (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 1) 76 #define KVM_REG_LOONGARCH_VCPU_RESET (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 2) 77 78 #define LOONGARCH_REG_SHIFT 3 79 #define LOONGARCH_REG_64(TYPE, REG) (TYPE | KVM_REG_SIZE_U64 | (REG << LOONGARCH_REG_SHIFT)) 80 #define KVM_IOC_CSRID(REG) LOONGARCH_REG_64(KVM_REG_LOONGARCH_CSR, REG) 81 #define KVM_IOC_CPUCFG(REG) LOONGARCH_REG_64(KVM_REG_LOONGARCH_CPUCFG, REG) 82 83 struct kvm_debug_exit_arch { 84 }; 85 86 /* for KVM_SET_GUEST_DEBUG */ 87 struct kvm_guest_debug_arch { 88 }; 89 90 /* definition of registers in kvm_run */ 91 struct kvm_sync_regs { 92 }; 93 94 /* dummy definition */ 95 struct kvm_sregs { 96 }; 97 98 struct kvm_iocsr_entry { 99 __u32 addr; 100 __u32 pad; 101 __u64 data; 102 }; 103 104 #define KVM_NR_IRQCHIPS 1 105 #define KVM_IRQCHIP_NUM_PINS 64 106 #define KVM_MAX_CORES 256 107 108 #endif /* __UAPI_ASM_LOONGARCH_KVM_H */ 109