Date: Mon, 9 Jul 2012 11:35:06 GMT From: Dmitrij Tejblum <tejblum@yandex-team.ru> To: freebsd-gnats-submit@FreeBSD.org Subject: i386/169730: [patch] libc/i386/gen/getcontextx.c::__getcontextx_size() is broken Message-ID: <201207091135.q69BZ62v029923@red.freebsd.org> Resent-Message-ID: <201207091140.q69Be5ep086877@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 169730
>Category: i386
>Synopsis: [patch] libc/i386/gen/getcontextx.c::__getcontextx_size() is broken
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: freebsd-i386
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Jul 09 11:40:05 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator: Dmitrij Tejblum
>Release: FreeBSD 9.0-STABLE
>Organization:
>Environment:
>Description:
__getcontextx_size() compute size of "extended" cpu state, depending on the CPU features. To do it, it should check if the bit CPUID2_OSXSAVE present in the "features2" field. But actually it checks some junk instead of the "features2" bitfield.
To get features2 field, one should execure the "cpuid" instruction with EAX==1, but the code use EAX==0. See also the amd64 counterpart (libc/amd64/gen/getcontextx.c) for the correct (I believe) code.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
--- lib/libc/i386/gen/getcontextx.c.00 2012-02-22 01:18:59.000000000 +0400
+++ lib/libc/i386/gen/getcontextx.c 2012-07-06 21:45:04.000000000 +0400
@@ -64,15 +64,15 @@
if (cpuid_supported) {
__asm __volatile(
" pushl %%ebx\n"
" cpuid\n"
" movl %%ebx,%1\n"
" popl %%ebx\n"
: "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3])
- : "0" (0x0));
+ : "0" (1));
if ((p[2] & CPUID2_OSXSAVE) != 0) {
__asm __volatile(
" pushl %%ebx\n"
" cpuid\n"
" movl %%ebx,%1\n"
" popl %%ebx\n"
: "=a" (p[0]), "=r" (p[1]), "=c" (p[2]),
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207091135.q69BZ62v029923>
