diff mbox series

[v2,22/29] LoongArch: KVM: Implement handle idle exception

Message ID 20230220065735.1282809-23-zhaotianrui@loongson.cn (mailing list archive)
State New, archived
Headers show
Series Add KVM LoongArch support | expand

Commit Message

zhaotianrui Feb. 20, 2023, 6:57 a.m. UTC
Implement kvm handle loongarch vcpu idle exception, using kvm_vcpu_block
to emulate it.

Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
 arch/loongarch/kvm/exit.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Paolo Bonzini Feb. 20, 2023, 6:40 p.m. UTC | #1
On 2/20/23 07:57, Tianrui Zhao wrote:
> +int _kvm_emu_idle(struct kvm_vcpu *vcpu)
> +{
> +	++vcpu->stat.idle_exits;
> +	trace_kvm_exit(vcpu, KVM_TRACE_EXIT_IDLE);

Please add a separate tracepoint, don't overload trace_kvm_exit().

Likewise for _kvm_trap_handle_gspr().

I think _kvm_trap_handle_gspr() should have a tracepoint whose parameter 
is inst.word.

Paolo

> +	if (!vcpu->arch.irq_pending) {
> +		kvm_save_timer(vcpu);
> +		kvm_vcpu_block(vcpu);
> +	}
> +
> +	return EMULATE_DONE;
zhaotianrui Feb. 21, 2023, 9:48 a.m. UTC | #2
在 2023年02月21日 02:40, Paolo Bonzini 写道:
> On 2/20/23 07:57, Tianrui Zhao wrote:
>> +int _kvm_emu_idle(struct kvm_vcpu *vcpu)
>> +{
>> +    ++vcpu->stat.idle_exits;
>> +    trace_kvm_exit(vcpu, KVM_TRACE_EXIT_IDLE);
>
> Please add a separate tracepoint, don't overload trace_kvm_exit().
>
> Likewise for _kvm_trap_handle_gspr().
>
> I think _kvm_trap_handle_gspr() should have a tracepoint whose 
> parameter is inst.word.

Thanks, I will add the tracepoint for _kvm_emu_idle and 
_kvm_trap_handle_gspr.

Thanks
Tianrui Zhao

>
> Paolo
>
>> +    if (!vcpu->arch.irq_pending) {
>> +        kvm_save_timer(vcpu);
>> +        kvm_vcpu_block(vcpu);
>> +    }
>> +
>> +    return EMULATE_DONE;
diff mbox series

Patch

diff --git a/arch/loongarch/kvm/exit.c b/arch/loongarch/kvm/exit.c
index f02e2b940..a6beb83a0 100644
--- a/arch/loongarch/kvm/exit.c
+++ b/arch/loongarch/kvm/exit.c
@@ -191,3 +191,15 @@  int _kvm_complete_iocsr_read(struct kvm_vcpu *vcpu, struct kvm_run *run)
 
 	return er;
 }
+
+int _kvm_emu_idle(struct kvm_vcpu *vcpu)
+{
+	++vcpu->stat.idle_exits;
+	trace_kvm_exit(vcpu, KVM_TRACE_EXIT_IDLE);
+	if (!vcpu->arch.irq_pending) {
+		kvm_save_timer(vcpu);
+		kvm_vcpu_block(vcpu);
+	}
+
+	return EMULATE_DONE;
+}