* [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers
@ 2015-09-10 11:31 Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 1/2] lib: link in linux kernel headers (uapi) Andrew Jones
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrew Jones @ 2015-09-10 11:31 UTC (permalink / raw)
To: kvm; +Cc: alex.bennee, andre.przywara, wei, lkurusa, pbonzini
Rather than import uapi headers, just include them. I've put an RFC on
this series because it will now require kernel headers to be installed on
the build machine. I'm guessing that's not a big problem, but before we
commit to it, it'd be good to hear opinions from others.
This change wouldn't be worth it just for psci.h, but we're looking at PCI
support now, and thus we'll also want pci.h (and pci_regs.h). Although
after pci.h I'm not sure what else we'll eventually want. If nothing, then
maybe importing pci.h is also the right thing to do?
Thanks,
drew
Andrew Jones (2):
lib: link in linux kernel headers (uapi)
Revert "arm/arm64: import include/uapi/linux/psci.h"
.gitignore | 1 +
Makefile | 4 +--
configure | 9 ++++++
lib/arm/asm/page.h | 2 +-
lib/arm/asm/psci.h | 2 +-
lib/arm/asm/uapi-psci.h | 73 -----------------------------------------------
lib/arm64/asm/page.h | 2 +-
lib/arm64/asm/psci.h | 2 +-
lib/arm64/asm/uapi-psci.h | 1 -
lib/asm-generic/page.h | 2 +-
lib/const.h | 11 -------
11 files changed, 17 insertions(+), 92 deletions(-)
delete mode 100644 lib/arm/asm/uapi-psci.h
delete mode 100644 lib/arm64/asm/uapi-psci.h
delete mode 100644 lib/const.h
--
2.4.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [kvm-unit-tests RFC PATCH 1/2] lib: link in linux kernel headers (uapi)
2015-09-10 11:31 [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Andrew Jones
@ 2015-09-10 11:31 ` Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 2/2] Revert "arm/arm64: import include/uapi/linux/psci.h" Andrew Jones
2015-09-10 16:24 ` [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Jones @ 2015-09-10 11:31 UTC (permalink / raw)
To: kvm; +Cc: alex.bennee, andre.przywara, wei, lkurusa, pbonzini
Rather than import uapi headers, e.g. lib/arm/asm/uapi-psci.h, just
include them. For cross compilation we'll need the headers explicitly
added to the include path, but doing -I /usr/include won't work, as
some of our local header names will collide with /usr/include names.
Even just doing -I /usr/include/linux would leave too many potential
name collisions. So we create a lib/linux link, and do *not*
add -I lib/linux. Doing it this way requires code to include the uapi
headers with <linux/header.h>, putting them in their own "linux"
namespace.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
.gitignore | 1 +
Makefile | 4 ++--
configure | 9 +++++++++
lib/arm/asm/page.h | 2 +-
lib/arm/asm/psci.h | 2 +-
lib/arm64/asm/page.h | 2 +-
lib/arm64/asm/psci.h | 2 +-
lib/asm-generic/page.h | 2 +-
lib/const.h | 11 -----------
9 files changed, 17 insertions(+), 18 deletions(-)
delete mode 100644 lib/const.h
diff --git a/.gitignore b/.gitignore
index 242fae475094c..48ae6293e7ed0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ patches
cscope.*
*.swp
/lib/asm
+/lib/linux
/config.mak
/*-run
/test.log
diff --git a/Makefile b/Makefile
index 0d5933474cd8c..77f8863af706c 100644
--- a/Makefile
+++ b/Makefile
@@ -80,10 +80,10 @@ libfdt_clean:
$(LIBFDT_objdir)/.*.d
distclean: clean libfdt_clean
- $(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
+ $(RM) lib/linux lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
$(RM) -r tests
-cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
+cscope: common_dirs = lib lib/libfdt lib/linux lib/asm lib/asm-generic
cscope:
$(RM) ./cscope.*
find -L $(TEST_DIR) lib/$(TEST_DIR) lib/$(ARCH) $(common_dirs) -maxdepth 1 \
diff --git a/configure b/configure
index b2ad32a3e3a52..88e17a49f2660 100755
--- a/configure
+++ b/configure
@@ -90,6 +90,15 @@ if [ -f $testdir/run ]; then
ln -fs $testdir/run $testdir-run
fi
+# link uapi/linux
+rm -f lib/linux
+if [ ! -d /usr/include/linux ]; then
+ echo kernel-headers not installed, aborting...
+ exit 1
+else
+ ln -s /usr/include/linux lib/linux
+fi
+
# check for dependent 32 bit libraries
if [ "$arch" != "arm" ]; then
cat << EOF > lib_test.c
diff --git a/lib/arm/asm/page.h b/lib/arm/asm/page.h
index 039e2ddfb8e0f..df76969964ed3 100644
--- a/lib/arm/asm/page.h
+++ b/lib/arm/asm/page.h
@@ -6,7 +6,7 @@
* This work is licensed under the terms of the GNU LGPL, version 2.
*/
-#include <const.h>
+#include <linux/const.h>
#define PAGE_SHIFT 12
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h
index c5fe78184b5ac..11ac45028d787 100644
--- a/lib/arm/asm/psci.h
+++ b/lib/arm/asm/psci.h
@@ -1,7 +1,7 @@
#ifndef _ASMARM_PSCI_H_
#define _ASMARM_PSCI_H_
#include <libcflat.h>
-#include <asm/uapi-psci.h>
+#include <linux/psci.h>
#define PSCI_INVOKE_ARG_TYPE u32
#define PSCI_FN_CPU_ON PSCI_0_2_FN_CPU_ON
diff --git a/lib/arm64/asm/page.h b/lib/arm64/asm/page.h
index 29ad1f1f720c4..3144e8efcc7ae 100644
--- a/lib/arm64/asm/page.h
+++ b/lib/arm64/asm/page.h
@@ -11,7 +11,7 @@
* This work is licensed under the terms of the GNU LGPL, version 2.
*/
-#include <const.h>
+#include <linux/const.h>
#define PGTABLE_LEVELS 2
#define VA_BITS 42
diff --git a/lib/arm64/asm/psci.h b/lib/arm64/asm/psci.h
index 940d61d34c05d..0a7d7c854e2b3 100644
--- a/lib/arm64/asm/psci.h
+++ b/lib/arm64/asm/psci.h
@@ -1,7 +1,7 @@
#ifndef _ASMARM64_PSCI_H_
#define _ASMARM64_PSCI_H_
#include <libcflat.h>
-#include <asm/uapi-psci.h>
+#include <linux/psci.h>
#define PSCI_INVOKE_ARG_TYPE u64
#define PSCI_FN_CPU_ON PSCI_0_2_FN64_CPU_ON
diff --git a/lib/asm-generic/page.h b/lib/asm-generic/page.h
index 66c72a62bb0f7..f872f6fa0dad2 100644
--- a/lib/asm-generic/page.h
+++ b/lib/asm-generic/page.h
@@ -9,7 +9,7 @@
* This work is licensed under the terms of the GNU LGPL, version 2.
*/
-#include "const.h"
+#include <linux/const.h>
#define PAGE_SHIFT 12
#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
diff --git a/lib/const.h b/lib/const.h
deleted file mode 100644
index 5cd94d7067541..0000000000000
--- a/lib/const.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef _CONST_H_
-#define _CONST_H_
-#ifdef __ASSEMBLY__
-#define _AC(X,Y) X
-#define _AT(T,X) X
-#else
-#define __AC(X,Y) (X##Y)
-#define _AC(X,Y) __AC(X,Y)
-#define _AT(T,X) ((T)(X))
-#endif
-#endif
--
2.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [kvm-unit-tests RFC PATCH 2/2] Revert "arm/arm64: import include/uapi/linux/psci.h"
2015-09-10 11:31 [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 1/2] lib: link in linux kernel headers (uapi) Andrew Jones
@ 2015-09-10 11:31 ` Andrew Jones
2015-09-10 16:24 ` [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Jones @ 2015-09-10 11:31 UTC (permalink / raw)
To: kvm; +Cc: alex.bennee, andre.przywara, wei, lkurusa, pbonzini
The previous patch allows us to "unimport" this header now.
This reverts commit 7bc9f5e757bfa5c5a5202816404444fcf47a14b3.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
lib/arm/asm/uapi-psci.h | 73 -----------------------------------------------
lib/arm64/asm/uapi-psci.h | 1 -
2 files changed, 74 deletions(-)
delete mode 100644 lib/arm/asm/uapi-psci.h
delete mode 100644 lib/arm64/asm/uapi-psci.h
diff --git a/lib/arm/asm/uapi-psci.h b/lib/arm/asm/uapi-psci.h
deleted file mode 100644
index 5c6fada2b5105..0000000000000
--- a/lib/arm/asm/uapi-psci.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef _ASMARM_UAPI_PSCI_H_
-#define _ASMARM_UAPI_PSCI_H_
-/*
- * From include/uapi/linux/psci.h
- */
-
-/* PSCI v0.2 interface */
-#define PSCI_0_2_FN_BASE 0x84000000
-#define PSCI_0_2_FN(n) (PSCI_0_2_FN_BASE + (n))
-#define PSCI_0_2_64BIT 0x40000000
-#define PSCI_0_2_FN64_BASE \
- (PSCI_0_2_FN_BASE + PSCI_0_2_64BIT)
-#define PSCI_0_2_FN64(n) (PSCI_0_2_FN64_BASE + (n))
-
-#define PSCI_0_2_FN_PSCI_VERSION PSCI_0_2_FN(0)
-#define PSCI_0_2_FN_CPU_SUSPEND PSCI_0_2_FN(1)
-#define PSCI_0_2_FN_CPU_OFF PSCI_0_2_FN(2)
-#define PSCI_0_2_FN_CPU_ON PSCI_0_2_FN(3)
-#define PSCI_0_2_FN_AFFINITY_INFO PSCI_0_2_FN(4)
-#define PSCI_0_2_FN_MIGRATE PSCI_0_2_FN(5)
-#define PSCI_0_2_FN_MIGRATE_INFO_TYPE PSCI_0_2_FN(6)
-#define PSCI_0_2_FN_MIGRATE_INFO_UP_CPU PSCI_0_2_FN(7)
-#define PSCI_0_2_FN_SYSTEM_OFF PSCI_0_2_FN(8)
-#define PSCI_0_2_FN_SYSTEM_RESET PSCI_0_2_FN(9)
-
-#define PSCI_0_2_FN64_CPU_SUSPEND PSCI_0_2_FN64(1)
-#define PSCI_0_2_FN64_CPU_ON PSCI_0_2_FN64(3)
-#define PSCI_0_2_FN64_AFFINITY_INFO PSCI_0_2_FN64(4)
-#define PSCI_0_2_FN64_MIGRATE PSCI_0_2_FN64(5)
-#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7)
-
-/* PSCI v0.2 power state encoding for CPU_SUSPEND function */
-#define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
-#define PSCI_0_2_POWER_STATE_ID_SHIFT 0
-#define PSCI_0_2_POWER_STATE_TYPE_SHIFT 16
-#define PSCI_0_2_POWER_STATE_TYPE_MASK \
- (0x1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT)
-#define PSCI_0_2_POWER_STATE_AFFL_SHIFT 24
-#define PSCI_0_2_POWER_STATE_AFFL_MASK \
- (0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT)
-
-/* PSCI v0.2 affinity level state returned by AFFINITY_INFO */
-#define PSCI_0_2_AFFINITY_LEVEL_ON 0
-#define PSCI_0_2_AFFINITY_LEVEL_OFF 1
-#define PSCI_0_2_AFFINITY_LEVEL_ON_PENDING 2
-
-/* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */
-#define PSCI_0_2_TOS_UP_MIGRATE 0
-#define PSCI_0_2_TOS_UP_NO_MIGRATE 1
-#define PSCI_0_2_TOS_MP 2
-
-/* PSCI version decoding (independent of PSCI version) */
-#define PSCI_VERSION_MAJOR_SHIFT 16
-#define PSCI_VERSION_MINOR_MASK \
- ((1U << PSCI_VERSION_MAJOR_SHIFT) - 1)
-#define PSCI_VERSION_MAJOR_MASK ~PSCI_VERSION_MINOR_MASK
-#define PSCI_VERSION_MAJOR(ver) \
- (((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT)
-#define PSCI_VERSION_MINOR(ver) \
- ((ver) & PSCI_VERSION_MINOR_MASK)
-
-/* PSCI return values (inclusive of all PSCI versions) */
-#define PSCI_RET_SUCCESS 0
-#define PSCI_RET_NOT_SUPPORTED -1
-#define PSCI_RET_INVALID_PARAMS -2
-#define PSCI_RET_DENIED -3
-#define PSCI_RET_ALREADY_ON -4
-#define PSCI_RET_ON_PENDING -5
-#define PSCI_RET_INTERNAL_FAILURE -6
-#define PSCI_RET_NOT_PRESENT -7
-#define PSCI_RET_DISABLED -8
-
-#endif /* _ASMARM_UAPI_PSCI_H_ */
diff --git a/lib/arm64/asm/uapi-psci.h b/lib/arm64/asm/uapi-psci.h
deleted file mode 100644
index 83d018f954e4c..0000000000000
--- a/lib/arm64/asm/uapi-psci.h
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../arm/asm/uapi-psci.h"
--
2.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers
2015-09-10 11:31 [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 1/2] lib: link in linux kernel headers (uapi) Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 2/2] Revert "arm/arm64: import include/uapi/linux/psci.h" Andrew Jones
@ 2015-09-10 16:24 ` Paolo Bonzini
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2015-09-10 16:24 UTC (permalink / raw)
To: Andrew Jones, kvm; +Cc: alex.bennee, andre.przywara, wei, lkurusa
On 10/09/2015 13:31, Andrew Jones wrote:
> Rather than import uapi headers, just include them. I've put an RFC on
> this series because it will now require kernel headers to be installed on
> the build machine. I'm guessing that's not a big problem, but before we
> commit to it, it'd be good to hear opinions from others.
>
> This change wouldn't be worth it just for psci.h, but we're looking at PCI
> support now, and thus we'll also want pci.h (and pci_regs.h). Although
> after pci.h I'm not sure what else we'll eventually want. If nothing, then
> maybe importing pci.h is also the right thing to do?
Sounds good, and it's a tiny bit easier to go include->import than
import->include.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-10 16:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-10 11:31 [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 1/2] lib: link in linux kernel headers (uapi) Andrew Jones
2015-09-10 11:31 ` [kvm-unit-tests RFC PATCH 2/2] Revert "arm/arm64: import include/uapi/linux/psci.h" Andrew Jones
2015-09-10 16:24 ` [kvm-unit-tests RFC PATCH 0/2] try another approach for uapi headers Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).