Repository navigation
pvr/g5p, util/tc: long Firefox renders: real control stream block sizes, rolled-over rp info use-after-free - #49
Merged
Conversation
…uing a render
g5p_cmd_draw() continues a render in a new one (a mid-render barrier: the
first stores, the second loads) before its VDM control stream passes
PVR_G5P_MAX_VDM_BYTES, which pvr_arch_g5p_vdm_stream() lays out as one
range. It counted PVR_CMD_BUFFER_CSB_BO_SIZE (4 KiB) per pvr_csb block,
but pvr_csb_buffer_extend() fills a block up to its BO's size, which the
kernel rounds up to its page: 16 KiB on the iPad. The continuation came
only after 255 blocks (about 4 MiB), so long renders were refused at
1 MiB instead ("a control stream of 1373708 bytes in 85 blocks (at most
1048576)", Speedometer 3.1 in Firefox) and skipped.
Sum the blocks' BO sizes and keep the largest block in reserve.
The 1 MiB limit is the driver's, not the hardware's: the A9 VDM follows
STREAM_LINK (Apple's streams use it), but only flattened streams have
run on the device so far.
Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
…nfos When a renderpass continues across a batch flush, the flushed batch's last tc_batch_rp_info links to infos[0] of the new batch (full_copy in tc_batch_increment_renderpass_info()). While the flushed batch executes, the driver thread follows that link in threaded_context_get_renderpass_info(), and after executing it writes through it (tc_batch_execute() clears next->prev). If the new batch then records ten more renderpasses, tc_batch_renderpass_infos_resize() reallocates its array: the old infos[0] is freed while the driver thread may still read its ready fence and next pointer, or write its prev pointer. Firefox (WebRender through Zink) crashed in threaded_context_get_renderpass_info() from zink_batch_rp() with a wild pointer made of float data (SIGSEGV at 0x44c2600044800028) during a render of several thousand draws. Before moving an array whose infos[0] was linked from the previous batch, wait for that batch's fence. infos[0] has ended and been signalled by then, so the driver thread is never waiting on the recording thread. This happens only for a batch that started inside a renderpass and holds more than ten renderpasses. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
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.
Two fixes for long Firefox (WebRender through Zink) renders on the A9:
g5p_cmd_draw()continues a render before its VDM control stream passesPVR_G5P_MAX_VDM_BYTES(1 MiB), but it counted 4 KiB per block. The kernel rounds each block BO up to its page, 16 KiB on the iPad. So the continuation came only after about 4 MiB, and long renders were refused at 1 MiB instead and skipped. Speedometer 3.1 hit "a control stream of 1373708 bytes in 85 blocks (at most 1048576)". The fix sums the real BO sizes and keeps the largest block in reserve.tc_batch_rp_infolinks toinfos[0]of the new batch. If the new batch then records more than ten render passes,tc_batch_renderpass_infos_resize()reallocates the array while the driver thread may still read or write through that link. Firefox crashed inthreaded_context_get_renderpass_info()fromzink_batch_rp()(SIGSEGV on a wild pointer made of float data) during a render of several thousand draws, at Speedometer step 48. Before moving an array whoseinfos[0]the previous batch links to, the fix waits for that batch's fence. This is a common Gallium change for any threaded-context driver.Tested on the iPad 5 (j71t): both are in the Mesa the device has run since 2026-12-03 (Firefox daily sites and scroll benchmarks, no crash). Built on this head (Vulkan imagination with asserts on, and the Zink GL build); the G5P meson host tests pass, 9/9.
How to test
On a stock Orchard install with Mesa built from this branch:
Expected on the iPad 5: no control stream refusals and no threaded-context crash during Speedometer. A10: the util/tc fix applies to every Gallium threaded-context driver (Zink on the A10 too). The block count is G5P-only.