x86/shadow: More consistent printing for debug messages
PATCH 1/2 x86/shadow: More consistent printing for debug messages
* Use %pv or just d%d in preference to the multiple current ways of presenting the same information.
* Use PRI_mfn instead of opencoding it.
* Drop all explicit use of __func__ from SHADOW_{PRINTK,DEBUG}() calls. The wrappers already include it.
* Use hex rather than decimal for printing a pagefault error code.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
--- xen/arch/x86/mm/shadow/common.c | 23 ++++++++++------------ xen/arch/x86/mm/shadow/multi.c | 42 ++++++++++++++++++----------------------- 2 files changed, 28 insertions(+), 37 deletions(-)
xen/arch/x86/mm/shadow/common.c +10 -13
@@ -723,8 +723,7 @@ static void _sh_resync(struct vcpu *v, mfn_t gmfn, & ~SHF_L1_ANY));ASSERT (!sh_page_has_multiple_shadows (mfn_to_page (gmfn))); -SHADOW_PRINTK ("d=%d, v=%d, gmfn=%05lx\n" , - v->domain->domain_id, v->vcpu_id,mfn_x (gmfn)); +SHADOW_PRINTK ("%pv gmfn=%" PRI_mfn"\n" , v,mfn_x (gmfn));/* Need to pull write access so the page *stays* in sync. */ if (oos_remove_write_access (v, gmfn, fixup) )
@@ -900,7 +899,7 @@ void sh_resync_all(struct vcpu *v, int skip, int this, int others)mfn_t *oos_snapshot = v->arch.paging.shadow.oos_snapshot;struct oos_fixup *oos_fixup = v->arch.paging.shadow.oos_fixup; -SHADOW_PRINTK ("d=%d, v=%d\n" , v->domain->domain_id, v->vcpu_id); +SHADOW_PRINTK ("%pv\n" , v);ASSERT (paging_locked_by_me (v->domain));
@@ -961,8 +960,7 @@ int sh_unsync(struct vcpu *v, mfn_t gmfn)ASSERT (paging_locked_by_me (v->domain)); -SHADOW_PRINTK ("d=%d, v=%d, gmfn=%05lx\n" , - v->domain->domain_id, v->vcpu_id,mfn_x (gmfn)); +SHADOW_PRINTK ("%pv gmfn=%" PRI_mfn"\n" , v,mfn_x (gmfn)); pg =mfn_to_page (gmfn);
@@ -2792,7 +2790,7 @@ void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all)* can be called via put_page_type when we clear a shadow l1e).*/ paging_lock_recursive (d); -SHADOW_PRINTK ("d=%d: gmfn=%lx\n" , d->domain_id,mfn_x (gmfn)); +SHADOW_PRINTK ("d%d gmfn=%" PRI_mfn"\n" , d->domain_id,mfn_x (gmfn));/* Bail out now if the page is not shadowed */ if ( (pg->count_info & PGC_page_table) ==0 )
@@ -2847,7 +2845,7 @@ void sh_remove_shadows(struct domain *d, mfn_t gmfn, int fast, int all)/* If that didn't catch the shadows, something is wrong */ if ( !fast && all && (pg->count_info & PGC_page_table) ) { -SHADOW_ERROR ("can't find all shadows of mfn %05lx " +SHADOW_ERROR ("can't find all shadows of mfn %" PRI_mfn" " "(shadow_flags=%08x)\n" ,mfn_x (gmfn), pg->shadow_flags);domain_crash (d);
@@ -3016,9 +3014,9 @@ static void sh_update_paging_modes(struct vcpu *v)if ( v->arch.paging.mode != old_mode ) { - SHADOW_PRINTK("new paging mode: d=%u v=%u pe=%d gl=%u " + SHADOW_PRINTK("new paging mode: %pv pe=%d gl=%u " "sl=%u (was g=%u s=%u)\n", - d->domain_id, v->vcpu_id, + v, is_hvm_domain(d) ? hvm_paging_enabled(v) : 1, v->arch.paging.mode->guest_levels, v->arch.paging.mode->shadow.shadow_levels,
@@ -3033,11 +3031,10 @@ static void sh_update_paging_modes(struct vcpu *v)if ( v != current &&vcpu_runnable (v) ) { -SHADOW_ERROR ("Some third party (d=%u v=%u) is changing " -"this HVM vcpu's (d=%u v=%u) paging mode " +SHADOW_ERROR ("Some third party (%pv) is changing " +"this HVM vcpu's (%pv) paging mode " "while it is running.\n" , - current->domain->domain_id, current->vcpu_id, - v->domain->domain_id, v->vcpu_id); + current, v);/* It's not safe to do that because we can't change * the host CR3 for a running domain */ domain_crash (v->domain);
xen/arch/x86/mm/shadow/multi.c +18 -24
120 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 xen/trace: Turn the stub debugtrace_{dump, printk}() macros into functions
This allows printf format checking to be performed, and for debugtrace_printk() to evaluate its arguments, even if debugtrace is disabled at compile time.
No intended change.
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: George Dunlap <[email protected]>
--- xen/include/xen/lib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/include/xen/lib.h +4 -2
@@ -68,8 +68,10 @@ extern void debugtrace_dump(void);extern void debugtrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));#else -#define debugtrace_dump () ((void)0) -#define debugtrace_printk (_f, ...) ((void)0) +static inline void debugtrace_dump (void ) {}; +static inline void + __attribute__ ((format (printf,1 ,2 ))) +debugtrace_printk (const char *fmt, ...) {};#endif /* Allows us to use '%p' as general-purpose machine-word format char. */
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen/trace: Turn the stub debugtrace_{dump, printk}() macros into functions
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.09.16 at 21:21, <[email protected]> wrote:
xen/include/xen/lib.h extern void debugtrace_dump(void); · line 75
Quoted 10 lines
xen/include/xen/lib.h +4
-2@@ -68,8 +68,10 @@ extern void debugtrace_dump(void);extern void debugtrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));#else -#define debugtrace_dump () ((void)0) -#define debugtrace_printk (_f, ...) ((void)0) +static inline void debugtrace_dump (void ) {}; +static inline void + __attribute__ ((format (printf,1 ,2 ))) +debugtrace_printk (const char *fmt, ...) {};#endif
With the stray semicolons dropped, and provided this (at least a little surprisingly) doesn't cause any other fallout with DEBUG_TRACE_DUMP defined,
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen/trace: Turn the stub debugtrace_{dump, printk}() macros into functions
Quoted 15 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.09.16 at 21:21, <[email protected]> wrote:
xen/include/xen/lib.h extern void debugtrace_dump(void); · line 75
Quoted 10 lines
xen/include/xen/lib.h +4
-2@@ -68,8 +68,10 @@ extern void debugtrace_dump(void);extern void debugtrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));#else -#define debugtrace_dump () ((void)0) -#define debugtrace_printk (_f, ...) ((void)0) +static inline void debugtrace_dump (void ) {}; +static inline void + __attribute__ ((format (printf,1 ,2 ))) +debugtrace_printk (const char *fmt, ...) {};#endif With the stray semicolons dropped
Oh yes of course.
Quoted 2 lines
and provided this (at least a little surprisingly) doesn't cause any other fallout with
DEBUG_TRACE_DUMPdefined,
I don't know what you mean by this. We strictly only change the non-defined case, and that compiles fine on all architectures.
~Andrew
Quoted 6 lines
Acked-by Jan Beulich <[email protected]>Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen/trace: Turn the stub debugtrace_{dump, printk}() macros into functions
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 02.09.16 at 12:00, <[email protected]> wrote:
Quoted 15 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 01.09.16 at 21:21, <[email protected]> wrote:
xen/include/xen/lib.h extern void debugtrace_dump(void); · line 75
Quoted 10 lines
xen/include/xen/lib.h +4
-2@@ -68,8 +68,10 @@ extern void debugtrace_dump(void);extern void debugtrace_printk (const char *fmt, ...) __attribute__ ((format (printf,1 ,2 )));#else -#define debugtrace_dump () ((void)0) -#define debugtrace_printk (_f, ...) ((void)0) +static inline void debugtrace_dump (void ) {}; +static inline void + __attribute__ ((format (printf,1 ,2 ))) +debugtrace_printk (const char *fmt, ...) {};#endif With the stray semicolons dropped
Quoted 7 lines
Oh yes of course.
Quoted 2 lines
and provided this (at least a little surprisingly) doesn't cause any other fallout with
DEBUG_TRACE_DUMPdefined,I don't know what you mean by this. We strictly only change the non-defined case,
Oh, sorry.
Quoted 1 line
and that compiles fine on all architectures.
Good.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 8 lines · Andrew Cooper
* Use %pv or just d%d in preference to the multiple current ways of presenting the same information.
* UsePRI_mfninstead of opencoding it.
* Drop all explicit use of__func__from SHADOW_{PRINTK,DEBUG}() calls. The wrappers already include it.
* Use hex rather than decimal for printing a pagefault error code.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel