Re: build error with latest git kernel for a user mode linux build

richard -rw- weinberger
2013-04-12T18:39:51Z

[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]

On Fri, Apr 12, 2013 at 7:51 PM, Toralf Förster <toralf.foerster@gmx.de> wrote:
> On 04/12/2013 07:41 PM, richard -rw- weinberger wrote:
>> You .config build perfectly fine here.
>> Have you tried a "make mrproper"?
> ick - I forgot to un-apply your patch you sent to me related to the trinity-madvise UML problem - compiles fine now again
>
> but this now seems not to work any longer :
>
> $ cat devel/stub_pte_fix.diff
> diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
> index b30f34a..db2d885 100644
> --- a/arch/um/include/asm/Kbuild
> +++ b/arch/um/include/asm/Kbuild
> @@ -3,3 +3,4 @@ generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h
> generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h exec.h
> generic-y += switch_to.h clkdev.h
> generic-y += trace_clock.h
> +header-y += mman.h
> diff --git a/arch/um/include/asm/mman.h b/arch/um/include/asm/mman.h
> new file mode 100644
> index 0000000..d8fb362
> --- /dev/null
> +++ b/arch/um/include/asm/mman.h
> @@ -0,0 +1,10 @@
> +#ifndef __UM_MMAN_H__
> ...

The attached patch is an updated version of stub_pte_fix.diff. It
should fix your issues. :-)

--
Thanks,
//richard

[-- Attachment #2: stub_pte_fix.diff --]
[-- Type: application/octet-stream, Size: 2443 bytes --]

diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index b30f34a..db2d885 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -3,3 +3,4 @@ generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h
generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h exec.h
generic-y += switch_to.h clkdev.h
generic-y += trace_clock.h
+header-y += mman.h
diff --git a/arch/um/include/asm/mman.h b/arch/um/include/asm/mman.h
new file mode 100644
index 0000000..bb0a8c7
--- /dev/null
+++ b/arch/um/include/asm/mman.h
@@ -0,0 +1,9 @@
+#ifndef __UM_MMAN_H__
+#define __UM_MMAN_H__
+
+#include <uapi/asm/mman.h>
+
+#define arch_mmap_check uml_mmap_check
+int uml_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
+
+#endif /* __UM_MMAN_H__ */
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 5abcbfb..632c066 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -10,6 +10,7 @@
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/slab.h>
+#include <linux/mman.h>
#include <asm/fixmap.h>
#include <asm/page.h>
#include <as-layout.h>
@@ -320,3 +321,8 @@ void *uml_kmalloc(int size, int flags)
{
return kmalloc(size, flags);
}
+
+int uml_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
+{
+ return (flags & MAP_FIXED && addr < STUB_START + STUB_END) ? -EINVAL : 0;
+}
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index ff03067..db09322 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -103,7 +103,7 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)

void uml_setup_stubs(struct mm_struct *mm)
{
- int err, ret;
+ int ret;

if (!skas_needs_stub)
return;
@@ -120,15 +120,10 @@ void uml_setup_stubs(struct mm_struct *mm)
mm->context.stub_pages[0] = virt_to_page(&__syscall_stub_start);
mm->context.stub_pages[1] = virt_to_page(mm->context.id.stack);

- /* dup_mmap already holds mmap_sem */
- err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
- VM_READ | VM_MAYREAD | VM_EXEC |
- VM_MAYEXEC | VM_DONTCOPY,
- mm->context.stub_pages);
- if (err) {
- printk(KERN_ERR "install_special_mapping returned %d\n", err);
- goto out;
- }
+ /* XXX: the stub pages don't have a VMA, ensure that the PTR counter
+ * is correct at process exit. */
+ mm->nr_ptes--;
+
return;