From patchwork Thu Aug 20 13:33:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 11726327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28A5B739 for ; Thu, 20 Aug 2020 13:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 100FD22B43 for ; Thu, 20 Aug 2020 13:37:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FgUxwuIm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729070AbgHTNhL (ORCPT ); Thu, 20 Aug 2020 09:37:11 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28019 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729663AbgHTNd7 (ORCPT ); Thu, 20 Aug 2020 09:33:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597930437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X2fJCEf/hhnmDqCnQtY5hjOcNe8YUPEVscVUU8eAkMY=; b=FgUxwuImrHXMEeBy5azRmZsROXuXDEEzkyOt3QmFHc6HukJHlqW1Tt7LCRCo7rWmfaAaJW rDUNrSJRIdxHiy+wQe/31PsyKJGwR/Ny7aLW0S9Tke5+1VgRKw45xxQYkd9m0tWa/bW1pi vNvh1NI8AfRThKGysUcsxlUo8MprPfE= 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-196-vDgPCg3fNbqGSmAdSCx5vQ-1; Thu, 20 Aug 2020 09:33:46 -0400 X-MC-Unique: vDgPCg3fNbqGSmAdSCx5vQ-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 B2A52AE641; Thu, 20 Aug 2020 13:33:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35F7219D6C; Thu, 20 Aug 2020 13:33:40 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), Jim Mattson , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" , Sean Christopherson , Joerg Roedel , Wanpeng Li , Borislav Petkov , Vitaly Kuznetsov , Paolo Bonzini , Maxim Levitsky Subject: [PATCH v2 0/7] KVM: nSVM: ondemand nested state allocation + smm fixes Date: Thu, 20 Aug 2020 16:33:32 +0300 Message-Id: <20200820133339.372823-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi! This patch series does some refactoring and implements on demand nested state area This way at least guests that don't use nesting won't waste memory on nested state. Patches 1,2,3 are refactoring Patches 4,5 are new from V1 and implement more strict SMM save state area checking on resume from SMM to avoid guest tampering with this area. This was done to avoid crashing if the guest enabled 'guest was interrupted' flag there and we don't have nested state allocated. Patches 6,7 are for ondemand nested state. The series was tested with various nested guests, in one case even with L3 running, but note that due to unrelated issue, migration with nested guest running didn't work for me with or without this series. I am investigating this currently. Best regards, Maxim Levitsky Maxim Levitsky (7): KVM: SVM: rename a variable in the svm_create_vcpu KVM: nSVM: rename nested 'vmcb' to vmcb12_gpa in few places KVM: SVM: refactor msr permission bitmap allocation KVM: x86: allow kvm_x86_ops.set_efer to return a value KVM: nSVM: more strict smm checks KVM: emulator: more strict rsm checks. KVM: nSVM: implement ondemand allocation of the nested state arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/emulate.c | 22 ++++-- arch/x86/kvm/svm/nested.c | 53 +++++++++++-- arch/x86/kvm/svm/svm.c | 130 ++++++++++++++++++-------------- arch/x86/kvm/svm/svm.h | 10 ++- arch/x86/kvm/vmx/vmx.c | 5 +- arch/x86/kvm/x86.c | 3 +- 7 files changed, 151 insertions(+), 74 deletions(-)