VirtualBox

Changeset 96948 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Sep 30, 2022 6:58:20 AM (2 years ago)
Author:
vboxsync
Message:

IEM: Slightly corrected SYSCALL/SYSRET, fixed logging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp

    r96932 r96948  
    41224122    if (uNewCs == 0 || uNewSs == 0)
    41234123    {
     4124        /** @todo Neither Intel nor AMD document this check. */
    41244125        Log(("syscall: msrSTAR.CS = 0 or SS = 0 -> #GP(0)\n"));
    41254126        return iemRaiseGeneralProtectionFault0(pVCpu);
     
    41354136        if (!IEM_IS_CANONICAL(uNewRip))
    41364137        {
     4138            /** @todo Intel claims this can't happen because IA32_LSTAR MSR can't be written with non-canonical address. */
    41374139            Log(("syscall: New RIP not canonical -> #UD\n"));
    41384140            return iemRaiseUndefinedOpcode(pVCpu);
     
    41424144         * Commit it.
    41434145         */
    4144         Log(("syscall: %04x:%016RX64 [efl=%#llx] -> %04x:%016RX64\n", pVCpu->cpum.GstCtx.cs, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, uNewRip));
     4146        Log(("syscall: %04x:%016RX64 [efl=%#llx] -> %04x:%016RX64\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, uNewRip));
    41454147        pVCpu->cpum.GstCtx.rcx           = pVCpu->cpum.GstCtx.rip + cbInstr;
    41464148        pVCpu->cpum.GstCtx.rip           = uNewRip;
     
    41524154
    41534155        pVCpu->cpum.GstCtx.cs.Attr.u     = X86DESCATTR_P | X86DESCATTR_G | X86DESCATTR_L | X86DESCATTR_DT | X86_SEL_TYPE_ER_ACC;
    4154         pVCpu->cpum.GstCtx.ss.Attr.u     = X86DESCATTR_P | X86DESCATTR_G | X86DESCATTR_L | X86DESCATTR_DT | X86_SEL_TYPE_RW_ACC;
     4156        pVCpu->cpum.GstCtx.ss.Attr.u     = X86DESCATTR_P | X86DESCATTR_G | X86DESCATTR_D | X86DESCATTR_DT | X86_SEL_TYPE_RW_ACC;
    41554157    }
    41564158    else
     
    41594161         * Commit it.
    41604162         */
    4161         Log(("syscall: %04x:%08RX32 [efl=%#x] -> %04x:%08RX32\n",
    4162              pVCpu->cpum.GstCtx.cs, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.u, uNewCs, (uint32_t)(pVCpu->cpum.GstCtx.msrSTAR & MSR_K6_STAR_SYSCALL_EIP_MASK)));
     4163        Log(("syscall: %04x:%08RX32 [efl=%#x] -> %04x:%08RX32\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.u, uNewCs, (uint32_t)(pVCpu->cpum.GstCtx.msrSTAR & MSR_K6_STAR_SYSCALL_EIP_MASK)));
    41634164        pVCpu->cpum.GstCtx.rcx           = pVCpu->cpum.GstCtx.eip + cbInstr;
    41644165        pVCpu->cpum.GstCtx.rip           = pVCpu->cpum.GstCtx.msrSTAR & MSR_K6_STAR_SYSCALL_EIP_MASK;
     
    41794180    pVCpu->cpum.GstCtx.ss.u32Limit   = UINT32_MAX;
    41804181    pVCpu->cpum.GstCtx.ss.fFlags     = CPUMSELREG_FLAGS_VALID;
     4182
     4183    pVCpu->iem.s.uCpl       = 0;
     4184    pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu);
    41814185
    41824186    /* Flush the prefetch buffer. */
     
    42474251        if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
    42484252        {
    4249             Log(("sysret: %04x:%016RX64 [efl=%#llx] -> %04x:%016RX64 [r11=%#llx]\n",
    4250                  pVCpu->cpum.GstCtx.cs, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, pVCpu->cpum.GstCtx.rcx, pVCpu->cpum.GstCtx.r11));
    4251             /* Note! We disregard intel manual regarding the RCX cananonical
     4253            Log(("sysret: %04x:%016RX64 [efl=%#llx] -> %04x:%016RX64 [r11=%#llx]\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, pVCpu->cpum.GstCtx.rcx, pVCpu->cpum.GstCtx.r11));
     4254            /* Note! We disregard intel manual regarding the RCX canonical
    42524255                     check, ask intel+xen why AMD doesn't do it. */
    42534256            pVCpu->cpum.GstCtx.rip       = pVCpu->cpum.GstCtx.rcx;
     
    42574260        else
    42584261        {
    4259             Log(("sysret: %04x:%016RX64 [efl=%#llx] -> %04x:%08RX32 [r11=%#llx]\n",
    4260                  pVCpu->cpum.GstCtx.cs, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, pVCpu->cpum.GstCtx.ecx, pVCpu->cpum.GstCtx.r11));
     4262            Log(("sysret: %04x:%016RX64 [efl=%#llx] -> %04x:%08RX32 [r11=%#llx]\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.rip, pVCpu->cpum.GstCtx.rflags.u, uNewCs, pVCpu->cpum.GstCtx.ecx, pVCpu->cpum.GstCtx.r11));
    42614263            pVCpu->cpum.GstCtx.rip       = pVCpu->cpum.GstCtx.ecx;
    42624264            pVCpu->cpum.GstCtx.cs.Attr.u = X86DESCATTR_P | X86DESCATTR_G | X86DESCATTR_D | X86DESCATTR_DT | X86_SEL_TYPE_ER_ACC
     
    42644266        }
    42654267        /** @todo testcase: See what kind of flags we can make SYSRET restore and
    4266          *        what it really ignores. RF and VM are hinted at being zero, by AMD. */
     4268         *        what it really ignores. RF and VM are hinted at being zero, by AMD.
     4269         *        Intel says:  RFLAGS := (R11 & 3C7FD7H) | 2; */
    42674270        pVCpu->cpum.GstCtx.rflags.u      = pVCpu->cpum.GstCtx.r11 & (X86_EFL_POPF_BITS | X86_EFL_VIF | X86_EFL_VIP);
    42684271        pVCpu->cpum.GstCtx.rflags.u     |= X86_EFL_1;
     
    42704273    else
    42714274    {
    4272         Log(("sysret: %04x:%08RX32 [efl=%#x] -> %04x:%08RX32\n", pVCpu->cpum.GstCtx.cs, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.u, uNewCs, pVCpu->cpum.GstCtx.ecx));
     4275        Log(("sysret: %04x:%08RX32 [efl=%#x] -> %04x:%08RX32\n", pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip, pVCpu->cpum.GstCtx.eflags.u, uNewCs, pVCpu->cpum.GstCtx.ecx));
    42734276        pVCpu->cpum.GstCtx.rip           = pVCpu->cpum.GstCtx.rcx;
    42744277        pVCpu->cpum.GstCtx.rflags.u     |= X86_EFL_IF;
     
    42894292    /** @todo Testcase: verify that SS.u1Long and SS.u1DefBig are left unchanged
    42904293     *        on sysret. */
     4294
     4295    pVCpu->iem.s.uCpl       = 3;
     4296    pVCpu->iem.s.enmCpuMode = iemCalcCpuMode(pVCpu);
    42914297
    42924298    /* Flush the prefetch buffer. */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette