From patchwork Thu Sep 29 22:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgecombe, Rick P" X-Patchwork-Id: 12994687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70B36C433FE for ; Thu, 29 Sep 2022 22:30:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C7678D000C; Thu, 29 Sep 2022 18:30:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0507A8D0007; Thu, 29 Sep 2022 18:30:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD928D000C; Thu, 29 Sep 2022 18:30:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CD7388D0007 for ; Thu, 29 Sep 2022 18:30:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B350380483 for ; Thu, 29 Sep 2022 22:30:57 +0000 (UTC) X-FDA: 79966569354.03.BCED123 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf02.hostedemail.com (Postfix) with ESMTP id 313928000F for ; Thu, 29 Sep 2022 22:30:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664490657; x=1696026657; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=/a1pKHmwhVYyv4Ui3rbvLcahiUY8jR6mb1CYyGIJjno=; b=T6r0lnE9GQf7994PbYdeew4/HdoZEP84EDrPeibT0FDFRjwNKufJu2OV TK+2yYpj2FGyHR28KqleDUYS4lHx2DCGWnD+GOIoyZ5scWwPbmRMAuKOb a7TBemPvNj4YUfScNnol3+r1JuNRrYbXB1JwIMVIOQStxbUE2lLWuVkHP EKqUgksmOgYiXWz8fCNkWWEr1L1dZLM3zBFvmKEhtKhi2L/RA1jQm0NLa TPoUEwr2qsed8S4/X7gkqUX/kuZtk0m67Bd9+3Ujx/dtx6ZNSmj+wQjR3 0JmFg0+x+6g7yucdgFJx29slwMHvAzV4UdOhmMNjdMNN+A4PDUB+y4MUe w==; X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="289207578" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="289207578" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:30:55 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10485"; a="691016364" X-IronPort-AV: E=Sophos;i="5.93,356,1654585200"; d="scan'208";a="691016364" Received: from sergungo-mobl.amr.corp.intel.com (HELO rpedgeco-desk.amr.corp.intel.com) ([10.251.25.88]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2022 15:30:53 -0700 From: Rick Edgecombe 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" , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com Cc: rick.p.edgecombe@intel.com Subject: [PATCH v2 33/39] x86/cpufeatures: Limit shadow stack to Intel CPUs Date: Thu, 29 Sep 2022 15:29:30 -0700 Message-Id: <20220929222936.14584-34-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220929222936.14584-1-rick.p.edgecombe@intel.com> References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=T6r0lnE9; spf=pass (imf02.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664490657; a=rsa-sha256; cv=none; b=ocpZGgKLrckHjmJca0D/E9GAoE+PxHzL9tTQ0I93encB7o8aXIdu4/t32oRBMw8aefqR2G MSQr/QAs1QvFROYDEUQPtA5jFQneZ6Ys8ePzHQxI3aW6KipmOFwOgOny7Bcw5j3vy4RXYL IIVerNf+29aZMd2EwcEtVytxpYESw8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664490657; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=ZvZHPtice4S+QtAh8n4S4qav6Cl3YwQ728ZutqRRbh0=; b=Bk4Ovsm/H7C6CS/mcP4BG5Jq1D1hPuHylnYtpV3V3By+w5MM4NqNVKMGu1zHP3VStlKKgX i639Ixa8rwptI8K5+n3gCWZ10VZTTwarS/znYiJb1e5OMqpFmUgTubcqt0zk/2ON7M0o6G sWKThEKW2HBy/HdO4gjos+2WScIRjJk= Authentication-Results: imf02.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=T6r0lnE9; spf=pass (imf02.hostedemail.com: domain of rick.p.edgecombe@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Stat-Signature: p3wod1tuoy1zoh196xpsf76qeo9nerqz X-Rspamd-Queue-Id: 313928000F X-Rspamd-Server: rspam05 X-HE-Tag: 1664490657-297915 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: Shadow stack is supported on newer AMD processors, but the kernel implementation has not been tested on them. Prevent basic issues from showing up for normal users by disabling shadow stack on all CPUs except Intel until it has been tested. At which point the limitation should be removed. Signed-off-by: Rick Edgecombe --- v1: - New patch. arch/x86/kernel/cpu/common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index d7415bb556b2..f7cacc5698d5 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -606,6 +606,14 @@ static __always_inline void setup_cet(struct cpuinfo_x86 *c) if (!kernel_ibt && !user_shstk) return; + /* + * Shadow stack is supported on AMD processors, but has not been + * tested. Only support it on Intel processors until this is done. + * At which point, this vendor check should be removed. + */ + if (c->x86_vendor != X86_VENDOR_INTEL) + setup_clear_cpu_cap(X86_FEATURE_SHSTK); + if (kernel_ibt) msr = CET_ENDBR_EN;