[Devel] [PATCH vz10 11/14] ve: guard vdso and cpuid code with CONFIG_X86
Eva Kurchatova
eva.kurchatova at virtuozzo.com
Fri Jun 26 01:08:13 MSK 2026
kernel/ve/ve.c references x86-specific symbols (vdso_image_64,
vdso_image_32, TIF_CPUID_OVERRIDE, cpuid_override_on()) that are not
available under UML. Guard all VDSO image copying, freeing, and
version-code patching, as well as the CPUID override flag propagation,
with #ifdef CONFIG_X86.
Provide a static inline no-op stub for ve_free_vdso() on UML.
Also guard the ve_get_vdso_32/64() stubs in the !CONFIG_VE section
of ve.h with the same #ifdef CONFIG_X86, since the vdso_image_32
and vdso_image_64 externs they reference are equally unavailable.
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
https://virtuozzo.atlassian.net/browse/VSTOR-134732
Feature: fix kunit
---
include/linux/ve.h | 2 +-
kernel/ve/ve.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 1d32f6f57f8b..778dd4890c6a 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -367,7 +367,7 @@ static inline void ve_setup_task(struct task_struct *p, struct ve_struct *ve) {
static inline void ve_set_rpc_kill_fn(void (*fn)(struct net *, bool)) { }
-#if defined(CONFIG_X86) && !defined(CONFIG_UML)
+#ifdef CONFIG_X86
static inline struct vdso_image *ve_get_vdso_32(struct ve_struct *ve)
{
return (struct vdso_image *)&vdso_image_32;
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index e58ffb22da87..a4d445c80333 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -82,8 +82,10 @@ struct ve_struct ve0 = {
.meminfo_val = VE_MEMINFO_SYSTEM,
.umh_running_helpers = ATOMIC_INIT(0),
.umh_helpers_waitq = __WAIT_QUEUE_HEAD_INITIALIZER(ve0.umh_helpers_waitq),
+#ifdef CONFIG_X86
.vdso_64 = (struct vdso_image*)&vdso_image_64,
.vdso_32 = (struct vdso_image*)&vdso_image_32,
+#endif
};
EXPORT_SYMBOL(ve0);
@@ -672,6 +674,7 @@ u64 ve_get_uptime(struct ve_struct *ve)
}
EXPORT_SYMBOL(ve_get_uptime);
+#ifdef CONFIG_X86
static int copy_vdso(struct vdso_image **vdso_dst, const struct vdso_image *vdso_src)
{
struct vdso_image *vdso;
@@ -709,6 +712,9 @@ static void ve_free_vdso(struct ve_struct *ve)
kfree(ve->vdso_32);
}
}
+#else
+static inline void ve_free_vdso(struct ve_struct *ve) { }
+#endif
static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_css)
{
@@ -755,6 +761,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
if (err)
goto err_log;
+#ifdef CONFIG_X86
err = copy_vdso(&ve->vdso_64, &vdso_image_64);
if (err)
goto err_vdso;
@@ -762,6 +769,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
err = copy_vdso(&ve->vdso_32, &vdso_image_32);
if (err)
goto err_vdso;
+#endif
err = ve_mount_devtmpfs(ve);
if (err)
@@ -1152,8 +1160,10 @@ static ssize_t ve_os_release_write(struct kernfs_open_file *of, char *buf,
if (sscanf(buf, "%d.%d.%d", &n1, &n2, &n3) == 3) {
new_version = ((n1 << 16) + (n2 << 8)) + n3;
+#ifdef CONFIG_X86
*((int *)(ve->vdso_64->data + ve->vdso_64->sym_linux_version_code)) = new_version;
*((int *)(ve->vdso_32->data + ve->vdso_32->sym_linux_version_code)) = new_version;
+#endif
}
down_write(&uts_sem);
@@ -1836,8 +1846,10 @@ void ve_setup_task(struct task_struct *task, struct ve_struct *ve)
ve_set_task_start_time(ve, task);
+#ifdef CONFIG_X86
if (cpuid_override_on())
set_tsk_thread_flag(task, TIF_CPUID_OVERRIDE);
+#endif
}
EXPORT_SYMBOL(ve_setup_task);
--
2.54.0
More information about the Devel
mailing list