From patchwork Fri Oct 21 15:34:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 6769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp765291wrr; Fri, 21 Oct 2022 08:39:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5p9ACOQ+3N1p6xXeVA4PvwkXsRmBXM9Pr4Dxd6hW7AyN/RXvXuAFE2Pt8ULIVaQzYoBi4n X-Received: by 2002:a17:907:980e:b0:78d:b6d8:f53c with SMTP id ji14-20020a170907980e00b0078db6d8f53cmr16521449ejc.70.1666366750849; Fri, 21 Oct 2022 08:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666366750; cv=none; d=google.com; s=arc-20160816; b=FGBtBgGC60g1xI+avKRu0CylmVRUL8nWN47PWb2F38q7cE8iDyYHM22oDQ5hH0bYvv i2wWmNJ1tFEhP/C+0P/Ols7keP9uMxAyxWIsYamPwCkwCEv9Guz/uSysNcxlY2TGCVUN CyFJHZFh0bjS+jbUrqsJ+mchxq4gfkTPrLEzmsUAd8bOI+v8shUKwwZfLA5EG0Yrusds kiR1Wv3dbTdBbzbQ7yu3X8xA0w9Q0DnvxnyTxxFzGlgCDqnYIIXhUG1oZXylTpFWjBUf CheY29IqjMtqw/77l20JnmBIQpmKB8L5zm2LF/uUCVVs1n0hS9KjP7IByAJEJgxkSpAz WkUQ== 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=TMjYyofaXrIDMXqGqe1kqsccG9ZUBS6s914mxxQGXOF8mRbcsBo9UDI64DJ8YRxDVM 3ds5Aqv4lYazPovJgVtV6OrGnAYFQpLJETD287/eFNdvO5BedlJLHl1VTQEVLmoboHuz tENPrixdlO29IFc77LwhUh/+S4XtRYfXJVxx+sgbRFSqv3nE1b5fj84QaIvJeWQRMUsF iw5jqyuim+5YrmMUU2pzJBK6Y4YeBe4O1gGqXSF+8EoNtqkdvT2sX3NdNO4uZ5FM5Qr4 YU59z886Eycy4L95ykvcnU3q+VfTZz6GkDVix0Af7g4A2hJe8V25+y7ue8SSygWzii6u CiSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FyPCi+Vk; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go37-20020a1709070da500b0078df79d698dsi20397646ejc.810.2022.10.21.08.38.43; Fri, 21 Oct 2022 08:39:10 -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=FyPCi+Vk; 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 S230189AbiJUPhr (ORCPT + 99 others); Fri, 21 Oct 2022 11:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbiJUPgd (ORCPT ); Fri, 21 Oct 2022 11:36:33 -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 BA62F26EDA9 for ; Fri, 21 Oct 2022 08:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666366581; 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=FyPCi+Vk5wt+T5yIpTYBDil2epOs33Cw3BIhkI7Aa6+OtgF8cPZvGKErvvrJ7HcKyOhxe+ UlsTNcLy26noBUTD2eNO9nNmjcF+1o90rt6Gz8loe1FxHPg616qXj1OhzBORWHn0sbeSCY DtCMLQs8k1cyGZoDpzvzT85Zx/mnDEg= 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-663-LoMbqfi5PVWEvfVrrhZSVw-1; Fri, 21 Oct 2022 11:36:18 -0400 X-MC-Unique: LoMbqfi5PVWEvfVrrhZSVw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5023A886462; Fri, 21 Oct 2022 15:36:15 +0000 (UTC) Received: from ovpn-192-65.brq.redhat.com (ovpn-192-65.brq.redhat.com [10.40.192.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1898E40CA41F; Fri, 21 Oct 2022 15:36:12 +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 v12 20/46] KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id Date: Fri, 21 Oct 2022 17:34:55 +0200 Message-Id: <20221021153521.1216911-21-vkuznets@redhat.com> In-Reply-To: <20221021153521.1216911-1-vkuznets@redhat.com> References: <20221021153521.1216911-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747312182121965245?= X-GMAIL-MSGID: =?utf-8?q?1747312182121965245?= 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; }