Message ID | 20221101145426.251680-14-vkuznets@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3020609wru; Tue, 1 Nov 2022 07:57:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM61h+P9tG99id1ID4eZ2HemFJKjQaSJN6DO4MszUgw6iLRpRzoT/pwYf8Hzj+nZS7U4Jb/u X-Received: by 2002:a17:906:3287:b0:78d:8877:d50f with SMTP id 7-20020a170906328700b0078d8877d50fmr19083891ejw.486.1667314674875; Tue, 01 Nov 2022 07:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667314674; cv=none; d=google.com; s=arc-20160816; b=NAh15Z0qmIuMI08s4B3kQg0yzMdd+FvfOrEo71GCYfdFmMOG4ADr78jhjGDVNAQvlx z2Z7PeXMtRG55V3dAIRq3ztZs/Vzy7+FgSp4/XNCrygua7VfwhIZfjOAhONZ/8gPJbiX uasflWnFYDbzZeFJ2hO4i8uo/NMV52++PXvNI071lk2ceYQuiWIrtfh4ZYB+3v+US7ef lV6K/igH4+S7FYacGWyfRssWJhuZn9YvWD5wV1KjIuBSP1+VZzI3kVi0WvUCpg88IJE+ pynfGb0611hIN+kFXinb8x7/Sk4/YT2DLb8bC+fCf2iXnQUDXXA3qrHpitIQR0GCNz6C Rw8Q== 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=OYQ5cU/60jNuZcycVdq58PLDiIjTc3kSZzYvnPsyXKw=; b=g6yKa9BwSF7SKHYdAEIma/rRMnt17j9Fpoj3wab6q5FhikG3WqQ0D76gyLQRa09f05 JKd0DCIaENye4TJmXxlobj3CLgPVrmcirC71VxYffBwnT04wX8kI9H9fihJeJZ2vb1X4 v4mbqfw9/NilO5iQWiZv2+p5kTDFsBdLyuu9zMZiU8J2vt6PPzygSgQonHTSXe2ThnV3 VopRCds2chTQpVob7e3JSVJXVCC3ct/Yf204ySxxmDcAlxu7hX9dhMb4ECmJvcTrtTa1 POXSSvFZ77DLws0Q7Aq1bXFbCTsb2hpJa/oD1s/1anrjiWsGe4Fxt4f4SwVmhkTUY+Q+ 3Rig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FJmRnDZA; 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 i10-20020a1709064fca00b007adbc807ca8si12182924ejw.137.2022.11.01.07.57.30; Tue, 01 Nov 2022 07:57:54 -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=FJmRnDZA; 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 S231178AbiKAO4m (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Tue, 1 Nov 2022 10:56:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbiKAO4O (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Nov 2022 10:56:14 -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 D3BE86381 for <linux-kernel@vger.kernel.org>; Tue, 1 Nov 2022 07:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667314510; 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=OYQ5cU/60jNuZcycVdq58PLDiIjTc3kSZzYvnPsyXKw=; b=FJmRnDZA98Yxn7gyfLOMRWWWf2hwKvHCMsdNrI0yvKoW5OD+hCTmd9PPh5f1cUpLQ3Jaq3 q2BdhLGfybP570ftnN0fgQBwcxbYSz+mWwW9jOBTs19mTvw+pszBKkBNqMSQpfrC+XW506 UOWCU4Hyakmho4XSRtYBy7MzSfZyha8= 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-639-o5mE9aNPPuC7Tv_K2EB36w-1; Tue, 01 Nov 2022 10:55:07 -0400 X-MC-Unique: o5mE9aNPPuC7Tv_K2EB36w-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 B1A8E1C16EA3; Tue, 1 Nov 2022 14:55:04 +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 56F1EC15BA5; Tue, 1 Nov 2022 14:55:02 +0000 (UTC) From: Vitaly Kuznetsov <vkuznets@redhat.com> To: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com> Cc: Wanpeng Li <wanpengli@tencent.com>, Jim Mattson <jmattson@google.com>, Michael Kelley <mikelley@microsoft.com>, Siddharth Chandrasekaran <sidcha@amazon.de>, Yuan Yao <yuan.yao@linux.intel.com>, Maxim Levitsky <mlevitsk@redhat.com>, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v13 13/48] KVM: x86: Prepare kvm_hv_flush_tlb() to handle L2's GPAs Date: Tue, 1 Nov 2022 15:53:51 +0100 Message-Id: <20221101145426.251680-14-vkuznets@redhat.com> In-Reply-To: <20221101145426.251680-1-vkuznets@redhat.com> References: <20221101145426.251680-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.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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748306152642136423?= X-GMAIL-MSGID: =?utf-8?q?1748306152642136423?= |
Series |
KVM: x86: hyper-v: Fine-grained TLB flush + L2 TLB flush features
|
|
Commit Message
Vitaly Kuznetsov
Nov. 1, 2022, 2:53 p.m. UTC
To handle L2 TLB flush requests, KVM needs to translate the specified L2 GPA to L1 GPA to read hypercall arguments from there. No functional change as KVM doesn't handle VMCALL/VMMCALL from L2 yet. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- arch/x86/kvm/hyperv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index fca9c51891f5..cb145987f5b8 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -23,6 +23,7 @@ #include "ioapic.h" #include "cpuid.h" #include "hyperv.h" +#include "mmu.h" #include "xen.h" #include <linux/cpu.h> @@ -1908,6 +1909,19 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc) */ BUILD_BUG_ON(KVM_HV_MAX_SPARSE_VCPU_SET_BITS > 64); + /* + * 'Slow' hypercall's first parameter is the address in guest's memory + * where hypercall parameters are placed. This is either a GPA or a + * nested GPA when KVM is handling the call from L2 ('direct' TLB + * flush). Translate the address here so the memory can be uniformly + * read with kvm_read_guest(). + */ + if (!hc->fast && is_guest_mode(vcpu)) { + hc->ingpa = translate_nested_gpa(vcpu, hc->ingpa, 0, NULL); + if (unlikely(hc->ingpa == INVALID_GPA)) + return HV_STATUS_INVALID_HYPERCALL_INPUT; + } + if (hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST || hc->code == HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE) { if (hc->fast) {