From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 8E3DC8017D for ; Tue, 6 Oct 2026 22:55:57 +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 696MsiMv028688; Wed, 7 Oct 2026 01:54:45 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696MsiMv028688 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="g2y75TF+" Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696MscAU028659 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 7 Oct 2026 01:54:38 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696MscAU028659 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48c4649b368so2728748f8f.2 for ; Tue, 06 Oct 2026 15:54:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBzDf5/BOKVzXczFLPeKanDY7c/qGLeYnznEnk97emySYSVO3xoOttyv67odegd4lIF/mQhPtg==@openvz.org X-Gm-Message-State: AFq9FYIQl88YxV+ECNf4hIID0ZeAtaKiRCWPuZE77ELghCRgYs4mvF6+ 1KKTx0qZVrp7SUpdC1RnciCatGM187zpz6zbBfTJeCyUzxnLeNGCDEE6adYm5ofO+dgurAASUVB 3qJGfDMYDOweezTXAxvOaOlVJ5G6UA7beCvLodPnpRmxMxBAKcw+Oog== X-Gm-Gg: AYBFou2J3HvgYUWFXZw6tlVen6hh56NLj/6S7xBsTyOaDyt89/EOa30mj10yXmhUMQy A4/NSo/xeyN6l814X8CDPfW7KVPsKnA7bxW7W8QqZaxBqJ3FlvD5jUlIVNj14IgE1gu/xrLwcHh BgrI+6/8qHbUpqpulfMh0Ha4R3mDApvg47Xq0l2RzafwqQvc/AufpELdWqLH6ItSWr13XQA6g8k dc7LO1sm0tS8d2jqkToBeDV1PCODG135uAcUTB9wjvjQTlWXJuqPG5+UDc9eDe3M0V+yR8fytbW WfyvQo6l2W6ATZm9zK1YRXf0OaX3Gahz5V7oVtTVjWI4tDJhqzyrNgY32nnPGTlPmFX1c9Tn4y/ QNlNIYrwqGAxRxgL+7Q== X-Received: by 2002:a05:6000:260d:b0:48c:592f:916f with SMTP id ffacd0b85a97d-48c7278ed49mr1026948f8f.30.1791327278074; Tue, 06 Oct 2026 15:54:38 -0700 (PDT) X-Received: by 2002:a05:6000:260d:b0:48c:592f:916f with SMTP id ffacd0b85a97d-48c7278ed49mr1026918f8f.30.1791327277529; Tue, 06 Oct 2026 15:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791327277; cv=none; d=google.com; s=arc-20260327; b=aGHamWDdam78/VbnwEezfgHXkdwT5hf/KwEYpwkg1hUtz4xAxY4fmE/qBS3NYh3Tom J5S88ZU8EfDuruvuJIqPzIdjcxcEFUFy+rwYIzOad/3LNhrqHZlFBjR3yPlnxaHe9kv5 h+nOs/srVKbZdmQPaxHrWxxDx12+mBBvra6QZKL+TCkALfqWJ8TRpsXjs0F/nLzPfGNy +2UX36esf2JwAJbaRaMGUglFTrKpm/xyrSgR5KFGWsNTi0zyLhqwNgt050qc0Pfd63+8 81IzhgkuwVX8FMWNErh8AGWdXIjNIV7HD6gR7ftflJVGUGOcWCr/9/i9QAbAMnAcM0TB 1iBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:dkim-signature; bh=hZYE7QhC2ycO+pig/fkmD8hCmsqCECbcz731exao9+U=; fh=bRkZfFa6377EgOVW8zBDri2gGIQqe/ZeiH+ijEM/ROI=; b=r6V6cs2gtw7W0PDO0UzRWSk4zYqKulHPU3wYUiXp1/TlzzdHFAgjxi2xmAFVUABBEq uzx9S5TwUcV5k+Q3GEvxP2a8XHBCiGdMoD1DpoBD1ve6QDlHdbQeoUT67VWpSCc72P4L 6wBLZpbQNkMLVu26GSTZgw4DGp21CPVmKJNP1tnGagPgvGrzJ5eDUQnoa8ihk1un0heV a5Z0D8oVHwHfnlUjDUuBNUaJlB69ezy5Kor+aiYDO8VKWX/Bf+E3OLn4X3fMaBSw7Icb Kw8vT0I2y43olvHCvLVwKGLuJfo0IjoK3Mp4YC6cbs+7nkYcznU7dPyFs8AJ2YynJNW+ C/8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=g2y75TF+; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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-48c724a52a1si1577089f8f.344.2026.10.06.15.54.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 15:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of khorenko@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=g2y75TF+; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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=Content-Type:MIME-Version:Message-Id:Date:Subject :From; bh=hZYE7QhC2ycO+pig/fkmD8hCmsqCECbcz731exao9+U=; b=g2y75TF+ai4jrZmCmB7 6DlBdwNAbdNl4/kYPMTI+hSNaFI266GlnEqOoOObuyHn2iM85s8szLmRO3xmHPvjZlaGAaqCtDWAp 7TTFVU9MXRmYYIDfSG3MnIRrwRB39Gb0zxXCOioWNSgFgdxRKl17LH69qDJaYasNT/k8Hzfdc/0ny YFjGG9QY/yd25tu6/YkhIWh9orZncMHhT7tj9ZWw9qVdZTYkTrpLaW5kAuiHrEeaDmD++CQwyxnRg pRNxYwVc2uoxSpEpO6XnkTSnginD5+0iocW84aQ5jMJXuELCeOT/p+1Q4YkQcTXhNK4ACXJK8kaPU isVpquLpZG2rXZw==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xEE0B-005OA8-28; Wed, 07 Oct 2026 00:54:26 +0200 From: Konstantin Khorenko Date: Wed, 07 Oct 2026 00:54:30 +0200 Message-Id: <20261007-b4-prep-khorenko-vstor-148656-cpuid-v5-0-652c5c9e56da@virtuozzo.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIACd8xWoC/53Oy07EMAwF0F8ZZY1HcZKmLSv+A7HIk4YRTZW00 TzUfyctG4RmAbO07HuubyS7FFwmz4cbSa6EHOJYh+bpQMygxncHwdaZMMokUipBC5iSm+A0xOT GU4SS55gARScbCWZaggXVmKbvuUPfcVKlGvDhvLe8ksEE6I5I3r4XedEfzsxbx3Y6hI277P8U3 AP/qi4IFFqBkvZeeMrVSwlpXuL1Go8mfu6thT3gsup6aRF7Zlor6T2XP+Dy6qJEgbozirb2nit +uu3fXFFd7VEa1munmPjtruv6BeddO079AQAA X-Change-ID: 20261006-b4-prep-khorenko-vstor-148656-cpuid-a5c5993e1f83 To: Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7203; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=LSMsg1UgiAu5mh6P4AkX0K80GNMXWSqjy8ljTlVFHsQ=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqxXwqHQKPYeTnIf5oI3vH+pQLgnN2nYftWC6ei rDYZwPOFP2JAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCasV8KgAKCRBRlgpH+WFc KsgHD/42JzWT99t4AQWI0bcCnkma9gcs9zoLvt1LB6R4PaYBRYu1/2zYF8EzI/FEWuOl07g8uzR QDI3rMwMrh6rqaE/CNTuNpZsGYRbA+kmD2p3VrHHiZCGdSoabdiaebR1qCTGn7rfRVenSeG5J7x jrtzrEZxWp1xtDChWk2Gwm5dxWZE4elo9ymNAPZ4Cqea8Re4DEZQ+ISpwouvKtttLq7UdiH1RF6 Z3KkyFGQGPInny/ALoGn45CeJhYG62ZzBq6UOaVtDbCGVqZiabQ4+6QGMAk4E+XAHTRrQxVVs/U 0Rsn0ZNHdBdapHCv2LtL2F4odRyQzh5U36SsWqWPZIdAvkIuEjs6jDNGuDAWOcEgJ56O13so9IU ieJmPJSSqKZEeZ8Dkq156tk6MCvfhQsb4MDbEuRYzO8KyV9PUwLbADzhOsMJw4f0Xd/CoPh4x2X fjX5HBoScPCA2kgzl4X6tKhWYYV0laAMivNcnuocin68iCWGNEp3XOD4guzab1jE1h695Y7TDdP /occ19+/xVGCBp7ih7k09ET5wl+2hY/ftAbMS1wWFmg/QWBt32Enz9HYCXrkYX6hHnmgTO+oOob 34Z2Y3jq0N3onMlsvtZX3Qs+O1ULhHM+IaDPiVg8F3oTpUZE21r+01/hqpJpXau4BV4xUhaaZRF RuERImRNnSm7rqw== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v5 0/5] x86/ve: CPUID override follow-ups: arm at once, prefixes, selftests 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 VSTOR-148656, every Container start dying with SIGSEGV once /proc/vz/cpuid_override is non-empty, is fixed in 22.8 by 07338fbae5a3 ("x86/traps: emulate CPUID faults for user tasks in exc_general_protection()"). Working on it turned up two more defects in the same feature, and the fact that nothing had ever exercised it. This series takes care of those. None of them is a 22.x regression, all have been there since the vz9 port. Patch 2: ve_setup_task() only sets TIF_CPUID_OVERRIDE, the MSR follows at the next context switch. A task entering a VE through unshare() or setns() executes CPUID natively until it is scheduled out and sees the host values. set_cpuid_override() flips the MSR synchronously for the current task, the way disable_cpuid() does. Patch 4: check_cpuid_fault() compares two bytes at ip with 0f a2. A CPUID with a legacy or REX prefix faults the same way, but the handler sees the prefix and the task gets SIGSEGV. Use the instruction decoder, as fixup_umip_exception() does, and advance ip by the decoded length. Patches 1, 3, 5: selftests/ve/ve_cpuid_override_test. Each kernel patch gets its own case. The test saves and restores the table around every case and tears down in the parent, because the kselftest harness skips a child-side teardown after a failed ASSERT. Tested on sqvm2-4060, the node of the failing CI run (Broadwell VM with cpuid_fault, cpupools-features 9.1.7, so the table is armed at every Container start). With only the 22.8 fix, cases 3 and 4 fail the way their patches describe: host values, and a child killed by signal 11. With the whole series all four cases pass, repeatedly and on a non-empty table, and the vzctl-pytest start cases from the original ticket pass as well. https://virtuozzo.atlassian.net/browse/VSTOR-148843 Signed-off-by: Konstantin Khorenko --- Changes in v5: - Patch 1: the stop is reported to the parent before the child leaves the CPU, so the child hands over its voluntary context switch count and the parent waits for it to grow before SIGCONT; a SIGCONT in that window would have let the child run on without a switch (Sashiko). - Patch 1, 5: CPUID through __cpuid_count() and an xchg around ebx for the prefixed form, so the 32-bit PIC build is no concern and the Makefile gate can keep ARCH=x86 (Sashiko). - Patch 1: a failed table restore in the teardown fails the test instead of only logging; skip without root; log when the teardown cannot mount cgroup2; wider buffer for /proc//status; the header says one instance at a time (independent review). - Patch 5: early-clobber on the ebx substitute register in the prefixed CPUID asm, as has it (independent review). - Link to v4: http://lore.virtuozzo.com/20261007-b4-prep-khorenko-vstor-148656-cpuid-v4-0-bf16c29bea24@virtuozzo.com Changes in v4: - Patch 1: a child that exits before stopping is reaped by the ready wait, so its pid is cleared there and the teardown cannot kill a reused pid (Sashiko). - Patch 1: spawn leaves the VE cgroup before any ASSERT can fire, so a failed fork() no longer leaves the cgroup behind; a child killed before it stops is logged; the teardown is described as running in whichever process survives the ASSERT, the harness does not run it in the parent on that path (independent review). - Patch 1: use write_file_at() instead of a private copy, renumber the child exit codes, say "at least" in the too-large table message. - Patch 1: record the child pid right after fork(), so a child left stopped by an ASSERT between fork() and the cgroup move is still killed; say that a harness timeout leaves the test table in place and that the second case proves nothing without the first (independent review). - Patch 1: name the fix the tests detect, describe the host-side and fallback checks as the one masked bit they are, log errno when the table read or the cgroup2 mount fails, rename the two table buffers apart, -Wextra clean (independent review). - Link to v3: http://lore.virtuozzo.com/20261006-b4-prep-khorenko-vstor-148656-cpuid-v3-0-16141b8ca07d@virtuozzo.com Changes in v3: - Patch 1: a saved table the kernel cannot take back in one write (a page or more as printed) fails the setup instead of being silently left behind by a failed restore; writes replace the table, so there is no way to restore it in pieces (Sashiko). - Patch 1: the child pid lives in the fixture and the parent-side teardown kills a child that a failed ASSERT left stopped in the VE cgroup, otherwise destroy_ve() fails with EBUSY (Sashiko). - Patch 1: the Makefile keeps ARCH untouched and decides on a private variable, lib.mk picks the clang target by ARCH being empty (Sashiko). - Link to v2: http://lore.virtuozzo.com/20261006-b4-prep-khorenko-vstor-148656-cpuid-v2-0-f6d1192c7d60@virtuozzo.com Changes in v2: - Patch 1: the child stops itself with SIGSTOP after entering the VE and the parent resumes it, so faulting is armed by a real context switch; the pipe handshake, whose read could return without sleeping, is gone (Sashiko). - Patch 1: setup creates the VE cgroup last, so a failed ASSERT in setup leaves nothing behind; a failed restore in teardown is logged (Sashiko). - Patch 1: drop the EAX comparison after the fallback to hardware, the child is not pinned and hybrid CPUs may differ per core (Sashiko). - Patch 1: build the test on x86 only, add the binary to .gitignore (Sashiko). - Patch 3: the no-reschedule case repeats the sequence, a tick can still preempt the child in the window; with the handshake gone a child that dies before reporting is reaped where the result is read and its signal logged (Sashiko). - Retested on sqvm2-2084 with the whole series: all cases pass and the table is restored; on sqvm2-4060 with the stock kernel all cases fail with the expected diagnostics. - Link to v1: http://lore.virtuozzo.com/20261006-b4-prep-khorenko-vstor-148656-cpuid-v1-0-741609f4f03a@virtuozzo.com --- Konstantin Khorenko (5): selftests/ve: check CPUID override emulation for VE tasks x86/ve: enable CPUID faulting at once when the current task enters a VE selftests/ve: check CPUID override right after entering a VE x86/traps: decode the faulting CPUID with the instruction decoder selftests/ve: check CPUID override emulation for a prefixed CPUID arch/x86/kernel/process.c | 12 + arch/x86/kernel/traps.c | 16 +- include/linux/cpuid_override.h | 3 + kernel/ve/ve.c | 2 +- tools/testing/selftests/ve/.gitignore | 1 + tools/testing/selftests/ve/Makefile | 10 + .../testing/selftests/ve/ve_cpuid_override_test.c | 357 +++++++++++++++++++++ 7 files changed, 394 insertions(+), 7 deletions(-) --- base-commit: f5d1fdcfffe101fe2bafa7df09d95d2e811c5c5e change-id: 20261006-b4-prep-khorenko-vstor-148656-cpuid-a5c5993e1f83 Best regards, -- Konstantin Khorenko _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel