* [PATCH] ARM: KVM: fix warning in mmu.c
@ 2014-02-05 19:58 Marc Zyngier
2014-02-07 3:51 ` Christoffer Dall
0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2014-02-05 19:58 UTC (permalink / raw)
To: linux-arm-kernel
Compiling with THP enabled leads to the following warning:
arch/arm/kvm/mmu.c: In function ?unmap_range?:
arch/arm/kvm/mmu.c:177:39: warning: ?pte? may be used uninitialized in this function [-Wmaybe-uninitialized]
if (kvm_pmd_huge(*pmd) || page_empty(pte)) {
^
Code inspection reveals that these two cases are mutually exclusive,
so GCC is a bit overzealous here. But silence it anyway by setting
pte to NULL if kvm_pmd_huge(*pmd) is true.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/kvm/mmu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index ea21b6a..3020221 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -169,12 +169,14 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
pte = pte_offset_kernel(pmd, addr);
clear_pte_entry(kvm, pte, addr);
next = addr + PAGE_SIZE;
+ } else {
+ pte = NULL;
}
/*
* If the pmd entry is to be cleared, walk back up the ladder
*/
- if (kvm_pmd_huge(*pmd) || page_empty(pte)) {
+ if (kvm_pmd_huge(*pmd) || (pte && page_empty(pte))) {
clear_pmd_entry(kvm, pmd, addr);
next = pmd_addr_end(addr, end);
if (page_empty(pmd) && !page_empty(pud)) {
--
1.8.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] ARM: KVM: fix warning in mmu.c
2014-02-05 19:58 [PATCH] ARM: KVM: fix warning in mmu.c Marc Zyngier
@ 2014-02-07 3:51 ` Christoffer Dall
0 siblings, 0 replies; 2+ messages in thread
From: Christoffer Dall @ 2014-02-07 3:51 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Feb 05, 2014 at 07:58:25PM +0000, Marc Zyngier wrote:
> Compiling with THP enabled leads to the following warning:
>
> arch/arm/kvm/mmu.c: In function ?unmap_range?:
> arch/arm/kvm/mmu.c:177:39: warning: ?pte? may be used uninitialized in this function [-Wmaybe-uninitialized]
> if (kvm_pmd_huge(*pmd) || page_empty(pte)) {
> ^
> Code inspection reveals that these two cases are mutually exclusive,
> so GCC is a bit overzealous here. But silence it anyway by setting
> pte to NULL if kvm_pmd_huge(*pmd) is true.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
> arch/arm/kvm/mmu.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
> index ea21b6a..3020221 100644
> --- a/arch/arm/kvm/mmu.c
> +++ b/arch/arm/kvm/mmu.c
> @@ -169,12 +169,14 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
> pte = pte_offset_kernel(pmd, addr);
> clear_pte_entry(kvm, pte, addr);
> next = addr + PAGE_SIZE;
> + } else {
> + pte = NULL;
> }
If it's just for the compiler, how about just setting pte = NULL when
pte is declared in the top of the function as to not interrupt the flow?
-Christoffer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-07 3:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-05 19:58 [PATCH] ARM: KVM: fix warning in mmu.c Marc Zyngier
2014-02-07 3:51 ` Christoffer Dall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).