@@ -125,14 +125,8 @@ The VHM will respond to the ioctl:
125
125
The hypercall ``HC_CREATE_VCPU `` is handled in the hypervisor with
126
126
the parameter:
127
127
128
- .. code-block :: c
129
-
130
- struct acrn_create_vcpu {
131
- /** the virtual CPU ID for the VCPU created */
132
- uint16_t vcpu_id;
133
- /** the physical CPU ID for the VCPU created */
134
- uint16_t pcpu_id;
135
- } __attribute__((aligned(8)));
128
+ .. doxygenstruct :: acrn_create_vcpu
129
+ :project: Project ACRN
136
130
137
131
CPU assignment management in HV
138
132
===============================
@@ -187,43 +181,26 @@ the major states are:
187
181
188
182
ACRN vCPU state transitions
189
183
190
- This table shows the functions which drive the state machine of the vCPU
184
+ Following functions are used to drive the state machine of the vCPU
191
185
lifecycle:
192
186
193
- .. list-table ::
194
- :widths: 20 80
195
- :header-rows: 1
196
-
197
- * - **Function **
198
- - **Description **
199
-
200
- * - create_vcpu
201
- - Creates/allocates a vCPU instance, with initialization for its
202
- vcpu_id, vpid, vmcs, vlapic, etc. It sets the init vCPU state
203
- to VCPU_INIT.
204
-
205
- * - schedule_vcpu
206
- - Adds a vCPU into the run queue and make a reschedule request for it.
207
- It sets the vCPU state to VCPU_RUNNING.
187
+ .. doxygenfunction :: create_vcpu
188
+ :project: Project ACRN
208
189
209
- * - pause_vcpu
210
- - Change a vCPU state to VCPU_PAUSED or VCPU_ZOMBIE, and make a
211
- reschedule request for it.
190
+ .. doxygenfunction :: schedule_vcpu
191
+ :project: Project ACRN
212
192
213
- * - resume_vcpu
214
- - Change a vCPU state to VCPU_RUNNING, and make a reschedule request
215
- for it.
193
+ .. doxygenfunction :: pause_vcpu
194
+ :project: Project ACRN
216
195
217
- * - reset_vcpu
218
- - Reset all fields in a vCPU instance, the vCPU state is reset to
219
- VCPU_INIT.
196
+ .. doxygenfunction :: resume_vcpu
197
+ :project: Project ACRN
220
198
221
- * - destroy_vcpu
222
- - Destroy/free a vCPU instance.
199
+ .. doxygenfunction :: reset_vcpu
200
+ :project: Project ACRN
223
201
224
- * - start/run_vcpu
225
- - An interface in vCPU thread to implement VM entry and VM exit.
226
- A CPU switches between VMX root mode and non-root mode based on it.
202
+ .. doxygenfunction :: run_vcpu
203
+ :project: Project ACRN
227
204
228
205
229
206
vCPU Scheduling
@@ -322,37 +299,8 @@ vCPU Run Context
322
299
During a vCPU switch between root and non-root mode, the run context of
323
300
the vCPU is saved and restored using this structure:
324
301
325
- .. code-block :: c
326
-
327
- struct run_context {
328
- /* Contains the guest register set.
329
- * NOTE: This must be the first element in the structure, so that
330
- * the offsets in vmx_asm.S match
331
- */
332
- union {
333
- struct cpu_gp_regs regs;
334
- uint64_t longs[NUM_GPRS];
335
- } guest_cpu_regs;
336
-
337
- /* The guests CR registers 0, 2, 3 and 4. */
338
- uint64_t cr0;
339
-
340
- /* CPU_CONTEXT_OFFSET_CR2 =
341
- * offsetof(struct run_context, cr2) = 136
342
- */
343
- uint64_t cr2;
344
- uint64_t cr4;
345
-
346
- uint64_t rip;
347
- uint64_t rflags;
348
-
349
- /* CPU_CONTEXT_OFFSET_IA32_SPEC_CTRL =
350
- * offsetof(struct run_context, ia32_spec_ctrl) = 168
351
- */
352
- uint64_t ia32_spec_ctrl;
353
- uint64_t ia32_efer;
354
- };
355
-
302
+ .. doxygenstruct :: run_context
303
+ :project: Project ACRN
356
304
357
305
The vCPU handles runtime context saving by three different
358
306
categories:
@@ -385,54 +333,53 @@ categories:
385
333
386
334
For the first two categories above, ACRN provides these get/set APIs:
387
335
388
- .. list-table ::
389
- :widths: 30 70
390
- :header-rows: 1
336
+ .. doxygenfunction :: vcpu_get_gpreg
337
+ :project: Project ACRN
391
338
392
- * - ** APIs **
393
- - ** Desc **
339
+ .. doxygenfunction :: vcpu_set_gpreg
340
+ :project: Project ACRN
394
341
395
- * - vcpu_get_gpreg
396
- - Get target vCPU's general purpose registers value in run_context
342
+ .. doxygenfunction :: vcpu_get_rip
343
+ :project: Project ACRN
397
344
398
- * - vcpu_set_gpreg
399
- - Set target vCPU's general purpose registers value in run_context
345
+ .. doxygenfunction :: vcpu_set_rip
346
+ :project: Project ACRN
400
347
401
- * - vcpu_get_rip
402
- - Get & cache target vCPU's RIP in run_context
348
+ .. doxygenfunction :: vcpu_get_rsp
349
+ :project: Project ACRN
403
350
404
- * - vcpu_set_rip
405
- - Update target vCPU's RIP in run_context
351
+ .. doxygenfunction :: vcpu_set_rsp
352
+ :project: Project ACRN
406
353
407
- * - vcpu_get_rsp
408
- - Get & cache target vCPU's RSP in run_context
354
+ .. doxygenfunction :: vcpu_get_efer
355
+ :project: Project ACRN
409
356
410
- * - vcpu_set_rsp
411
- - Update target vCPU's RSP in run_context
357
+ .. doxygenfunction :: vcpu_set_efer
358
+ :project: Project ACRN
412
359
413
- * - vcpu_get_efer
414
- - Get & cache target vCPU's EFER in run_context
360
+ .. doxygenfunction :: vcpu_get_rflags
361
+ :project: Project ACRN
415
362
416
- * - vcpu_set_efer
417
- - Update target vCPU's EFER in run_context
363
+ .. doxygenfunction :: vcpu_set_rflags
364
+ :project: Project ACRN
418
365
419
- * - vcpu_get_rflags
420
- - Get & cache target vCPU's RFLAGS in run_context
366
+ .. doxygenfunction :: vcpu_get_cr0
367
+ :project: Project ACRN
421
368
422
- * - vcpu_set_rflags
423
- - Update target vCPU's RFLAGS in run_context
369
+ .. doxygenfunction :: vcpu_set_cr0
370
+ :project: Project ACRN
424
371
425
- * - vcpu_get_cr2
426
- - Get target vCPU's CR2 register value in run_context
372
+ .. doxygenfunction :: vcpu_get_cr2
373
+ :project: Project ACRN
427
374
428
- * - vcpu_set_cr2
429
- - Set target vCPU's CR2 register value in run_context
375
+ .. doxygenfunction :: vcpu_set_cr2
376
+ :project: Project ACRN
430
377
431
- * - vcpu_get_cr0/4
432
- - Get & cache target vCPU's CR0/4 register in run_context
378
+ .. doxygenfunction :: vcpu_get_cr4
379
+ :project: Project ACRN
433
380
434
- * - vcpu_set_cr0/4
435
- - Update target vCPU's CR0/4 register in run_context
381
+ .. doxygenfunction :: vcpu_set_cr4
382
+ :project: Project ACRN
436
383
437
384
438
385
VM Exit Handlers
@@ -646,49 +593,10 @@ For a guest vCPU's state initialization:
646
593
- UOS BSP: DM context initialization through hypercall
647
594
648
595
- If it's AP, then it will always start from real mode, and the start
649
- vector will always come from vlapic INIT-SIPI emulation. So there
650
- is no need for *boot_ctx *. Instead we use a static guest state setting
651
- pre-defined for real mode.
652
-
653
- .. code-block :: c
654
-
655
- struct acrn_vcpu_state {
656
- struct acrn_gp_regs gprs;
657
- struct acrn_dt_desc gdt;
658
- uint64_t rip;
659
- uint64_t cs_base;
660
- uint64_t cr0;
661
- uint64_t cr4;
662
- uint64_t reserved_64[4];
663
-
664
- uint32_t cs_ar;
665
- uint32_t reserved_32[4];
666
-
667
- /* don't change the order of following sel */
668
- uint16_t cs_sel;
669
- uint16_t ss_sel;
670
- uint16_t ds_sel;
671
- uint16_t es_sel;
672
- uint16_t fs_sel;
673
- uint16_t gs_sel;
674
-
675
- uint16_t reserved_16[4];
676
- };
677
-
678
- struct boot_ctx {
679
- struct acrn_vcpu_state vcpu_state;
680
- struct acrn_dt_desc idt;
681
- uint64_t cr3;
682
- uint64_t ia32_efer;
683
- uint64_t rflags;
684
-
685
- void *rsdp;
686
- void *ap_trampoline_buf;
687
-
688
- uint16_t ldt_sel;
689
- uint16_t tr_sel;
690
- }__attribute__((aligned(8)));
596
+ vector will always come from vlapic INIT-SIPI emulation.
691
597
598
+ .. doxygenstruct :: acrn_vcpu_regs
599
+ :project: Project ACRN
692
600
693
601
.. list-table ::
694
602
:widths: 20 40 10 30
0 commit comments