From: Andrew Cooper Date: Thu, 15 Apr 2021 01:03:00 +0000 (+0100) Subject: various: Fix scan-build deadcode.DeadStores issues X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8b9b625d0bb309f2771c290033114dcbbcec3434;p=xtf.git various: Fix scan-build deadcode.DeadStores issues Scan-build complains: main.c:164:15: warning: Although the value stored to 'cr4' is used in the enclosing expression, the value is never actually read from 'cr4' [deadcode.DeadStores] write_cr4(cr4 &= ~X86_CR4_DE); ^ ~~~~~~~~~~~ Rework all impacted logic avoid dead stores of this form. Signed-off-by: Andrew Cooper --- diff --git a/tests/debug-regs/main.c b/tests/debug-regs/main.c index 9d4b74e..19c8889 100644 --- a/tests/debug-regs/main.c +++ b/tests/debug-regs/main.c @@ -138,7 +138,7 @@ static void test_pv_dr7_io_breakpoints(void) printk("Test PV %%dr7 IO breakpoints\n"); if ( !(cr4 & X86_CR4_DE) ) - write_cr4(cr4 |= X86_CR4_DE); + write_cr4(cr4 | X86_CR4_DE); /* Active IO breakpoint in %dr0. */ io0 = DR7_SYM(0, G, IO, 32) | X86_DR7_GE | X86_DR7_DEFAULT; @@ -161,7 +161,7 @@ static void test_pv_dr7_io_breakpoints(void) write_dr7(io0); /* Clear %cr4.de, after which IO breakpoints are invalid. */ - write_cr4(cr4 &= ~X86_CR4_DE); + write_cr4(cr4); /* Attempt to reload an IO breakpoint in %dr0, which should fail ... */ exinfo_t fault = 0; diff --git a/tests/nested-vmx/vmxon.c b/tests/nested-vmx/vmxon.c index 74b1182..e101288 100644 --- a/tests/nested-vmx/vmxon.c +++ b/tests/nested-vmx/vmxon.c @@ -181,7 +181,7 @@ void test_vmxon(void) test_vmxon_novmxe(); test_vmxon_novmxe_in_user(); - write_cr4(cr4 |= X86_CR4_VMXE); + write_cr4(cr4 | X86_CR4_VMXE); test_vmxon_in_user(); test_vmxon_overly_wide_paddr(); diff --git a/tests/pv-fsgsbase/main.c b/tests/pv-fsgsbase/main.c index d354238..de966c9 100644 --- a/tests/pv-fsgsbase/main.c +++ b/tests/pv-fsgsbase/main.c @@ -174,7 +174,9 @@ void test_main(void) { xtf_failure("Fail: Initial CR4.FSGSBASE state should be clear\n"); - if ( pv_write_cr4_safe(cr4 &= ~X86_CR4_FSGSBASE) ) + /* Try turning CR4.FSGSBASE off, to continue the test. */ + cr4 &= ~X86_CR4_FSGSBASE; + if ( pv_write_cr4_safe(cr4) ) return xtf_failure("Fail: Fault while trying to clear CR4.FSGSBASE\n"); } @@ -187,14 +189,14 @@ void test_main(void) if ( !cpu_has_fsgsbase ) { /* If the FSGSBASE feature isn't visible, check we can't turn it on. */ - if ( !pv_write_cr4_safe(cr4 |= X86_CR4_FSGSBASE) ) + if ( !pv_write_cr4_safe(cr4 | X86_CR4_FSGSBASE) ) xtf_failure("Fail: Able to set CR4.FSGSBASE without the feature\n"); return; } /* Check we can turn CR4.FSGSBASE on. */ - if ( pv_write_cr4_safe(cr4 |= X86_CR4_FSGSBASE) ) + if ( pv_write_cr4_safe(cr4 | X86_CR4_FSGSBASE) ) xtf_failure("Fail: Unable to enable CR4.FSGSBASE\n"); /* Check that {RD,WR}{FS,GS}BASE instructions are enabled. */ @@ -204,7 +206,7 @@ void test_main(void) test_wrfsbase_values(); /* Check we can turn CR4.FSGSBASE off again. */ - if ( pv_write_cr4_safe(cr4 &= ~X86_CR4_FSGSBASE) ) + if ( pv_write_cr4_safe(cr4) ) xtf_failure("Fail: Unable to enable CR4.FSGSBASE\n"); /* Check that {RD,WR}{FS,GS}BASE instructions are disabled again. */ diff --git a/tests/xsa-269/main.c b/tests/xsa-269/main.c index d633d50..164a602 100644 --- a/tests/xsa-269/main.c +++ b/tests/xsa-269/main.c @@ -43,7 +43,7 @@ void test_main(void) */ wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_TR); wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_BTS); - wrmsr_safe(MSR_DEBUGCTL, val |= DEBUGCTL_BTINT); + wrmsr_safe(MSR_DEBUGCTL, val | DEBUGCTL_BTINT); /* * If we're still alive, generate a billion jumps to check that BTS really