1*806a15b2SBoyan Karatotev // SPDX-License-Identifier: GPL-2.0 2*806a15b2SBoyan Karatotev // Copyright (C) 2020 ARM Limited 3*806a15b2SBoyan Karatotev 4*806a15b2SBoyan Karatotev #include <stdio.h> 5*806a15b2SBoyan Karatotev #include <stdlib.h> 6*806a15b2SBoyan Karatotev #include <sys/auxv.h> 7*806a15b2SBoyan Karatotev 8*806a15b2SBoyan Karatotev #include "helper.h" 9*806a15b2SBoyan Karatotev main(void)10*806a15b2SBoyan Karatotevint main(void) 11*806a15b2SBoyan Karatotev { 12*806a15b2SBoyan Karatotev struct signatures signed_vals; 13*806a15b2SBoyan Karatotev unsigned long hwcaps; 14*806a15b2SBoyan Karatotev size_t val; 15*806a15b2SBoyan Karatotev 16*806a15b2SBoyan Karatotev fread(&val, sizeof(size_t), 1, stdin); 17*806a15b2SBoyan Karatotev 18*806a15b2SBoyan Karatotev /* don't try to execute illegal (unimplemented) instructions) caller 19*806a15b2SBoyan Karatotev * should have checked this and keep worker simple 20*806a15b2SBoyan Karatotev */ 21*806a15b2SBoyan Karatotev hwcaps = getauxval(AT_HWCAP); 22*806a15b2SBoyan Karatotev 23*806a15b2SBoyan Karatotev if (hwcaps & HWCAP_PACA) { 24*806a15b2SBoyan Karatotev signed_vals.keyia = keyia_sign(val); 25*806a15b2SBoyan Karatotev signed_vals.keyib = keyib_sign(val); 26*806a15b2SBoyan Karatotev signed_vals.keyda = keyda_sign(val); 27*806a15b2SBoyan Karatotev signed_vals.keydb = keydb_sign(val); 28*806a15b2SBoyan Karatotev } 29*806a15b2SBoyan Karatotev signed_vals.keyg = (hwcaps & HWCAP_PACG) ? keyg_sign(val) : 0; 30*806a15b2SBoyan Karatotev 31*806a15b2SBoyan Karatotev fwrite(&signed_vals, sizeof(struct signatures), 1, stdout); 32*806a15b2SBoyan Karatotev 33*806a15b2SBoyan Karatotev return 0; 34*806a15b2SBoyan Karatotev } 35