Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp643906ybm; Fri, 29 May 2020 08:45:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3ZUjuPccfj6zD5SpMAAkOqLAdvzy7OQP+YC4km11urBOjgHB6jNkGU3EkJiQdi4/6SAsm X-Received: by 2002:a50:d1c4:: with SMTP id i4mr8826831edg.344.1590767114524; Fri, 29 May 2020 08:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590767114; cv=none; d=google.com; s=arc-20160816; b=VT6O6y13lBCYrpMw64rHzEeP0vEEY7r+2ZmkpSTQAuesSYXXHBNj3mHx2JBoxEWR21 QhbIUJMp9dOvrbnSI2Bx056plGqBHprfsup4NH4zGGzl0DGtP4lIcQnKBOvTCcKQV66i nQv/hh/il0csawepUb9LCWOjuvGxhI/vhKvdBVDc7x//cFtygIutSx5s5ZXCaXHNCbS8 L9FZ/ZV0SzsLeyBbV2fFlOQu9zuhEIHdlVJVZXOk5whLpos9Fs4SxRZ63CODsc3XUBqT Et6XKjS1JwHbKBklwqckmxH5ovAQ1NM/22XJq13Jcve+yh7ZFFHrxPC4IR6a44w6pBLq QyJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=fYwdhNfw49NnqBUK5rThFPz3+tIf64fjifvlv5uw11s=; b=mr0ynOqhMUacb9eeSobM+aCusByhU6NnBIRCAP1sL8BhgcBSFWtWGddiTbVhIwbh00 qhxF7VRwmYc1uxk0XQ/hKAbrPXlNVqMAZvabaMF7l1pg9QJ5Ljvt0fEQj2ZEdSfDsx/K 6+yVLEctQuz5AjEnm6Of+73ZkDbrWecCOyzQ0jvZD3niD+l1Oe/TFunZOk5hVDKjW1Qf yE4Bbw8oPyCtZ6eOvwVU7607FbBP4zwXQVHW2N00dhuKDbQ4OqqqH4eHJJSr3/3DluM4 3yLEMfQqKH8sn4dWj+7g4+hS6hM3mR1GPyLI7XDY/BXG52P1dgy+OJXqvl2C2QNIcDHw 9Drw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T+6WveLm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si4707922edn.355.2020.05.29.08.44.50; Fri, 29 May 2020 08:45:14 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=T+6WveLm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727885AbgE2PmJ (ORCPT + 99 others); Fri, 29 May 2020 11:42:09 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58784 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727078AbgE2Pjo (ORCPT ); Fri, 29 May 2020 11:39:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590766782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fYwdhNfw49NnqBUK5rThFPz3+tIf64fjifvlv5uw11s=; b=T+6WveLmfgPuzuE5+s2f4rDG2q9o/Mh+CJCSYkwC24znMayHkMc15hZGOtAfGuN2/TNIuA afIoWMChUtKKfOat3vZjydrUnhGhufaxGJLSU91rQPjktAshxW8p9117cr5KmfOgZe0I21 VblpZuv7qJRV8FinUKsZzJiGFllFul0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-SiNi5XP4OTu0bmeDC7BnAA-1; Fri, 29 May 2020 11:39:40 -0400 X-MC-Unique: SiNi5XP4OTu0bmeDC7BnAA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB7CC835B42; Fri, 29 May 2020 15:39:39 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6284C5D9D5; Fri, 29 May 2020 15:39:39 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 08/30] KVM: nSVM: move map argument out of enter_svm_guest_mode Date: Fri, 29 May 2020 11:39:12 -0400 Message-Id: <20200529153934.11694-9-pbonzini@redhat.com> In-Reply-To: <20200529153934.11694-1-pbonzini@redhat.com> References: <20200529153934.11694-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unmapping the nested VMCB in enter_svm_guest_mode is a bit of a wart, since the map is not used elsewhere in the function. There are just two calls, so move it there. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 14 ++++++-------- arch/x86/kvm/svm/svm.c | 3 ++- arch/x86/kvm/svm/svm.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 8756c9f463fd..8e98d5e420a5 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -229,7 +229,7 @@ static bool nested_vmcb_checks(struct vmcb *vmcb) } void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa, - struct vmcb *nested_vmcb, struct kvm_host_map *map) + struct vmcb *nested_vmcb) { bool evaluate_pending_interrupts = is_intercept(svm, INTERCEPT_VINTR) || @@ -304,8 +304,6 @@ void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa, svm->vmcb->control.pause_filter_thresh = nested_vmcb->control.pause_filter_thresh; - kvm_vcpu_unmap(&svm->vcpu, map, true); - /* Enter Guest-Mode */ enter_guest_mode(&svm->vcpu); @@ -368,10 +366,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm) nested_vmcb->control.exit_code_hi = 0; nested_vmcb->control.exit_info_1 = 0; nested_vmcb->control.exit_info_2 = 0; - - kvm_vcpu_unmap(&svm->vcpu, &map, true); - - return ret; + goto out; } trace_kvm_nested_vmrun(svm->vmcb->save.rip, vmcb_gpa, @@ -414,7 +409,7 @@ int nested_svm_vmrun(struct vcpu_svm *svm) copy_vmcb_control_area(hsave, vmcb); svm->nested.nested_run_pending = 1; - enter_svm_guest_mode(svm, vmcb_gpa, nested_vmcb, &map); + enter_svm_guest_mode(svm, vmcb_gpa, nested_vmcb); if (!nested_svm_vmrun_msrpm(svm)) { svm->vmcb->control.exit_code = SVM_EXIT_ERR; @@ -425,6 +420,9 @@ int nested_svm_vmrun(struct vcpu_svm *svm) nested_svm_vmexit(svm); } +out: + kvm_vcpu_unmap(&svm->vcpu, &map, true); + return ret; } diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index feb96a410f2d..76b3f553815e 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3814,7 +3814,8 @@ static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate) if (kvm_vcpu_map(&svm->vcpu, gpa_to_gfn(vmcb), &map) == -EINVAL) return 1; nested_vmcb = map.hva; - enter_svm_guest_mode(svm, vmcb, nested_vmcb, &map); + enter_svm_guest_mode(svm, vmcb, nested_vmcb); + kvm_vcpu_unmap(&svm->vcpu, &map, true); } return 0; } diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 89fab75dd4f5..33e3f09d7a8e 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -395,7 +395,7 @@ static inline bool nested_exit_on_nmi(struct vcpu_svm *svm) } void enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb_gpa, - struct vmcb *nested_vmcb, struct kvm_host_map *map); + struct vmcb *nested_vmcb); int nested_svm_vmrun(struct vcpu_svm *svm); void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb); int nested_svm_vmexit(struct vcpu_svm *svm); -- 2.26.2