From patchwork Tue Nov 1 14:53:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 13710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3021045wru; Tue, 1 Nov 2022 07:58:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OhE8sE/VGR3CPl6pJOpN1b0NSwH0o0tggEQeMTvTdY1kZZPLDcl4rvMR6YRiBWCvwqPLG X-Received: by 2002:a05:6402:5c9:b0:446:fb0:56bb with SMTP id n9-20020a05640205c900b004460fb056bbmr19896580edx.173.1667314730127; Tue, 01 Nov 2022 07:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314730; cv=none; d=google.com; s=arc-20160816; b=uzNLX+TD/Kkdoxb/QEzI6p0dZBid1Rd6t2FyXrvlSkFMe3oND1WF9bj20DM07vfYXD b8lcgfphqXXkFH3+KB/6I/Wo1BTBC+c0nylBc9dJm8x6EvWn2J1KwR5MN1t5QAdxIMRO 3M9BA8dOoyn8/B5bMzVeht+kcyR1JOWbhYQFG74BWcqutUBpaJgyVVShMtAEQD4I/K8k 0l2K/CCcysXOrbgrIw7l+SpkISNr5B7KBFkilFf31NsiygBGt5YLOAWwVHgeGZ2Ho0C5 i7pinbooERGRg6AjFWb4YTtwSNfG8AzkYBe7zK52H38HHr8iZgbqdLTdGYUhLpX7ruZO /Dvw== 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=o7HJKd/tb8dCsA2/QRkG3g5/WdjkirIaLyQWbjGL3dk=; b=ppobo7xQdBxAb3edYP5HPll6xGaST/5hwPSdQn/n8dBUQIIUbH33mpqzqOYqnFkU9t jmiSVRaU5TeBpfgQpUq3D/c1b2JeNZNoj47vgWBaSo4jAHtSyJOOqbDnJMPb/nyifg/7 3KybB90BiCg+bTpVblaGEGaEgm0JcOBtKXTKlW/3I75TuqDHV00yDl69eR4VH9mIOfRq n0OM8aDWLRxhyd+Kbm98end8t0FZuFgx206V41Yx32jTT1waMbBV16qeSm7UPrzthOf4 6oHo7j+O4M6byRJ3cjVOgaSSk10JtyXPDQtP4X+uthouKrUXb3fAs8WpRQ+ixZSH3+Wl 0oGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A+tTrNxw; 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 l19-20020a170906795300b0073d9ea386d4si12785587ejo.983.2022.11.01.07.58.25; Tue, 01 Nov 2022 07:58:50 -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=A+tTrNxw; 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 S231284AbiKAO5h (ORCPT + 99 others); Tue, 1 Nov 2022 10:57:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbiKAO4r (ORCPT ); Tue, 1 Nov 2022 10:56:47 -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 69EA91CB34 for ; Tue, 1 Nov 2022 07:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314541; 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=o7HJKd/tb8dCsA2/QRkG3g5/WdjkirIaLyQWbjGL3dk=; b=A+tTrNxwQm5deKYcXkjRygT+kk4ro0mz8DNe+az1zi0ujVJ67Y6v742632lIGu2GXLe29c kfhnFLVJ20hJqrk+eDo8GOWMchsSeNypA9gfoJojhXw6OSdOu9dm7pFTf45gGt1nYWMpEm 3yZ9c6uG7E+WBaApCHcXmFYptpYW0Ec= 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-663-szFVJqWoPG2C8uQJ54xDhQ-1; Tue, 01 Nov 2022 10:55:38 -0400 X-MC-Unique: szFVJqWoPG2C8uQJ54xDhQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 684E029DD9AC; Tue, 1 Nov 2022 14:55:37 +0000 (UTC) Received: from ovpn-194-149.brq.redhat.com (ovpn-194-149.brq.redhat.com [10.40.194.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCF2BC3E6BC; Tue, 1 Nov 2022 14:55:26 +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 v13 20/48] KVM: nSVM: Keep track of Hyper-V hv_vm_id/hv_vp_id Date: Tue, 1 Nov 2022 15:53:58 +0100 Message-Id: <20221101145426.251680-21-vkuznets@redhat.com> In-Reply-To: <20221101145426.251680-1-vkuznets@redhat.com> References: <20221101145426.251680-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-3.1 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748306210370717713?= X-GMAIL-MSGID: =?utf-8?q?1748306210370717713?= 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 Reviewed-by: Sean Christopherson 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; }