From patchwork Sat Jun 25 18:14:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 640565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rcNfq4Q8Qz9sDC for ; Sun, 26 Jun 2016 04:15:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ZIp3JGsg; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ZTMxjcMUnfzU RbKWetlkeikxczQZWmx7ZuiKeINiYYQb3jZU5mu3CXY9EWb0ReQE6oqUrnGdhU/M D6xwUbzaIiLxeorGUuvm2sfg7iKTA8fslGrH+Z89uM0oyL7lDqB0IzWXxEzLebMP Ld0rv6cYOQf8JQrbnFYGTxutQj36XO8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=8U02Esee8PLRYU/LJN 1iUl1JT/Q=; b=ZIp3JGsgOaUFeJ98EkkoSdLt5IOBCg8UYX4hy4EL46D7z5DGPm KJ/rGFBrlAf/wV5FHT6HBpI+psH1AFFy2dqGT7h3zAuaU0yYu11r6whpLvm6UcUP kRhFXTBw9cHjS67tA2XWqdqc/LKndS/TzZ8F2pSiXRAWzvJVjDWQ7fVec= Received: (qmail 129786 invoked by alias); 25 Jun 2016 18:15:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 129772 invoked by uid 89); 25 Jun 2016 18:15:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=1616, 16, 16 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 25 Jun 2016 18:15:28 +0000 Received: from firstfloor.org (174-25-125-60.ptld.qwest.net [174.25.125.60]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 5861E3F4D0; Sat, 25 Jun 2016 20:15:23 +0200 (CEST) Received: by firstfloor.org (Postfix, from userid 1000) id 0813DA523D; Sat, 25 Jun 2016 11:15:00 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, ilya.enkovich@intel.com, Andi Kleen Subject: [PATCH] Fix MPX tests on systems with MPX disabled Date: Sat, 25 Jun 2016 11:14:50 -0700 Message-Id: <20160625181450.19462-1-andi@firstfloor.org> From: Andi Kleen I have a Skylake system with MPX in the CPU, but MPX is disabled in the kernel configuration. This makes all the MPX tests fail because they assume if MPX is in CPUID it works Check the output of XGETBV too to detect non MPX kernels. gcc/testsuite/: 2016-06-25 Andi Kleen * gcc.target/i386/mpx/mpx-check.h: Check XGETBV output if kernel supports MPX. --- gcc/testsuite/gcc.target/i386/mpx/mpx-check.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h index 3afa460..73aa01f 100644 --- a/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h +++ b/gcc/testsuite/gcc.target/i386/mpx/mpx-check.h @@ -16,6 +16,16 @@ mpx_test (int, const char **); #define DEBUG +#define XSTATE_BNDREGS (1 << 3) + +/* This should be an intrinsic, but isn't. */ +static int xgetbv (unsigned x) +{ + unsigned eax, edx; + asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (x)); + return eax; +} + int main (int argc, const char **argv) { @@ -27,7 +37,7 @@ main (int argc, const char **argv) __cpuid_count (7, 0, eax, ebx, ecx, edx); /* Run MPX test only if host has MPX support. */ - if (ebx & bit_MPX) + if ((ebx & bit_MPX) && (xgetbv (0) & XSTATE_BNDREGS)) mpx_test (argc, argv); else {