From patchwork Thu Oct 11 15:16:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10636917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D37AA17E1 for ; Thu, 11 Oct 2018 15:23:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C249C2BA4D for ; Thu, 11 Oct 2018 15:23:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B37152BA59; Thu, 11 Oct 2018 15:23:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 386332BA52 for ; Thu, 11 Oct 2018 15:23:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9769E6B02A5; Thu, 11 Oct 2018 11:22:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8BBCC6B02AA; Thu, 11 Oct 2018 11:22:09 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C4096B02A5; Thu, 11 Oct 2018 11:22:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 07CFD6B02A3 for ; Thu, 11 Oct 2018 11:22:09 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id e24-v6so6242797pga.16 for ; Thu, 11 Oct 2018 08:22:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=StORTPBNA6TeZo6VcPugQPhXp09bTuFa2SHwm2IbcY8=; b=PN07HI63KY5654KsRwyDWia+tt0KtJJBodlvogLYqOgUMAIHm0YUWy30RVCiY5GQRC z/sSz3tMnMPhnaaX3QFlWDGiV7c6LlJHTOH3wORUuvhErozRIsm/IwrwmfHragDtA6uU TXvk3U9xwprk79FXcRy9eB/+PjIgkUS6cyBni0RZ2Q+nbFT5F3sG3qzU8klmvRI559Pz KFKu7epAzy88dh4HD66gejgkz1suHYiagziUrb9WYi4P6qvWLPrnDFxtAt+X696OLQmi +DSVOTrqHJiY9TWA39q7hW3jeuIk9htK+GXKxk7z5A2k+sFgXzi3KMMbHZBFNC8cLTm8 FY0w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ABuFfog9GBQl/DdE5E/Q7X5Bj2YqrIWptQ4KMUjg5gawFShFk5gdyUB9 yUiwEzcrW4/WJSMRuv0T5SY/6gYeEq1QVj0IywxKdn8aEiFpl9CttPscmzCRj/gkW4pyV2ywjqB OQlGPq3uKfaV5nW7QeG7XDi3mkhabagk/U0CYSoCo26qD3Kaun/AXUp+IuYRUwArQVg== X-Received: by 2002:a17:902:223:: with SMTP id 32-v6mr2021917plc.112.1539271328726; Thu, 11 Oct 2018 08:22:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62x69LEi4r8xAJz6k1NKuwdeLaBPxbSTL4iAH8HB00W0QNVxo9EFR55n9kyh/4/d1rdxbst X-Received: by 2002:a17:902:223:: with SMTP id 32-v6mr2021884plc.112.1539271328110; Thu, 11 Oct 2018 08:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271328; cv=none; d=google.com; s=arc-20160816; b=d4bs3MsccavwvxvSk0rx0yGRH0AauCrN1tbheAXLU5GSGwV0h6esxcJSgSdpT33qgQ wTtLvR35SnfFEBFm2Nac8LgPFBFg7WYkkVwOdd+QcFJbAmQWprBQiSgQTSAf60DwiRjI HgAi1lkQlfDvhNYENvfJO6dwipueC98opbU/1oBK7ZBHDHGleRRVdAxETQcrWumNbJiY kNiYy9HYnYC3GOGX5wXp0LVRmUYgLidR5V6+J6cvG1t69qlEZgFRR4joUmWASmRb5DQN CIHfUb0Ze/9thzLT7Y+VKCjhXjojS6gMM0VW/as9J0pkif/RLUSW8A0WAEwKESROBC0A I4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=StORTPBNA6TeZo6VcPugQPhXp09bTuFa2SHwm2IbcY8=; b=VbhmA3F9aXMTyE8kbMDMPWvuk3KnmI1rAzoUJpgynF0G2r+2sSs9sQtjecb2f79R92 BDOlR45HTDsgIWYauMieuCXs3B4hSNk1Cn/EGiuLvJiE8CGQaHXjLowYzd8o8KG6nW4S J4wYTFOL+Lbnp27WPCfES/COEv/Ix2veIjlt/mWi1pI844Dej+aIUoA1vV6DhPVSa3jM S+gKglItgT8cePYj6x266uj9/OM4fZt8/fp37wUOcbV00RNA0uBxnfrXcz72xdpYr3O9 YKJblrJTo4PLaq2bpSXAaZj7dqFX1R3BQa+qUnHXlH2ZYop1MmAk1x5m91vqakBW+MJV FbFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id 33-v6si28541073plh.50.2018.10.11.08.22.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="77271630" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga007.fm.intel.com with ESMTP; 11 Oct 2018 08:21:44 -0700 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: [PATCH v5 05/11] x86/cet/ibt: ELF header parsing for IBT Date: Thu, 11 Oct 2018 08:16:48 -0700 Message-Id: <20181011151654.27221-6-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151654.27221-1-yu-cheng.yu@intel.com> References: <20181011151654.27221-1-yu-cheng.yu@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 2e2030a0462b..177b5144fdf4 100644 --- a/arch/x86/kernel/elf.c +++ b/arch/x86/kernel/elf.c @@ -336,6 +336,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; }