From patchwork Wed Sep 16 12:55:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 40415 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 44226398642E; Wed, 16 Sep 2020 12:55:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44226398642E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1600260949; bh=ZFjY9pN9H7ooRmGNcnfNqJg0LVIFNiZgtZtRwI2GrIs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=vwjSvHxjxeZLgKVoMAxMFfJoS3fu4/Zzmk8gKUbllY/UN2uhykHc/SDS4wE+lwKBr Vs2s1+BpKe/QpsD92NKN4OYARywGY57+bcjYzNbIEpyNAGVSVjSrT66W7D10pT87w6 SRnYfWFLSCWplktVCFRTc4rX2lQ17J5Ltr1JcpAc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by sourceware.org (Postfix) with ESMTPS id 9588F384607B for ; Wed, 16 Sep 2020 12:55:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9588F384607B Received: by mail-pg1-x541.google.com with SMTP id 67so3824306pgd.12 for ; Wed, 16 Sep 2020 05:55:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZFjY9pN9H7ooRmGNcnfNqJg0LVIFNiZgtZtRwI2GrIs=; b=ms7P6h5Zv56+LAZRY6uKhhogaVU4fyzeST+F0UzQ/VodjaxfWN322Cxq/ihVGerk5L oiBg++KVygAC5b6iB8k0c0DTLOdXoUbYHMa1Wyu9X8/1fTarOJ2a93w7+p2ZARl1MQox VO6hk+u2UBuxcgw4DzOTDU0cm5vQjfrrWd2S2D7fo9UvIdC+R7lbIeYeBXlZjliEwYlK njHqXYb4isIaxAbqN+Od+1bi+L8D7yNFkYNfRBG3RFPxReDUDKKAwHgEw3Nn22zclMbw ct9fbSdl1jGjTES0AyrLwRPV6txWNrUEThPjBBGCj8NCDq2mAvwmLLnBkfFpZamskRmr mmgg== X-Gm-Message-State: AOAM530Vs17cxVjNuLeuL9ON/pGW5jVe6VKRDDmxnGtWMceNfWpvOVtc XLFjWntvRBwTrCZXqwUxOOyOlkYFK1Q= X-Google-Smtp-Source: ABdhPJweYFs7Dr2gG8xw4OEv5Mw95O46AOQ//GqNFyjOssYN9ysCKiRYlBdWzHAurnPwvLTljMOoXQ== X-Received: by 2002:a63:30c8:: with SMTP id w191mr17845728pgw.415.1600260945452; Wed, 16 Sep 2020 05:55:45 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id g129sm5431967pfb.9.2020.09.16.05.55.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 05:55:44 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 938D81A00D6 for ; Wed, 16 Sep 2020 05:55:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] x86: Use HAS_CPU_FEATURE with IBT and SHSTK [BZ #26625] Date: Wed, 16 Sep 2020 05:55:42 -0700 Message-Id: <20200916125542.3152966-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" commit 04bba1e5d84b6fd8d3a3b006bc240cd5d241ee30 Author: H.J. Lu Date: Wed Aug 5 13:51:56 2020 -0700 x86: Set CPU usable feature bits conservatively [BZ #26552] Set CPU usable feature bits only for CPU features which are usable in user space and whose usability can be detected from user space, excluding features like FSGSBASE whose enable bit can only be checked in the kernel. no longer turns on the usable bits of IBT and SHSTK since we don't know if IBT and SHSTK are usable much later. Use HAS_CPU_FEATURE to check if the processor supports IBT and SHSTK. --- sysdeps/x86/cpu-features.c | 4 ++-- sysdeps/x86/dl-cet.c | 4 ++-- sysdeps/x86/tst-get-cpu-features.c | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index a9945b94bb..6551df19c0 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -723,9 +723,9 @@ no_cpuid: GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK */ unsigned int cet_feature = 0; - if (!CPU_FEATURE_USABLE (IBT)) + if (!HAS_CPU_FEATURE (IBT)) cet_feature |= GNU_PROPERTY_X86_FEATURE_1_IBT; - if (!CPU_FEATURE_USABLE (SHSTK)) + if (!HAS_CPU_FEATURE (SHSTK)) cet_feature |= GNU_PROPERTY_X86_FEATURE_1_SHSTK; if (cet_feature) diff --git a/sysdeps/x86/dl-cet.c b/sysdeps/x86/dl-cet.c index 03572f7af6..5524b66038 100644 --- a/sysdeps/x86/dl-cet.c +++ b/sysdeps/x86/dl-cet.c @@ -74,10 +74,10 @@ dl_cet_check (struct link_map *m, const char *program) GLIBC_TUNABLES=glibc.cpu.hwcaps=-IBT,-SHSTK */ - enable_ibt &= (CPU_FEATURE_USABLE (IBT) + enable_ibt &= (HAS_CPU_FEATURE (IBT) && (enable_ibt_type == cet_always_on || (m->l_cet & lc_ibt) != 0)); - enable_shstk &= (CPU_FEATURE_USABLE (SHSTK) + enable_shstk &= (HAS_CPU_FEATURE (SHSTK) && (enable_shstk_type == cet_always_on || (m->l_cet & lc_shstk) != 0)); } diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c index a3225a00e6..d11eac9853 100644 --- a/sysdeps/x86/tst-get-cpu-features.c +++ b/sysdeps/x86/tst-get-cpu-features.c @@ -320,7 +320,6 @@ do_test (void) CHECK_CPU_FEATURE_USABLE (OSPKE); CHECK_CPU_FEATURE_USABLE (WAITPKG); CHECK_CPU_FEATURE_USABLE (AVX512_VBMI2); - CHECK_CPU_FEATURE_USABLE (SHSTK); CHECK_CPU_FEATURE_USABLE (GFNI); CHECK_CPU_FEATURE_USABLE (VAES); CHECK_CPU_FEATURE_USABLE (VPCLMULQDQ); @@ -344,7 +343,6 @@ do_test (void) CHECK_CPU_FEATURE_USABLE (HYBRID); CHECK_CPU_FEATURE_USABLE (TSXLDTRK); CHECK_CPU_FEATURE_USABLE (PCONFIG); - CHECK_CPU_FEATURE_USABLE (IBT); CHECK_CPU_FEATURE_USABLE (AMX_BF16); CHECK_CPU_FEATURE_USABLE (AMX_TILE); CHECK_CPU_FEATURE_USABLE (AMX_INT8);