Changeset View
Standalone View
stand/powerpc/ofw/cas.c
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
register_t value; | register_t value; | ||||
__asm __volatile ("mfpvr %0" : "=r"(value)); | __asm __volatile ("mfpvr %0" : "=r"(value)); | ||||
return (value); | return (value); | ||||
} | } | ||||
static __inline int | |||||
ppc64_hv(void) | |||||
{ | |||||
int hv; | |||||
/* PSL_HV is bit 3 of 64-bit MSR */ | |||||
__asm __volatile ("mfmsr %0\n\t" | |||||
jhibbits: Can you use machine/psl.h and machine/cpufunc.h? Then you can use 'uint64_t hv = mfmsrd() &… | |||||
Done Inline ActionsOk, I'll give it a try and see if works. luporl: Ok, I'll give it a try and see if works. | |||||
Done Inline ActionsIt doesn't work, as doing so raises a couple of issues. The first issue is that stand is 32-bit, so __powerpc64__ is not defined and would need to be defined manually to get the right contents from psl.h and cpufunc.h. The second issue is that the needed contents are protected by an "#ifdef _KERNEL", needing to define it manually to make it work. The third issue, that I haven't investigate deeper, is that register_t ends up being defined as a 32-bit integer, which truncates the value returned by mfmsr(), resulting in wrong code that will test a bit that will always be 0. So in summary it seems that, at least currently, it is not possible to reuse cpufunc.h and psl.h in stand. luporl: It doesn't work, as doing so raises a couple of issues.
The first issue is that stand is 32… | |||||
"rldicl %0,%0,4,63" : "=r"(hv)); | |||||
return (hv); | |||||
} | |||||
int | int | ||||
ppc64_cas(void) | ppc64_cas(void) | ||||
{ | { | ||||
int rc; | int rc; | ||||
ihandle_t ihandle; | ihandle_t ihandle; | ||||
cell_t err; | cell_t err; | ||||
/* Skip CAS when running on PowerNV */ | |||||
if (!ppc64_hv()) | |||||
return (0); | |||||
/* Perform CAS only for POWER8 and later cores */ | /* Perform CAS only for POWER8 and later cores */ | ||||
switch (mfpvr() & PVR_VER_MASK) { | switch (mfpvr() & PVR_VER_MASK) { | ||||
Done Inline ActionsWould this prevent loader from being used on powernv? I know currently we don't boot with loader on POWER8 and POWER9, but that may change in the future. jhibbits: Would this prevent loader from being used on powernv? I know currently we don't boot with… | |||||
Done Inline ActionsYes, it would. luporl: Yes, it would.
What if I add a check for PSL_HV bit and skip CAS if it is set? Kernel code… | |||||
Done Inline ActionsThat should work, I think. jhibbits: That should work, I think. | |||||
Done Inline ActionsHV bit test added. I've confirmed it works on pseries. luporl: HV bit test added. I've confirmed it works on pseries. | |||||
case PVR_VER_P8: | case PVR_VER_P8: | ||||
case PVR_VER_P8E: | case PVR_VER_P8E: | ||||
case PVR_VER_P8NVL: | case PVR_VER_P8NVL: | ||||
case PVR_VER_P9: | case PVR_VER_P9: | ||||
break; | break; | ||||
default: | default: | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 18 Lines |
Can you use machine/psl.h and machine/cpufunc.h? Then you can use 'uint64_t hv = mfmsrd() & PSL_SF; return (hv != 0);'