No description
Find a file
Lloyd Pique aec6536741 virtgpu_cross_domain: Hold a lock for all of bo_create
In crosvm, the MinigbmDevice implementation of the Gralloc interface
assumes that a call to get_image_memory_requirements will be immediately
followed by a matching call to allocate_memory, as the implementation
stashes a buffer allocated by the first call to be returned by the
second.

However on Android multiple processes/threads can be making calls to
allocate memory via CrosGralloc. In particular if the device is
configured to use the cross-domain back-end, and two threads are trying
to allocate memory, the two requests to get the memory requirements for
an allocation can be submitted to crosvm followed by the two requests to
actually allocate memory.

When the assumption is violated, the crosvm code was raising an error
for the SECOND memory requirement request. However the error does not
propagate back to the virtgpu_cross_domain code here. The result is that
the request is understood to have succeeded, and the code here then
reads the size metadata from the response buffer, but that contains the
values from the FIRST memory requirement request. Those values may be

There is a fix for crosvm in review (https://crrev.com/c/6260975) to
not raise an error if the calls are not made in the expected order,
while still maintaining a single stashed buffer. However this means the
memory allocated for one of the two requests must be released, and would
have to be reallocated, at some extra runtime cost as allocating
graphics memory requires allocating physically contiguous memory.

The existing cross-domain code here acquired a simple mutex lock to
maintain a metadata cache, which was held for the duration of the first
call. This change extends the duration of the lock to the entire
allocation request so that the guest always makes the two requests in
the expected order.

BUG=b:395748805,b:355060470
TEST=ARCVM on Corsola starts up under high CPU stress

Change-Id: I6429ea28141ef440345a3eb442066173b3e04802
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/6288246
Commit-Queue: Lloyd Pique <lpique@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Lloyd Pique <lpique@google.com>
2025-02-25 04:26:53 -08:00
cros_gralloc cros_gralloc: Avoid using masks in handle_usage() 2024-10-15 16:19:58 +00:00
external xe: add initial Xe kmd support for gen12 xelp 2025-02-10 11:07:50 -08:00
.clang-format minigbm: add clang-format and presubmit hooks 2017-03-31 10:40:27 -07:00
amdgpu.c dri: pass use_flags to dri_bo_create_with_modifiers 2024-09-04 02:19:39 +00:00
backend_mock.c minigbm: format fix 2024-05-01 08:09:45 +00:00
common.mk minigbm: Update common.mk to unbreak gcc and bfd builds 2024-09-03 12:44:03 +00:00
DIR_METADATA DIR_METADATA: Add V2 Test Plans. 2022-11-30 01:25:57 +00:00
dri.c dri: pass use_flags to dri_bo_create_with_modifiers 2024-09-04 02:19:39 +00:00
dri.h dri: pass use_flags to dri_bo_create_with_modifiers 2024-09-04 02:19:39 +00:00
drv.c xe: add initial Xe kmd support for gen12 xelp 2025-02-10 11:07:50 -08:00
drv.h i915: Remove media compression support 2024-09-25 15:34:16 +00:00
drv_array_helpers.c minigbm: refactor driver helpers 2021-10-01 18:35:11 +00:00
drv_array_helpers.h minigbm: refactor driver helpers 2021-10-01 18:35:11 +00:00
drv_helpers.c drv: remove unused #include <linux/dma-buf.h> 2025-02-11 11:00:38 -08:00
drv_helpers.h Revert "gralloc: Error when locking buffer alloc'd without CPU_ usage" 2024-10-08 20:42:45 +00:00
drv_priv.h minigbm: Add an API to return cache attributes 2024-02-01 17:40:19 +00:00
dumb_driver.c minigbm: Add more dumb drivers 2022-12-07 14:36:24 +00:00
gbm.c minigbm: add gbm_{bo,surface}_create_with_modifiers2 2024-03-12 11:19:37 +00:00
gbm.h minigbm: #define MINIGBM_HAS_GBM_BO_GET_MAP_INFO 2024-06-18 03:02:33 +00:00
gbm_helpers.c minigbm: passthrough SENSOR_DIRECT_DATA via gbm frontend 2022-07-26 23:41:35 +00:00
gbm_helpers.h minigbm: standardize naming of buffer creation flags 2017-10-02 17:27:17 -07:00
gbm_priv.h minigbm: add clang-format and presubmit hooks 2017-03-31 10:40:27 -07:00
gbm_unittest.cc minigbm: format fix 2024-05-01 08:09:45 +00:00
i915.c [i915] Use write-combining for offset map case. 2025-01-09 22:30:59 -08:00
intel_defines.h xe: add lnl/ptl pci ids 2025-02-11 14:24:15 -08:00
LICENSE minigbm: Add a LICENSE file 2017-04-21 21:57:32 -07:00
Makefile xe: add initial Xe kmd support for gen12 xelp 2025-02-10 11:07:50 -08:00
mediatek.c minigbm: Fix 10bit protected allocations on MTK 2024-10-28 07:50:21 +00:00
minigbm_helpers.c minigbm: clean up legacy gbm_get_default_device_fd usage 2023-03-09 05:06:53 +00:00
minigbm_helpers.h minigbm: clean up legacy gbm_get_default_device_fd usage 2023-03-09 05:06:53 +00:00
msm.c msm: pad extra for YV12 to align with freedreno fdl_layout 2024-04-29 23:20:14 +00:00
OWNERS Remove marcheu@chromium.org from OWNERS 2024-11-21 20:10:59 +00:00
PRESUBMIT.cfg minigbm: fix typo in PRESUBMIT.cfg 2017-05-20 03:55:21 -07:00
presubmit.sh minigbm: i915: use local i915 drm header 2020-11-25 22:35:14 +00:00
rockchip.c minigbm: clean up bo.handles 2023-04-09 18:57:40 +00:00
testrunner.cc minigbm: add unit test for minigbm public apis 2024-01-30 20:59:57 +00:00
util.h xe: add initial Xe kmd support for gen12 xelp 2025-02-10 11:07:50 -08:00
vc4.c minigbm: clean up bo.handles 2023-04-09 18:57:40 +00:00
virtgpu.c drv/virtgpu: add log level for logging 2022-07-14 08:48:27 +00:00
virtgpu.h Add format filtering for virgl gfxstream 2024-08-01 15:42:33 +00:00
virtgpu_cross_domain.c virtgpu_cross_domain: Hold a lock for all of bo_create 2025-02-25 04:26:53 -08:00
virtgpu_virgl.c Initialize emulated_metadata fields to avoid uninitialized warnings 2024-08-27 00:06:40 +00:00
xe.c xe: add lnl/ptl pci ids 2025-02-11 14:24:15 -08:00