Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp605321rwi; Thu, 20 Oct 2022 02:59:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5l1bgrthOKoVHO066BWfOdBG6n7ZejHDKQWRN7HdPFmZ4T3WGBczc/IeKOryTjbgC5lImL X-Received: by 2002:a17:906:8457:b0:78d:b793:5511 with SMTP id e23-20020a170906845700b0078db7935511mr10173359ejy.393.1666259998958; Thu, 20 Oct 2022 02:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666259998; cv=none; d=google.com; s=arc-20160816; b=JNiH8bzgKr8w8vskXkS7Edu6yEZIeJpW0KpoY86lgztPHJs3xPiuO4lKe7LDOqG0GY 07C0rPXQOFb8wNrmiPRrbJJFE7apWjzbFQBVeaodwD3Fz5dNgC4nXBysDNUdMYdytMOs zJ6GtWs7vQAsHl6sbdew724GShtgOGGsTlBNrAYAuw37esEh2SctFrsNpxbPFzMwrRfv xaGDk+WO9ytqnd/RSEec07T6Oj9dI/6UwTFKMWnjd2lqTto0JjHQH0xdSzU0IkGTNiBS PyN0IM8x8vieQl6l/VvNsC26eVM6X2qdp5SRBUcqm4CIV5RFy679E/Jq26YAZLl9Epdg NjiQ== 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=P73JFXQ3AWZGy0kFIbXH5/4fwtY8KoEObX2sf4YZ6rg=; b=L3h/HS0vfv0ZJaI6uG4uk/AF/zIdRmrk3TIERtZwd2LSF7qBNAAZbjEO/1vDG30nWj GO+l8rsEXT3Y/YGWpleT9Q3Lggm7eblj2/iQyIr79li3bxSJuvH8PdIGX0j8coaz3gIu MUxcP5UDSrB8Ni9l8aFyQEStmOWpcSvl/L1/TsjZnaCLZu7Sh2+XWPjFWGfbmjylWrwS GX0zCnKHePDidL7cHh5DqmOztk4Gialax7K4QYohjXrW0CnGb5yTLfIgBuSqgOHFUFPf R1d2G1JewzAP4rwwrbkeoTCwg0KVgeG7RcMy8I9aNKuBL7LFdSJKo33hfN000KvEJ2cR hUTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L2f8vb7V; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp18-20020a170906c15200b0078bec673145si16366513ejc.519.2022.10.20.02.59.33; Thu, 20 Oct 2022 02:59:58 -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=@redhat.com header.s=mimecast20190719 header.b=L2f8vb7V; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230423AbiJTJbl (ORCPT + 99 others); Thu, 20 Oct 2022 05:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbiJTJb0 (ORCPT ); Thu, 20 Oct 2022 05:31:26 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0955147D00 for ; Thu, 20 Oct 2022 02:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666258280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P73JFXQ3AWZGy0kFIbXH5/4fwtY8KoEObX2sf4YZ6rg=; b=L2f8vb7V/tZcbsO/sunLqpi/4sl0vrE2m74VYIPf/IvpoSHy+P32seDeHxELbD5dyO7MIM foFCoUGl+LhKwf35GnvyrFVp+DkMgHrUf8JzE3+dL86lntsDA8Iq508o5+qB/dk0EL7uvN UXAZ4tXQ/rsgzx/TDDd4F2znShVna8c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-9-w3fq1VFrN-yCpp6SElqxpQ-1; Thu, 20 Oct 2022 05:31:15 -0400 X-MC-Unique: w3fq1VFrN-yCpp6SElqxpQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6654085A583; Thu, 20 Oct 2022 09:31:14 +0000 (UTC) Received: from localhost.localdomain (ovpn-192-51.brq.redhat.com [10.40.192.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99B2249BB60; Thu, 20 Oct 2022 09:31:11 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Paolo Bonzini , Borislav Petkov , Ingo Molnar , Sean Christopherson , x86@kernel.org, Thomas Gleixner , Dave Hansen , "H. Peter Anvin" , Maxim Levitsky , stable@vger.kernel.org Subject: [PATCH 3/4] KVM: x86: add kvm_leave_nested Date: Thu, 20 Oct 2022 12:30:54 +0300 Message-Id: <20221020093055.224317-4-mlevitsk@redhat.com> In-Reply-To: <20221020093055.224317-1-mlevitsk@redhat.com> References: <20221020093055.224317-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Wrap a call to nested_ops->leave_nested into a function. Cc: stable@vger.kernel.org Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/nested.c | 3 --- arch/x86/kvm/vmx/nested.c | 3 --- arch/x86/kvm/x86.c | 8 +++++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index b02a3a1792f194..7354f0035a691d 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1146,9 +1146,6 @@ void svm_free_nested(struct vcpu_svm *svm) svm->nested.initialized = false; } -/* - * Forcibly leave nested mode in order to be able to reset the VCPU later on. - */ void svm_leave_nested(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 8f67a9c4a28706..a66c5e276ab408 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -6440,9 +6440,6 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu, return kvm_state.size; } -/* - * Forcibly leave nested mode in order to be able to reset the VCPU later on. - */ void vmx_leave_nested(struct kvm_vcpu *vcpu) { if (is_guest_mode(vcpu)) { diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4bd5f8a751de91..d86a8aae1471d3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -628,6 +628,12 @@ static void kvm_queue_exception_vmexit(struct kvm_vcpu *vcpu, unsigned int vecto ex->payload = payload; } +/* Forcibly leave the nested mode in cases like a vCPU reset */ +static void kvm_leave_nested(struct kvm_vcpu *vcpu) +{ + kvm_x86_ops.nested_ops->leave_nested(vcpu); +} + static void kvm_multiple_exception(struct kvm_vcpu *vcpu, unsigned nr, bool has_error, u32 error_code, bool has_payload, unsigned long payload, bool reinject) @@ -5200,7 +5206,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, if (events->flags & KVM_VCPUEVENT_VALID_SMM) { if (!!(vcpu->arch.hflags & HF_SMM_MASK) != events->smi.smm) { - kvm_x86_ops.nested_ops->leave_nested(vcpu); + kvm_leave_nested(vcpu); kvm_smm_changed(vcpu, events->smi.smm); } -- 2.26.3