Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1444913rwj; Sun, 30 Oct 2022 00:28:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5IXe/5vr2aEfDBkhGwCSfeNzuvNoybnzR4PSTiiqJwBRwTfTRZdtE2bLYMQF/3i1cLKudl X-Received: by 2002:a17:902:ed85:b0:186:f151:de7d with SMTP id e5-20020a170902ed8500b00186f151de7dmr8024556plj.73.1667114898103; Sun, 30 Oct 2022 00:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667114898; cv=none; d=google.com; s=arc-20160816; b=CujfR6DA7dXaliCDts6HwK1kTNhm2pSMZ/J11nGMtC4+HdFnJpccb5Mpx6dxHtRALE 2NAyFLcyAGxZ9wfC1L1FpQmbTIv+q+Fjcd7zTe6vY+Luwi6wdWbJJYQg/Q8J/7vpBqbt xnHW21u2oziZ51C7ZZmhc5zcm5ReOnFM6vGO98Nxm++jNMSZ/kp9BbauGDxSi9un91O/ U4W+Ded65b06coFcdQyK0bVxAUlhZpieEcXvON0XRfg57XhIbniH8bxGajzjvLeh5bJu s3vPwyo6GsffBfv4rDliH8yqwl1VimOqEVpZVFmp4gY/1hy1sNKCi8ZfVeKUgjCoH2xE 0ijg== 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=XZsqKe7r7AX6kU4HCDKMcH47PsynUSkeQONzF7VfAQY=; b=oOcI5Z/IB1Kq7p7B8R/64psBROYTQPqj3WR0AUA/HooP3K2JIBKWY45dybcMYDLjLB qH71x7Oqo4NvR/2DupbavHjj+S22MYo8NwAnw0SR74HUP16SICK3LI8DATdtZAkkRIut UhuwKsDqwFCWT1L2Zh25lMWTcleju0NtKG0J1SKXos/2bBBwVuUVvX4Qbu7c4ajqVhKR I9l9ye7uUjJ2G7vIyFl2M/ltihS7owERucabLuvNuVMN5uGOMWszG33aR5KXcti85Fw6 zKJHch6+M+3sX6ZD/pH/aL1SEOYAbhj0EMDMLXSGRCemJ+l4M4nPvvAgisI50R6cPdVN OI6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dd0dMKtM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a170902bc4c00b0018280f67482si4054601plz.113.2022.10.30.00.28.07; Sun, 30 Oct 2022 00:28:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dd0dMKtM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231422AbiJ3Gbf (ORCPT + 99 others); Sun, 30 Oct 2022 02:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230432AbiJ3G3q (ORCPT ); Sun, 30 Oct 2022 02:29:46 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1DC239C; Sat, 29 Oct 2022 23:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111089; x=1698647089; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QfilQfz5T6WX7jIiQti9o/c2YET0YrmSZ7uU0IfCFmE=; b=dd0dMKtMGn6x5i9nU/MvAyaG1/4bsVYvt1IH7mIzD1UXTlO7FIaFa0R6 duAA0lWTJeSxdITv+r7hwycCFyj9Uq45O6h5LBPxpYBrOCskOGVu4ZSLz mlbths3ANKQ4aqnng+Ld40ZH1382GsJEIKNSDZWDKbTQFS+5PRjsx4P07 g6Hl11HWAmE0/PKyzKxFYAtQEgJ6tDWSJu8P4zQDFSEiUlU6wtVx3fX1b AFT3A13OCalbufwWNywIj+UXV2ouW0qATnips6b3S7nwfNiFG6ORWn216 7Tvu6Dy568shrTDixJxgkO58VzUKGOnKqwdHxpeVisDbxqD+hk9lx1rpk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037197" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037197" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:11 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393113" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393113" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:11 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Sean Christopherson Subject: [PATCH v10 084/108] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument Date: Sat, 29 Oct 2022 23:23:25 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: Sean Christopherson TDX uses different ABI to get information about VM exit. Pass intr_info to the NMI and INTR handlers instead of pulling it from vcpu_vmx in preparation for sharing the bulk of the handlers with TDX. When the guest TD exits to VMM, RAX holds status and exit reason, RCX holds exit qualification etc rather than the VMCS fields because VMM doesn't have access to the VMCS. The eventual code will be VMX: - get exit reason, intr_info, exit_qualification, and etc from VMCS - call NMI/INTR handlers (common code) TDX: - get exit reason, intr_info, exit_qualification, and etc from guest registers - call NMI/INTR handlers (common code) Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini --- arch/x86/kvm/vmx/vmx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index b4c65eb17cc2..79d8d6a89516 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6830,28 +6830,27 @@ static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu) rdmsrl(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err); } -static void handle_exception_nmi_irqoff(struct vcpu_vmx *vmx) +static void handle_exception_nmi_irqoff(struct kvm_vcpu *vcpu, u32 intr_info) { const unsigned long nmi_entry = (unsigned long)asm_exc_nmi_noist; - u32 intr_info = vmx_get_intr_info(&vmx->vcpu); /* if exit due to PF check for async PF */ if (is_page_fault(intr_info)) - vmx->vcpu.arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags(); + vcpu->arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags(); /* if exit due to NM, handle before interrupts are enabled */ else if (is_nm_fault(intr_info)) - handle_nm_fault_irqoff(&vmx->vcpu); + handle_nm_fault_irqoff(vcpu); /* Handle machine checks before interrupts are enabled */ 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, nmi_entry); + handle_interrupt_nmi_irqoff(vcpu, nmi_entry); } -static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu) +static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu, + u32 intr_info) { - u32 intr_info = vmx_get_intr_info(vcpu); unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK; gate_desc *desc = (gate_desc *)host_idt_base + vector; @@ -6871,9 +6870,9 @@ void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu) return; if (vmx->exit_reason.basic == EXIT_REASON_EXTERNAL_INTERRUPT) - handle_external_interrupt_irqoff(vcpu); + handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu)); else if (vmx->exit_reason.basic == EXIT_REASON_EXCEPTION_NMI) - handle_exception_nmi_irqoff(vmx); + handle_exception_nmi_irqoff(vcpu, vmx_get_intr_info(vcpu)); } /* -- 2.25.1