introduce generic implementation of macros from bug.h
v8 cover introduce generic implementation of macros from bug.h
A large part of the content of the bug.h is repeated among all architectures (especially x86 and RISCV have the same implementation), so it was created a new config CONFIG_GENERIC_BUG_FRAME which is used to introduce generic implementation of do_bug_frame() and move x86's <asm/bug.h> to <xen/common/...> with the following changes:
* Add inclusion of arch-specific header <asm/bug.h>
* Rename the guard and remove x86 specific changes
* Wrap macros BUG_FRAME/run_in_exception_handler/WARN/BUG/assert_failed/etc into #ifndef "BUG_FRAME/run_in_exception_handler/WARN/BUG/assert_failed/etc" thereby each architecture can override the generic implementation of macros.
* Add #if{n}def __ASSEMBLY__ ... #endif
* Introduce BUG_FRAME_STRUCTURE define to be able to change the structure of bug frame
* Introduce BUG_INSTR and BUG_ASM_CONST to make _ASM_BUGFRAME_TEXT reusable between architectures
* Introduce BUG_DEBUGGER_TRAP_FATAL to hide details about TRAP_invalid_op for specific architecture
* Introduce BUILD_BUG_ON_LINE_WIDTH(line) to make more generic BUG_FRAME macros
* Make macros related to bug frame structure more generic.
RISC-V will be switched to use <xen/bug.h> and in the future, it will use common the version of do_bug_frame() when xen/common will work for RISC-V.
---
Changes in V8:
* move BUILD_BUG_ON_LINE_WIDTH(line) to "ifndef BUG_FRAME_STRUCT" and add #elif for "ifndef BUG_FRAME_STRUCT" to define stub for BUILD_BUG_ON_LINE_WIDTH.
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue ( more details in the changes to the patch [xen/x86: switch x86 to use generic implemetation of bug.h] ).
* remove <asm/bug.h> from <x86/acpi/cpufreq/cpufreq.c> and <drivers/cpufreq/cpufreq.c> as nothing from <xen/bug.h> are used in <*/cpufreq.c>
* Rebase the patch series on the top of the latest staging: it was a merge conflict inisde x86/Kconfig.
---
Changes in V7:
* Introduce new patch to clean up ARM's <asm/bug.h> from unused defines:
BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH
* fix addressed code style.
* Remove '#include <xen/debugger.h>' from bug.c. it should be a part
of <asm/bug.h>. * move BUILD_BUG_ON_LINE_WIDTH to '#ifndef BUG_FRAME_STRUCT' and define dummy BUILD_BUG_ON_LINE_WIDTH when BUG_FRAME_STRUCT is defined. * remove update prototype of 'void (*fn)(const struct cpu_user_regs *)' to 'void (*fn)(struct cpu_user_regs *)'.
* add code to to make sure the type used in run_in_exception_handler() matches the one used here.
* Remove #undef {BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH} from ARM and x86:
- for ARM was created separate patch where the defines are removed as unused.
- for x86, the defines were removed now not to produce #undef of them to remove
them again in the following-up patch
* make eip 'const void *' in x86's do_invalid_op()
* change [eip = (unsigned char *)eip + sizeof(bug_insn);] to [eip += sizeof(bug_insn);]
* add '#include <xen/debugger.h>' to x86's <asm/bug.h>
---
Changes in V6:
* Update the cover letter message: add information that BUG_DEBUGGER_TRAP_FATAL() and BUILD_BUG_ON_LINE_WIDTH().
* Introduce BUILD_BUG_ON_LINE_WIDTH(line) to make more generic BUG_FRAME macros.
* fix addressed code style
* change -EINVAL to -ENOENT in case when bug_frame wasn't found in generic do_bug_frame().
* change all 'return id' to 'break' inside switch/case of do_bug_frame().
* move up "#ifndef __ASSEMBLY__" to include BUG_DEBUGGER_TRAP_FATAL.
* update the comment of BUG_ASM_CONST.
* Introduce BUILD_BUG_ON_LINE_WIDTH(line) to make more generic BUG_FRAME macros
* remove #ifndef BUG_FRAME_STRUCT around BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH as it is required to be defined before <asm/bug.h> as it is used by x86's <asm/bug.h> when the header is included in assembly code.
* add undef of BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH for ARM & x86
as they were introduced unconditionally in <xen/bug.h>.
* update the type of eip to 'void *' in do_invalid_op() for x86
* fix the logic of do_invalid_op() for x86
* move macros BUG_DEBUGGER_TRAP_FATAL under #ifndef __ASSEMBLY__ as
it is not necessary to be in assembly code for x86.
---
Changes in V5:
* Update the cover letter message as the patch, on which the patch series
is based, has been merged to staging.
* Remove "#ifdef BUG_FN_REG..." from generic do_bug_frame() as ARM will
use generic implementation fully.
---
Changes in V4:
* Introduce and use generic BUG_DEBUGGER_TRAP_FATAL(regs) mnacros which is used to deal with debugger_trap_fatal(TRAP_invalid_op, regs) where TRAP_invalid_op is x86-specific.
* Add comment what do_bug_frame() returns.
* Do refactoring of do_bug_frame():
* invert the condition 'if ( region )' in do_bug_frame() to reduce the indention.
* change type of variable i from 'unsigned int' to 'size_t' as it is compared with n_bugs which has type 'size_t'
* Remove '#include <xen/stringify.h>' from <xen/bug.h> as it doesn't need any more after switch to x86 implementation.
* Remove '#include <xen/errno.h>' as it isn't needed any more
* Move bug_*() macros inside '#ifndef BUG_FRAME_STRUCT'
* Add <xen/lib.h> to fix compile issue with BUILD_ON()...
* Add documentation for BUG_ASM_CONST.
* Defines BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH were moved into "ifndef BUG_FRAME_STRUCT" in <xen/bug.h> as they are specific for 'struct bug_frame' and so should co-exist together. So the defines were back to <asm/bug.h> until BUG_FRAME_STRUCT will be defined in
<asm/bug.h>.
* Switch ARM implementation to generic one
* Remove BUG_FN_REG from arm{16,32}/bug.h as it isn't needed after switch to generic implementation
* Back comment /* !__ASSEMBLY__ */ for #else case in <asm/bug.h>
* Remove changes related to x86/.../asm/debuger.h as do_bug_frame() prototype was updated and cpu_user_regs isn't const any more.
---
Changes in V3:
* Nothing was done with the comment in <xen/bug.h> before run_in_exception_handler
but I think it can be changed during the merge.
* Add debugger_trap_fatal() to do_bug_frame(). It simplifies usage of
do_bug_frame() for x86 so making handle_bug_frame() and find_bug_frame()
not needed anymore.
* Update do_bug_frame() to return -EINVAL if something goes wrong; otherwise
id of bug_frame
* Update _ASM_BUGFRAME_TEXT to make it more portable.
* Drop unnecessary comments.
* Update patch 2 not to break compilation: move some parts from patches 3 and 4
to patch 2
* As prototype and what do_bug_frame() returns was changed so patch 3 and 4
was updated to use a new version of do_bug_frame
* Change debugger_trap_fatal() prototype for x86 to align with prototype in
<xen/debugger.h>
---
Changes in V2:
* Update cover letter.
* Switch to x86 implementation as generic as it is more compact ( at least from the point of view of bug frame structure).
* Put [PATCH v1 4/4] xen: change <asm/bug.h> to <xen/bug.h> as second patch,
update the patch to change all <asm/bug.h> to <xen/bug.h> among the whole project
to not break compilation.
* Rename CONFIG_GENERIC_DO_BUG_FRAME to CONFIG_GENERIC_BUG_FRAME.
* Change the macro bug_loc(b) to avoid the need for a cast:
#define bug_loc(b) ((unsigned long)(b) + (b)->loc_disp)
* Rename BUG_FRAME_STUFF to BUG_FRAME_STRUCT
* Make macros related to bug frame structure more generic.
* Rename bug_file() in ARM implementation to bug_ptr() as generic do_bug_frame() uses
bug_ptr().
* Introduce BUG_INSTR and MODIFIER to make _ASM_BUGFRAME_TEXT reusable between x86 and
RISC-V. * Rework do_invalid_op() in x86 ( re-use handle_bug_frame() and find_bug_frame() )
---
Oleksii Kurochko (5):
xen: introduce CONFIG_GENERIC_BUG_FRAME
xen/arm: remove unused defines in <asm/bug.h>
xen: change <asm/bug.h> to <xen/bug.h>
xen/arm: switch ARM to use generic implementation of bug.h xen/x86: switch x86 to use generic implemetation of bug.h
xen/arch/arm/Kconfig | 1 + xen/arch/arm/arm32/traps.c | 2 +- xen/arch/arm/include/asm/arm32/bug.h | 2 - xen/arch/arm/include/asm/arm64/bug.h | 2 - xen/arch/arm/include/asm/bug.h | 88 +-------------- xen/arch/arm/include/asm/div64.h | 2 +- xen/arch/arm/include/asm/traps.h | 2 - xen/arch/arm/traps.c | 81 +------------- xen/arch/arm/vgic/vgic-v2.c | 2 +- xen/arch/arm/vgic/vgic.c | 2 +- xen/arch/x86/Kconfig | 1 + xen/arch/x86/acpi/cpufreq/cpufreq.c | 1 - xen/arch/x86/include/asm/asm_defns.h | 2 +- xen/arch/x86/include/asm/bug.h | 84 +------------- xen/arch/x86/traps.c | 81 ++------------ xen/common/Kconfig | 3 + xen/common/Makefile | 1 + xen/common/bug.c | 108 ++++++++++++++++++ xen/drivers/cpufreq/cpufreq.c | 1 - xen/include/xen/bug.h | 161 +++++++++++++++++++++++++++ xen/include/xen/lib.h | 2 +- 21 files changed, 296 insertions(+), 333 deletions(-) create mode 100644 xen/common/bug.c create mode 100644 xen/include/xen/bug.h
Signature · 1 line
2.39.2
PATCH v8 2/5 xen/arm: remove unused defines in <asm/bug.h>
The following defines BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH aren't used in ARM so could be purged as unused.
---
Changes in V8:
* Update the commit message with Requested-by and Reviewed-by
--- xen/arch/arm/include/asm/bug.h | 4 ---- 1 file changed, 4 deletions(-)
xen/arch/arm/include/asm/bug.h +0 -4
@@ -9,10 +9,6 @@# error "unknown ARM variant"#endif -#define BUG_DISP_WIDTH 24 -#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) -#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) -struct bug_frame {signed int loc_disp;/* Relative address to the bug address */ signed int file_disp;/* Relative address to the filename */
Signature · 1 line
2.39.2
PATCH v8 3/5 xen: change <asm/bug.h> to <xen/bug.h>
In reply to Oleksii KurochkoThe idea of the patch is to change all <asm/bug.h> to <xen/bug.h> and keep Xen compilable with adding only minimal amount of changes:
1. It was added "#include <xen/types.h>" to ARM's "<asm/bug.h>" as it uses uint_{16,32}t in 'struct bug_frame'.
2. It was added '#define BUG_FRAME_STRUCT' which means that ARM hasn't been switched to generic implementation yet.
3. It was added '#define BUG_FRAME_STRUCT' which means that x86 hasn't been switched to generic implementation yet.
4. BUGFRAME_* and _start_bug_frame[], _stop_bug_frame_*[] were removed for ARM & x86 to deal with compilation errors such as:
redundant redeclaration of ...
5. Remove BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH from x86's <asm.bug.h> to not to produce #undef for them and #define again with the same values as in <xen/bug.h>. These #undef and #define will be anyway removed in the patch [2]
6. Remove <asm/bug.h> from <x86/acpi/cpufreq/cpufreq.c> and <drivers/cpufreq/cpufreq.c> as nothing from <xen/bug.h> are used in <*/cpufreq.c>
In the following two patches x86 and ARM archictectures will be switched fully:
[1] xen/arm: switch ARM to use generic implementation of bug.h
[2] xen/x86: switch x86 to use generic implemetation of bug.h
---
Changes in V8:
* remove <asm/bug.h> from <x86/acpi/cpufreq/cpufreq.c> and
<drivers/cpufreq/cpufreq.c> as nothing from <xen/bug.h> are used in
<*/cpufreq.c>
* update the commit message
---
Changes in V7:
* Remove #undef {BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH} from
ARM and x86:
* for ARM was created separate patch where the defines are removed as
unused.
* for x86, the defines were removed now not to produce #undef of them to remove
them again in the following-up patch
* Update commit message
* Add Reviewed-by: Jan Beulich <[email protected]>
---
Changes in V6:
- change the inclusion order of <xen/bug.h>.
- add #undef of BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH for ARM & x86
as they were introduced unconditionally in <xen/bug.h>.
- update the commit message
---
Changes in V5:
- Nothing changed
---
Changes in V4:
- defines BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH, BUG_LINE_HI_WIDTH were moved into "ifndef BUG_FRAME_STRUCT" in <xen/bug.h> as they are specific for 'struct bug_frame' and so should co-exist together. So the defines were back to <asm/bug.h> until BUG_FRAME_STRUCT will be defined in <asm/bug.h>.
- Update the comment message.
---
Changes in V3:
* Update patch 2 not to break compilation: move some parts from patches 3 and 4
to patch 2:
* move some generic parts from <asm/bug.h> to <xen/bug.h>
* add define BUG_FRAME_STRUCT in ARM's <asm/bug.h>
---
Changes in V2:
* Put [PATCH v1 4/4] xen: change <asm/bug.h> to <xen/bug.h> as second patch,
update the patch to change all <asm/bug.h> to <xen/bug.h> among the whole project
to not break build.
* Update the commit message.
--- xen/arch/arm/include/asm/bug.h | 17 ++++------------- xen/arch/arm/include/asm/div64.h | 2 +- xen/arch/arm/vgic/vgic-v2.c | 2 +- xen/arch/arm/vgic/vgic.c | 2 +- xen/arch/x86/acpi/cpufreq/cpufreq.c | 1 - xen/arch/x86/include/asm/asm_defns.h | 2 +- xen/arch/x86/include/asm/bug.h | 19 ++----------------- xen/drivers/cpufreq/cpufreq.c | 1 - xen/include/xen/lib.h | 2 +- 9 files changed, 11 insertions(+), 37 deletions(-)
xen/arch/arm/include/asm/bug.h +4 -13
@@ -1,6 +1,8 @@#ifndef __ARM_BUG_H__#define __ARM_BUG_H__ +#include <xen/types.h> +#if defined(CONFIG_ARM_32 )# include <asm/arm32/bug.h> #elif defined(CONFIG_ARM_64 )
@@ -9,6 +11,8 @@# error "unknown ARM variant"#endif +#define BUG_FRAME_STRUCT +struct bug_frame {signed int loc_disp;/* Relative address to the bug address */ signed int file_disp;/* Relative address to the filename */
@@ -22,13 +26,6 @@ struct bug_frame {#define bug_line (b) ((b)->line)#define bug_msg (b) ((const char *)(b) + (b)->msg_disp) -#define BUGFRAME_run_fn 0 -#define BUGFRAME_warn 1 -#define BUGFRAME_bug 2 -#define BUGFRAME_assert 3 - -#define BUGFRAME_NR 4 -/* Many versions of GCC doesn't support the asm %c parameter which would * be preferable to this unpleasantness. We use mergeable string * sections to avoid multiple copies of the string appearing in the
@@ -85,12 +82,6 @@ struct bug_frame {unreachable (); \ } while (0) -extern const struct bug_frame __start_bug_frames[], - __stop_bug_frames_0[], - __stop_bug_frames_1[], - __stop_bug_frames_2[], - __stop_bug_frames_3[]; -#endif /* __ARM_BUG_H__ */ /* * Local variables:
xen/arch/arm/include/asm/div64.h +1 -1
@@ -74,7 +74,7 @@#elif __GNUC__ >=4 -#include <asm/bug.h> +#include <xen/bug.h> /* * If the divisor happens to be constant, we determine the appropriate
xen/arch/arm/vgic/vgic-v2.c +1 -1
@@ -16,8 +16,8 @@*/ #include <asm/new_vgic.h> -#include <asm/bug.h> #include <asm/gic.h> +#include <xen/bug.h> #include <xen/sched.h> #include <xen/sizes.h>
xen/arch/arm/vgic/vgic.c +1 -1
@@ -15,9 +15,9 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <xen/bug.h> #include <xen/list_sort.h> #include <xen/sched.h> -#include <asm/bug.h> #include <asm/event.h> #include <asm/new_vgic.h>
xen/arch/x86/acpi/cpufreq/cpufreq.c +0 -1
@@ -35,7 +35,6 @@#include <xen/sched.h> #include <xen/timer.h> #include <xen/xmalloc.h> -#include <asm/bug.h> #include <asm/msr.h> #include <asm/io.h> #include <asm/processor.h>
xen/arch/x86/include/asm/asm_defns.h +1 -1
@@ -6,8 +6,8 @@/* NB. Auto-generated from arch/.../asm-offsets.c */ #include <asm/asm-offsets.h> #endif -#include <asm/bug.h> #include <asm/x86-defns.h> +#include <xen/bug.h> #include <xen/stringify.h> #include <asm/cpufeature.h> #include <asm/alternative.h>
xen/arch/x86/include/asm/bug.h +2 -17
@@ -1,19 +1,10 @@ #ifndef __X86_BUG_H__ #define __X86_BUG_H__ -#define BUG_DISP_WIDTH 24 -#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) -#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) - -#define BUGFRAME_run_fn 0 -#define BUGFRAME_warn 1 -#define BUGFRAME_bug 2 -#define BUGFRAME_assert 3 - -#define BUGFRAME_NR 4 - #ifndef __ASSEMBLY__ +#define BUG_FRAME_STRUCT + struct bug_frame { signed int loc_disp:BUG_DISP_WIDTH; unsigned int line_hi:BUG_LINE_HI_WIDTH;
@@ -80,12 +71,6 @@ struct bug_frame {unreachable (); \ } while (0) -extern const struct bug_frame __start_bug_frames[], - __stop_bug_frames_0[], - __stop_bug_frames_1[], - __stop_bug_frames_2[], - __stop_bug_frames_3[]; -#else /* !__ASSEMBLY__ */ /*
xen/drivers/cpufreq/cpufreq.c +0 -1
@@ -39,7 +39,6 @@#include <xen/guest_access.h> #include <xen/domain.h> #include <xen/cpu.h> -#include <asm/bug.h> #include <asm/io.h> #include <asm/processor.h>
xen/include/xen/lib.h +1 -1
@@ -24,12 +24,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> -#include <asm/bug.h> #define BUG_ON (p) do { if (unlikely(p)) BUG(); } while (0)#define WARN_ON (p) ({ \
Signature · 1 line
2.39.2
PATCH v8 5/5 xen/x86: switch x86 to use generic implemetation of bug.h
In reply to Oleksii KurochkoThe following changes were made:
* Make GENERIC_BUG_FRAME mandatory for X86
* Update asm/bug.h using generic implementation in <xen/bug.h>
* Update do_invalid_op using generic do_bug_frame()
* Define BUG_DEBUGGER_TRAP_FATAL to debugger_trap_fatal(X86_EXC_GP,regs)
* type of eip variable was changed to 'const void *'
* add '#include <xen/debugger.h>'
---
Changes in V8:
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue. The following compilation issue occurs:
In file included from ./arch/x86/include/asm/smp.h:10,
from ./include/xen/smp.h:4,
from ./arch/x86/include/asm/processor.h:10,
from ./arch/x86/include/asm/system.h:6,
from ./arch/x86/include/asm/atomic.h:5,
from ./include/xen/gdbstub.h:24,
from ./arch/x86/include/asm/debugger.h:10,
from ./include/xen/debugger.h:24,
from ./arch/x86/include/asm/bug.h:7,
from ./include/xen/bug.h:15,
from ./include/xen/lib.h:27,
from ./include/xen/perfc.h:6,
from arch/x86/x86_64/asm-offsets.c:9:
./include/xen/cpumask.h: In function 'cpumask_check':
./include/xen/cpumask.h:84:9: error: implicit declaration of function 'ASSERT' [-Werror=implicit-function-declaration]
84 | ASSERT(cpu < nr_cpu_ids); It happens in case when CONFIG_CRASH_DEBUG is enabled and the reason for that is when <xen/lib.h> is included in <x86_64/asm-offsets.c>:9 the "layout" of <xen/lib.h> would be the following:
#include <xen/bug.h>:
#include <asm/bug.h>:
#include <xen/debugger.h>:
....
cpumask.h:
....
ASSERT(cpu < nr_cpu_ids);
return cpu;
....
....
#define ASSERT ...
.... Thereby ASSERT is defined after it was used in <xen/cpumask.h>.
* Rebase the patch series on the top of the latest staging: it was a merge conflict inisde x86/Kconfig.
---
Changes in V7:
* update the commit message
* make eip 'const void *'
* change [eip = (unsigned char *)eip + sizeof(bug_insn);] to [eip += sizeof(bug_insn);]
* add '#include <xen/debugger.h>' to <asm/bug.h>
* add Reviewed-by: Jan Beulich <[email protected]>
---
Changes in V6:
* update the commit message
* update the type of eip to 'void *' in do_invalid_op()
* fix the logic of do_invalid_op()
* move macros BUG_DEBUGGER_TRAP_FATAL under #ifndef __ASSEMBLY__ as
it is not necessary to be in assembly code.
---
Changes in V5:
* Nothing changed
---
Changes in V4:
* Back comment /* !__ASSEMBLY__ */ for #else case in <asm/bug.h>
* Remove changes related to x86/.../asm/debuger.h as do_bug_frame() prototype was updated and cpu_user_regs isn't const any more.
---
Changes in V3:
* As prototype and what do_bug_frame() returns was changed so patch 3 and 4 was updated to use a new version of do_bug_frame
* MODIFIER was change to BUG_ASM_CONST to align with generic implementation
---
Changes in V2:
* Remove all unnecessary things from <asm/bug.h> as they were introduced in
<xen/bug.h>.
* Define BUG_INSTR = 'ud2' and MODIFIER = 'c' ( it is needed to skip '$'
when use an imidiate in x86 assembly )
* Update do_invalid_op() to re-use handle_bug_frame() and find_bug_frame()
from generic implemetation of CONFIG_GENERIC_BUG_FRAME
* Code style fixes.
---
xen/arch/x86/Kconfig | 1 +
xen/arch/x86/include/asm/bug.h | 69 ++---------------------------
xen/arch/x86/traps.c | 81 ++++------------------------------
3 files changed, 12 insertions(+), 139 deletions(-)xen/arch/x86/Kconfig +1 -0
@@ -11,6 +11,7 @@ config X86 select ARCH_MAP_DOMAIN_PAGE select ARCH_SUPPORTS_INT128 imply CORE_PARKING + select GENERIC_BUG_FRAME select HAS_ALTERNATIVE select HAS_COMPAT select HAS_CPUFREQ
xen/arch/x86/include/asm/bug.h +3 -66
76 lines not on this page · raw message
xen/arch/x86/traps.c +8 -73
109 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v8 1/5 xen: introduce CONFIG_GENERIC_BUG_FRAME
In reply to Oleksii KurochkoA large part of the content of the bug.h is repeated among all architectures, so it was decided to create a new config CONFIG_GENERIC_BUG_FRAME.
The version of <bug.h> from x86 was taken as the base version.
The patch introduces the following stuff:
* common bug.h header
* generic implementation of do_bug_frame
* new config CONFIG_GENERIC_BUG_FRAME
---
Changes in V8:
* move BUILD_BUG_ON_LINE_WIDTH(line) to "ifndef BUG_FRAME_STRUCT" and add #elif for "ifndef BUG_FRAME_STRUCT" to define stub for BUILD_BUG_ON_LINE_WIDTH.
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue ( more details in the changes to the patch [xen/x86: switch x86 to use generic implemetation of bug.h] ).
---
Changes in V7:
* fix code style.
* Remove '#include <xen/debugger.h>' from bug.c. it should be a part of <asm/bug.h>.
* move BUILD_BUG_ON_LINE_WIDTH to '#ifndef BUG_FRAME_STRUCT' and define dummy BUILD_BUG_ON_LINE_WIDTH when BUG_FRAME_STRUCT is defined.
* remove update prototype of 'void (*fn)(const struct cpu_user_regs *)' to
'void (*fn)(struct cpu_user_regs *)'.
* add code to to make sure the type used in run_in_exception_handler()
matches the one used here.
---
Changes in V6:
* fix code style.
* change -EINVAL to -ENOENT in case when bug_frame wasn't found in
generic do_bug_frame()
* change all 'return id' to 'break' inside switch/case of generic do_bug_frame()
* move up "#ifndef __ASSEMBLY__" to include BUG_DEBUGGER_TRAP_FATAL
* update the comment of BUG_ASM_CONST
* make the line with 'BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH))' in BUG_FRAME macros more abstract
* remove #ifndef BUG_FRAME_STRUCT around BUG_DISP_WIDTH, BUG_LINE_LO_WIDTH as it is
required to be defined before <asm/bug.h> as it is used by x86's <asm/bug.h> when
the header is included in assembly code.
---
Changes in V5:
* Remove "#ifdef BUG_FN_REG..." from generic do_bug_frame() as ARM will
use generic implementation fully.
---
Changes in V4:
* common/bug.c:
- Use BUG_DEBUGGER_TRAP_FATAL(regs) mnacros instead of debugger_trap_fatal(TRAP_invalid_op, regs) in <common/bug.c> as TRAP_invalid_op is x86-specific thereby BUG_DEBUGGER_TRAP_FATAL should be defined for each architecture.
- add information about what do_bug_frame() returns.
- invert the condition 'if ( region )' in do_bug_frame() to reduce the indention.
- change type of variable i from 'unsigned int' to 'size_t' as it is compared with n_bugs which has type 'size_t'
* xen/bug.h:
- Introduce generic BUG_DEBUGGER_TRAP_FATAL(regs) mnacros which is used to deal with debugger_trap_fatal(TRAP_invalid_op, regs) where TRAP_invalid_op is x86-specific
- remove '#include <xen/stringify.h>' as it doesn't need any more after switch to x86 implementation.
- remove '#include <xen/errno.h>' as it isn't needed any more
- move bug_*() macros inside '#ifndef BUG_FRAME_STRUCT'
- add <xen/lib.h> to fix compile issue with BUILD_ON()...
- Add documentation for BUG_ASM_CONST.
* Update the commit message
---
Changes in V3:
* Add debugger_trap_fatal() to do_bug_frame(). It simplifies usage of do_bug_frame() for x86 so making handle_bug_frame() and find_bug_frame()
not needed anymore.
* Update do_bug_frame() to return -EINVAL if something goes wrong; otherwise
id of bug_frame
* Update _ASM_BUGFRAME_TEXT to make it more portable.
* Drop unnecessary comments.
* define stub value for TRAP_invalid_op in case if wasn't defined in
arch-specific folders.
---
Changes in V2:
- Switch to x86 implementation as generic as it is more compact
( at least from the point of view of bug frame structure ).
- Rename CONFIG_GENERIC_DO_BUG_FRAME to CONFIG_GENERIC_BUG_FRAME.
- Change the macro bug_loc(b) to avoid the need for a cast:
#define bug_loc(b) ((unsigned long)(b) + (b)->loc_disp)
- Rename BUG_FRAME_STUFF to BUG_FRAME_STRUCT
- Make macros related to bug frame structure more generic.
- Introduce BUG_INSTR and MODIFIER to make _ASM_BUGFRAME_TEXT reusable
between x86 and RISC-V.
- Rework do_bug_frame() and introduce find_bug_frame() and handle_bug_frame()
functions to make it reusable by x86.
- code style fixes
---
xen/common/Kconfig | 3 +
xen/common/Makefile | 1 +
xen/common/bug.c | 108 ++++++++++++++++++++++++++++
xen/include/xen/bug.h | 161 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 273 insertions(+)
create mode 100644 xen/common/bug.c
create mode 100644 xen/include/xen/bug.hxen/common/Kconfig +3 -0
@@ -29,6 +29,9 @@ config ALTERNATIVE_CALL config ARCH_MAP_DOMAIN_PAGE bool +config GENERIC_BUG_FRAME + bool + config HAS_ALTERNATIVE bool
xen/common/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_ARGO) += argo.o obj-y += bitmap.o +obj-$(CONFIG_GENERIC_BUG_FRAME) += bug.o obj-$(CONFIG_HYPFS_CONFIG) += config_data.o obj-$(CONFIG_CORE_PARKING) += core_parking.o obj-y += cpu.o
xen/common/bug.c new file +108 -0
108 lines not on this page · raw message
xen/include/xen/bug.h new file +161 -0
161 lines not on this page · raw message
Signature · 1 line
2.39.2
PATCH v8 4/5 xen/arm: switch ARM to use generic implementation of bug.h
In reply to Oleksii KurochkoThe following changes were made:
* make GENERIC_BUG_FRAME mandatory for ARM
* As do_bug_frame() returns -EINVAL in case something goes wrong otherwise id of bug frame. Thereby 'if' cases where do_bug_frame() was updated to check if the returned value is less than 0
* Switch ARM's implementation of bug.h macros to generic one
---
Changes in V8:
* Nothing changed.
---
Changes in V7:
* Rebase the patch.
---
Changes in V6:
* Update the "changes in v5"
* Rebase on top of the patch [xen: introduce CONFIG_GENERIC_BUG_FRAME] as
there were minor changes.
---
Changes in V5:
* common/bug.c changes were removed after rebase
(the patch [xen: introduce CONFIG_GENERIC_BUG_FRAME] was reworked to make
ARM implementation to use generic do_bug_frame())
---
Changes in V4:
* Switch ARM implementation to generic one
* Remove BUG_FN_REG from arm{16,32}/bug.h as it isn't needed after switch to generic implementation
* Update commit message
---
Changes in V3:
* As prototype and what do_bug_frame() returns was changed so patch 3 and 4
was updated to use a new version of do_bug_frame
---
Changes in V2:
* Rename bug_file() in ARM implementation to bug_ptr() as
generic do_bug_frame() uses bug_ptr().
* Remove generic parts from bug.h
* Remove declaration of 'int do_bug_frame(...)'
from <asm/traps.h> as it was introduced in <xen/bug.h>
--- xen/arch/arm/Kconfig | 1 + xen/arch/arm/arm32/traps.c | 2 +- xen/arch/arm/include/asm/arm32/bug.h | 2 - xen/arch/arm/include/asm/arm64/bug.h | 2 - xen/arch/arm/include/asm/bug.h | 71 +----------------------- xen/arch/arm/include/asm/traps.h | 2 - xen/arch/arm/traps.c | 81 +--------------------------- 7 files changed, 4 insertions(+), 157 deletions(-)
xen/arch/arm/Kconfig +1 -0
@@ -12,6 +12,7 @@ config ARM_64 config ARM def_bool y + select GENERIC_BUG_FRAME select HAS_ALTERNATIVE select HAS_DEVICE_TREE select HAS_PASSTHROUGH
xen/arch/arm/arm32/traps.c +1 -1
@@ -48,7 +48,7 @@ void do_trap_undefined_instruction(struct cpu_user_regs *regs)if ( instr !=BUG_OPCODE ) goto die; -if (do_bug_frame (regs, pc) ) +if (do_bug_frame (regs, pc) <0 ) goto die; regs->pc +=4 ;
xen/arch/arm/include/asm/arm32/bug.h +0 -2
@@ -10,6 +10,4 @@#define BUG_INSTR ".word " __stringify(BUG_OPCODE) -#define BUG_FN_REG r0 -#endif /* __ARM_ARM32_BUG_H__ */
xen/arch/arm/include/asm/arm64/bug.h +0 -2
@@ -6,6 +6,4 @@#define BUG_INSTR "brk " __stringify(BRK_BUG_FRAME_IMM) -#define BUG_FN_REG x0 -#endif /* __ARM_ARM64_BUG_H__ */
xen/arch/arm/include/asm/bug.h +1 -70
77 lines not on this page · raw message
xen/arch/arm/include/asm/traps.h +0 -2
@@ -69,8 +69,6 @@ void do_cp(struct cpu_user_regs *regs, const union hsr hsr);void do_trap_smc (struct cpu_user_regs *regs,const union hsr hsr);void do_trap_hvc_smccc (struct cpu_user_regs *regs); -int do_bug_frame (const struct cpu_user_regs *regs,vaddr_t pc); -void noreturndo_unexpected_trap (const char *msg,const struct cpu_user_regs *regs);void do_trap_hyp_sync (struct cpu_user_regs *regs);
xen/arch/arm/traps.c +1 -80
93 lines not on this page · raw message
Signature · 1 line
2.39.2
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
In reply to Oleksii KurochkoQuoted 14 lines · Oleksii Kurochko
The following changes were made:
* MakeGENERIC_BUG_FRAMEmandatory for X86
* Updateasm/bug.husing generic implementation in <xen/bug.h>
* Updatedo_invalid_opusing genericdo_bug_frame()
* DefineBUG_DEBUGGER_TRAP_FATALtodebugger_trap_fatal(X86_EXC_GP,regs)
* type of eip variable was changed to 'const void *'
* add '#include <xen/debugger.h>'Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
Changes in V8:
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue. The following compilation issue occurs:
Quoted 16 lines
In file included from ./arch/x86/include/asm/smp.h:10,
from ./include/xen/smp.h:4,
from ./arch/x86/include/asm/processor.h:10,
from ./arch/x86/include/asm/system.h:6,
from ./arch/x86/include/asm/atomic.h:5,
from ./include/xen/gdbstub.h:24,
from ./arch/x86/include/asm/debugger.h:10,
from ./include/xen/debugger.h:24,
from ./arch/x86/include/asm/bug.h:7,
from ./include/xen/bug.h:15,
from ./include/xen/lib.h:27,
from ./include/xen/perfc.h:6,
from arch/x86/x86_64/asm-offsets.c:9:
./include/xen/cpumask.h: In function 'cpumask_check':
./include/xen/cpumask.h:84:9: error: implicit declaration of function 'ASSERT' [-Werror=implicit-function-declaration]
84 | ASSERT(cpu < nr_cpu_ids);I'm going to post a patch to address this specific failure. But something similar may then surface elsewhere.
Quoted 1 line
It happens in case when
CONFIG_CRASH_DEBUGis enabled
I have to admit that I don't see the connection to CRASH_DEBUG: It's the asm/atomic.h inclusion that's problematic afaics, yet that (needlessly) happens outside the respective #ifdef in xen/gdbstub.h.
If another instance of this header interaction issue would surface despite my to-be-posted patch, I'd be okay with going this route for the moment. But I think the real issue here is xen/lib.h including xen/bug.h. Instead of that, some stuff that's presently in xen/lib.h should instead move to xen/bug.h, and the inclusion there be dropped. Any parties actually using stuff from xen/bug.h (xen/lib.h then won't anymore) should then include that header themselves.
Jan
Quoted 16 lines
and the reason for that is when
<xen/lib.h> is included in <x86_64/asm-offsets.c>:9 the "layout" of <xen/lib.h> would be the following:#include <xen/bug.h>: #include <asm/bug.h>: #include <xen/debugger.h>: .... cpumask.h: .... ASSERT(cpu < nr_cpu_ids); return cpu; .... .... #define ASSERT ... ....Thereby ASSERT is defined after it was used in <
xen/cpumask.h>.
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
In reply to Oleksii KurochkoQuoted 4 lines · Oleksii Kurochko
A large part of the content of the
bug.his repeated among all architectures, so it was decided to create a new configCONFIG_GENERIC_BUG_FRAME.
Quoted 8 lines
The version of <
bug.h> from x86 was taken as the base version.The patch introduces the following stuff:
* commonbug.hheader
* generic implementation ofdo_bug_frame
* new configCONFIG_GENERIC_BUG_FRAMESigned-off-by Oleksii Kurochko <[email protected]>
The patch looks good to me now, but as said in reply to patch 5 I'd like to ...
Quoted 7 lines
---
Changes in V8:
* moveBUILD_BUG_ON_LINE_WIDTH(line)to "ifndefBUG_FRAME_STRUCT" and add #elif for "ifndefBUG_FRAME_STRUCT" to define stub forBUILD_BUG_ON_LINE_WIDTH.
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue ( more details in the changes to the patch [xen/x86: switch x86 to use generic implemetation ofbug.h] ).
... get away without this, so for the moment I won't offer R-b just yet.
One further note on naming (sorry, could have occurred to me earlier):
Quoted 41 lines
xen/include/xen/bug.h new file +38
-0@@ -0,0 +1,161 @@ +#ifndef __XEN_BUG_H__ +#define __XEN_BUG_H__ + +#define BUGFRAME_run_fn 0 +#define BUGFRAME_warn 1 +#define BUGFRAME_bug 2 +#define BUGFRAME_assert 3 + +#define BUGFRAME_NR 4 + +#define BUG_DISP_WIDTH 24 +#define BUG_LINE_LO_WIDTH (31 - BUG_DISP_WIDTH) +#define BUG_LINE_HI_WIDTH (31 - BUG_DISP_WIDTH) + +#include <asm/bug.h> + +#ifndef __ASSEMBLY__ + +#ifndef BUG_DEBUGGER_TRAP_FATAL +#define BUG_DEBUGGER_TRAP_FATAL (regs) 0 +#endif + +#include <xen/lib.h> + +#ifndef BUG_FRAME_STRUCT + +struct bug_frame { +signed int loc_disp:BUG_DISP_WIDTH ; +unsigned int line_hi:BUG_LINE_HI_WIDTH ; +signed int ptr_disp:BUG_DISP_WIDTH ; +unsigned int line_lo:BUG_LINE_LO_WIDTH ; +signed int msg_disp[]; +}; + +#define bug_loc (b) ((unsigned long)(b) + (b)->loc_disp) + +#define bug_ptr (b) ((const void *)(b) + (b)->ptr_disp) +
xen/include/xen/bug.h line 48
Quoted 10 lines
xen/include/xen/bug.h new file +10
-0+#define bug_line (b) (((((b)->line_hi + ((b)->loc_disp < 0)) & \ + ((1 << BUG_LINE_HI_WIDTH) - 1)) << \ + BUG_LINE_LO_WIDTH) + \ + (((b)->line_lo + ((b)->ptr_disp < 0)) & \ + ((1 << BUG_LINE_LO_WIDTH) - 1))) + +#define bug_msg (b) ((const char *)(b) + (b)->msg_disp[1]) + +#define BUILD_BUG_ON_LINE_WIDTH (line) \ + BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH))
While this and ...
xen/include/xen/bug.h line 52
Quoted 3 lines
xen/include/xen/bug.h new file +3
-0+#elif !defined(BUILD_BUG_ON_LINE_WIDTH ) + +#define BUILD_BUG_ON_LINE_WIDTH (line) ((void)(line)
... this look okay-ish here, ...
Quoted 31 lines
xen/include/xen/bug.h new file +31
-0+#endif /* BUG_FRAME_STRUCT */ + + +/* +* Some architectures mark immediate instruction operands in a special way. +* In such cases the special marking may need omitting when specifying +* directive operands. Allow architectures to specify a suitable +* modifier. +*/ +#ifndef BUG_ASM_CONST +#define BUG_ASM_CONST "" +#endif + +#ifndef _ASM_BUGFRAME_TEXT + +#define _ASM_BUGFRAME_TEXT (second_frame) \ + ".Lbug%=:"BUG_INSTR"\n" \ + " .pushsection .bug_frames.%"BUG_ASM_CONST"[bf_type], \"a\", %%progbits\n" \ + " .p2align 2\n" \ + ".Lfrm%=:\n" \ + " .long (.Lbug%= - .Lfrm%=) + %"BUG_ASM_CONST"[bf_line_hi]\n" \ + " .long (%"BUG_ASM_CONST"[bf_ptr] - .Lfrm%=) + %"BUG_ASM_CONST"[bf_line_lo]\n"\ + " .if " #second_frame "\n" \ + " .long 0, %"BUG_ASM_CONST"[bf_msg] - .Lfrm%=\n" \ + " .endif\n" \ + " .popsection\n" + +#define _ASM_BUGFRAME_INFO (type, line, ptr, msg) \ + [bf_type] "i" (type), \ + [bf_ptr] "i" (ptr), \ + [bf_msg] "i" (msg), \
xen/include/xen/bug.h line 94
Quoted 10 lines
xen/include/xen/bug.h new file +10
-0+ [bf_line_lo] "i" ((line & ((1 << BUG_LINE_LO_WIDTH) - 1)) \ + << BUG_DISP_WIDTH), \ + [bf_line_hi] "i" (((line) >> BUG_LINE_LO_WIDTH) << BUG_DISP_WIDTH) + +#endif /* _ASM_BUGFRAME_TEXT */ + +#ifndef BUG_FRAME + +#define BUG_FRAME (type, line, ptr, second_frame, msg) do { \ + BUILD_BUG_ON_LINE_WIDTH(line); \
... the latest at the use site the naming is somewhat odd. I'm inclined to suggest something like BUG_CHECK_LINE_WIDTH() or BUG_CHECK_LINE(). Aiui the use of the name is isolated to this header, in which case making such an adjustment while committing would be feasible. If, of course, as per above no other need for a change arises (i.e. if in particular the xen/debugger.h inclusion cannot be moved back where it was).
Jan
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
In reply to Oleksii Kurochkoxen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h>
I actually meant to also ask: What is this needed for? Glancing over the code ...
Quoted 87 lines
xen/common/bug.c new file +87
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame (struct cpu_user_regs *regs,unsigned long pc) +{ +const struct bug_frame *bug =NULL ; +const struct virtual_region *region; +const char *prefix ="" , *filename, *predicate; +unsigned long fixup; +unsigned int id, lineno; + + region =find_text_region (pc); +if ( !region ) +return -EINVAL ; + +for ( id =0 ; id <BUGFRAME_NR ; id++ ) + { +const struct bug_frame *b; +size_t i; + +for ( i =0 , b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { +if (bug_loc (b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: +if ( !bug ) +return -ENOENT ; + +if ( id == BUGFRAME_run_fn ) + { +void (*fn)(struct cpu_user_regs *) =bug_ptr (bug); + +fn (regs); + +/* Re-enforce consistent types, because of the casts involved. */ +if ( false ) +run_in_exception_handler (fn); + +return id; + } + +/* WARN, BUG or ASSERT: decode the filename pointer and line number. */ + filename =bug_ptr (bug); +if ( !is_kernel (filename) && !is_patch (filename) ) +return -EINVAL ; + fixup =strlen (filename); +if ( fixup >50 ) + { + filename += fixup -47 ; + prefix ="..." ; + } + lineno =bug_line (bug); + +switch ( id ) + { +case BUGFRAME_warn: +printk ("Xen WARN at %s%s:%d\n" , prefix, filename, lineno); +show_execution_state (regs); + +break ; + +case BUGFRAME_bug: +printk ("Xen BUG at %s%s:%d\n" , prefix, filename, lineno); + +if (BUG_DEBUGGER_TRAP_FATAL (regs) ) +break ; + +show_execution_state (regs); +panic ("Xen BUG at %s%s:%d\n" , prefix, filename, lineno); + +case BUGFRAME_assert: +/* ASSERT: decode the predicate string pointer. */ + predicate =bug_msg (bug); +if ( !is_kernel (predicate) && !is_patch (predicate) ) + predicate ="<unknown>" ; + +printk ("Assertion '%s' failed at %s%s:%d\n" , + predicate, prefix, filename, lineno); +
xen/common/bug.c line 108
Quoted 10 lines
xen/common/bug.c new file +10
-0+if (BUG_DEBUGGER_TRAP_FATAL (regs) ) +break ; + +show_execution_state (regs); +panic ("Assertion '%s' failed at %s%s:%d\n" , + predicate, prefix, filename, lineno); + } + +return id; +}
... I can't really spot what it might be that comes from that header. Oh, on the N+1st run I've spotted it - it's show_execution_state(). The declaration of which, already being used from common code ahead of this series, should imo be moved to a common header. I guess I'll make yet another patch ...
Jan
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 116 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing over the
code ...Quoted 97 lines
xen/common/bug.c new file +43
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame (struct cpu_user_regs *regs,unsigned long pc) +{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the castsinvolved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer and linenumber. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);xen/common/bug.c new file +35
-0+ + switch ( id ) + { + case BUGFRAME_warn: + printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); + show_execution_state(regs); + + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate = bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate = "<unknown>"; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } +
Quoted 8 lines
Quoted 2 lines
+ return id;
+}... I can't really spot what it might be that comes from that header. Oh, on the N+1st run I've spotted it - it's
show_execution_state(). The declaration of which, already being used from common code ahead of this series, should imo be moved to a common header. I guess I'll make yet another patch ...
As mentioned above. Not only show_execution_state() but also cpu_user_regs structure. ( at lest, for ARM & RISCV )
~ Oleksii
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 125 lines · Oleksii
Quoted 116 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing over the
code ...Quoted 97 lines
xen/common/bug.c new file +43
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame (struct cpu_user_regs *regs,unsigned long pc) +{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the castsinvolved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer and linenumber. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);xen/common/bug.c new file +35
-0+ + switch ( id ) + { + case BUGFRAME_warn: + printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno); + show_execution_state(regs); + + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); + + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate = bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate = "<unknown>"; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } +Quoted 8 lines
Quoted 2 lines
+ return id;
+}... I can't really spot what it might be that comes from that header. Oh, on the N+1st run I've spotted it - it's
show_execution_state(). The declaration of which, already being used from common code ahead of this series, should imo be moved to a common header. I guess I'll make yet another patch ...
Quoted 2 lines
As mentioned above. Not only
show_execution_state()but alsocpu_user_regsstructure. ( at lest, for ARM & RISCV )
Do we deref "regs" anywhere? I can't seem to be able to spot an instance. Without a deref (or alike) a forward decl is all that's needed for this code to compile.
Jan
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 135 lines · Jan Beulich
Quoted 134 lines · Oleksii
Quoted 133 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing over
the
code ...Quoted 93 lines
xen/common/bug.c new file +43
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame (struct cpu_user_regs *regs,unsigned long pc) +{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the castsinvolved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer andline
number. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);
+
+ switch ( id )
+ {
+ caseBUGFRAME_warn:
+printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
+show_execution_state(regs);xen/common/bug.c new file +5
-0+ + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +6
-0+ + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +10
-0+ + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate = bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate = "<unknown>"; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); +xen/common/bug.c line 108
Quoted 10 lines
xen/common/bug.c new file +10
-0+ if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } + + return id; +}... I can't really spot what it might be that comes from that header.
Oh, on the N+1st run I've spotted it - it'sshow_execution_state().
The declaration of which, already being used from common code ahead
of this series, should imo be moved to a common header. I guess I'll
make yet another patch ...
Quoted 8 lines
Quoted 2 lines
As mentioned above. Not only
show_execution_state()but alsocpu_user_regsstructure. ( at lest, for ARM & RISCV )Do we deref "regs" anywhere? I can't seem to be able to spot an instance.
Without a deref (or alike) a forward decl is all that's needed for this
code to compile.
You are there is no a deref so let's swich to a forward decl.
I'll add it to a new version of the patch series.
~ Oleksii
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 140 lines · Oleksii
Quoted 139 lines · Jan Beulich
Quoted 137 lines · Oleksii
Quoted 126 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing over
the
code ...Quoted 94 lines
xen/common/bug.c new file +5
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame(struct cpu_user_regs *regs, unsigned longpc)
xen/common/bug.c new file +38
-0+{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the castsinvolved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer andline
number. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);
+
+ switch ( id )
+ {
+ caseBUGFRAME_warn:
+printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
+show_execution_state(regs);xen/common/bug.c new file +5
-0+ + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +6
-0+ + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +10
-0+ + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate = bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate = "<unknown>"; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); +xen/common/bug.c line 108
Quoted 10 lines
xen/common/bug.c new file +10
-0+ if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } + + return id; +}... I can't really spot what it might be that comes from that
Quoted 8 lines
header.
Oh, on the N+1st run I've spotted it - it'sshow_execution_state().
The declaration of which, already being used from common code ahead
of this series, should imo be moved to a common header. I guess I'll
make yet another patch ...As mentioned above. Not only
show_execution_state()but alsocpu_user_regsstructure. ( at lest, for ARM & RISCV )
Quoted 8 lines
Quoted 5 lines
Do we deref "regs" anywhere? I can't seem to be able to spot an instance.
Without a deref (or alike) a forward decl is all that's needed for this
code to compile.You are there is no a deref so let's swich to a forward decl.
I'll add it to a new version of the patch series.
I just realized that show_execution_state() is declared in <asm/processor.h>.
So we have to leave an inclusion of the header or declare the function explicitly.
~ Oleksii
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 146 lines · Oleksii
Quoted 145 lines · Oleksii
Quoted 144 lines · Jan Beulich
Quoted 135 lines · Oleksii
Quoted 126 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing over
the
code ...Quoted 94 lines
xen/common/bug.c new file +5
-0+/* +* Returns a negative value in case of an error otherwise +* BUGFRAME_{run_fn, warn, bug, assert} +*/ +int do_bug_frame(struct cpu_user_regs *regs, unsigned longpc)
xen/common/bug.c new file +38
-0+{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) = bug_ptr(bug); + + fn(regs); + + /* Re-enforce consistent types, because of the castsinvolved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointer andline
number. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);
+
+ switch ( id )
+ {
+ caseBUGFRAME_warn:
+printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
+show_execution_state(regs);xen/common/bug.c new file +5
-0+ + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +6
-0+ + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +10
-0+ + case BUGFRAME_assert: + /* ASSERT: decode the predicate string pointer. */ + predicate = bug_msg(bug); + if ( !is_kernel(predicate) && !is_patch(predicate) ) + predicate = "<unknown>"; + + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); +xen/common/bug.c line 108
Quoted 10 lines
xen/common/bug.c new file +10
-0+ if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } + + return id; +}... I can't really spot what it might be that comes from that
Quoted 8 lines
header.
Oh, on the N+1st run I've spotted it - it'sshow_execution_state().
The declaration of which, already being used from common code ahead
of this series, should imo be moved to a common header. I guess I'll
make yet another patch ...Quoted 2 lines
As mentioned above. Not only
show_execution_state()but alsocpu_user_regsstructure. ( at lest, for ARM & RISCV )Do we deref "regs" anywhere? I can't seem to be able to spot an instance.
Without a deref (or alike) a forward decl is all that's needed for this
code to compile.
Quoted 5 lines
Quoted 3 lines
You are there is no a deref so let's swich to a forward decl.
I'll add it to a new version of the patch series.
I just realized that
show_execution_state()is declared in <asm/processor.h>.
Not anymore with "move {,vcpu_}show_execution_state() declarations to common header", which was specifically made ...
Quoted 2 lines
So we have to leave an inclusion of the header or declare the function explicitly.
... to eliminate this dependency, but which sadly is still pending an Arm side ack.
Jan
Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Quoted 169 lines · Jan Beulich
Quoted 159 lines · Oleksii
Quoted 158 lines · Oleksii
Quoted 157 lines · Jan Beulich
Quoted 147 lines · Oleksii
Quoted 138 lines · Jan Beulich
xen/common/bug.c line 10
Quoted 13 lines · Oleksii Kurochko
xen/common/bug.c new file +10
-0@@ -0,0 +1,108 @@ +#include <xen/bug.h> +#include <xen/debugger.h> +#include <xen/errno.h> +#include <xen/kernel.h> +#include <xen/livepatch.h> +#include <xen/string.h> +#include <xen/types.h> +#include <xen/virtual_region.h> + +#include <asm/processor.h> I actually meant to also ask: What is this needed for? Glancing
over
the
code ...Quoted 102 lines
xen/common/bug.c new file +2
-0+/* +* Returns a negative value in case of an error otherwise
+ * BUGFRAME_{run_fn, warn, bug, assert}
+ */
+int do_bug_frame(structcpu_user_regs*regs, unsigned long
pc)xen/common/bug.c new file +34
-0+{ + const struct bug_frame *bug = NULL; + const struct virtual_region *region; + const char *prefix = "", *filename, *predicate; + unsigned long fixup; + unsigned int id, lineno; + + region = find_text_region(pc); + if ( !region ) + return -EINVAL; + + for ( id = 0; id < BUGFRAME_NR; id++ ) + { + const struct bug_frame *b; + size_t i; + + for ( i = 0, b = region->frame[id].bugs; + i < region->frame[id].n_bugs; b++, i++ ) + { + if ( bug_loc(b) == pc ) + { + bug = b; + goto found; + } + } + } + + found: + if ( !bug ) + return -ENOENT; + + if ( id == BUGFRAME_run_fn ) + { + void (*fn)(struct cpu_user_regs *) =
bug_ptr(bug);xen/common/bug.c new file +4
-0+ + fn(regs); + + /* Re-enforce consistent types, because of thecasts
involved. */
+ if ( false )
+run_in_exception_handler(fn);xen/common/bug.c new file +5
-0+ + return id; + } + + /* WARN, BUG or ASSERT: decode the filename pointerand
line
number. */
+ filename =bug_ptr(bug);
+ if ( !is_kernel(filename) && !is_patch(filename) ) + return-EINVAL;
+ fixup = strlen(filename);
+ if ( fixup > 50 )
+ {
+ filename += fixup - 47;
+ prefix = "...";
+ }
+ lineno =bug_line(bug);
+
+ switch ( id )
+ {
+ caseBUGFRAME_warn:
+ printk("Xen WARN at %s%s:%d\n", prefix, filename,
lineno);
+show_execution_state(regs);xen/common/bug.c new file +5
-0+ + break; + + case BUGFRAME_bug: + printk("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
xen/common/bug.c new file +6
-0+ + if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Xen BUG at %s%s:%d\n", prefix, filename,lineno);
+
+ caseBUGFRAME_assert:
+ /* ASSERT: decode the predicate string pointer. */
+ predicate =bug_msg(bug);
+ if ( !is_kernel(predicate) && !is_patch(predicate) )
+ predicate = "<unknown>";xen/common/bug.c new file +4
-0+ + printk("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); +xen/common/bug.c
Quoted 10 lines
xen/common/bug.c new file +10
-0+ if ( BUG_DEBUGGER_TRAP_FATAL(regs) ) + break; + + show_execution_state(regs); + panic("Assertion '%s' failed at %s%s:%d\n", + predicate, prefix, filename, lineno); + } + + return id; +}... I can't really spot what it might be that comes from that
header.
Oh, on the N+1st run I've spotted it - it'sQuoted 8 lines
show_execution_state().
The declaration of which, already being used from common code
ahead
of this series, should imo be moved to a common header. I guess
I'll
make yet another patch ...Quoted 2 lines
As mentioned above. Not only
show_execution_state()but alsocpu_user_regsstructure. ( at lest, for ARM & RISCV )Do we deref "regs" anywhere? I can't seem to be able to spot an instance.
Without a deref (or alike) a forward decl is all that's needed for
this
code to compile.Quoted 5 lines
Quoted 3 lines
You are there is no a deref so let's swich to a forward decl.
I'll add it to a new version of the patch series.
I just realized that
show_execution_state()is declared in <asm/processor.h>.Not anymore with "move {,vcpu_}show_execution_state() declarations to common header", which was specifically made ...
Quoted 6 lines
Quoted 3 lines
So we have to leave an inclusion of the header or declare the function
explicitly.... to eliminate this dependency, but which sadly is still pending an Arm side ack.
Oh, I forgot about that patch.
Then you are right there is no any sense in the inclusion of <asm/processor.h>.
~ Oleksii
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
In reply to Jan BeulichHello Jan,
Quoted 47 lines · Jan Beulich
Quoted 25 lines · Oleksii Kurochko
The following changes were made:
* MakeGENERIC_BUG_FRAMEmandatory for X86
* Updateasm/bug.husing generic implementation in <xen/bug.h>
* Updatedo_invalid_opusing genericdo_bug_frame()
* DefineBUG_DEBUGGER_TRAP_FATALtodebugger_trap_fatal(X86_EXC_GP,regs)
* type of eip variable was changed to 'const void *'
* add '#include <xen/debugger.h>'Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
Changes in V8:
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue.
The following compilation issue occurs:
In file included from./arch/x86/include/asm/smp.h:10, from./include/xen/smp.h:4,
from./arch/x86/include/asm/processor.h:10, from./arch/x86/include/asm/system.h:6, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24,
from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24,
from./arch/x86/include/asm/bug.h:7,Quoted 8 lines
from
./include/xen/bug.h:15,
from./include/xen/lib.h:27,
from./include/xen/perfc.h:6,
fromarch/x86/x86_64/asm-offsets.c:9:
./include/xen/cpumask.h: In function 'cpumask_check':
./include/xen/cpumask.h:84:9: error: implicit declaration of function 'ASSERT' [-Werror=implicit-function-declaration] 84 |ASSERT(cpu < nr_cpu_ids);I'm going to post a patch to address this specific failure. But something
similar may then surface elsewhere.Quoted 1 line
It happens in case when
CONFIG_CRASH_DEBUGis enabledI have to admit that I don't see the connection to
CRASH_DEBUG: It's theasm/atomic.hinclusion that's problematic afaics, yet that (needlessly)
happens outside the respective #ifdef inxen/gdbstub.h.
Quoted 13 lines
If another instance of this header interaction issue would surface despite
my to-be-posted patch, I'd be okay with going this route for the moment.
But I think the real issue here isxen/lib.hincludingxen/bug.h. Instead
of that, some stuff that's presently inxen/lib.hshould instead move toxen/bug.h, and the inclusion there be dropped. Any parties actually using
stuff fromxen/bug.h(xen/lib.hthen won't anymore) should then include
that header themselves.
As all your patches are in the staging.
Can I send a new patch vesrion with <asm/processor.h> removed in common/bug.c but leave <xen/debugger.h>?
Should I wait for xen/lib.h reworking?
Quoted 21 lines
Jan
Quoted 17 lines
and the reason for that is when
<xen/lib.h> is included in <x86_64/asm-offsets.c>:9 the "layout" of <xen/lib.h> would be
the following:
#include <xen/bug.h>:
#include <asm/bug.h>:
#include <xen/debugger.h>:
....
cpumask.h:
....
ASSERT(cpu < nr_cpu_ids);
return cpu;
....
....
#define ASSERT ...
....
Thereby ASSERT is defined after it was used in <xen/cpumask.h>.
~ Oleksii
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
Quoted 63 lines · Oleksii
Hello Jan,
Quoted 47 lines · Jan Beulich
Quoted 25 lines · Oleksii Kurochko
The following changes were made:
* MakeGENERIC_BUG_FRAMEmandatory for X86
* Updateasm/bug.husing generic implementation in <xen/bug.h>
* Updatedo_invalid_opusing genericdo_bug_frame()
* DefineBUG_DEBUGGER_TRAP_FATALtodebugger_trap_fatal(X86_EXC_GP,regs)
* type of eip variable was changed to 'const void *'
* add '#include <xen/debugger.h>'Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
Changes in V8:
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue.
The following compilation issue occurs:
In file included from./arch/x86/include/asm/smp.h:10, from./include/xen/smp.h:4,
from./arch/x86/include/asm/processor.h:10, from./arch/x86/include/asm/system.h:6, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24,
from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24,
from./arch/x86/include/asm/bug.h:7,Quoted 8 lines
from
./include/xen/bug.h:15,
from./include/xen/lib.h:27,
from./include/xen/perfc.h:6,
fromarch/x86/x86_64/asm-offsets.c:9:
./include/xen/cpumask.h: In function 'cpumask_check':
./include/xen/cpumask.h:84:9: error: implicit declaration of function 'ASSERT' [-Werror=implicit-function-declaration] 84 |ASSERT(cpu < nr_cpu_ids);I'm going to post a patch to address this specific failure. But something
similar may then surface elsewhere.Quoted 1 line
It happens in case when
CONFIG_CRASH_DEBUGis enabledI have to admit that I don't see the connection to
CRASH_DEBUG: It's theasm/atomic.hinclusion that's problematic afaics, yet that (needlessly)
happens outside the respective #ifdef inxen/gdbstub.h.Quoted 13 lines
If another instance of this header interaction issue would surface despite
my to-be-posted patch, I'd be okay with going this route for the moment.
But I think the real issue here isxen/lib.hincludingxen/bug.h. Instead
of that, some stuff that's presently inxen/lib.hshould instead move toxen/bug.h, and the inclusion there be dropped. Any parties actually using
stuff fromxen/bug.h(xen/lib.hthen won't anymore) should then include
that header themselves.
Quoted 4 lines
As all your patches are in the staging.
Can I send a new patch vesrion with <
asm/processor.h> removed incommon/bug.cbut leave <xen/debugger.h>?
If another variant of the build issue still exists, then you want to leave that as is, yes (but update the description to point out the new issue that makes this necessary).
Quoted 1 line
Should I wait for
xen/lib.hreworking?
No.
Jan
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
In reply to Jan BeulichQuoted 47 lines · Jan Beulich
Quoted 25 lines · Oleksii Kurochko
The following changes were made:
* MakeGENERIC_BUG_FRAMEmandatory for X86
* Updateasm/bug.husing generic implementation in <xen/bug.h>
* Updatedo_invalid_opusing genericdo_bug_frame()
* DefineBUG_DEBUGGER_TRAP_FATALtodebugger_trap_fatal(X86_EXC_GP,regs)
* type of eip variable was changed to 'const void *'
* add '#include <xen/debugger.h>'Signed-off-by Oleksii Kurochko <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
Changes in V8:
* move <xen/debuger.h> from <asm/bug.h> to <common/bug.c> to fix compilation issue.
The following compilation issue occurs:
In file included from./arch/x86/include/asm/smp.h:10, from./include/xen/smp.h:4,
from./arch/x86/include/asm/processor.h:10, from./arch/x86/include/asm/system.h:6, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24,
from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24,
from./arch/x86/include/asm/bug.h:7,Quoted 8 lines
from
./include/xen/bug.h:15,
from./include/xen/lib.h:27,
from./include/xen/perfc.h:6,
fromarch/x86/x86_64/asm-offsets.c:9:
./include/xen/cpumask.h: In function 'cpumask_check':
./include/xen/cpumask.h:84:9: error: implicit declaration of function 'ASSERT' [-Werror=implicit-function-declaration] 84 |ASSERT(cpu < nr_cpu_ids);I'm going to post a patch to address this specific failure. But something
similar may then surface elsewhere.Quoted 1 line
It happens in case when
CONFIG_CRASH_DEBUGis enabledI have to admit that I don't see the connection to
CRASH_DEBUG: It's theasm/atomic.hinclusion that's problematic afaics, yet that (needlessly)
happens outside the respective #ifdef inxen/gdbstub.h.
Quoted 13 lines
If another instance of this header interaction issue would surface despite
my to-be-posted patch, I'd be okay with going this route for the moment.
But I think the real issue here isxen/lib.hincludingxen/bug.h. Instead
of that, some stuff that's presently inxen/lib.hshould instead move toxen/bug.h, and the inclusion there be dropped. Any parties actually using
stuff fromxen/bug.h(xen/lib.hthen won't anymore) should then include
that header themselves.
I tried to remove dependency between xen/lib.h and xen/bug.h but it is still the same issue but for different compilation unit:
mmanual-endbr -fno-jump-tables '-D__OBJECT_LABEL__=asm-offsets.s' - mpreferred-stack-boundary=3 -S -g0 -o asm-offsets.s.new -MQ asm- offsets.s arch/x86/x86_64/asm-offsets.c
In file included from ./include/public/domctl.h:21,
from ./include/public/sysctl.h:18,
from ./arch/x86/include/asm/cpuid.h:14,
from ./arch/x86/include/asm/cpufeature.h:10,
from ./arch/x86/include/asm/system.h:7,
from ./arch/x86/include/asm/atomic.h:5,
from ./include/xen/gdbstub.h:24,
from ./arch/x86/include/asm/debugger.h:10,
from ./include/xen/debugger.h:24,
from ./arch/x86/include/asm/bug.h:6,
from ./include/xen/bug.h:15,
from ./arch/x86/include/asm/alternative.h:7,
from ./arch/x86/include/asm/bitops.h:8,
from ./include/xen/bitops.h:106,
from ./arch/x86/include/asm/smp.h:8,
from ./include/xen/smp.h:4,
from ./include/xen/perfc.h:7,
from arch/x86/x86_64/asm-offsets.c:9:~ Oleksii
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
Quoted 11 lines · Oleksii
offsets.s
arch/x86/x86_64/asm-offsets.c
In file included from./include/public/domctl.h:21, from./include/public/sysctl.h:18, from./arch/x86/include/asm/cpuid.h:14, from./arch/x86/include/asm/cpufeature.h:10, from./arch/x86/include/asm/system.h:7, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24, from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24, from./arch/x86/include/asm/bug.h:6,
Quoted 8 lines
from
./include/xen/bug.h:15,
from./arch/x86/include/asm/alternative.h:7, from./arch/x86/include/asm/bitops.h:8, from./include/xen/bitops.h:106, from./arch/x86/include/asm/smp.h:8, from./include/xen/smp.h:4,
from./include/xen/perfc.h:7,
fromarch/x86/x86_64/asm-offsets.c:9:
And again the problem is that x86's <asm/bug.h> includes <xen/debugger.h> which somewhere inside uses BUG() which will be defined after we will back for x86's <asm/bug.h> to <xen/bug.h> where BUG() is defined.
So it looks like we can't include to <asm/bug.h> something that will use functionality defined in <xen/bug.h>...
Thereby I don't see better option that include <xen/debugger.h> in <common/bug.c> instead of <asm/bug.h>
~ Oleksii
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
Quoted 25 lines · Oleksii
Quoted 11 lines · Oleksii
offsets.s
arch/x86/x86_64/asm-offsets.c
In file included from./include/public/domctl.h:21, from./include/public/sysctl.h:18, from./arch/x86/include/asm/cpuid.h:14, from./arch/x86/include/asm/cpufeature.h:10, from./arch/x86/include/asm/system.h:7, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24, from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24, from./arch/x86/include/asm/bug.h:6,Quoted 8 lines
from
./include/xen/bug.h:15,
from./arch/x86/include/asm/alternative.h:7, from./arch/x86/include/asm/bitops.h:8, from./include/xen/bitops.h:106, from./arch/x86/include/asm/smp.h:8, from./include/xen/smp.h:4,
from./include/xen/perfc.h:7,
fromarch/x86/x86_64/asm-offsets.c:9:And again the problem is that x86's <
asm/bug.h> includes <xen/debugger.h> which somewhere inside usesBUG()which will be defined after we will back for x86's <asm/bug.h> to <xen/bug.h> whereBUG()is defined.
Quoted 5 lines
So it looks like we can't include to <
asm/bug.h> something that will use functionality defined in <xen/bug.h>...Thereby I don't see better option that include <
xen/debugger.h> in <common/bug.c> instead of <asm/bug.h>
Or as an option we can include <xen/bug.h> in <asm/bug.h> instead of include <asm/bug.h> in <xen/bug.h> it will allow us to resolve an issue...
Do you think this option will be better?
~ Oleksii
Re: [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation of bug.h
Quoted 26 lines · Oleksii
Quoted 25 lines · Oleksii
Quoted 11 lines · Oleksii
offsets.s
arch/x86/x86_64/asm-offsets.c
In file included from./include/public/domctl.h:21, from./include/public/sysctl.h:18, from./arch/x86/include/asm/cpuid.h:14, from./arch/x86/include/asm/cpufeature.h:10, from./arch/x86/include/asm/system.h:7, from./arch/x86/include/asm/atomic.h:5, from./include/xen/gdbstub.h:24, from./arch/x86/include/asm/debugger.h:10, from./include/xen/debugger.h:24, from./arch/x86/include/asm/bug.h:6,Quoted 8 lines
from
./include/xen/bug.h:15,
from./arch/x86/include/asm/alternative.h:7, from./arch/x86/include/asm/bitops.h:8, from./include/xen/bitops.h:106, from./arch/x86/include/asm/smp.h:8, from./include/xen/smp.h:4,
from./include/xen/perfc.h:7,
fromarch/x86/x86_64/asm-offsets.c:9:And again the problem is that x86's <
asm/bug.h> includes <xen/debugger.h> which somewhere inside usesBUG()which will be defined after we will back for x86's <asm/bug.h> to <xen/bug.h> whereBUG()is defined.
Quoted 5 lines
Quoted 5 lines
So it looks like we can't include to <
asm/bug.h> something that will use functionality defined in <xen/bug.h>...Thereby I don't see better option that include <
xen/debugger.h> in <common/bug.c> instead of <asm/bug.h>
Well, to deal with this specific issue we could re-arrange xen/perfc.h a little (to skip part of it when COMPILE_OFFSETS is defined), but it seems quite likely that then the same issue would surface yet again elsewhere. So yes, for the time being I guess we need to go with what you have. Until we can sort the xen/lib.h vs xen/bug.h aspect.
Quoted 5 lines
Or as an option we can include <
xen/bug.h> in <asm/bug.h> instead of include <asm/bug.h> in <xen/bug.h> it will allow us to resolve an issue...Do you think this option will be better?
No, imo that arrangement should remain as is.
Jan