exec_target.c 883 B

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