From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEBEBC27C4F for ; Wed, 26 Jun 2024 20:29:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E81E26B0085; Wed, 26 Jun 2024 16:29:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E31956B0089; Wed, 26 Jun 2024 16:29:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2246B008C; Wed, 26 Jun 2024 16:29:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AD7DD6B0085 for ; Wed, 26 Jun 2024 16:29:56 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 60E18C168A for ; Wed, 26 Jun 2024 20:29:56 +0000 (UTC) X-FDA: 82274181192.07.9DB6128 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by imf27.hostedemail.com (Postfix) with ESMTP id 3760740016 for ; Wed, 26 Jun 2024 20:29:53 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=yoseli.org header.s=gm1 header.b=MO5BpPV8; dmarc=none; spf=none (imf27.hostedemail.com: domain of jeanmichel.hautbois@yoseli.org has no SPF policy when checking 217.70.183.201) smtp.mailfrom=jeanmichel.hautbois@yoseli.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719433776; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YBpTCEMojCIFuv+8k7YbqxKyVs+I28NmHx1pGxkZja8=; b=Ida5h7pvOVYvxqFcC0cHjtqE5qHq98B/iE3uA/WvI1IdlbHfbsGx82NQ4y+hbX7mr11yh/ NWp7ek0Q1dq/XBed64HBNLLywijyDysIrYERnx3vo8w9euePY43E32rjMSSHxn3KDOd7CQ xhb3b7TbQGS9kmIjEmZpygItdM88DQE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719433776; a=rsa-sha256; cv=none; b=XV5nIYqBep2mArDzJC9SvhnvSx9iyKuswlOUzszp8J2xOoalf1BqsO9Q0vvrdVa8wkF4gm 5wwN+oNQAz1pTjzaDH6Ux01pPKQpkOaeEfRRrodgZKxdfz1RIPRhPg4VOfkImxo7ocdLch jkqKET6+NAC+i8by7p7r6Vf/wlhElrw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=yoseli.org header.s=gm1 header.b=MO5BpPV8; dmarc=none; spf=none (imf27.hostedemail.com: domain of jeanmichel.hautbois@yoseli.org has no SPF policy when checking 217.70.183.201) smtp.mailfrom=jeanmichel.hautbois@yoseli.org Received: by mail.gandi.net (Postfix) with ESMTPSA id 33D2F1BF203; Wed, 26 Jun 2024 20:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yoseli.org; s=gm1; t=1719433792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YBpTCEMojCIFuv+8k7YbqxKyVs+I28NmHx1pGxkZja8=; b=MO5BpPV8foQRuH8isn0BXEJ0EWCr3VNQY8hK3spb0zBTecjY3hg9ot5qnhufpQvqcWW6e7 gTSFnH/BeyXhyjN9Jf7h00O3JNfDxEeA6Z1pXZIqeAPEGXjS7nEkRcESnt70G9ZqCl3V+F GB0MJPwXzGL6ZIPM9J17U+uqz68tq08nyjgUV8agB+T5jrygBgg1WKcY5VgEeFXJFjAIrT KH7DUrBgYV8rBOzRoHKIpU3pEgYqUvOt08psOJ3b+i3PI0wQ3A1gjuZ1B1Lx7uU/VwK+ca a2QklAUBxan16y49vPmkLNAz1FDKrQXC26K/dBuoXaBFY8QIdP3/waPKPRM0FA== Message-ID: Date: Wed, 26 Jun 2024 22:29:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: m68k 54418 fails to execute user space To: Michael Schmitz , linux-m68k@lists.linux-m68k.org, linux-mm@kvack.org, linux-mtd@lists.infradead.org Cc: Greg Ungerer , Geert Uytterhoeven , Christoph Hellwig , wbx@openadk.org References: <735e19b6-3747-417f-ba5b-1a7da137a3a3@yoseli.org> <7fb2988d-ab89-405f-8cf1-edcdd2196376@gmail.com> Content-Language: en-US From: Jean-Michel Hautbois In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Sasl: jeanmichel.hautbois@yoseli.org X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3760740016 X-Stat-Signature: rg5k6twqcgx5mu4s38859xxp1gofr3mx X-Rspam-User: X-HE-Tag: 1719433793-289313 X-HE-Meta: U2FsdGVkX19wwzodMcdxuRskum/V0OWXTDGC8j1l8HjSCN0z6inbwEUVnoPLF/m5aVQkJeUWaXy6blXadXT5NpcMH5aUQkmWyzfTvIYc8Uegug1fn1CzY0nIwoS4ACe5jnFAHX099MCJbLO8F0ndbNmyqMxuwFrtNngquFdfOkyBXYmChLqHdzNv3yYqIewulPsXOV8zDavR36wMYkcFoTFK0cvT43be+lLXs22vmFSkBwYXaN+nV7UhoI18Mhcr6J+r9SWF+YPuermnr/+UmXCpCV7vIyPoiD6jMFsLAicoBYfnxWg9AvhUr4pN8NeCWYAVcvnaz3GDp81LXqyNm1dL9oyOc73AlEWDfGSQn/8Dnnt6n2ncwuSTRfTEVBz+neRDkgPdQCVR6oNXXo58i7UklO3Rdl8uHGxCB634TJhuQTBveEp9KiQELVlpcnM8cSh3OZrbsZLt/T86F6fUCt+uZzvnD8ElXDpbX8oODzHCG0Au9eTMPhGQ2a99HSKgXPVjbkiRWErBrnuVjR3uY+iDP5NGobiH67Bm4dnifyKmCXtvymsuKARIbZdE40BmnKdVIEnTUZ7SDoyUJjw6Dn4dA96ObLoRHuuVAXJ7G9Q24MQYeyoVsbhjKd0YjkeGoTraHsfdET6H0IIrvUPGkcokDnDpl104PNaJ4Fv68Eo8uCvzUI379NJILRcYRLVYpl3mK0McqVBBTigQ68BX1wZ/20AC5rEJsU49qZm/fcw6AB1Z9EzXOz2hUSLHbF4p1R0gtz2Nk+vjzuQ8+LS4XvLtnLrj+60WOUGMAGCZ5aJLcdAHFpsGsBwqsRBtaBBr0QE8+lTjpspzp2wKkSfuJ/5gpQTGRyDxLEg1HY44AkKTAQJ9dpP7aQMmcgM9Bw0Uggmyf9SfUpYtK5NufANlkvEqus4uG+MF2qpuukvWfkiJ5Bbu5hRcX8Xp4mvcEBBRU4S0MwtAsn06zXdgrPH VKSkhKyh NV5arXAuSH7MbDuaElugNkgglP+o6MO69ab+JJVYirYmuHqKLLs3b2yRbytF0RQuTRtn3c0kP54HhwqmVvo2BUrPEyGBL0kGIy9tuMcp9uFGYXxVSq1alHwzlNG+njMoRIvqiJBHn7tLEMzjQAMKNojt4LcMu8OlAE/NB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Michael, On 26/06/2024 21:36, Michael Schmitz wrote: > Jean-Michel, > > On 27/06/24 01:28, Jean-Michel Hautbois wrote: >> Hi Michael, >> >> On 26/06/2024 03:56, Michael Schmitz wrote: >>> Jean-Michel, >>> >>> On 24/06/24 20:56, Jean-Michel Hautbois wrote: >>>> >>>> When I printk the do_page_fault first debug, I get for the first >>>> call to ls: >>>> bash-5.2# ls >>>> [   14.700000] do page fault: >>>> [   14.700000] regs->sr=0x0, regs->pc=0x70069ee6, >>>> address=0x70069ee6, 0, (ptrval) >>> >>> Page not present, read fault. Please disable obfuscation of kernel >>> pointer addresses by printk. Maybe also disable address space >>> randomization while debugging this. >>> >>>> This call works almost fine (I still have the assert failed: >>>> folio->private != NULL issue). >>>> >>>> And when I call it a second time, I get: >>>> bash-5.2# ls >>>> [   19.820000] do page fault: >>>> [   19.820000] regs->sr=0x0, regs->pc=0x6011d65a, >>>> address=0x700e2004, 2, (ptrval) >>> >>> Page not present, write fault. >>> >>> It would be helpful if you could get a dump of /proc/1/maps before >>> the execve() syscall in your helloworld init replacement. That might >>> confirm all these addresses are legit (assuming mappings survive >>> across execve(), that is), and what they correspond to. >>> >>>> >>>> The address corresponds to the defined zone ELF_ET_DYN_BASE as I set >>>> it to 0x70000000. >>>> >>>> regs->pc is not the same as the address. It might be unrelevant, but >>>> any help is appreciated to understand the process behind :-). >>>> >>>> I keep digging, and I am in the asm part which fears me a bit ! >>> >>> I don't see that you'd need to look at any asm code here. >> >> I add a small test in do_page_fault, and in case of an error, it >> panics. The result follows: > > Please take a look at the comments at the start of > arch/m68k/mm/fault.c:do_page_fault(). The meaning of the bits in > error_code are explained there. > > error_code != 0 is just one possible case out of the four that are > handled by do_page_fault(). It does not signify 'no error' - if there > hadn't been a page fault, do_page_fault() would not have been called. > > You just forced a panic each time a write fault and/or a protection > fault happens. Write faults are absolutely expected to happen when > loading a library - ld.so needs to perform relocation after loading a > dynamic library, and that means writes to the GOT in the library's data > segment (PIC assumed). I feel dumb -_- thanks for the explanation (I *knew* that page faults are expected, but as I couldn't not see when it works or not, I kept focus on this silly part). > > >>  ./scripts/decode_stacktrace.sh vmlinux < /tmp/trace.log >> [    3.857000] Run /bin/bash as init process >> [    3.858000]   with arguments: >> [    3.861000]     /bin/bash >> [    3.862000]   with environment: >> [    3.863000]     HOME=/ >> [    3.864000]     TERM=linux >> [    4.242000] do page fault: >> [    4.242000] regs->sr=0x2000, regs->pc=0x41366924, >> address=0x700b3364, 2, 41fb0000 >> [    4.242000] Kernel panic - not syncing: page fault error >> [    4.242000] CPU: 0 PID: 1 Comm: bash Not tainted >> 6.10.0-rc5-g927da6cf01fe-dirty #25 >> [    4.242000] Stack from 4186dda8: >> [    4.242000]         4186dda8 41423aa4 41423aa4 700b3300 00000001 >> 00000000 4136ee10 41423aa4 >> [    4.242000]         41366d7a 700b3364 700b3364 00000000 0000000d >> 4186de60 41fb0000 41d51a60 >> [    4.242000]         41005696 41416a90 41416a4d 00002000 41366924 >> 700b3364 00000002 41fb0000 >> [    4.242000]         0000000a 700b3364 00000000 0000000d 00000012 >> 41d51a00 4186de60 41d51a60 >> [    4.242000]         41fb81c0 41d51a60 410052fe 4100529a 4186de60 >> 700b3364 00000002 00000000 >> [    4.242000]         700bc414 00000003 00008000 700ac000 41003660 >> 4186de60 00000000 00000000 >> [    4.242000] Call Trace: dump_stack (lib/dump_stack.c:124) >> [    4.242000] panic (kernel/panic.c:266 kernel/panic.c:368) >> [    4.242000] do_page_fault (arch/m68k/mm/fault.c:88 (discriminator 1)) >> [    4.242000] __clear_user (arch/m68k/lib/uaccess.c:108) >> [    4.242000] buserr_c (arch/m68k/kernel/traps.c:725 >> arch/m68k/kernel/traps.c:775) >> [    4.242000] buserr_c (arch/m68k/kernel/traps.c:748 >> arch/m68k/kernel/traps.c:775) >> [    4.242000] buserr (arch/m68k/kernel/entry.S:116) >> [    4.242000] ma_slots (lib/maple_tree.c:759) >> [    4.242000] __clear_user (arch/m68k/lib/uaccess.c:108) >> [    4.242000] elf_load (fs/binfmt_elf.c:125 (discriminator 1) >> fs/binfmt_elf.c:421 (discriminator 1)) >> [    4.242000] load_elf_binary (fs/binfmt_elf.c:1132) >> [    4.242000] memset (arch/m68k/lib/memset.c:11) >> [    4.242000] load_misc_binary (fs/binfmt_misc.c:97 >> fs/binfmt_misc.c:146 fs/binfmt_misc.c:213) >> [    4.242000] memset (arch/m68k/lib/memset.c:11) >> [    4.242000] bprm_execve (fs/exec.c:1797 fs/exec.c:1839 >> fs/exec.c:1891 fs/exec.c:1867) >> [    4.242000] copy_strings_kernel (fs/exec.c:669) >> [    4.242000] count_strings_kernel (fs/exec.c:473) >> [    4.242000] kernel_execve (fs/exec.c:2058) >> [    4.242000] __dynamic_pr_debug (lib/dynamic_debug.c:865) >> [    4.242000] run_init_process (init/main.c:1389) >> [    4.242000] _printk (kernel/printk/printk.c:2365) >> [    4.242000] kernel_init (init/main.c:1508) >> [    4.242000] kernel_init (init/main.c:1459) >> [    4.242000] ret_from_kernel_thread (arch/m68k/kernel/entry.S:142) >> [    4.242000] >> [    4.242000] ---[ end Kernel panic - not syncing: page fault error ]--- >> >> Looks like a memory mapping failure, but why ? >> My JTAG at this point dumps a list of 0s at 0x41fb0000 and my SDRAM >> starts at 0x40000000 and ends at 0x50000000 (256MB). > 0x41fb0000 seems to be init's page directory. The fault address is in > the range where I'd expect dynamic libraries to reside. How can I check it is init's page directory ? >> >> It looks like a TLB write miss which is obscure to me :-). >> >> I tried to use the /proc but as expected it is not alive after >> mounting it. > > The memory map ought to be accessible through sysrq - an alternative > would be to modify the ELF binfmt handler and dump the map once ld.so > has finished with relocations. I can use sysrq but AFAIK I can show the memory info, not the memory map ? Modifying the ELF binfmt handler might be doable... JM > > Cheers, > >     Michael > > >> Thanks, >> JM >> >> >>> Cheers, >>> >>>      Michael >>> >>>> >>>> Thanks ! >>>> JM