Skip to contentSkip to conversation

KVM: SVM: Fix "error" isn't initialized

PATCH linmiaohe 3 participants 3 messages Nov 27, 2019 KVM

lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 5 lines

From: Haiwei Li <[email protected]>
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.

Quoted 15 lines
arch/x86/kvm/svm.c +2 -1
@@ -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 lore raw
Quoted 13 lines · linmiaohe
Quoted 5 lines

From: Haiwei Li <[email protected]>
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.

Quoted 1 line

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?

#2 lore raw
Quoted 16 lines · Sean Christopherson
Quoted 13 lines · linmiaohe
Quoted 5 lines

From: Haiwei Li <[email protected]>
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.

Quoted 1 line

PS: This is just my personal point.

Quoted 8 lines

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.