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 1AA7980799 for ; Tue, 6 Oct 2026 20:46:02 +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 696Kimhg027837; Tue, 6 Oct 2026 23:44:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696Kimhg027837 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="JExln9WW" Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696KicOp027805 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 6 Oct 2026 23:44:38 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696KicOp027805 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4a17e77c5b1so3211245e9.1 for ; Tue, 06 Oct 2026 13:44:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBzHn5frMPduLM6K5VINpsmEEf9SPYuqyKqZ1opB1sIjmmJNuL2r+34TIuXnThb31AkVspvNKA==@openvz.org X-Gm-Message-State: AFuF++n/lCLcrzhvHSHWoU1PMlaRJ1HDF9yXlKmXGG34JigxtBUZW1LH N2+6r4/+PvXVtZyJp0JiK31BOWwNlIj3VxqmbfUWvW4RuyfS+JLwW4MvpYZ2vLuy3SnfRQgNavv gtNQ4E9tqYSQObAltUQNdAiRe+Jb2vSIY+KUJnyBQO2d1B826xQmFRw== X-Gm-Gg: AYBFou2PJKbU5QtAq1ZfGTujzjccHhCwKM/gQjxwQ8g1ND0W0YiKf+ONV6w64U0neZp S3/ejAHk5zX/DqSG4kzOJF3q58XvoVb2fq7VfPpML3Cn1QGHcwmEQX5hDNa0X5ngBnRmm1dnsdT 2IDVUzW3C0jd8vDB/+FsgclKobuUafVkeS4MJFHaKv6CmSg5qORJyyhxrib9abQZne+H7Mj+hc3 oZljOBkAviCg+RnHEjCErHTM68WRh0DbAqlp0r3ufZJGTT3Bd70DSOkGhZFv8sbzVjgVAVZZZ6h g0bSQ1iXnGwQmrAsoFbnbVoKeSwuQewUFnOU0bJ6M0Zascw2YqxlWx3RIyDXYHhLrPfCRKUthIM 9TA98xujk67Jyllun X-Received: by 2002:a05:600c:34d5:b0:4a0:25c:8af2 with SMTP id 5b1f17b1804b1-4a18064cf50mr493095e9.17.1791319478297; Tue, 06 Oct 2026 13:44:38 -0700 (PDT) X-Received: by 2002:a05:600c:34d5:b0:4a0:25c:8af2 with SMTP id 5b1f17b1804b1-4a18064cf50mr492755e9.17.1791319477821; Tue, 06 Oct 2026 13:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791319477; cv=none; d=google.com; s=arc-20260327; b=VCfTyAGHHGXuhOua+6kium5rFT/fKxRKpHloUrmvVFWp2kXqoVMdLPt+RRIATJF24A 1jvHuZ3LStjGKrtSBXHyiz856kwuB2lsWP/+v0vtu5WtDwm7nEhVTV7Z0eRCp8Rkjuow a6mmjqJBFeb3GoewfebO+KA+WhXcualPoCdsUc2YnP84h/CL0gKN3dLovzKhaUvmL46I Al+tlde9tIUlplqlTC73HSWrJEfmag1Nql0ssxFEVHQqxyDkF6/m53VF5LnrvDEkqzbS uhZ7HF6qcTlLjXLRtBeLgbbIG7myI5C57+cWHWtVUFu0M/Mxkv9FbGPkFBaWeKT3ZBhS 8fWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=Iev0lB7wBKp+kzuFGeJeyOPXt2P6gCU+Q3Gw1QtqlOk=; fh=bRkZfFa6377EgOVW8zBDri2gGIQqe/ZeiH+ijEM/ROI=; b=b0pWiEDKcyWJVshbJndEzTHi324oXyJMoBOnHGVRYJnM/cO+X2VBpxOy99yK6uiohX 0fgl1Tx+ClTUvhYxkjVIHWjSpPNJCY0yOSjx1fnm3Zxb8fTSp56sPJKV33302jDoX8Q3 M1PziaIc4+sirUj7VwAdN7Cbs9uiVZwdCwxjnshM9yfch+lVYlk+0sq67vNCGm9OoNiF XpEPpu67e5nNWiKJxo2NnZDakbceBXArpsijZDPm7tHKHdzupqYVDyUXT/cr5qmqVH3D dRyiU6HjmT7PAsrGrLc/iSjoMuwQK3sMt/cIH85hOoPZWWIfUMt82f52W1YHdNHCA3Gj xc0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=JExln9WW; 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-48c724a7568si1096187f8f.350.2026.10.06.13.44.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 13:44: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=JExln9WW; 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=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=Iev0lB7wBKp+kzuFGeJeyOPXt2P6gCU+Q3Gw1QtqlOk=; b=JExln9WWrxmnXm7wDgS w55cy4bzXqMrU5AzBYWi8LfQvA++54xmoqKb86rhNS5cCUbA28mpwSlM9g7lnLjVne7nsrv1G6TSp DT4v2g/HRgSQ48zSYldid2r/nAY9HbkO2ieVwb/vLsn6+XBcOmcF1h8MIIxaEgiQwgyav//dX7oVB DCldg8gCasGnzlLx1La9vG125nwyH67dVUpmmUKa42d4z/0inZJcMttxupui9RF6CUa16U5valdqQ /HVQk7Y8E/JeMhJoK+7i6XzepkeU6HZNz5+zDa2E6ZpX6gve0j7FPYOKYcPpvKhoyeuaYe92S3+0f hgc/C3Riwd2IPLQ==; 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 1xEByO-002tkg-0x; Tue, 06 Oct 2026 22:44:27 +0200 From: Konstantin Khorenko Date: Tue, 06 Oct 2026 22:44:34 +0200 MIME-Version: 1.0 Message-Id: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v3-3-16141b8ca07d@virtuozzo.com> References: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v3-0-16141b8ca07d@virtuozzo.com> In-Reply-To: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v3-0-16141b8ca07d@virtuozzo.com> To: Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4642; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=15pVbA8rtKn5+jf8dy2CPlDV7N/wA2gdB6K+nxe4glE=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqxV2z4/R7wLKMAYzw5tK2gvmLKk6HcJkwXzCn1 EN6XSA1/EGJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCasVdswAKCRBRlgpH+WFc Kt5cD/4qLCaHX/Nu8SvnXg91vQuLKoC4zOgiBUjkvxUKlp/r3gN6MiqEvgWEMWbtjSAxKmjDzGs z30jyHNhkndS8N/8aSEjmZTvw5RZiDbZ/WyTJkNoMHt11MmrMNkicDX6t2gXclWdHbZbRB6PD8W qnd0eFJJRw0EBreURhJide6W57wOhqEPfzrLIZ/g7vJhBQ+CcLVmYdI7w8BbydgZuT54mke6Anp 9skBrx2QwHxN2EGtmHY7VEB4enupDfvE+KuWA+Hnr+1eMFRctp9Zj6wNirldqr2oK1lVUWdjXVD XIrkPhcnfL3Gp/feQeOqv92d93QGeIfG1KTMEyiD536dzjJvp3VxBOM/35obOdXp0DXJgMw38f4 vNrJptkqNpF6E7AdqMH0F7LaE8KZIQ0RM4EtrCUCZ/vFS8pKadwkSE/GobY5SljsmTOvKow2+71 fts7cXJEKFWnb5wIDzxcI7Fg+uUCOu2+aM9Og+L7MI1HuV3LLkz44j0tVTJxkD8m7PyYMaioUnx mGhnYgycOOsOpZqV/DoD1D1tkGY8sXE1gngFnRrYx9Xa1IwWmUKTjCrCizRwpbP7/1AG80lQh+5 T+WvLuPWFQT6oKx0GHiy/fFfbGjkmUjzXs6t58S6WqGRDEeXwcxcpVeLAw2HotJgg0ooJm6wtZi E9yA6Rg3uqTL78Q== 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 v3 3/5] selftests/ve: check CPUID override right after entering a VE 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 Add a case where the child executes CPUID straight after unshare(), without stopping or blocking in between, and expects the table values. Before the kernel change the override took effect only after the first context switch, so the child saw the hardware values. A tick can still preempt the child in that window, so the case runs the sequence several times: a kernel that arms faulting only at the switch has to get lucky every time. https://virtuozzo.atlassian.net/browse/VSTOR-148843 Feature: x86: cpu pools (cpuid override) --- .../testing/selftests/ve/ve_cpuid_override_test.c | 52 ++++++++++++++++------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/ve/ve_cpuid_override_test.c b/tools/testing/selftests/ve/ve_cpuid_override_test.c index 0e3537099ddb2..9d2d5ddd32201 100644 --- a/tools/testing/selftests/ve/ve_cpuid_override_test.c +++ b/tools/testing/selftests/ve/ve_cpuid_override_test.c @@ -27,6 +27,7 @@ #define CPUID_OVERRIDE_PATH "/proc/vz/cpuid_override" #define CPUID_LEAF 1 #define CPUID_TABLE_LEN 128 +#define NO_RESCHED_ROUNDS 20 /* The kernel takes a table back only in one write below a page. */ #define CPUID_WRITE_MAX 4096 #define CPUID_TABLE_MAX (2 * CPUID_WRITE_MAX) @@ -57,13 +58,14 @@ static int write_cpuid_override(const char *table) /* * The child enters a fresh VE, so it is armed with the table state of that - * moment, then reports its view of the leaf to the parent over a pipe. It - * stops itself in between: a stopped task is off the CPU, so the resume is - * a context switch, and the parent may change the table while the child - * stands still. + * moment, then reports its view of the leaf to the parent over a pipe. With + * @stop it stops itself in between: a stopped task is off the CPU, so the + * resume is a context switch, and the parent may change the table while + * the child stands still. */ struct child_ctx { int result_pipe[2]; + int stop; }; static int cpuid_child(struct child_ctx *ctx) @@ -74,7 +76,7 @@ static int cpuid_child(struct child_ctx *ctx) if (unshare(CLONE_NEWVE) < 0) return 21; - if (raise(SIGSTOP)) + if (ctx->stop && raise(SIGSTOP)) return 22; do_cpuid(CPUID_LEAF, &r); @@ -155,7 +157,7 @@ FIXTURE_TEARDOWN_PARENT(ve_cpuid_override) close(cgv2_fd); } -/* Fork the child into the VE and return once it stands still there. */ +/* Fork the child into the VE; with @stop return once it stands still. */ static pid_t spawn_cpuid_child(struct __test_metadata *_metadata, FIXTURE_DATA(ve_cpuid_override) * self, struct child_ctx *ctx) @@ -175,11 +177,13 @@ static pid_t spawn_cpuid_child(struct __test_metadata *_metadata, ASSERT_GE(enter_cgroup(self->cgv2_fd, 0), 0); close(ctx->result_pipe[1]); - ASSERT_GE(waitpid(pid, &status, WUNTRACED), 0); - if (WIFEXITED(status)) - TH_LOG("child exited with %d before stopping", - WEXITSTATUS(status)); - ASSERT_TRUE(WIFSTOPPED(status)); + if (ctx->stop) { + ASSERT_GE(waitpid(pid, &status, WUNTRACED), 0); + if (WIFEXITED(status)) + TH_LOG("child exited with %d before stopping", + WEXITSTATUS(status)); + ASSERT_TRUE(WIFSTOPPED(status)); + } return pid; } @@ -208,7 +212,7 @@ static void collect_cpuid_child(struct __test_metadata *_metadata, TEST_F(ve_cpuid_override, ve_sees_table_host_sees_hardware) { - struct child_ctx ctx; + struct child_ctx ctx = { .stop = 1 }; struct cpuid_regs r; pid_t pid; @@ -229,7 +233,7 @@ TEST_F(ve_cpuid_override, ve_sees_table_host_sees_hardware) TEST_F(ve_cpuid_override, flushed_table_falls_back_to_hardware) { - struct child_ctx ctx; + struct child_ctx ctx = { .stop = 1 }; struct cpuid_regs r; pid_t pid; @@ -244,4 +248,26 @@ TEST_F(ve_cpuid_override, flushed_table_falls_back_to_hardware) EXPECT_NE(r.edx & self->bit, 0); } +/* + * The child does not block between entering the VE and the CPUID, but a + * tick can still preempt it there. Repeat, so that a kernel which arms + * faulting only at the switch has to get lucky every time. + */ +TEST_F(ve_cpuid_override, armed_before_first_reschedule) +{ + struct cpuid_regs r; + int i; + + ASSERT_EQ(write_cpuid_override(self->table), 0); + + for (i = 0; i < NO_RESCHED_ROUNDS; i++) { + struct child_ctx ctx = { .stop = 0 }; + + spawn_cpuid_child(_metadata, self, &ctx); + collect_cpuid_child(_metadata, self, &ctx, &r); + ASSERT_EQ(r.edx, self->host.edx & ~self->bit) + TH_LOG("round %d", i); + } +} + TEST_HARNESS_MAIN -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel