Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5567332rwb; Wed, 21 Sep 2022 09:24:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pC7ptW9uH9x9WypWtwrOXx1bEtPhjtasyS3Ak/MQfIIhbbG5Vd/seJbv4vE9fpChngq8C X-Received: by 2002:a17:907:743:b0:740:ef93:2ffc with SMTP id xc3-20020a170907074300b00740ef932ffcmr21590432ejb.514.1663777466013; Wed, 21 Sep 2022 09:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663777466; cv=none; d=google.com; s=arc-20160816; b=pksW1/KhQhRaT2dP94YLMC1W4mMTJodFmfkc1Dtxww/ShfWORHI9Qm4rZKM1GSP7go DReQ71vkr343gQAuBbsEtw+PrMjFaEjsbmFz3oxJamXugvKKJBXhKMZJhsHkg4DOtWjA vNW63tsSz+7Oa76CeEFh8GBEMyZteT4JF+jUZbGGzb/CKhCCQIHnXqcZi2Z6gxtvPW78 KlDGwVPxNxPBDomtJ1psBgS3ebqBecLf8hEhfAdgLfA7gR63hQZ9cm4B4nn4Htl5CxI8 3VByEXN4/FVkxqrmVCKA9G5SytGw/TQ6TtGQaLMvd8ZkDFlJEBYuxmh9WTiloxZejnSJ UK5g== 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=bKLAKGDhRcNUDjsxfDBgnVDeYz46O+IxpgpKEmoUFsQ=; b=FKRpIgpvQR3DOzujU4vPX60SYjf+hECatdSQLgRnsXhq29441GZVD6qxlfY/4b2eRj NY33MKycJOfSY15CCESUIIv2Unmg5KPUDz480NiAz0cHyl99CViNgFgG1tYhko6gTLXZ fhvveuSSev/knOUUIN6xDpUBaKJLg1HpLAWiHCSN+VmvCeSzqmAU5ceBlgWpEkGQGpd0 Mi7i2rFoIIOxxYy3ooFy4LpJTknem72yNPZx6oFJ1DQvw5kYIvtV45zinLdBhQwMHT+C mnfZV1FkMCbaqoAvuYcv8sDQ1mLFwv+O2QJuaKsUVGRLSUQb4IYG4CXKo60YIF+8npxy lTBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fNbIsy0L; 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 b26-20020a17090630da00b007803ce9432csi2579999ejb.490.2022.09.21.09.23.56; Wed, 21 Sep 2022 09:24:25 -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=fNbIsy0L; 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 S231312AbiIUP0x (ORCPT + 99 others); Wed, 21 Sep 2022 11:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbiIUP0G (ORCPT ); Wed, 21 Sep 2022 11:26:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3083F832F5 for ; Wed, 21 Sep 2022 08:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663773924; 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=bKLAKGDhRcNUDjsxfDBgnVDeYz46O+IxpgpKEmoUFsQ=; b=fNbIsy0L5uWGOBKEFUnCh5BkhN8XESaOhn16PcoFptYPcviWCI8ET+bVR50qUFpgdA7e/v FEQ6lz+pcmE9HSO2NvMBiE4xHlrbCaEKP/rHmKW/8m6bE+BWG2+GIKt7giq9VCfkqP43Pi zC31ow0rBJb3S46bZ6QwZhRzmfZxcy0= 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-497-Fi3jYBFsP9OEy5otSjUaTg-1; Wed, 21 Sep 2022 11:25:20 -0400 X-MC-Unique: Fi3jYBFsP9OEy5otSjUaTg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 48914296A602; Wed, 21 Sep 2022 15:25:19 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.194.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BBCA2166B2D; Wed, 21 Sep 2022 15:25:16 +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 v10 14/39] KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id Date: Wed, 21 Sep 2022 17:24:11 +0200 Message-Id: <20220921152436.3673454-15-vkuznets@redhat.com> In-Reply-To: <20220921152436.3673454-1-vkuznets@redhat.com> References: <20220921152436.3673454-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.6 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 | 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 4c620999d230..9fd75d45b31b 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -800,6 +800,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