From: Oleksii <oleksii.kurochko@gmail.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Jason Andryuk <jandryuk@gmail.com>, 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 v7 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME
Date: Tue, 14 Mar 2023 21:12:01 +0200 [thread overview]
Message-ID: <192fbcf22a6c6e16498cc208eeb37fc6e08ce56a.camel@gmail.com> (raw)
In-Reply-To: <3df43c25-6c06-0cbb-5452-c989511a7e15@suse.com>
On Mon, 2023-03-13 at 17:26 +0100, Jan Beulich wrote:
> On 09.03.2023 14:33, Oleksii Kurochko wrote:
> > --- /dev/null
> > +++ b/xen/common/bug.c
> > @@ -0,0 +1,107 @@
> > +#include <xen/bug.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>
> > +
> > +/*
> > + * 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 = BUGFRAME_NR, lineno;
>
> Unnecessary initializer; "id" is set ...
>
> > + region = find_text_region(pc);
> > + if ( !region )
> > + return -EINVAL;
> > +
> > + for ( id = 0; id < BUGFRAME_NR; id++ )
>
> ... unconditionally here.
>
> > --- /dev/null
> > +++ b/xen/include/xen/bug.h
> > @@ -0,0 +1,162 @@
> > +#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)
> > +
> > +#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])
> > +
> > +#ifndef BUILD_BUG_ON_LINE_WIDTH
> > +#define BUILD_BUG_ON_LINE_WIDTH(line) \
> > + BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH +
> > BUG_LINE_HI_WIDTH))
> > +#endif
>
> I still don't see why you have #ifdef here. What I would expect is
> (as
> expressed before)
>
> #define BUILD_BUG_ON_LINE_WIDTH(line) \
> BUILD_BUG_ON((line) >> (BUG_LINE_LO_WIDTH + BUG_LINE_HI_WIDTH))
>
> #else /* BUG_FRAME_STRUCT */
>
> #ifndef BUILD_BUG_ON_LINE_WIDTH
> #define BUILD_BUG_ON_LINE_WIDTH(line) ((void)(line)
> #endif
>
> (perhaps shortened to
>
> #elif !defined(BUILD_BUG_ON_LINE_WIDTH)
> #define BUILD_BUG_ON_LINE_WIDTH(line) ((void)(line)
>
> )
>
> > +#endif /* BUG_FRAME_STRUCT */
>
> ... and then the separate conditional further down dropped. Have you
> found anything speaking against this approach?
Both options are fine from compilation point of view.
Lets change it to proposed by you option with '#elif !defined(...)...'
I'll prepare new patch series and sent it to the mailing list.
I would like to add the changes from the [PATCH] xen/cpufreq: Remove
<asm/bug.h> by Jason Andryuk <jandryuk@gmail.com> but I don't know how
correctly do that. I mean should I added one more Signed-off to the
patch?
Thanks.
~ Oleksii
next prev parent reply other threads:[~2023-03-14 19:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 13:33 [PATCH v7 0/5] introduce generic implementation of macros from bug.h Oleksii Kurochko
2023-03-09 13:33 ` [PATCH v7 1/5] xen: introduce CONFIG_GENERIC_BUG_FRAME Oleksii Kurochko
2023-03-13 16:26 ` Jan Beulich
2023-03-14 19:12 ` Oleksii [this message]
2023-03-14 19:17 ` Jason Andryuk
2023-03-15 7:11 ` Jan Beulich
2023-03-09 13:33 ` [PATCH v7 2/5] xen/arm: remove unused defines in <asm/bug.h> Oleksii Kurochko
2023-03-09 14:22 ` Jan Beulich
2023-03-09 13:33 ` [PATCH v7 3/5] xen: change <asm/bug.h> to <xen/bug.h> Oleksii Kurochko
2023-03-09 13:33 ` [PATCH v7 4/5] xen/arm: switch ARM to use generic implementation of bug.h Oleksii Kurochko
2023-03-09 13:33 ` [PATCH v7 5/5] xen/x86: switch x86 to use generic implemetation " Oleksii Kurochko
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=192fbcf22a6c6e16498cc208eeb37fc6e08ce56a.camel@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=gianluca@rivosinc.com \
--cc=jandryuk@gmail.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.