Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp482331rwb; Tue, 4 Oct 2022 06:45:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QJocga1aIS1ckAe3tquru4R25N1/4u8cHY3kInAc1qin6ECA02LykXhr48THL4U7GAAy8 X-Received: by 2002:a17:906:2bc7:b0:72f:dc70:a3c6 with SMTP id n7-20020a1709062bc700b0072fdc70a3c6mr19405456ejg.645.1664891151103; Tue, 04 Oct 2022 06:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664891151; cv=none; d=google.com; s=arc-20160816; b=IilwOKthMOQ7m6ASZWhaBTGf2UlnuYFQ3eCv5HovvfGcpVon6DIZ1QhYStWMkKiKpp nkE3NU9ATjrrYsY1ND4jWW0YuB21t1N5v8qgA3ynU3Gx9ybD1DsTmGcUheJsjQ3s5VRM iGq7Bs+G/G8BtRwEAWVr3s0ribBrJRIRK2lt6/c3s3USYCHnDrNVUJXlrD+nfMgemsSK H/R/5u+GSXEiqdY2OmRb6XtT0cLnLIs3rGzaLKGSQFCGswkQCx3M4g3zG7svBbY/pNH/ ajFhqa6z8YfyOEAI9baBZts3UZyfrlCFK6N0h81MSH+NCFdB6w7F1HmR11qHEF2TJ3Ds loUQ== 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=27w0Xf6KPC4Fsi1BOos8sj3cpjd7912e9dNdzVM+f78=; b=lcmIOtKcAQ1KIbSRub5JUQ03M4LjRjijIeHv52nJRhovtadqwQ9FHV7J63uTZXgtTz WWoZ4GBoWAauXHpNitrfOMcSHOpvxuvgeKLX0JmT2fFFWBQUH3CIEeOKdvbjq+osuWWC N4lScVOZDig+lxRJDT55f8xhspegtOdIwdzPGW5RNYP1NdqmBPtm8wDqf3MoNYfrU018 Q4Qbih15yqzEmmRiMZvZC3xu8eAzW9kGlsILbTp9SIcTeEvJz0ptgG6/NGtNyUNUFIVA MVmpCA8jsn/9P7ccZBTe+k7ducH5AwvF7KhLb/E4KUR9dYnRRGS+BXbSyWNa3bqkB6cP ERDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b6r9w+6m; 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 b4-20020a0564021f0400b00458b4bebee5si7459220edb.406.2022.10.04.06.45.25; Tue, 04 Oct 2022 06:45:51 -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=b6r9w+6m; 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 S229675AbiJDMlu (ORCPT + 99 others); Tue, 4 Oct 2022 08:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbiJDMlU (ORCPT ); Tue, 4 Oct 2022 08:41:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B64C617054 for ; Tue, 4 Oct 2022 05:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887237; 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=27w0Xf6KPC4Fsi1BOos8sj3cpjd7912e9dNdzVM+f78=; b=b6r9w+6m/Lz9Ir4T4REQl9G0NKB4owMXk0VVydxRtYw4PsaRYIhFTbdGtLNJyGs+0024Xw NEl+szYr7nXI1dJOmvbtfJprVPhlVW0Wmz2pbj926h+RI7hKR2MC3Lmya5hc3qyFMxvpg7 TiFnVJQyclsf+BwZC8nEU/pwA0boNsc= 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-86-dt9C2oavP-msF-JI9B0MGA-1; Tue, 04 Oct 2022 08:40:32 -0400 X-MC-Unique: dt9C2oavP-msF-JI9B0MGA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06DE1855305; Tue, 4 Oct 2022 12:40:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2A517AE5; Tue, 4 Oct 2022 12:40:29 +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 v11 13/46] KVM: x86: Prepare kvm_hv_flush_tlb() to handle L2's GPAs Date: Tue, 4 Oct 2022 14:39:23 +0200 Message-Id: <20221004123956.188909-14-vkuznets@redhat.com> In-Reply-To: <20221004123956.188909-1-vkuznets@redhat.com> References: <20221004123956.188909-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.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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 9ede23e881b1..215d6cf09f21 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