xen/arch/arm/arm32/insn.c | 3 ++- xen/arch/arm/arm64/cpufeature.c | 1 + xen/arch/arm/arm64/insn.c | 1 + xen/arch/arm/cpufeature.c | 1 + xen/arch/arm/include/asm/arm32/cmpxchg.h | 1 + xen/arch/arm/include/asm/arm64/cmpxchg.h | 2 ++ xen/arch/arm/include/asm/regs.h | 2 +- xen/arch/arm/include/asm/vgic.h | 1 + xen/arch/ppc/include/asm/time.h | 2 +- xen/arch/x86/bitops.c | 2 +- xen/arch/x86/include/asm/cpufeature.h | 1 + xen/arch/x86/include/asm/system.h | 2 +- xen/arch/x86/include/asm/x86_64/page.h | 2 ++ xen/arch/x86/x86_emulate/private.h | 1 + xen/common/efi/common-stub.c | 2 +- xen/common/version.c | 1 + xen/include/public/hvm/save.h | 2 +- xen/include/xen/bug.h | 19 +++++++++++++++++++ xen/include/xen/cpumask.h | 1 + xen/include/xen/device_tree.h | 1 + xen/include/xen/lib.h | 19 ------------------- xen/include/xen/list.h | 2 +- xen/include/xen/livepatch.h | 2 ++ xen/include/xen/mm.h | 1 + xen/include/xen/param.h | 1 + xen/lib/list-sort.c | 1 + xen/xsm/flask/ss/ebitmap.h | 1 + 27 files changed, 48 insertions(+), 27 deletions(-)
Move the macros mentioned in the commit subject to their appropriate
locations.
Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and
include "xen/bug.h" in files where xen/bug.h macros are utilized.
Most of the changes were made because a file requires macros from xen/bug.h,
except for some files for Arm which require definitions of BUG_OPCODE,
BUG_INSTR, BUG_FN_REG.
xen/lib.h was added to list-sort.c ( otherwise compilation errors related
to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was
removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h
functionality and only xen/bug.h is needed.
cpufeature.h requires the inclusion of <xen/cache.h>;
otherwise, the following error will occur:
ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41:
multiple definitions of `__cacheline_aligned';
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
xen/arch/arm/arm32/insn.c | 3 ++-
xen/arch/arm/arm64/cpufeature.c | 1 +
xen/arch/arm/arm64/insn.c | 1 +
xen/arch/arm/cpufeature.c | 1 +
xen/arch/arm/include/asm/arm32/cmpxchg.h | 1 +
xen/arch/arm/include/asm/arm64/cmpxchg.h | 2 ++
xen/arch/arm/include/asm/regs.h | 2 +-
xen/arch/arm/include/asm/vgic.h | 1 +
xen/arch/ppc/include/asm/time.h | 2 +-
xen/arch/x86/bitops.c | 2 +-
xen/arch/x86/include/asm/cpufeature.h | 1 +
xen/arch/x86/include/asm/system.h | 2 +-
xen/arch/x86/include/asm/x86_64/page.h | 2 ++
xen/arch/x86/x86_emulate/private.h | 1 +
xen/common/efi/common-stub.c | 2 +-
xen/common/version.c | 1 +
xen/include/public/hvm/save.h | 2 +-
xen/include/xen/bug.h | 19 +++++++++++++++++++
xen/include/xen/cpumask.h | 1 +
xen/include/xen/device_tree.h | 1 +
xen/include/xen/lib.h | 19 -------------------
xen/include/xen/list.h | 2 +-
xen/include/xen/livepatch.h | 2 ++
xen/include/xen/mm.h | 1 +
xen/include/xen/param.h | 1 +
xen/lib/list-sort.c | 1 +
xen/xsm/flask/ss/ebitmap.h | 1 +
27 files changed, 48 insertions(+), 27 deletions(-)
diff --git a/xen/arch/arm/arm32/insn.c b/xen/arch/arm/arm32/insn.c
index 49953a042a..2a62bb9cce 100644
--- a/xen/arch/arm/arm32/insn.c
+++ b/xen/arch/arm/arm32/insn.c
@@ -13,8 +13,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <xen/lib.h>
#include <xen/bitops.h>
+#include <xen/bug.h>
+#include <xen/lib.h>
#include <xen/sizes.h>
#include <asm/insn.h>
diff --git a/xen/arch/arm/arm64/cpufeature.c b/xen/arch/arm/arm64/cpufeature.c
index b4656ff4d8..864413d9cc 100644
--- a/xen/arch/arm/arm64/cpufeature.c
+++ b/xen/arch/arm/arm64/cpufeature.c
@@ -69,6 +69,7 @@
* KVM guests.
*/
+#include <xen/bug.h>
#include <xen/types.h>
#include <xen/kernel.h>
#include <asm/sysregs.h>
diff --git a/xen/arch/arm/arm64/insn.c b/xen/arch/arm/arm64/insn.c
index 22f2bdebd5..773c3749d1 100644
--- a/xen/arch/arm/arm64/insn.c
+++ b/xen/arch/arm/arm64/insn.c
@@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/bug.h>
#include <xen/types.h>
#include <xen/lib.h>
#include <xen/errno.h>
diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
index f43d5cb338..ef77473bf8 100644
--- a/xen/arch/arm/cpufeature.c
+++ b/xen/arch/arm/cpufeature.c
@@ -5,6 +5,7 @@
* Copyright (C) 2015 ARM Ltd.
*/
+#include <xen/bug.h>
#include <xen/types.h>
#include <xen/init.h>
#include <xen/smp.h>
diff --git a/xen/arch/arm/include/asm/arm32/cmpxchg.h b/xen/arch/arm/include/asm/arm32/cmpxchg.h
index 37b2d64eb6..8455eb7cc3 100644
--- a/xen/arch/arm/include/asm/arm32/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm32/cmpxchg.h
@@ -1,6 +1,7 @@
#ifndef __ASM_ARM32_CMPXCHG_H
#define __ASM_ARM32_CMPXCHG_H
+#include <xen/bug.h>
#include <xen/prefetch.h>
extern void __bad_xchg(volatile void *ptr, int size);
diff --git a/xen/arch/arm/include/asm/arm64/cmpxchg.h b/xen/arch/arm/include/asm/arm64/cmpxchg.h
index 031fa6d92a..f160e8e7bc 100644
--- a/xen/arch/arm/include/asm/arm64/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm64/cmpxchg.h
@@ -1,6 +1,8 @@
#ifndef __ASM_ARM64_CMPXCHG_H
#define __ASM_ARM64_CMPXCHG_H
+#include <xen/bug.h>
+
extern void __bad_xchg(volatile void *ptr, int size);
static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
index f998aedff5..0d9f239a77 100644
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -5,7 +5,7 @@
#ifndef __ASSEMBLY__
-#include <xen/lib.h>
+#include <xen/bug.h>
#include <xen/types.h>
#include <public/xen.h>
#include <asm/current.h>
diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h
index 922779ce14..79b73a0dbb 100644
--- a/xen/arch/arm/include/asm/vgic.h
+++ b/xen/arch/arm/include/asm/vgic.h
@@ -22,6 +22,7 @@
#include <asm/new_vgic.h>
#else
+#include <xen/bug.h>
#include <xen/radix-tree.h>
#include <xen/rbtree.h>
diff --git a/xen/arch/ppc/include/asm/time.h b/xen/arch/ppc/include/asm/time.h
index aa9dda82a3..f23eec173e 100644
--- a/xen/arch/ppc/include/asm/time.h
+++ b/xen/arch/ppc/include/asm/time.h
@@ -2,7 +2,7 @@
#ifndef __ASM_PPC_TIME_H__
#define __ASM_PPC_TIME_H__
-#include <xen/lib.h>
+#include <xen/bug.h>
#include <asm/processor.h>
#include <asm/regs.h>
diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c
index f6ee71512c..720ab32362 100644
--- a/xen/arch/x86/bitops.c
+++ b/xen/arch/x86/bitops.c
@@ -1,6 +1,6 @@
#include <xen/bitops.h>
-#include <xen/lib.h>
+#include <xen/bug.h>
unsigned int __find_first_bit(
const unsigned long *addr, unsigned int size)
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 896483a900..be16492c68 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -6,6 +6,7 @@
#ifndef __ASM_I386_CPUFEATURE_H
#define __ASM_I386_CPUFEATURE_H
+#include <xen/cache.h>
#include <xen/const.h>
#include <asm/cpuid.h>
diff --git a/xen/arch/x86/include/asm/system.h b/xen/arch/x86/include/asm/system.h
index 6e40a03cb3..debf6bfa17 100644
--- a/xen/arch/x86/include/asm/system.h
+++ b/xen/arch/x86/include/asm/system.h
@@ -1,8 +1,8 @@
#ifndef __ASM_SYSTEM_H
#define __ASM_SYSTEM_H
-#include <xen/lib.h>
#include <xen/bitops.h>
+#include <xen/bug.h>
#include <asm/cpufeature.h>
#include <asm/x86-defns.h>
diff --git a/xen/arch/x86/include/asm/x86_64/page.h b/xen/arch/x86/include/asm/x86_64/page.h
index f49e10475f..19ca64d792 100644
--- a/xen/arch/x86/include/asm/x86_64/page.h
+++ b/xen/arch/x86/include/asm/x86_64/page.h
@@ -19,6 +19,8 @@ static inline unsigned long canonicalise_addr(unsigned long addr)
return addr & ~CANONICAL_MASK;
}
+#include <xen/bug.h>
+
#include <xen/types.h>
#include <xen/pdx.h>
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 33f2870508..0fa26ba00a 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -8,6 +8,7 @@
#ifdef __XEN__
+# include <xen/bug.h>
# include <xen/kernel.h>
# include <asm/endbr.h>
# include <asm/msr-index.h>
diff --git a/xen/common/efi/common-stub.c b/xen/common/efi/common-stub.c
index 5a91fe28cc..77f138a6c5 100644
--- a/xen/common/efi/common-stub.c
+++ b/xen/common/efi/common-stub.c
@@ -1,6 +1,6 @@
+#include <xen/bug.h>
#include <xen/efi.h>
#include <xen/errno.h>
-#include <xen/lib.h>
bool efi_enabled(unsigned int feature)
{
diff --git a/xen/common/version.c b/xen/common/version.c
index e807ef4de0..80869430fc 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -1,3 +1,4 @@
+#include <xen/bug.h>
#include <xen/compile.h>
#include <xen/init.h>
#include <xen/errno.h>
diff --git a/xen/include/public/hvm/save.h b/xen/include/public/hvm/save.h
index ff0048e5f8..5561495b27 100644
--- a/xen/include/public/hvm/save.h
+++ b/xen/include/public/hvm/save.h
@@ -51,7 +51,7 @@ struct hvm_save_descriptor {
struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char cpt[2];}; \
struct __HVM_SAVE_TYPE_COMPAT_##_x { _ctype t; }
-# include <xen/lib.h> /* BUG() */
+# include <xen/bug.h> /* BUG() */
# define DECLARE_HVM_SAVE_TYPE(_x, _code, _type) \
static inline int __HVM_SAVE_FIX_COMPAT_##_x(void *h, uint32_t size) \
{ BUG(); return -1; } \
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index 4bd0be5088..7c150b7032 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -16,6 +16,7 @@
#ifndef __ASSEMBLY__
+#include <xen/compiler.h>
#include <xen/macros.h>
#include <xen/types.h>
@@ -127,6 +128,24 @@ static void always_inline run_in_exception_handler(
} while ( false )
#endif
+#define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0)
+#define WARN_ON(p) ({ \
+ bool ret_warn_on_ = (p); \
+ \
+ if ( unlikely(ret_warn_on_) ) \
+ WARN(); \
+ unlikely(ret_warn_on_); \
+})
+
+#ifndef NDEBUG
+#define ASSERT(p) \
+ do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
+#define ASSERT_UNREACHABLE() assert_failed("unreachable")
+#else
+#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
+#define ASSERT_UNREACHABLE() do { } while (0)
+#endif
+
#ifdef CONFIG_GENERIC_BUG_FRAME
/*
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 145e140481..46e75d54ba 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -55,6 +55,7 @@
* for_each_present_cpu(cpu) for-loop cpu over cpu_present_map
*/
+#include <xen/bug.h>
#include <xen/bitmap.h>
#include <xen/kernel.h>
#include <xen/random.h>
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 94a836cb4e..6fe2fa8b21 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -14,6 +14,7 @@
#include <asm/device.h>
#include <public/xen.h>
#include <public/device_tree_defs.h>
+#include <xen/bug.h>
#include <xen/kernel.h>
#include <xen/string.h>
#include <xen/types.h>
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 1793be5b6b..4c755cc275 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -5,31 +5,12 @@
#ifndef __ASSEMBLY__
-#include <xen/bug.h>
#include <xen/inttypes.h>
#include <xen/stdarg.h>
#include <xen/types.h>
#include <xen/xmalloc.h>
#include <xen/string.h>
-#define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0)
-#define WARN_ON(p) ({ \
- bool ret_warn_on_ = (p); \
- \
- if ( unlikely(ret_warn_on_) ) \
- WARN(); \
- unlikely(ret_warn_on_); \
-})
-
-#ifndef NDEBUG
-#define ASSERT(p) \
- do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
-#define ASSERT_UNREACHABLE() assert_failed("unreachable")
-#else
-#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
-#define ASSERT_UNREACHABLE() do { } while (0)
-#endif
-
#define __ACCESS_ONCE(x) ({ \
(void)(typeof(x))0; /* Scalar typecheck. */ \
(volatile typeof(x) *)&(x); })
diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h
index dc5a8c461b..b5eab3a1eb 100644
--- a/xen/include/xen/list.h
+++ b/xen/include/xen/list.h
@@ -7,7 +7,7 @@
#ifndef __XEN_LIST_H__
#define __XEN_LIST_H__
-#include <xen/lib.h>
+#include <xen/bug.h>
#include <asm/system.h>
/*
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index 45df4bba4f..ad0eae28bd 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -18,6 +18,8 @@ struct xen_sysctl_livepatch_op;
#ifdef CONFIG_LIVEPATCH
+#include <xen/lib.h>
+
/*
* We use alternative and exception table code - which by default are __init
* only, however we need them during runtime. These macros allows us to build
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3d9b2d05a5..bb29b352ec 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -61,6 +61,7 @@
#ifndef __XEN_MM_H__
#define __XEN_MM_H__
+#include <xen/bug.h>
#include <xen/compiler.h>
#include <xen/mm-frame.h>
#include <xen/types.h>
diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 9170455cde..d8471ffe18 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -1,6 +1,7 @@
#ifndef _XEN_PARAM_H
#define _XEN_PARAM_H
+#include <xen/bug.h>
#include <xen/hypfs.h>
#include <xen/init.h>
#include <xen/lib.h>
diff --git a/xen/lib/list-sort.c b/xen/lib/list-sort.c
index de1af2ef8b..251764804c 100644
--- a/xen/lib/list-sort.c
+++ b/xen/lib/list-sort.c
@@ -15,6 +15,7 @@
* this program; If not, see <http://www.gnu.org/licenses/>.
*/
+#include <xen/lib.h>
#include <xen/list.h>
#include <xen/list_sort.h>
diff --git a/xen/xsm/flask/ss/ebitmap.h b/xen/xsm/flask/ss/ebitmap.h
index bb43de891d..7b2da8179a 100644
--- a/xen/xsm/flask/ss/ebitmap.h
+++ b/xen/xsm/flask/ss/ebitmap.h
@@ -15,6 +15,7 @@
#define _SS_EBITMAP_H_
#include <xen/bitmap.h>
+#include <xen/bug.h>
#define EBITMAP_UNIT_NUMS ((32 - sizeof(void *) - sizeof(u32)) \
/ sizeof(unsigned long))
--
2.43.0
On 2/2/24 13:03, Oleksii Kurochko wrote: > Move the macros mentioned in the commit subject to their appropriate > locations. > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > Most of the changes were made because a file requires macros from xen/bug.h, > except for some files for Arm which require definitions of BUG_OPCODE, > BUG_INSTR, BUG_FN_REG. > > xen/lib.h was added to list-sort.c ( otherwise compilation errors related > to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was > removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h > functionality and only xen/bug.h is needed. > > cpufeature.h requires the inclusion of <xen/cache.h>; > otherwise, the following error will occur: > ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > multiple definitions of `__cacheline_aligned'; > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > --- <snip/> > diff --git a/xen/xsm/flask/ss/ebitmap.h b/xen/xsm/flask/ss/ebitmap.h > index bb43de891d..7b2da8179a 100644 > --- a/xen/xsm/flask/ss/ebitmap.h > +++ b/xen/xsm/flask/ss/ebitmap.h > @@ -15,6 +15,7 @@ > #define _SS_EBITMAP_H_ > > #include <xen/bitmap.h> > +#include <xen/bug.h> > > #define EBITMAP_UNIT_NUMS ((32 - sizeof(void *) - sizeof(u32)) \ > / sizeof(unsigned long)) Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Hello Shawn, Could you please take a look at the patch and PPC-related changes in xen/arch/ppc/include/asm/time.h ? Thanks in advance. ~ Oleksii On Fri, 2024-02-02 at 20:03 +0200, Oleksii Kurochko wrote: > Move the macros mentioned in the commit subject to their appropriate > locations. > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h > and > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > Most of the changes were made because a file requires macros from > xen/bug.h, > except for some files for Arm which require definitions of > BUG_OPCODE, > BUG_INSTR, BUG_FN_REG. > > xen/lib.h was added to list-sort.c ( otherwise compilation errors > related > to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h > was > removed from xen/list.h. Since nothing in xen/list.h depends on > xen/lib.h > functionality and only xen/bug.h is needed. > > cpufeature.h requires the inclusion of <xen/cache.h>; > otherwise, the following error will occur: > ld: > common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > multiple definitions of `__cacheline_aligned'; > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > --- > xen/arch/arm/arm32/insn.c | 3 ++- > xen/arch/arm/arm64/cpufeature.c | 1 + > xen/arch/arm/arm64/insn.c | 1 + > xen/arch/arm/cpufeature.c | 1 + > xen/arch/arm/include/asm/arm32/cmpxchg.h | 1 + > xen/arch/arm/include/asm/arm64/cmpxchg.h | 2 ++ > xen/arch/arm/include/asm/regs.h | 2 +- > xen/arch/arm/include/asm/vgic.h | 1 + > xen/arch/ppc/include/asm/time.h | 2 +- > xen/arch/x86/bitops.c | 2 +- > xen/arch/x86/include/asm/cpufeature.h | 1 + > xen/arch/x86/include/asm/system.h | 2 +- > xen/arch/x86/include/asm/x86_64/page.h | 2 ++ > xen/arch/x86/x86_emulate/private.h | 1 + > xen/common/efi/common-stub.c | 2 +- > xen/common/version.c | 1 + > xen/include/public/hvm/save.h | 2 +- > xen/include/xen/bug.h | 19 +++++++++++++++++++ > xen/include/xen/cpumask.h | 1 + > xen/include/xen/device_tree.h | 1 + > xen/include/xen/lib.h | 19 ------------------- > xen/include/xen/list.h | 2 +- > xen/include/xen/livepatch.h | 2 ++ > xen/include/xen/mm.h | 1 + > xen/include/xen/param.h | 1 + > xen/lib/list-sort.c | 1 + > xen/xsm/flask/ss/ebitmap.h | 1 + > 27 files changed, 48 insertions(+), 27 deletions(-) > > diff --git a/xen/arch/arm/arm32/insn.c b/xen/arch/arm/arm32/insn.c > index 49953a042a..2a62bb9cce 100644 > --- a/xen/arch/arm/arm32/insn.c > +++ b/xen/arch/arm/arm32/insn.c > @@ -13,8 +13,9 @@ > * You should have received a copy of the GNU General Public > License > * along with this program. If not, see > <http://www.gnu.org/licenses/>. > */ > -#include <xen/lib.h> > #include <xen/bitops.h> > +#include <xen/bug.h> > +#include <xen/lib.h> > #include <xen/sizes.h> > #include <asm/insn.h> > > diff --git a/xen/arch/arm/arm64/cpufeature.c > b/xen/arch/arm/arm64/cpufeature.c > index b4656ff4d8..864413d9cc 100644 > --- a/xen/arch/arm/arm64/cpufeature.c > +++ b/xen/arch/arm/arm64/cpufeature.c > @@ -69,6 +69,7 @@ > * KVM guests. > */ > > +#include <xen/bug.h> > #include <xen/types.h> > #include <xen/kernel.h> > #include <asm/sysregs.h> > diff --git a/xen/arch/arm/arm64/insn.c b/xen/arch/arm/arm64/insn.c > index 22f2bdebd5..773c3749d1 100644 > --- a/xen/arch/arm/arm64/insn.c > +++ b/xen/arch/arm/arm64/insn.c > @@ -18,6 +18,7 @@ > * You should have received a copy of the GNU General Public License > * along with this program. If not, see > <http://www.gnu.org/licenses/>. > */ > +#include <xen/bug.h> > #include <xen/types.h> > #include <xen/lib.h> > #include <xen/errno.h> > diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c > index f43d5cb338..ef77473bf8 100644 > --- a/xen/arch/arm/cpufeature.c > +++ b/xen/arch/arm/cpufeature.c > @@ -5,6 +5,7 @@ > * Copyright (C) 2015 ARM Ltd. > */ > > +#include <xen/bug.h> > #include <xen/types.h> > #include <xen/init.h> > #include <xen/smp.h> > diff --git a/xen/arch/arm/include/asm/arm32/cmpxchg.h > b/xen/arch/arm/include/asm/arm32/cmpxchg.h > index 37b2d64eb6..8455eb7cc3 100644 > --- a/xen/arch/arm/include/asm/arm32/cmpxchg.h > +++ b/xen/arch/arm/include/asm/arm32/cmpxchg.h > @@ -1,6 +1,7 @@ > #ifndef __ASM_ARM32_CMPXCHG_H > #define __ASM_ARM32_CMPXCHG_H > > +#include <xen/bug.h> > #include <xen/prefetch.h> > > extern void __bad_xchg(volatile void *ptr, int size); > diff --git a/xen/arch/arm/include/asm/arm64/cmpxchg.h > b/xen/arch/arm/include/asm/arm64/cmpxchg.h > index 031fa6d92a..f160e8e7bc 100644 > --- a/xen/arch/arm/include/asm/arm64/cmpxchg.h > +++ b/xen/arch/arm/include/asm/arm64/cmpxchg.h > @@ -1,6 +1,8 @@ > #ifndef __ASM_ARM64_CMPXCHG_H > #define __ASM_ARM64_CMPXCHG_H > > +#include <xen/bug.h> > + > extern void __bad_xchg(volatile void *ptr, int size); > > static inline unsigned long __xchg(unsigned long x, volatile void > *ptr, int size) > diff --git a/xen/arch/arm/include/asm/regs.h > b/xen/arch/arm/include/asm/regs.h > index f998aedff5..0d9f239a77 100644 > --- a/xen/arch/arm/include/asm/regs.h > +++ b/xen/arch/arm/include/asm/regs.h > @@ -5,7 +5,7 @@ > > #ifndef __ASSEMBLY__ > > -#include <xen/lib.h> > +#include <xen/bug.h> > #include <xen/types.h> > #include <public/xen.h> > #include <asm/current.h> > diff --git a/xen/arch/arm/include/asm/vgic.h > b/xen/arch/arm/include/asm/vgic.h > index 922779ce14..79b73a0dbb 100644 > --- a/xen/arch/arm/include/asm/vgic.h > +++ b/xen/arch/arm/include/asm/vgic.h > @@ -22,6 +22,7 @@ > #include <asm/new_vgic.h> > #else > > +#include <xen/bug.h> > #include <xen/radix-tree.h> > #include <xen/rbtree.h> > > diff --git a/xen/arch/ppc/include/asm/time.h > b/xen/arch/ppc/include/asm/time.h > index aa9dda82a3..f23eec173e 100644 > --- a/xen/arch/ppc/include/asm/time.h > +++ b/xen/arch/ppc/include/asm/time.h > @@ -2,7 +2,7 @@ > #ifndef __ASM_PPC_TIME_H__ > #define __ASM_PPC_TIME_H__ > > -#include <xen/lib.h> > +#include <xen/bug.h> > #include <asm/processor.h> > #include <asm/regs.h> > > diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c > index f6ee71512c..720ab32362 100644 > --- a/xen/arch/x86/bitops.c > +++ b/xen/arch/x86/bitops.c > @@ -1,6 +1,6 @@ > > #include <xen/bitops.h> > -#include <xen/lib.h> > +#include <xen/bug.h> > > unsigned int __find_first_bit( > const unsigned long *addr, unsigned int size) > diff --git a/xen/arch/x86/include/asm/cpufeature.h > b/xen/arch/x86/include/asm/cpufeature.h > index 896483a900..be16492c68 100644 > --- a/xen/arch/x86/include/asm/cpufeature.h > +++ b/xen/arch/x86/include/asm/cpufeature.h > @@ -6,6 +6,7 @@ > #ifndef __ASM_I386_CPUFEATURE_H > #define __ASM_I386_CPUFEATURE_H > > +#include <xen/cache.h> > #include <xen/const.h> > #include <asm/cpuid.h> > > diff --git a/xen/arch/x86/include/asm/system.h > b/xen/arch/x86/include/asm/system.h > index 6e40a03cb3..debf6bfa17 100644 > --- a/xen/arch/x86/include/asm/system.h > +++ b/xen/arch/x86/include/asm/system.h > @@ -1,8 +1,8 @@ > #ifndef __ASM_SYSTEM_H > #define __ASM_SYSTEM_H > > -#include <xen/lib.h> > #include <xen/bitops.h> > +#include <xen/bug.h> > #include <asm/cpufeature.h> > #include <asm/x86-defns.h> > > diff --git a/xen/arch/x86/include/asm/x86_64/page.h > b/xen/arch/x86/include/asm/x86_64/page.h > index f49e10475f..19ca64d792 100644 > --- a/xen/arch/x86/include/asm/x86_64/page.h > +++ b/xen/arch/x86/include/asm/x86_64/page.h > @@ -19,6 +19,8 @@ static inline unsigned long > canonicalise_addr(unsigned long addr) > return addr & ~CANONICAL_MASK; > } > > +#include <xen/bug.h> > + > #include <xen/types.h> > > #include <xen/pdx.h> > diff --git a/xen/arch/x86/x86_emulate/private.h > b/xen/arch/x86/x86_emulate/private.h > index 33f2870508..0fa26ba00a 100644 > --- a/xen/arch/x86/x86_emulate/private.h > +++ b/xen/arch/x86/x86_emulate/private.h > @@ -8,6 +8,7 @@ > > #ifdef __XEN__ > > +# include <xen/bug.h> > # include <xen/kernel.h> > # include <asm/endbr.h> > # include <asm/msr-index.h> > diff --git a/xen/common/efi/common-stub.c b/xen/common/efi/common- > stub.c > index 5a91fe28cc..77f138a6c5 100644 > --- a/xen/common/efi/common-stub.c > +++ b/xen/common/efi/common-stub.c > @@ -1,6 +1,6 @@ > +#include <xen/bug.h> > #include <xen/efi.h> > #include <xen/errno.h> > -#include <xen/lib.h> > > bool efi_enabled(unsigned int feature) > { > diff --git a/xen/common/version.c b/xen/common/version.c > index e807ef4de0..80869430fc 100644 > --- a/xen/common/version.c > +++ b/xen/common/version.c > @@ -1,3 +1,4 @@ > +#include <xen/bug.h> > #include <xen/compile.h> > #include <xen/init.h> > #include <xen/errno.h> > diff --git a/xen/include/public/hvm/save.h > b/xen/include/public/hvm/save.h > index ff0048e5f8..5561495b27 100644 > --- a/xen/include/public/hvm/save.h > +++ b/xen/include/public/hvm/save.h > @@ -51,7 +51,7 @@ struct hvm_save_descriptor { > struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char > cpt[2];}; \ > struct __HVM_SAVE_TYPE_COMPAT_##_x { _ctype t; } > > -# include <xen/lib.h> /* BUG() */ > +# include <xen/bug.h> /* BUG() */ > # define DECLARE_HVM_SAVE_TYPE(_x, _code, > _type) \ > static inline int __HVM_SAVE_FIX_COMPAT_##_x(void *h, uint32_t > size) \ > { BUG(); return -1; > } \ > diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h > index 4bd0be5088..7c150b7032 100644 > --- a/xen/include/xen/bug.h > +++ b/xen/include/xen/bug.h > @@ -16,6 +16,7 @@ > > #ifndef __ASSEMBLY__ > > +#include <xen/compiler.h> > #include <xen/macros.h> > #include <xen/types.h> > > @@ -127,6 +128,24 @@ static void always_inline > run_in_exception_handler( > } while ( false ) > #endif > > +#define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) > +#define WARN_ON(p) ({ \ > + bool ret_warn_on_ = (p); \ > + \ > + if ( unlikely(ret_warn_on_) ) \ > + WARN(); \ > + unlikely(ret_warn_on_); \ > +}) > + > +#ifndef NDEBUG > +#define ASSERT(p) \ > + do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) > +#define ASSERT_UNREACHABLE() assert_failed("unreachable") > +#else > +#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0) > +#define ASSERT_UNREACHABLE() do { } while (0) > +#endif > + > #ifdef CONFIG_GENERIC_BUG_FRAME > > /* > diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h > index 145e140481..46e75d54ba 100644 > --- a/xen/include/xen/cpumask.h > +++ b/xen/include/xen/cpumask.h > @@ -55,6 +55,7 @@ > * for_each_present_cpu(cpu) for-loop cpu over > cpu_present_map > */ > > +#include <xen/bug.h> > #include <xen/bitmap.h> > #include <xen/kernel.h> > #include <xen/random.h> > diff --git a/xen/include/xen/device_tree.h > b/xen/include/xen/device_tree.h > index 94a836cb4e..6fe2fa8b21 100644 > --- a/xen/include/xen/device_tree.h > +++ b/xen/include/xen/device_tree.h > @@ -14,6 +14,7 @@ > #include <asm/device.h> > #include <public/xen.h> > #include <public/device_tree_defs.h> > +#include <xen/bug.h> > #include <xen/kernel.h> > #include <xen/string.h> > #include <xen/types.h> > diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h > index 1793be5b6b..4c755cc275 100644 > --- a/xen/include/xen/lib.h > +++ b/xen/include/xen/lib.h > @@ -5,31 +5,12 @@ > > #ifndef __ASSEMBLY__ > > -#include <xen/bug.h> > #include <xen/inttypes.h> > #include <xen/stdarg.h> > #include <xen/types.h> > #include <xen/xmalloc.h> > #include <xen/string.h> > > -#define BUG_ON(p) do { if (unlikely(p)) BUG(); } while (0) > -#define WARN_ON(p) ({ \ > - bool ret_warn_on_ = (p); \ > - \ > - if ( unlikely(ret_warn_on_) ) \ > - WARN(); \ > - unlikely(ret_warn_on_); \ > -}) > - > -#ifndef NDEBUG > -#define ASSERT(p) \ > - do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) > -#define ASSERT_UNREACHABLE() assert_failed("unreachable") > -#else > -#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0) > -#define ASSERT_UNREACHABLE() do { } while (0) > -#endif > - > #define __ACCESS_ONCE(x) ({ \ > (void)(typeof(x))0; /* Scalar typecheck. */ \ > (volatile typeof(x) *)&(x); }) > diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h > index dc5a8c461b..b5eab3a1eb 100644 > --- a/xen/include/xen/list.h > +++ b/xen/include/xen/list.h > @@ -7,7 +7,7 @@ > #ifndef __XEN_LIST_H__ > #define __XEN_LIST_H__ > > -#include <xen/lib.h> > +#include <xen/bug.h> > #include <asm/system.h> > > /* > diff --git a/xen/include/xen/livepatch.h > b/xen/include/xen/livepatch.h > index 45df4bba4f..ad0eae28bd 100644 > --- a/xen/include/xen/livepatch.h > +++ b/xen/include/xen/livepatch.h > @@ -18,6 +18,8 @@ struct xen_sysctl_livepatch_op; > > #ifdef CONFIG_LIVEPATCH > > +#include <xen/lib.h> > + > /* > * We use alternative and exception table code - which by default > are __init > * only, however we need them during runtime. These macros allows us > to build > diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h > index 3d9b2d05a5..bb29b352ec 100644 > --- a/xen/include/xen/mm.h > +++ b/xen/include/xen/mm.h > @@ -61,6 +61,7 @@ > #ifndef __XEN_MM_H__ > #define __XEN_MM_H__ > > +#include <xen/bug.h> > #include <xen/compiler.h> > #include <xen/mm-frame.h> > #include <xen/types.h> > diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h > index 9170455cde..d8471ffe18 100644 > --- a/xen/include/xen/param.h > +++ b/xen/include/xen/param.h > @@ -1,6 +1,7 @@ > #ifndef _XEN_PARAM_H > #define _XEN_PARAM_H > > +#include <xen/bug.h> > #include <xen/hypfs.h> > #include <xen/init.h> > #include <xen/lib.h> > diff --git a/xen/lib/list-sort.c b/xen/lib/list-sort.c > index de1af2ef8b..251764804c 100644 > --- a/xen/lib/list-sort.c > +++ b/xen/lib/list-sort.c > @@ -15,6 +15,7 @@ > * this program; If not, see <http://www.gnu.org/licenses/>. > */ > > +#include <xen/lib.h> > #include <xen/list.h> > #include <xen/list_sort.h> > > diff --git a/xen/xsm/flask/ss/ebitmap.h b/xen/xsm/flask/ss/ebitmap.h > index bb43de891d..7b2da8179a 100644 > --- a/xen/xsm/flask/ss/ebitmap.h > +++ b/xen/xsm/flask/ss/ebitmap.h > @@ -15,6 +15,7 @@ > #define _SS_EBITMAP_H_ > > #include <xen/bitmap.h> > +#include <xen/bug.h> > > #define EBITMAP_UNIT_NUMS ((32 - sizeof(void *) - > sizeof(u32)) \ > / sizeof(unsigned long))
Hi Oleksii, On 02/02/2024 18:03, Oleksii Kurochko wrote: > Move the macros mentioned in the commit subject to their appropriate > locations. > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > Most of the changes were made because a file requires macros from xen/bug.h, > except for some files for Arm which require definitions of BUG_OPCODE, > BUG_INSTR, BUG_FN_REG. > > xen/lib.h was added to list-sort.c ( otherwise compilation errors related > to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was > removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h > functionality and only xen/bug.h is needed. > > cpufeature.h requires the inclusion of <xen/cache.h>; > otherwise, the following error will occur: > ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > multiple definitions of `__cacheline_aligned'; > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Julien Grall <jgrall@amazon.com> Cheers, -- Julien Grall
On Thu, 2024-02-08 at 21:30 +0000, Julien Grall wrote: > Hi Oleksii, Hi Julien, > > On 02/02/2024 18:03, Oleksii Kurochko wrote: > > Move the macros mentioned in the commit subject to their > > appropriate > > locations. > > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h > > and > > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > > > Most of the changes were made because a file requires macros from > > xen/bug.h, > > except for some files for Arm which require definitions of > > BUG_OPCODE, > > BUG_INSTR, BUG_FN_REG. > > > > xen/lib.h was added to list-sort.c ( otherwise compilation errors > > related > > to {d}printk occur during compilation of list-sort.c. ) as > > xen/lib.h was > > removed from xen/list.h. Since nothing in xen/list.h depends on > > xen/lib.h > > functionality and only xen/bug.h is needed. > > > > cpufeature.h requires the inclusion of <xen/cache.h>; > > otherwise, the following error will occur: > > ld: > > common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > > multiple definitions of `__cacheline_aligned'; > > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > Acked-by: Julien Grall <jgrall@amazon.com> Thanks. ~ Oleksii
On 02.02.2024 19:03, Oleksii Kurochko wrote: > Move the macros mentioned in the commit subject to their appropriate > locations. > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > Most of the changes were made because a file requires macros from xen/bug.h, > except for some files for Arm which require definitions of BUG_OPCODE, > BUG_INSTR, BUG_FN_REG. > > xen/lib.h was added to list-sort.c ( otherwise compilation errors related > to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was > removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h > functionality and only xen/bug.h is needed. > > cpufeature.h requires the inclusion of <xen/cache.h>; > otherwise, the following error will occur: > ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > multiple definitions of `__cacheline_aligned'; > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com> with one nit: > --- a/xen/include/xen/cpumask.h > +++ b/xen/include/xen/cpumask.h > @@ -55,6 +55,7 @@ > * for_each_present_cpu(cpu) for-loop cpu over cpu_present_map > */ > > +#include <xen/bug.h> > #include <xen/bitmap.h> > #include <xen/kernel.h> > #include <xen/random.h> I think everywhere else you nicely inserted new #include-s so respect alphabetical ordering, just here the insertion would want to move one line down. Likely easy to do while committing, if no other reason for a v2 arises ... Jan
On Thu, 2024-02-08 at 17:42 +0100, Jan Beulich wrote: > On 02.02.2024 19:03, Oleksii Kurochko wrote: > > Move the macros mentioned in the commit subject to their > > appropriate > > locations. > > Additionally, eliminate the dependency of xen/lib.h from xen/bug.h > > and > > include "xen/bug.h" in files where xen/bug.h macros are utilized. > > > > Most of the changes were made because a file requires macros from > > xen/bug.h, > > except for some files for Arm which require definitions of > > BUG_OPCODE, > > BUG_INSTR, BUG_FN_REG. > > > > xen/lib.h was added to list-sort.c ( otherwise compilation errors > > related > > to {d}printk occur during compilation of list-sort.c. ) as > > xen/lib.h was > > removed from xen/list.h. Since nothing in xen/list.h depends on > > xen/lib.h > > functionality and only xen/bug.h is needed. > > > > cpufeature.h requires the inclusion of <xen/cache.h>; > > otherwise, the following error will occur: > > ld: > > common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41: > > multiple definitions of `__cacheline_aligned'; > > > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> > > Acked-by: Jan Beulich <jbeulich@suse.com> > with one nit: > > > --- a/xen/include/xen/cpumask.h > > +++ b/xen/include/xen/cpumask.h > > @@ -55,6 +55,7 @@ > > * for_each_present_cpu(cpu) for-loop cpu over > > cpu_present_map > > */ > > > > +#include <xen/bug.h> > > #include <xen/bitmap.h> > > #include <xen/kernel.h> > > #include <xen/random.h> > > I think everywhere else you nicely inserted new #include-s so respect > alphabetical ordering, just here the insertion would want to move one > line down. Likely easy to do while committing, if no other reason for > a v2 arises ... I'll be happy if it can be done during committing. Thanks.
© 2016 - 2024 Red Hat, Inc.