From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B5B8C433DF for ; Thu, 21 May 2020 21:17:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03C14207F9 for ; Thu, 21 May 2020 21:17:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03C14207F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9B7D280009; Thu, 21 May 2020 17:17:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 941DB80007; Thu, 21 May 2020 17:17:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8308B80009; Thu, 21 May 2020 17:17:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 6A74380007 for ; Thu, 21 May 2020 17:17:41 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 124124DC9 for ; Thu, 21 May 2020 21:17:41 +0000 (UTC) X-FDA: 76841987922.13.brick00_7d1110eee082a X-HE-Tag: brick00_7d1110eee082a X-Filterd-Recvd-Size: 4408 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 May 2020 21:17:39 +0000 (UTC) IronPort-SDR: Jh6JtZCRnJevrEV4oSxUQ+sR9yrexk1HQ7vTUp/0Sp4pPhNLOx0s8BqN0IwFdy6+hIj9zz8D75 Wa99HaTYE4Og== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2020 14:17:37 -0700 IronPort-SDR: m6oSK0QqnCy8iuARIOKXpyNhnlkfm9AYnpNWX/bVcxPdVBY1OOEMK9syEBvp+wyfHPU07sLfOU H5RCbW6fk+1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,419,1583222400"; d="scan'208";a="440623118" Received: from yyu32-desk.sc.intel.com ([143.183.136.146]) by orsmga005.jf.intel.com with ESMTP; 21 May 2020 14:17:36 -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 , Borislav Petkov , 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 , Dave Martin , Weijiang Yang Cc: Yu-cheng Yu Subject: [RFC PATCH 0/5] Update selftests/x86 for CET Date: Thu, 21 May 2020 14:17:15 -0700 Message-Id: <20200521211720.20236-1-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: When CET is enabled for selftests/x86, two tests need updates. - The test 'sigreturn_64' does a sigreturn() from a 64-bit context into a 32-bit context. The task's 64-bit shadow stack pointer certainly triggers a fault. Fix it by allocating and switching to a new shadow stack in the 32-bit address range. The arch_ptrcl(ARCH_X86_CET_ALLOC_SHSTK) is updated for taking a bit fr= om the input parameter to indicate the desire of MAP_32BIT. I am proposin= g this change to minimize API changes, but open to any alternatives. - The test 'sysret_rip' fails because the assembly code needs ENDBR opcodes. Fix it by adding just that. My latest CET submission (v10) does not include the IBT patches. My purpose of posting this now is to show the changes needed in x86 tests. Since ENDBR is nop when IBT is n= ot enabled, this patch can be applied now or split out and merged with the IBT patches. - The makefile changes add "-fcf-protection -mshstk" to the gcc command, when those are available. - Introduce cet_quick_test that checks the system's CET capabilities. This series is based on my CET series: https://lore.kernel.org/lkml/20200429220732.31602-2-yu-cheng.yu@intel.com= / Yu-cheng Yu (5): x86/cet/shstk: Modify ARCH_X86_CET_ALLOC_SHSTK for 32-bit address range selftest/x86: Enable CET for selftests/x86 selftest/x86: Fix sigreturn_64 test. selftest/x86: Fix sysret_rip with ENDBR selftest/x86: Add CET quick test arch/x86/include/asm/cet.h | 2 +- arch/x86/include/uapi/asm/prctl.h | 2 + arch/x86/kernel/cet.c | 19 ++- arch/x86/kernel/cet_prctl.c | 6 +- tools/testing/selftests/x86/Makefile | 7 +- tools/testing/selftests/x86/cet_quick_test.c | 128 +++++++++++++++++++ tools/testing/selftests/x86/sigreturn.c | 28 ++++ tools/testing/selftests/x86/sysret_rip.c | 5 +- 8 files changed, 185 insertions(+), 12 deletions(-) create mode 100644 tools/testing/selftests/x86/cet_quick_test.c --=20 2.21.0