mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-05-26 11:40:24 +02:00
KVM: LoongArch: selftests: Add cpucfg read/write helpers
Add helper macros and functions to read and write CPU configuration registers (cpucfg) from the guest and from the VMM. This interface is required in upcoming selftests for querying and setting CPU features, such as PMU capabilities. Signed-off-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
@@ -128,6 +128,17 @@
|
||||
#define CSR_TLBREHI_PS_SHIFT 0
|
||||
#define CSR_TLBREHI_PS (0x3fUL << CSR_TLBREHI_PS_SHIFT)
|
||||
|
||||
#define read_cpucfg(reg) \
|
||||
({ \
|
||||
register unsigned long __v; \
|
||||
__asm__ __volatile__( \
|
||||
"cpucfg %0, %1\n\t" \
|
||||
: "=r" (__v) \
|
||||
: "r" (reg) \
|
||||
: "memory"); \
|
||||
__v; \
|
||||
})
|
||||
|
||||
#define csr_read(csr) \
|
||||
({ \
|
||||
register unsigned long __v; \
|
||||
|
||||
@@ -251,6 +251,14 @@ static void loongarch_set_reg(struct kvm_vcpu *vcpu, uint64_t id, uint64_t val)
|
||||
__vcpu_set_reg(vcpu, id, val);
|
||||
}
|
||||
|
||||
static void loongarch_set_cpucfg(struct kvm_vcpu *vcpu, uint64_t id, uint64_t val)
|
||||
{
|
||||
uint64_t cfgid;
|
||||
|
||||
cfgid = KVM_REG_LOONGARCH_CPUCFG | KVM_REG_SIZE_U64 | 8 * id;
|
||||
__vcpu_set_reg(vcpu, cfgid, val);
|
||||
}
|
||||
|
||||
static void loongarch_get_csr(struct kvm_vcpu *vcpu, uint64_t id, void *addr)
|
||||
{
|
||||
uint64_t csrid;
|
||||
|
||||
Reference in New Issue
Block a user