Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp225138iof; Mon, 6 Jun 2022 02:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN8DQf2Brnc9Ir4KdtvZpXtwOXs0vVgqHxuAKNLsFWf2KZfoL0nzzkjXVQskriLYDZqvqy X-Received: by 2002:a63:8048:0:b0:3fc:8c4e:29ae with SMTP id j69-20020a638048000000b003fc8c4e29aemr20159684pgd.295.1654506175153; Mon, 06 Jun 2022 02:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654506175; cv=none; d=google.com; s=arc-20160816; b=Mu8hSfZWgGz7toFy16vLS2Y/cBfu+CtjFvBVW5IxxPzFlDFe3AqNWdVLpp4R8gjyK8 rTuxfpZ3qK4SaNbzXhyfiu50w/3GY2TAFLOiS5XgcR23VzFr7jhpLapy8D635RXabssd xGiWH2J2WLZz1vMZ5uguEcHvLKzh2sIcT68ABYNmvxgYjOXvMozrXZ5yyYBCpk4yf3xn R9PS2kgtVrOHG4P2SEXPNO/iokFgUmrcAceONDP4/92OWOXKGSHqUOES1QZJWwRB0kLH eSHV8Dq8A+G3YHmtI2iw4gXx8+pjQxbtKGXyarUO9CueB4TYA2ZaH2qSwp6Ut92vxb06 hFjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3E43Fzw+oCB39QSOxfacQFbXPw0r2XrLSWBUCQjkAUc=; b=QWtzIt3cshEFq/4N0FimIoR9wMXNBNb9HzDWMktNVIMdU5M3WUTs/ZCDBcz9RV4CRE suLYYmzWl/p3ZoHUTLv+SLl3vH07WteJwYJxp53GvKXZWs9QNPJm4twrA6k23OCGj18o X7j/jhiIYR0x3XA0v+VrhPznf2zCAD274plJD3wYkA10ktnhWtiwTZLmJxHJFGZQlA/d R9/sRqOtqhq04pdwm9sel+wnqlU2DLTy822qhfq7O8uljLX7j2VC9DJrgUgMpGT2D3S7 quoZ+jCow/sDZVsaFX9prB7ZopJJuln3DhTbu2vsc8mUOxeVYXsX88O9VrFcQ1odoQFQ cXeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YmHMFYzM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id jb4-20020a170903258400b00163e9cf7ce7si16845851plb.287.2022.06.06.02.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 02:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YmHMFYzM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 395875B8AB; Mon, 6 Jun 2022 01:40:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbiFFIjL (ORCPT + 99 others); Mon, 6 Jun 2022 04:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbiFFIht (ORCPT ); Mon, 6 Jun 2022 04:37:49 -0400 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 B61682018A for ; Mon, 6 Jun 2022 01:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654504655; 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: in-reply-to:in-reply-to:references:references; bh=3E43Fzw+oCB39QSOxfacQFbXPw0r2XrLSWBUCQjkAUc=; b=YmHMFYzMbw9D6d0yISrbnmek/yT+alRzPABjqU3TdT5djebrcomjVWaB/yDrcYTezqqWeJ 8gphAQWEtFCK+ysxxQOBTSrGPVRGBn9xLAHK30u3HXDuzunpJf9sHM+q6GY4ELpp2w1kDz dfQ+ZSmVbMt5pGExATBS6O11P0tno6w= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-564-m4oNoppFMc64juUNLeLLuQ-1; Mon, 06 Jun 2022 04:37:32 -0400 X-MC-Unique: m4oNoppFMc64juUNLeLLuQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 554E93C19024; Mon, 6 Jun 2022 08:37:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.193.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7BF0A1121314; Mon, 6 Jun 2022 08:37:30 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 14/38] KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id Date: Mon, 6 Jun 2022 10:36:31 +0200 Message-Id: <20220606083655.2014609-15-vkuznets@redhat.com> In-Reply-To: <20220606083655.2014609-1-vkuznets@redhat.com> References: <20220606083655.2014609-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to nSVM, KVM needs to know L2's VM_ID/VP_ID and Partition assist page address to handle L2 TLB flush requests. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm/hyperv.h | 16 ++++++++++++++++ arch/x86/kvm/svm/nested.c | 2 ++ 2 files changed, 18 insertions(+) diff --git a/arch/x86/kvm/svm/hyperv.h b/arch/x86/kvm/svm/hyperv.h index 7d6d97968fb9..8cf702fed7e5 100644 --- a/arch/x86/kvm/svm/hyperv.h +++ b/arch/x86/kvm/svm/hyperv.h @@ -9,6 +9,7 @@ #include #include "../hyperv.h" +#include "svm.h" /* * Hyper-V uses the software reserved 32 bytes in VMCB @@ -32,4 +33,19 @@ struct hv_enlightenments { */ #define VMCB_HV_NESTED_ENLIGHTENMENTS VMCB_SW +static inline void nested_svm_hv_update_vm_vp_ids(struct kvm_vcpu *vcpu) +{ + struct vcpu_svm *svm = to_svm(vcpu); + struct hv_enlightenments *hve = + (struct hv_enlightenments *)svm->nested.ctl.reserved_sw; + struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); + + if (!hv_vcpu) + return; + + hv_vcpu->nested.pa_page_gpa = hve->partition_assist_page; + hv_vcpu->nested.vm_id = hve->hv_vm_id; + hv_vcpu->nested.vp_id = hve->hv_vp_id; +} + #endif /* __ARCH_X86_KVM_SVM_HYPERV_H__ */ diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 88da8edbe1e1..e8908cc56e22 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -811,6 +811,8 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, if (kvm_vcpu_apicv_active(vcpu)) kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu); + nested_svm_hv_update_vm_vp_ids(vcpu); + return 0; } -- 2.35.3