Skip to content

Commit 80989e8

Browse files
author
Jinrong Liang
committed
KVM: x86/PVM: Enhance exit reason handling for PVM hypercalls
Improve the handling of exit reasons for PVM hypercalls by adding more specific exit reasons based on the type of PVM hypercall. This enables a more fine-grained analysis of the performance and behavior of PVM-based virtual machines. The new exit reasons cover various PVM hypercall types, including IRQ_WIN, IRQ_HALT, LOAD_PGTBL, TLB_FLUSH, TLB_FLUSH_CURRENT, TLB_INVLPG, LOAD_GS, RDMSR, WRMSR, and LOAD_TLS. Providing specific exit reasons for each of these hypercall types allows for better insights into the performance characteristics of PVM-based virtual machines and helps identify potential areas for optimization. Moreover, this change benefits performance analysis tools, such as perf, by allowing them to provide more detailed information about the execution of PVM hypercalls. This improvement helps users gain a better understanding of the performance bottlenecks in their virtualized environments and make informed decisions about optimizing their systems. Signed-off-by: Jinrong Liang <cloudliang@tencent.com>
1 parent 819c84c commit 80989e8

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

arch/x86/kvm/pvm/pvm.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,27 @@ static int pvm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
24242424
return 0;
24252425
}
24262426

2427+
static u32 pvm_get_hypercall_exit_reason(struct kvm_vcpu *vcpu)
2428+
{
2429+
u32 hypercall_exit_code = kvm_rax_read(vcpu);
2430+
2431+
switch (hypercall_exit_code) {
2432+
case PVM_HC_IRQ_WIN:
2433+
case PVM_HC_IRQ_HALT:
2434+
case PVM_HC_LOAD_PGTBL:
2435+
case PVM_HC_TLB_FLUSH:
2436+
case PVM_HC_TLB_FLUSH_CURRENT:
2437+
case PVM_HC_TLB_INVLPG:
2438+
case PVM_HC_LOAD_GS:
2439+
case PVM_HC_RDMSR:
2440+
case PVM_HC_WRMSR:
2441+
case PVM_HC_LOAD_TLS:
2442+
return hypercall_exit_code;
2443+
default:
2444+
return PVM_EXIT_REASONS_HYPERCALL;
2445+
}
2446+
}
2447+
24272448
static u32 pvm_get_syscall_exit_reason(struct kvm_vcpu *vcpu)
24282449
{
24292450
struct vcpu_pvm *pvm = to_pvm(vcpu);
@@ -2435,7 +2456,7 @@ static u32 pvm_get_syscall_exit_reason(struct kvm_vcpu *vcpu)
24352456
else if (rip == pvm->msr_rets_rip_plus2)
24362457
return PVM_EXIT_REASONS_ERETS;
24372458
else
2438-
return PVM_EXIT_REASONS_HYPERCALL;
2459+
return pvm_get_hypercall_exit_reason(vcpu);
24392460
}
24402461

24412462
return PVM_EXIT_REASONS_SYSCALL;

0 commit comments

Comments
 (0)