Reflow the ZynqMP message for grepability, and fix the omission of a newline.
There is a race condition where multiple cpus could race to set once_ boolean.
However, the use of this construct is mainly useful for boot time code, and
the only consequence of the race is a repeated print message.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
switch ( ssbd_state )
{
case ARM_SSBD_FORCE_DISABLE:
- {
- static bool once = true;
-
- if ( once )
- printk("%s disabled from command-line\n", entry->desc);
- once = false;
+ printk_once("%s disabled from command-line\n", entry->desc);
arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL);
required = false;
-
break;
- }
case ARM_SSBD_RUNTIME:
if ( required )
break;
case ARM_SSBD_FORCE_ENABLE:
- {
- static bool once = true;
-
- if ( once )
- printk("%s forced from command-line\n", entry->desc);
- once = false;
+ printk_once("%s forced from command-line\n", entry->desc);
arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL);
required = true;
-
break;
- }
default:
ASSERT_UNREACHABLE();
*/
if ( !cpus_have_const_cap(ARM_SMCCC_1_1) )
{
- static bool once = true;
+ printk_once(XENLOG_WARNING
+ "ZynqMP firmware Error: no SMCCC 1.1 support. Disabling firmware calls\n");
- if ( once )
- {
- printk(XENLOG_WARNING "ZynqMP firmware Error: no SMCCC 1.1 "
- "support. Disabling firmware calls.");
- once = false;
- }
return false;
}
return zynqmp_eemi(regs);
#define _p(_x) ((void *)(unsigned long)(_x))
extern void printk(const char *format, ...)
__attribute__ ((format (printf, 1, 2)));
+
+#define printk_once(fmt, args...) \
+({ \
+ static bool __read_mostly once_; \
+ if ( unlikely(!once_) ) \
+ { \
+ once_ = true; \
+ printk(fmt, ## args); \
+ } \
+})
+
extern void guest_printk(const struct domain *d, const char *format, ...)
__attribute__ ((format (printf, 2, 3)));
extern void noreturn panic(const char *format, ...)