Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1885785pxv; Fri, 2 Jul 2021 15:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHGW3HdYqVFr6Ff7lZQqvMC5P+PNpsvV6FCECu5hQuCv0lSOkpT7zXOn+Xh8pH49/691zm X-Received: by 2002:a05:6402:216:: with SMTP id t22mr1968412edv.70.1625263765884; Fri, 02 Jul 2021 15:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263765; cv=none; d=google.com; s=arc-20160816; b=xNWz31HLXNE1vUd/zfc0t2WOOLWljSX75qTtQcbx63yeZTa4XHNe61n661n1URbQPm x9BGJRvByodLR2bGlL3qseohQ9RXZ+iAplWtakNehd9Nt4m65TO2N/FWFKhDCJ5ESEpX pFFCH1ntbyeukwvqPykOr/SS3y5huVKBJoqQpveWkgDk4fsZWl5La9ZtXX4dssg4QgLA N9c7KMg4/JaV1jzSu1CiRf6PQhdrV143NZXxrpiY6nAfNXGojIWKA3y3WpzpxT+KieoJ RdVEBkYPo7ovD0o3QrUBP80M9TsXDbb8qE4Eec8cF7H2tCvXUuEpoHR40mxQNfnZCiK3 Gf+w== 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; bh=Tth6YRGgGTKszUivCoe/1djLkf0lnMl/j5Q5iHZYaK8=; b=Ajq6ww1b1y9t7dBfKBq9O2YkHqaQfVznv9bJJ2ZybpC4oA0+4azBsq33VqKK519BjC xROczjhdQX1mQbSChdwKp9srRLNiLzZe1ZrkXctd2Lfi2sHHk40tjltR312G3Dx5iV3v a7mH+ujoyW7KxyVyc5iCDsCk8OSTPA0IHTNwlr7jMmVrfb9w94mY8cFHtrTnYfr96og/ EXkgfL1NyTWVxw6Cngq8lJAA7quDFvV0mfblrKc0vdfgbZ/NyMhLkVvaa++8oO/5mjta bWZwajL7GJyGiUueObwaRsDBfzjgAhrW6Apw4JoJP/pn6ytN1902yAEr+SsItRK+SXHb DDKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si4403097ejj.601.2021.07.02.15.09.03; Fri, 02 Jul 2021 15:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233822AbhGBWKR (ORCPT + 99 others); Fri, 2 Jul 2021 18:10:17 -0400 Received: from mga17.intel.com ([192.55.52.151]:15306 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233986AbhGBWIo (ORCPT ); Fri, 2 Jul 2021 18:08:44 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="189168412" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="189168412" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:31 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814890" 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; 02 Jul 2021 15:05:31 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH v2 63/69] KVM: VMX: Move .get_interrupt_shadow() implementation to common VMX code Date: Fri, 2 Jul 2021 15:05:09 -0700 Message-Id: <11a3389da6184785b238b0d5a7f60279aa0a93b1.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/common.h | 14 ++++++++++++++ arch/x86/kvm/vmx/vmx.c | 10 +--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h index 755aaec85199..817ff3e74933 100644 --- a/arch/x86/kvm/vmx/common.h +++ b/arch/x86/kvm/vmx/common.h @@ -120,6 +120,20 @@ static inline int __vmx_handle_ept_violation(struct kvm_vcpu *vcpu, gpa_t gpa, return kvm_mmu_page_fault(vcpu, gpa, error_code, NULL, 0); } +static inline u32 __vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu) +{ + u32 interruptibility; + int ret = 0; + + interruptibility = vmread32(vcpu, GUEST_INTERRUPTIBILITY_INFO); + if (interruptibility & GUEST_INTR_STATE_STI) + ret |= KVM_X86_SHADOW_INT_STI; + if (interruptibility & GUEST_INTR_STATE_MOV_SS) + ret |= KVM_X86_SHADOW_INT_MOV_SS; + + return ret; +} + static inline u32 vmx_encode_ar_bytes(struct kvm_segment *var) { u32 ar; diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index d69d4dc7c071..d31cace67907 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1467,15 +1467,7 @@ void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu) { - u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO); - int ret = 0; - - if (interruptibility & GUEST_INTR_STATE_STI) - ret |= KVM_X86_SHADOW_INT_STI; - if (interruptibility & GUEST_INTR_STATE_MOV_SS) - ret |= KVM_X86_SHADOW_INT_MOV_SS; - - return ret; + return __vmx_get_interrupt_shadow(vcpu); } void vmx_set_interrupt_shadow(struct kvm_vcpu *vcpu, int mask) -- 2.25.1