libcpumf: Detect PMU pai_crypto

Add a check to detect Processor Activity Instrumentation (PAI)
facility unit.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2022-04-28 15:32:07 +02:00
committed by Jan Höppner
parent 0981df62c0
commit acdce2a7a9
3 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
#define S390_CPUS_POSSIBLE "/sys/devices/system/cpu/possible"
#define S390_CPUS_ONLINE "/sys/devices/system/cpu/online"
#define S390_CPUMSF_BUFFERSZ "/sys/module/kernel/parameters/cpum_sfb_size"
#define S390_SYSFS_PAI_CRYPTO "/sys/devices/pai_crypto/"
/**
* Read out the PMU type from a given file.
@@ -121,4 +122,12 @@ bool libcpumf_have_sfb(void);
* @retval false Information could not be retrieved
*/
bool libcpumf_sfb_info(unsigned long *min, unsigned long *max);
/**
* Return true if PAI_CRYPTO counter Facility is supported.
*
* @retval true PAI_CRYPTO counter Facility is available
* @retval false PAI_CRYPTO counter Facility is not available
*/
bool libcpumf_have_pai_crypto(void);
#endif

View File

@@ -72,5 +72,7 @@ int main(void)
if (rc)
printf(" sfb_min %lu sfb_max %lu", sfb_min, sfb_max);
putchar('\n');
printf("PAI crypto support %d\n", libcpumf_have_pai_crypto());
return EXIT_SUCCESS;
}

View File

@@ -139,3 +139,10 @@ bool libcpumf_sfb_info(unsigned long *min, unsigned long *max)
fclose(fp);
return rc;
}
bool libcpumf_have_pai_crypto(void)
{
struct stat statbuf;
return (stat(S390_SYSFS_PAI_CRYPTO, &statbuf) == -1) ? false : true;
}