page-protection.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * QEMU page protection definitions.
  3. *
  4. * Copyright (c) 2003 Fabrice Bellard
  5. *
  6. * SPDX-License-Identifier: LGPL-2.1+
  7. */
  8. #ifndef EXEC_PAGE_PROT_COMMON_H
  9. #define EXEC_PAGE_PROT_COMMON_H
  10. /* same as PROT_xxx */
  11. #define PAGE_READ 0x0001
  12. #define PAGE_WRITE 0x0002
  13. #define PAGE_EXEC 0x0004
  14. #define PAGE_RWX (PAGE_READ | PAGE_WRITE | PAGE_EXEC)
  15. #define PAGE_VALID 0x0008
  16. /*
  17. * Original state of the write flag (used when tracking self-modifying code)
  18. */
  19. #define PAGE_WRITE_ORG 0x0010
  20. /*
  21. * Invalidate the TLB entry immediately, helpful for s390x
  22. * Low-Address-Protection. Used with PAGE_WRITE in tlb_set_page_with_attrs()
  23. */
  24. #define PAGE_WRITE_INV 0x0020
  25. /* For use with page_set_flags: page is being replaced; target_data cleared. */
  26. #define PAGE_RESET 0x0040
  27. /* For linux-user, indicates that the page is MAP_ANON. */
  28. #define PAGE_ANON 0x0080
  29. /* Target-specific bits that will be used via page_get_flags(). */
  30. #define PAGE_TARGET_1 0x0200
  31. #define PAGE_TARGET_2 0x0400
  32. /*
  33. * For linux-user, indicates that the page is mapped with the same semantics
  34. * in both guest and host.
  35. */
  36. #define PAGE_PASSTHROUGH 0x0800
  37. #ifdef CONFIG_USER_ONLY
  38. void TSA_NO_TSA mmap_lock(void);
  39. void TSA_NO_TSA mmap_unlock(void);
  40. bool have_mmap_lock(void);
  41. static inline void mmap_unlock_guard(void *unused)
  42. {
  43. mmap_unlock();
  44. }
  45. #define WITH_MMAP_LOCK_GUARD() \
  46. for (int _mmap_lock_iter __attribute__((cleanup(mmap_unlock_guard))) \
  47. = (mmap_lock(), 0); _mmap_lock_iter == 0; _mmap_lock_iter = 1)
  48. #else
  49. static inline void mmap_lock(void) {}
  50. static inline void mmap_unlock(void) {}
  51. #define WITH_MMAP_LOCK_GUARD()
  52. #endif /* !CONFIG_USER_ONLY */
  53. #endif