From owner-freebsd-i386@FreeBSD.ORG Mon Jul 9 11:40:05 2012 Return-Path: Delivered-To: freebsd-i386@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BD41F1065673 for ; Mon, 9 Jul 2012 11:40:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7BD2B8FC1F for ; Mon, 9 Jul 2012 11:40:05 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q69Be5Pi086878 for ; Mon, 9 Jul 2012 11:40:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q69Be5ep086877; Mon, 9 Jul 2012 11:40:05 GMT (envelope-from gnats) Resent-Date: Mon, 9 Jul 2012 11:40:05 GMT Resent-Message-Id: <201207091140.q69Be5ep086877@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-i386@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dmitrij Tejblum Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 748BB106566C for ; Mon, 9 Jul 2012 11:35:07 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 5EFA88FC12 for ; Mon, 9 Jul 2012 11:35:07 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q69BZ6KP029931 for ; Mon, 9 Jul 2012 11:35:06 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q69BZ62v029923; Mon, 9 Jul 2012 11:35:06 GMT (envelope-from nobody) Message-Id: <201207091135.q69BZ62v029923@red.freebsd.org> Date: Mon, 9 Jul 2012 11:35:06 GMT From: Dmitrij Tejblum To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: i386/169730: [patch] libc/i386/gen/getcontextx.c::__getcontextx_size() is broken X-BeenThere: freebsd-i386@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: I386-specific issues for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jul 2012 11:40:05 -0000 >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: