* Re: TASK_SIZE for !MMU [not found] <20140429100028.GH28564@pengutronix.de> @ 2014-06-02 8:51 ` Uwe Kleine-König 2014-06-03 12:14 ` Greg Ungerer 0 siblings, 1 reply; 5+ messages in thread From: Uwe Kleine-König @ 2014-06-02 8:51 UTC (permalink / raw) To: Rabin Vincent, Will Deacon, linux-arm-kernel Cc: David Howells, uclinux-dist-devel, linux-m68k, linux-c6x-dev, linux-m32r, microblaze-uclinux, linux-xtensa, kernel, Andrew Morton, linux-mm, linux-kernel Hello [expand Cc: a bit] On Tue, Apr 29, 2014 at 12:00:28PM +0200, Uwe Kleine-Konig wrote: > I grepped through the kernel (v3.15-rc1) for usages of TASK_SIZE to > check if/how it is used on !MMU ARM machines. Most open questions also > affect the other !MMU platforms, so I put the blackfin, c6x, frv and > m32r, m68k, microblaze and xtensa lists on Cc:. (Did I miss a platform > that cares for !MMU ?) > > Most occurences are fine, see the list at the end of this mail. However > some are not or are unclear to me. Here is the complete list[1] apart from > the definition of TASK_SIZE for !MMU in arch/arm/include/asm/memory.h: > > - Probably this should be explict s/TASK_SIZE/CONFIG_DRAM_SIZE/. This > is generic code however while CONFIG_DRAM_SIZE is ARM only. > mm/nommu.c: if (!rlen || rlen > TASK_SIZE) > > - The issue the patch by Rabin is addressing (Subject: [PATCH] ARM: fix > string functions on !MMU), alternatively make TASK_SIZE ~0UL. > arch/arm/include/asm/uaccess.h:#define user_addr_max() \ > arch/arm/include/asm/uaccess.h: (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL) [reference: http://www.spinics.net/lists/arm-kernel/msg324112.html ] > - probably bearable if broken: > drivers/misc/lkdtm.c: if (user_addr >= TASK_SIZE) { > lib/test_user_copy.c: user_addr = vm_mmap(...) > lib/test_user_copy.c: if (user_addr >= (unsigned long)(TASK_SIZE)) { > lib/test_user_copy.c: pr_warn("Failed to allocate user memory\n"); > lib/test_user_copy.c: return -ENOMEM; > > - unclear to me: > fs/exec.c: current->mm->task_size = TASK_SIZE; > - depends on PERF_EVENTS > kernel/events/core.c: if (!addr || addr >= TASK_SIZE) > kernel/events/core.c: return TASK_SIZE - addr; > kernel/events/uprobes.c: area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, > - depends on (PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)): > arch/arm/kernel/hw_breakpoint.c: return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE); > - seems to cope with big TASK_SIZE > fs/namespace.c: size = TASK_SIZE - (unsigned long)data; > fs/namespace.c: if (size > PAGE_SIZE) > fs/namespace.c: size = PAGE_SIZE; > - depends on PLAT_S5P || ARCH_EXYNOS, this looks wrong > drivers/media/platform/s5p-mfc/s5p_mfc_common.h:#define DST_QUEUE_OFF_BASE (TASK_SIZE / 2) > - used for prctl(PR_SET_MM, ...) > kernel/sys.c: if (addr >= TASK_SIZE || addr < mmap_min_addr) > > Any help to judge if these are OK is appreciated (even from Will :-) > > I think it would be OK to define TASK_SIZE to 0xffffffff for !MMU. > blackfin, frv and m68k also do this. c6x does define it to 0xFFFFF000 to > leave space for error codes. > > Thoughts? The problem is that current linus/master (and also next) doesn't boot on my ARM-nommu machine because the user string functions (strnlen_user, strncpy_from_user et al.) refuse to work on strings above TASK_SIZE which in my case also includes the XIP kernel image. Maybe someone of the mm people can bring light into the unclear points above and the question what TASK_SIZE is supposed to be on no-MMU machines? Best regards Uwe > [1] complete as in "skip everything below arch/ but arch/arm" :-) > [removed the list, if you're interested, it's available at http://mid.gmane.org/20140429100028.GH28564@pengutronix.de] -- Pengutronix e.K. | Uwe Kleine-Konig | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TASK_SIZE for !MMU 2014-06-02 8:51 ` TASK_SIZE for !MMU Uwe Kleine-König @ 2014-06-03 12:14 ` Greg Ungerer 2014-06-03 14:11 ` Uwe Kleine-König 0 siblings, 1 reply; 5+ messages in thread From: Greg Ungerer @ 2014-06-03 12:14 UTC (permalink / raw) To: Uwe Kleine-König, Rabin Vincent, Will Deacon, linux-arm-kernel Cc: David Howells, uclinux-dist-devel, linux-m68k, linux-c6x-dev, linux-m32r, microblaze-uclinux, linux-xtensa, kernel, Andrew Morton, linux-mm, linux-kernel Hi Uwe, On 02/06/14 18:51, Uwe Kleine-Konig wrote: > Hello > > [expand Cc: a bit] > > On Tue, Apr 29, 2014 at 12:00:28PM +0200, Uwe Kleine-Konig wrote: >> I grepped through the kernel (v3.15-rc1) for usages of TASK_SIZE to >> check if/how it is used on !MMU ARM machines. Most open questions also >> affect the other !MMU platforms, so I put the blackfin, c6x, frv and >> m32r, m68k, microblaze and xtensa lists on Cc:. (Did I miss a platform >> that cares for !MMU ?) >> >> Most occurences are fine, see the list at the end of this mail. However >> some are not or are unclear to me. Here is the complete list[1] apart from >> the definition of TASK_SIZE for !MMU in arch/arm/include/asm/memory.h: >> >> - Probably this should be explict s/TASK_SIZE/CONFIG_DRAM_SIZE/. This >> is generic code however while CONFIG_DRAM_SIZE is ARM only. >> mm/nommu.c: if (!rlen || rlen > TASK_SIZE) >> >> - The issue the patch by Rabin is addressing (Subject: [PATCH] ARM: fix >> string functions on !MMU), alternatively make TASK_SIZE ~0UL. >> arch/arm/include/asm/uaccess.h:#define user_addr_max() \ >> arch/arm/include/asm/uaccess.h: (segment_eq(get_fs(), USER_DS) ? TASK_SIZE : ~0UL) > [reference: http://www.spinics.net/lists/arm-kernel/msg324112.html ] > >> - probably bearable if broken: >> drivers/misc/lkdtm.c: if (user_addr >= TASK_SIZE) { >> lib/test_user_copy.c: user_addr = vm_mmap(...) >> lib/test_user_copy.c: if (user_addr >= (unsigned long)(TASK_SIZE)) { >> lib/test_user_copy.c: pr_warn("Failed to allocate user memory\n"); >> lib/test_user_copy.c: return -ENOMEM; >> >> - unclear to me: >> fs/exec.c: current->mm->task_size = TASK_SIZE; >> - depends on PERF_EVENTS >> kernel/events/core.c: if (!addr || addr >= TASK_SIZE) >> kernel/events/core.c: return TASK_SIZE - addr; >> kernel/events/uprobes.c: area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE, >> - depends on (PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)): >> arch/arm/kernel/hw_breakpoint.c: return (va >= TASK_SIZE) && ((va + len - 1) >= TASK_SIZE); >> - seems to cope with big TASK_SIZE >> fs/namespace.c: size = TASK_SIZE - (unsigned long)data; >> fs/namespace.c: if (size > PAGE_SIZE) >> fs/namespace.c: size = PAGE_SIZE; >> - depends on PLAT_S5P || ARCH_EXYNOS, this looks wrong >> drivers/media/platform/s5p-mfc/s5p_mfc_common.h:#define DST_QUEUE_OFF_BASE (TASK_SIZE / 2) >> - used for prctl(PR_SET_MM, ...) >> kernel/sys.c: if (addr >= TASK_SIZE || addr < mmap_min_addr) >> >> Any help to judge if these are OK is appreciated (even from Will :-) >> >> I think it would be OK to define TASK_SIZE to 0xffffffff for !MMU. >> blackfin, frv and m68k also do this. c6x does define it to 0xFFFFF000 to >> leave space for error codes. I did that same change for m68k in commit cc24c40 ("m68knommu: remove size limit on non-MMU TASK_SIZE"). For similar reasons as you need to now. >> Thoughts? > The problem is that current linus/master (and also next) doesn't boot on > my ARM-nommu machine because the user string functions (strnlen_user, > strncpy_from_user et al.) refuse to work on strings above TASK_SIZE > which in my case also includes the XIP kernel image. I seem to recall that we were not considering flash or anything else other than RAM when defining that original TASK_SIZE (back many, many years ago). Some of the address checks you list above made some sense if you had everything in RAM (though only upper bounds are checked). The thinking was some checking is better than none I suppose. Setting a hard coded memory size in CONFIG_DRAM_SIZE is not all that fantastic either... Regards Greg > Maybe someone of the mm people can bring light into the unclear points > above and the question what TASK_SIZE is supposed to be on no-MMU > machines? > > Best regards > Uwe > >> [1] complete as in "skip everything below arch/ but arch/arm" :-) >> > [removed the list, if you're interested, it's available at > http://mid.gmane.org/20140429100028.GH28564@pengutronix.de] > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TASK_SIZE for !MMU 2014-06-03 12:14 ` Greg Ungerer @ 2014-06-03 14:11 ` Uwe Kleine-König 2014-06-03 15:19 ` Geert Uytterhoeven 2014-06-04 11:57 ` Greg Ungerer 0 siblings, 2 replies; 5+ messages in thread From: Uwe Kleine-König @ 2014-06-03 14:11 UTC (permalink / raw) To: Greg Ungerer Cc: Rabin Vincent, Will Deacon, linux-arm-kernel, linux-xtensa, linux-m32r, linux-c6x-dev, microblaze-uclinux, linux-kernel, David Howells, linux-mm, linux-m68k, kernel, uclinux-dist-devel, Andrew Morton, panchaxari, Linus Walleij Hello Greg, thanks for your reply. On Tue, Jun 03, 2014 at 10:14:55PM +1000, Greg Ungerer wrote: > >>I think it would be OK to define TASK_SIZE to 0xffffffff for !MMU. > >>blackfin, frv and m68k also do this. c6x does define it to 0xFFFFF000 to > >>leave space for error codes. > > I did that same change for m68k in commit cc24c40 ("m68knommu: remove > size limit on non-MMU TASK_SIZE"). For similar reasons as you need to > now. ok. > >>Thoughts? > >The problem is that current linus/master (and also next) doesn't boot on > >my ARM-nommu machine because the user string functions (strnlen_user, > >strncpy_from_user et al.) refuse to work on strings above TASK_SIZE > >which in my case also includes the XIP kernel image. > > I seem to recall that we were not considering flash or anything else > other than RAM when defining that original TASK_SIZE (back many, many > years ago). Some of the address checks you list above made some sense > if you had everything in RAM (though only upper bounds are checked). > The thinking was some checking is better than none I suppose. What is the actual meaning of TASK_SIZE? The maximal value of a valid userspace address? > Setting a hard coded memory size in CONFIG_DRAM_SIZE is not all that > fantastic either... Not sure what you mean? Having CONFIG_DRAM_SIZE at all or use it for boundary checking? CONFIG_DRAM_SIZE is hardly used apart from defining TASK_SIZE: - #define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) which is only used to define MODULES_END. Ap - Some memory configuration using cp15 registers in arch/arm/mm/proc-arm{740,940,946}.S For the former I'd say better use 0xffffffff, too. For the latter I wonder if we should just drop CPU_ARM740T, CPU_ARM940T and CPU_ARM946E. These are only selectable if ARCH_INTEGRATOR and are not selected by other symbols. As ARCH_INTEGRATOR selects ARM_PATCH_PHYS_VIRT since commit fe9891454473 (ARM: integrator: Default enable ARM_PATCH_PHYS_VIRT, AUTO_ZRELADDR) for Linux 3.13 and ARM_PATCH_PHYS_VIRT depends on MMU the Integrator-noMMU targets are broken anyhow. I will prepare a patch series with some cleanups. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-Konig | Industrial Linux Solutions | http://www.pengutronix.de/ | -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TASK_SIZE for !MMU 2014-06-03 14:11 ` Uwe Kleine-König @ 2014-06-03 15:19 ` Geert Uytterhoeven 2014-06-04 11:57 ` Greg Ungerer 1 sibling, 0 replies; 5+ messages in thread From: Geert Uytterhoeven @ 2014-06-03 15:19 UTC (permalink / raw) To: Uwe Kleine-König Cc: Greg Ungerer, Rabin Vincent, Will Deacon, linux-arm-kernel@lists.infradead.org, linux-xtensa@linux-xtensa.org, linux-m32r, linux-c6x-dev, microblaze-uclinux, linux-kernel@vger.kernel.org, David Howells, Linux MM, linux-m68k, Sascha Hauer, uclinux-dist-devel@blackfin.uclinux.org, Andrew Morton, panchaxari, Linus Walleij On Tue, Jun 3, 2014 at 4:11 PM, Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote: >> I did that same change for m68k in commit cc24c40 ("m68knommu: remove >> size limit on non-MMU TASK_SIZE"). For similar reasons as you need to >> now. > ok. > >> >>Thoughts? >> >The problem is that current linus/master (and also next) doesn't boot on >> >my ARM-nommu machine because the user string functions (strnlen_user, >> >strncpy_from_user et al.) refuse to work on strings above TASK_SIZE >> >which in my case also includes the XIP kernel image. >> >> I seem to recall that we were not considering flash or anything else >> other than RAM when defining that original TASK_SIZE (back many, many >> years ago). Some of the address checks you list above made some sense >> if you had everything in RAM (though only upper bounds are checked). >> The thinking was some checking is better than none I suppose. > What is the actual meaning of TASK_SIZE? The maximal value of a valid > userspace address? Yes $ git show cc24c40 commit cc24c405949e3d4418a90014d10166679d78141a Author: Greg Ungerer <gerg@uclinux.org> Date: Mon May 24 11:22:05 2010 +1000 m68knommu: remove size limit on non-MMU TASK_SIZE The TASK_SIZE define is used in some places as a limit on the size of the virtual address space of a process. On non-MMU systems those addresses used in comparison will be physical addresses, and they could be anywhere in the 32bit physical address space. So for !CONFIG_MMU systems set the TASK_SIZE to the maximum physical address. Signed-off-by: Greg Ungerer <gerg@uclinux.org> Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: TASK_SIZE for !MMU 2014-06-03 14:11 ` Uwe Kleine-König 2014-06-03 15:19 ` Geert Uytterhoeven @ 2014-06-04 11:57 ` Greg Ungerer 1 sibling, 0 replies; 5+ messages in thread From: Greg Ungerer @ 2014-06-04 11:57 UTC (permalink / raw) To: Uwe Kleine-König Cc: Rabin Vincent, Will Deacon, linux-arm-kernel, linux-xtensa, linux-m32r, linux-c6x-dev, microblaze-uclinux, linux-kernel, David Howells, linux-mm, linux-m68k, kernel, uclinux-dist-devel, Andrew Morton, panchaxari, Linus Walleij Hi Uwe, On 04/06/14 00:11, Uwe Kleine-Konig wrote: > On Tue, Jun 03, 2014 at 10:14:55PM +1000, Greg Ungerer wrote: >>>> I think it would be OK to define TASK_SIZE to 0xffffffff for !MMU. >>>> blackfin, frv and m68k also do this. c6x does define it to 0xFFFFF000 to >>>> leave space for error codes. >> >> I did that same change for m68k in commit cc24c40 ("m68knommu: remove >> size limit on non-MMU TASK_SIZE"). For similar reasons as you need to >> now. > ok. > >>>> Thoughts? >>> The problem is that current linus/master (and also next) doesn't boot on >>> my ARM-nommu machine because the user string functions (strnlen_user, >>> strncpy_from_user et al.) refuse to work on strings above TASK_SIZE >>> which in my case also includes the XIP kernel image. >> >> I seem to recall that we were not considering flash or anything else >> other than RAM when defining that original TASK_SIZE (back many, many >> years ago). Some of the address checks you list above made some sense >> if you had everything in RAM (though only upper bounds are checked). >> The thinking was some checking is better than none I suppose. > What is the actual meaning of TASK_SIZE? The maximal value of a valid > userspace address? Yes (as Geert pointed out :-) The limit of virtual userspace addresses. >> Setting a hard coded memory size in CONFIG_DRAM_SIZE is not all that >> fantastic either... > Not sure what you mean? Having CONFIG_DRAM_SIZE at all or use it for > boundary checking? Having the DRAM size be a configure time constant. And as you have found RAM isn't the only place in the physical address space that code will necessarily access. > CONFIG_DRAM_SIZE is hardly used apart from defining TASK_SIZE: > > - #define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) > which is only used to define MODULES_END. Ap > - Some memory configuration using cp15 registers in > arch/arm/mm/proc-arm{740,940,946}.S > > For the former I'd say better use 0xffffffff, too. For the latter I > wonder if we should just drop CPU_ARM740T, CPU_ARM940T and CPU_ARM946E. > These are only selectable if ARCH_INTEGRATOR and are not selected by > other symbols. As ARCH_INTEGRATOR selects ARM_PATCH_PHYS_VIRT since > commit fe9891454473 (ARM: integrator: Default enable > ARM_PATCH_PHYS_VIRT, AUTO_ZRELADDR) for Linux 3.13 and > ARM_PATCH_PHYS_VIRT depends on MMU the Integrator-noMMU targets are > broken anyhow. > > I will prepare a patch series with some cleanups. I have no idea how many people would be using those older ARM CPU types. It was hard to get much interest for them in mainline even years ago. Regards Greg -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-04 11:57 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20140429100028.GH28564@pengutronix.de> 2014-06-02 8:51 ` TASK_SIZE for !MMU Uwe Kleine-König 2014-06-03 12:14 ` Greg Ungerer 2014-06-03 14:11 ` Uwe Kleine-König 2014-06-03 15:19 ` Geert Uytterhoeven 2014-06-04 11:57 ` Greg Ungerer
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).