[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC v2 7/9] target/loongarch: Implement kvm_arch_handle_exit
From: |
Tianrui Zhao |
Subject: |
[PATCH RFC v2 7/9] target/loongarch: Implement kvm_arch_handle_exit |
Date: |
Thu, 27 Apr 2023 15:26:43 +0800 |
Implement kvm_arch_handle_exit for loongarch. In this
function, the KVM_EXIT_LOONGARCH_IOCSR is handled,
we read or write the iocsr address space by the addr,
length and is_write argument in kvm_run.
Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
target/loongarch/kvm.c | 24 +++++++++++++++++++++++-
target/loongarch/trace-events | 1 +
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/target/loongarch/kvm.c b/target/loongarch/kvm.c
index 59d7e35490..bd994926d9 100644
--- a/target/loongarch/kvm.c
+++ b/target/loongarch/kvm.c
@@ -494,7 +494,29 @@ bool kvm_arch_cpu_check_are_resettable(void)
int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
{
- return 0;
+ int ret = 0;
+ LoongArchCPU *cpu = LOONGARCH_CPU(cs);
+ CPULoongArchState *env = &cpu->env;
+ MemTxAttrs attrs = {};
+
+ attrs.requester_id = env_cpu(env)->cpu_index;
+
+ trace_kvm_arch_handle_exit(run->exit_reason);
+ switch (run->exit_reason) {
+ case KVM_EXIT_LOONGARCH_IOCSR:
+ address_space_rw(&env->address_space_iocsr,
+ run->iocsr_io.phys_addr,
+ attrs,
+ run->iocsr_io.data,
+ run->iocsr_io.len,
+ run->iocsr_io.is_write);
+ break;
+ default:
+ ret = -1;
+ warn_report("KVM: unknown exit reason %d", run->exit_reason);
+ break;
+ }
+ return ret;
}
void kvm_arch_accel_class_init(ObjectClass *oc)
diff --git a/target/loongarch/trace-events b/target/loongarch/trace-events
index 6926bbe399..c79e01663a 100644
--- a/target/loongarch/trace-events
+++ b/target/loongarch/trace-events
@@ -11,3 +11,4 @@ kvm_failed_get_mpstate(const char *msg) "Failed to get
mp_state from KVM: %s"
kvm_failed_put_mpstate(const char *msg) "Failed to put mp_state into KVM: %s"
kvm_failed_get_counter(const char *msg) "Failed to get counter from KVM: %s"
kvm_failed_put_counter(const char *msg) "Failed to put counter into KVM: %s"
+kvm_arch_handle_exit(int num) "kvm arch handle exit, the reason number: %d"
--
2.31.1
- [PATCH RFC v2 0/9] Add loongarch kvm accel support, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 5/9] target/loongarch: Implement kvm_arch_init function, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 9/9] target/loongarch: Add loongarch kvm into meson build, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 8/9] target/loongarch: Implement set vcpu intr for kvm, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 7/9] target/loongarch: Implement kvm_arch_handle_exit,
Tianrui Zhao <=
- [PATCH RFC v2 3/9] target/loongarch: Supplement vcpu env initial when vcpu reset, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 6/9] target/loongarch: Implement kvm_arch_init_vcpu, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 2/9] target/loongarch: Define some kvm_arch interfaces, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 1/9] linux-headers: Add KVM headers for loongarch, Tianrui Zhao, 2023/04/27
- [PATCH RFC v2 4/9] target/loongarch: Implement kvm get/set registers, Tianrui Zhao, 2023/04/27