Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1558794pxb; Tue, 26 Oct 2021 11:13:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZIEWClUx3Z3uVLAEE1cjdMJztSy0BDLYmfLt0prtXCXrzfSwqbFFYyS6Wtshu3j8/F9ry X-Received: by 2002:a17:90b:3b85:: with SMTP id pc5mr357087pjb.74.1635272017250; Tue, 26 Oct 2021 11:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635272017; cv=none; d=google.com; s=arc-20160816; b=jIjETpW3AkQrZp9UlabuLGjfi0DtAgpYT7wl1OD63pWvCXCp1VpDlGzVnqLY9w0Wdy PsM+XQC3L/MhPhu05tisF6GPbkUmnO14JYA2UgtaweyZWLmhkkMgXlQ7oyeENkxffGbj 2NoqIgA8trBEi9OhpA2d3Mp+Zlg17P28xNR7dmgPW0ss9uScT/DuEzETkF1RqTv/35tj bemRMu1ARDBb1EUcz56YOcLZYXrcRgG/bAJA7d3ta0E4PUiScwOf9rainhtWuc+ZuS0E 2i4c41wXmEgOjw+HQMSMMSPhNoNewxGjDrD1jKwEVDNUPcPc/ewoVKjilmBTJiMnlPGX Xz/w== 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=vCa+spC0KQtSHgukCjNrrEMucNU48jb75xiLTYQDh+ozTTaHnFR7SpcBg91Hgn/m0K t4Q1LRii9cEwpQpHDzWz9QPF7l4x74CHK+Ygs2ZxH8LX4a8Zk8FlZi4AXsGIJpVp9DkN LGwdL6lT8kcz33PHd0qFCwE5re7XUHLSePX8VUc0BGVbtvQJwv0NkKzwMe+20tz48JQQ b/qKHFpdp++fis7LbFQTI4SOkXzEtlHE5Mj1Vro73rx9t4+RXCL1aSkppXaFT7zytfWw LOJQgou2aNJdOQmY4EiC3z1e4CrZOMxJDeOVTJEKoe1rRH6iQtydNL48rY9ncJBF2+c7 iUkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XoBtR3vI; 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 d27si1781881pgd.517.2021.10.26.11.13.21; Tue, 26 Oct 2021 11:13:37 -0700 (PDT) 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=XoBtR3vI; 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 S236585AbhJZObE (ORCPT + 99 others); Tue, 26 Oct 2021 10:31:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236560AbhJZOa5 (ORCPT ); Tue, 26 Oct 2021 10:30:57 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B4AC061767 for ; Tue, 26 Oct 2021 07:28:33 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so1834026pjb.3 for ; Tue, 26 Oct 2021 07:28:33 -0700 (PDT) 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=XoBtR3vIQXaOLJhHcBP0PxdJposDjjjTVcj5gJMP2n1vuF8fJCjnQfjaNpUh2Tg4xm etwbT7AvlsrW9b16G6yc7ZHDnH9E7qUrsoRsdvv0aSI2Tol8M0LFTx4wsnj8cbYouGMk vmMd0Fdorkwug9N1s9Cz+d1iV2hehsd88hV0+gWL3RH++nEY5zvrQ0WP80zXCrVOJp93 3ZJWJbFuIJwY4BfUHbHJILcluhQOZeNCK9W/k4sOWdX+6ZYHj1grZjPu13mmSsbAEM/G ZDC5dgEKpIgO+i5FdK0ifWGFwdsEYaJ+Yy+n9fIIN/UmaTNqC62RR/w2l1DA/leR9M9J Evlw== 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=EkF1UUc7PFddsRXA8JW+wSV/jMcaAC0pf9Z9e+zAQHv0Voe9I7HK8hdHG9oJd9pRxZ kDrUfqwULOe09a0rMpspYwOja+8alQ32O6JKtarlzBqP4TpTjZh2KsPQsVkLO++8hhIh QMb9xsM4oYzvTsZJ4hnks1zsYH/a6UKiUO21sH8QxZEdb6t5Qm/JzbswT60jX3O/YVzV Wg6+H5zGX7uZsJROl27XDjQ7zvZW74qYYwH8cQSOILk0GcHX+fuzUSGLsqkIKAAVYopB ceL8bQu64HB86DO9lBRoFAtDjb8EVIahy0TVWtIBMyHkwkiVrV+ME/BpCkDAwRWdbH15 rCMw== X-Gm-Message-State: AOAM530576de+JTy9TihiL/0UItYmt81T32B4tB0MlfXXWOt1UNbu5te 56QvVuGCJECXWkUFVs0w95125Oks3Uc= X-Received: by 2002:a17:90b:1811:: with SMTP id lw17mr10923845pjb.22.1635258513083; Tue, 26 Oct 2021 07:28:33 -0700 (PDT) Received: from localhost ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id b2sm7760766pgh.33.2021.10.26.07.28.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Oct 2021 07:28:32 -0700 (PDT) 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 V4 13/50] x86/entry: Add arch/x86/entry/entry64.c for C entry code Date: Tue, 26 Oct 2021 22:27:45 +0800 Message-Id: <20211026142824.18362-3-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20211026141420.17138-1-jiangshanlai@gmail.com> References: <20211026141420.17138-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