[Bug 279901] glibc-2.39-2 and above on the host segfault

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 18 Dec 2024 23:49:22 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279901

--- Comment #41 from Konstantin Belousov <kib@FreeBSD.org> ---
(In reply to Florian Weimer from comment #39)
For 8000_001Dh, the %ecx == 0 reply seems to be legal, for fully assoc cache.
This probably explains why my previous attempt did not worked, lets arbitrary
set asssoc to 2 (%ecx == 1). From your explanation, and what I see in code,
glibc should use the 'new way' then.

For 8000_0006h, bhyve reflects the data reported by the host CPU.

For 8000_0008h, the reported number of threads is user-controllable, AFAIR.
There is a strange force-fallback to legacy reporting of ApicIdSize (%ecx
15:12)
when cpu count per-package is less than 16.  A useful experiment is to remove
it.



diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c
index a833b61786e7..b00ae12f802d 100644
--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -150,8 +150,8 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax,
uint64_t *rbx,
                                 * pkg_id_shift and other OSes may rely on it.
                                 */
                                width = MIN(0xF, log2(threads * cores));
-                               if (width < 0x4)
-                                       width = 0;
+//                             if (width < 0x4)
+//                                     width = 0;
                                logical_cpus = MIN(0xFF, threads * cores - 1);
                                regs[2] = (width << AMDID_COREID_SIZE_SHIFT) |
logical_cpus;
                        }
@@ -256,7 +256,7 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax,
uint64_t *rbx,
                                func = 3;       /* unified cache */
                                break;
                        default:
-                               logical_cpus = 0;
+                               logical_cpus = sockets * threads * cores;
                                level = 0;
                                func = 0;
                                break;
@@ -266,7 +266,7 @@ x86_emulate_cpuid(struct vcpu *vcpu, uint64_t *rax,
uint64_t *rbx,
                        regs[0] = (logical_cpus << 14) | (1 << 8) |
                            (level << 5) | func;
                        regs[1] = (func > 0) ? (CACHE_LINE_SIZE - 1) : 0;
-                       regs[2] = 0;
+                       regs[2] = 1;    /* Num of cache ways */
                        regs[3] = 0;
                        break;

-- 
You are receiving this mail because:
You are the assignee for the bug.