kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: Add tracepoint for cr_interception
@ 2020-09-04 11:25 Haiwei Li
  2020-09-04 12:01 ` Vitaly Kuznetsov
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Haiwei Li @ 2020-09-04 11:25 UTC (permalink / raw)
  To: linux-kernel, kvm, x86
  Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli, vkuznets,
	sean.j.christopherson, pbonzini

From: Haiwei Li <lihaiwei@tencent.com>

Add trace_kvm_cr_write and trace_kvm_cr_read for svm.

Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
---
  arch/x86/kvm/svm/svm.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 03dd7bac8034..2c6dea48ba62 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -2261,6 +2261,7 @@ static int cr_interception(struct vcpu_svm *svm)
  	if (cr >= 16) { /* mov to cr */
  		cr -= 16;
  		val = kvm_register_read(&svm->vcpu, reg);
+		trace_kvm_cr_write(cr, val);
  		switch (cr) {
  		case 0:
  			if (!check_selective_cr0_intercepted(svm, val))
@@ -2306,6 +2307,7 @@ static int cr_interception(struct vcpu_svm *svm)
  			return 1;
  		}
  		kvm_register_write(&svm->vcpu, reg, val);
+		trace_kvm_cr_read(cr, val);
  	}
  	return kvm_complete_insn_gp(&svm->vcpu, err);
  }
--
2.18.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add tracepoint for cr_interception
  2020-09-04 11:25 [PATCH] KVM: SVM: Add tracepoint for cr_interception Haiwei Li
@ 2020-09-04 12:01 ` Vitaly Kuznetsov
  2020-09-04 12:44   ` Haiwei Li
  2020-09-23  6:24 ` Haiwei Li
  2020-09-24  0:44 ` Wanpeng Li
  2 siblings, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2020-09-04 12:01 UTC (permalink / raw)
  To: Haiwei Li
  Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli,
	sean.j.christopherson, pbonzini, linux-kernel, kvm, x86

Haiwei Li <lihaiwei.kernel@gmail.com> writes:

> From: Haiwei Li <lihaiwei@tencent.com>
>
> Add trace_kvm_cr_write and trace_kvm_cr_read for svm.
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
> ---
>   arch/x86/kvm/svm/svm.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 03dd7bac8034..2c6dea48ba62 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -2261,6 +2261,7 @@ static int cr_interception(struct vcpu_svm *svm)

There are two special cases when we go to emulate_on_interception() and
these won't be logged but I don't think this is a must.

>   	if (cr >= 16) { /* mov to cr */
>   		cr -= 16;
>   		val = kvm_register_read(&svm->vcpu, reg);
> +		trace_kvm_cr_write(cr, val);
>   		switch (cr) {
>   		case 0:
>   			if (!check_selective_cr0_intercepted(svm, val))
> @@ -2306,6 +2307,7 @@ static int cr_interception(struct vcpu_svm *svm)
>   			return 1;
>   		}
>   		kvm_register_write(&svm->vcpu, reg, val);
> +		trace_kvm_cr_read(cr, val);

The 'default:' case above does 'return 1;' so we won't get the trace but
I understand you put trace_kvm_cr_read() here so you can log the
returned 'val', #UD should be clearly visible. 

>   	}
>   	return kvm_complete_insn_gp(&svm->vcpu, err);
>   }
> --
> 2.18.4
>

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add tracepoint for cr_interception
  2020-09-04 12:01 ` Vitaly Kuznetsov
@ 2020-09-04 12:44   ` Haiwei Li
  0 siblings, 0 replies; 5+ messages in thread
From: Haiwei Li @ 2020-09-04 12:44 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli,
	sean.j.christopherson, pbonzini, linux-kernel, kvm, x86



On 20/9/4 20:01, Vitaly Kuznetsov wrote:
> Haiwei Li <lihaiwei.kernel@gmail.com> writes:
> 
>> From: Haiwei Li <lihaiwei@tencent.com>
>>
>> Add trace_kvm_cr_write and trace_kvm_cr_read for svm.
>>
>> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
>> ---
>>    arch/x86/kvm/svm/svm.c | 2 ++
>>    1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
>> index 03dd7bac8034..2c6dea48ba62 100644
>> --- a/arch/x86/kvm/svm/svm.c
>> +++ b/arch/x86/kvm/svm/svm.c
>> @@ -2261,6 +2261,7 @@ static int cr_interception(struct vcpu_svm *svm)
> 
> There are two special cases when we go to emulate_on_interception() and
> these won't be logged but I don't think this is a must.
> 
>>    	if (cr >= 16) { /* mov to cr */
>>    		cr -= 16;
>>    		val = kvm_register_read(&svm->vcpu, reg);
>> +		trace_kvm_cr_write(cr, val);
>>    		switch (cr) {
>>    		case 0:
>>    			if (!check_selective_cr0_intercepted(svm, val))
>> @@ -2306,6 +2307,7 @@ static int cr_interception(struct vcpu_svm *svm)
>>    			return 1;
>>    		}
>>    		kvm_register_write(&svm->vcpu, reg, val);
>> +		trace_kvm_cr_read(cr, val);
> 
> The 'default:' case above does 'return 1;' so we won't get the trace but
> I understand you put trace_kvm_cr_read() here so you can log the
> returned 'val', #UD should be clearly visible.
> 
>>    	}
>>    	return kvm_complete_insn_gp(&svm->vcpu, err);
>>    }
>> --
>> 2.18.4
>>
> 
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Thanks a lot.

> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add tracepoint for cr_interception
  2020-09-04 11:25 [PATCH] KVM: SVM: Add tracepoint for cr_interception Haiwei Li
  2020-09-04 12:01 ` Vitaly Kuznetsov
@ 2020-09-23  6:24 ` Haiwei Li
  2020-09-24  0:44 ` Wanpeng Li
  2 siblings, 0 replies; 5+ messages in thread
From: Haiwei Li @ 2020-09-23  6:24 UTC (permalink / raw)
  To: linux-kernel, kvm, x86
  Cc: hpa, bp, mingo, tglx, joro, jmattson, wanpengli, vkuznets,
	sean.j.christopherson, pbonzini

Kindly ping. :)
On 20/9/4 19:25, Haiwei Li wrote:
> From: Haiwei Li <lihaiwei@tencent.com>
> 
> Add trace_kvm_cr_write and trace_kvm_cr_read for svm.
> 
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
> ---
>   arch/x86/kvm/svm/svm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 03dd7bac8034..2c6dea48ba62 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -2261,6 +2261,7 @@ static int cr_interception(struct vcpu_svm *svm)
>       if (cr >= 16) { /* mov to cr */
>           cr -= 16;
>           val = kvm_register_read(&svm->vcpu, reg);
> +        trace_kvm_cr_write(cr, val);
>           switch (cr) {
>           case 0:
>               if (!check_selective_cr0_intercepted(svm, val))
> @@ -2306,6 +2307,7 @@ static int cr_interception(struct vcpu_svm *svm)
>               return 1;
>           }
>           kvm_register_write(&svm->vcpu, reg, val);
> +        trace_kvm_cr_read(cr, val);
>       }
>       return kvm_complete_insn_gp(&svm->vcpu, err);
>   }
> -- 
> 2.18.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add tracepoint for cr_interception
  2020-09-04 11:25 [PATCH] KVM: SVM: Add tracepoint for cr_interception Haiwei Li
  2020-09-04 12:01 ` Vitaly Kuznetsov
  2020-09-23  6:24 ` Haiwei Li
@ 2020-09-24  0:44 ` Wanpeng Li
  2 siblings, 0 replies; 5+ messages in thread
From: Wanpeng Li @ 2020-09-24  0:44 UTC (permalink / raw)
  To: Haiwei Li
  Cc: linux-kernel, kvm, x86, hpa, bp, mingo, tglx, Joerg Roedel,
	jmattson, wanpengli, Vitaly Kuznetsov, Sean Christopherson,
	pbonzini

On Fri, 4 Sep 2020 at 19:29, Haiwei Li <lihaiwei.kernel@gmail.com> wrote:
>
> From: Haiwei Li <lihaiwei@tencent.com>
>
> Add trace_kvm_cr_write and trace_kvm_cr_read for svm.
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>

Reviewed-by: Wanpeng Li <wanpengli@tencent.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-24  0:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 11:25 [PATCH] KVM: SVM: Add tracepoint for cr_interception Haiwei Li
2020-09-04 12:01 ` Vitaly Kuznetsov
2020-09-04 12:44   ` Haiwei Li
2020-09-23  6:24 ` Haiwei Li
2020-09-24  0:44 ` Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).