NetBSD Problem Report #58693

From www@netbsd.org  Tue Sep 24 16:22:28 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EA95C1A923B
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 24 Sep 2024 16:22:27 +0000 (UTC)
Message-Id: <20240924162226.5C6981A923D@mollari.NetBSD.org>
Date: Tue, 24 Sep 2024 16:22:26 +0000 (UTC)
From: cmeerw@cmeerw.org
Reply-To: cmeerw@cmeerw.org
To: gnats-bugs@NetBSD.org
Subject: x86-64 VM: assertion "lp_max >= core_max" failed
X-Send-Pr-Version: www-1.0

>Number:         58693
>Category:       kern
>Synopsis:       x86-64 VM: assertion "lp_max >= core_max" failed
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 24 16:25:01 +0000 2024
>Originator:     Christof Meerwald
>Release:        10.0
>Organization:
>Environment:
NetBSD linveo.cmeerw.net 10.0 NetBSD 10.0 (GENERIC) #2: Tue Sep 24 15:50:04 UTC 2024  cmeerw@linveo.cmeerw.net:/home/cmeerw/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
In some VM environments (with Intel x86-64 CPUs), information returned from cpuid might be somewhat inconsistent, so we run into this assertion in arch/x86/x86/cpu_topology.c:

  assertion "lp_max >= core_max" failed

In my case this was seen on an Intel VM with 2 CPU cores assigned to the VM, relevant bits from the cpuid information:

      hyper-threading / multi-core supported = false

      maximum IDs for cores in pkg       = 0xf (15)

   brand = "Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz"

This means that lp_max ends up being 1 and core_max = 16.

Other OSes like Linux or FreeBSD work fine in such an environment.

see https://mail-index.netbsd.org/tech-kern/2024/09/22/msg029737.html for some initial discussion on the mailing list.
>How-To-Repeat:
Try to boot NetBSD on a VM with somewhat inconsistent cpuid information as shown above.
>Fix:
It seems like the safest thing to do would be to turn the assertion into an if with maybe a warning and setting smt_bits = 0 in the else branch, e.g.

Index: arch/x86/x86/cpu_topology.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/x86/cpu_topology.c,v
retrieving revision 1.21
diff -u -r1.21 cpu_topology.c
--- arch/x86/x86/cpu_topology.c 12 Oct 2022 10:26:09 -0000      1.21
+++ arch/x86/x86/cpu_topology.c 24 Sep 2024 15:49:12 -0000
@@ -160,8 +160,12 @@
                core_max = 1;
        }

-       KASSERT(lp_max >= core_max);
-       smt_bits = ilog2((lp_max / core_max) - 1) + 1;
+       if (lp_max >= core_max) {
+               smt_bits = ilog2((lp_max / core_max) - 1) + 1;
+       } else {
+               printf("WARNING: lp_max < core_max, assuming no SMT\n");
+               smt_bits = 0;
+       }
        if (core_bits == 0) {
                core_bits = ilog2(core_max - 1) + 1;
        }

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.