From b1dee1bc7f0a150493c3865ef8b62c42842cabc9 Mon Sep 17 00:00:00 2001 From: Farrah Chen Date: Wed, 26 Aug 2026 16:33:43 +0800 Subject: [PATCH 1/2] lass: detect lass enable via /proc/cpuinfo flag Determine LASS enablement from the kernel-exposed lass flag in /proc/cpuinfo instead of parsing /proc/cmdline, since there is no lass kernel command line parameter and LASS is enabled from CPUID. Also fix lass_enable being unconditionally set to true so the detection result is honored. [Test Components] lass [Test Types] func Co-developed-by: Copilot Signed-off-by: Farrah Chen (cherry picked from commit 6ab86a2834e016c0df319b4ce79ed8715694f59d) --- BM/lass/lass.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/BM/lass/lass.c b/BM/lass/lass.c index 895b96a7..0e80b0b1 100644 --- a/BM/lass/lass.c +++ b/BM/lass/lass.c @@ -127,11 +127,11 @@ int cpu_has_lass(void) return (cpuinfo[0] & (1 << 6)); } -/* Get information from /proc/cmdline */ +/* Check the lass flag exposed by the kernel in /proc/cpuinfo */ static bool check_lass_enable(void) { char buf[256] = {0}; - char command[256] = "cat /proc/cmdline"; + char command[256] = "grep -m1 -ow lass /proc/cpuinfo"; bool rv = false; FILE *cmd = popen(command, "r"); @@ -141,7 +141,7 @@ static bool check_lass_enable(void) ; // printf("Get buff:%s\n", buf); pclose(cmd); - rv = (strstr(buf, " lass") != 0); + rv = (strstr(buf, "lass") != 0); // printf("%s Get lass! rv:%x\n", __func__, rv); } @@ -290,9 +290,9 @@ static int test_read_vsys_address(void) printf("can_read:%d, vsyscall_map_r:%d\n", can_read, vsyscall_map_r); if (vsyscall_map_r == can_read) - pass_case("Could read vsyscall addr is expected"); + pass_case("vsyscall read behavior matches expectation"); else - fail_case("Could not read vsyscall addr is not expected"); + fail_case("vsyscall read behavior does not match expectation"); return 0; } @@ -714,9 +714,10 @@ int main(int argc, char *argv[]) if (!check_lass_enable()) { lass_enable = false; - printf(" under default mode without lass defined in cmdline.\n"); + printf(" no lass flag in /proc/cpuinfo, running under default mode without lass.\n"); + } else { + lass_enable = true; } - lass_enable = true; check_vsyscall_status(); From 7729da37f8f0941c00c47d92bd7facf8b185d7a3 Mon Sep 17 00:00:00 2001 From: Farrah Chen Date: Wed, 26 Aug 2026 17:53:03 +0800 Subject: [PATCH 2/2] lass: read full /proc/cmdline when detecting vsyscall mode check_vsyscall_status() read /proc/cmdline into a 256-byte buffer, but a real distro kernel command line often exceeds that. The fgets() loop then keeps only the last chunk, so an early vsyscall= token (e.g. vsyscall=none) was dropped and the mode was misdetected, causing the 'm' case to fail unexpectedly. Enlarge the buffer to hold the whole command line (x86 COMMAND_LINE_SIZE is 2048). [Test Components] lass [Test Types] func Co-developed-by: Copilot Signed-off-by: Farrah Chen (cherry picked from commit 1fd00ef702cb0dfc8e2c1105126248274a19fff5) --- BM/lass/lass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BM/lass/lass.c b/BM/lass/lass.c index 0e80b0b1..341ca132 100644 --- a/BM/lass/lass.c +++ b/BM/lass/lass.c @@ -151,7 +151,7 @@ static bool check_lass_enable(void) /* Get information from /proc/cmdline */ static bool check_vsyscall_status(void) { - char buf[256] = {0}; + char buf[4096] = {0}; char command[256] = "cat /proc/cmdline"; bool rv = false;