From patchwork Mon Apr 26 11:13:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 12224165 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=unavailable 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 E2891C433B4 for ; Mon, 26 Apr 2021 11:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA7BA61359 for ; Mon, 26 Apr 2021 11:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233034AbhDZLO7 (ORCPT ); Mon, 26 Apr 2021 07:14:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41637 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232492AbhDZLO4 (ORCPT ); Mon, 26 Apr 2021 07:14:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619435655; 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=4EGSofxQx4brtBrsah9Z+zPRC9nWkVvSS5E/pnfMZn0=; b=E0S6t5qc1zssvPJR2i03GN7FsBl/xfOKirD79+vlmyeJMSCiGLYE6eNjkqYydjfnVzq4Ov JLrw0Dn3DpThH/RdoWS073q/3ZFrjlz3g74zeEJAPpLgyPrzoUk/wAfOrm0FupFIbsvcXo LJ+YxwtkrqTzH7h8x/txfEct/a2A99k= 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-442-78yYM6mCOhS2wonT2h580w-1; Mon, 26 Apr 2021 07:14:11 -0400 X-MC-Unique: 78yYM6mCOhS2wonT2h580w-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 ABF3F84B9A7; Mon, 26 Apr 2021 11:13:40 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAE505D9F0; Mon, 26 Apr 2021 11:13:35 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: linux-doc@vger.kernel.org (open list:DOCUMENTATION), Thomas Gleixner , Jonathan Corbet , Paolo Bonzini , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), linux-kernel@vger.kernel.org (open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)), "H. Peter Anvin" , Ingo Molnar , Borislav Petkov , Wanpeng Li , Vitaly Kuznetsov , Jim Mattson , Sean Christopherson , Joerg Roedel , Maxim Levitsky Subject: [PATCH v2 0/6] Introduce KVM_{GET|SET}_SREGS2 and fix PDPTR migration Date: Mon, 26 Apr 2021 14:13:27 +0300 Message-Id: <20210426111333.967729-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This patch set aims to fix few flaws that were discovered in KVM_{GET|SET}_SREGS on x86: * There is no support for reading/writing PDPTRs although these are considered to be part of the guest state. * There is useless interrupt bitmap which isn't needed * No support for future extensions (via flags and such) Also if the user doesn't use the new SREG2 api, the PDPTR load after migration is now done on KVM_REQ_GET_NESTED_STATE_PAGES to at least read them correctly in cases when guest memory map is not up to date when nested state is loaded. This patch series was tested by doing nested migration test of 32 bit PAE L1 + 32 bit PAE L2 on AMD and Intel and by nested migration test of 64 bit L1 + 32 bit PAE L2 on AMD. The later test currently fails on Intel (regardless of my patches). Changes from V1: - move only PDPTRS load to KVM_REQ_GET_NESTED_STATE_PAGES on VMX - rebase on top of kvm/queue - improve the KVM_GET_SREGS2 to have flag for PDPTRS and remove padding Patches to qemu will be send soon as well. Best regards, Maxim Levitskky Maxim Levitsky (6): KVM: nSVM: refactor the CR3 reload on migration KVM: nVMX: delay loading of PDPTRs to KVM_REQ_GET_NESTED_STATE_PAGES KVM: x86: introduce kvm_register_clear_available KVM: x86: Introduce KVM_GET_SREGS2 / KVM_SET_SREGS2 KVM: nSVM: avoid loading PDPTRs after migration when possible KVM: nVMX: avoid loading PDPTRs after migration when possible Documentation/virt/kvm/api.rst | 48 +++++++++++ arch/x86/include/asm/kvm_host.h | 7 ++ arch/x86/include/uapi/asm/kvm.h | 13 +++ arch/x86/kvm/kvm_cache_regs.h | 12 +++ arch/x86/kvm/svm/nested.c | 33 ++++++-- arch/x86/kvm/svm/svm.c | 6 +- arch/x86/kvm/vmx/nested.c | 24 ++++-- arch/x86/kvm/x86.c | 139 ++++++++++++++++++++++++++------ include/uapi/linux/kvm.h | 4 + 9 files changed, 246 insertions(+), 40 deletions(-)