Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp424676rwb; Tue, 4 Oct 2022 06:04:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4vakWRhh1nQL9LdxK85CYoeiTfApVu6BPaBdjsZFmmFiSscJm6jNfNGeUx7hAJ6vIBqkW+ X-Received: by 2002:a05:6402:3485:b0:451:f615:321f with SMTP id v5-20020a056402348500b00451f615321fmr23729492edc.65.1664888682746; Tue, 04 Oct 2022 06:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664888682; cv=none; d=google.com; s=arc-20160816; b=pQNGuYy4SGlNYsBU5BaoLp8beHZNECKTfqv1lNl7IxaKY6/mMkVNnHmSkvEHTTtq3Q jSoJ7lR5fRqzoxRboQtsMr78En5I6eeAvnZ+Vt9yePreHRj56DukJnksyNviHFTVPUvq 5IX+DmbeRQfm0YIKQm/DPRELh2Q9/sXS3jA/wDvjYtc5E0jiT6M0Lhuyf6np84QEujT4 mwAus/noVbWwrHWTHag9Q5ah2GcUv5S3DNs3TVaP2O6hCoROcQ0F46Ips5COtJeKNn19 JKGdvR67VKUvbtwSVE9oFBzZuo81t9JCaHABygPa+e+Qh6RYNNzhZ3Ix+qqrgeRLgEdj LbMA== 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=jcLmf4WreUvIvvpPtaDC32YuYtyFtYkrgIUYKQrkhBc=; b=JlL69ZZtXVu+wPlkjX3JIesgUWl8yQv/vZe+KGuHvCzCEAPNFIKeGQPYO1WU1lbSab yxGIM4rH9X/PxditfCk/p9ud3Ss51BZ8k1UJ22mcRQLWfh+NjeywJ5g5Z5pcTjWsw1nw YmBYUERcngZi+Kt4lMtxhkiRTJWme77V2+5EZF135gle09kgmUiECwfn9YxJ/9jJBAGr U832X5qBSvyA+cWSwqN+JIIUZwHf/TSR/398U5qKoVmz3SVCTU2pJqrbAGFBlc95z3Qu TMUb7fR6YYbyo5UlO/YKHr31Fhc7/WPREcwNHLCZNMhtvZ3ZBxKtGUrkZzfZxFA6Ruxq wyeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ERr09HWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r9-20020a1709060d4900b0077d6d63bd0dsi8873294ejh.184.2022.10.04.06.04.16; Tue, 04 Oct 2022 06:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ERr09HWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbiJDMuw (ORCPT + 99 others); Tue, 4 Oct 2022 08:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbiJDMuP (ORCPT ); Tue, 4 Oct 2022 08:50:15 -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 ESMTPS id 635A05E553 for ; Tue, 4 Oct 2022 05:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887623; 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=jcLmf4WreUvIvvpPtaDC32YuYtyFtYkrgIUYKQrkhBc=; b=ERr09HWxll095ySbzIIWa7vUnL+uqjexmoo85cKev0t9lfH/rB1ti1ieCwIp40qoskMpwR eRCm8XyOCYYRDGBmHs1BEVNoD+5MKrGU2Aq+WgdtTb27Dr0IwMJLurKUSmtrOAJzpPbGJ1 He0MiSfvP+VmN+qAJO9XBgNxP+xP4Mc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-F_Ie9UWGMDmBiL8USyi6pA-1; Tue, 04 Oct 2022 08:40:49 -0400 X-MC-Unique: F_Ie9UWGMDmBiL8USyi6pA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 40FBD8027FE; Tue, 4 Oct 2022 12:40:49 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2445E7AE5; Tue, 4 Oct 2022 12:40:47 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson Cc: Wanpeng Li , Jim Mattson , Michael Kelley , Siddharth Chandrasekaran , Yuan Yao , Maxim Levitsky , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 20/46] KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id Date: Tue, 4 Oct 2022 14:39:30 +0200 Message-Id: <20221004123956.188909-21-vkuznets@redhat.com> In-Reply-To: <20221004123956.188909-1-vkuznets@redhat.com> References: <20221004123956.188909-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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. Reviewed-by: Maxim Levitsky Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/svm/hyperv.h | 15 +++++++++++++++ arch/x86/kvm/svm/nested.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/arch/x86/kvm/svm/hyperv.h b/arch/x86/kvm/svm/hyperv.h index c59544cdf03b..e97d80974e72 100644 --- a/arch/x86/kvm/svm/hyperv.h +++ b/arch/x86/kvm/svm/hyperv.h @@ -9,5 +9,20 @@ #include #include "../hyperv.h" +#include "svm.h" + +static inline void nested_svm_hv_update_vm_vp_ids(struct kvm_vcpu *vcpu) +{ + struct vcpu_svm *svm = to_svm(vcpu); + struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments; + 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 c2a49aa50a58..45bab740f3f0 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -799,6 +799,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.37.3