Message ID | 20190114174703.17844-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | mtrr: fix incorrect mask on amd_sys_conf | expand |
On 2019-01-14 9:47 a.m., Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Currently the check (amd_sys_conf | 0x200000) is always true as or'ing > anything with a non-zero leads to a non-zero (true) result. Fix this by > using an 'and' to perform the masking as was intended. > > Fixes: 9e3c4bfc050d ("mtrr: check memory type above 4GB on AMD platforms") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/bios/mtrr/mtrr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c > index 453dc57b..b2576bf0 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -193,7 +193,7 @@ static int get_default_mtrr(fwts_framework *fw) > */ > if (strstr(fwts_cpuinfo->vendor_id, "AMD")) { > if (fwts_cpu_readmsr(fw, 0, AMD_SYS_CFG_MSR, &amd_sys_conf) == FWTS_OK) > - if (amd_sys_conf | 0x200000) > + if (amd_sys_conf & 0x200000) > amd_Tom2ForceMemTypeWB = true; > } > > Thanks. That was a silly mistake. Acked-by: Alex Hung <alex.hung@canonical.com>
On 14/01/2019 20:08, Alex Hung wrote: > On 2019-01-14 9:47 a.m., Colin King wrote: >> From: Colin Ian King <colin.king@canonical.com> >> >> Currently the check (amd_sys_conf | 0x200000) is always true as or'ing >> anything with a non-zero leads to a non-zero (true) result. Fix this by >> using an 'and' to perform the masking as was intended. >> >> Fixes: 9e3c4bfc050d ("mtrr: check memory type above 4GB on AMD platforms") >> Signed-off-by: Colin Ian King <colin.king@canonical.com> >> --- >> src/bios/mtrr/mtrr.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c >> index 453dc57b..b2576bf0 100644 >> --- a/src/bios/mtrr/mtrr.c >> +++ b/src/bios/mtrr/mtrr.c >> @@ -193,7 +193,7 @@ static int get_default_mtrr(fwts_framework *fw) >> */ >> if (strstr(fwts_cpuinfo->vendor_id, "AMD")) { >> if (fwts_cpu_readmsr(fw, 0, AMD_SYS_CFG_MSR, &amd_sys_conf) == FWTS_OK) >> - if (amd_sys_conf | 0x200000) >> + if (amd_sys_conf & 0x200000) >> amd_Tom2ForceMemTypeWB = true; >> } >> >> > > Thanks. That was a silly mistake. I should have spotted it when reviewing it. Fortunately the static analyzers are rather good and spotting these kind of issues. Colin > > Acked-by: Alex Hung <alex.hung@canonical.com> >
On 1/15/19 1:47 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Currently the check (amd_sys_conf | 0x200000) is always true as or'ing > anything with a non-zero leads to a non-zero (true) result. Fix this by > using an 'and' to perform the masking as was intended. > > Fixes: 9e3c4bfc050d ("mtrr: check memory type above 4GB on AMD platforms") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > src/bios/mtrr/mtrr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c > index 453dc57b..b2576bf0 100644 > --- a/src/bios/mtrr/mtrr.c > +++ b/src/bios/mtrr/mtrr.c > @@ -193,7 +193,7 @@ static int get_default_mtrr(fwts_framework *fw) > */ > if (strstr(fwts_cpuinfo->vendor_id, "AMD")) { > if (fwts_cpu_readmsr(fw, 0, AMD_SYS_CFG_MSR, &amd_sys_conf) == FWTS_OK) > - if (amd_sys_conf | 0x200000) > + if (amd_sys_conf & 0x200000) > amd_Tom2ForceMemTypeWB = true; > } > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index 453dc57b..b2576bf0 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -193,7 +193,7 @@ static int get_default_mtrr(fwts_framework *fw) */ if (strstr(fwts_cpuinfo->vendor_id, "AMD")) { if (fwts_cpu_readmsr(fw, 0, AMD_SYS_CFG_MSR, &amd_sys_conf) == FWTS_OK) - if (amd_sys_conf | 0x200000) + if (amd_sys_conf & 0x200000) amd_Tom2ForceMemTypeWB = true; }