mttb in sys/powerpc/include/cpufunc.h still does not handle/protect-against interrupts

Mark Millard marklmi at yahoo.com
Tue Apr 20 19:07:12 UTC 2021


Looking at sys/powerpc/include/cpufunc.h in main (and so older too):

static __inline void
mttb(u_quad_t time)
{

	mtspr(TBR_TBWL, 0);
	mtspr(TBR_TBWU, (uint32_t)(time >> 32));
	mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff));
}

This code still does not protect against interrupts
(only suggestive):

	mtspr(TBR_TBWL, 0);
HERE?
	mtspr(TBR_TBWU, (uint32_t)(time >> 32));
HERE?
	mtspr(TBR_TBWL, (uint32_t)(time & 0xffffffff));


My code disabled interrupts around the update:

static __inline void
mttb(u_quad_t time)
{
	const uint32_t   high= time>>32;
	const uint32_t   low=  time&0xffffffffu;

	const register_t predisable_msr= intr_disable();
	mtspr(TBR_TBWL, 0);
	mtspr(TBR_TBWU, high);
	mtspr(TBR_TBWL, low);
	intr_restore(predisable_msr);
}

As I remember, I found powerpc documentation that indicated
such was important to reliable settings.


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-ppc mailing list