* [PATCH] KVM: SVM: Fix "error" isn't initialized
@ 2019-11-27 3:05 Haiwei Li
0 siblings, 0 replies; 5+ messages in thread
From: Haiwei Li @ 2019-11-27 3:05 UTC (permalink / raw)
To: linux-kernel, kvm, x86
Cc: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa
From d32ebcf6f426385942fe6c469255e73188cd7d38 Mon Sep 17 00:00:00 2001
From: Haiwei Li <lihaiwei@tencent.com>
Date: Wed, 27 Nov 2019 11:03:21 +0800
Subject: [PATCH] initialize 'error'
There are a bunch of error paths were "error" isn't initialized.
Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
arch/x86/kvm/svm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 362e874..0b3d49c 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6294,7 +6294,8 @@ static int enable_smi_window(struct kvm_vcpu *vcpu)
static int sev_flush_asids(void)
{
- int ret, error;
+ int ret;
+ int error = 0;
/*
* DEACTIVATE will clear the WBINVD indicator causing DF_FLUSH to fail,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: SVM: Fix "error" isn't initialized
@ 2019-11-27 3:30 linmiaohe
2019-11-27 3:44 ` Sean Christopherson
0 siblings, 1 reply; 5+ messages in thread
From: linmiaohe @ 2019-11-27 3:30 UTC (permalink / raw)
To: Haiwei Li, linux-kernel, kvm, x86
Cc: pbonzini, rkrcmar, sean.j.christopherson, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa
> From: Haiwei Li <lihaiwei@tencent.com>
> Subject: [PATCH] initialize 'error'
>
> There are a bunch of error paths were "error" isn't initialized.
Hi,
In case error case, sev_guest_df_flush() do not set the error.
Can you set the value of error to reflect what error happened
in sev_guest_df_flush()?
The current fix may looks confused when print "DF_FLUSH failed" with
error = 0.
Thanks.
PS: This is just my personal point.
>
> Signed-off-by: Haiwei Li <lihaiwei@tencent.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>--- a/arch/x86/kvm/svm.c
>+++ b/arch/x86/kvm/svm.c
>@@ -6294,7 +6294,8 @@ static int enable_smi_window(struct kvm_vcpu *vcpu)
>
> static int sev_flush_asids(void)
> {
>- int ret, error;
>+ int ret;
>+ int error = 0;
>
> /*
> * DEACTIVATE will clear the WBINVD indicator causing DF_FLUSH to fail,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: SVM: Fix "error" isn't initialized
2019-11-27 3:30 linmiaohe
@ 2019-11-27 3:44 ` Sean Christopherson
2019-11-27 5:38 ` Haiwei Li
0 siblings, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2019-11-27 3:44 UTC (permalink / raw)
To: linmiaohe
Cc: Haiwei Li, linux-kernel, kvm, x86, pbonzini, rkrcmar, vkuznets,
wanpengli, jmattson, joro, tglx, mingo, bp, hpa
On Wed, Nov 27, 2019 at 03:30:06AM +0000, linmiaohe wrote:
>
> > From: Haiwei Li <lihaiwei@tencent.com>
> > Subject: [PATCH] initialize 'error'
> >
> > There are a bunch of error paths were "error" isn't initialized.
> Hi,
> In case error case, sev_guest_df_flush() do not set the error.
> Can you set the value of error to reflect what error happened
> in sev_guest_df_flush()?
> The current fix may looks confused when print "DF_FLUSH failed" with
> error = 0.
> Thanks.
>
> PS: This is just my personal point.
Disclaimer: not my world at all...
Based on the prototype for __sev_do_cmd_locked(), @error is intended to be
filled only if there's an actual response from the PSP, which is a 16-bit
value. So maybe init @psp_ret at the beginning of __sev_do_cmd_locked() to
-1 to indicate the command was never sent to the PSP? And update the
pr_err() in sev_asid_flush() to explicitly state it's the PSP return?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: SVM: Fix "error" isn't initialized
2019-11-27 3:44 ` Sean Christopherson
@ 2019-11-27 5:38 ` Haiwei Li
0 siblings, 0 replies; 5+ messages in thread
From: Haiwei Li @ 2019-11-27 5:38 UTC (permalink / raw)
To: Sean Christopherson, linmiaohe
Cc: linux-kernel, kvm, x86, pbonzini, rkrcmar, vkuznets, wanpengli,
jmattson, joro, tglx, mingo, bp, hpa
On 2019/11/27 11:44, Sean Christopherson wrote:
> On Wed, Nov 27, 2019 at 03:30:06AM +0000, linmiaohe wrote:
>>
>>> From: Haiwei Li <lihaiwei@tencent.com>
>>> Subject: [PATCH] initialize 'error'
>>>
>>> There are a bunch of error paths were "error" isn't initialized.
>> Hi,
>> In case error case, sev_guest_df_flush() do not set the error.
>> Can you set the value of error to reflect what error happened
>> in sev_guest_df_flush()?
>> The current fix may looks confused when print "DF_FLUSH failed" with
>> error = 0.
>> Thanks.
>>
>> PS: This is just my personal point.
>
> Disclaimer: not my world at all...
>
> Based on the prototype for __sev_do_cmd_locked(), @error is intended to be
> filled only if there's an actual response from the PSP, which is a 16-bit
> value. So maybe init @psp_ret at the beginning of __sev_do_cmd_locked() to
> -1 to indicate the command was never sent to the PSP? And update the
> pr_err() in sev_asid_flush() to explicitly state it's the PSP return?
>
Thanks for your advise. Good point. I will send a new patch.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: SVM: Fix "error" isn't initialized
@ 2019-11-27 6:28 linmiaohe
0 siblings, 0 replies; 5+ messages in thread
From: linmiaohe @ 2019-11-27 6:28 UTC (permalink / raw)
To: Sean Christopherson
Cc: Haiwei Li, linux-kernel, kvm, x86, pbonzini, rkrcmar, vkuznets,
wanpengli, jmattson, joro, tglx, mingo, bp, hpa
On 2019/11/27 11:44, Sean Christopherson wrote:
> On Wed, Nov 27, 2019 at 03:30:06AM +0000, linmiaohe wrote:
>>
>>> From: Haiwei Li <lihaiwei@tencent.com>
>>> Subject: [PATCH] initialize 'error'
>>>
>>> There are a bunch of error paths were "error" isn't initialized.
>> Hi,
>> In case error case, sev_guest_df_flush() do not set the error.
>> Can you set the value of error to reflect what error happened in
>> sev_guest_df_flush()?
>> The current fix may looks confused when print "DF_FLUSH failed" with
>> error = 0.
>> Thanks.
>>
>> PS: This is just my personal point.
>
> Disclaimer: not my world at all...
>
> Based on the prototype for __sev_do_cmd_locked(), @error is intended
> to be filled only if there's an actual response from the PSP, which is
> a 16-bit value. So maybe init @psp_ret at the beginning of
> __sev_do_cmd_locked() to
> -1 to indicate the command was never sent to the PSP? And update the
> pr_err() in sev_asid_flush() to explicitly state it's the PSP return?
>
I think it's a good alternative. Many Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-27 6:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-27 3:05 [PATCH] KVM: SVM: Fix "error" isn't initialized Haiwei Li
2019-11-27 3:30 linmiaohe
2019-11-27 3:44 ` Sean Christopherson
2019-11-27 5:38 ` Haiwei Li
2019-11-27 6:28 linmiaohe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.