Re: [External] Re: [RESEND RFC: timer passthrough 0/9] Support timer passthrough for VM

2021-02-23 Thread Zhimin Feng
is '0'), the preemption timer would trigger immediate VMExit, so the host timer would be handled in the preemption timer handler. Thanks! Zhimin 在 2021/2/9 上午2:13, Konrad Rzeszutek Wilk 写道: On Fri, Feb 05, 2021 at 06:03:08PM +0800, Zhimin Feng wrote: The main motivation for this patch

Re: [External] Re: [RFC: timer passthrough 1/9] KVM: vmx: hook set_next_event for getting the host tscd

2021-02-23 Thread Zhimin Feng
Hi tglx This question is very nice,  we should be considered to judge whether the current active device is the tsc deadline timer. I will fix this in V2. Thanks Zhimin 在 2021/2/6 上午2:11, Thomas Gleixner 写道: On Fri, Feb 05 2021 at 18:03, Zhimin Feng wrote: @@ -520,6 +521,24 @@ struct

[RESEND RFC: timer passthrough 0/9] Support timer passthrough for VM

2021-02-05 Thread Zhimin Feng
| 411766.67| - Avg.Latency|0.99483 | 1.24294 | = Zhimin Feng (9): KVM: vmx: hook set_next_event for getting the host tscd KVM: vmx

[RFC: timer passthrough 2/9] KVM: vmx: enable host lapic timer offload preemtion timer

2021-02-05 Thread Zhimin Feng
Use preemption timer to handle host timer Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 54 + arch/x86/kvm/x86.c | 1 + 3 files changed, 56 insertions(+) diff --git a/arch/x86

[RFC: timer passthrough 3/9] KVM: vmx: enable passthrough timer to guest

2021-02-05 Thread Zhimin Feng
Allow Guest to write tscdeadline msr directly. Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/lapic.c| 9 +++ arch/x86/kvm/vmx/vmx.c | 56 + 3 files changed, 68 insertions(+) diff --git

[RFC: timer passthrough 1/9] KVM: vmx: hook set_next_event for getting the host tscd

2021-02-05 Thread Zhimin Feng
In order to get the host tscd value, we need to hook set_next_event function Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 21 + arch/x86/kvm/vmx/vmx.c | 51 + arch/x86/kvm/x86.c | 1 + kernel/time

[RFC: timer passthrough 4/9] KVM: vmx: enable passth timer switch to sw timer

2021-02-05 Thread Zhimin Feng
Switch the guest timer to software timer when the VCPU is scheduled. Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 65 + arch/x86/kvm/x86.c | 12 ++-- 3 files changed, 76

[RFC: timer passthrough 5/9] KVM: vmx: use tsc_adjust to enable tsc_offset timer passthrough

2021-02-05 Thread Zhimin Feng
ust equal tsc_offset and vmcs tsc offset filed equal 0, so the vm execute rdtsc the result like this: rdtsc = host_tsc + tsc_adjust + 0 the tsc_deadline_msr value will equal tsc stampcounter msr and the irq will trigger success. Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h |

[RFC: timer passthrough 9/9] KVM: vmx: query the state of timer-passth for vm

2021-02-05 Thread Zhimin Feng
query the state of timer passthrough of specific vm Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/vmx/vmx.c | 11 +++ arch/x86/kvm/x86.c | 6 ++ include/uapi/linux/kvm.h| 1 + tools/include/uapi/linux/kvm.h | 1

[RFC: timer passthrough 6/9] KVM: vmx: check enable_timer_passth strictly

2021-02-05 Thread Zhimin Feng
preemption timer is default disabled timer passthrough is default enabled Signed-off-by: Zhimin Feng --- arch/x86/kvm/vmx/vmx.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 44b2fd59587e..a12da3cef86d 100644

[RFC: timer passthrough 8/9] KVM: vmx: Dynamically open or close the timer-passthrough for pre-vm

2021-02-05 Thread Zhimin Feng
Timer passthrough is default disabled Signed-off-by: Zhimin Feng --- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/lapic.c| 10 +--- arch/x86/kvm/vmx/vmx.c | 52 + arch/x86/kvm/x86.c | 6 + include/linux

[RFC: timer passthrough 7/9] KVM: vmx: save the initial value of host tscd

2021-02-05 Thread Zhimin Feng
Record the host tscd value. Signed-off-by: Zhimin Feng --- arch/x86/kvm/vmx/vmx.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index a12da3cef86d..98eca70d4251 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -251,8