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 5AC1D80726 for ; Tue, 6 Oct 2026 17:20:52 +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 696HJZsO026662; Tue, 6 Oct 2026 20:19:36 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696HJZsO026662 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ws01xG5h" Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 696HJJtY026622 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 6 Oct 2026 20:19:19 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696HJJtY026622 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a01b112fa2so45558275e9.1 for ; Tue, 06 Oct 2026 10:19:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvByVxY2AmDiOZVX2YRE6ebcx6cUiJY/G4hU3H7gtXD+FwmnyrDoweSH+qx8C78im7BwCjv904A==@openvz.org X-Gm-Message-State: AFuF++mtnt9yz8YsT4t6Fu9TVmkl/r6hEa0cF7SFpu9SUIIpFwAEUGwQ eDX5xfsOHyUCYI0wSyCWAzGpEtLUenqI30optltjlEnW7FzMLyK880CAoheRjwdB7NF+4abAJys wwcxYuuYqIHlElzzs+8b8sVZ3vrpCRiNfhrX1d1PpuIqKYY7iPE2wAA== X-Gm-Gg: AYBFou0lCoJQocLtdbl73NX2CY8stLjmqgrZPA1LY88qbOaLStWrTuiGNxLECC63vO6 idnGgnM9YO2+j74KTaz7QmUDJST9rYoPiOq02muyrMWKhdkVqEWP+5gSOvzGgPdAQhpO8DUUHWz Ih5xZFKwVaAiVcCBiNfIpPZNEL8ADNGWafShrs7nTvzrL7BO08zG6GCwTdRJCDu7a7VVlCtCyeC YCsHxUg7BTypyJgjB9XGWKw8KBvx+Grd2nlbfpQeJEPuzdVHvQ0FWhQ+QN5095+DvIK3VNbk21z 9sRGjlPgUuncgm68Tao2BGU1XzRBSjNVQPKXYS9fr49u5JDh/H44udb0BgMmqXOp5IV0JDX9a/c 931pEgLBV/PZ3s4+XXA== X-Received: by 2002:a05:600c:1f91:b0:4a1:6916:798 with SMTP id 5b1f17b1804b1-4a17b53abc0mr37031585e9.14.1791307159163; Tue, 06 Oct 2026 10:19:19 -0700 (PDT) X-Received: by 2002:a05:600c:1f91:b0:4a1:6916:798 with SMTP id 5b1f17b1804b1-4a17b53abc0mr37031435e9.14.1791307158693; Tue, 06 Oct 2026 10:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791307158; cv=none; d=google.com; s=arc-20260327; b=Q8vUAzPsi1bcH8OmH3bhMa98kNaqH6bm4vsYm25ZqQqNiebdPwtmbkuoh2jMvnUgfr YF/1hh/r+XNIcLkHW5mWN3905P2Y0Whcy4ZjffnaOzf7meBAsZEY4ubn6Y/sfv1o95VQ vHX8i8tHUK0tNSgm5RQCFTgpKJYYcr2NlLy7LwQsO+m0bqbTIj6CX11q99tY/quTuWP5 DvTC0QnEPajgAp7kUn5rWBKyN0M8CZQquF0Tqnx/vjqPSxsO2ZzmHQOrxTY3dpD2kz/q 7S+Jk3oY1jEJuY/vVq837CV+W1rthbq7WoMqziKFgBYoLAY6fPqrhTXt03/0O3ytFx23 Ngzw== 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=pLUhgozBJGeo5hDJxYlovyihG94d4Dc3nJdtI4Cf9cI=; fh=bRkZfFa6377EgOVW8zBDri2gGIQqe/ZeiH+ijEM/ROI=; b=GUfirkcKESoObmlwQZ3KQaSpxOAoFEPQCZE962Bae+CCOeHgW8zv5HdqVDJierS96c UShXlxJe6CXlQ0j3XzonmsSciw2+LFN1KC6UN+JKU3/wfH2PBCzA7utOkPZgoNzGH8iz mVjH1Scv55Ckf/dbqVtvnSlh0D/ak/FBJJ2UkwVRK9A8mCxaxqcaL5WYq49lv7cEgOXA aJ+LVGKdgBG57UazkQckgY+k4P+T2wV8cZ0p1UQ5Pa8XhB8Zal4KW+NmO6C0aEh2MtOE V+Kt9bEZpPaIDvjY8wP3XTNW97QZo1oaws+O4xYJ7oUEWrMIGq5MWl0kFDu6ipXALfiF 0LWQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ws01xG5h; 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-48c7248059bsi418197f8f.229.2026.10.06.10.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 10:19:18 -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=ws01xG5h; 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=pLUhgozBJGeo5hDJxYlovyihG94d4Dc3nJdtI4Cf9cI=; b=ws01xG5hTOU7AiIOjc9 QNyw5upIB045WKuv7L3shq4IoIee7UFoWypwN6YDxHj+ygKXoduKng/sSHtF1OHl2zzaCvGwnxB9G dP4s+9ouefo+uA9QPr0LFLgdawhwbUZow6kBLj/pvvZxyr0bRW+eRtj2DwspMyGqXhi9SSjj9RoNc 6EMcYkY0CrkkO9zwsRNkkaq3pez74iyNDFHCU8IjdK48aNOrJV/xCzXJd11raY1bCN3QGTZkVRgiP Qh+G1mDsS6+LgJHDRTbPRg6ffU+brvaXvvXtAfactYH2Mj72cN7D11Si60++E6i3gms1CxfQDIYFm vixUYyrQbrvDWbQ==; 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 1xE8lh-00GXnn-1C; Tue, 06 Oct 2026 19:19:08 +0200 From: Konstantin Khorenko Date: Tue, 06 Oct 2026 19:19:12 +0200 MIME-Version: 1.0 Message-Id: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v2-3-f6d1192c7d60@virtuozzo.com> References: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v2-0-f6d1192c7d60@virtuozzo.com> In-Reply-To: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v2-0-f6d1192c7d60@virtuozzo.com> To: Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4630; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=FZk8APjeSVQiNv74niVmEY6ElKcNg4QyGKFOZdzEXHE=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqxS2UPGzz6yLaqQ7rhwbHnl9QD73b6hRpcFdkP +7JBL74/GCJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCasUtlAAKCRBRlgpH+WFc KrefEAChwMyPobPPRygUKVnTVUB9Bch1tmFowNg4s3rdyTpUsC7DEiKq1Hvg78XOkNpfuoncLlz MUMztKDUOdGBgheUhCWJZnzXQkcDC0lnv/jeCMaJ6/92USxgLbxzXQiVVC1HNCcnQq8dr4LAAOJ 2jGnezMCrnVvG5KtZUx5o+awvqM2dLzLzkIz/AX7XJrJ+d2Syz9sNEJag+IfYXLbLQLltV0IuVY 2h1+WKDTMLpMf4aWYZk6k2riuTKu96ZV2Duam3qnqa/CAOmPnkeyPBrlNJ88HFu2BYgyYWCsNWh OVG4wOZwgUF6R72WrrHRGUfch2INHl2oWd/ee0GJlK0rxNnByAIcFzuZYKu/om+XePuvBrA0BZh 6BhyrhyI4XCziJjCb1/EerXKFyagj2NArFGY/IrYuwV/XH3LA9HNdjZE6bCgQ03VEwhj7pmDzYN zYnZ3fzx879Wt0X2mE9faOhHqqYkOndc+13ozUmmmsieXLRNhvIik6JgFH2GD+txjxCbR1guBcb ujogQ2amftRDJ5OK0oX6ezow54sq+76d53KB/Y48UHSVeagYfzaKdphTkr75Hj1rzH5x+ZrT9st YTSAhjzOsit+Q2mOUNJuUyKsjCQVREapON5VX3AHsFia54MrKKmIlYeQAnzZK+K3uDOCduVeltg jTDHutwO5+S72HQ== 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 v2 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 | 54 ++++++++++++++++------ 1 file changed, 41 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 291b88404a53e..0e748d4fd5f33 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 /* 128 entries of up to 67 characters each, as the kernel prints them. */ #define CPUID_TABLE_MAX 16384 @@ -56,13 +57,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) @@ -73,7 +75,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); @@ -148,7 +150,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, int cgv2_fd, int ctid, struct child_ctx *ctx) { @@ -166,11 +168,13 @@ static pid_t spawn_cpuid_child(struct __test_metadata *_metadata, ASSERT_GE(enter_cgroup(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; } @@ -197,7 +201,7 @@ static void collect_cpuid_child(struct __test_metadata *_metadata, pid_t pid, 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; @@ -218,7 +222,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; @@ -233,4 +237,28 @@ 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; + pid_t pid; + int i; + + ASSERT_EQ(write_cpuid_override(self->table), 0); + + for (i = 0; i < NO_RESCHED_ROUNDS; i++) { + struct child_ctx ctx = { .stop = 0 }; + + pid = spawn_cpuid_child(_metadata, self->cgv2_fd, self->ctid, + &ctx); + collect_cpuid_child(_metadata, pid, &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