Skip to content

Commit

Permalink
target/loongarch: Set cpuid CSR register only once with kvm mode
Browse files Browse the repository at this point in the history
CSR cpuid register is used for routing irq to different vcpus, its
value is kept unchanged since poweron. So it is not necessary to
set CSR cpuid register after system resets, and it is only set at
vm creation stage.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240115085121.180524-1-maobibo@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
  • Loading branch information
bibo-mao authored and gaosong-loongson committed Jan 25, 2024
1 parent 4a4efae commit 61f6e15
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions target/loongarch/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int kvm_loongarch_get_csr(CPUState *cs)
return ret;
}

static int kvm_loongarch_put_csr(CPUState *cs)
static int kvm_loongarch_put_csr(CPUState *cs, int level)
{
int ret = 0;
LoongArchCPU *cpu = LOONGARCH_CPU(cs);
Expand Down Expand Up @@ -322,8 +322,11 @@ static int kvm_loongarch_put_csr(CPUState *cs)
ret |= kvm_set_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_RVACFG),
&env->CSR_RVACFG);

ret |= kvm_set_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_CPUID),
/* CPUID is constant after poweron, it should be set only once */
if (level >= KVM_PUT_FULL_STATE) {
ret |= kvm_set_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_CPUID),
&env->CSR_CPUID);
}

ret |= kvm_set_one_reg(cs, KVM_IOC_CSRID(LOONGARCH_CSR_PRCFG1),
&env->CSR_PRCFG1);
Expand Down Expand Up @@ -598,7 +601,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
return ret;
}

ret = kvm_loongarch_put_csr(cs);
ret = kvm_loongarch_put_csr(cs, level);
if (ret) {
return ret;
}
Expand Down

0 comments on commit 61f6e15

Please sign in to comment.