Skip to content

Commit bf99859

Browse files
committed
kvm: vendor the vgem sources, drop the raw.githubusercontent fetch
The out-of-tree vgem build fetched its three sources from raw.githubusercontent.com with anonymous curl, and GitHub rate-limits anonymous raw fetches from Actions egress (HTTP 429) — the 2026-10-05 iso lap died on the third attempt, after the action had already done the expensive apt steps. The sources are small and frozen upstream (torvalds/linux v6.17, drivers/gpu/drm/vgem), so vendor them verbatim next to the action and copy them at build time: hermetic, no network to lose. curl leaves the apt line; the out-of-tree Makefile is still written by the action, so it stays unwritten in the vendor dir.
1 parent 10c6821 commit bf99859

5 files changed

Lines changed: 500 additions & 6 deletions

File tree

‎.github/actions/kvm/action.yml‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ runs:
4646
fi
4747
if ! ls /dev/dri/renderD* >/dev/null 2>&1; then
4848
echo " .. no render node and no vgem module; building vgem out of tree"
49-
sudo apt-get install -y -qq "linux-headers-$(uname -r)" build-essential curl
49+
sudo apt-get install -y -qq "linux-headers-$(uname -r)" build-essential
5050
vgem_dir=/tmp/vgem-build
5151
mkdir -p "$vgem_dir"
52-
base="https://raw.githubusercontent.com/torvalds/linux/v6.17/drivers/gpu/drm/vgem"
53-
for f in vgem_drv.c vgem_drv.h vgem_fence.c; do
54-
curl --proto '=https' --tlsv1.2 --fail --silent --show-error \
55-
"$base/$f" -o "$vgem_dir/$f" || echo "vgem source unavailable; continuing without a render node"
56-
done
52+
# The sources are vendored in the repo (vgem/ next to this
53+
# action, torvalds/linux v6.17 verbatim): the fetch used to
54+
# be anonymous curl against raw.githubusercontent.com, and
55+
# GitHub rate-limits that (HTTP 429) from Actions egress —
56+
# the 2026-10-05 iso lap died on it. A repo-local copy has
57+
# no network to lose.
58+
cp "${{ github.action_path }}/vgem/"*.{c,h} "$vgem_dir/"
5759
if [ -f "$vgem_dir/vgem_drv.c" ]; then
5860
printf 'vgem-y := vgem_drv.o vgem_fence.o\nobj-m += vgem.o\n' > "$vgem_dir/Makefile"
5961
make -C "/lib/modules/$(uname -r)/build" M="$vgem_dir" modules -j4 -s \

‎.github/actions/kvm/vgem/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# vendored vgem sources
2+
3+
Out-of-tree build sources for the vgem DRM driver, copied verbatim from
4+
upstream: `torvalds/linux` tag `v6.17`, `drivers/gpu/drm/vgem/`
5+
(`vgem_drv.c`, `vgem_drv.h`, `vgem_fence.c`). License: GPL-2.0 — see the
6+
headers in each file.
7+
8+
## Why vendored
9+
10+
The kvm action builds vgem when the runner has no DRM render node (the
11+
20261004 runner image's azure kernel dropped vgem from modules-extra and
12+
the guest's virgl GL cannot initialize without a node). The build
13+
previously fetched these files from `raw.githubusercontent.com` with
14+
anonymous curl, which GitHub rate-limits (HTTP 429) from Actions egress
15+
IPs — the 2026-10-05 `iso` lap died on exactly that. Vendored sources
16+
make the action hermetic: no network fetch, no 429 lottery.
17+
18+
## Upstream policy
19+
20+
Re-vendor by hand when the driver changes upstream in a way that
21+
matters (it has been stable for years). The `Makefile` is NOT vendored:
22+
the action writes its own two-line out-of-tree Makefile.
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
/*
2+
* Copyright 2011 Red Hat, Inc.
3+
* Copyright © 2014 The Chromium OS Authors
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a
6+
* copy of this software and associated documentation files (the "Software")
7+
* to deal in the software without restriction, including without limitation
8+
* on the rights to use, copy, modify, merge, publish, distribute, sub
9+
* license, and/or sell copies of the Software, and to permit persons to whom
10+
* them Software is furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice (including the next
13+
* paragraph) shall be included in all copies or substantial portions of the
14+
* Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTIBILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19+
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
* Authors:
24+
* Adam Jackson <ajax@redhat.com>
25+
* Ben Widawsky <ben@bwidawsk.net>
26+
*/
27+
28+
/*
29+
* This is vgem, a (non-hardware-backed) GEM service. This is used by Mesa's
30+
* software renderer and the X server for efficient buffer sharing.
31+
*/
32+
33+
#include <linux/dma-buf.h>
34+
#include <linux/module.h>
35+
#include <linux/device/faux.h>
36+
#include <linux/shmem_fs.h>
37+
#include <linux/vmalloc.h>
38+
39+
#include <drm/drm_drv.h>
40+
#include <drm/drm_file.h>
41+
#include <drm/drm_gem_shmem_helper.h>
42+
#include <drm/drm_ioctl.h>
43+
#include <drm/drm_managed.h>
44+
#include <drm/drm_prime.h>
45+
46+
#include "vgem_drv.h"
47+
48+
#define DRIVER_NAME "vgem"
49+
#define DRIVER_DESC "Virtual GEM provider"
50+
#define DRIVER_MAJOR 1
51+
#define DRIVER_MINOR 0
52+
53+
static struct vgem_device {
54+
struct drm_device drm;
55+
struct faux_device *faux_dev;
56+
} *vgem_device;
57+
58+
static int vgem_open(struct drm_device *dev, struct drm_file *file)
59+
{
60+
struct vgem_file *vfile;
61+
int ret;
62+
63+
vfile = kzalloc(sizeof(*vfile), GFP_KERNEL);
64+
if (!vfile)
65+
return -ENOMEM;
66+
67+
file->driver_priv = vfile;
68+
69+
ret = vgem_fence_open(vfile);
70+
if (ret) {
71+
kfree(vfile);
72+
return ret;
73+
}
74+
75+
return 0;
76+
}
77+
78+
static void vgem_postclose(struct drm_device *dev, struct drm_file *file)
79+
{
80+
struct vgem_file *vfile = file->driver_priv;
81+
82+
vgem_fence_close(vfile);
83+
kfree(vfile);
84+
}
85+
86+
static struct drm_ioctl_desc vgem_ioctls[] = {
87+
DRM_IOCTL_DEF_DRV(VGEM_FENCE_ATTACH, vgem_fence_attach_ioctl, DRM_RENDER_ALLOW),
88+
DRM_IOCTL_DEF_DRV(VGEM_FENCE_SIGNAL, vgem_fence_signal_ioctl, DRM_RENDER_ALLOW),
89+
};
90+
91+
DEFINE_DRM_GEM_FOPS(vgem_driver_fops);
92+
93+
static struct drm_gem_object *vgem_gem_create_object(struct drm_device *dev, size_t size)
94+
{
95+
struct drm_gem_shmem_object *obj;
96+
97+
obj = kzalloc(sizeof(*obj), GFP_KERNEL);
98+
if (!obj)
99+
return ERR_PTR(-ENOMEM);
100+
101+
/*
102+
* vgem doesn't have any begin/end cpu access ioctls, therefore must use
103+
* coherent memory or dma-buf sharing just wont work.
104+
*/
105+
obj->map_wc = true;
106+
107+
return &obj->base;
108+
}
109+
110+
static const struct drm_driver vgem_driver = {
111+
.driver_features = DRIVER_GEM | DRIVER_RENDER,
112+
.open = vgem_open,
113+
.postclose = vgem_postclose,
114+
.ioctls = vgem_ioctls,
115+
.num_ioctls = ARRAY_SIZE(vgem_ioctls),
116+
.fops = &vgem_driver_fops,
117+
118+
DRM_GEM_SHMEM_DRIVER_OPS,
119+
.gem_create_object = vgem_gem_create_object,
120+
121+
.name = DRIVER_NAME,
122+
.desc = DRIVER_DESC,
123+
.major = DRIVER_MAJOR,
124+
.minor = DRIVER_MINOR,
125+
};
126+
127+
static int __init vgem_init(void)
128+
{
129+
int ret;
130+
struct faux_device *fdev;
131+
132+
fdev = faux_device_create("vgem", NULL, NULL);
133+
if (!fdev)
134+
return -ENODEV;
135+
136+
if (!devres_open_group(&fdev->dev, NULL, GFP_KERNEL)) {
137+
ret = -ENOMEM;
138+
goto out_unregister;
139+
}
140+
141+
dma_coerce_mask_and_coherent(&fdev->dev,
142+
DMA_BIT_MASK(64));
143+
144+
vgem_device = devm_drm_dev_alloc(&fdev->dev, &vgem_driver,
145+
struct vgem_device, drm);
146+
if (IS_ERR(vgem_device)) {
147+
ret = PTR_ERR(vgem_device);
148+
goto out_devres;
149+
}
150+
vgem_device->faux_dev = fdev;
151+
152+
/* Final step: expose the device/driver to userspace */
153+
ret = drm_dev_register(&vgem_device->drm, 0);
154+
if (ret)
155+
goto out_devres;
156+
157+
return 0;
158+
159+
out_devres:
160+
devres_release_group(&fdev->dev, NULL);
161+
out_unregister:
162+
faux_device_destroy(fdev);
163+
return ret;
164+
}
165+
166+
static void __exit vgem_exit(void)
167+
{
168+
struct faux_device *fdev = vgem_device->faux_dev;
169+
170+
drm_dev_unregister(&vgem_device->drm);
171+
devres_release_group(&fdev->dev, NULL);
172+
faux_device_destroy(fdev);
173+
}
174+
175+
module_init(vgem_init);
176+
module_exit(vgem_exit);
177+
178+
MODULE_AUTHOR("Red Hat, Inc.");
179+
MODULE_AUTHOR("Intel Corporation");
180+
MODULE_DESCRIPTION(DRIVER_DESC);
181+
MODULE_LICENSE("GPL and additional rights");
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright © 2012 Intel Corporation
3+
* Copyright © 2014 The Chromium OS Authors
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a
6+
* copy of this software and associated documentation files (the "Software"),
7+
* to deal in the Software without restriction, including without limitation
8+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9+
* and/or sell copies of the Software, and to permit persons to whom the
10+
* Software is furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice (including the next
13+
* paragraph) shall be included in all copies or substantial portions of the
14+
* Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22+
* IN THE SOFTWARE.
23+
*
24+
* Authors:
25+
* Ben Widawsky <ben@bwidawsk.net>
26+
*
27+
*/
28+
29+
#ifndef _VGEM_DRV_H_
30+
#define _VGEM_DRV_H_
31+
32+
#include <drm/drm_gem.h>
33+
#include <drm/drm_cache.h>
34+
35+
#include <uapi/drm/vgem_drm.h>
36+
37+
struct vgem_file {
38+
struct idr fence_idr;
39+
struct mutex fence_mutex;
40+
};
41+
42+
int vgem_fence_open(struct vgem_file *file);
43+
int vgem_fence_attach_ioctl(struct drm_device *dev,
44+
void *data,
45+
struct drm_file *file);
46+
int vgem_fence_signal_ioctl(struct drm_device *dev,
47+
void *data,
48+
struct drm_file *file);
49+
void vgem_fence_close(struct vgem_file *file);
50+
51+
#endif

0 commit comments

Comments
 (0)