Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2620424rdg; Mon, 16 Oct 2023 09:35:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEETOAJqMlwc68yyP6/yseLlmmlsHOs0PvWCrWiMi0MTDBGyTBo3Q0izdPnXq0gXW2tgSWK X-Received: by 2002:a17:90b:216:b0:27d:1126:1ff6 with SMTP id fy22-20020a17090b021600b0027d11261ff6mr11235055pjb.8.1697474129390; Mon, 16 Oct 2023 09:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474129; cv=none; d=google.com; s=arc-20160816; b=b1XUc5F6NUDuQq4Q7tarXhYd2oh+0I2BunJ7CNVB1r553qIk2/Ej+n18zeQIVMA3dv 6Yq8Ak/wh7HLgTBM8o3Fi4xBBtcjh73XeBTSTImk1xr2myD9cxlTmivIOPxgksWNcl2c lBGPdDxr5/oEqf5LGUAUGI8ACYks840P7tn4RxAItoQYq8TrvI4WpRmN43pTF7yLBWYi ZDi8Cuscj8/KXz7Eermm9nhCIFzhCfxlL9o4NtCIH0yi24jwdc7Lho5fKTm30TW7SV6z v7CYzZxC9rIH5EYeJ1IjNLBpeAN6NV2pR4EXRSFe3e5J/CtB29j0Y9wUz8Ge7R74UQZ5 8yCA== 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=2uh3Ry0fDxd/ueQK8USth9WC0FKfu4JWXNmcMrqrbbo=; fh=4OEEkzWp/q+dELKxtVy/jK+pEs8VYY1pIiC6FIGYmPg=; b=Nk6wZrodKbSvFcEKeGB2Q47YU9RnGnShK88MQw6udBSKMGSR0RUoV6oLsDN/KIHQ+4 sxYBpIEY7zevTI1dQ1KAvpo9jc8SIltKt5j9f9jpkbF92Kkajz81Y43lzJtHtN8Cgzew j4Eq/i0HxfGIHQ0L7f+zCXExvwwlan3fLwo7sgNcHSfqt1tp9UZOMJxegBOngs5qKsdq Z5clTzshS1598/moGH1sWNZ8UtNELWP0UY2/tdAnrSuA1BeN+bgjRKq6QC1kWOaW7wCu Xbo7pqKQ2R+icZlkC4q8y6+43rL2HImEymy2iCP4TXD74oVTyMNCwdWc7F2+1mFVvMav k9Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WjeFOeph; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s123-20020a632c81000000b005aad7d775fdsi8036008pgs.301.2023.10.16.09.35.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:35:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WjeFOeph; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1EC61804197C; Mon, 16 Oct 2023 09:35:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234363AbjJPQfN (ORCPT + 99 others); Mon, 16 Oct 2023 12:35:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234364AbjJPQeB (ORCPT ); Mon, 16 Oct 2023 12:34:01 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514173AAB; Mon, 16 Oct 2023 09:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473168; x=1729009168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yEf3IPjg+bDdjyb1Hf8PTFsGWUMHA165u/euLiyM95Y=; b=WjeFOeph/nt5Mu7G3YzLmRzpKb78RmID0YxdYFwV+X9ttIdTCWRZF4FD BzQOv/nyOzDZEYBCUy7uhGHq0pnEfZon/HgF+Dp0X0cNRjr4gKKsmdLQ9 C3cEfya1ChZbhgddXB1cBbxkPefMOunhwE/p7vELfn71Id2re9YaeM60P /jSwJKwb9UZ9BrRQHELPK2bmzBeUEEJtJtGMKM6xyHNl4HHgYJlNIJ7lH sOQ7o0GxjiqHP8eTkW2h4xZdzdZK0Jcv/qB2c29m68MFdizdtMoOCMatE vcuVyyqinD7ukoGbtI4Cvd3d/RcFZosGjETr7RNhwKwPHwQvYJqYnnJoH w==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364921970" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364921970" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:16:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448247" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448247" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:58 -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 , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson Subject: [PATCH v16 079/116] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument Date: Mon, 16 Oct 2023 09:14:31 -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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:35:26 -0700 (PDT) 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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 484c3c7b46c8..b1c36525a81a 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6913,24 +6913,22 @@ 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_irqoff(struct vcpu_vmx *vmx) +static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info) { - 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(); } -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; @@ -6953,9 +6951,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_irqoff(vmx); + handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu)); } /* -- 2.25.1