- Timestamp:
- Apr 8, 2024 6:01:43 AM (10 months ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp
r100935 r104219 1780 1780 { 1781 1781 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue); 1782 pVCpu->cpum.s.Guest.msrSFMASK = uValue; 1782 /* The high bits are ignored and read-as-zero, writing to them does not raise #GP. See @bugref{10610}.*/ 1783 pVCpu->cpum.s.Guest.msrSFMASK = uValue & UINT32_MAX; 1783 1784 return VINF_SUCCESS; 1784 1785 } … … 1798 1799 { 1799 1800 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue); 1800 pVCpu->cpum.s.Guest.fs.u64Base = uValue; 1801 return VINF_SUCCESS; 1801 if (X86_IS_CANONICAL(uValue)) 1802 { 1803 pVCpu->cpum.s.Guest.fs.u64Base = uValue; 1804 return VINF_SUCCESS; 1805 } 1806 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue)); 1807 return VERR_CPUM_RAISE_GP_0; 1802 1808 } 1803 1809 … … 1815 1821 { 1816 1822 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue); 1817 pVCpu->cpum.s.Guest.gs.u64Base = uValue; 1818 return VINF_SUCCESS; 1823 if (X86_IS_CANONICAL(uValue)) 1824 { 1825 pVCpu->cpum.s.Guest.gs.u64Base = uValue; 1826 return VINF_SUCCESS; 1827 } 1828 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue)); 1829 return VERR_CPUM_RAISE_GP_0; 1819 1830 } 1820 1831 … … 1833 1844 { 1834 1845 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue); 1835 pVCpu->cpum.s.Guest.msrKERNELGSBASE = uValue; 1836 return VINF_SUCCESS; 1846 if (X86_IS_CANONICAL(uValue)) 1847 { 1848 pVCpu->cpum.s.Guest.msrKERNELGSBASE = uValue; 1849 return VINF_SUCCESS; 1850 } 1851 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue)); 1852 return VERR_CPUM_RAISE_GP_0; 1837 1853 } 1838 1854 -
trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp
r103289 r104219 380 380 else 381 381 { 382 ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pCtx->msrKERNELGSBASE); 383 ASMWrMsr(MSR_K8_LSTAR, pCtx->msrLSTAR); 384 ASMWrMsr(MSR_K6_STAR, pCtx->msrSTAR); 385 /* The system call flag mask register isn't as benign and accepting of all 386 values as the above, so mask it to avoid #GP'ing on corrupted input. */ 387 Assert(!(pCtx->msrSFMASK & ~(uint64_t)UINT32_MAX)); 388 ASMWrMsr(MSR_K8_SF_MASK, pCtx->msrSFMASK & UINT32_MAX); 382 /* Avoid raising #GP caused by writing illegal values to these MSRs. */ 383 if ( X86_IS_CANONICAL(pCtx->msrKERNELGSBASE) 384 && X86_IS_CANONICAL(pCtx->msrLSTAR)) 385 { 386 ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pCtx->msrKERNELGSBASE); 387 ASMWrMsr(MSR_K8_LSTAR, pCtx->msrLSTAR); 388 ASMWrMsr(MSR_K6_STAR, pCtx->msrSTAR); 389 /* The system call flag mask register isn't as benign and accepting of all 390 values as the above, so mask it to avoid #GP'ing on corrupted input. */ 391 Assert(!(pCtx->msrSFMASK & ~(uint64_t)UINT32_MAX)); 392 ASMWrMsr(MSR_K8_SF_MASK, pCtx->msrSFMASK & UINT32_MAX); 393 } 394 else 395 AssertMsgFailed(("Incompatible lazily-loaded guest MSR values\n")); 389 396 } 390 397 }
Note:
See TracChangeset
for help on using the changeset viewer.