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 BABC38017D for ; Tue, 6 Oct 2026 14:58:25 +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 696Ev53S025541; Tue, 6 Oct 2026 17:57:05 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696Ev53S025541 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="WKiGN1R/" 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 696EuqM0025506 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Tue, 6 Oct 2026 17:56:52 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 696EuqM0025506 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-48c4445512dso2234381f8f.2 for ; Tue, 06 Oct 2026 07:56:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBybIGYeuOhC18WracTXU13b6lbJLZNZ6sG00txZe71YMOGI1YsCN0sO+D8mapd2XfFlqfhwJQ==@openvz.org X-Gm-Message-State: AFq9FYIyHdsTm6Kp3eJcqh8HNvAKuKWUbJAMuirEY7Pev3yg6lJrTe0q E+MckhxkT7wxL2f+OJNDm37DV8VNRpuEqHu4+arRMLndXqV2iyKH3yemR/FpMMi4WnLONQHm0U0 1Paqt3y6biAtJrT8nzauRC6RYY2E0xzB2V3rNo+p9teRisL8b6Rf+Vw== X-Gm-Gg: AYBFou0WKWOGJ8u9BEgMroxDUIyLty1Bkw7C0/uOALFH9i80kwlmzR7pn59Kvli+lv8 l2byezO6/fqwh0Yrh90zpm+RQNbx37QLG7RmHLTD/yPoSwLTm60h1MTotJGOUOdd3maiBBCRlaq xh97L9qdyVUiLPUIS9A6lSvyTUT/oeFbQkAyfVdwHa5XzpJ+PHuBDS3gNMdHgoweMw+QUf4pxGY rlBbvr2a4VNFr6RbZQxdlHFjZQ6YaZkcVuda+7Oaec8jhgzvDUTYJRW+pOziK8FFRkP1MoRW5W7 UB3mtycSciX++VNyqtM8vndZ8/FvmbgBhU9CTnBsqZOO9IfmEzAWPNEAKKWNW/KuTMgCjmPjOpw Krz1u7lws/6AP7UbJXg== X-Received: by 2002:a5d:64cc:0:b0:488:57ad:d5c8 with SMTP id ffacd0b85a97d-48c6d0f4b12mr3434711f8f.3.1791298611894; Tue, 06 Oct 2026 07:56:51 -0700 (PDT) X-Received: by 2002:a5d:64cc:0:b0:488:57ad:d5c8 with SMTP id ffacd0b85a97d-48c6d0f4b12mr3434655f8f.3.1791298611215; Tue, 06 Oct 2026 07:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791298611; cv=none; d=google.com; s=arc-20260327; b=rmJtjS/U012mmVukfPCdR7FQ4edRjzz1spTH18JWMut+hACcWE4FKevRjDoCbocQaf 8V8xLlU4eqgvxvZmjzeSGsrLsCb3rrg3Qe1XeDBgHvItZxPL7K6f//274Qnzoy2VF0UW IuvQKB/btJsfNWaVw7qFaWCe3OKVGzPrJw9gLCd7tIQuJZYuTX9nyeN3UWt+Xh/Zbx8A H6n7cQ0fLylfO86KYBZqKzBQI1PUSnuM3TDB/4DwL8Ji/bpk0Qno8McAIvqt2FsuHXGY mHnxIcGPl2FLkUqDIR3pT66YJeRTWGt0Z7W/zMwoFQRRPVDzPtY2qItOBFMc/ozMIP26 awTA== 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=xxxcOtbW5IAjpmVhqqQ5UjWVGQ4UFlxkq9ticlfFjBo=; fh=bRkZfFa6377EgOVW8zBDri2gGIQqe/ZeiH+ijEM/ROI=; b=gA7kaGFZm3jNhMY0mY+bOgoAuLnHBT+sZCIOKzw9M+DuYmzXKjafwmbnGwBkj0EBB0 rUghSkf9GkaBHc9bBPQkXD86JZpmoVt0Vzf9LIgoT9fANOSILxZc0BYO2Idec5QQEGio D0FsfnY/WXqKohbcdL57gbsVgbx8krAUAYNL7KYIzRxogBSAsJF2cfn1rFCSu+/vGFSF oGdqNozrhRLpqYeEc65uBlw/2g8UO+qnKpPcHaRq+eBXZatjh5eusbDJM7u1FYDERCNw u3LAYhZlBMZiufs91oLJA+sHZHUAqSeJPavOJ9ka3sFpWMOZWuSBTX/Glw55HEs+1A8H JZQw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b="WKiGN1R/"; 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-48c6bb90c60si5143114f8f.442.2026.10.06.07.56.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2026 07:56:51 -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="WKiGN1R/"; 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=xxxcOtbW5IAjpmVhqqQ5UjWVGQ4UFlxkq9ticlfFjBo=; b=WKiGN1R/hnn/DaqDDXL tyyWxfa3pSyRE+4VWBFMzlj6sOGfSqqoTbr7HEhOrFxItWSFyvLkobfPeSL8RMyx2p3gvqYnfSdo2 blGEBIRqbCIHd+O0MTzrvzFxrFulhBna3AoL3dN+q7KJBdBOKRgX6VyrSBsh7ClmkTXXzRDbak9KG qocmMwsk5UOp0C2QmleTLkSrudMAnhGyf6kxy8UanfVoQ6A6dDErSByyZFM6GyhAg5gwGEoQxYdAs HRLAWjNF2SuYSJshJJF+2980mX+W/dCBBiBhhW902sNV8yDlvH+VF7u7G2SIn30MScKKLFdlZbAVI JmrbOXPiIQ8l/Rg==; 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 1xE6Xq-00DosW-0K; Tue, 06 Oct 2026 16:56:41 +0200 From: Konstantin Khorenko Date: Tue, 06 Oct 2026 16:56:36 +0200 MIME-Version: 1.0 Message-Id: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v1-3-741609f4f03a@virtuozzo.com> References: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v1-0-741609f4f03a@virtuozzo.com> In-Reply-To: <20261006-b4-prep-khorenko-vstor-148656-cpuid-v1-0-741609f4f03a@virtuozzo.com> To: Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3433; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=NWPkvGQPwtO27FMQaR0NSpuv/45kbMHk//ewTAAqd0s=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBqxQwx/X3LdpTqnqRuq4iygIPcbZYsllSjNHj8B a05UXtF5WaJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCasUMMQAKCRBRlgpH+WFc Kh2LD/9ObOx6KJzcnNOHb3Me6zR75mZDpBClhrNx/Ub0G28hjygRizfktQNmqLYB7Nhr36Ehn2Z YMjZWJZwdnLBSXTBFsMohYMU2nuCoP84rmrsMIFLbgRbG+ts4WkvPrdjH4A8zyKyt0p220AJTjl +Te22wJTpbrBchFRh8xjI52AfqMmkSiP0shPJHVyW6Rv3MzqnZvubd9exCZH9VdUq8w+PiP6czK FkQXxU9zr4VZWAgiFACVAOM5MkqDPDojnOlKxBYsdFLoi/MD36/1vNuggVCJMgHakIH/X+Jab6n 2X8ANRUZEfSG++bBRjFjnlHAAKla+nwZgCf4Hdf8DRuFjOVsOWbifl6w5OeXlLbHTzBvRfMbvn6 Fr4jbeQNGtarLoxF7fA6kij68j/h+ZiEfo1RkFoHEym2fQJuwULkI94UQULw8GIyII73Vdun4Bn V46LAFBKaVtTNFgiRNYXpBFFchTnFl0O31qqtjeDlLX/qG4MkJdjICSk1KeXJPOQRSwZXpY+Czi Kgb0zAnZFE92wa5d0ccIiFi1Gp4kagm2jQh8kfyNL9+wA3RSR/DcbIc6qIUgGftxRL7pdQxnURI hNbbeDgocRss0Pa/GPtphPc/HCKNc6+nDglVpBN2ZBDWYhTMCVKydfIbJ75M+/7Dl1eM0E610u4 DCwpXeK5TizRERw== 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 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 blocking or waking anyone 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. https://virtuozzo.atlassian.net/browse/VSTOR-148843 Feature: x86: cpu pools (cpuid override) Signed-off-by: Konstantin Khorenko --- .../testing/selftests/ve/ve_cpuid_override_test.c | 42 ++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/ve/ve_cpuid_override_test.c b/tools/testing/selftests/ve/ve_cpuid_override_test.c index c066d67d72a82..be2b808f1c77e 100644 --- a/tools/testing/selftests/ve/ve_cpuid_override_test.c +++ b/tools/testing/selftests/ve/ve_cpuid_override_test.c @@ -54,13 +54,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 - * blocks between the two steps: faulting is switched on for the task at its - * next context switch, and the parent may change the table meanwhile. + * moment, then reports its view of the leaf to the parent over a pipe. With + * @wait_go it blocks between the two steps, which lets the parent change + * the table meanwhile and forces a context switch before the CPUID. */ struct child_ctx { int result_pipe[2]; int go_pipe[2]; + int wait_go; }; static int cpuid_child(struct child_ctx *ctx) @@ -73,12 +74,18 @@ static int cpuid_child(struct child_ctx *ctx) if (unshare(CLONE_NEWVE) < 0) return 21; - if (write(ctx->result_pipe[1], "R", 1) != 1) - return 22; - if (read(ctx->go_pipe[0], &go, 1) != 1) - return 23; - + if (ctx->wait_go) { + if (write(ctx->result_pipe[1], "R", 1) != 1) + return 22; + if (read(ctx->go_pipe[0], &go, 1) != 1) + return 23; + } + + /* Without wait_go nothing wakes the parent before the CPUID. */ do_cpuid(CPUID_LEAF, &r); + + if (!ctx->wait_go && write(ctx->result_pipe[1], "R", 1) != 1) + return 22; if (write(ctx->result_pipe[1], &r, sizeof(r)) != sizeof(r)) return 24; return 0; @@ -187,7 +194,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 = { .wait_go = 1 }; struct cpuid_regs r; pid_t pid; @@ -208,7 +215,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 = { .wait_go = 1 }; struct cpuid_regs r; pid_t pid; @@ -224,4 +231,19 @@ TEST_F(ve_cpuid_override, flushed_table_falls_back_to_hardware) EXPECT_NE(r.edx & self->bit, 0); } +/* No context switch between entering the VE and the CPUID. */ +TEST_F(ve_cpuid_override, armed_before_first_reschedule) +{ + struct child_ctx ctx = { .wait_go = 0 }; + struct cpuid_regs r; + pid_t pid; + + ASSERT_EQ(write_cpuid_override(self->table), 0); + + pid = spawn_cpuid_child(_metadata, self->cgv2_fd, self->ctid, &ctx); + collect_cpuid_child(_metadata, pid, &ctx, &r); + + EXPECT_EQ(r.edx, self->host.edx & ~self->bit); +} + TEST_HARNESS_MAIN -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel