Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2523039rwi; Tue, 1 Nov 2022 08:36:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6BmPpIVf0XXxN85pO474M6FsQnML5atIlos6yE7IUTRS83jy2yyGauCwsO/tL4wHCGgHW8 X-Received: by 2002:a63:1803:0:b0:46f:73ce:fe28 with SMTP id y3-20020a631803000000b0046f73cefe28mr17678828pgl.219.1667316971570; Tue, 01 Nov 2022 08:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667316971; cv=none; d=google.com; s=arc-20160816; b=a7dNjLMKxv4fiE13TyrOYUU8mxf63K39G6BT/Xfpdu56xZn4thBjj8er3RienhqiFy tFcBJCA/0Uji0FJsFNEDbL23o6S9F8eImNPGWJsUV7JNB/W6S7Rn+fVyIXOu6WlWfjlP s1oaaMangvHOz+YzQ6KGW5fF6xmhCACp++X1MhKHR/2m2ds+b3qi+VmhnGebKtK2j6yD zFOp37fJJwVMyhM4CuIB4ibNxpD9mHjUyKY01+QTrxNMVZGL2KZe/INFjD8pdD+CVAH2 jisCB+19eJZPlgiYzwLHN/oPVFM8ezWc2HyB+p9C1ozZY4PeD+SqwUAaixHtTcgo/Wnw oo3Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a170902e80900b00184306292a5si14574472plg.229.2022.11.01.08.35.56; Tue, 01 Nov 2022 08:36:11 -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 + 96 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 ); 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 ; 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 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 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- 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 @@ -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) { -- 2.37.3