[uml-devel] [PATCH v2] um: Print minimum physical memory requirement
Print a more sensible message about the minimum physical memory requirement. Signed-off-by: Thomas Meyer --- diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 549ecf3..f7af5e6 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -61,18 +61,26 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end, unsigned long len, unsigned long long highmem) { unsigned long reserve = reserve_end - start; - int pfn = PFN_UP(__pa(reserve_end)); - int delta = (len - reserve) >> PAGE_SHIFT; - int err, offset, bootmap_size; + unsigned long pfn = PFN_UP(__pa(reserve_end)); + unsigned long delta = (len - reserve) >> PAGE_SHIFT; + unsigned long offset, bootmap_size; + int err, map_size; + + offset = uml_reserved - uml_physmem; + map_size = len - offset; + if(map_size <= 0) { + printf("Too few physical memory! Needed=%d, given=%d\n", + offset, len); + exit(1); + } physmem_fd = create_mem_file(len + highmem); - offset = uml_reserved - uml_physmem; err = os_map_memory((void *) uml_reserved, physmem_fd, offset, - len - offset, 1, 1, 1); + map_size, 1, 1, 1); if (err < 0) { printf("setup_physmem - mapping %ld bytes of memory at 0x%p " - "failed - errno = %d\n", len - offset, + "failed - errno = %d\n", map_size, (void *) uml_reserved, err); exit(1); } -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH v2] um: Print minimum physical memory requirement
On Fri, Apr 3, 2015 at 1:59 PM, Thomas Meyer wrote: > --- a/arch/um/kernel/physmem.c > +++ b/arch/um/kernel/physmem.c > @@ -61,18 +61,26 @@ void __init setup_physmem(unsigned long start, unsigned > long reserve_end, > unsigned long len, unsigned long long highmem) > { > unsigned long reserve = reserve_end - start; > - int pfn = PFN_UP(__pa(reserve_end)); > - int delta = (len - reserve) >> PAGE_SHIFT; > - int err, offset, bootmap_size; > + unsigned long pfn = PFN_UP(__pa(reserve_end)); > + unsigned long delta = (len - reserve) >> PAGE_SHIFT; > + unsigned long offset, bootmap_size; > + int err, map_size; map_size should be unsigned long. > + > + offset = uml_reserved - uml_physmem; > + map_size = len - offset; -- Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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 -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH v2] um: Print minimum physical memory requirement
Am Freitag, den 03.04.2015, 15:17 +0200 schrieb Geert Uytterhoeven: > On Fri, Apr 3, 2015 at 1:59 PM, Thomas Meyer wrote: > > --- a/arch/um/kernel/physmem.c > > +++ b/arch/um/kernel/physmem.c > > @@ -61,18 +61,26 @@ void __init setup_physmem(unsigned long start, unsigned > > long reserve_end, > > unsigned long len, unsigned long long highmem) > > { > > unsigned long reserve = reserve_end - start; > > - int pfn = PFN_UP(__pa(reserve_end)); > > - int delta = (len - reserve) >> PAGE_SHIFT; > > - int err, offset, bootmap_size; > > + unsigned long pfn = PFN_UP(__pa(reserve_end)); > > + unsigned long delta = (len - reserve) >> PAGE_SHIFT; > > + unsigned long offset, bootmap_size; > > + int err, map_size; > > map_size should be unsigned long. No, this can actually get negative as the memory size needed by the executable file (linux) can be bigger then the physical memory assigned to the kernel via "mem=xxx" command line! > > > + > > + offset = uml_reserved - uml_physmem; > > + map_size = len - offset; > > > > -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
Re: [uml-devel] [PATCH v2] um: Print minimum physical memory requirement
On Fri, Apr 3, 2015 at 3:22 PM, Thomas Meyer wrote: > Am Freitag, den 03.04.2015, 15:17 +0200 schrieb Geert Uytterhoeven: >> On Fri, Apr 3, 2015 at 1:59 PM, Thomas Meyer wrote: >> > --- a/arch/um/kernel/physmem.c >> > +++ b/arch/um/kernel/physmem.c >> > @@ -61,18 +61,26 @@ void __init setup_physmem(unsigned long start, >> > unsigned long reserve_end, >> > unsigned long len, unsigned long long highmem) >> > { >> > unsigned long reserve = reserve_end - start; >> > - int pfn = PFN_UP(__pa(reserve_end)); >> > - int delta = (len - reserve) >> PAGE_SHIFT; >> > - int err, offset, bootmap_size; >> > + unsigned long pfn = PFN_UP(__pa(reserve_end)); >> > + unsigned long delta = (len - reserve) >> PAGE_SHIFT; >> > + unsigned long offset, bootmap_size; >> > + int err, map_size; >> >> map_size should be unsigned long. > > No, this can actually get negative as the memory size needed by the > executable file (linux) can be bigger then the physical memory assigned > to the kernel via "mem=xxx" command line! In that case it should be (signed) long. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@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 -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[uml-devel] [PATCH v3] um: Print minimum physical memory requirement
Print a more sensible message about the minimum physical memory requirement. Signed-off-by: Thomas Meyer --- diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 549ecf3..6f20626 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -57,22 +57,51 @@ void map_memory(unsigned long virt, unsigned long phys, unsigned long len, extern int __syscall_stub_start; +/** + * setup_physmem() - Setup physical memory for UML + * @start: Start address of the physical kernel memory, + * i.e start address of the executable image. + * @reserve_end: end address of the physical kernel memory. + * @len: Length of total physical memory that should be mapped/made + * available, in bytes. + * @highmem: Number of highmem bytes that should be mapped/made available. + * + * Creates an unlinked temporary file of size (len + highmem) and memory maps + * it on the last executable image address (uml_reserved). + * + * The offset is needed as the length of the total physical memory + * (len + highmem) includes the size of the memory used be the executable image, + * but the mapped-to address is the last address of the executable image + * (uml_reserved == end address of executable image). + * + * The memory mapped memory of the temporary file is used as backing memory + * of all user space processes/kernel tasks. + */ void __init setup_physmem(unsigned long start, unsigned long reserve_end, unsigned long len, unsigned long long highmem) { unsigned long reserve = reserve_end - start; - int pfn = PFN_UP(__pa(reserve_end)); - int delta = (len - reserve) >> PAGE_SHIFT; - int err, offset, bootmap_size; + unsigned long pfn = PFN_UP(__pa(reserve_end)); + unsigned long delta = (len - reserve) >> PAGE_SHIFT; + unsigned long offset, bootmap_size; + long map_size; + int err; + + offset = uml_reserved - uml_physmem; + map_size = len - offset; + if(map_size <= 0) { + printf("Too few physical memory! Needed=%d, given=%d\n", + offset, len); + exit(1); + } physmem_fd = create_mem_file(len + highmem); - offset = uml_reserved - uml_physmem; err = os_map_memory((void *) uml_reserved, physmem_fd, offset, - len - offset, 1, 1, 1); + map_size, 1, 1, 1); if (err < 0) { printf("setup_physmem - mapping %ld bytes of memory at 0x%p " - "failed - errno = %d\n", len - offset, + "failed - errno = %d\n", map_size, (void *) uml_reserved, err); exit(1); } -- Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ ___ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel