From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 279C88045D for ; Mon, 2 Nov 2026 10:06:13 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A2A4seT023230; Mon, 2 Nov 2026 13:04:55 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A2A4seT023230 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="XxJr+Pbr" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A2A4sSX023226 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Mon, 2 Nov 2026 13:04:54 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A2A4sSX023226 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-48dff112181so2547285f8f.3 for ; Mon, 02 Nov 2026 02:04:54 -0800 (PST) X-Gm-Message-State: APuU4Z/4PFNF6BAlHcqoTQUBw11G0UZywA3NjmUBHveer3SZZWqxw86R 2qYagN9+RRcbd/d9ATWwRzoQsP8ofIfVnSn5W7GIXxVk8qkxdNeTrnmaE/pubFSnuVy1CDN6/Xo 9WhZkVDOxePSdRYnbIy+vWSvbm4jQgxT5n9N2t/WiUEOzQkwKVpG3VA== X-Gm-Gg: AYBFou0eD93HRVddMVL3yxa5TpKnx06hMSPjKzKv4Ppar3K08hJJtnNWu0YPVPQVjdv U7lsJdbch9v0gG8FnCfD7Vv+NI6ckBePmvnab7BrkK4VnpbGO/K3I6JsxzEj9BStvxOhT19+pRC qvamKVfgGf+BAJNoQG3jLzevxBdrkNLZxSEay3VkFNbBaDUP7P9hjuWtMNqza5reNKuodua9t0R lTTNdcqIwm00bP3R6sXwheKcMRyRXpYcT9OI6Mhi8ILr9HdtH2DL9rSj04QjoGPj9u+It1cM7TW SosFNX8Mh7OhnH7pki3kcVYfjoP8Ns8+PriX52GJMwKh5HZ5W9gmCk9H0GCi8LMpKk3j1nBzPRr AM5ASrO/iFlijXw63WD+s4sGt3RiMyA== X-Received: by 2002:a05:6000:2213:b0:48c:7f18:c85e with SMTP id ffacd0b85a97d-48e6e3042d5mr21434076f8f.45.1793613893886; Mon, 02 Nov 2026 02:04:53 -0800 (PST) X-Received: by 2002:a05:6000:2213:b0:48c:7f18:c85e with SMTP id ffacd0b85a97d-48e6e3042d5mr21434002f8f.45.1793613893223; Mon, 02 Nov 2026 02:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793613893; cv=none; d=google.com; s=arc-20260327; b=LCJCCvr8ROl0l4S3ube0MsdwQqnYsKMhYTwrEiejgq0h5joqgWlMzZ4Ofi6eULmUA8 99iI7NDAW9CtHDliBfnQTECzxj0MsmWsEDIvEWIvvch1Q6TB7DgGDtaXTh7cHn9HEbPO Oycb97iJyOEwetJpdX6INfhoS8NqEg6RVNjHZh75hJJuM+7FUXMTK+rIrkV+v9WipCbO nNuuRI7eUHazOTbFKY5P+kyBxbJW250QLLUASJAI+KD/pcmiYspN27YV2MA8XLYm5+Bc 9lQOzx74ckhf0LATErVYGuN7j+bC4XhpJNLJZd5NctUTb1A9Ybd+RuuuyWpf7h6yCmVb wyJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=8FsM/Y72n5asqMUiv5xJN71xrJoIkRYWbf1PGfXgCKM=; fh=QQvtjDaAlLft5IR2jnjma4lVp8TaaKU12WD0fWdFifQ=; b=eHjYMSzscdlYNQGwobXJw8qhJuk7foiwWjk5Pt9sAd0w+wg/vZy8rJAG/XBt6lWKL0 GorqZtA1SdWn/Ukoc6PYzZbutUotNnL/4wiB3eVC9XS7tVLXF5dlWkC2wUWAuAWTWEHQ Ru716Z4+SE3qVNDXZs62rJQO9R86sXMwKzZmME92R6NjtZDPSJADKL/pHxzpXTt6g0wj /SvZrmaIWWIb4tXlrps+HjVGbY80ppgL4BxD5Bq3nloGrQ+RP4HI07fwM+F1Hjad++ys APJsD4WZp2zdKrZKbe5nbtpPW2F8MZwDT6BS8p+5TEje6OFdzdb3l36XunWQCmTA24OA /Elg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=XxJr+Pbr; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-48e73e46579si16993098f8f.283.2026.11.02.02.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2026 02:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=XxJr+Pbr; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=8FsM/Y72n5asqMUiv5xJN71xrJoIkRYWbf1PGfXgCKM=; b=XxJr+PbrMOtW 016y6GTp2TxjC2hvi7ukqCjhJzP/fKVJ1tRrU7aMDhKI4H+HR/35WrqgBNAvZDwpMKuelgkjZuTQr 5N6iLN5vn5PjTJhAZVLy2A0IW2v1PTBtbUdV1TBg2FzzbJYp0noUkFNFR0wtFrUo4ASoAcmYjd/Rh grW0+RThGlX52NExz4+hgra6D1K2gP9YigOBcESuPmo2n8OosMKeKU6+W1XE3mw7k7jac9WFBN1Wf 8heWy5S5khlBN3a2e8H0SDCMGtidd/1OJsMempO6JtL9mFcUAGEKisH2sQX5FsOHN9M0yB2pfKhNF FKRgKNi4KP7QwniF87yEMw==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=192.168.1.87) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xNoqR-004OLO-0d; Mon, 02 Nov 2026 11:04:44 +0100 From: Vladimir Riabchun To: devel@openvz.org Date: Mon, 2 Nov 2026 11:04:32 +0100 Message-ID: <20261102100432.15867-1-vladimir.riabchun@virtuozzo.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-OZ-Fwd: true Subject: [Devel] [PATCH RK VZ10] x86/traps: emulate CPUID faults for user tasks in exc_general_protection() X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org A non-empty /proc/vz/cpuid_override table makes ve_setup_task() set TIF_CPUID_OVERRIDE on every task entering a VE, so the CPU raises #GP on each CPUID the task executes and check_cpuid_fault() is supposed to emulate the instruction with the table values. The call sits after the user-mode branch of exc_general_protection(), which ends in gp_user_force_sig_segv() and goto exit, so it is reached only for a kernel-mode #GP, where CPUID never faults. Every Container task dies with SIGSEGV on the first CPUID of glibc init_cpu_features() instead of getting the override: traps: bash[179661] general protection fault ip:7fa8b470357f ... in ld-linux-x86-64.so.2[1857f,...] The original vz8 patch was written for 4.18, where do_general_protection() handled kernel mode first and the call landed on the user path. The vz9 port kept the relative position after upstream had reversed the order of the two branches. Move the call into the user-mode branch, before the signal is sent. check_cpuid_fault() still declines tasks with TIF_NOCPUID, so arch_prctl(ARCH_SET_CPUID, 0) keeps its SIGSEGV semantics. Fixes: 1033fe455434 ("arch/x86: introduce cpuid override") https://virtuozzo.atlassian.net/browse/VSTOR-148656 Feature: x86: cpu pools (cpuid override) Reviewed-by: Vasileios Almpanis vasileios.almpanis@virtuozzo.com Link: http://lore.virtuozzo.com/20261006-b4-prep-khorenko-vstor-148656-just-cpuid-v1-1-6f2a2a6deef3@virtuozzo.com Signed-off-by: Konstantin Khorenko khorenko@virtuozzo.com ReadyKernel-specific changes: We can't patch exc_general_protection directly, so we need another place. fixup_vdso_exception is not inlined and is the last check on user-mode path. We can perform CPUID fault check inside fixup_vdso_exception on false path, that will be the closes reproduction of fix behavior. RK_BUG: VSTOR-152668 RK_CHANGELOG: Fix GP handler to support CPUID emulation and allow container start. Signed-off-by: Vladimir Riabchun vladimir.riabchun@virtuozzo.com --- arch/x86/entry/vdso/extable.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/extable.c b/arch/x86/entry/vdso/extable.c index afcf5b65beef..ca8c184925ec 100644 --- a/arch/x86/entry/vdso/extable.c +++ b/arch/x86/entry/vdso/extable.c @@ -9,6 +9,30 @@ struct vdso_exception_table_entry { int insn, fixup; }; +static int check_cpuid_fault(struct pt_regs *regs, long error_code) +{ + unsigned long addr; + unsigned short opcode; + + if (error_code != 0) + return 0; + + if (test_thread_flag(TIF_NOCPUID)) + return 0; + + addr = convert_ip_to_linear(current, regs); + if (get_user(opcode, (unsigned short __user *)addr)) + return 0; + + if (opcode != 0xa20f) + return 0; + + do_cpuid_fault(regs); + + regs->ip += 2; + return 1; +} + bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, unsigned long error_code, unsigned long fault_addr) { @@ -26,7 +50,7 @@ bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, return false; if (!current->mm->context.vdso) - return false; + goto try_fixup_cupid; base = (unsigned long)current->mm->context.vdso + image->extable_base; nr_entries = image->extable_len / (sizeof(*extable)); @@ -42,5 +66,10 @@ bool fixup_vdso_exception(struct pt_regs *regs, int trapnr, } } +try_fixup_cupid: + /* Only exc_general_protection can go this way */ + if (trapnr == X86_TRAP_GP && check_cpuid_fault(regs, error_code)) + return true; + return false; } -- 2.52.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel