Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp525108iof; Mon, 6 Jun 2022 07:56:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygeSBxPNEwyH7zODqlmQ0yudT+6bUcW7LdhehmC6RAPahnc0j+pjRvkQu2iee6Ve36boiz X-Received: by 2002:a63:340b:0:b0:3fd:c66:eb40 with SMTP id b11-20020a63340b000000b003fd0c66eb40mr16944038pga.288.1654527378966; Mon, 06 Jun 2022 07:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654527378; cv=none; d=google.com; s=arc-20160816; b=iUBE0Pw+A5XNUq5NhSST4thLWT+rfxFQ3fQBsneuOumeQIv2xZ01wPWmM+KSIH/tqv 1tL8SvDjThxszQ2NUE5qdyymZ3ofVLUCjhL59st1lJ3/QT83IXonKqx7CReQ1FxhQok5 T4886n1i063X/xYhpvrWEfX15hAz6OdEFtQqkgU5O8svVmknfqPGXp+zmatRgxPC+XXL MZcuEqIhCwPwpGxlKlvn/3e4wRKXeDZKroI01IMSmqCaSUFdgx3T15krMkBVjxrlcLOE YxjROQ4IIGV4m0XAWKiwS+zmPhZL+eqF7VO18RdcVCR2s8SS5L2iOM7LglbTMfPf/ULz dQWA== 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=4unt6PUqjlwmajoQtsGt030sfPAmI7QPMB4lAchbRI4=; b=DFpf98x7yyRLMvFqO1h2zHMW3bi/Mm/lgUPUwBvTJRW8r7m9Tg6D+Z58AxVLrckFCx EI9JS2hGqyajBbEkVvxYFmYlc27QWIADvsUaD2GzlwWCXgd008Kih2hzpv6FvVmHFPCv j9FGOkbG90dPa4/0xjCqqaPjLMypgua0nQ434igjh61vTN+OKXL1GtSs0Od9Y2+UNByN aVV3u0X4fTgqVULkIaMbd/frZaGms2FvEvwZBvs/fe9qyEFE+Vy6jD1EaUDlXEYu/fG0 DzHNdslduvrgcyboa/cst8uPFYJm8ijKbz00/tmQNv0tsquBt32YKFq4mCoY5721fGRw vdiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NTfisVuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z8-20020a656648000000b003fde8b80069si1423911pgv.372.2022.06.06.07.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 07:56:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NTfisVuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5964D28E1B; Mon, 6 Jun 2022 07:45:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239888AbiFFOos (ORCPT + 99 others); Mon, 6 Jun 2022 10:44:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239973AbiFFOop (ORCPT ); Mon, 6 Jun 2022 10:44:45 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E646750455 for ; Mon, 6 Jun 2022 07:44:43 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id a10so12983162pju.3 for ; Mon, 06 Jun 2022 07:44:43 -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=4unt6PUqjlwmajoQtsGt030sfPAmI7QPMB4lAchbRI4=; b=NTfisVuYf6vYip3A6oX/MtlyiOevTjc09L/PPyG1XEp9uKlhU2KdJP3HX7Z9A7j2kU Axic04KC7h61W3hKt9ubEiMliDseLMGQX9su3bO3oO12PbhU8u9n/KQxY5TMDEMJfPPV pZskzj9G1d75GXBTlQx/2LKlBRUs9ycTX3pDERNcrz3zs3kFwWM3vKqEb0eRfnPKcjZb CxcVrKkRXdZ9OSesmTiJtMM41eA6wZ7wRRUnpqqR55FCd9K8IOhBjG+yM8dOQTgTj6rn 7DN/bPNAmSc2oanW8TKkOKur5wQXG2M+CgUZJCSI8wdZcRyETB3GWLlqSDINvwfitYu2 NK7A== 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=4unt6PUqjlwmajoQtsGt030sfPAmI7QPMB4lAchbRI4=; b=T0sWWtNIpb7k+QerVSYrV6FpZGAQxz4ONNISKYUKWQ2d5VTQQPtDf7Bj0+PW4TspPi ocMqSmOadf1gRHChDXIoEmFxN/YEvGpxfCVHhnNIfnOjsYPHrIFIdhkokfdzdDudQPa4 I+kMkgwwv/BbrUkjlaSwazw0eJuVaSyLQcyhoUphwelnH23aq3yKR9hB0vTXsgoTw7KO JxVp1RuoJxbf7DrHTCkbTwpA6bC8WMTWvLRxF7UWSPcglHr63p4Yd5Lj0OIBkJNdGici kwbMXN0tDt97MRJqpiXUUsC5zeJmHiZTdJfIXdw3Ny2+pxEuruIE4XQ2D8HmjSOH4nYS 1OAw== X-Gm-Message-State: AOAM533putVJAb+3im4EO7O5LlSynTFVxDMwYfgO+Xqe1NMQAZda5YDz 5sUjhuaVVs8x0Tn9Oei7wG+HTgHupMI= X-Received: by 2002:a17:90a:6747:b0:1e6:6a5b:f040 with SMTP id c7-20020a17090a674700b001e66a5bf040mr29353109pjm.134.1654526683263; Mon, 06 Jun 2022 07:44:43 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id g196-20020a6252cd000000b0051b9e224623sm11394200pfb.141.2022.06.06.07.44.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2022 07:44:42 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Thomas Gleixner , x86@kernel.org, Lai Jiangshan , Ingo Molnar , Dave Hansen , "H. Peter Anvin" Subject: [PATCH V3 4/7] x86/entry: Add arch/x86/entry/entry64.c for C entry code Date: Mon, 6 Jun 2022 22:45:06 +0800 Message-Id: <20220606144509.617611-5-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220606144509.617611-1-jiangshanlai@gmail.com> References: <20220606144509.617611-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 a user controlled value, or the CR3 is the KPTI 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 the macro __noinstr_section. But stack-protector can not be disabled function-granularly by some compliers. So stack-protector is disabled for the whole file in Makefile. 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..ace73861c2a0 --- /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) 2022 Lai Jiangshan, Ant Group + * + * 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 a user controlled value, or the CR3 + * is the PTI user CR3 or both. + */ +#include -- 2.19.1.6.gb485710b