LBR virtualization removed#579
Merged
NotRequiem merged 14 commits intokernelwernel:devfrom Nov 26, 2025
Merged
Conversation
…t a hypervisor present
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've detected a very very improbable, but possible race condition in my previous LRB check due to how a context switch would be handled by the kernel in a race condition where my function would read the static volatile pointer to determine if the last branch record was populated in the vectored exception handler. Sumarized control flow of the bug is as following:
most probable branch case:
CALLexecutesICEBPexecutesCPU triggers
#DB. LBRs are frozen.kernel enters
KiTrap01kernel reads the TOS MSR.
kernel populates
ExceptionRecord->ExceptionInformation[0]with the addresskernel dispatches exception to vmaware's veh
best guess on some reports where this technique false flags:
CALLexecutes.external hardware interrupt fires in APIC/X2APIC.
in the kernel, CPU jumps to ISR
kernel decides thread's time slice (quantum) is over
KiSwapContextis called to switch to another thread.kernel does not save and restore the full LBR stack
kernel reschedules VMAware's thread
kernel re-injects pending
#DB(fromTForICEBP)trap handler attempts to read the LBR MSR if DebugControl set from
MSR_LASTBRANCH_TOS, finds it empty, and consequently setsExceptionInformation[0] = 0.kernel builds
EXCEPTION_RECORDstructure to pass toRtlDispatchException(which callsRtlAddVectoredExceptionHandler, setting LBR to 0so basically scheduler preemption can fuck up the detection because we cannot increment IRQL