From patchwork Tue Mar 1 18:26:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 12765020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE96EC433EF for ; Tue, 1 Mar 2022 18:27:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3F93F10E5A3; Tue, 1 Mar 2022 18:27:19 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 42E7910E6E9 for ; Tue, 1 Mar 2022 18:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646159237; 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=vzjWdcHRTHDRPwgL5xAIJJ+6OIz16Rt5thfeij3VhC0=; b=brl0ezCViJiS9SzyIH8h0xnbLYW+/HvoCaqxx/rXDtJVG50Ekk8EEO38istPr0Qwu4FJgl ibcF4G7tFcjvF5cKE8aVvlYseXBIZ3fnR8l50Zr5Dqy1yumFI92Iew4eW+pU6/CjXbpYUi O8D3EnTTVzDMlobDjd5SqkVzl2Bb0KE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-SfvRU821MJqmlxM7UYYEDg-1; Tue, 01 Mar 2022 13:27:13 -0500 X-MC-Unique: SfvRU821MJqmlxM7UYYEDg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F6201854E21; Tue, 1 Mar 2022 18:27:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 590B486C42; Tue, 1 Mar 2022 18:26:40 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Subject: [PATCH v3 00/11] RFC: nested AVIC Date: Tue, 1 Mar 2022 20:26:28 +0200 Message-Id: <20220301182639.559568-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wanpeng Li , David Airlie , dri-devel@lists.freedesktop.org, "H. Peter Anvin" , Joerg Roedel , x86@kernel.org, Maxim Levitsky , Ingo Molnar , Zhi Wang , Dave Hansen , intel-gfx@lists.freedesktop.org, Borislav Petkov , Rodrigo Vivi , Thomas Gleixner , intel-gvt-dev@lists.freedesktop.org, Jim Mattson , Tvrtko Ursulin , Sean Christopherson , linux-kernel@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This patch series implement everything that is needed to use AMD's AVIC while a nested guest is running including ability of the nested guest to use it, and brings feature parity vs APICv. I already posted patch 2, and patch 1 is extracted from another patch I posted today ‘KVM: x86: nSVM: implement nested VMLOAD/VMSAVE’ To make this series not depend on anything. This is RFC. There still corner cases that need to be fixed in regard to locking, especially around RCU use, locking is IMHO a bit ugly and inefficient. I did test this with nested guests (even 3 level of nesting, all with AVIC enabled), I also did a light test with VFIO passthrough. Suggestions, comments are welcome. Best regards, Maxim Levitsky Maxim Levitsky (11): KVM: x86: SVM: move nested_npt_enabled to svm.h KVM: x86: SVM: allow AVIC to co-exist with a nested guest running KVM: x86: mmu: allow to enable write tracking externally x86: KVMGT: use kvm_page_track_write_tracking_enable KVM: x86: mmu: add gfn_in_memslot helper KVM: x86: lapic: don't allow to change APIC ID when apic acceleration is enabled KVM: x86: SVM: remove avic's broken code that updated APIC ID KVM: x86: SVM: move avic state to separate struct KVM: x86: rename .set_apic_access_page_addr to reload_apic_access_page KVM: nSVM: implement support for nested AVIC KVM: SVM: allow to avoid not needed updates to is_running arch/x86/include/asm/kvm-x86-ops.h | 3 +- arch/x86/include/asm/kvm_host.h | 12 +- arch/x86/include/asm/kvm_page_track.h | 1 + arch/x86/include/asm/svm.h | 8 +- arch/x86/kvm/Kconfig | 3 - arch/x86/kvm/lapic.c | 28 +- arch/x86/kvm/mmu.h | 8 +- arch/x86/kvm/mmu/mmu.c | 16 +- arch/x86/kvm/mmu/page_track.c | 10 +- arch/x86/kvm/svm/avic.c | 763 +++++++++++++++++++++++--- arch/x86/kvm/svm/nested.c | 147 ++++- arch/x86/kvm/svm/svm.c | 61 +- arch/x86/kvm/svm/svm.h | 158 +++++- arch/x86/kvm/trace.h | 164 +++++- arch/x86/kvm/vmx/vmx.c | 8 +- arch/x86/kvm/x86.c | 31 +- drivers/gpu/drm/i915/Kconfig | 1 - drivers/gpu/drm/i915/gvt/kvmgt.c | 5 + include/linux/kvm_host.h | 10 +- virt/kvm/kvm_main.c | 3 +- 20 files changed, 1298 insertions(+), 142 deletions(-)