From nobody Fri Dec 19 10:55:54 2025 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F0DA184540 for ; Tue, 4 Nov 2025 19:31:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284679; cv=none; b=Sa3R5Y5wblQqDaWZGphXGyFYGHp4Z5/t22uB69iXnsnU9PlD26W2QY6/PalMIMK6t8PQqpKh8nwH87Zh4B/C4Q3DZ3vloB/XYeDmoOLZSPR5zcEDs9lIuMfaNXZ8j7fbUQiGxsy9mcdvyr2DrYO3JlEUOaqJRcpM5KSS6rLucTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284679; c=relaxed/simple; bh=pnJdLRml59KM/6R8I9/bLJImximiLfRJIf5qVWtTj+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sZN3k1pIQ2j0ZOYvDTQDivVWrkMdy0dNw7b+5Nge7i8PV4cAc+lsRryluIQlQiv0Oi/qphn2X0ti9gKU8nzdoNsMMOyCsb5MgY+GOtcmtTkwTqrxJz5/XcE9cYvINh89+EPJNTydk2CTbA8fSPxJyAbjfCDVbkDodJJ2R5dj1Sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ggdAo1GA; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ggdAo1GA" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1762284674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vCypeWKlDM3/Kf44AfQNFN9PYKjkYPOvRvn07TDQo3Q=; b=ggdAo1GAjo/ZABS4Ne9MW14hmNxS7R6haNS6fgUH274wOGEMr/5Z/Xliz8Ox2TYQ/h2srI fEkCgdXI3I0H+udhbVOtaNes4gzMhv07oqTrhK+TbH2UZcvUKG/zWHxqyvNFU+sp5ZqVfc VxRweMZs4lq6YP8r0XBgtbKTlaZyt0I= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [kvm-unit-tests 1/4] x86/vmx: Skip vmx_pf_exception_test_fep early if FEP is not available Date: Tue, 4 Nov 2025 19:30:13 +0000 Message-ID: <20251104193016.3408754-2-yosry.ahmed@linux.dev> In-Reply-To: <20251104193016.3408754-1-yosry.ahmed@linux.dev> References: <20251104193016.3408754-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" The check to skip the test is currently performed in the guest code. There a few TEST_ASSERTs that happen before the guest is run, which internally call report_passed(). The latter increases the number of passed tests. Hence, when vmx_pf_exception_test_fep is run, report_summary() does not return a "skip" error code because the total number of tests is larger than the number of skipped tests. Skip early if FEP is not available, before any assertions, such that report_summary() finds exactly 1 skipped test and returns the appropriate error code. Signed-off-by: Yosry Ahmed --- x86/vmx_tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 0b3cfe50c6142..4f214ebdbe1d9 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -10644,7 +10644,10 @@ static void vmx_pf_exception_test(void) =20 static void vmx_pf_exception_forced_emulation_test(void) { - __vmx_pf_exception_test(NULL, NULL, vmx_pf_exception_forced_emulation_tes= t_guest); + if (is_fep_available) + __vmx_pf_exception_test(NULL, NULL, vmx_pf_exception_forced_emulation_te= st_guest); + else + report_skip("Forced emulation prefix (FEP) not available\n"); } =20 static void invalidate_tlb_no_vpid(void *data) --=20 2.51.2.1026.g39e6a42477-goog From nobody Fri Dec 19 10:55:54 2025 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 822A52D8DDF for ; Tue, 4 Nov 2025 19:31:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284680; cv=none; b=D9HOgJ0gXR/VaI9gLb0ESTZMpTlWxXkSzQzmSmJOwYSfhi0u9LQJR3RSPJNj6IQe8w6P4LqqOuyVtocr4x/cUmkjAi7qIGhb3dePh7B+2DX7IagAAcO3Rqw96bng6GKTo/aUPYMtQgEN2uR9iSIqdCRmR9a+0pFz2y6dMo/kCHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284680; c=relaxed/simple; bh=wqUNVKL8v768YOHBTWNTvZgtQ4Ct5tATq9NbNTdlpU8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QJ2B/xhRR0tcIe2/OpNT4TrMtJTBxQHHRU9GzuHvulkupLd1nVr7P8ddMs/cAH4r/zSQzpkpapVrCTmfuEh+abVj8P3shfiiVPcWe9Jvkc/St1ahNZBb7BPUY/6fV5UtuxyQYEG+BZ+w3OLtYw9uD4DttgCOBT8S05cN7x0qny0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TSO5Zpvl; arc=none smtp.client-ip=95.215.58.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="TSO5Zpvl" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1762284676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5yeVlMAcS+nPhQGjM8V6lNyq9Vi8yJTliVlIvK4CNPY=; b=TSO5ZpvlEa0Jnz4DHG5kBK8jHyWxYqLVTD5khYb6YNnAtyei0ID/rtIzELnGJhrKdTPEWh JQ8C5pQZH9wDAAr4sqIHNvCUfAv9YPV4hDlOdVB2oOdc9I1UHo1LG0/LFHwa5spFeVT3WQ 9oPVBHAdJuxWyr3A9e8NVYq0clPFoaI= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [kvm-unit-tests 2/4] x86/svm: Print SVM test names before running tests Date: Tue, 4 Nov 2025 19:30:14 +0000 Message-ID: <20251104193016.3408754-3-yosry.ahmed@linux.dev> In-Reply-To: <20251104193016.3408754-1-yosry.ahmed@linux.dev> References: <20251104193016.3408754-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" When SVM tests are run, the log is a see of PASS/FAIL/SKIPs that are not clearly separated by test. Sometimes it's hard to attribute a failure to a specific test (e.g. if the same helper is reused by multiple tests). Print the test name before running each test. Signed-off-by: Yosry Ahmed --- x86/svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/x86/svm.c b/x86/svm.c index 5015339ddb657..de9eb19443caa 100644 --- a/x86/svm.c +++ b/x86/svm.c @@ -407,6 +407,7 @@ int run_svm_tests(int ac, char **av, struct svm_test *s= vm_tests) report_skip("%s (not supported)", svm_tests[i].name); continue; } + printf("SVM test: %s\n", svm_tests[i].name); if (svm_tests[i].v2 =3D=3D NULL) { if (svm_tests[i].on_vcpu) { if (cpu_count() <=3D svm_tests[i].on_vcpu) --=20 2.51.2.1026.g39e6a42477-goog From nobody Fri Dec 19 10:55:54 2025 Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBD352DF130 for ; Tue, 4 Nov 2025 19:31:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284682; cv=none; b=diRRIO9lXlpPZYPk9UDHI4PFucxHZrJL4AL6R8lw6RGRWs2h+y83iTXA2dFZ5ZqI9glvAfMFEliZUc97U8bkvmF70f4+AJfVdWkZv0n0GE6v5ydDDO6EunFEKBMY3/03oR9vGojlYGiFDMmZ18tI+7uqnG/SkeV6CVk/kxBNOWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284682; c=relaxed/simple; bh=kt678DbU1qxWHIB0EdWESp0hwR1eDkZu5lvd3m8VPAM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OMEJVrLZzwPNLl9J/nf7vIcFmIlE1UIBVRLe+G+VFtxot4e2Zqu0sK6vXccjDIoN2u6pgh8DMjd+HzeEhTWSU1QF/lmgtWFG9AKiXhK4sGyFiPwvwwWa3bLsyUe9AmIJPvkYDILcQ1ZGJ0f2YdMyq8+VYNI5rPTBhjT04BHmnKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=e4bKQDvR; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="e4bKQDvR" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1762284679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3L/cBhwg47T+kUAQUIyvUlpW3xHKx07/9p0yryhRDOY=; b=e4bKQDvR+p/mKAV3Nfe+qHm6Dk52w4rpjOyqSGhxu8Egi1T9vp/SgSuR4P2lnm2J0IIrHw KazOn7Ih8TJup/tcuYQFarywnLvOoJvwF0tkwMGcMeqiHTMFaE76JZTpY+DNy/JnJTLc0d KQRIX4DXcFv7sbSqBXelorVwouY24t8= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [kvm-unit-tests 3/4] x86/svm: Replace #UD on failure in LBRV tests with proper report()s Date: Tue, 4 Nov 2025 19:30:15 +0000 Message-ID: <20251104193016.3408754-4-yosry.ahmed@linux.dev> In-Reply-To: <20251104193016.3408754-1-yosry.ahmed@linux.dev> References: <20251104193016.3408754-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" In LBRV tests, failures in the guest trigger a #UD and does not convey useful debugging info (i.e. expected and actual values of MSRs). Replace them with proper report() calls. Admittedly, it is unclear why the choice of #UD was made given that report() works fine in the guest. Signed-off-by: Yosry Ahmed --- x86/svm_tests.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/x86/svm_tests.c b/x86/svm_tests.c index 2981f459032cb..8d309860e76e5 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -3017,16 +3017,17 @@ do { \ TEST_EXPECT_EQ((u64)to_expected, amd_get_lbr_rip(MSR_IA32_LASTBRANCHTOIP)= ); \ } while (0) =20 -/* - * FIXME: Do something other than generate an exception to communicate fai= lure. - * Debugging without expected vs. actual is an absolute nightmare. - */ #define GUEST_CHECK_LBR(from_expected, to_expected) \ do { \ - if ((u64)(from_expected) !=3D amd_get_lbr_rip(MSR_IA32_LASTBRANCHFROMIP))= \ - asm volatile("ud2"); \ - if ((u64)(to_expected) !=3D amd_get_lbr_rip(MSR_IA32_LASTBRANCHTOIP)) \ - asm volatile("ud2"); \ + u64 from_ip =3D amd_get_lbr_rip(MSR_IA32_LASTBRANCHFROMIP); \ + u64 to_ip =3D amd_get_lbr_rip(MSR_IA32_LASTBRANCHTOIP); \ + \ + report((u64)(from_expected) =3D=3D from_ip, \ + "Expected MSR_IA32_LASTBRANCHFROMIP: 0x%lx, found: 0x%lx", \ + (u64)from_expected, from_ip); \ + report((u64)(to_expected) =3D=3D to_ip, \ + "Expected MSR_IA32_LASTBRANCHTOIP: 0x%lx, found: 0x%lx", \ + (u64)to_expected, to_ip); \ } while (0) =20 #define REPORT_GUEST_LBR_ERROR(vmcb) \ --=20 2.51.2.1026.g39e6a42477-goog From nobody Fri Dec 19 10:55:54 2025 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6819F2E6CC0 for ; Tue, 4 Nov 2025 19:31:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284684; cv=none; b=MwSO6cThhSN9ipYmkJxTQPLyxzHZ2IJlUjq931kRgJfYOBU05y1/KFdcEHPyCgS/UyZErSw0FbU0UcOyJLRcz/U+8GI75VbL8CcpWVIsqVgKptYiOgFlyWvEG4Dk9Hg4lkCqJ1Wrx2+6beUL5G2dhJ1Y+YpKDB5JDesKIw4416g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762284684; c=relaxed/simple; bh=+ZJA6Q75MIRb7BPwJQxYYkjbOwsjL+1qbka9doCeMbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q7JGntK26mFGpmiLFW4M2hUC4GJt2PZzumHoWr/iAc3DK4YsIgmDNNyi2i8yO2lHH1LLiLj0IVDoE+/Eye9ZMQVr4uZ8fPLvSypuJv5ZSEcMLsUmD7jRrM5Ie5CpvLVUbw+JQvZ06AVQCg2Ajp/UMp3wuf7zaonGG0J8NdhJvXA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=JMwYmvBO; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="JMwYmvBO" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1762284680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=givJI//PiAABh+/f+gBvpZ0lroLLWSUedcKqAHccxGg=; b=JMwYmvBOMhpEjCwRCpCXCEUnynnZCC36OZL1GruFCVBVHW6+CLEIPl1+ZWyjQUhagROsBD JaScDP0pzUaLU1yohIV7iNXFG0lQZwEl0EkFsHdxUv7YQhGMf54KjZ2onkBGmXI5GBEAi7 QJb7krxIBAYJF+vcb7qwaPwh1lAPAR0= From: Yosry Ahmed To: Sean Christopherson Cc: Paolo Bonzini , Jim Mattson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed Subject: [kvm-unit-tests 4/4] x86/svm: Deflake svm_tsc_scale_test Date: Tue, 4 Nov 2025 19:30:16 +0000 Message-ID: <20251104193016.3408754-5-yosry.ahmed@linux.dev> In-Reply-To: <20251104193016.3408754-1-yosry.ahmed@linux.dev> References: <20251104193016.3408754-1-yosry.ahmed@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" On an AMT Turin (EPYC Zen 5), svm_tsc_scale_test flakes on the last test case with 0.0001 TSC scaling ratio, even with the 24-bit shift for stability. On failure, the actual value is 49 instead of the expected 50. Use a higher scaling ratio, 0.001, which makes the test pass consistently. Signed-off-by: Yosry Ahmed --- x86/svm_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86/svm_tests.c b/x86/svm_tests.c index 8d309860e76e5..29c899762b7a4 100644 --- a/x86/svm_tests.c +++ b/x86/svm_tests.c @@ -1002,7 +1002,7 @@ static void svm_tsc_scale_test(void) } =20 svm_tsc_scale_run_testcase(50, 255, rdrand()); - svm_tsc_scale_run_testcase(50, 0.0001, rdrand()); + svm_tsc_scale_run_testcase(50, 0.001, rdrand()); } =20 static void latency_prepare(struct svm_test *test) --=20 2.51.2.1026.g39e6a42477-goog