x86: kvm/paging_tmpl.h intialize the variable before using it
PATCH 1/1 x86: kvm/paging_tmpl.h intialize the variable before using it
May be in some cases paging64_fetch() and paging32_fetch() will return sptep without initialization.
Also fixes compilation warning:
CC arch/x86/kernel/io_delay.o
arch/x86/kvm/paging_tmpl.h: In function ‘paging64_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this function arch/x86/kvm/paging_tmpl.h: In function ‘paging32_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this function
--- arch/x86/kvm/paging_tmpl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kvm/paging_tmpl.h +1 -1
@@ -276,7 +276,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, {unsigned access = gw->pt_access;struct kvm_mmu_page *shadow_page; -u64 spte, *sptep; +u64 spte, *sptep =NULL ;int direct;gfn_t table_gfn;int r;
Signature · 1 line
1.6.1.1
Quoted 21 lines · Jaswinder Singh Rajput
May be in some cases
paging64_fetch()andpaging32_fetch()will return sptep without initialization.Also fixes compilation warning:
CCarch/x86/kernel/io_delay.o
arch/x86/kvm/paging_tmpl.h: In function ‘paging64_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionarch/x86/kvm/paging_tmpl.h: In function ‘paging32_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionSigned-off-by Jaswinder Singh Rajput <[email protected]>--- arch/x86/kvm/paging_tmpl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/x86/kvm/paging_tmpl.h +0
-0
arch/x86/kvm/paging_tmpl.h static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, · line 282
Quoted 8 lines
arch/x86/kvm/paging_tmpl.h +1
-1@@ -276,7 +276,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, {unsigned access = gw->pt_access;struct kvm_mmu_page *shadow_page; -u64 spte, *sptep; +u64 spte, *sptep =NULL ;int direct;gfn_t table_gfn;int r;
It's a false alarm. Isn't there a macro to shut up the warning?
Signature · 1 line
error compiling committee.c: too many arguments to function
Hello Avi,
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Jaswinder Singh Rajput
May be in some cases
paging64_fetch()andpaging32_fetch()will return sptep without initialization.Also fixes compilation warning:
CCarch/x86/kernel/io_delay.o
arch/x86/kvm/paging_tmpl.h: In function ‘paging64_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionarch/x86/kvm/paging_tmpl.h: In function ‘paging32_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionSigned-off-by Jaswinder Singh Rajput <[email protected]>--- arch/x86/kvm/paging_tmpl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 17 lines
Quoted 6 lines
arch/x86/kvm/paging_tmpl.h +0
-0arch/x86/kvm/paging_tmpl.h static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, · line 282
Quoted 8 lines
arch/x86/kvm/paging_tmpl.h +1
-1@@ -276,7 +276,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, {unsigned access = gw->pt_access;struct kvm_mmu_page *shadow_page; -u64 spte, *sptep; +u64 spte, *sptep =NULL ;int direct;gfn_t table_gfn;int r;It's a false alarm. Isn't there a macro to shut up the warning?
In arch/x86/kvm/paging_tmpl.h sptep is initialize only in :
for_each_shadow_entry(vcpu, addr, iterator) {
If we skip this, then we end up with wild sptep and returning it.
Do you still think it is a false alarm ?
--
JSR
Quoted 4 lines · Jaswinder Singh Rajput
Quoted 3 lines
It's a false alarm. Isn't there a macro to shut up the warning?
Quoted 8 lines
In
arch/x86/kvm/paging_tmpl.hsptep is initialize only in :
for_each_shadow_entry(vcpu, addr, iterator){If we skip this, then we end up with wild sptep and returning it.
Do you still think it is a false alarm ?
That loop always has at least one iteration.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 7 lines · Avi Kivity
Quoted 6 lines · Jaswinder Singh Rajput
Quoted 3 lines
It's a false alarm. Isn't there a macro to shut up the warning?
In
arch/x86/kvm/paging_tmpl.hsptep is initialize only in :
Quoted 9 lines
Quoted 6 lines
for_each_shadow_entry(vcpu, addr, iterator){If we skip this, then we end up with wild sptep and returning it.
Do you still think it is a false alarm ?
That loop always has at least one iteration.
hmm, In that case we should use a do-while flavor function so that the compiler will also happy with it.
--
JSR
Quoted 6 lines · Jaswinder Singh Rajput
Quoted 2 lines
That loop always has at least one iteration.
hmm, In that case we should use a do-while flavor function so that the compiler will also happy with it.
My own happiness requires that the loop not be rewritten.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
Quoted 16 lines · Avi Kivity
Quoted 15 lines · Jaswinder Singh Rajput
May be in some cases
paging64_fetch()andpaging32_fetch()will return sptep without initialization.Also fixes compilation warning:
CCarch/x86/kernel/io_delay.o
arch/x86/kvm/paging_tmpl.h: In function ‘paging64_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionarch/x86/kvm/paging_tmpl.h: In function ‘paging32_fetch’:
arch/x86/kvm/paging_tmpl.h:279: warning: ‘sptep’ may be used uninitialized in this functionSigned-off-by Jaswinder Singh Rajput <[email protected]>--- arch/x86/kvm/paging_tmpl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 16 lines
Quoted 6 lines
arch/x86/kvm/paging_tmpl.h +0
-0arch/x86/kvm/paging_tmpl.h static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, · line 282
Quoted 8 lines
arch/x86/kvm/paging_tmpl.h +1
-1@@ -276,7 +276,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, {unsigned access = gw->pt_access;struct kvm_mmu_page *shadow_page; -u64 spte, *sptep; +u64 spte, *sptep =NULL ;int direct;gfn_t table_gfn;int r;It's a false alarm. Isn't there a macro to shut up the warning?
there's uninitialized_var(), but that will shut up the warning and any _correct_ future warning - so it's dangerous. Initialize it to NULL and be done with it? We dont want stray warnings in the kernel.
Ingo
Quoted 5 lines · Ingo Molnar
Quoted 2 lines
It's a false alarm. Isn't there a macro to shut up the warning?
there's
uninitialized_var(), but that will shut up the warning and any _correct_ future warning - so it's dangerous. Initialize it to NULL and be done with it? We dont want stray warnings in the kernel.
Makes sense, so I've applied the patch.
Signature · 1 line
error compiling committee.c: too many arguments to function