From: Jan Beulich <jbeulich@suse.com>
To: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Cc: Julien Grall <julien@xen.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Gianluca Guida <gianluca@rivosinc.com>,
George Dunlap <george.dunlap@citrix.com>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Date: Thu, 16 Mar 2023 12:26:23 +0100 [thread overview]
Message-ID: <3bc211fa-a8f7-70ce-bfa9-5e4380776070@suse.com> (raw)
In-Reply-To: <2afad972cd8da98dcb0ba509ba29ff239dc47cd0.1678900513.git.oleksii.kurochko@gmail.com>
On 15.03.2023 18:21, Oleksii Kurochko wrote:
> --- /dev/null
> +++ b/xen/common/bug.c
> @@ -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 ...
> +/*
> + * 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);
> +
> + 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
next prev parent reply other threads:[~2023-03-16 11:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 17:21 [PATCH v8 0/5] introduce generic implementation of macros from bug.h Oleksii Kurochko
2023-03-15 17:21 ` [PATCH v8 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME Oleksii Kurochko
2023-03-16 10:03 ` Jan Beulich
2023-03-16 11:26 ` Jan Beulich [this message]
2023-03-17 9:23 ` Oleksii
2023-03-17 14:59 ` Jan Beulich
2023-03-20 11:36 ` Oleksii
2023-03-21 11:18 ` Oleksii
2023-03-21 13:35 ` Jan Beulich
2023-03-21 14:44 ` Oleksii
2023-03-15 17:21 ` [PATCH v8 2/5] xen/arm: remove unused defines in <asm/bug.h> Oleksii Kurochko
2023-03-15 17:21 ` [PATCH v8 3/5] xen: change <asm/bug.h> to <xen/bug.h> Oleksii Kurochko
2023-03-15 17:21 ` [PATCH v8 4/5] xen/arm: switch ARM to use generic implementation of bug.h Oleksii Kurochko
2023-03-15 17:21 ` [PATCH v8 5/5] xen/x86: switch x86 to use generic implemetation " Oleksii Kurochko
2023-03-16 9:52 ` Jan Beulich
2023-03-27 16:10 ` Oleksii
2023-03-28 8:13 ` Jan Beulich
2023-03-28 15:38 ` Oleksii
2023-03-28 16:38 ` Oleksii
2023-03-28 16:55 ` Oleksii
2023-03-29 7:15 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3bc211fa-a8f7-70ce-bfa9-5e4380776070@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=gianluca@rivosinc.com \
--cc=julien@xen.org \
--cc=oleksii.kurochko@gmail.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).