jump_label.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef __ASSEMBLY__
  12. #include <linux/types.h>
  13. #include <asm/feature-fixups.h>
  14. #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
  15. #define JUMP_LABEL_NOP_SIZE 4
  16. static __always_inline bool arch_static_branch(struct static_key *key)
  17. {
  18. asm_volatile_goto("1:\n\t"
  19. "nop\n\t"
  20. ".pushsection __jump_table, \"aw\"\n\t"
  21. JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
  22. ".popsection \n\t"
  23. : : "i" (key) : : l_yes);
  24. return false;
  25. l_yes:
  26. return true;
  27. }
  28. #ifdef CONFIG_PPC64
  29. typedef u64 jump_label_t;
  30. #else
  31. typedef u32 jump_label_t;
  32. #endif
  33. struct jump_entry {
  34. jump_label_t code;
  35. jump_label_t target;
  36. jump_label_t key;
  37. };
  38. #else
  39. #define ARCH_STATIC_BRANCH(LABEL, KEY) \
  40. 1098: nop; \
  41. .pushsection __jump_table, "aw"; \
  42. FTR_ENTRY_LONG 1098b, LABEL, KEY; \
  43. .popsection
  44. #endif
  45. #endif /* _ASM_POWERPC_JUMP_LABEL_H */