Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp388777rwb; Tue, 25 Jul 2023 17:57:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFN8V+4PqF2EykyAsTvJnjwVRHevRe3TL6dAu6a2BFR/LxFjeUjMsLFExaB+Boja5YwUtZG X-Received: by 2002:a05:6a00:21cf:b0:682:713e:e520 with SMTP id t15-20020a056a0021cf00b00682713ee520mr862243pfj.8.1690333046062; Tue, 25 Jul 2023 17:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690333046; cv=none; d=google.com; s=arc-20160816; b=T+Iutb3RP0xwrdp2jEPj3Iz15k6krzfT8+7peAPX3gINlWy3QSoaetwNQFfFwHzea/ fNcflKr1KPoUZikpG0JpIt1pv+x4LBY6MxPAmhWDkZvORsuzRIWmhcv+2ryVgUyNAbzl LK1KirJC2eR4qAidvBpxtPBT8L4i8Fa12n7CF/CVwQGE4LlpN5PB12O8TSN3b4RjYJk+ Im5tMyVSQW0bt24jGB986L98gbkbI7v+bHaD1LieMfPWX6hoz3Il3qmu0naexFw66HLB aGfIyLycmtYlBLLnqv/eTjyvNWPosCPF7xctd1JaLwHPf2BCSGLBMYZyrmOD/EMBxouP w2WQ== 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=DgM0OFQemrO/wFWHLQ7duep30fwYoiKZqVY/VrY0NPs=; fh=aHvdLX1Pa61KvQFmeZODM982ht845x7CZ22gIB9kxIo=; b=pCEZPSLS+qRqsDCYPej0L9TtG9HcepefEyttHddhDCQi8ilIuUAmdtaQR1BPEkE322 qpiDOiaXjJfkW7DCz/5RaUyFhQEq208eWyxlja+fewRFShmOeeF/clO/dvdD3/HL99HD a/xW6fOW25g3aUr0Ygtrtl0/yXL9Iqv4LdBlzWSruWDAc5xKGw3/cqdxFPfnAApxxZbO AMzDgoVKvfGrCPpavabTI5DR6+gobqasrwQLyC9Et5lfJjqYUuNw7PaJ1iydG0wroYb0 2MY/J6xl+zVRnIWnI7xA2jBEzak9p8RfaePw1YBXGM5Q4WI0sLRuNil2cKs2DzTl31ad mDsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iS77jPu1; 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 be3-20020a656e43000000b00543a6ce8c33si12414508pgb.78.2023.07.25.17.57.13; Tue, 25 Jul 2023 17:57:26 -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=iS77jPu1; 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 S232725AbjGYWWa (ORCPT + 99 others); Tue, 25 Jul 2023 18:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbjGYWVc (ORCPT ); Tue, 25 Jul 2023 18:21:32 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53CF630F2; Tue, 25 Jul 2023 15:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690323446; x=1721859446; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qKbGFOwuKt5AHiw8B939WZUTvZiMGlmCpoxGrITv5jI=; b=iS77jPu1DciWBuyTXU2vwdk+NY2q/hTioq7UoefsGtzOhnxU4Zk0JSUb nTiic+ryvy0g2agFpJvgrRoVFfYSU7Gm2qgi+F8fppW1DJw9kz1GMNWrP abaX2fAccIhyLRwcbx2fxKPITeIKU3q8XDDslVp0uH/SHrfHcd0e77Ogk kAHMM9soYMztb/aSCFk4u4PJJfVm3JLi9i26dlwhaQvFrrO4JozMMpL1R /RwjTLoLStLw49jWXVpV4aAw/rpNGEpSSa3LNL3yTawwyy0UhSyDn9GIJ eZQzOsJGpM+7+88eeJV9Mg8rmfhVIwCOHOT1E26Yb64Y3nFVYKN12qJdK Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="367882637" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="367882637" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="840001855" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="840001855" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:15:57 -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 v15 080/115] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument Date: Tue, 25 Jul 2023 15: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=-4.4 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 | 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 7a72391d8133..11904a720181 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6883,24 +6883,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; @@ -6923,9 +6921,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