Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3308818imu; Mon, 19 Nov 2018 13:58:17 -0800 (PST) X-Google-Smtp-Source: AJdET5dMZyCggmkudm0A/vTgIEjnqyhPePVweokq68GIobo/B46w90DWPmNeuwOFeGrIHZD2w0lD X-Received: by 2002:a17:902:a601:: with SMTP id u1mr24105549plq.77.1542664696863; Mon, 19 Nov 2018 13:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542664696; cv=none; d=google.com; s=arc-20160816; b=iSw/f4l3amOsxwkn6WMLgxzYJiF5wCIZ60YnmGbblWwydGonsX8fZLUZ5UwcwSQ9DK D4xJREVzS6peh2+xr1OgZqMeeDNTYHvn3toQNyAYs/AP8wH7VRCWXn/KxncMR6ZiZOJC YJMjaLNOqokZcpBoMd6i78GCCHtR5uEaLDIr8L1DPnIt/eeGh7XcqPqeS2gE7OUYg2Rk VxYW5EfhnymxOujRLMsD0hLGOnH96oxegQn8+AZGN6F90zVPyXpGv22k+NMyfiKghQLN yohcu8pX8Ethkzkt2dKr7vvKuhvky2E2M1sHNJuYRTi8iI/dogbVekoIbz5DfdK2tLD5 FdJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=o/PBQ3CkV7J/3jACeeurg2rtp1WiDpNRBsfd4DxQg+o=; b=0MD3HT/YZHxT2/Sb96IynDZ6IS8xg9b8i6E0bYD6AM5ThuuElLzbshcCvGkDPyMUpC f2S5d4vYFDOpz40xiXkYckGtgS5rDSy01jLRuutuieqsCXLTrlwq5omOUA1u1Yscoq2E QqlUD6MmMaBerfMNtqTOHaQcftRXI90xC5fCwpTiTKdWhtVM/IF9ziIE+wMtC8CorpVc mB+dNwbnjzZnjAjGAEUkj/9v+/8quf0W13ehYELMuAYpq+bZpXHgpAb4IfJwPS02nHr7 wJ4sBWcu3GbBkVokme+89TzZKnWeBln7k/qwyUaojQWI+EQnR9xMDfUkprV2MRaj2Bcy oPkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v184si38399493pgd.295.2018.11.19.13.58.01; Mon, 19 Nov 2018 13:58:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731771AbeKTIUk (ORCPT + 99 others); Tue, 20 Nov 2018 03:20:40 -0500 Received: from mga09.intel.com ([134.134.136.24]:32114 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbeKTIUj (ORCPT ); Tue, 20 Nov 2018 03:20:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 13:54:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,254,1539673200"; d="scan'208";a="92423899" Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by orsmga006.jf.intel.com with ESMTP; 19 Nov 2018 13:54:57 -0800 From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Cc: Yu-cheng Yu Subject: [RFC PATCH v6 05/11] x86/cet/ibt: ELF header parsing for IBT Date: Mon, 19 Nov 2018 13:49:28 -0800 Message-Id: <20181119214934.6174-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181119214934.6174-1-yu-cheng.yu@intel.com> References: <20181119214934.6174-1-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Look in .note.gnu.property of an ELF file and check if Indirect Branch Tracking needs to be enabled for the task. Signed-off-by: H.J. Lu Signed-off-by: Yu-cheng Yu --- arch/x86/include/uapi/asm/elf_property.h | 1 + arch/x86/kernel/elf.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/x86/include/uapi/asm/elf_property.h b/arch/x86/include/uapi/asm/elf_property.h index af361207718c..343a871b8fc1 100644 --- a/arch/x86/include/uapi/asm/elf_property.h +++ b/arch/x86/include/uapi/asm/elf_property.h @@ -11,5 +11,6 @@ * Bits for GNU_PROPERTY_X86_FEATURE_1_AND */ #define GNU_PROPERTY_X86_FEATURE_1_SHSTK (0x00000002) +#define GNU_PROPERTY_X86_FEATURE_1_IBT (0x00000001) #endif /* _UAPI_ASM_X86_ELF_PROPERTY_H */ diff --git a/arch/x86/kernel/elf.c b/arch/x86/kernel/elf.c index 60e396e2abe9..7727b9332097 100644 --- a/arch/x86/kernel/elf.c +++ b/arch/x86/kernel/elf.c @@ -353,6 +353,11 @@ int arch_setup_features(void *ehdr_p, void *phdr_p, } } + if (cpu_feature_enabled(X86_FEATURE_IBT)) { + if (feature & GNU_PROPERTY_X86_FEATURE_1_IBT) + err = cet_setup_ibt(); + } + out: return err; } -- 2.17.1