[PATCH] x86: break mutual header inclusion

Previous thread: Love and Hate on LKML by Love Hate on Tuesday, May 27, 2008 - 4:48 pm. (4 messages)

Next thread: rt10 on top of grsecurity-2.1.11: issue with marker-upstream.patch by Andrey Vul on Tuesday, May 27, 2008 - 5:51 pm. (1 message)
To: Ingo Molnar <mingo@...>
Cc: <linux-kernel@...>
Date: Tuesday, May 27, 2008 - 4:49 pm

Hi,

What do you think about this? The new file (vm86_mask.h) could actually be
embedded completely in processor-flags.h, but I went for what I believe is
the safer approach.

This has been compile tested on x86_32 and x86_64 defconfig.

Vegard

From: Vegard Nossum <vegard.nossum@gmail.com>
Date: Tue, 27 May 2008 21:38:35 +0200
Subject: [PATCH] x86: break mutual header inclusion

This breaks up the mutual inclusion between headers ptrace.h and vm86.h
by moving what's needed by both files into a new (minimal) file
vm86_mask.h.

We also move #include lines to the top.

Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
---
include/asm-x86/ptrace.h | 10 +++-------
include/asm-x86/vm86.h | 9 ++-------
include/asm-x86/vm86_mask.h | 12 ++++++++++++
3 files changed, 17 insertions(+), 14 deletions(-)
create mode 100644 include/asm-x86/vm86_mask.h

diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h
index 9f922b0..7ba799d 100644
--- a/include/asm-x86/ptrace.h
+++ b/include/asm-x86/ptrace.h
@@ -2,8 +2,10 @@
#define _ASM_X86_PTRACE_H

#include <linux/compiler.h> /* For __user */
+#include <asm/ds.h> /* the DS BTS struct is used for ptrace too */
+#include <asm/segment.h>
#include <asm/ptrace-abi.h>
-
+#include <asm/vm86_mask.h>

#ifndef __ASSEMBLY__

@@ -55,9 +57,6 @@ struct pt_regs {
unsigned long ss;
};

-#include <asm/vm86.h>
-#include <asm/segment.h>
-
#endif /* __KERNEL__ */

#else /* __i386__ */
@@ -127,9 +126,6 @@ struct pt_regs {

#ifdef __KERNEL__

-/* the DS BTS struct is used for ptrace as well */
-#include <asm/ds.h>
-
struct task_struct;

extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
diff --git a/include/asm-x86/vm86.h b/include/asm-x86/vm86.h
index 074b357..ad8d143 100644
--- a/include/asm-x86/vm86.h
+++ b/include/asm-x86/vm86.h
@@ -13,12 +13,8 @@
*/

#include <asm/processor-flag...

To: Vegard Nossum <vegard.nossum@...>
Cc: Ingo Molnar <mingo@...>, <linux-kernel@...>
Date: Tuesday, May 27, 2008 - 5:38 pm

Breaking the mutual header inclusion is appreciated, but some comments

Moving #include's out of an #ifdef __KERNEL__ can (and does here) break
our userspace headers.

Running "make headers_check" after touching anything under include/ is

Do we need a new header for this or can it go into processor-flags.h ?

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

--

To: Adrian Bunk <bunk@...>
Cc: Ingo Molnar <mingo@...>, <linux-kernel@...>
Date: Tuesday, May 27, 2008 - 6:01 pm

Hi!

Ah, that's true. My mistake.

CHECK include/asm/ptrace.h
[...]/usr/include/asm/ptrace.h requires asm/ds.h, which does not exist
in exported headers

What do you reckon is better here, to put #ifdef __KERNEL__ around the
whole of ds.h and export it, or put #ifdef __KERNEL__ around the
#include in ptrace.h? It feels wasteful to put it around the whole
ds.h, since what is the point in exporting an empty file? On the other
hand, it makes much more sense to put it there than in the "caller" in
order to avoid the duplication of #ifdef __KERNEL__. So unless you
prefer otherwise, I will choose the former (to export ds.h as well).

I hope you agree with the idea of moving the #include line to the top
of the file, however?

Thanks for the tip, that is very useful. I didn't realize I should use

It can go in there, yes. I will do that in the re-worked (hopefully
correct) patch.

This business of breaking cycles is a bit nasty. There are very many
traps to fall into, very many setups to break, and very little support
from the tools to help you get it right (though with 'make
headers_check' I am a little better off).

Thanks for the help :-)

Vegard

--
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
-- E. W. Dijkstra, EWD1036
--

To: Vegard Nossum <vegard.nossum@...>
Cc: Ingo Molnar <mingo@...>, <linux-kernel@...>
Date: Tuesday, May 27, 2008 - 6:27 pm

Our userspace headers are an API, and offering empty previsously
unexported headers to userspace sounds like the worse choice to me.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

--

Previous thread: Love and Hate on LKML by Love Hate on Tuesday, May 27, 2008 - 4:48 pm. (4 messages)

Next thread: rt10 on top of grsecurity-2.1.11: issue with marker-upstream.patch by Andrey Vul on Tuesday, May 27, 2008 - 5:51 pm. (1 message)