jump_label.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _ASM_POWERPC_JUMP_LABEL_H
  2. #define _ASM_POWERPC_JUMP_LABEL_H
  3. /*
  4. * Copyright 2010 Michael Ellerman, IBM Corp.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/types.h>
  12. #include <asm/feature-fixups.h>
  13. #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
  14. #define JUMP_LABEL_NOP_SIZE 4
  15. static __always_inline bool arch_static_branch(struct static_key *key)
  16. {
  17. asm_volatile_goto("1:\n\t"
  18. "nop\n\t"
  19. ".pushsection __jump_table, \"aw\"\n\t"
  20. JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
  21. ".popsection \n\t"
  22. : : "i" (key) : : l_yes);
  23. return false;
  24. l_yes:
  25. return true;
  26. }
  27. #ifdef CONFIG_PPC64
  28. typedef u64 jump_label_t;
  29. #else
  30. typedef u32 jump_label_t;
  31. #endif
  32. struct jump_entry {
  33. jump_label_t code;
  34. jump_label_t target;
  35. jump_label_t key;
  36. };
  37. #endif /* _ASM_POWERPC_JUMP_LABEL_H */