linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] powerpc: implement CONFIG_DEBUG_VIRTUAL
Date: Wed, 19 Dec 2018 11:26:00 +1100	[thread overview]
Message-ID: <87a7l2s6p3.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <87y38nrkto.fsf@concordia.ellerman.id.au>

Michael Ellerman <mpe@ellerman.id.au> writes:
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> This patch implements CONFIG_DEBUG_VIRTUAL to warn about
>> incorrect use of virt_to_phys() and page_to_phys()
>
> This commit is breaking my p5020ds booting a 32-bit kernel with:
>
>   smp: Bringing up secondary CPUs ...
>   __ioremap(): phys addr 0x7fef5000 is RAM lr ioremap_coherent
>   Unable to handle kernel paging request for data at address 0x00000000
>   Faulting instruction address: 0xc002e950
>   Oops: Kernel access of bad area, sig: 11 [#1]
>   BE SMP NR_CPUS=24 CoreNet Generic
>   Modules linked in:
>   CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.20.0-rc2-gcc-7.0.1-00138-g9a0380d299e9 #148
>   NIP:  c002e950 LR: c002eb20 CTR: 00000001
>   REGS: e804bd20 TRAP: 0300   Not tainted  (4.20.0-rc2-gcc-7.0.1-00138-g9a0380d299e9)
>   MSR:  00021002 <CE,ME>  CR: 28004222  XER: 00000000
>   DEAR: 00000000 ESR: 00000000 
>   GPR00: c002eb20 e804bdd0 e8050000 00000000 00021002 00000000 00000050 00021002 
>   GPR08: 2d3f0000 00000001 00000000 00000004 24000842 00000000 c00026d0 00000000 
>   GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001 
>   GPR24: 00029002 7fef5140 30000000 00000000 00000000 00000040 00000001 00000000 
>   NIP [c002e950] smp_85xx_kick_cpu+0x120/0x410
>   LR [c002eb20] smp_85xx_kick_cpu+0x2f0/0x410
>   Call Trace:
>   [e804bdd0] [c002eb20] smp_85xx_kick_cpu+0x2f0/0x410 (unreliable)
>   [e804be20] [c0012e38] __cpu_up+0xc8/0x230
>   [e804be50] [c0040b34] bringup_cpu+0x34/0x110
>   [e804be70] [c00418a8] cpu_up+0x128/0x250
>   [e804beb0] [c0b84b14] smp_init+0xc4/0x10c
>   [e804bee0] [c0b75c1c] kernel_init_freeable+0xc8/0x250
>   [e804bf20] [c00026e8] kernel_init+0x18/0x120
>   [e804bf40] [c0011298] ret_from_kernel_thread+0x14/0x1c
>   Instruction dump:
>   7fb3e850 57bdd1be 2e1d0000 41d20250 57bd3032 393dffc0 7e6a9b78 5529d1be 
>   39290001 7d2903a6 60000000 60000000 <7c0050ac> 394a0040 4200fff8 7c0004ac 
>   ---[ end trace edcab2a1dfd5b38c ]---
>
>
> Which is obviously this hunk:
>
>> diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
>> index 4fc77a99c9bf..68d204a45cd0 100644
>> --- a/arch/powerpc/mm/pgtable_32.c
>> +++ b/arch/powerpc/mm/pgtable_32.c
>> @@ -143,7 +143,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, pgprot_t prot, void *call
>>  	 * Don't allow anybody to remap normal RAM that we're using.
>>  	 * mem_init() sets high_memory so only do the check after that.
>>  	 */
>> -	if (slab_is_available() && (p < virt_to_phys(high_memory)) &&
>> +	if (slab_is_available() && virt_addr_valid(p) &&
>>  	    page_is_ram(__phys_to_pfn(p))) {
>>  		printk("__ioremap(): phys addr 0x%llx is RAM lr %ps\n",
>>  		       (unsigned long long)p, __builtin_return_address(0));
>
>
> I'll try and come up with a fix tomorrow.

Actually I think that change is just wrong. virt_addr_valid() takes a
virtual address, but p is a physical address.

So I'll drop this hunk for now, which makes the patch a no-op when
DEBUG_VIRTUAL is n which is probably the way it should be.

cheers

  reply	other threads:[~2018-12-19  0:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 22:40 [PATCH v3] powerpc: implement CONFIG_DEBUG_VIRTUAL Christophe Leroy
2018-12-12  0:23 ` Michael Ellerman
2018-12-12  7:19   ` Christophe Leroy
2018-12-12 10:35     ` Michael Ellerman
2018-12-18 14:06 ` Michael Ellerman
2018-12-19  0:26   ` Michael Ellerman [this message]
2018-12-19  6:57     ` Christophe Leroy
2018-12-19  7:03       ` Christophe Leroy
2018-12-19  8:04         ` Michael Ellerman
2018-12-22  9:54 ` [v3] " Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a7l2s6p3.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=benh@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).