diff options
author | Bibo Mao <maobibo@loongson.cn> | 2023-12-19 10:48:28 +0800 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2023-12-19 10:48:28 +0800 |
commit | 5b3d524993ff1fb36089be850ccb121ac3296bcf (patch) | |
tree | 83aed9914b0db0d7a67930f27e3ebbe3a5b7e7ed /tools/testing/selftests/bpf/prog_tests/recursion.c | |
parent | 1ab9c6099495f79bfbcd6058d02d7556034a89b0 (diff) |
LoongArch: KVM: Fix timer emulation with oneshot mode
When timer is fired in oneshot mode, CSR TVAL will be -1 rather than 0.
There needs special handing for this situation. There are two scenarios
when oneshot timer is fired. One scenario is that time is fired after
exiting to host, CSR TVAL is set with 0 in order to inject hw interrupt,
and -1 will assigned to CSR TVAL soon.
The other situation is that timer is fired in VM and guest kernel is
hanlding timer IRQ, IRQ is acked and is ready to set next expired timer
value, then vm exits to host. Timer interrupt should not be inject at
this point, else there will be spurious timer interrupt.
Here hw timer irq status in CSR ESTAT is used to judge these two
scenarios. If CSR TVAL is -1, the oneshot timer is fired; and if timer
hw irq is on in CSR ESTAT register, it happens after exiting to host;
else if timer hw irq is off, we think that it happens in vm and timer
IRQ handler has already acked IRQ.
With this patch, runltp with version ltp20230516 passes to run in vm.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/recursion.c')
0 files changed, 0 insertions, 0 deletions