From patchwork Thu Jan 7 09:38:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 12003355 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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 334ECC433E0 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 F3A342333F for ; Thu, 7 Jan 2021 09:40:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbhAGJkg (ORCPT ); Thu, 7 Jan 2021 04:40:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44679 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbhAGJkg (ORCPT ); Thu, 7 Jan 2021 04:40:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610012349; 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; bh=0/UvIsE6v1FZ8l1jZ7AnILfXjsl6XgnZoeG7pEBoAX4=; b=UswIR7I3sqB3XTAOwxGLgnQiQKoS0jwtpuuz5jb4BnowznAXJhcj4IvLW2mSVOMoIGUNxI b1HgfR8lgiS8ZrF9u/UArC5rvXJJGTns+7FN5dvc7UDJjndoubbz/iG2eL+T04R0bRdqja pflpRpigdaaPVpHgbGdQEcSyKfr6t1Q= 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-497-34FcIbIPMUOnL2sw4IGfiQ-1; Thu, 07 Jan 2021 04:39:06 -0500 X-MC-Unique: 34FcIbIPMUOnL2sw4IGfiQ-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 33CD9AFA80; Thu, 7 Jan 2021 09:39:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3966219D7D; Thu, 7 Jan 2021 09:38:55 +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 0/4] KVM: nSVM: few random fixes Date: Thu, 7 Jan 2021 11:38:50 +0200 Message-Id: <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 This is a series of fixes to nested SVM, that finally makes my kvm on kvm stress test pass, and fix various other issues/regressions. Patch 1 is a fix for recent regression related to code that delayed the nested msr bitmap processing to the next vm entry, and started to crash the L1 after my on demand nested state allocation patches. The problem was that the code assumed that we will still be in the nested guest mode on next vmentry after setting the nested state, but a pending event can cause a nested vmexit prior to that. Patch 2 makes KVM restore nested_run_pending flag on migration which fixes various issues including potentially missed L1->L2 event injection if migration happens while nested run is pending. Patches 3,4 are few things I found while reviewing the nested migration code. I don't have a reproducer for them. Thanks a lot to Sean Christopherson for the review feedback on V1 of this series, which is fully incorporated in this series. Best regards, Maxim Levitsky Maxim Levitsky (4): KVM: nSVM: cancel KVM_REQ_GET_NESTED_STATE_PAGES on nested vmexit KVM: nSVM: correctly restore nested_run_pending on migration KVM: nSVM: always leave the nested state first on KVM_SET_NESTED_STATE KVM: nSVM: mark vmcb as dirty when forcingly leaving the guest mode arch/x86/kvm/svm/nested.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)