Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp425692pxh; Wed, 10 Nov 2021 04:04:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHJNka3TShDzTWLb44l+q3ULt6tuhFi9kP2K6vymIG9cV2cEwZxLrWSMfvBYQFEEMnKH+7 X-Received: by 2002:a17:906:5d06:: with SMTP id g6mr10996047ejt.3.1636545873299; Wed, 10 Nov 2021 04:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636545873; cv=none; d=google.com; s=arc-20160816; b=wp27dsB+PQuv+uZ3MjFr21eJ5eXMZ7QBeYjFkbt4SqezycqkWHwvVUxt0ioCBlHPK7 t51NFn3HlQCIvV15DFyYW4h0tLDpUiXaByk2QdV5OsZlChl4yP5njlXlWahXN/6JkL7C 8RKDWbhYhh3ZVuQd5PJkjGXgGjpifURq2kvyzqYi9R833QkgQ/RQu+0d3D71QXojpaJi 7ReBlX0q2joey4OmzrEQ52V5RNxNy531btfuHwga+6MF24ASGhVdP0i2Oa2CmDaZVCvS YkA2HbBB6VCDxu80Ot0+UlKvHOOA3efLhnBWncF37elUifkBFaSxG0yNFtMpe4L7UFN9 QsRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0go08qE6YjF720dW2xAnGLMtyjjxpO8kE2iuFpdx1kM=; b=Hr0z3rnTf3uNU+mL2f4ZTriK/W4bCR6agMqhFNH+rg3HKw2v4RMw/Yp4OouMg1jLa+ vJLrtg90EYYniei0MKwHx+kwaRKx/nsWH58K+Zfbl0yUTiBUKdTtsSnWQibWxS0V1JMg 86Gi0dNcufP3aEQqILslh3fgCWrjOXoaklqv5H2NrFoh+7X4wIR353Wu13wZVl+HffNh RiCS4W7jbE3dt9kmvxm6dzqlCeF4TVkeI6k/wpWqMrTKX/XQ9P3dZv8ARu0ZgfHEC0Ap yIwN2efLMb7bq4Jaj4Ss7516oWjjsGNkZ16FBI31/IHB/Kpm3nHNN2sCXoOifWdjCCaz cldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="eiMDc/JD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sh11si36934253ejc.687.2021.11.10.04.04.06; Wed, 10 Nov 2021 04:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="eiMDc/JD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231701AbhKJMBp (ORCPT + 99 others); Wed, 10 Nov 2021 07:01:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231484AbhKJMBl (ORCPT ); Wed, 10 Nov 2021 07:01:41 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A88C061764 for ; Wed, 10 Nov 2021 03:58:54 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so1632921pjc.4 for ; Wed, 10 Nov 2021 03:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0go08qE6YjF720dW2xAnGLMtyjjxpO8kE2iuFpdx1kM=; b=eiMDc/JD59APb5ZVi15YxMqmM4YF31gkArbRUBXMIJSMkcq2etUpsVK2mQ3a2bgFP4 XWU2aggeWjgYTOwxsLHe35xmaoVlRJXiyZX4UWaGJdrRrqehplhAAPuIzryZKo/ZC78T aMxMaMaYt/thkWDrIQOpIKR6C2Kv/IPyLpVWBO+imA0VR3ik7puzugHQ1moVIxv8h0N/ u5NpiufuQWa58KQd4F9nZ+wiNWwVb71ivyM/lRZIQYlki+ARrmAkgmdm35avrk8/SjGW tbqzMpwpBRKxbrLQ2N6l9VHKeBH1MFvPya9ZRfGRwm/8Pg+mQqB+13JpujYtaESwkBQM NN0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0go08qE6YjF720dW2xAnGLMtyjjxpO8kE2iuFpdx1kM=; b=IkNaE4n1+H2/C2ZLpC6isVTfdCnOOc+wG4ucu/yaFyVM5oYYl0j4yFbVMkra1Rt+8W gO1QGj+vyBAZiPlIaZ9cVXVzFEHgAy0bJ/7e2xWBSELu2kxpwFglTZB0vN7s25KViTCn d5Q11KsONs4w31vFCsk1StP8amcXnLNrVH+xCA1Nl6bBDKc97obyX349V06iQ6OSTfTp JqJk/SMEBVs5FKGmSuHGYtCm+EJUVdH+tUrUtxQ7egrkXYNdtEa5TGFHFa+/o2a5By9t zf7G+Ydk+lhaXLlTvXdAlzMV8RjcWQRwAc0WlYrOsTvhO3ERtZ+8k6eJTr2VYLVjnCql cT3w== X-Gm-Message-State: AOAM53134aSZRKAMiyxjBD12DKqCC7YIKKO/mdc63xlOi0vdnsanXf5g eott4VFPWxs05UcKyhJGOIpkQgfK3pY= X-Received: by 2002:a17:902:7404:b0:142:3599:74c5 with SMTP id g4-20020a170902740400b00142359974c5mr14849424pll.67.1636545533632; Wed, 10 Nov 2021 03:58:53 -0800 (PST) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id na15sm6306249pjb.31.2021.11.10.03.58.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Nov 2021 03:58:53 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Lai Jiangshan , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH V5 13/50] x86/entry: Add arch/x86/entry/entry64.c for C entry code Date: Wed, 10 Nov 2021 19:56:59 +0800 Message-Id: <20211110115736.3776-14-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20211110115736.3776-1-jiangshanlai@gmail.com> References: <20211110115736.3776-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lai Jiangshan Add a C file "entry64.c" to deposit C entry code for traps and faults which will be as the same logic as the existing ASM code in entry_64.S. The file is as low level as entry_64.S and its code can be running in the environments that the GS base is user controlled value, or the CR3 is PTI user CR3 or both. All the code in this file should not be instrumentable. Many instrument facilities can be disabled by per-function attributes which are included in __noinstr_section. But stack-protector can not be disabled function- granularly by many versions of GCC that can be supported for compiling the kernel. So stack-protector is disabled for the whole file in Makefile. It is prepared for later patches that implement C version of the entry code in entry64.c. Suggested-by: Joerg Roedel Signed-off-by: Lai Jiangshan --- arch/x86/entry/Makefile | 3 ++- arch/x86/entry/entry64.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 arch/x86/entry/entry64.c diff --git a/arch/x86/entry/Makefile b/arch/x86/entry/Makefile index 7fec5dcf6438..792f7009ff32 100644 --- a/arch/x86/entry/Makefile +++ b/arch/x86/entry/Makefile @@ -10,13 +10,14 @@ KCOV_INSTRUMENT := n CFLAGS_REMOVE_common.o = $(CC_FLAGS_FTRACE) CFLAGS_common.o += -fno-stack-protector +CFLAGS_entry64.o += -fno-stack-protector obj-y := entry_$(BITS).o thunk_$(BITS).o syscall_$(BITS).o obj-y += common.o +obj-$(CONFIG_X86_64) += entry64.o obj-y += vdso/ obj-y += vsyscall/ obj-$(CONFIG_IA32_EMULATION) += entry_64_compat.o syscall_32.o obj-$(CONFIG_X86_X32_ABI) += syscall_x32.o - diff --git a/arch/x86/entry/entry64.c b/arch/x86/entry/entry64.c new file mode 100644 index 000000000000..762595603ce7 --- /dev/null +++ b/arch/x86/entry/entry64.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 1991, 1992 Linus Torvalds + * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs + * Copyright (C) 2000 Pavel Machek + * Copyright (C) 2021 Lai Jiangshan, Alibaba + * + * Handle entries and exits for hardware traps and faults. + * + * It is as low level as entry_64.S and its code can be running in the + * environments that the GS base is user controlled value, or the CR3 + * is PTI user CR3 or both. + */ +#include -- 2.19.1.6.gb485710b