Patchwork cpu: virt: correctly return true if SVM is enabled

login
register
mail settings
Submitter Colin King
Date May 7, 2013, 8:52 a.m.
Message ID <1367916756-17957-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/242083/
State Accepted
Headers show

Comments

Colin King - May 7, 2013, 8:52 a.m.
From: Colin Ian King <colin.king@canonical.com>

Coverity CID #997308: Operands don't affect result

The test for the SVM bit should be checking to see if the result
of the mask is set and returning 1 if so.  This is a bug inherited
from the Linux ready firmware kit.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/cpu/virt/virt_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - May 9, 2013, 5:38 a.m.
On 05/07/2013 04:52 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997308: Operands don't affect result
>
> The test for the SVM bit should be checking to see if the result
> of the mask is set and returning 1 if so.  This is a bug inherited
> from the Linux ready firmware kit.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/cpu/virt/virt_svm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/cpu/virt/virt_svm.c b/src/cpu/virt/virt_svm.c
> index ceba8b6..9b618fd 100644
> --- a/src/cpu/virt/virt_svm.c
> +++ b/src/cpu/virt/virt_svm.c
> @@ -61,7 +61,7 @@ static int vt_locked_by_bios(void)
>   	if (fwts_cpu_readmsr(0, MSR_FEATURE_CONTROL, &msr))
>   		return -1;
>
> -	return ((msr & 0x1000) == 1); /* SVM capable but locked by bios*/
> +	return ((msr & 0x1000) == 0x1000); /* SVM capable but locked by bios*/
>   }
>
>   void virt_check_svm(fwts_framework *fw)
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - May 20, 2013, 7:34 a.m.
On Tue, May 7, 2013 at 4:52 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Coverity CID #997308: Operands don't affect result
>
> The test for the SVM bit should be checking to see if the result
> of the mask is set and returning 1 if so.  This is a bug inherited
> from the Linux ready firmware kit.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/cpu/virt/virt_svm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/cpu/virt/virt_svm.c b/src/cpu/virt/virt_svm.c
> index ceba8b6..9b618fd 100644
> --- a/src/cpu/virt/virt_svm.c
> +++ b/src/cpu/virt/virt_svm.c
> @@ -61,7 +61,7 @@ static int vt_locked_by_bios(void)
>         if (fwts_cpu_readmsr(0, MSR_FEATURE_CONTROL, &msr))
>                 return -1;
>
> -       return ((msr & 0x1000) == 1); /* SVM capable but locked by bios*/
> +       return ((msr & 0x1000) == 0x1000); /* SVM capable but locked by bios*/
>  }
>
>  void virt_check_svm(fwts_framework *fw)
> --
> 1.8.1.2
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>>

Patch

diff --git a/src/cpu/virt/virt_svm.c b/src/cpu/virt/virt_svm.c
index ceba8b6..9b618fd 100644
--- a/src/cpu/virt/virt_svm.c
+++ b/src/cpu/virt/virt_svm.c
@@ -61,7 +61,7 @@  static int vt_locked_by_bios(void)
 	if (fwts_cpu_readmsr(0, MSR_FEATURE_CONTROL, &msr))
 		return -1;
 
-	return ((msr & 0x1000) == 1); /* SVM capable but locked by bios*/
+	return ((msr & 0x1000) == 0x1000); /* SVM capable but locked by bios*/
 }
 
 void virt_check_svm(fwts_framework *fw)