From patchwork Thu Jan 7 09:38:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 12003357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F2D0C43381 for ; Thu, 7 Jan 2021 09:40:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5206A23371 for ; Thu, 7 Jan 2021 09:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727487AbhAGJkp (ORCPT ); Thu, 7 Jan 2021 04:40:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:34143 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbhAGJko (ORCPT ); Thu, 7 Jan 2021 04:40:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610012358; 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=Xewkuyd+yZLUtmmkTpU1BhtOSrSJwLQTvCzDTVejJmI=; b=WrMLeQ7gBY9g22HkTWkCa90fy8bVtZHx5X49lwlqzqO1n3YK3Koxhx+wWSqa9w3OCQSB1Q OtvKD5rP6VVhUU7VFQOKhcvD5mjvOQdPwgYgU43KKj4ds6ymLGK74QGPzXYWVtnW0pjbPq gpxQDNesbo/TZJfzaWTDkreF8pO0gRI= 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-64-RzMPIdH9Me64Au4ILOhETg-1; Thu, 07 Jan 2021 04:39:17 -0500 X-MC-Unique: RzMPIdH9Me64Au4ILOhETg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E46D809DCD; Thu, 7 Jan 2021 09:39:14 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0842019481; Thu, 7 Jan 2021 09:39:10 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Vitaly Kuznetsov , "H. Peter Anvin" , Sean Christopherson , Borislav Petkov , Paolo Bonzini , Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Ingo Molnar , Wanpeng Li , Joerg Roedel , Jim Mattson , Maxim Levitsky Subject: [PATCH v2 2/4] KVM: nSVM: correctly restore nested_run_pending on migration Date: Thu, 7 Jan 2021 11:38:52 +0200 Message-Id: <20210107093854.882483-3-mlevitsk@redhat.com> In-Reply-To: <20210107093854.882483-1-mlevitsk@redhat.com> References: <20210107093854.882483-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The code to store it on the migration exists, but no code was restoring it. One of the side effects of fixing this is that L1->L2 injected events are no longer lost when migration happens with nested run pending. Signed-off-by: Maxim Levitsky --- arch/x86/kvm/svm/nested.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index ee4f2082ad1bd..cc3130ab612e5 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1200,6 +1200,10 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, * in the registers, the save area of the nested state instead * contains saved L1 state. */ + + svm->nested.nested_run_pending = + !!(kvm_state->flags & KVM_STATE_NESTED_RUN_PENDING); + copy_vmcb_control_area(&hsave->control, &svm->vmcb->control); hsave->save = *save;