Skip to contentSkip to conversation

kvm.h: __user requires compiler.h

PATCH Applied Christian Borntraeger 3 participants 8 messages Mar 12, 2008 – Mar 25, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm.h: __user requires compiler.h

include/linux/kvm.h defines struct kvm_dirty_log to

	[...]
	union {
		void __user *dirty_bitmap; /* one bit per page */
		__u64 padding;
	};

__user requires compiler.h to compile. Currently, this works on x86 only coincidentally due to other include files. This patch makes kvm.h compile in all cases.

---
 include/linux/kvm.h |    1 +
 1 file changed, 1 insertion(+)
include/linux/kvm.h +1 -0
Index: kvm/include/linux/kvm.h
===================================================================
@@ -8,6 +8,7 @@
  */
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 #include <linux/ioctl.h>
 #include <asm/kvm.h>
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Applied
#1 lore raw
Quoted 11 lines · Christian Borntraeger

include/linux/kvm.h defines struct kvm_dirty_log to

	[...]
	union {
		void __user *dirty_bitmap; /* one bit per page */
		__u64 padding;
	};

__user requires compiler.h to compile. Currently, this works on x86 only coincidentally due to other include files. This patch makes kvm.h compile in all cases.

Applied, thanks.

Signature · 7 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#2 lore raw
In reply to Christian Borntraeger

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there, there isn't a linux/compiler.h.

The host kernelpath isn't normally part of the libkvm or QEMU build. So we have a couple options.

1) make the host kernelpath (/lib/modules/$(uname -r)/build/include) part of the libkvm/QEMU build.

2) Do something else about __user

Suggestions? #1 might be a pain since there may be include conflicts between the host kernel include and kernel/include.

Regards,

Anthony Liguori

Quoted 32 lines · Christian Borntraeger

include/linux/kvm.h defines struct kvm_dirty_log to

	[...]
	union {
		void __user *dirty_bitmap; /* one bit per page */
		__u64 padding;
	};

__user requires compiler.h to compile. Currently, this works on x86 only coincidentally due to other include files. This patch makes kvm.h compile in all cases.

---
 include/linux/kvm.h |    1 +
 1 file changed, 1 insertion(+)

Index: kvm/include/linux/kvm.h
===================================================================

include/linux/kvm.h +1 -1
@@ -8,6 +8,7 @@
  */
 
 #include <asm/types.h>
+#include <linux/compiler.h>
 #include <linux/ioctl.h>
 #include <asm/kvm.h>
 
 
 
 
-------------------------------------------------------------------------
Quoted 3 lines

This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#3 lore raw
Quoted 8 lines · Anthony Liguori

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there, there isn't a linux/compiler.h.

The host kernelpath isn't normally part of the libkvm or QEMU build. So we have a couple options.

Quoted 8 lines

1) make the host kernelpath (/lib/modules/$(uname -r)/build/include) part of the libkvm/QEMU build.

2) Do something else about __user

Suggestions? #1 might be a pain since there may be include conflicts between the host kernel include and kernel/include.

We could hack 'make sync' to strip out __user (just like we run unifdef). Of course the reasons for including linux/compiler.h are still valid, so it needs to remain.

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#4 lore raw
In reply to Anthony Liguori

Am Freitag, 21. März 2008 schrieb Anthony Liguori:

Quoted 4 lines

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there, there isn't a linux/compiler.h.

I checked with make headers_install, which strips out __user and compiler.h nicely. I never tried "make sync" since I was not aware of it.

Christian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#5 lore raw
Quoted 11 lines · Christian Borntraeger

Am Freitag, 21. März 2008 schrieb Anthony Liguori:

Quoted 5 lines

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there, there isn't a linux/compiler.h.

I checked with make headers_install, which strips out __user and compiler.h nicely. I never tried "make sync" since I was not aware of it.

Maybe we should generate the 'make sync' headers using 'make headers_install'.

Signature · 7 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
#6 lore raw

Am Montag, 24. März 2008 schrieb Avi Kivity:

Quoted 6 lines
Quoted 5 lines · Christian Borntraeger

Am Freitag, 21. März 2008 schrieb Anthony Liguori:

Quoted 3 lines

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there,

[...]

Quoted 2 lines

Maybe we should generate the 'make sync' headers using 'make headers_install'.

headers_install works because there is

# Eliminate the contents of (and inclusions of) compiler.h

HDRSED  := sed  -e "s/ inline / __inline__ /g" \
                -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
                -e "s/(__user[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
                -e "s/(__force[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
                -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" 
\
                -e "s/[[:space:]]__attribute_const__$$//" \
                -e "/^\#include <linux\/compiler.h>/d"

in scripts/Makefile.headersinst

If you dont want to do something like for make sync, what about providing a dummy compiler.h, which has
only this line?
#define __user

Christian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#7 lore raw
Quoted 32 lines · Christian Borntraeger

Am Montag, 24. März 2008 schrieb Avi Kivity:

Quoted 9 lines
Quoted 7 lines · Christian Borntraeger

Am Freitag, 21. März 2008 schrieb Anthony Liguori:

Quoted 4 lines

This patch breaks QEMU build when doing a 'make sync'. When you do a top-level ./configure, libkvm is built with kerneldir pointing to kvm-userspace/kernel/include. While linux/kvm.h is present there,

[...]

Quoted 3 lines

Maybe we should generate the 'make sync' headers using 'make headers_install'.

headers_install works because there is

# Eliminate the contents of (and inclusions of) compiler.h

HDRSED  := sed  -e "s/ inline / __inline__ /g" \
                -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
                -e "s/(__user[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
                -e "s/(__force[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
                -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
                -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" 
\
                -e "s/[[:space:]]__attribute_const__$$//" \
                -e "/^\#include <linux\/compiler.h>/d"
Quoted 7 lines

in scripts/Makefile.headersinst

If you dont want to do something like for make sync, what about providing a dummy compiler.h, which has
only this line?
#define __user

I already added something similar, see
bcb30c8bafc7cac75c38981a57bc1f94521e83f4.

Signature · 7 lines
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/