From patchwork Thu Jun 2 09:35:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pawar, Amit" X-Patchwork-Id: 12709 Received: (qmail 130107 invoked by alias); 2 Jun 2016 09:35:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 130092 invoked by uid 89); 2 Jun 2016 09:35:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1577, HX-MS-Exchange-CrossTenant-originalarrivaltime:Jun, family, 876 X-HELO: na01-bn1-obe.outbound.protection.outlook.com From: "Pawar, Amit" To: "libc-alpha@sourceware.org" Subject: FMA4 detection fails. Date: Thu, 2 Jun 2016 09:35:42 +0000 Message-ID: authentication-results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=amd.com; x-ms-office365-filtering-correlation-id: 56aa3664-30b9-4c51-48bc-08d38ac9442f x-microsoft-exchange-diagnostics: 1; SN1PR12MB0734; 5:Wii0G8zkOXOKRDJjc+laCxfSNj7woLzOKCHTv0vG8OEb/wOGzqjo4VT/1lluKY7UOnaI2pMM9NLaVoI8mLguQ6uUhRMFjDq1/xDuFXDPTuzGcVY8OSG/vcqrTZmIDqLWRbRdIrt4eqDyWFf6FDYaZA==; 24:O6gsAt4cqiOFtJJp09UYeZsmVCvem6HmuT0RsmwHB0i78jJsCvS3PiU2o3Nqu2zekTw7sGahsEZLrOJ43aqOeQcUVXXMyNZWfwVCRt/9SCo=; 7:2jxffjSqQBjTLyM/mXVSW/qTdyYVmXfRe01BeoCnM84baDw4ZVjhWZ7ul1LzHes6m3wCrN52NPkT3jFFiE4s+14i09EBFDbIFM7B6fnioDy7l3Y9fMut7Dq0rkS2za6QLJN138iC6lQoDxRf05A9w2hwHDWKOS38A5BKdYDHuG8JpMdBMueBjyoZAPgtjPfV; 20:ozepKvZR9TTzoczDxpUwZ6xfrX0nhjXne3bLWAHEqFuIljMzHVcW0xBBQI+K32FDA/ZPq86/UAFumjL+vk3uFO9j3dpQ7fgmQrG+6+4lhnf3Pmpuy6L7WbPrCuyG5B+ZNv+UO/z2UBr1iQ4NvU3+kWsibdHxnXM9+um1EujFZ6dQqnC4j6z3iHsc13FUIVS4wBVmbnqvo6SXVKqtfwurtdWv/rQhiHwqnexjyEzwtq4xuj4f806bYX0i8zas4VIB x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0734; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:SN1PR12MB0734; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0734; x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(189998001)(92566002)(5008740100001)(3660700001)(15975445007)(66066001)(74316001)(3280700002)(110136002)(77096005)(19580395003)(5640700001)(2900100001)(8936002)(450100001)(2906002)(87936001)(9686002)(5002640100001)(86362001)(11100500001)(2351001)(5003600100002)(54356999)(5004730100002)(586003)(33656002)(102836003)(3846002)(2501003)(122556002)(10400500002)(76576001)(107886002)(6116002)(229853001)(8676002)(99286002)(81166006)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0734; H:SN1PR12MB0733.namprd12.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jun 2016 09:35:42.4193 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0734 After the git commit "f4b6d20366aac66070f1cf50552cf2951991a1e5" FMA4 detection is failing in trunk. This commit was related to Bugzilla id https://sourceware.org/bugzilla/show_bug.cgi?id=19214 and is ok to fix in following way in cpu-features.c file? Thanks, Amit Pawar diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index a5fa81f..384e328 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -87,10 +87,6 @@ get_common_indeces (struct cpu_features *cpu_features, if (CPU_FEATURES_CPU_P (cpu_features, FMA)) cpu_features->feature[index_arch_FMA_Usable] |= bit_arch_FMA_Usable; - /* Determine if FMA4 is usable. */ - if (CPU_FEATURES_CPU_P (cpu_features, FMA4)) - cpu_features->feature[index_arch_FMA4_Usable] - |= bit_arch_FMA4_Usable; } } } @@ -230,6 +226,25 @@ init_cpu_features (struct cpu_features *cpu_features) cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx, cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx); + /* Can we call xgetbv? */ + if (CPU_FEATURES_CPU_P (cpu_features, OSXSAVE)) + { + unsigned int xcrlow; + unsigned int xcrhigh; + + asm ("xgetbv" : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0)); + + /* Is YMM and XMM state usable? */ + if ((xcrlow & (bit_YMM_state | bit_XMM_state)) == + (bit_YMM_state | bit_XMM_state)) + { + /* Determine if FMA4 is usable. */ + if (CPU_FEATURES_CPU_P (cpu_features, FMA4)) + cpu_features->feature[index_arch_FMA4_Usable] + |= bit_arch_FMA4_Usable; + } + } + if (family == 0x15) { #if index_arch_Fast_Unaligned_Load != index_arch_Fast_Copy_Backward