public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/7] Uml merge for 2.6.14
@ 2005-09-10 17:44 Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 1/7] Uml: more cleaning Paolo 'Blaisorblade' Giarrusso
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Jeff Dike, LKML, user-mode-linux-devel, blaisorblade

Merge easy part of my local Uml tree - mostly little bugfixes, and some tested
VM oneliners.

One patch (linker script change, adding dwarf debug sections) is applied to
i386 and x86-64 as well, on request(?) by Sam Ravnborg.

--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 1/7] Uml: more cleaning
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 2/7] i386 / uml: add dwarf sections to static link script Paolo 'Blaisorblade' Giarrusso
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: uml-more-clean --]
[-- Type: text/plain, Size: 1436 bytes --]

We must remove even arch/um/os-Linux/util/mk_user_constants, which we don't do.
Also, Kconfig_arch must be listed only once, between CLEAN_FILES.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/Makefile |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/um/Makefile b/arch/um/Makefile
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -103,7 +103,6 @@ endef
 
 ifneq ($(KBUILD_SRC),)
 $(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch)
-CLEAN_FILES += $(ARCH_DIR)/Kconfig.arch
 else
 $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
 endif
@@ -144,14 +143,14 @@ endef
 #TT or skas makefiles and don't clean skas_ptregs.h.
 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
 	$(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \
-	$(ARCH_DIR)/include/user_constants.h
+	$(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch
 
 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
-	$(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os \
-	$(ARCH_DIR)/Kconfig.arch
+	$(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os
 
 archclean:
 	$(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
+	$(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util
 	@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
 		-o -name '*.gcov' \) -type f -print | xargs rm -f
 

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 2/7] i386 / uml: add dwarf sections to static link script
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 1/7] Uml: more cleaning Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 18:38   ` Sam Ravnborg
  2005-09-10 17:44 ` [patch 3/7] x86_64 linker script cleanups for debug sections Paolo 'Blaisorblade' Giarrusso
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Sam Ravnborg, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: uml-add-dwarf-sections-to-static-link-script --]
[-- Type: text/plain, Size: 5746 bytes --]

Inside the linker script, insert the code for DWARF debug info sections. This
may help GDB'ing a Uml binary. Actually, it seems that ld is able to guess
what I added correctly, but normal linker scripts include this section so it
should be correct anyway adding it.

On request by Sam Ravnborg <sam@ravnborg.org>, I've added it to
asm-generic/vmlinux.lds.s. I've also moved there the stabs debug section,
used the new macro in i386 linker script and added DWARF debug section to
that.

In the truth, I've not been able to verify the difference in GDB behaviour
after this change (I've seen large improvements with another patch). This
may depend on my binutils version, older one may have worse defaults.

However, this section is present in normal linker script, so add it at
least for the sake of cleanness.

Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/i386/kernel/vmlinux.lds.S    |   11 +++--------
 arch/um/kernel/dyn.lds.S          |   37 ++++--------------------------------
 arch/um/kernel/uml.lds.S          |   14 +++++---------
 include/asm-generic/vmlinux.lds.h |   38 +++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -144,12 +144,7 @@ SECTIONS
 	*(.exitcall.exit)
 	}
 
-  /* Stabs debugging sections.  */
-  .stab 0 : { *(.stab) }
-  .stabstr 0 : { *(.stabstr) }
-  .stab.excl 0 : { *(.stab.excl) }
-  .stab.exclstr 0 : { *(.stab.exclstr) }
-  .stab.index 0 : { *(.stab.index) }
-  .stab.indexstr 0 : { *(.stab.indexstr) }
-  .comment 0 : { *(.comment) }
+  STABS_DEBUG
+
+  DWARF_DEBUG
 }
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -146,37 +146,8 @@ SECTIONS
   }
   _end = .;
   PROVIDE (end = .);
-   /* Stabs debugging sections.  */
-  .stab          0 : { *(.stab) }
-  .stabstr       0 : { *(.stabstr) }
-  .stab.excl     0 : { *(.stab.excl) }
-  .stab.exclstr  0 : { *(.stab.exclstr) }
-  .stab.index    0 : { *(.stab.index) }
-  .stab.indexstr 0 : { *(.stab.indexstr) }
-  .comment       0 : { *(.comment) }
-  /* DWARF debug sections.
-     Symbols in the DWARF debugging sections are relative to the beginning
-     of the section so we begin them at 0.  */
-  /* DWARF 1 */
-  .debug          0 : { *(.debug) }
-  .line           0 : { *(.line) }
-  /* GNU DWARF 1 extensions */
-  .debug_srcinfo  0 : { *(.debug_srcinfo) }
-  .debug_sfnames  0 : { *(.debug_sfnames) }
-  /* DWARF 1.1 and DWARF 2 */
-  .debug_aranges  0 : { *(.debug_aranges) }
-  .debug_pubnames 0 : { *(.debug_pubnames) }
-  /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
-  .debug_abbrev   0 : { *(.debug_abbrev) }
-  .debug_line     0 : { *(.debug_line) }
-  .debug_frame    0 : { *(.debug_frame) }
-  .debug_str      0 : { *(.debug_str) }
-  .debug_loc      0 : { *(.debug_loc) }
-  .debug_macinfo  0 : { *(.debug_macinfo) }
-  /* SGI/MIPS DWARF 2 extensions */
-  .debug_weaknames 0 : { *(.debug_weaknames) }
-  .debug_funcnames 0 : { *(.debug_funcnames) }
-  .debug_typenames 0 : { *(.debug_typenames) }
-  .debug_varnames  0 : { *(.debug_varnames) }
+
+  STABS_DEBUG
+
+  DWARF_DEBUG
 }
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -93,14 +93,10 @@ SECTIONS
    *(.bss)
    *(COMMON)
   }
-  _end = . ;
+  _end = .;
   PROVIDE (end = .);
-  /* Stabs debugging sections.  */
-  .stab 0 : { *(.stab) }
-  .stabstr 0 : { *(.stabstr) }
-  .stab.excl 0 : { *(.stab.excl) }
-  .stab.exclstr 0 : { *(.stab.exclstr) }
-  .stab.index 0 : { *(.stab.index) }
-  .stab.indexstr 0 : { *(.stab.indexstr) }
-  .comment 0 : { *(.comment) }
+
+  STABS_DEBUG
+
+  DWARF_DEBUG
 }
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -103,3 +103,41 @@
 		VMLINUX_SYMBOL(__kprobes_text_start) = .;		\
 		*(.kprobes.text)					\
 		VMLINUX_SYMBOL(__kprobes_text_end) = .;
+
+		/* DWARF debug sections.
+		Symbols in the DWARF debugging sections are relative to
+		the beginning of the section so we begin them at 0.  */
+#define DWARF_DEBUG							\
+		/* DWARF 1 */						\
+		.debug          0 : { *(.debug) }			\
+		.line           0 : { *(.line) }			\
+		/* GNU DWARF 1 extensions */				\
+		.debug_srcinfo  0 : { *(.debug_srcinfo) }		\
+		.debug_sfnames  0 : { *(.debug_sfnames) }		\
+		/* DWARF 1.1 and DWARF 2 */				\
+		.debug_aranges  0 : { *(.debug_aranges) }		\
+		.debug_pubnames 0 : { *(.debug_pubnames) }		\
+		/* DWARF 2 */						\
+		.debug_info     0 : { *(.debug_info			\
+				.gnu.linkonce.wi.*) }			\
+		.debug_abbrev   0 : { *(.debug_abbrev) }		\
+		.debug_line     0 : { *(.debug_line) }			\
+		.debug_frame    0 : { *(.debug_frame) }			\
+		.debug_str      0 : { *(.debug_str) }			\
+		.debug_loc      0 : { *(.debug_loc) }			\
+		.debug_macinfo  0 : { *(.debug_macinfo) }		\
+		/* SGI/MIPS DWARF 2 extensions */			\
+		.debug_weaknames 0 : { *(.debug_weaknames) }		\
+		.debug_funcnames 0 : { *(.debug_funcnames) }		\
+		.debug_typenames 0 : { *(.debug_typenames) }		\
+		.debug_varnames  0 : { *(.debug_varnames) }		\
+
+		/* Stabs debugging sections.  */
+#define STABS_DEBUG							\
+		.stab 0 : { *(.stab) }					\
+		.stabstr 0 : { *(.stabstr) }				\
+		.stab.excl 0 : { *(.stab.excl) }			\
+		.stab.exclstr 0 : { *(.stab.exclstr) }			\
+		.stab.index 0 : { *(.stab.index) }			\
+		.stab.indexstr 0 : { *(.stab.indexstr) }		\
+		.comment 0 : { *(.comment) }

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 3/7] x86_64 linker script cleanups for debug sections
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 1/7] Uml: more cleaning Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 2/7] i386 / uml: add dwarf sections to static link script Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-12  5:52   ` Andi Kleen
  2005-09-10 17:44 ` [patch 4/7] uml: inline mk_pte and various friends Paolo 'Blaisorblade' Giarrusso
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Sam Ravnborg, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: x86-64-link-script-cleanup --]
[-- Type: text/plain, Size: 1264 bytes --]

Use the new macros for x86_64 too.

Note that the current scripts includes different definitions; more exactly,
it only contains part of the DWARF2 sections and the .comment one from
Stabs. Shouldn't be a problem, anyway.

Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/x86_64/kernel/vmlinux.lds.S |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -194,20 +194,7 @@ SECTIONS
 #endif
 	}
 
-  /* DWARF 2 */
-  .debug_info     0 : { *(.debug_info) }
-  .debug_abbrev   0 : { *(.debug_abbrev) }
-  .debug_line     0 : { *(.debug_line) }
-  .debug_frame    0 : { *(.debug_frame) }
-  .debug_str      0 : { *(.debug_str) }
-  .debug_loc      0 : { *(.debug_loc) }
-  .debug_macinfo  0 : { *(.debug_macinfo) }
-  /* SGI/MIPS DWARF 2 extensions */
-  .debug_weaknames 0 : { *(.debug_weaknames) }
-  .debug_funcnames 0 : { *(.debug_funcnames) }
-  .debug_typenames 0 : { *(.debug_typenames) }
-  .debug_varnames  0 : { *(.debug_varnames) }
+  STABS_DEBUG
 
-
-  .comment 0 : { *(.comment) }
+  DWARF_DEBUG
 }

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 4/7] uml: inline mk_pte and various friends
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
                   ` (2 preceding siblings ...)
  2005-09-10 17:44 ` [patch 3/7] x86_64 linker script cleanups for debug sections Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 5/7] uml: fix fault handler on write Paolo 'Blaisorblade' Giarrusso
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: uml-inline-mk_pte --]
[-- Type: text/plain, Size: 4809 bytes --]

Turns out that, for UML, a *lot* of VM-related trivial functions are not
inlined but rather normal functions.

In other sections of UML code, this is justified by having files which
interact with the host and cannot therefore include kernel headers, but in
this case there's no such justification.

I've had to turn many of them to macros because of missing declarations. While
doing this, I've decided to reuse some already existing macros.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/include/mem.h    |   12 +++++++++++-
 arch/um/kernel/ksyms.c   |    5 -----
 arch/um/kernel/physmem.c |   35 -----------------------------------
 include/asm-um/page.h    |    3 +--
 include/asm-um/pgtable.h |   16 +++++++++++-----
 5 files changed, 23 insertions(+), 48 deletions(-)

diff --git a/arch/um/include/mem.h b/arch/um/include/mem.h
--- a/arch/um/include/mem.h
+++ b/arch/um/include/mem.h
@@ -13,7 +13,17 @@ extern int physmem_subst_mapping(void *v
 extern int is_remapped(void *virt);
 extern int physmem_remove_mapping(void *virt);
 extern void physmem_forget_descriptor(int fd);
-extern unsigned long to_phys(void *virt);
+
+extern unsigned long uml_physmem;
+static inline unsigned long to_phys(void *virt)
+{
+	return(((unsigned long) virt) - uml_physmem);
+}
+
+static inline void *to_virt(unsigned long phys)
+{
+	return((void *) uml_physmem + phys);
+}
 
 #endif
 
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -34,14 +34,9 @@ EXPORT_SYMBOL(host_task_size);
 EXPORT_SYMBOL(arch_validate);
 EXPORT_SYMBOL(get_kmem_end);
 
-EXPORT_SYMBOL(page_to_phys);
-EXPORT_SYMBOL(phys_to_page);
 EXPORT_SYMBOL(high_physmem);
 EXPORT_SYMBOL(empty_zero_page);
 EXPORT_SYMBOL(um_virt_to_phys);
-EXPORT_SYMBOL(__virt_to_page);
-EXPORT_SYMBOL(to_phys);
-EXPORT_SYMBOL(to_virt);
 EXPORT_SYMBOL(mode_tt);
 EXPORT_SYMBOL(handle_page_fault);
 EXPORT_SYMBOL(find_iomem);
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -248,16 +248,6 @@ unsigned long high_physmem;
 
 extern unsigned long physmem_size;
 
-void *to_virt(unsigned long phys)
-{
-	return((void *) uml_physmem + phys);
-}
-
-unsigned long to_phys(void *virt)
-{
-	return(((unsigned long) virt) - uml_physmem);
-}
-
 int init_maps(unsigned long physmem, unsigned long iomem, unsigned long highmem)
 {
 	struct page *p, *map;
@@ -298,31 +288,6 @@ int init_maps(unsigned long physmem, uns
 	return(0);
 }
 
-struct page *phys_to_page(const unsigned long phys)
-{
-	return(&mem_map[phys >> PAGE_SHIFT]);
-}
-
-struct page *__virt_to_page(const unsigned long virt)
-{
-	return(&mem_map[__pa(virt) >> PAGE_SHIFT]);
-}
-
-phys_t page_to_phys(struct page *page)
-{
-	return((page - mem_map) << PAGE_SHIFT);
-}
-
-pte_t mk_pte(struct page *page, pgprot_t pgprot)
-{
-	pte_t pte;
-
-	pte_set_val(pte, page_to_phys(page), pgprot);
-	if(pte_present(pte))
-		pte_mknewprot(pte_mknewpage(pte));
-	return(pte);
-}
-
 /* Changed during early boot */
 static unsigned long kmem_top = 0;
 
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
--- a/include/asm-um/page.h
+++ b/include/asm-um/page.h
@@ -96,8 +96,7 @@ extern unsigned long uml_physmem;
 
 #define __va_space (8*1024*1024)
 
-extern unsigned long to_phys(void *virt);
-extern void *to_virt(unsigned long phys);
+#include "mem.h"
 
 /* Cast to unsigned long before casting to void * to avoid a warning from
  * mmap_kmem about cutting a long long down to a void *.  Not sure that
diff --git a/include/asm-um/pgtable.h b/include/asm-um/pgtable.h
--- a/include/asm-um/pgtable.h
+++ b/include/asm-um/pgtable.h
@@ -326,14 +326,22 @@ static inline void set_pte(pte_t *pteptr
 }
 #define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
 
-extern phys_t page_to_phys(struct page *page);
-
 /*
  * Conversion functions: convert a page and protection to a page entry,
  * and a page entry and page directory to the page they refer to.
  */
 
-extern pte_t mk_pte(struct page *page, pgprot_t pgprot);
+#define phys_to_page(phys) pfn_to_page(phys_to_pfn(phys))
+#define __virt_to_page(virt) phys_to_page(__pa(virt))
+#define page_to_phys(page) pfn_to_phys(page_to_pfn(page))
+
+#define mk_pte(page, pgprot) \
+	({ pte_t pte;					\
+							\
+	pte_set_val(pte, page_to_phys(page), (pgprot));	\
+	if (pte_present(pte))				\
+		pte_mknewprot(pte_mknewpage(pte));	\
+	pte;})
 
 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
 {
@@ -410,8 +418,6 @@ static inline pte_t pte_modify(pte_t pte
 #endif
 #endif
 
-extern struct page *phys_to_page(const unsigned long phys);
-extern struct page *__virt_to_page(const unsigned long virt);
 #define virt_to_page(addr) __virt_to_page((const unsigned long) addr)
 
 /*

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 5/7] uml: fix fault handler on write
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
                   ` (3 preceding siblings ...)
  2005-09-10 17:44 ` [patch 4/7] uml: inline mk_pte and various friends Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 6/7] uml: avoid already done dirtying Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 7/7] uml: retry host close() on EINTR Paolo 'Blaisorblade' Giarrusso
  6 siblings, 0 replies; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: uml-fix-fault-handler-on-write --]
[-- Type: text/plain, Size: 1031 bytes --]

The UML fault handler was recently changed to enforce PROT_NONE protections,
by requiring VM_READ or VM_EXEC on VMA's.

However, by mistake, things were changed such that VM_READ is always checked,
also on write faults; so a VMA mapped with only PROT_WRITE is not readable
(unless it's prefaulted with MAP_POPULATE or with a write), which is different
from i386.

Discovered while testing remap_file_pages protection support.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/kernel/trap_kern.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -57,7 +57,8 @@ good_area:
 	if(is_write && !(vma->vm_flags & VM_WRITE)) 
 		goto out;
 
-        if(!(vma->vm_flags & (VM_READ | VM_EXEC)))
+	/* Don't require VM_READ|VM_EXEC for write faults! */
+        if(!is_write && !(vma->vm_flags & (VM_READ | VM_EXEC)))
                 goto out;
 
 	do {

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 6/7] uml: avoid already done dirtying
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
                   ` (4 preceding siblings ...)
  2005-09-10 17:44 ` [patch 5/7] uml: fix fault handler on write Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 17:44 ` [patch 7/7] uml: retry host close() on EINTR Paolo 'Blaisorblade' Giarrusso
  6 siblings, 0 replies; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: uml-avoid-already-done-dirtying --]
[-- Type: text/plain, Size: 904 bytes --]

The PTE returned from handle_mm_fault is already marked as dirty and accessed
if needed.
Also, since this is not set with set_pte() (which sets NEWPAGE and NEWPROT as
needed), this wouldn't work anyway.

This version has been updated and fixed, thanks to some feedback from Jeff Dike.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/kernel/trap_kern.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/um/kernel/trap_kern.c b/arch/um/kernel/trap_kern.c
--- a/arch/um/kernel/trap_kern.c
+++ b/arch/um/kernel/trap_kern.c
@@ -85,8 +85,7 @@ survive:
 		pte = pte_offset_kernel(pmd, address);
 	} while(!pte_present(*pte));
 	err = 0;
-	*pte = pte_mkyoung(*pte);
-	if(pte_write(*pte)) *pte = pte_mkdirty(*pte);
+	WARN_ON(!pte_young(*pte) || (is_write && !pte_dirty(*pte)));
 	flush_tlb_page(vma, address);
 out:
 	up_read(&mm->mmap_sem);

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [patch 7/7] uml: retry host close() on EINTR
  2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
                   ` (5 preceding siblings ...)
  2005-09-10 17:44 ` [patch 6/7] uml: avoid already done dirtying Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 17:44 ` Paolo 'Blaisorblade' Giarrusso
  2005-09-10 19:00   ` Linus Torvalds
  6 siblings, 1 reply; 14+ messages in thread
From: Paolo 'Blaisorblade' Giarrusso @ 2005-09-10 17:44 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Dike, Paolo Blaisorblade Giarrusso, LKML,
	user-mode-linux-devel

[-- Attachment #1: fix-close-eintr --]
[-- Type: text/plain, Size: 733 bytes --]

When calling close() on the host, we must retry the operation when we get
EINTR.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---

 arch/um/os-Linux/file.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -17,6 +17,7 @@
 #include <sys/uio.h>
 #include "os.h"
 #include "user.h"
+#include "user_util.h"
 #include "kern_util.h"
 
 static void copy_stat(struct uml_stat *dst, struct stat64 *src)
@@ -300,7 +301,7 @@ int os_connect_socket(char *name)
 
 void os_close_file(int fd)
 {
-	close(fd);
+	CATCH_EINTR(close(fd));
 }
 
 int os_seek_file(int fd, __u64 offset)

--

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 2/7] i386 / uml: add dwarf sections to static link script
  2005-09-10 17:44 ` [patch 2/7] i386 / uml: add dwarf sections to static link script Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 18:38   ` Sam Ravnborg
  0 siblings, 0 replies; 14+ messages in thread
From: Sam Ravnborg @ 2005-09-10 18:38 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Linus Torvalds, Jeff Dike, LKML, user-mode-linux-devel

On Sat, Sep 10, 2005 at 07:44:54PM +0200, Paolo 'Blaisorblade' Giarrusso wrote:
> Inside the linker script, insert the code for DWARF debug info sections. This
> may help GDB'ing a Uml binary. Actually, it seems that ld is able to guess
> what I added correctly, but normal linker scripts include this section so it
> should be correct anyway adding it.
> 
> On request by Sam Ravnborg <sam@ravnborg.org>, I've added it to
> asm-generic/vmlinux.lds.s. I've also moved there the stabs debug section,
> used the new macro in i386 linker script and added DWARF debug section to
> that.
Thanks!
Acked-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 7/7] uml: retry host close() on EINTR
  2005-09-10 17:44 ` [patch 7/7] uml: retry host close() on EINTR Paolo 'Blaisorblade' Giarrusso
@ 2005-09-10 19:00   ` Linus Torvalds
  2005-09-11  7:28     ` Paolo Ornati
  0 siblings, 1 reply; 14+ messages in thread
From: Linus Torvalds @ 2005-09-10 19:00 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Jeff Dike, LKML, user-mode-linux-devel



On Sat, 10 Sep 2005, Paolo 'Blaisorblade' Giarrusso wrote:
>
> When calling close() on the host, we must retry the operation when we get
> EINTR.

Actually, no.

If close() return EINTR, the file descriptor _will_ have been closed. The
error return just tells you that soem error happened on the file: for
example, in the case of EINTR, the close() may not have flushed all the
pending data synchronously.

Re-doing the close() is the wrong thing to do, since in a threaded 
environment, something else might have opened another file, gotten the 
same file descriptor, and you now close _another_ file.

(Normally, re-doing the close will just return EBADF, of course).

I'm going to drop this patch, but in case you've ever seen a case where 
EINTR actually means that the fd didn't get closed, please holler, and we 
need to fix it.

			Linus

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 7/7] uml: retry host close() on EINTR
  2005-09-10 19:00   ` Linus Torvalds
@ 2005-09-11  7:28     ` Paolo Ornati
  2005-09-11 11:49       ` Linus Torvalds
  0 siblings, 1 reply; 14+ messages in thread
From: Paolo Ornati @ 2005-09-11  7:28 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Paolo 'Blaisorblade' Giarrusso, Jeff Dike, LKML,
	user-mode-linux-devel

On Sat, 10 Sep 2005 12:00:01 -0700 (PDT)
Linus Torvalds <torvalds@osdl.org> wrote:

> Re-doing the close() is the wrong thing to do, since in a threaded 
> environment, something else might have opened another file, gotten
> the same file descriptor, and you now close _another_ file.

So glibc doc is wrong here:

http://www.gnu.org/software/libc/manual/html_node/Opening-and-Closing-Files.html#index-close-1197

-----------------------------------------------------------------------
The normal return value from close is 0; a value of -1 is returned in
case of failure. The following errno error conditions are defined for
this function:

...

EINTR
    The close call was interrupted by a signal. See Interrupted
Primitives. Here is an example of how to handle EINTR properly:

               TEMP_FAILURE_RETRY (close (desc));
-----------------------------------------------------------------------


And: /usr/include/unistd.h

# define TEMP_FAILURE_RETRY(expression)		\
  (__extension__				\
    ({ long int __result;			\
       do __result = (long int) (expression);	\
       while (__result == -1L && errno == EINTR); \
       __result; }))
#endif


SUSV3:
-------------------------------------------------------------
If close() is interrupted by a signal that is to be caught, it shall
return -1 with errno set to [EINTR] and the state of fildes is
unspecified
-------------------------------------------------------------

Unspecified! ;-)

-- 
	Paolo Ornati
	Linux 2.6.13.1 on x86_64

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 7/7] uml: retry host close() on EINTR
  2005-09-11  7:28     ` Paolo Ornati
@ 2005-09-11 11:49       ` Linus Torvalds
  0 siblings, 0 replies; 14+ messages in thread
From: Linus Torvalds @ 2005-09-11 11:49 UTC (permalink / raw)
  To: Paolo Ornati
  Cc: Paolo 'Blaisorblade' Giarrusso, Jeff Dike, LKML,
	user-mode-linux-devel



On Sun, 11 Sep 2005, Paolo Ornati wrote:
> 
> So glibc doc is wrong here:

Yes.

> SUSV3:
> -------------------------------------------------------------
> If close() is interrupted by a signal that is to be caught, it shall
> return -1 with errno set to [EINTR] and the state of fildes is
> unspecified
> -------------------------------------------------------------
> 
> Unspecified! ;-)

I don't know of any system where re-trying the close() is the right thing
to do, but I guess they exist. I think the Linux behaviour of "hey, it's
closed, live with it" is pretty universal - almost nobody ever tests the
return value of close().

Even the "careful" users that want to hear about IO errors have to really 
do an fsync(), so any IO errors should show up there. Of course, checking 
the return value of "close()" in addition to the fsync() is always a good 
idea anyway, and I suspect they do.

In Linux, another thread may return with the same fd in open() even _long_
before the close() that released it has even finished. The kernel releases
the fd itself early, and then the rest (anything that could return EINTR -
things like TCP linger stuff etc) is all done with just the "struct file".

So retrying is really really wrong. And not just on Linux. I think this is 
true on _most_  if not all unix implementations out there.

		Linus

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 3/7] x86_64 linker script cleanups for debug sections
  2005-09-10 17:44 ` [patch 3/7] x86_64 linker script cleanups for debug sections Paolo 'Blaisorblade' Giarrusso
@ 2005-09-12  5:52   ` Andi Kleen
  2005-09-13 17:56     ` Blaisorblade
  0 siblings, 1 reply; 14+ messages in thread
From: Andi Kleen @ 2005-09-12  5:52 UTC (permalink / raw)
  To: Paolo 'Blaisorblade' Giarrusso
  Cc: Jeff Dike, Sam Ravnborg, linux-kernel

Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> writes:

> Use the new macros for x86_64 too.
> 
> Note that the current scripts includes different definitions; more exactly,
> it only contains part of the DWARF2 sections and the .comment one from
> Stabs. Shouldn't be a problem, anyway.

Can you please always cc me on any arch/x86_64,asm-x86_64 patches? 

> Cc: Sam Ravnborg <sam@ravnborg.org>
> Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> ---
> 
>  arch/x86_64/kernel/vmlinux.lds.S |   17 ++---------------
>  1 files changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
> --- a/arch/x86_64/kernel/vmlinux.lds.S
> +++ b/arch/x86_64/kernel/vmlinux.lds.S
> @@ -194,20 +194,7 @@ SECTIONS
>  #endif
>  	}
>  
> -  /* DWARF 2 */
> -  .debug_info     0 : { *(.debug_info) }
> -  .debug_abbrev   0 : { *(.debug_abbrev) }
> -  .debug_line     0 : { *(.debug_line) }
> -  .debug_frame    0 : { *(.debug_frame) }
> -  .debug_str      0 : { *(.debug_str) }
> -  .debug_loc      0 : { *(.debug_loc) }
> -  .debug_macinfo  0 : { *(.debug_macinfo) }
> -  /* SGI/MIPS DWARF 2 extensions */
> -  .debug_weaknames 0 : { *(.debug_weaknames) }
> -  .debug_funcnames 0 : { *(.debug_funcnames) }
> -  .debug_typenames 0 : { *(.debug_typenames) }
> -  .debug_varnames  0 : { *(.debug_varnames) }
> +  STABS_DEBUG

There are no stabs sections on x86-64

> -
> -  .comment 0 : { *(.comment) }
> +  DWARF_DEBUG

-Andi

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [patch 3/7] x86_64 linker script cleanups for debug sections
  2005-09-12  5:52   ` Andi Kleen
@ 2005-09-13 17:56     ` Blaisorblade
  0 siblings, 0 replies; 14+ messages in thread
From: Blaisorblade @ 2005-09-13 17:56 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Sam Ravnborg, linux-kernel

On Monday 12 September 2005 07:52, Andi Kleen wrote:
> Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> writes:
> > Use the new macros for x86_64 too.
> >
> > Note that the current scripts includes different definitions; more
> > exactly, it only contains part of the DWARF2 sections and the .comment
> > one from Stabs. Shouldn't be a problem, anyway.
>
> Can you please always cc me on any arch/x86_64,asm-x86_64 patches?
Sorry, forgot this one - 

> > +  STABS_DEBUG
>
> There are no stabs sections on x86-64
Ok, just leave .comment then (if it's actually present and useful) and 
DWARF_DEBUG. Need patch?
> > -  .comment 0 : { *(.comment) }
> > +  DWARF_DEBUG
>
> -Andi

-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade


		
___________________________________ 
Yahoo! Messenger: chiamate gratuite in tutto il mondo 
http://it.messenger.yahoo.com

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-09-13 18:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-10 17:44 [patch 0/7] Uml merge for 2.6.14 Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 1/7] Uml: more cleaning Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 2/7] i386 / uml: add dwarf sections to static link script Paolo 'Blaisorblade' Giarrusso
2005-09-10 18:38   ` Sam Ravnborg
2005-09-10 17:44 ` [patch 3/7] x86_64 linker script cleanups for debug sections Paolo 'Blaisorblade' Giarrusso
2005-09-12  5:52   ` Andi Kleen
2005-09-13 17:56     ` Blaisorblade
2005-09-10 17:44 ` [patch 4/7] uml: inline mk_pte and various friends Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 5/7] uml: fix fault handler on write Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 6/7] uml: avoid already done dirtying Paolo 'Blaisorblade' Giarrusso
2005-09-10 17:44 ` [patch 7/7] uml: retry host close() on EINTR Paolo 'Blaisorblade' Giarrusso
2005-09-10 19:00   ` Linus Torvalds
2005-09-11  7:28     ` Paolo Ornati
2005-09-11 11:49       ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox