summaryrefslogtreecommitdiffstats
path: root/src/VBox/VMM/VMMR0/HMVMXR0.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 22:55:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 22:55:52 +0000
commitcd47c2446f1a9dee96610f298989848f8986a8be (patch)
tree02c30d62a9164987d0aaba2f72c58a50053205d6 /src/VBox/VMM/VMMR0/HMVMXR0.cpp
parentReleasing progress-linux version 7.0.14-dfsg-4~progress7.99u1. (diff)
downloadvirtualbox-cd47c2446f1a9dee96610f298989848f8986a8be.tar.xz
virtualbox-cd47c2446f1a9dee96610f298989848f8986a8be.zip
Merging upstream version 7.0.16-dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/VMM/VMMR0/HMVMXR0.cpp')
-rw-r--r--src/VBox/VMM/VMMR0/HMVMXR0.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/VBox/VMM/VMMR0/HMVMXR0.cpp b/src/VBox/VMM/VMMR0/HMVMXR0.cpp
index 26b6252e..0bb3b490 100644
--- a/src/VBox/VMM/VMMR0/HMVMXR0.cpp
+++ b/src/VBox/VMM/VMMR0/HMVMXR0.cpp
@@ -382,13 +382,20 @@ static void hmR0VmxLazyLoadGuestMsrs(PVMCPUCC pVCpu)
}
else
{
- ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pCtx->msrKERNELGSBASE);
- ASMWrMsr(MSR_K8_LSTAR, pCtx->msrLSTAR);
- ASMWrMsr(MSR_K6_STAR, pCtx->msrSTAR);
- /* The system call flag mask register isn't as benign and accepting of all
- values as the above, so mask it to avoid #GP'ing on corrupted input. */
- Assert(!(pCtx->msrSFMASK & ~(uint64_t)UINT32_MAX));
- ASMWrMsr(MSR_K8_SF_MASK, pCtx->msrSFMASK & UINT32_MAX);
+ /* Avoid raising #GP caused by writing illegal values to these MSRs. */
+ if ( X86_IS_CANONICAL(pCtx->msrKERNELGSBASE)
+ && X86_IS_CANONICAL(pCtx->msrLSTAR))
+ {
+ ASMWrMsr(MSR_K8_KERNEL_GS_BASE, pCtx->msrKERNELGSBASE);
+ ASMWrMsr(MSR_K8_LSTAR, pCtx->msrLSTAR);
+ ASMWrMsr(MSR_K6_STAR, pCtx->msrSTAR);
+ /* The system call flag mask register isn't as benign and accepting of all
+ values as the above, so mask it to avoid #GP'ing on corrupted input. */
+ Assert(!(pCtx->msrSFMASK & ~(uint64_t)UINT32_MAX));
+ ASMWrMsr(MSR_K8_SF_MASK, pCtx->msrSFMASK & UINT32_MAX);
+ }
+ else
+ AssertMsgFailed(("Incompatible lazily-loaded guest MSR values\n"));
}
}
pVCpu->hmr0.s.vmx.fLazyMsrs |= VMX_LAZY_MSRS_LOADED_GUEST;