jump_label.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 jump_label_key *key)
  16. {
  17. asm goto("1:\n\t"
  18. "nop\n\t"
  19. ".pushsection __jump_table, \"aw\"\n\t"
  20. ".align 4\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. jump_label_t pad;
  38. };
  39. #endif /* _ASM_POWERPC_JUMP_LABEL_H */