jump_label.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2015 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _ASM_TILE_JUMP_LABEL_H
  15. #define _ASM_TILE_JUMP_LABEL_H
  16. #include <arch/opcode.h>
  17. #define JUMP_LABEL_NOP_SIZE TILE_BUNDLE_SIZE_IN_BYTES
  18. static __always_inline bool arch_static_branch(struct static_key *key,
  19. bool branch)
  20. {
  21. asm_volatile_goto("1:\n\t"
  22. "nop" "\n\t"
  23. ".pushsection __jump_table, \"aw\"\n\t"
  24. ".quad 1b, %l[l_yes], %0 + %1 \n\t"
  25. ".popsection\n\t"
  26. : : "i" (key), "i" (branch) : : l_yes);
  27. return false;
  28. l_yes:
  29. return true;
  30. }
  31. static __always_inline bool arch_static_branch_jump(struct static_key *key,
  32. bool branch)
  33. {
  34. asm_volatile_goto("1:\n\t"
  35. "j %l[l_yes]" "\n\t"
  36. ".pushsection __jump_table, \"aw\"\n\t"
  37. ".quad 1b, %l[l_yes], %0 + %1 \n\t"
  38. ".popsection\n\t"
  39. : : "i" (key), "i" (branch) : : l_yes);
  40. return false;
  41. l_yes:
  42. return true;
  43. }
  44. typedef u64 jump_label_t;
  45. struct jump_entry {
  46. jump_label_t code;
  47. jump_label_t target;
  48. jump_label_t key;
  49. };
  50. #endif /* _ASM_TILE_JUMP_LABEL_H */