Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp402987lqs; Tue, 5 Mar 2024 05:43:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpDHopMDsIJ3jhd/+UsOKAjlXDWwopNbDZAcRqq0Fz5MFeEWT+gx0I63fy/fdb2mcnwwTuHJNC6qnLtQezU7laNSE3mUinX2LR3MF33Q== X-Google-Smtp-Source: AGHT+IFjWecwj7ah91TcB9XnPIq+PWMgtm10IdZzld+WwFsQ8tCrVYsmgwpfphm2FdwCAfkdiLzU X-Received: by 2002:ac2:4241:0:b0:512:b915:606a with SMTP id m1-20020ac24241000000b00512b915606amr1335200lfl.12.1709646180531; Tue, 05 Mar 2024 05:43:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709646180; cv=pass; d=google.com; s=arc-20160816; b=K2itgNcD8YxPh/bY5/q+ySUabVVikuFxLg1asv309sVQgWx3hbY7FB8kdVE+goPXPQ YyiozCafkOTA0FV8mU8u7fIaq1FLpyIf/u2+FSX4vANX8PNtopo1PV4NCiEcZo+U/bSc OoV2Ibla5CrQ0xujvC3kHVovghqt4svLJTy3qarYuO9WajxA3RX9haerb3FfZAFADBhC OIhTnAOp1IBdUKDwuMlawc85182FJqeoMo4zC68ce6TBqJjJWFc0OOcn4h7JGoH9qcXv 4CrPtdImiGodno8e+ZArSOm+bgAJ48z4CV1pvhwK5oC6NKIWfTB5HoNcsBVXZEf+z9b9 ASKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=HUpHYIbaNmX1dR+hLhEjyoEaoj/QYBNJ6TLazQWrgwI=; fh=tgUWUbuI+B0KV3Xw+e/6lpHO2uTJDIACNIPu4ivbyA8=; b=V3CCL8rgIEC6jMITp+bpWkF3nH65KdRx7Te9GRKkEe7zc6nZHmHucSbKJSLK7LgTz8 ITflenPKqcerPskv9d6HBuDifGTHceCLooP0dD2LdtwY/olS3u8dj3iKGaVP3Jr3fI3M Kq1BLRLXmMcLocMukTboLIAAJUgVcmhKHODoUOiK6wyj5/luiFImW6AgKo1ln02D+Hrz fJeiZDZBK137R3Id3xjBizlTFq5ACPEOjXULt/U5auHoSb0dUkacadcI9yhJUX8MF03m ybSIn6Sk5QJhUByhLG1GPihoNiwcf7tlzxrpwfcN9lSEDeUqfILVBO5OUc03mJ7F8Kak MEYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NvSLPpzu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-92462-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92462-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q3-20020a170906388300b00a4439ecbc1esi5025902ejd.797.2024.03.05.05.43.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 05:43:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92462-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NvSLPpzu; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-92462-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92462-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 432A11F21EA0 for ; Tue, 5 Mar 2024 13:43:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C95A38612C; Tue, 5 Mar 2024 13:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NvSLPpzu" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472DF5676A; Tue, 5 Mar 2024 13:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709646174; cv=none; b=T++4P9ztkMoA/MGtuixdzjvX+azGOrxcJgF+v+TWCc1cMRTeqOzrszghPa06SIgiHrMIlX0BaBRmm+h8+TihobGI7N864kp1H7Qip0lRIkswN9S3F1CHRbxloWBL7hcYMdB5FmvgrBuuQIyq1xYu1nLpGXYak3Cyxco//eK331E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709646174; c=relaxed/simple; bh=1TUXrK0mJ+n0Z9W20paGt+AZeDVv0d+6JACKRbEJcIU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Qu32RHlxh8XqsbFeSIjeZievhJUnYGCDV8BXy6vgZhKkDAaHpLN9MnBuqlzzi0rWFF3ZjbzH7v1I3BT2OTTu/0r6vmR2QcZ6fpwvQLiL/CcXsh7EZLCUR9EacNxrr8KdRw1vynpZKZ8advzwHctrbhmdwPgGzFjDxlVnRj3UMP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=NvSLPpzu; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709646172; x=1741182172; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1TUXrK0mJ+n0Z9W20paGt+AZeDVv0d+6JACKRbEJcIU=; b=NvSLPpzuFE+wpZr4vmargD2hixWj3PKpnirSb7Wwi2y6Fww1xMfbbTDZ szNlxbZWTaoSDXiGyqlVYYO6iBkdtMvV0zheQ3VvG5Ij9AHe0+0xR9q5l m+LjHB+Js2Ww9ruFVdo7O7dG0o06RL5x66NVvyN0U5IblKX0NIGtbfwlS rb3AtySDFSZvl87RA5uLRy0OBuwC079SMw8jeYlzYtXJDUsEQQnKTQZ30 +dlUpmEpoLVX2skhoA5rnof1sBwMwoN+YafM+6z46O1GpAYcxRZHhm+HM 7wYIwlhhJbyYI//CWlIMVLcvb/oxnHq/qJ/78IpCD+aMfmkKrBfVGRAel Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11003"; a="4055200" X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="4055200" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 05:42:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="9321527" Received: from peizhenz-mobl2.ccr.corp.intel.com (HELO [10.124.242.47]) ([10.124.242.47]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 05:42:49 -0800 Message-ID: <15567943-817b-4fb8-a4ab-2d97ce2c827a@linux.intel.com> Date: Tue, 5 Mar 2024 21:42:47 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 09/21] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, seanjc@google.com, michael.roth@amd.com, isaku.yamahata@intel.com, thomas.lendacky@amd.com References: <20240227232100.478238-1-pbonzini@redhat.com> <20240227232100.478238-10-pbonzini@redhat.com> From: Binbin Wu In-Reply-To: <20240227232100.478238-10-pbonzini@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/28/2024 7:20 AM, Paolo Bonzini wrote: > 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 > Message-Id: <0396a9ae70d293c9d0b060349dae385a8a4fbcec.1705965635.git.isaku.yamahata@intel.com> > Signed-off-by: Paolo Bonzini Reviewed-by: Binbin Wu > --- > 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 3d8a7e4c8e37..8aedfe0fd78c 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -7000,24 +7000,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; > > @@ -7040,9 +7038,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)); > } > > /*