LATX, fix: Handle guest return addresses in JRRA stack returns - #479
Open
yzewei wants to merge 1 commit into
Open
LATX, fix: Handle guest return addresses in JRRA stack returns#479yzewei wants to merge 1 commit into
yzewei wants to merge 1 commit into
Conversation
JRRA stack returns assume that the address popped from the guest stack is already a LoongArch translated-code address and jump to it directly. Some guest control-flow paths still store x86 guest addresses, such as the pretcode saved in a Linux user-mode signal frame. JRRA could mistake such an address for a host translated address and execute it as LoongArch code, causing SIGBUS. Use reserved_va to distinguish the two kinds of return addresses in the JRRA stack-return path: - fall back to the normal translate_ret() and TB lookup path for guest addresses; - retain the direct JRRA return fast path for host translated addresses. This preserves the optimized return path for translated code while preventing guest addresses from being executed directly as LoongArch code. Signed-off-by: Zewei Yang <yangzewei@loongson.cn>
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.
When the JRRA stack return optimization is enabled, return addresses are treated by default as addresses of translated LoongArch code, allowing for a direct jump.
However, certain guest control-flow paths still store x86 guest addresses—such as the
pretcodefound in Linux user-mode signal frames. Upon return, JRRA mistakenly treats such an address as a LoongArch address and attempts to execute it, triggering a SIGBUS.This fix uses
reserved_vato distinguish between the two types of return addresses:translate_ret()and TB lookup paths;The JRRA fast-return behavior for standard host-translated code remains unchanged.