Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4094506pxb; Wed, 13 Oct 2021 20:52:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwI2MEy/MObm2tBT/QOAy0G2XSnmQ/fps1G+7D/VgURfBfyAgZCdnLyhlKiXnhlq5FkQf2 X-Received: by 2002:a62:641:0:b0:44b:74bb:294c with SMTP id 62-20020a620641000000b0044b74bb294cmr3045841pfg.12.1634183562199; Wed, 13 Oct 2021 20:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634183562; cv=none; d=google.com; s=arc-20160816; b=XyU6S/p8hCHVH60NThEKNi4hdXnci/HosuEiY7amLbu/ZajqenvdrKhnk2t3Cw9z/H yQPDb9CTSOPRXs2l1Amb/EG3SL1yi0PF0bjZcDqljyl34AsKIm/HxZVqEIKo2tR4m7GP sMQxjDoedZJvMAPF5KlzH5wIU6lri1hZx4wtdDM//gEMXr9fqywayr12hqs+D1gP6MUl wedmGqdhlGv4ZyZv7PTDlgAEMRppsYFrL9yfC5Tn7DmjUnUxHmPFd1Jef7JJD9q29WCY N8wMjBhgSZUaKEIta6i7QsbRQ8DhLgyiw0Woxk9ZxMJ3qHLKdRvbXRc9qmPcMd1Dy0Ue 272w== 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=hg5X/fXuO5IzWpbw25ZvrVT5KoY60jnAFeBGvtwJeGk=; b=VfJj4aL48q+ijcjibHdUkbrYpK/tUjy8ueL3bzncZdkOXN7UA3aDDv3TSTQlLo3FcS fIqQxYBA7mTe1yBZj71qmi6zyDdqtW2+F89zHh7sOeRZneSEgkBTUI3p/nGv2ZaGct4q m0dUgev5pWaddaK/n0G4BbRPM5bSXH0vktxtLPTwMuQmxrvhAb4As1OidniyBj2HhH4U RUp/HzOAbIQZF9gHu9UVLSHiH1Ob/j7otoR4rRl0O1ZDzLsECRQNDQ8zYl87uv34DWmQ RyCHoX/82WzwvG8QSXY9n6rHi9888nWM8oCgjtmaTgOd7X5A46h7uC2HYw9T30Q1/mg+ kPyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jr9WfnZb; 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 5si1945807pga.607.2021.10.13.20.52.29; Wed, 13 Oct 2021 20:52:42 -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=Jr9WfnZb; 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 S230201AbhJNDxR (ORCPT + 99 others); Wed, 13 Oct 2021 23:53:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbhJNDxO (ORCPT ); Wed, 13 Oct 2021 23:53:14 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49E90C061570 for ; Wed, 13 Oct 2021 20:51:10 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id i76so2153877pfe.13 for ; Wed, 13 Oct 2021 20:51:10 -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=hg5X/fXuO5IzWpbw25ZvrVT5KoY60jnAFeBGvtwJeGk=; b=Jr9WfnZbxH44R0hNtS5cd0SxIF5JOr1aQ8XQx11V6sXTPF9vhbzXVIEQ5otk9DzJGU r7Uf1C/yadLrdBF0OjFbG5+rVnH3H9Lnxscc9vRd+bS7LHxPlA8FPuaYnNBpf6pea9rX n1O7X6S3N/qWSV6EyJK81RSaL4ihmqpOXWT9YREpxek+oq00SGLxgmvR/at6yGNXWSRW js2ayko5hCZavztQFH5zhXLHrJZEvwQ70/VXVzZHSv+N87ka6js4zCsytH3Y5zxHXJYl /TMRdVpOHz0WsIt0jyMZhjwq4sFAf5c7hzmz3v0KPCy4u2DJeAUESymgO05NXZdj8b7g xtfQ== 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=hg5X/fXuO5IzWpbw25ZvrVT5KoY60jnAFeBGvtwJeGk=; b=5Hkvrhl3tlnR2FH03UCeb3WYl2JpL9zFyVwyVr5MDlYVzR/nvN8wMOCYF70is8fllZ 0Uawl6DWLKgCj6e6P/mHDmw9Wic8KVQVNPHs+5sWKNyaMt3UOTvTVLUp3gMgbYP6GTNt 3MQHWMlJ+lifB0N7pJyuwZeh7e2e/5V+LivHpILacmL48x34vol1fYezQw5fkHW7r4Va fZDsdeD3QYj47bKhXsLP+pt5b6Xn0V0dKylC91NkII+FOjUjtWginB+Mp+bmbLx0tdEP EO1E9EJ4DVbia5EpE0YDLxOPdAz86DON/oTiOsjem1uh6bKnsi0uIkTGX0BdJTZx+9+h 2RMg== X-Gm-Message-State: AOAM533ZWJ/snceJHqjc79nLELZqnO4MMuq2xNXhd0OyaDmEuNV53kQe n5ofzsQhmLhpbdWeSe1ig1e81CltiYk= X-Received: by 2002:a62:1c52:0:b0:44c:f1c3:9cb5 with SMTP id c79-20020a621c52000000b0044cf1c39cb5mr3325783pfc.14.1634183469722; Wed, 13 Oct 2021 20:51:09 -0700 (PDT) Received: from localhost ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id k1sm864037pjj.54.2021.10.13.20.51.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Oct 2021 20:51:09 -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 , "H. Peter Anvin" , Juergen Gross , "Peter Zijlstra (Intel)" , Joerg Roedel , Javier Martinez Canillas , Daniel Bristot de Oliveira , Brijesh Singh , Andy Shevchenko , Tom Lendacky , Arvind Sankar , Chester Lin Subject: [PATCH V3 41/49] x86/nmi: Use C entry code Date: Thu, 14 Oct 2021 11:50:18 +0800 Message-Id: <20211014035027.17681-6-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20211014031413.14471-1-jiangshanlai@gmail.com> References: <20211014031413.14471-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 Use DEFINE_IDTENTRY_IST_ETNRY to emit C entry function and use the function directly in entry_64.S. Signed-off-by: Lai Jiangshan --- arch/x86/entry/entry_64.S | 17 ++--------------- arch/x86/include/asm/idtentry.h | 5 ++++- arch/x86/kernel/Makefile | 1 + 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 7c994bcde1b0..0a1a55c8207e 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1309,21 +1309,8 @@ end_repeat_nmi: PUSH_AND_CLEAR_REGS ENCODE_FRAME_POINTER - /* - * Use paranoid_entry to handle SWAPGS and CR3. - */ - call paranoid_entry - UNWIND_HINT_REGS - - movq %rsp, %rdi - movq $-1, %rsi - call exc_nmi - - /* - * Use paranoid_exit to handle SWAPGS and CR3, but no need to use - * restore_regs_and_return_to_kernel as we must handle nested NMI. - */ - call paranoid_exit + movq %rsp, %rdi /* pt_regs pointer */ + call ist_exc_nmi POP_REGS diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index b9a6750dbba2..57636844b0fd 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -372,6 +372,8 @@ __visible __entry_text void ist_##func(struct pt_regs *regs) \ #define DEFINE_IDTENTRY_NOIST(func) \ DEFINE_IDTENTRY_RAW(noist_##func) +#define DEFINE_IDTENTRY_NMI DEFINE_IDTENTRY_IST + #define DECLARE_IDTENTRY_MCE DECLARE_IDTENTRY_IST #define DEFINE_IDTENTRY_MCE DEFINE_IDTENTRY_IST #define DEFINE_IDTENTRY_MCE_USER DEFINE_IDTENTRY_NOIST @@ -421,6 +423,8 @@ __visible __entry_text void ist_##func(struct pt_regs *regs) \ #else /* CONFIG_X86_64 */ +#define DEFINE_IDTENTRY_NMI DEFINE_IDTENTRY_RAW + /** * DECLARE_IDTENTRY_DF - Declare functions for double fault 32bit variant * @vector: Vector number (ignored for C) @@ -452,7 +456,6 @@ __visible noinstr void func(struct pt_regs *regs, \ /* C-Code mapping */ #define DECLARE_IDTENTRY_NMI DECLARE_IDTENTRY_RAW -#define DEFINE_IDTENTRY_NMI DEFINE_IDTENTRY_RAW #else /* !__ASSEMBLY__ */ diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 8ac45801ba8b..28815c2e6cb2 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -51,6 +51,7 @@ KCOV_INSTRUMENT := n CFLAGS_head$(BITS).o += -fno-stack-protector CFLAGS_cc_platform.o += -fno-stack-protector CFLAGS_traps.o += -fno-stack-protector +CFLAGS_nmi.o += -fno-stack-protector CFLAGS_irq.o := -I $(srctree)/$(src)/../include/asm/trace -- 2.19.1.6.gb485710b