Changeset 11798 in vbox
- Timestamp:
- Aug 29, 2008 9:48:49 AM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 35616
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/cpum.h
r11704 r11798 363 363 */ 364 364 #define CPUMCTX2CORE(pCtx) ((PCPUMCTXCORE)(void *)&(pCtx)->edi) 365 366 367 /** 368 * Selector hidden registers. (version 1.6) 369 */ 370 typedef struct CPUMSELREGHID_VER1_6 371 { 372 /** Base register. */ 373 uint32_t u32Base; 374 /** Limit (expanded). */ 375 uint32_t u32Limit; 376 /** Flags. 377 * This is the high 32-bit word of the descriptor entry. 378 * Only the flags, dpl and type are used. */ 379 X86DESCATTR Attr; 380 } CPUMSELREGHID_VER1_6; 381 382 /** 383 * CPU context. (Version 1.6) 384 */ 385 #pragma pack(1) 386 typedef struct CPUMCTX_VER1_6 387 { 388 /** FPU state. (16-byte alignment) 389 * @todo This doesn't have to be in X86FXSTATE on CPUs without fxsr - we need a type for the 390 * actual format or convert it (waste of time). */ 391 X86FXSTATE fpu; 392 393 /** CPUMCTXCORE Part. 394 * @{ */ 395 union 396 { 397 uint32_t edi; 398 uint64_t rdi; 399 }; 400 union 401 { 402 uint32_t esi; 403 uint64_t rsi; 404 }; 405 union 406 { 407 uint32_t ebp; 408 uint64_t rbp; 409 }; 410 union 411 { 412 uint32_t eax; 413 uint64_t rax; 414 }; 415 union 416 { 417 uint32_t ebx; 418 uint64_t rbx; 419 }; 420 union 421 { 422 uint32_t edx; 423 uint64_t rdx; 424 }; 425 union 426 { 427 uint32_t ecx; 428 uint64_t rcx; 429 }; 430 /* Note: we rely on the exact layout, because we use lss esp, [] in the switcher */ 431 uint32_t esp; 432 RTSEL ss; 433 RTSEL ssPadding; 434 /* Note: no overlap with esp here. */ 435 uint64_t rsp; 436 437 RTSEL gs; 438 RTSEL gsPadding; 439 RTSEL fs; 440 RTSEL fsPadding; 441 RTSEL es; 442 RTSEL esPadding; 443 RTSEL ds; 444 RTSEL dsPadding; 445 RTSEL cs; 446 RTSEL csPadding[3]; /* 3 words to force 8 byte alignment for the remainder */ 447 448 union 449 { 450 X86EFLAGS eflags; 451 X86RFLAGS rflags; 452 }; 453 union 454 { 455 uint32_t eip; 456 uint64_t rip; 457 }; 458 459 uint64_t r8; 460 uint64_t r9; 461 uint64_t r10; 462 uint64_t r11; 463 uint64_t r12; 464 uint64_t r13; 465 uint64_t r14; 466 uint64_t r15; 467 468 /** Hidden selector registers. 469 * @{ */ 470 CPUMSELREGHID_VER1_6 esHid; 471 CPUMSELREGHID_VER1_6 csHid; 472 CPUMSELREGHID_VER1_6 ssHid; 473 CPUMSELREGHID_VER1_6 dsHid; 474 CPUMSELREGHID_VER1_6 fsHid; 475 CPUMSELREGHID_VER1_6 gsHid; 476 /** @} */ 477 478 /** @} */ 479 480 /** Control registers. 481 * @{ */ 482 uint64_t cr0; 483 uint64_t cr2; 484 uint64_t cr3; 485 uint64_t cr4; 486 uint64_t cr8; 487 /** @} */ 488 489 /** Debug registers. 490 * @{ */ 491 uint64_t dr0; 492 uint64_t dr1; 493 uint64_t dr2; 494 uint64_t dr3; 495 uint64_t dr4; /**< @todo remove dr4 and dr5. */ 496 uint64_t dr5; 497 uint64_t dr6; 498 uint64_t dr7; 499 /* DR8-15 are currently not supported */ 500 /** @} */ 501 502 /** Global Descriptor Table register. */ 503 VBOXGDTR_VER1_6 gdtr; 504 uint16_t gdtrPadding; 505 uint32_t gdtrPadding64;/** @todo fix this hack */ 506 /** Interrupt Descriptor Table register. */ 507 VBOXIDTR_VER1_6 idtr; 508 uint16_t idtrPadding; 509 uint32_t idtrPadding64;/** @todo fix this hack */ 510 /** The task register. 511 * Only the guest context uses all the members. */ 512 RTSEL ldtr; 513 RTSEL ldtrPadding; 514 /** The task register. 515 * Only the guest context uses all the members. */ 516 RTSEL tr; 517 RTSEL trPadding; 518 519 /** The sysenter msr registers. 520 * This member is not used by the hypervisor context. */ 521 CPUMSYSENTER SysEnter; 522 523 /** System MSRs. 524 * @{ */ 525 uint64_t msrEFER; 526 uint64_t msrSTAR; 527 uint64_t msrPAT; 528 uint64_t msrLSTAR; 529 uint64_t msrCSTAR; 530 uint64_t msrSFMASK; 531 uint64_t msrFSBASE; 532 uint64_t msrGSBASE; 533 uint64_t msrKERNELGSBASE; 534 /** @} */ 535 536 /** Hidden selector registers. 537 * @{ */ 538 CPUMSELREGHID_VER1_6 ldtrHid; 539 CPUMSELREGHID_VER1_6 trHid; 540 /** @} */ 541 542 /* padding to get 32byte aligned size */ 543 uint32_t padding[2]; 544 } CPUMCTX_VER1_6; 545 #pragma pack() 365 546 366 547 /** -
trunk/include/VBox/types.h
r11306 r11798 375 375 } VBOXIDTR, *PVBOXIDTR; 376 376 #pragma pack() 377 378 #pragma pack(1) 379 /** IDTR from version 1.6 */ 380 typedef struct VBOXIDTR_VER1_6 381 { 382 /** Size of the IDT. */ 383 uint16_t cbIdt; 384 /** Address of the IDT. */ 385 uint32_t pIdt; 386 } VBOXIDTR_VER1_6, *PVBOXIDTR_VER1_6; 387 #pragma pack() 388 377 389 /** @} */ 378 390 … … 397 409 /** Pointer to GDTR. */ 398 410 typedef VBOXGDTR *PVBOXGDTR; 411 412 #pragma pack(1) 413 /** GDTR from version 1.6 */ 414 typedef struct VBOXGDTR_VER1_6 415 { 416 /** Size of the GDT. */ 417 uint16_t cbGdt; 418 /** Address of the GDT. */ 419 uint32_t pGdt; 420 } VBOXGDTR_VER1_6; 421 #pragma pack() 399 422 400 423 /** @} */ -
trunk/src/VBox/VMM/CPUM.cpp
r11792 r11798 64 64 *******************************************************************************/ 65 65 /** The saved state version. */ 66 #define CPUM_SAVED_STATE_VERSION 8 66 #define CPUM_SAVED_STATE_VERSION_VER1_6 6 67 #define CPUM_SAVED_STATE_VERSION 8 67 68 68 69 … … 752 753 } 753 754 755 /** 756 * Load a version 1.6 CPUMCTX structure. 757 * 758 * @returns VBox status code. 759 * @param pVM VM Handle. 760 * @param pCpumctx16 Version 1.6 CPUMCTX 761 */ 762 static void cpumR3LoadCPUM1_6(PVM pVM, CPUMCTX_VER1_6 *pCpumctx16) 763 { 764 #define CPUMCTX16_LOADREG(regname) pVM->cpum.s.Guest.regname = pCpumctx16->regname; 765 766 #define CPUMCTX16_LOADHIDREG(regname) \ 767 pVM->cpum.s.Guest.regname##Hid.u64Base = pCpumctx16->regname##Hid.u32Base; \ 768 pVM->cpum.s.Guest.regname##Hid.u32Limit = pCpumctx16->regname##Hid.u32Limit; \ 769 pVM->cpum.s.Guest.regname##Hid.Attr = pCpumctx16->regname##Hid.Attr; 770 771 #define CPUMCTX16_LOADSEGREG(regname) \ 772 pVM->cpum.s.Guest.regname = pCpumctx16->regname; \ 773 CPUMCTX16_LOADHIDREG(regname); 774 775 pVM->cpum.s.Guest.fpu = pCpumctx16->fpu; 776 777 CPUMCTX16_LOADREG(rax); 778 CPUMCTX16_LOADREG(rbx); 779 CPUMCTX16_LOADREG(rcx); 780 CPUMCTX16_LOADREG(rdx); 781 CPUMCTX16_LOADREG(rdi); 782 CPUMCTX16_LOADREG(rsi); 783 CPUMCTX16_LOADREG(rbp); 784 CPUMCTX16_LOADREG(rsp); 785 CPUMCTX16_LOADREG(rip); 786 CPUMCTX16_LOADREG(rflags); 787 788 CPUMCTX16_LOADSEGREG(cs); 789 CPUMCTX16_LOADSEGREG(ds); 790 CPUMCTX16_LOADSEGREG(es); 791 CPUMCTX16_LOADSEGREG(fs); 792 CPUMCTX16_LOADSEGREG(gs); 793 CPUMCTX16_LOADSEGREG(ss); 794 795 CPUMCTX16_LOADREG(r8); 796 CPUMCTX16_LOADREG(r9); 797 CPUMCTX16_LOADREG(r10); 798 CPUMCTX16_LOADREG(r11); 799 CPUMCTX16_LOADREG(r12); 800 CPUMCTX16_LOADREG(r13); 801 CPUMCTX16_LOADREG(r14); 802 CPUMCTX16_LOADREG(r15); 803 804 CPUMCTX16_LOADREG(cr0); 805 CPUMCTX16_LOADREG(cr2); 806 CPUMCTX16_LOADREG(cr3); 807 CPUMCTX16_LOADREG(cr4); 808 809 CPUMCTX16_LOADREG(dr0); 810 CPUMCTX16_LOADREG(dr1); 811 CPUMCTX16_LOADREG(dr2); 812 CPUMCTX16_LOADREG(dr3); 813 CPUMCTX16_LOADREG(dr4); 814 CPUMCTX16_LOADREG(dr5); 815 CPUMCTX16_LOADREG(dr6); 816 CPUMCTX16_LOADREG(dr7); 817 818 pVM->cpum.s.Guest.gdtr.cbGdt = pCpumctx16->gdtr.cbGdt; 819 pVM->cpum.s.Guest.gdtr.pGdt = pCpumctx16->gdtr.pGdt; 820 pVM->cpum.s.Guest.idtr.cbIdt = pCpumctx16->idtr.cbIdt; 821 pVM->cpum.s.Guest.idtr.pIdt = pCpumctx16->idtr.pIdt; 822 823 CPUMCTX16_LOADREG(ldtr); 824 CPUMCTX16_LOADREG(tr); 825 826 pVM->cpum.s.Guest.SysEnter = pCpumctx16->SysEnter; 827 828 CPUMCTX16_LOADREG(msrEFER); 829 CPUMCTX16_LOADREG(msrSTAR); 830 CPUMCTX16_LOADREG(msrPAT); 831 CPUMCTX16_LOADREG(msrLSTAR); 832 CPUMCTX16_LOADREG(msrCSTAR); 833 CPUMCTX16_LOADREG(msrSFMASK); 834 CPUMCTX16_LOADREG(msrKERNELGSBASE); 835 836 CPUMCTX16_LOADHIDREG(ldtr); 837 CPUMCTX16_LOADHIDREG(tr); 838 839 #undef CPUMCTX16_LOADHIDREG 840 #undef CPUMCTX16_LOADSEGREG 841 #undef CPUMCTX16_LOADREG 842 } 754 843 755 844 /** … … 766 855 * Validate version. 767 856 */ 768 if (u32Version != CPUM_SAVED_STATE_VERSION) 857 if ( u32Version != CPUM_SAVED_STATE_VERSION 858 && u32Version != CPUM_SAVED_STATE_VERSION_VER1_6) 769 859 { 770 860 AssertMsgFailed(("cpuR3Load: Invalid version u32Version=%d!\n", u32Version)); … … 780 870 pVM->cpum.s.Hyper.cr3 = uCR3; 781 871 pVM->cpum.s.Hyper.esp = uESP; 782 SSMR3GetMem(pSSM, &pVM->cpum.s.Guest, sizeof(pVM->cpum.s.Guest)); 872 if (u32Version == CPUM_SAVED_STATE_VERSION_VER1_6) 873 { 874 CPUMCTX_VER1_6 cpumctx16; 875 memset(&pVM->cpum.s.Guest, 0, sizeof(pVM->cpum.s.Guest)); 876 SSMR3GetMem(pSSM, &cpumctx16, sizeof(cpumctx16)); 877 878 /* Save the old cpumctx state into the new one. */ 879 cpumR3LoadCPUM1_6(pVM, &cpumctx16); 880 } 881 else 882 SSMR3GetMem(pSSM, &pVM->cpum.s.Guest, sizeof(pVM->cpum.s.Guest)); 883 783 884 SSMR3GetU32(pSSM, &pVM->cpum.s.fUseFlags); 784 885 SSMR3GetU32(pSSM, &pVM->cpum.s.fChanged);
Note:
See TracChangeset
for help on using the changeset viewer.