Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp171443rdb; Mon, 22 Jan 2024 16:17:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IENAcafjIwlGffsWBuumeFFLHhNqBBWWukdZrAEIRHAQuQu4Y5ZIP4KyknUhhqpPUOCawqP X-Received: by 2002:a17:906:4701:b0:a2f:7f27:8aa with SMTP id y1-20020a170906470100b00a2f7f2708aamr2389701ejq.115.1705969027869; Mon, 22 Jan 2024 16:17:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705969027; cv=pass; d=google.com; s=arc-20160816; b=NhI0FwSn4EZOIdcGU6DzKvEV6YKzp/oBc4HsKjF5zWmaROrfgA1ge2JmSFPiKVFGAd x4eDCgqs3dSZO8bKTwjHZosIimAOCp0E8DR3C/R6LHvGYIf9DLjZxMGTzU5G3LrNEzOx 2hUAvGLRiQjj1ifbzQUnbkx5agsHhROkjWLT1oU8oQcNX05b2IEv7kFNyPVXhMis9d/W jEg7+dRGcNZ+MocAQ/1u6BXDbgdBC1SUQtQ2OwhnCJTCCLwWYIV0kjTAnj+sT3CeIcuC 2N5xkaEOXgYTwVpnvXAwtM8vnmgVjiGA+L3d48mpJwfGgMKaVoOURPv+px1XWiQGPZfg 6geQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WqIaciXGGScI7B0Z5+Ddu1eWt8OHXfCmxo4XXXnk5iY=; fh=ka1BjeomumTXa1Vhgkzg2yK2f13tB8VguFI2e9zPJ3c=; b=TRjK2djW72uZuNuYMTzkvhFW/WQSkYfVeDUV9KOJj5E/1VHuYtTthVAFlCd0nAnsPM bkHzF7y3b4pJ1pGCfkEogQxenlkRE76kUmqxuXXRv8bAd2luJOn7ja3cOxK/889XyQcZ GQipsM9qvAzfarX+sIjvyR1fRHj39zYKjBfuDXV3F9MoLpHtvACyaCG5rgfQsUnRCw1l 27GgtmbYx3EGGl9Qul9GDcT5NW4fJO4h36Z2tnIsCS/UKQJQdjluSnqR87KZVpqK5p1Q 0b/1unSTCumO1o1Bcs17XdRbucD6LL4E++ZUVuX3Xy4efS+3zmyQeKj6JGwikDQVfDQS wpWw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YQ+Uc98F; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34383-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 lm23-20020a170906981700b00a2ceaf80bcasi9970372ejb.983.2024.01.22.16.17.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34383-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=YQ+Uc98F; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34383-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34383-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 CA06E1F29352 for ; Tue, 23 Jan 2024 00:08:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA8876773F; Mon, 22 Jan 2024 23:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YQ+Uc98F" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 8A2E3657B4; Mon, 22 Jan 2024 23:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967754; cv=none; b=V/Z6D4x9ilcJNNsasKf4XBiuD5FLoc+JW08+5+U3c6q7vkkAtpkFB058wqhN7GDvGXb8ahgvFqTs/jW/vhGMFeAVOHlo3dBp6bM9C53TEJAJa1HwiHcc+PdWrsab9hGkTw4T9fXElsxviBaenal3QcgnTfggkvGqkS5xKuYqNqE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967754; c=relaxed/simple; bh=Cfpm2hNjd5LEOec/LWb3PLl0qqQDCYpA3Ruagdl1izI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xra5ToebmzikOmGJjG8MV6kLK5TA1Wb87WMUSJ+SC3PSTBlXrIR7l9nnrlaG1EpBQdu7kn7CboeYEzYTMouKY8dOuibW1Rd4l6DhQMkFJpaovRh/UV32shlIvlLAkI1vsFSo63i24g3sA3I+V14KXJ8dlVO17NuqkyMPzZ+xFfo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YQ+Uc98F; arc=none smtp.client-ip=192.55.52.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705967752; x=1737503752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cfpm2hNjd5LEOec/LWb3PLl0qqQDCYpA3Ruagdl1izI=; b=YQ+Uc98F6PAPrSz20AqzonG56z4HJjFCyEVnXe70ld2Ke2Tfj7HAKUdc 5V2NNi7fQPCU7QqV+4C6WDDSZGLpl3qipfGlxVM+lIPnjgeIf4lAdH5Fc huDb7slLdYx3o2/4sbQinLu1TdU3coJUoscEloRtRpqgjzBu5+8gBH/in f36dFI1A2p+TeHfcokKdm9iAO5h1z3f7OZXFOWPoGxkjzVQT/E3hGOGrX JNiIlUzUSlfgWrLJKm2Nw6f6I6Qf9/VSw7zlJJ/+AjlOnTa3iNgoXK8ok FyY6yGgdC1ssAwWva7MCJyGZSjSYVREEx+LvvRaudnPrDvNK6D/S2cJf5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="400217805" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="400217805" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27817931" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:45 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson Subject: [PATCH v18 084/121] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument Date: Mon, 22 Jan 2024 15:54:00 -0800 Message-Id: <0396a9ae70d293c9d0b060349dae385a8a4fbcec.1705965635.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 0373f6a3e5e3..5fe4eb2c2430 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6912,24 +6912,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; @@ -6952,9 +6950,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