cpu.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  1. /*
  2. * QEMU CPU model
  3. *
  4. * Copyright (c) 2012 SUSE LINUX Products GmbH
  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 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see
  18. * <http://www.gnu.org/licenses/gpl-2.0.html>
  19. */
  20. #ifndef QEMU_CPU_H
  21. #define QEMU_CPU_H
  22. #include "hw/qdev-core.h"
  23. #include "disas/dis-asm.h"
  24. #include "exec/breakpoint.h"
  25. #include "exec/hwaddr.h"
  26. #include "exec/vaddr.h"
  27. #include "exec/memattrs.h"
  28. #include "exec/mmu-access-type.h"
  29. #include "exec/tlb-common.h"
  30. #include "qapi/qapi-types-machine.h"
  31. #include "qapi/qapi-types-run-state.h"
  32. #include "qemu/bitmap.h"
  33. #include "qemu/rcu_queue.h"
  34. #include "qemu/queue.h"
  35. #include "qemu/lockcnt.h"
  36. #include "qemu/thread.h"
  37. #include "qom/object.h"
  38. typedef int (*WriteCoreDumpFunction)(const void *buf, size_t size,
  39. void *opaque);
  40. /**
  41. * SECTION:cpu
  42. * @section_id: QEMU-cpu
  43. * @title: CPU Class
  44. * @short_description: Base class for all CPUs
  45. */
  46. #define TYPE_CPU "cpu"
  47. /* Since this macro is used a lot in hot code paths and in conjunction with
  48. * FooCPU *foo_env_get_cpu(), we deviate from usual QOM practice by using
  49. * an unchecked cast.
  50. */
  51. #define CPU(obj) ((CPUState *)(obj))
  52. /*
  53. * The class checkers bring in CPU_GET_CLASS() which is potentially
  54. * expensive given the eventual call to
  55. * object_class_dynamic_cast_assert(). Because of this the CPUState
  56. * has a cached value for the class in cs->cc which is set up in
  57. * cpu_exec_realizefn() for use in hot code paths.
  58. */
  59. typedef struct CPUClass CPUClass;
  60. DECLARE_CLASS_CHECKERS(CPUClass, CPU,
  61. TYPE_CPU)
  62. /**
  63. * OBJECT_DECLARE_CPU_TYPE:
  64. * @CpuInstanceType: instance struct name
  65. * @CpuClassType: class struct name
  66. * @CPU_MODULE_OBJ_NAME: the CPU name in uppercase with underscore separators
  67. *
  68. * This macro is typically used in "cpu-qom.h" header file, and will:
  69. *
  70. * - create the typedefs for the CPU object and class structs
  71. * - register the type for use with g_autoptr
  72. * - provide three standard type cast functions
  73. *
  74. * The object struct and class struct need to be declared manually.
  75. */
  76. #define OBJECT_DECLARE_CPU_TYPE(CpuInstanceType, CpuClassType, CPU_MODULE_OBJ_NAME) \
  77. typedef struct ArchCPU CpuInstanceType; \
  78. OBJECT_DECLARE_TYPE(ArchCPU, CpuClassType, CPU_MODULE_OBJ_NAME);
  79. typedef struct CPUWatchpoint CPUWatchpoint;
  80. /* see physmem.c */
  81. struct CPUAddressSpace;
  82. /* see accel/tcg/tb-jmp-cache.h */
  83. struct CPUJumpCache;
  84. /* see accel-cpu.h */
  85. struct AccelCPUClass;
  86. /* see sysemu-cpu-ops.h */
  87. struct SysemuCPUOps;
  88. /**
  89. * CPUClass:
  90. * @class_by_name: Callback to map -cpu command line model name to an
  91. * instantiatable CPU type.
  92. * @parse_features: Callback to parse command line arguments.
  93. * @reset_dump_flags: #CPUDumpFlags to use for reset logging.
  94. * @has_work: Callback for checking if there is work to do.
  95. * @mmu_index: Callback for choosing softmmu mmu index;
  96. * may be used internally by memory_rw_debug without TCG.
  97. * @memory_rw_debug: Callback for GDB memory access.
  98. * @dump_state: Callback for dumping state.
  99. * @query_cpu_fast:
  100. * Fill in target specific information for the "query-cpus-fast"
  101. * QAPI call.
  102. * @get_arch_id: Callback for getting architecture-dependent CPU ID.
  103. * @set_pc: Callback for setting the Program Counter register. This
  104. * should have the semantics used by the target architecture when
  105. * setting the PC from a source such as an ELF file entry point;
  106. * for example on Arm it will also set the Thumb mode bit based
  107. * on the least significant bit of the new PC value.
  108. * If the target behaviour here is anything other than "set
  109. * the PC register to the value passed in" then the target must
  110. * also implement the synchronize_from_tb hook.
  111. * @get_pc: Callback for getting the Program Counter register.
  112. * As above, with the semantics of the target architecture.
  113. * @gdb_read_register: Callback for letting GDB read a register.
  114. * No more than @gdb_num_core_regs registers can be read.
  115. * @gdb_write_register: Callback for letting GDB write a register.
  116. * No more than @gdb_num_core_regs registers can be written.
  117. * @gdb_adjust_breakpoint: Callback for adjusting the address of a
  118. * breakpoint. Used by AVR to handle a gdb mis-feature with
  119. * its Harvard architecture split code and data.
  120. * @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer
  121. * from @gdb_core_xml_file.
  122. * @gdb_core_xml_file: File name for core registers GDB XML description.
  123. * @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop
  124. * before the insn which triggers a watchpoint rather than after it.
  125. * @gdb_arch_name: Optional callback that returns the architecture name known
  126. * to GDB. The caller must free the returned string with g_free.
  127. * @disas_set_info: Setup architecture specific components of disassembly info
  128. * @adjust_watchpoint_address: Perform a target-specific adjustment to an
  129. * address before attempting to match it against watchpoints.
  130. * @deprecation_note: If this CPUClass is deprecated, this field provides
  131. * related information.
  132. *
  133. * Represents a CPU family or model.
  134. */
  135. struct CPUClass {
  136. /*< private >*/
  137. DeviceClass parent_class;
  138. /*< public >*/
  139. ObjectClass *(*class_by_name)(const char *cpu_model);
  140. void (*parse_features)(const char *typename, char *str, Error **errp);
  141. bool (*has_work)(CPUState *cpu);
  142. int (*mmu_index)(CPUState *cpu, bool ifetch);
  143. int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
  144. uint8_t *buf, int len, bool is_write);
  145. void (*dump_state)(CPUState *cpu, FILE *, int flags);
  146. void (*query_cpu_fast)(CPUState *cpu, CpuInfoFast *value);
  147. int64_t (*get_arch_id)(CPUState *cpu);
  148. void (*set_pc)(CPUState *cpu, vaddr value);
  149. vaddr (*get_pc)(CPUState *cpu);
  150. int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg);
  151. int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg);
  152. vaddr (*gdb_adjust_breakpoint)(CPUState *cpu, vaddr addr);
  153. const char *gdb_core_xml_file;
  154. const gchar * (*gdb_arch_name)(CPUState *cpu);
  155. void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
  156. const char *deprecation_note;
  157. struct AccelCPUClass *accel_cpu;
  158. /* when system emulation is not available, this pointer is NULL */
  159. const struct SysemuCPUOps *sysemu_ops;
  160. /* when TCG is not available, this pointer is NULL */
  161. const TCGCPUOps *tcg_ops;
  162. /*
  163. * if not NULL, this is called in order for the CPUClass to initialize
  164. * class data that depends on the accelerator, see accel/accel-common.c.
  165. */
  166. void (*init_accel_cpu)(struct AccelCPUClass *accel_cpu, CPUClass *cc);
  167. /*
  168. * Keep non-pointer data at the end to minimize holes.
  169. */
  170. int reset_dump_flags;
  171. int gdb_num_core_regs;
  172. bool gdb_stop_before_watchpoint;
  173. };
  174. /*
  175. * Fix the number of mmu modes to 16, which is also the maximum
  176. * supported by the softmmu tlb api.
  177. */
  178. #define NB_MMU_MODES 16
  179. /* Use a fully associative victim tlb of 8 entries. */
  180. #define CPU_VTLB_SIZE 8
  181. /*
  182. * The full TLB entry, which is not accessed by generated TCG code,
  183. * so the layout is not as critical as that of CPUTLBEntry. This is
  184. * also why we don't want to combine the two structs.
  185. */
  186. struct CPUTLBEntryFull {
  187. /*
  188. * @xlat_section contains:
  189. * - in the lower TARGET_PAGE_BITS, a physical section number
  190. * - with the lower TARGET_PAGE_BITS masked off, an offset which
  191. * must be added to the virtual address to obtain:
  192. * + the ram_addr_t of the target RAM (if the physical section
  193. * number is PHYS_SECTION_NOTDIRTY or PHYS_SECTION_ROM)
  194. * + the offset within the target MemoryRegion (otherwise)
  195. */
  196. hwaddr xlat_section;
  197. /*
  198. * @phys_addr contains the physical address in the address space
  199. * given by cpu_asidx_from_attrs(cpu, @attrs).
  200. */
  201. hwaddr phys_addr;
  202. /* @attrs contains the memory transaction attributes for the page. */
  203. MemTxAttrs attrs;
  204. /* @prot contains the complete protections for the page. */
  205. uint8_t prot;
  206. /* @lg_page_size contains the log2 of the page size. */
  207. uint8_t lg_page_size;
  208. /* Additional tlb flags requested by tlb_fill. */
  209. uint8_t tlb_fill_flags;
  210. /*
  211. * Additional tlb flags for use by the slow path. If non-zero,
  212. * the corresponding CPUTLBEntry comparator must have TLB_FORCE_SLOW.
  213. */
  214. uint8_t slow_flags[MMU_ACCESS_COUNT];
  215. /*
  216. * Allow target-specific additions to this structure.
  217. * This may be used to cache items from the guest cpu
  218. * page tables for later use by the implementation.
  219. */
  220. union {
  221. /*
  222. * Cache the attrs and shareability fields from the page table entry.
  223. *
  224. * For ARMMMUIdx_Stage2*, pte_attrs is the S2 descriptor bits [5:2].
  225. * Otherwise, pte_attrs is the same as the MAIR_EL1 8-bit format.
  226. * For shareability and guarded, as in the SH and GP fields respectively
  227. * of the VMSAv8-64 PTEs.
  228. */
  229. struct {
  230. uint8_t pte_attrs;
  231. uint8_t shareability;
  232. bool guarded;
  233. } arm;
  234. } extra;
  235. };
  236. /*
  237. * Data elements that are per MMU mode, minus the bits accessed by
  238. * the TCG fast path.
  239. */
  240. typedef struct CPUTLBDesc {
  241. /*
  242. * Describe a region covering all of the large pages allocated
  243. * into the tlb. When any page within this region is flushed,
  244. * we must flush the entire tlb. The region is matched if
  245. * (addr & large_page_mask) == large_page_addr.
  246. */
  247. vaddr large_page_addr;
  248. vaddr large_page_mask;
  249. /* host time (in ns) at the beginning of the time window */
  250. int64_t window_begin_ns;
  251. /* maximum number of entries observed in the window */
  252. size_t window_max_entries;
  253. size_t n_used_entries;
  254. /* The next index to use in the tlb victim table. */
  255. size_t vindex;
  256. /* The tlb victim table, in two parts. */
  257. CPUTLBEntry vtable[CPU_VTLB_SIZE];
  258. CPUTLBEntryFull vfulltlb[CPU_VTLB_SIZE];
  259. CPUTLBEntryFull *fulltlb;
  260. } CPUTLBDesc;
  261. /*
  262. * Data elements that are shared between all MMU modes.
  263. */
  264. typedef struct CPUTLBCommon {
  265. /* Serialize updates to f.table and d.vtable, and others as noted. */
  266. QemuSpin lock;
  267. /*
  268. * Within dirty, for each bit N, modifications have been made to
  269. * mmu_idx N since the last time that mmu_idx was flushed.
  270. * Protected by tlb_c.lock.
  271. */
  272. uint16_t dirty;
  273. /*
  274. * Statistics. These are not lock protected, but are read and
  275. * written atomically. This allows the monitor to print a snapshot
  276. * of the stats without interfering with the cpu.
  277. */
  278. size_t full_flush_count;
  279. size_t part_flush_count;
  280. size_t elide_flush_count;
  281. } CPUTLBCommon;
  282. /*
  283. * The entire softmmu tlb, for all MMU modes.
  284. * The meaning of each of the MMU modes is defined in the target code.
  285. * Since this is placed within CPUNegativeOffsetState, the smallest
  286. * negative offsets are at the end of the struct.
  287. */
  288. typedef struct CPUTLB {
  289. #ifdef CONFIG_TCG
  290. CPUTLBCommon c;
  291. CPUTLBDesc d[NB_MMU_MODES];
  292. CPUTLBDescFast f[NB_MMU_MODES];
  293. #endif
  294. } CPUTLB;
  295. /*
  296. * Low 16 bits: number of cycles left, used only in icount mode.
  297. * High 16 bits: Set to -1 to force TCG to stop executing linked TBs
  298. * for this CPU and return to its top level loop (even in non-icount mode).
  299. * This allows a single read-compare-cbranch-write sequence to test
  300. * for both decrementer underflow and exceptions.
  301. */
  302. typedef union IcountDecr {
  303. uint32_t u32;
  304. struct {
  305. #if HOST_BIG_ENDIAN
  306. uint16_t high;
  307. uint16_t low;
  308. #else
  309. uint16_t low;
  310. uint16_t high;
  311. #endif
  312. } u16;
  313. } IcountDecr;
  314. /**
  315. * CPUNegativeOffsetState: Elements of CPUState most efficiently accessed
  316. * from CPUArchState, via small negative offsets.
  317. * @can_do_io: True if memory-mapped IO is allowed.
  318. * @plugin_mem_cbs: active plugin memory callbacks
  319. * @plugin_mem_value_low: 64 lower bits of latest accessed mem value.
  320. * @plugin_mem_value_high: 64 higher bits of latest accessed mem value.
  321. */
  322. typedef struct CPUNegativeOffsetState {
  323. CPUTLB tlb;
  324. #ifdef CONFIG_PLUGIN
  325. /*
  326. * The callback pointer are accessed via TCG (see gen_empty_mem_helper).
  327. */
  328. GArray *plugin_mem_cbs;
  329. uint64_t plugin_mem_value_low;
  330. uint64_t plugin_mem_value_high;
  331. #endif
  332. IcountDecr icount_decr;
  333. bool can_do_io;
  334. } CPUNegativeOffsetState;
  335. struct KVMState;
  336. struct kvm_run;
  337. /* work queue */
  338. /* The union type allows passing of 64 bit target pointers on 32 bit
  339. * hosts in a single parameter
  340. */
  341. typedef union {
  342. int host_int;
  343. unsigned long host_ulong;
  344. void *host_ptr;
  345. vaddr target_ptr;
  346. } run_on_cpu_data;
  347. #define RUN_ON_CPU_HOST_PTR(p) ((run_on_cpu_data){.host_ptr = (p)})
  348. #define RUN_ON_CPU_HOST_INT(i) ((run_on_cpu_data){.host_int = (i)})
  349. #define RUN_ON_CPU_HOST_ULONG(ul) ((run_on_cpu_data){.host_ulong = (ul)})
  350. #define RUN_ON_CPU_TARGET_PTR(v) ((run_on_cpu_data){.target_ptr = (v)})
  351. #define RUN_ON_CPU_NULL RUN_ON_CPU_HOST_PTR(NULL)
  352. typedef void (*run_on_cpu_func)(CPUState *cpu, run_on_cpu_data data);
  353. struct qemu_work_item;
  354. #define CPU_UNSET_NUMA_NODE_ID -1
  355. /**
  356. * struct CPUState - common state of one CPU core or thread.
  357. *
  358. * @cpu_index: CPU index (informative).
  359. * @cluster_index: Identifies which cluster this CPU is in.
  360. * For boards which don't define clusters or for "loose" CPUs not assigned
  361. * to a cluster this will be UNASSIGNED_CLUSTER_INDEX; otherwise it will
  362. * be the same as the cluster-id property of the CPU object's TYPE_CPU_CLUSTER
  363. * QOM parent.
  364. * Under TCG this value is propagated to @tcg_cflags.
  365. * See TranslationBlock::TCG CF_CLUSTER_MASK.
  366. * @tcg_cflags: Pre-computed cflags for this cpu.
  367. * @nr_threads: Number of threads within this CPU core.
  368. * @thread: Host thread details, only live once @created is #true
  369. * @sem: WIN32 only semaphore used only for qtest
  370. * @thread_id: native thread id of vCPU, only live once @created is #true
  371. * @running: #true if CPU is currently running (lockless).
  372. * @has_waiter: #true if a CPU is currently waiting for the cpu_exec_end;
  373. * valid under cpu_list_lock.
  374. * @created: Indicates whether the CPU thread has been successfully created.
  375. * @halt_cond: condition variable sleeping threads can wait on.
  376. * @interrupt_request: Indicates a pending interrupt request.
  377. * @halted: Nonzero if the CPU is in suspended state.
  378. * @stop: Indicates a pending stop request.
  379. * @stopped: Indicates the CPU has been artificially stopped.
  380. * @unplug: Indicates a pending CPU unplug request.
  381. * @crash_occurred: Indicates the OS reported a crash (panic) for this CPU
  382. * @singlestep_enabled: Flags for single-stepping.
  383. * @icount_extra: Instructions until next timer event.
  384. * @cpu_ases: Pointer to array of CPUAddressSpaces (which define the
  385. * AddressSpaces this CPU has)
  386. * @num_ases: number of CPUAddressSpaces in @cpu_ases
  387. * @as: Pointer to the first AddressSpace, for the convenience of targets which
  388. * only have a single AddressSpace
  389. * @gdb_regs: Additional GDB registers.
  390. * @gdb_num_regs: Number of total registers accessible to GDB.
  391. * @gdb_num_g_regs: Number of registers in GDB 'g' packets.
  392. * @node: QTAILQ of CPUs sharing TB cache.
  393. * @opaque: User data.
  394. * @mem_io_pc: Host Program Counter at which the memory was accessed.
  395. * @accel: Pointer to accelerator specific state.
  396. * @kvm_fd: vCPU file descriptor for KVM.
  397. * @work_mutex: Lock to prevent multiple access to @work_list.
  398. * @work_list: List of pending asynchronous work.
  399. * @plugin_state: per-CPU plugin state
  400. * @ignore_memory_transaction_failures: Cached copy of the MachineState
  401. * flag of the same name: allows the board to suppress calling of the
  402. * CPU do_transaction_failed hook function.
  403. * @kvm_dirty_gfns: Points to the KVM dirty ring for this CPU when KVM dirty
  404. * ring is enabled.
  405. * @kvm_fetch_index: Keeps the index that we last fetched from the per-vCPU
  406. * dirty ring structure.
  407. *
  408. * @neg_align: The CPUState is the common part of a concrete ArchCPU
  409. * which is allocated when an individual CPU instance is created. As
  410. * such care is taken is ensure there is no gap between between
  411. * CPUState and CPUArchState within ArchCPU.
  412. *
  413. * @neg: The architectural register state ("cpu_env") immediately follows
  414. * CPUState in ArchCPU and is passed to TCG code. The @neg structure holds
  415. * some common TCG CPU variables which are accessed with a negative offset
  416. * from cpu_env.
  417. */
  418. struct CPUState {
  419. /*< private >*/
  420. DeviceState parent_obj;
  421. /* cache to avoid expensive CPU_GET_CLASS */
  422. CPUClass *cc;
  423. /*< public >*/
  424. int nr_threads;
  425. struct QemuThread *thread;
  426. #ifdef _WIN32
  427. QemuSemaphore sem;
  428. #endif
  429. int thread_id;
  430. bool running, has_waiter;
  431. struct QemuCond *halt_cond;
  432. bool thread_kicked;
  433. bool created;
  434. bool stop;
  435. bool stopped;
  436. /* Should CPU start in powered-off state? */
  437. bool start_powered_off;
  438. bool unplug;
  439. bool crash_occurred;
  440. bool exit_request;
  441. int exclusive_context_count;
  442. uint32_t cflags_next_tb;
  443. /* updates protected by BQL */
  444. uint32_t interrupt_request;
  445. int singlestep_enabled;
  446. int64_t icount_budget;
  447. int64_t icount_extra;
  448. uint64_t random_seed;
  449. sigjmp_buf jmp_env;
  450. QemuMutex work_mutex;
  451. QSIMPLEQ_HEAD(, qemu_work_item) work_list;
  452. struct CPUAddressSpace *cpu_ases;
  453. int cpu_ases_count;
  454. int num_ases;
  455. AddressSpace *as;
  456. MemoryRegion *memory;
  457. struct CPUJumpCache *tb_jmp_cache;
  458. GArray *gdb_regs;
  459. int gdb_num_regs;
  460. int gdb_num_g_regs;
  461. QTAILQ_ENTRY(CPUState) node;
  462. /* ice debug support */
  463. QTAILQ_HEAD(, CPUBreakpoint) breakpoints;
  464. QTAILQ_HEAD(, CPUWatchpoint) watchpoints;
  465. CPUWatchpoint *watchpoint_hit;
  466. void *opaque;
  467. /* In order to avoid passing too many arguments to the MMIO helpers,
  468. * we store some rarely used information in the CPU context.
  469. */
  470. uintptr_t mem_io_pc;
  471. /* Only used in KVM */
  472. int kvm_fd;
  473. struct KVMState *kvm_state;
  474. struct kvm_run *kvm_run;
  475. struct kvm_dirty_gfn *kvm_dirty_gfns;
  476. uint32_t kvm_fetch_index;
  477. uint64_t dirty_pages;
  478. int kvm_vcpu_stats_fd;
  479. bool vcpu_dirty;
  480. /* Use by accel-block: CPU is executing an ioctl() */
  481. QemuLockCnt in_ioctl_lock;
  482. #ifdef CONFIG_PLUGIN
  483. CPUPluginState *plugin_state;
  484. #endif
  485. /* TODO Move common fields from CPUArchState here. */
  486. int cpu_index;
  487. int cluster_index;
  488. uint32_t tcg_cflags;
  489. uint32_t halted;
  490. int32_t exception_index;
  491. AccelCPUState *accel;
  492. /* Used to keep track of an outstanding cpu throttle thread for migration
  493. * autoconverge
  494. */
  495. bool throttle_thread_scheduled;
  496. /*
  497. * Sleep throttle_us_per_full microseconds once dirty ring is full
  498. * if dirty page rate limit is enabled.
  499. */
  500. int64_t throttle_us_per_full;
  501. bool ignore_memory_transaction_failures;
  502. /* Used for user-only emulation of prctl(PR_SET_UNALIGN). */
  503. bool prctl_unalign_sigbus;
  504. /* track IOMMUs whose translations we've cached in the TCG TLB */
  505. GArray *iommu_notifiers;
  506. /*
  507. * MUST BE LAST in order to minimize the displacement to CPUArchState.
  508. */
  509. char neg_align[-sizeof(CPUNegativeOffsetState) % 16] QEMU_ALIGNED(16);
  510. CPUNegativeOffsetState neg;
  511. };
  512. /* Validate placement of CPUNegativeOffsetState. */
  513. QEMU_BUILD_BUG_ON(offsetof(CPUState, neg) !=
  514. sizeof(CPUState) - sizeof(CPUNegativeOffsetState));
  515. static inline CPUArchState *cpu_env(CPUState *cpu)
  516. {
  517. /* We validate that CPUArchState follows CPUState in cpu-all.h. */
  518. return (CPUArchState *)(cpu + 1);
  519. }
  520. typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ;
  521. extern CPUTailQ cpus_queue;
  522. #define first_cpu QTAILQ_FIRST_RCU(&cpus_queue)
  523. #define CPU_NEXT(cpu) QTAILQ_NEXT_RCU(cpu, node)
  524. #define CPU_FOREACH(cpu) QTAILQ_FOREACH_RCU(cpu, &cpus_queue, node)
  525. #define CPU_FOREACH_SAFE(cpu, next_cpu) \
  526. QTAILQ_FOREACH_SAFE_RCU(cpu, &cpus_queue, node, next_cpu)
  527. extern __thread CPUState *current_cpu;
  528. /**
  529. * qemu_tcg_mttcg_enabled:
  530. * Check whether we are running MultiThread TCG or not.
  531. *
  532. * Returns: %true if we are in MTTCG mode %false otherwise.
  533. */
  534. extern bool mttcg_enabled;
  535. #define qemu_tcg_mttcg_enabled() (mttcg_enabled)
  536. /**
  537. * cpu_paging_enabled:
  538. * @cpu: The CPU whose state is to be inspected.
  539. *
  540. * Returns: %true if paging is enabled, %false otherwise.
  541. */
  542. bool cpu_paging_enabled(const CPUState *cpu);
  543. #if !defined(CONFIG_USER_ONLY)
  544. /**
  545. * cpu_get_memory_mapping:
  546. * @cpu: The CPU whose memory mappings are to be obtained.
  547. * @list: Where to write the memory mappings to.
  548. * @errp: Pointer for reporting an #Error.
  549. *
  550. * Returns: %true on success, %false otherwise.
  551. */
  552. bool cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list,
  553. Error **errp);
  554. /**
  555. * cpu_write_elf64_note:
  556. * @f: pointer to a function that writes memory to a file
  557. * @cpu: The CPU whose memory is to be dumped
  558. * @cpuid: ID number of the CPU
  559. * @opaque: pointer to the CPUState struct
  560. */
  561. int cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cpu,
  562. int cpuid, void *opaque);
  563. /**
  564. * cpu_write_elf64_qemunote:
  565. * @f: pointer to a function that writes memory to a file
  566. * @cpu: The CPU whose memory is to be dumped
  567. * @cpuid: ID number of the CPU
  568. * @opaque: pointer to the CPUState struct
  569. */
  570. int cpu_write_elf64_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
  571. void *opaque);
  572. /**
  573. * cpu_write_elf32_note:
  574. * @f: pointer to a function that writes memory to a file
  575. * @cpu: The CPU whose memory is to be dumped
  576. * @cpuid: ID number of the CPU
  577. * @opaque: pointer to the CPUState struct
  578. */
  579. int cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cpu,
  580. int cpuid, void *opaque);
  581. /**
  582. * cpu_write_elf32_qemunote:
  583. * @f: pointer to a function that writes memory to a file
  584. * @cpu: The CPU whose memory is to be dumped
  585. * @cpuid: ID number of the CPU
  586. * @opaque: pointer to the CPUState struct
  587. */
  588. int cpu_write_elf32_qemunote(WriteCoreDumpFunction f, CPUState *cpu,
  589. void *opaque);
  590. /**
  591. * cpu_get_crash_info:
  592. * @cpu: The CPU to get crash information for
  593. *
  594. * Gets the previously saved crash information.
  595. * Caller is responsible for freeing the data.
  596. */
  597. GuestPanicInformation *cpu_get_crash_info(CPUState *cpu);
  598. #endif /* !CONFIG_USER_ONLY */
  599. /**
  600. * CPUDumpFlags:
  601. * @CPU_DUMP_CODE:
  602. * @CPU_DUMP_FPU: dump FPU register state, not just integer
  603. * @CPU_DUMP_CCOP: dump info about TCG QEMU's condition code optimization state
  604. * @CPU_DUMP_VPU: dump VPU registers
  605. */
  606. enum CPUDumpFlags {
  607. CPU_DUMP_CODE = 0x00010000,
  608. CPU_DUMP_FPU = 0x00020000,
  609. CPU_DUMP_CCOP = 0x00040000,
  610. CPU_DUMP_VPU = 0x00080000,
  611. };
  612. /**
  613. * cpu_dump_state:
  614. * @cpu: The CPU whose state is to be dumped.
  615. * @f: If non-null, dump to this stream, else to current print sink.
  616. *
  617. * Dumps CPU state.
  618. */
  619. void cpu_dump_state(CPUState *cpu, FILE *f, int flags);
  620. #ifndef CONFIG_USER_ONLY
  621. /**
  622. * cpu_get_phys_page_attrs_debug:
  623. * @cpu: The CPU to obtain the physical page address for.
  624. * @addr: The virtual address.
  625. * @attrs: Updated on return with the memory transaction attributes to use
  626. * for this access.
  627. *
  628. * Obtains the physical page corresponding to a virtual one, together
  629. * with the corresponding memory transaction attributes to use for the access.
  630. * Use it only for debugging because no protection checks are done.
  631. *
  632. * Returns: Corresponding physical page address or -1 if no page found.
  633. */
  634. hwaddr cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
  635. MemTxAttrs *attrs);
  636. /**
  637. * cpu_get_phys_page_debug:
  638. * @cpu: The CPU to obtain the physical page address for.
  639. * @addr: The virtual address.
  640. *
  641. * Obtains the physical page corresponding to a virtual one.
  642. * Use it only for debugging because no protection checks are done.
  643. *
  644. * Returns: Corresponding physical page address or -1 if no page found.
  645. */
  646. hwaddr cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
  647. /** cpu_asidx_from_attrs:
  648. * @cpu: CPU
  649. * @attrs: memory transaction attributes
  650. *
  651. * Returns the address space index specifying the CPU AddressSpace
  652. * to use for a memory access with the given transaction attributes.
  653. */
  654. int cpu_asidx_from_attrs(CPUState *cpu, MemTxAttrs attrs);
  655. /**
  656. * cpu_virtio_is_big_endian:
  657. * @cpu: CPU
  658. * Returns %true if a CPU which supports runtime configurable endianness
  659. * is currently big-endian.
  660. */
  661. bool cpu_virtio_is_big_endian(CPUState *cpu);
  662. #endif /* CONFIG_USER_ONLY */
  663. /**
  664. * cpu_list_add:
  665. * @cpu: The CPU to be added to the list of CPUs.
  666. */
  667. void cpu_list_add(CPUState *cpu);
  668. /**
  669. * cpu_list_remove:
  670. * @cpu: The CPU to be removed from the list of CPUs.
  671. */
  672. void cpu_list_remove(CPUState *cpu);
  673. /**
  674. * cpu_reset:
  675. * @cpu: The CPU whose state is to be reset.
  676. */
  677. void cpu_reset(CPUState *cpu);
  678. /**
  679. * cpu_class_by_name:
  680. * @typename: The CPU base type.
  681. * @cpu_model: The model string without any parameters.
  682. *
  683. * Looks up a concrete CPU #ObjectClass matching name @cpu_model.
  684. *
  685. * Returns: A concrete #CPUClass or %NULL if no matching class is found
  686. * or if the matching class is abstract.
  687. */
  688. ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model);
  689. /**
  690. * cpu_model_from_type:
  691. * @typename: The CPU type name
  692. *
  693. * Extract the CPU model name from the CPU type name. The
  694. * CPU type name is either the combination of the CPU model
  695. * name and suffix, or same to the CPU model name.
  696. *
  697. * Returns: CPU model name or NULL if the CPU class doesn't exist
  698. * The user should g_free() the string once no longer needed.
  699. */
  700. char *cpu_model_from_type(const char *typename);
  701. /**
  702. * cpu_create:
  703. * @typename: The CPU type.
  704. *
  705. * Instantiates a CPU and realizes the CPU.
  706. *
  707. * Returns: A #CPUState or %NULL if an error occurred.
  708. */
  709. CPUState *cpu_create(const char *typename);
  710. /**
  711. * parse_cpu_option:
  712. * @cpu_option: The -cpu option including optional parameters.
  713. *
  714. * processes optional parameters and registers them as global properties
  715. *
  716. * Returns: type of CPU to create or prints error and terminates process
  717. * if an error occurred.
  718. */
  719. const char *parse_cpu_option(const char *cpu_option);
  720. /**
  721. * cpu_has_work:
  722. * @cpu: The vCPU to check.
  723. *
  724. * Checks whether the CPU has work to do.
  725. *
  726. * Returns: %true if the CPU has work, %false otherwise.
  727. */
  728. static inline bool cpu_has_work(CPUState *cpu)
  729. {
  730. g_assert(cpu->cc->has_work);
  731. return cpu->cc->has_work(cpu);
  732. }
  733. /**
  734. * qemu_cpu_is_self:
  735. * @cpu: The vCPU to check against.
  736. *
  737. * Checks whether the caller is executing on the vCPU thread.
  738. *
  739. * Returns: %true if called from @cpu's thread, %false otherwise.
  740. */
  741. bool qemu_cpu_is_self(CPUState *cpu);
  742. /**
  743. * qemu_cpu_kick:
  744. * @cpu: The vCPU to kick.
  745. *
  746. * Kicks @cpu's thread.
  747. */
  748. void qemu_cpu_kick(CPUState *cpu);
  749. /**
  750. * cpu_is_stopped:
  751. * @cpu: The CPU to check.
  752. *
  753. * Checks whether the CPU is stopped.
  754. *
  755. * Returns: %true if run state is not running or if artificially stopped;
  756. * %false otherwise.
  757. */
  758. bool cpu_is_stopped(CPUState *cpu);
  759. /**
  760. * do_run_on_cpu:
  761. * @cpu: The vCPU to run on.
  762. * @func: The function to be executed.
  763. * @data: Data to pass to the function.
  764. * @mutex: Mutex to release while waiting for @func to run.
  765. *
  766. * Used internally in the implementation of run_on_cpu.
  767. */
  768. void do_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data,
  769. QemuMutex *mutex);
  770. /**
  771. * run_on_cpu:
  772. * @cpu: The vCPU to run on.
  773. * @func: The function to be executed.
  774. * @data: Data to pass to the function.
  775. *
  776. * Schedules the function @func for execution on the vCPU @cpu.
  777. */
  778. void run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data);
  779. /**
  780. * async_run_on_cpu:
  781. * @cpu: The vCPU to run on.
  782. * @func: The function to be executed.
  783. * @data: Data to pass to the function.
  784. *
  785. * Schedules the function @func for execution on the vCPU @cpu asynchronously.
  786. */
  787. void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data);
  788. /**
  789. * async_safe_run_on_cpu:
  790. * @cpu: The vCPU to run on.
  791. * @func: The function to be executed.
  792. * @data: Data to pass to the function.
  793. *
  794. * Schedules the function @func for execution on the vCPU @cpu asynchronously,
  795. * while all other vCPUs are sleeping.
  796. *
  797. * Unlike run_on_cpu and async_run_on_cpu, the function is run outside the
  798. * BQL.
  799. */
  800. void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data data);
  801. /**
  802. * cpu_in_exclusive_context()
  803. * @cpu: The vCPU to check
  804. *
  805. * Returns true if @cpu is an exclusive context, for example running
  806. * something which has previously been queued via async_safe_run_on_cpu().
  807. */
  808. static inline bool cpu_in_exclusive_context(const CPUState *cpu)
  809. {
  810. return cpu->exclusive_context_count;
  811. }
  812. /**
  813. * qemu_get_cpu:
  814. * @index: The CPUState@cpu_index value of the CPU to obtain.
  815. *
  816. * Gets a CPU matching @index.
  817. *
  818. * Returns: The CPU or %NULL if there is no matching CPU.
  819. */
  820. CPUState *qemu_get_cpu(int index);
  821. /**
  822. * cpu_exists:
  823. * @id: Guest-exposed CPU ID to lookup.
  824. *
  825. * Search for CPU with specified ID.
  826. *
  827. * Returns: %true - CPU is found, %false - CPU isn't found.
  828. */
  829. bool cpu_exists(int64_t id);
  830. /**
  831. * cpu_by_arch_id:
  832. * @id: Guest-exposed CPU ID of the CPU to obtain.
  833. *
  834. * Get a CPU with matching @id.
  835. *
  836. * Returns: The CPU or %NULL if there is no matching CPU.
  837. */
  838. CPUState *cpu_by_arch_id(int64_t id);
  839. /**
  840. * cpu_interrupt:
  841. * @cpu: The CPU to set an interrupt on.
  842. * @mask: The interrupts to set.
  843. *
  844. * Invokes the interrupt handler.
  845. */
  846. void cpu_interrupt(CPUState *cpu, int mask);
  847. /**
  848. * cpu_set_pc:
  849. * @cpu: The CPU to set the program counter for.
  850. * @addr: Program counter value.
  851. *
  852. * Sets the program counter for a CPU.
  853. */
  854. static inline void cpu_set_pc(CPUState *cpu, vaddr addr)
  855. {
  856. cpu->cc->set_pc(cpu, addr);
  857. }
  858. /**
  859. * cpu_reset_interrupt:
  860. * @cpu: The CPU to clear the interrupt on.
  861. * @mask: The interrupt mask to clear.
  862. *
  863. * Resets interrupts on the vCPU @cpu.
  864. */
  865. void cpu_reset_interrupt(CPUState *cpu, int mask);
  866. /**
  867. * cpu_exit:
  868. * @cpu: The CPU to exit.
  869. *
  870. * Requests the CPU @cpu to exit execution.
  871. */
  872. void cpu_exit(CPUState *cpu);
  873. /**
  874. * cpu_pause:
  875. * @cpu: The CPU to pause.
  876. *
  877. * Pauses CPU, i.e. puts CPU into stopped state.
  878. */
  879. void cpu_pause(CPUState *cpu);
  880. /**
  881. * cpu_resume:
  882. * @cpu: The CPU to resume.
  883. *
  884. * Resumes CPU, i.e. puts CPU into runnable state.
  885. */
  886. void cpu_resume(CPUState *cpu);
  887. /**
  888. * cpu_remove_sync:
  889. * @cpu: The CPU to remove.
  890. *
  891. * Requests the CPU to be removed and waits till it is removed.
  892. */
  893. void cpu_remove_sync(CPUState *cpu);
  894. /**
  895. * free_queued_cpu_work() - free all items on CPU work queue
  896. * @cpu: The CPU which work queue to free.
  897. */
  898. void free_queued_cpu_work(CPUState *cpu);
  899. /**
  900. * process_queued_cpu_work() - process all items on CPU work queue
  901. * @cpu: The CPU which work queue to process.
  902. */
  903. void process_queued_cpu_work(CPUState *cpu);
  904. /**
  905. * cpu_exec_start:
  906. * @cpu: The CPU for the current thread.
  907. *
  908. * Record that a CPU has started execution and can be interrupted with
  909. * cpu_exit.
  910. */
  911. void cpu_exec_start(CPUState *cpu);
  912. /**
  913. * cpu_exec_end:
  914. * @cpu: The CPU for the current thread.
  915. *
  916. * Record that a CPU has stopped execution and exclusive sections
  917. * can be executed without interrupting it.
  918. */
  919. void cpu_exec_end(CPUState *cpu);
  920. /**
  921. * start_exclusive:
  922. *
  923. * Wait for a concurrent exclusive section to end, and then start
  924. * a section of work that is run while other CPUs are not running
  925. * between cpu_exec_start and cpu_exec_end. CPUs that are running
  926. * cpu_exec are exited immediately. CPUs that call cpu_exec_start
  927. * during the exclusive section go to sleep until this CPU calls
  928. * end_exclusive.
  929. */
  930. void start_exclusive(void);
  931. /**
  932. * end_exclusive:
  933. *
  934. * Concludes an exclusive execution section started by start_exclusive.
  935. */
  936. void end_exclusive(void);
  937. /**
  938. * qemu_init_vcpu:
  939. * @cpu: The vCPU to initialize.
  940. *
  941. * Initializes a vCPU.
  942. */
  943. void qemu_init_vcpu(CPUState *cpu);
  944. #define SSTEP_ENABLE 0x1 /* Enable simulated HW single stepping */
  945. #define SSTEP_NOIRQ 0x2 /* Do not use IRQ while single stepping */
  946. #define SSTEP_NOTIMER 0x4 /* Do not Timers while single stepping */
  947. /**
  948. * cpu_single_step:
  949. * @cpu: CPU to the flags for.
  950. * @enabled: Flags to enable.
  951. *
  952. * Enables or disables single-stepping for @cpu.
  953. */
  954. void cpu_single_step(CPUState *cpu, int enabled);
  955. /* Breakpoint/watchpoint flags */
  956. #define BP_MEM_READ 0x01
  957. #define BP_MEM_WRITE 0x02
  958. #define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE)
  959. #define BP_STOP_BEFORE_ACCESS 0x04
  960. /* 0x08 currently unused */
  961. #define BP_GDB 0x10
  962. #define BP_CPU 0x20
  963. #define BP_ANY (BP_GDB | BP_CPU)
  964. #define BP_HIT_SHIFT 6
  965. #define BP_WATCHPOINT_HIT_READ (BP_MEM_READ << BP_HIT_SHIFT)
  966. #define BP_WATCHPOINT_HIT_WRITE (BP_MEM_WRITE << BP_HIT_SHIFT)
  967. #define BP_WATCHPOINT_HIT (BP_MEM_ACCESS << BP_HIT_SHIFT)
  968. int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
  969. CPUBreakpoint **breakpoint);
  970. int cpu_breakpoint_remove(CPUState *cpu, vaddr pc, int flags);
  971. void cpu_breakpoint_remove_by_ref(CPUState *cpu, CPUBreakpoint *breakpoint);
  972. void cpu_breakpoint_remove_all(CPUState *cpu, int mask);
  973. /* Return true if PC matches an installed breakpoint. */
  974. static inline bool cpu_breakpoint_test(CPUState *cpu, vaddr pc, int mask)
  975. {
  976. CPUBreakpoint *bp;
  977. if (unlikely(!QTAILQ_EMPTY(&cpu->breakpoints))) {
  978. QTAILQ_FOREACH(bp, &cpu->breakpoints, entry) {
  979. if (bp->pc == pc && (bp->flags & mask)) {
  980. return true;
  981. }
  982. }
  983. }
  984. return false;
  985. }
  986. #if defined(CONFIG_USER_ONLY)
  987. static inline int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
  988. int flags, CPUWatchpoint **watchpoint)
  989. {
  990. return -ENOSYS;
  991. }
  992. static inline int cpu_watchpoint_remove(CPUState *cpu, vaddr addr,
  993. vaddr len, int flags)
  994. {
  995. return -ENOSYS;
  996. }
  997. static inline void cpu_watchpoint_remove_by_ref(CPUState *cpu,
  998. CPUWatchpoint *wp)
  999. {
  1000. }
  1001. static inline void cpu_watchpoint_remove_all(CPUState *cpu, int mask)
  1002. {
  1003. }
  1004. #else
  1005. int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
  1006. int flags, CPUWatchpoint **watchpoint);
  1007. int cpu_watchpoint_remove(CPUState *cpu, vaddr addr,
  1008. vaddr len, int flags);
  1009. void cpu_watchpoint_remove_by_ref(CPUState *cpu, CPUWatchpoint *watchpoint);
  1010. void cpu_watchpoint_remove_all(CPUState *cpu, int mask);
  1011. #endif
  1012. /**
  1013. * cpu_get_address_space:
  1014. * @cpu: CPU to get address space from
  1015. * @asidx: index identifying which address space to get
  1016. *
  1017. * Return the requested address space of this CPU. @asidx
  1018. * specifies which address space to read.
  1019. */
  1020. AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx);
  1021. G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
  1022. G_GNUC_PRINTF(2, 3);
  1023. /* $(top_srcdir)/cpu.c */
  1024. void cpu_class_init_props(DeviceClass *dc);
  1025. void cpu_exec_initfn(CPUState *cpu);
  1026. void cpu_vmstate_register(CPUState *cpu);
  1027. void cpu_vmstate_unregister(CPUState *cpu);
  1028. bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
  1029. void cpu_exec_unrealizefn(CPUState *cpu);
  1030. void cpu_exec_reset_hold(CPUState *cpu);
  1031. const char *target_name(void);
  1032. #ifdef COMPILING_PER_TARGET
  1033. #ifndef CONFIG_USER_ONLY
  1034. extern const VMStateDescription vmstate_cpu_common;
  1035. #define VMSTATE_CPU() { \
  1036. .name = "parent_obj", \
  1037. .size = sizeof(CPUState), \
  1038. .vmsd = &vmstate_cpu_common, \
  1039. .flags = VMS_STRUCT, \
  1040. .offset = 0, \
  1041. }
  1042. #endif /* !CONFIG_USER_ONLY */
  1043. #endif /* COMPILING_PER_TARGET */
  1044. #define UNASSIGNED_CPU_INDEX -1
  1045. #define UNASSIGNED_CLUSTER_INDEX -1
  1046. #endif