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_COALESCED_MMIO_PAGE_OFFSET 1 18 #define KVM_DIRTY_LOG_PAGE_OFFSET 64 19 20 #define KVM_GUESTDBG_USE_SW_BP 0x00010000 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 /* Debugging: Special instruction for software breakpoint */ 78 #define KVM_REG_LOONGARCH_DEBUG_INST (KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 3) 79 80 #define LOONGARCH_REG_SHIFT 3 81 #define LOONGARCH_REG_64(TYPE, REG) (TYPE | KVM_REG_SIZE_U64 | (REG << LOONGARCH_REG_SHIFT)) 82 #define KVM_IOC_CSRID(REG) LOONGARCH_REG_64(KVM_REG_LOONGARCH_CSR, REG) 83 #define KVM_IOC_CPUCFG(REG) LOONGARCH_REG_64(KVM_REG_LOONGARCH_CPUCFG, REG) 84 85 /* Device Control API on vcpu fd */ 86 #define KVM_LOONGARCH_VCPU_CPUCFG 0 87 #define KVM_LOONGARCH_VCPU_PVTIME_CTRL 1 88 #define KVM_LOONGARCH_VCPU_PVTIME_GPA 0 89 90 struct kvm_debug_exit_arch { 91 }; 92 93 /* for KVM_SET_GUEST_DEBUG */ 94 struct kvm_guest_debug_arch { 95 }; 96 97 /* definition of registers in kvm_run */ 98 struct kvm_sync_regs { 99 }; 100 101 /* dummy definition */ 102 struct kvm_sregs { 103 }; 104 105 struct kvm_iocsr_entry { 106 __u32 addr; 107 __u32 pad; 108 __u64 data; 109 }; 110 111 #define KVM_NR_IRQCHIPS 1 112 #define KVM_IRQCHIP_NUM_PINS 64 113 #define KVM_MAX_CORES 256 114 115 #endif /* __UAPI_ASM_LOONGARCH_KVM_H */ 116
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.