Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5514334rwb; Wed, 21 Sep 2022 08:47:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AnYVVhVKn5LMbETURN91sOb+cUE3/S3YuKQ0avFaDi5yk8MylifBgwmXSz6Y3lmWwtnEd X-Received: by 2002:a63:5852:0:b0:438:6d70:228d with SMTP id i18-20020a635852000000b004386d70228dmr24708329pgm.485.1663775235747; Wed, 21 Sep 2022 08:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663775235; cv=none; d=google.com; s=arc-20160816; b=DSzPZdomofF1ds4MHa3gwL7kv15ln5LYcsHjRDDgzj/aoshmn0BK/iURKlWqA6sTkU g+NlIMhwOuvOoaJArePO+uHsUfrTmw/eHF7uduadvuU2GUI238CM2gElZsVI2IsRBGiS nJeW3Ja/P/ltwstF4i0h0c92nbc6W4SnuIwyR0L4zY3mXH+ZEKN839sL+DxCBQNfLk/g MVC6+aLK1gUYWqf2liNCosJ4eBffcp4kZZgvNxVHlmAcMTMmyghynEDqThA5KEeXtGAh FbjNWlMwVgVThAYQzdQv/hH0qGrbNDt9kn0F2Q6tkS38aFVe+x9oOaYy/RvexG66+Lcw Hz7Q== 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=+8XGg+GrKhCOSoWfamw/FpUWoydPOzPYZEnB/VinLHk=; b=hvmCfJEViqmUSW4CCuGgI+0bRudhm94aw+pRbnbdU6ns9Gv3ahyv5qbJGwlpSzsXHL Qy7Hm1dmQmKCsxn34hBApixyTM/SmqpF0SAfcO/+RV3p4JQiI8IdW+cv1B03VJtE2c3X y4/ekk+ZAsbCc5WMRNO7sdn/cCtVqHYU864O498nmYzW599tgVmXLb91pa4FrGIJFABV JC7oXKlJFQ1KNYmxOYI7CFp8BEz3wWdPk6TUQIZLM/66xUV9IwwVxQSJUxCLpQ7bCUxA tOsDtupSVleMv+8/5stPTDEEe3cI4IWSn3nqsVelsXaq0Qa2h2Nt3vdRKzrcPTCh4Wcw MfJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I3Yh0Nhu; 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 b65-20020a633444000000b00430ab3a0357si3205250pga.234.2022.09.21.08.46.55; Wed, 21 Sep 2022 08:47:15 -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=I3Yh0Nhu; 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 S230038AbiIUP0C (ORCPT + 99 others); Wed, 21 Sep 2022 11:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbiIUPZ1 (ORCPT ); Wed, 21 Sep 2022 11:25:27 -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 2F0D678201 for ; Wed, 21 Sep 2022 08:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663773913; 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=+8XGg+GrKhCOSoWfamw/FpUWoydPOzPYZEnB/VinLHk=; b=I3Yh0NhuXXmUO0AtOLnLkhdC1fw6AV+fOGDJprRCXj70BKlYWA1GxFPxG0h9e/A9+kCm8W VoXe7AafcfYqBUxcPIy4mxCX77NaTEa+2IDa73YuNVDQm6wrXG9EeT7UUEGVZp0vQUfgez vrPY19YOXdmbvWyHPUz1sCN8BesSIaI= 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-639-EEIxbrj9M6uL3Qcy7l5Pvg-1; Wed, 21 Sep 2022 11:25:06 -0400 X-MC-Unique: EEIxbrj9M6uL3Qcy7l5Pvg-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 E3A1A87B2A2; Wed, 21 Sep 2022 15:24:59 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.194.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id E83562166B2A; Wed, 21 Sep 2022 15:24:57 +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 07/39] KVM: x86: Prepare kvm_hv_flush_tlb() to handle L2's GPAs Date: Wed, 21 Sep 2022 17:24:04 +0200 Message-Id: <20220921152436.3673454-8-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 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 Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index aced2b3fe56b..ad2560914a5f 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 @@ -1909,6 +1910,12 @@ 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); + 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