diff options
author | Andrew Jones <ajones@ventanamicro.com> | 2022-10-18 19:38:52 +0530 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2022-11-08 15:34:21 +0000 |
commit | b721ac0ad88a828890a7e44aa7889675152997eb (patch) | |
tree | 98e4797f2d6b5653e94ce3d6989a38e766e944d9 | |
parent | 23a8ed9073310d6aa06930cf65820cd2ccab2037 (diff) | |
download | kvmtool-b721ac0ad88a828890a7e44aa7889675152997eb.tar.gz |
riscv: Move reg encoding helpers to kvm-cpu-arch.h
We'll need one of these helpers in the next patch in another file.
Let's proactively move them all now, since others may some day also
be useful.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20221018140854.69846-5-apatel@ventanamicro.com
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | riscv/fdt.c | 2 | ||||
-rw-r--r-- | riscv/include/kvm/kvm-cpu-arch.h | 19 | ||||
-rw-r--r-- | riscv/kvm-cpu.c | 16 |
3 files changed, 19 insertions, 18 deletions
diff --git a/riscv/fdt.c b/riscv/fdt.c index ef0bc47e..8d6da11b 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -9,8 +9,6 @@ #include <linux/kernel.h> #include <linux/sizes.h> -#define RISCV_ISA_EXT_REG(id) __kvm_reg_id(KVM_REG_RISCV_ISA_EXT, \ - id, KVM_REG_SIZE_ULONG) struct isa_ext_info { const char *name; unsigned long ext_id; diff --git a/riscv/include/kvm/kvm-cpu-arch.h b/riscv/include/kvm/kvm-cpu-arch.h index 4b3e6022..e0148390 100644 --- a/riscv/include/kvm/kvm-cpu-arch.h +++ b/riscv/include/kvm/kvm-cpu-arch.h @@ -18,6 +18,25 @@ static inline __u64 __kvm_reg_id(__u64 type, __u64 idx, __u64 size) #define KVM_REG_SIZE_ULONG KVM_REG_SIZE_U32 #endif +#define RISCV_CONFIG_REG(name) __kvm_reg_id(KVM_REG_RISCV_CONFIG, \ + KVM_REG_RISCV_CONFIG_REG(name), \ + KVM_REG_SIZE_ULONG) + +#define RISCV_ISA_EXT_REG(id) __kvm_reg_id(KVM_REG_RISCV_ISA_EXT, \ + id, KVM_REG_SIZE_ULONG) + +#define RISCV_CORE_REG(name) __kvm_reg_id(KVM_REG_RISCV_CORE, \ + KVM_REG_RISCV_CORE_REG(name), \ + KVM_REG_SIZE_ULONG) + +#define RISCV_CSR_REG(name) __kvm_reg_id(KVM_REG_RISCV_CSR, \ + KVM_REG_RISCV_CSR_REG(name), \ + KVM_REG_SIZE_ULONG) + +#define RISCV_TIMER_REG(name) __kvm_reg_id(KVM_REG_RISCV_TIMER, \ + KVM_REG_RISCV_TIMER_REG(name), \ + KVM_REG_SIZE_U64) + struct kvm_cpu { pthread_t thread; diff --git a/riscv/kvm-cpu.c b/riscv/kvm-cpu.c index a17b9579..f98bd7ae 100644 --- a/riscv/kvm-cpu.c +++ b/riscv/kvm-cpu.c @@ -18,22 +18,6 @@ int kvm_cpu__get_debug_fd(void) return debug_fd; } -#define RISCV_CONFIG_REG(name) __kvm_reg_id(KVM_REG_RISCV_CONFIG, \ - KVM_REG_RISCV_CONFIG_REG(name), \ - KVM_REG_SIZE_ULONG) - -#define RISCV_CORE_REG(name) __kvm_reg_id(KVM_REG_RISCV_CORE, \ - KVM_REG_RISCV_CORE_REG(name), \ - KVM_REG_SIZE_ULONG) - -#define RISCV_CSR_REG(name) __kvm_reg_id(KVM_REG_RISCV_CSR, \ - KVM_REG_RISCV_CSR_REG(name), \ - KVM_REG_SIZE_ULONG) - -#define RISCV_TIMER_REG(name) __kvm_reg_id(KVM_REG_RISCV_TIMER, \ - KVM_REG_RISCV_TIMER_REG(name), \ - KVM_REG_SIZE_U64) - struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id) { struct kvm_cpu *vcpu; |