Skip to content

Commit

Permalink
drm/virtio: add buffer protection attribution
Browse files Browse the repository at this point in the history
add buffer protection attribution to support pxp.

Tracked-On: OAM-121827
Signed-off-by: Xue, Bosheng <[email protected]>
  • Loading branch information
bosheng1 committed Aug 20, 2024
1 parent 6225346 commit 1d88667
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions drivers/gpu/drm/virtio/virtgpu_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct virtio_gpu_object_params {
uint32_t blob_mem;
uint32_t blob_flags;
uint64_t blob_id;
bool protected;
};

struct virtio_gpu_object {
Expand All @@ -97,6 +98,7 @@ struct virtio_gpu_object {

int uuid_state;
uuid_t uuid;
bool protected;
};
#define gem_to_virtio_gpu_obj(gobj) \
container_of((gobj), struct virtio_gpu_object, base.base)
Expand Down
11 changes: 9 additions & 2 deletions drivers/gpu/drm/virtio/virtgpu_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
struct virtio_gpu_object_params params = { 0 };
struct virtio_gpu_object *bo;
struct drm_gem_object *obj;
struct drm_gem_object *i915_obj;
struct virtio_gpu_mem_entry *ents;
unsigned int nents;
struct dma_buf *dmabuf;
int ret;

if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) {
Expand All @@ -234,13 +236,18 @@ struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
if (ret != 0) {
goto err_put_id;
}

dmabuf = attach->dmabuf;
if (dmabuf && strcmp(module_name(dmabuf->owner), "i915") == 0) {
dmabuf = attach->dmabuf;
i915_obj = dmabuf->priv;
bo->protected = i915_obj->protected;
}
bo->guest_blob = true;
params.blob_mem = VIRTGPU_BLOB_MEM_GUEST;
params.blob_flags = VIRTGPU_BLOB_FLAG_USE_SHAREABLE;
params.blob = true;
params.size = size;

params.protected = bo->protected;
virtio_gpu_cmd_resource_create_blob(vgdev, bo, &params,
ents, nents);
virtio_gpu_object_save_restore_list(vgdev, bo, &params);
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/virtio/virtgpu_vq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
cmd_p->blob_id = cpu_to_le64(params->blob_id);
cmd_p->size = cpu_to_le64(params->size);
cmd_p->nr_entries = cpu_to_le32(nents);
cmd_p->protected = cpu_to_le64(params->protected);

vbuf->data_buf = ents;
vbuf->data_size = sizeof(*ents) * nents;
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/virtio_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ struct virtio_gpu_resource_create_blob {
__le32 nr_entries;
__le64 blob_id;
__le64 size;
__le64 protected;
/*
* sizeof(nr_entries * virtio_gpu_mem_entry) bytes follow
*/
Expand Down

0 comments on commit 1d88667

Please sign in to comment.