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: 12764997 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1EBFC433F5 for ; Tue, 1 Mar 2022 18:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232795AbiCAS2B (ORCPT ); Tue, 1 Mar 2022 13:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236949AbiCAS17 (ORCPT ); Tue, 1 Mar 2022 13:27:59 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0437065175 for ; Tue, 1 Mar 2022 10:27:17 -0800 (PST) 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 Cc: Vitaly Kuznetsov , Ingo Molnar , Sean Christopherson , Jani Nikula , Daniel Vetter , Zhi Wang , Dave Hansen , Tvrtko Ursulin , David Airlie , Wanpeng Li , Joonas Lahtinen , x86@kernel.org, intel-gvt-dev@lists.freedesktop.org, Joerg Roedel , Zhenyu Wang , Rodrigo Vivi , Paolo Bonzini , "H. Peter Anvin" , Borislav Petkov , Jim Mattson , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Gleixner , dri-devel@lists.freedesktop.org, Maxim Levitsky 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 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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(-)