From patchwork Mon Apr 26 23:09:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12225657 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DF60C433B4 for ; Tue, 27 Apr 2021 08:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D57D6127A for ; Tue, 27 Apr 2021 08:55:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235153AbhD0Izl (ORCPT ); Tue, 27 Apr 2021 04:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhD0Izl (ORCPT ); Tue, 27 Apr 2021 04:55:41 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C7FC061574; Tue, 27 Apr 2021 01:54:57 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id y22-20020a17090a8b16b0290150ae1a6d2bso6867274pjn.0; Tue, 27 Apr 2021 01:54:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DvudTC2BwHZGDoQJqasDl9cPJYuqaFYI5WCZvH5B/Zw=; b=oZTdWHWa9y4vR0NRkwGHue6dwcl2JqZgsg7a6+YjFGuPfYA01jgtr5CG2FVV6JxsZ9 mypKHQE3nwLiAe0xgegucJmA7TC2ZoXS596vwbQv8YCiSKBLOMOYJ8Im+ZlEXh+zSJ9g CHv2PTnEtz7IYhTMf68AtMxtuO4rUylhz0qM2NHyetmNgDmoXfdZvPmgKbnLQf4ilqyT H0MgsAj/qVMZiQ9HbXjDKU6nbYGbANvN+DVIMT23z4vlS7QnD53TDBNLTwkBxXpsNpZE +KC9qHwy4uf+fbZxJj96Zrs7SPVrj/7U1zxWyVqqlCxxH8NWiTS4Q0V+XrcwxNqP1099 RhDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DvudTC2BwHZGDoQJqasDl9cPJYuqaFYI5WCZvH5B/Zw=; b=l+AcO67iwz1+aDetsF0X1LWUlEzl7W/6z8cQ2+ucyYngw6Op/xqmQda+mMkXgJ8HSx PJ5MO7xRlY+NOTY3Li9Fs9SpS1H0kMhGB2eCD3raD/t4xG7SJNlyVfb+EIAxSwx0X3Yg iZKawFk/UCXv2G98pNbAvyYsidGACWEK6BuIvtylmyaG6Ofv4jJDG46eGqQeuNYsVwTA B5qzsPX8rJI5sg1tJWqSF6fsxzOHSrY/E7C9z111YYEv4OUYAw2N2Vq0SXs7fTrr8V7Q /XsxMTeDJZ2wGppmA4aYcYBK890sZINHr9iSkY07N2fRrq44bVrLXzpGKxsqnkquOx0f pv+Q== X-Gm-Message-State: AOAM530Z1kHSkAWMbzzsoqNw2huTue0LTGlRFwyUEn1dt0uXitPp2PV9 909QyrgQfL5eGrVTZkPAhiQ8uINmmZM= X-Google-Smtp-Source: ABdhPJyED8YOs73pY8DPavmzXj80ySfIXNvSlWASjVV8n8Ia2PPeO5IlLOQb7WEVRwY9uJ/wGmcSPA== X-Received: by 2002:a17:90b:2393:: with SMTP id mr19mr3656655pjb.24.1619513697046; Tue, 27 Apr 2021 01:54:57 -0700 (PDT) Received: from localhost ([47.251.4.198]) by smtp.gmail.com with ESMTPSA id a65sm1986221pfb.116.2021.04.27.01.54.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Apr 2021 01:54:56 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Thomas Gleixner , Paolo Bonzini , Sean Christopherson , Steven Rostedt , Andi Kleen , Andy Lutomirski , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Josh Poimboeuf , Uros Bizjak , Maxim Levitsky , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Peter Zijlstra , Alexandre Chartre , Joerg Roedel , Jian Cai , xen-devel@lists.xenproject.org Subject: [PATCH 1/4] x86/xen/entry: Rename xenpv_exc_nmi to noist_exc_nmi Date: Tue, 27 Apr 2021 07:09:46 +0800 Message-Id: <20210426230949.3561-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20210426230949.3561-1-jiangshanlai@gmail.com> References: <20210426230949.3561-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan There is no any functionality change intended. Just rename it and move it to arch/x86/kernel/nmi.c so that we can resue it later in next patch for early NMI and kvm. Cc: Thomas Gleixner Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Steven Rostedt Cc: Andi Kleen Cc: Andy Lutomirski Cc: Vitaly Kuznetsov Cc: Wanpeng Li Cc: Jim Mattson Cc: Joerg Roedel Cc: kvm@vger.kernel.org Cc: Josh Poimboeuf Cc: Uros Bizjak Cc: Maxim Levitsky Signed-off-by: Lai Jiangshan Acked-by: Juergen Gross --- arch/x86/include/asm/idtentry.h | 2 +- arch/x86/kernel/nmi.c | 8 ++++++++ arch/x86/xen/enlighten_pv.c | 9 +++------ arch/x86/xen/xen-asm.S | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index e35e342673c7..5b11d2ddbb5c 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -590,7 +590,7 @@ DECLARE_IDTENTRY_RAW(X86_TRAP_MC, xenpv_exc_machine_check); /* NMI */ DECLARE_IDTENTRY_NMI(X86_TRAP_NMI, exc_nmi); #ifdef CONFIG_XEN_PV -DECLARE_IDTENTRY_RAW(X86_TRAP_NMI, xenpv_exc_nmi); +DECLARE_IDTENTRY_RAW(X86_TRAP_NMI, noist_exc_nmi); #endif /* #DB */ diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index bf250a339655..2b907a76d0a1 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -524,6 +524,14 @@ DEFINE_IDTENTRY_RAW(exc_nmi) mds_user_clear_cpu_buffers(); } +#ifdef CONFIG_XEN_PV +DEFINE_IDTENTRY_RAW(noist_exc_nmi) +{ + /* On Xen PV, NMI doesn't use IST. The C part is the same as native. */ + exc_nmi(regs); +} +#endif + void stop_nmi(void) { ignore_nmis++; diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index 4f18cd9eacd8..5efbdb0905b7 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -565,12 +565,6 @@ static void xen_write_ldt_entry(struct desc_struct *dt, int entrynum, void noist_exc_debug(struct pt_regs *regs); -DEFINE_IDTENTRY_RAW(xenpv_exc_nmi) -{ - /* On Xen PV, NMI doesn't use IST. The C part is the same as native. */ - exc_nmi(regs); -} - DEFINE_IDTENTRY_RAW_ERRORCODE(xenpv_exc_double_fault) { /* On Xen PV, DF doesn't use IST. The C part is the same as native. */ @@ -626,6 +620,9 @@ struct trap_array_entry { .xen = xen_asm_xenpv_##func, \ .ist_okay = ist_ok } +/* Alias to make TRAP_ENTRY_REDIR() happy for nmi */ +#define xen_asm_xenpv_exc_nmi xen_asm_noist_exc_nmi + static struct trap_array_entry trap_array[] = { TRAP_ENTRY_REDIR(exc_debug, true ), TRAP_ENTRY_REDIR(exc_double_fault, true ), diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S index 1e626444712b..12e7cbbb2a8d 100644 --- a/arch/x86/xen/xen-asm.S +++ b/arch/x86/xen/xen-asm.S @@ -130,7 +130,7 @@ _ASM_NOKPROBE(xen_\name) xen_pv_trap asm_exc_divide_error xen_pv_trap asm_xenpv_exc_debug xen_pv_trap asm_exc_int3 -xen_pv_trap asm_xenpv_exc_nmi +xen_pv_trap asm_noist_exc_nmi xen_pv_trap asm_exc_overflow xen_pv_trap asm_exc_bounds xen_pv_trap asm_exc_invalid_op From patchwork Mon Apr 26 23:09:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12225659 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E7F9C433B4 for ; Tue, 27 Apr 2021 08:55:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EEB361002 for ; Tue, 27 Apr 2021 08:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235185AbhD0I4A (ORCPT ); Tue, 27 Apr 2021 04:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235062AbhD0Iz7 (ORCPT ); Tue, 27 Apr 2021 04:55:59 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6B18C061574; Tue, 27 Apr 2021 01:55:15 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id md17so3116982pjb.0; Tue, 27 Apr 2021 01:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/31Vy6dJtI8OfNAY7ghunL8gA/RZhNPFIkU577+CHEs=; b=A0xpPWh3R4bR9/A4KkPyHhizxphwgiPuLe9DPURlFVWpg+IfnOyhA4gsHx1cyY8rRK fb1szxBZolHo88h6FZblRM6nsdQjNiKBx5nVGfkBXzWNt2vpGAvxj1YuMzVQsFQp273z r7dudOSylQp1/3hnUkH9ByIJPy8lu1wjYVTslTHHZrfEgsQgM/McQ+Y077uRyV6JEO5c GnFDHskT0G+IWsta4CPbWvZkRYtXrW4S03kbOuIiahbMx+XaE2TNKnppudOfKDeW/SNw pk5hVLcZfp9SEH0BhUk5Xueb41D3XLHoBrnCQ5mzFyC8NJMOiq6xqT2U9YxM8tubcMXg srOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/31Vy6dJtI8OfNAY7ghunL8gA/RZhNPFIkU577+CHEs=; b=LIa/K1koORSZD7nhPIrH93lSbFYH6SyKzeDAWmb8+9pDjLOjdwfN8R8rPVsdbuPC0E b8v1BvZwPBIcOcrEtlkdaOj2Gi0buAIfil0CAtmRK+ePLxC0hlq2OKhawj0zKVEfBxOO WfrPLgHUujewEGZiV6r4IevmTUA6C891vxlPLRxi8DoggFLhJAf1u8AoT34zCgfyLWLV CVjjhqL+yh3X1keVLgofVs5CW++cYGmvEyM8pbWO4RVFXJgbzjXeF3W2xUr7gPpE5Zgq 8DwwdKHMXEqBE8zu+4kjbQeu/XZjXvU36Yqvk1BE7S+39BE8BpLibC0Srm7BuRDuVJxr SSLA== X-Gm-Message-State: AOAM530TnX9IIR7GgXpW1PQnzIuRFrQY9LeTfkEoBg/8ximZzENk2ck7 0hXdd6hnPgcA4SHb5mxnMpk6Y7NnqIU= X-Google-Smtp-Source: ABdhPJx+AJHGi3Rguoobjs/iQl6/SlIGKuNRMwZXS99zCPGUB+WyGOmVpZp9CTpHmWfFywdrAG0Bww== X-Received: by 2002:a17:902:bf44:b029:ec:c083:7377 with SMTP id u4-20020a170902bf44b02900ecc0837377mr22822309pls.27.1619513715229; Tue, 27 Apr 2021 01:55:15 -0700 (PDT) Received: from localhost ([47.251.4.198]) by smtp.gmail.com with ESMTPSA id 18sm1853014pji.30.2021.04.27.01.55.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Apr 2021 01:55:14 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Thomas Gleixner , Paolo Bonzini , Sean Christopherson , Steven Rostedt , Andi Kleen , Andy Lutomirski , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Josh Poimboeuf , Uros Bizjak , Maxim Levitsky , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra Subject: [PATCH 3/4] KVM/VMX: Invoke NMI non-IST entry instead of IST entry Date: Tue, 27 Apr 2021 07:09:48 +0800 Message-Id: <20210426230949.3561-4-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20210426230949.3561-1-jiangshanlai@gmail.com> References: <20210426230949.3561-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan In VMX, the NMI handler needs to be invoked after NMI VM-Exit. Before the commit 1a5488ef0dcf6 ("KVM: VMX: Invoke NMI handler via indirect call instead of INTn"), the work is done by INTn ("int $2"). But INTn microcode is relatively expensive, so the commit reworked NMI VM-Exit handling to invoke the kernel handler by function call. And INTn doesn't set the NMI blocked flag required by the linux kernel NMI entry. So moving away from INTn are very reasonable. Yet some details were missed. After the said commit applied, the NMI entry pointer is fetched from the IDT table and called from the kernel stack. But the NMI entry pointer installed on the IDT table is asm_exc_nmi() which expects to be invoked on the IST stack by the ISA. And it relies on the "NMI executing" variable on the IST stack to work correctly. When it is unexpectedly called from the kernel stack, the RSP-located "NMI executing" variable is also on the kernel stack and is "uninitialized" and can cause the NMI entry to run in the wrong way. So we should not used the NMI entry installed on the IDT table. Rather, we should use the NMI entry allowed to be used on the kernel stack which is asm_noist_exc_nmi() which is also used for XENPV and early booting. Link: https://lore.kernel.org/lkml/20200915191505.10355-3-sean.j.christopherson@intel.com/ Cc: Thomas Gleixner Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Steven Rostedt Cc: Andi Kleen Cc: Andy Lutomirski Cc: Vitaly Kuznetsov Cc: Wanpeng Li Cc: Jim Mattson Cc: Joerg Roedel Cc: kvm@vger.kernel.org Cc: Josh Poimboeuf Cc: Uros Bizjak Cc: Maxim Levitsky Signed-off-by: Lai Jiangshan --- arch/x86/kernel/nmi.c | 3 +++ arch/x86/kvm/vmx/vmx.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 2fb1fd59d714..919f0400d931 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -528,10 +528,13 @@ DEFINE_IDTENTRY_RAW(noist_exc_nmi) { /* * On Xen PV and early booting stage, NMI doesn't use IST. + * And when it is manually called from VMX NMI VM-Exit handler, + * it doesn't use IST either. * The C part is the same as native. */ exc_nmi(regs); } +EXPORT_SYMBOL_GPL(asm_noist_exc_nmi); void stop_nmi(void) { diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index bcbf0d2139e9..96e59d912637 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -6416,8 +6417,11 @@ static void handle_exception_nmi_irqoff(struct vcpu_vmx *vmx) else if (is_machine_check(intr_info)) kvm_machine_check(); /* We need to handle NMIs before interrupts are enabled */ - else if (is_nmi(intr_info)) - handle_interrupt_nmi_irqoff(&vmx->vcpu, intr_info); + else if (is_nmi(intr_info)) { + kvm_before_interrupt(&vmx->vcpu); + vmx_do_interrupt_nmi_irqoff((unsigned long)asm_noist_exc_nmi); + kvm_after_interrupt(&vmx->vcpu); + } } static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) From patchwork Mon Apr 26 23:09:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12225661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46716C433ED for ; Tue, 27 Apr 2021 08:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3B776100B for ; Tue, 27 Apr 2021 08:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235216AbhD0I4G (ORCPT ); Tue, 27 Apr 2021 04:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235062AbhD0I4F (ORCPT ); Tue, 27 Apr 2021 04:56:05 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C9F7C061574; Tue, 27 Apr 2021 01:55:23 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id h20so30497884plr.4; Tue, 27 Apr 2021 01:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PzcggadyhDBPR7CkYxhgm2opVcnUll8pyqBD4JcyorE=; b=i+DQQFnEX+WO8dczKbJtcvwM9Ge3MHWQDobm2okSjgTjr1DwlhkC+2PMnHHJlzUVDm D+AhAlpfliuJMBKgI2F2fT1hwDkL/srtNNe8Z//OPpVcZqy/KMtOq5fG94rLTFbIaJQB 6oL2WxwJiUvl+q1jiiP84TeE3S2EugTsGzCuAlWACJdRDsCbzAIZZQd3p0MhosI0ht66 hwHGDYJbZWmWsJdR7sfiFhPh0KWNFMv+wjgxmXeefyRS5rGnMcS5Oe+q62RcE83DsW5o jegpCuPMr8VXHCENK+wTu8XQOun0C22cSkdi9XvOhMwDWYawYjlIEyJhW+A4on/xDdG/ 37uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PzcggadyhDBPR7CkYxhgm2opVcnUll8pyqBD4JcyorE=; b=b3LGY8VBG/Yd3k8qPXRNzECBRzGCVSdOT8BfmemoRnIso/GDY3T/ylo9nDvC/5D+qT LAAnsaToc6i9BbSIqsvOs51ug7zMeaWUIApXRn9hjKWYiqefceogPsLd/2O+yFqhIChs oYuqyOx9tYyGIGMJ6ZbmumLNznmfzjHor0my0BWEsDCubvUI8Z/zdGtrF9V1Vw8IutP2 rDCuiaLoI3y8jNhNYVQIeVSSpIkwlFvU5Rpv4dcRSX7dK8xjnVliVJVi9IUxQXnBz2Kv ciKcnB0eihyy/XOSYfFcDGafpDzqTFDKEtQgNeGvOAqwNBOhqkD7VFr/cHHG1t17M6O5 jLCw== X-Gm-Message-State: AOAM5306GipJMJYhL23MxpScNb62Fu2ENR+0D8xLbgeZshKFQL6MAj6X Ry2U443eRik2UZS2by0inrmwCVdUFAQ= X-Google-Smtp-Source: ABdhPJyOS6jgcGOoHxz9iMFlZYdGZEV1pN/pf/U6LGC8G2QVEYcaApYs5/cNBh0xMUv+XJfrulkQsQ== X-Received: by 2002:a17:90a:352:: with SMTP id 18mr25304776pjf.223.1619513722745; Tue, 27 Apr 2021 01:55:22 -0700 (PDT) Received: from localhost ([47.251.4.198]) by smtp.gmail.com with ESMTPSA id e8sm1912910pfv.177.2021.04.27.01.55.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Apr 2021 01:55:22 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org Subject: [PATCH 4/4] KVM/VMX: Fold handle_interrupt_nmi_irqoff() into its solo caller Date: Tue, 27 Apr 2021 07:09:49 +0800 Message-Id: <20210426230949.3561-5-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20210426230949.3561-1-jiangshanlai@gmail.com> References: <20210426230949.3561-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan The function handle_interrupt_nmi_irqoff() is called only once and it doesn't handle for NMI, so its name is outdated. Cc: Sean Christopherson Signed-off-by: Lai Jiangshan --- arch/x86/kvm/vmx/vmx.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 96e59d912637..92c22211203e 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6396,16 +6396,6 @@ static void vmx_apicv_post_state_restore(struct kvm_vcpu *vcpu) void vmx_do_interrupt_nmi_irqoff(unsigned long entry); -static void handle_interrupt_nmi_irqoff(struct kvm_vcpu *vcpu, u32 intr_info) -{ - unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK; - gate_desc *desc = (gate_desc *)host_idt_base + vector; - - kvm_before_interrupt(vcpu); - vmx_do_interrupt_nmi_irqoff(gate_offset(desc)); - kvm_after_interrupt(vcpu); -} - static void handle_exception_nmi_irqoff(struct vcpu_vmx *vmx) { u32 intr_info = vmx_get_intr_info(&vmx->vcpu); @@ -6427,12 +6417,19 @@ static void handle_exception_nmi_irqoff(struct vcpu_vmx *vmx) static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) { u32 intr_info = vmx_get_intr_info(vcpu); + unsigned int vector; + gate_desc *desc; if (WARN_ONCE(!is_external_intr(intr_info), "KVM: unexpected VM-Exit interrupt info: 0x%x", intr_info)) return; - handle_interrupt_nmi_irqoff(vcpu, intr_info); + vector = intr_info & INTR_INFO_VECTOR_MASK; + desc = (gate_desc *)host_idt_base + vector; + + kvm_before_interrupt(vcpu); + vmx_do_interrupt_nmi_irqoff(gate_offset(desc)); + kvm_after_interrupt(vcpu); } static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)