Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp474634rwb; Tue, 4 Oct 2022 06:39:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Fy82pzFpk2ni3VcgToWt5+VDvuAWyP6D6cu5/TKw4DqqZyKrKT1yqzQ4yQ2R8Eb3gJLaw X-Received: by 2002:a17:906:58d6:b0:783:a081:7a20 with SMTP id e22-20020a17090658d600b00783a0817a20mr18940038ejs.357.1664890789784; Tue, 04 Oct 2022 06:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664890789; cv=none; d=google.com; s=arc-20160816; b=0YzBKnIpSNsnbi9kx5I9FimaBxv9hauwhifFUW9dM0hlHlXaig31sFlZfTjzFyJYj0 PJfiG2Vha6p3j4qxcQn8KIRbX82G1LrRRsO9hr8XsGJpxwybIh/w3IbGiONmfd/u7boz aoThPA3+wfjPM7CQL8X89iUr0ZfemFBephTtXggPeRKeamTVTkd/fkfoH72oaJCHUZ3j FOlELgIOHmmihGam4kwB2ZF0cqKDXA/oZNze/1X/tdX9y2z1nUMufsngGREyGqqo6BoB vVdKecacmJAGUM34iedL9Av2jHJUQnZwPxBWCCfuZj7v8L9bRqEjVAkZl6T5MX1S1D1s ax/Q== 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=XZ9SBNHMNy76zk4qS6397ZWYYGUY4rVD78M8UVsfZSI=; b=OMoervI2y6EaCXNuxf68DNLNhFBG9rQvF8I8hrAhfDhXOv2jG7vBDt6bbwxM6zRW+v 8c3kAT3u2grATVtZoDClRx9vDgbRBc/qvctdRQeT/FV21OsPFzFQLXkcye+kkerin1Ei u/QwFz96DVh8EzvPm7RLD1+EhIkzXqrWb5PLDILXGM2xOwVvIZKPDOp2mRyCEZJwlnJ0 R2Wlge/T4tcoimpgDZAIbqgnae3YIGLRCLXFFFZTQywbgOsq+feF9fua8efeTIivlUGV gVfUIne7qfuBls5JYeDu23epI03rNiZ1uhkkJDLUPJXOlQld3SFWHpYMIIswJUCItR5g lYhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BslvWC5m; 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 lc23-20020a170906dff700b0072b7fac8a7asi9882777ejc.926.2022.10.04.06.39.24; Tue, 04 Oct 2022 06:39:49 -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=BslvWC5m; 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 S229698AbiJDMn7 (ORCPT + 99 others); Tue, 4 Oct 2022 08:43:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbiJDMn0 (ORCPT ); Tue, 4 Oct 2022 08:43:26 -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 A64D05B07F for ; Tue, 4 Oct 2022 05:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664887269; 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=XZ9SBNHMNy76zk4qS6397ZWYYGUY4rVD78M8UVsfZSI=; b=BslvWC5mpc2WmLv3/vRyv2gfPCHosm+5u8AYoFmL2LzJUjdwL1InyEWcGXKfRu96vnsF6m PxpNe9oOL9kOS/fIO5cwfFVRbLM4BbYwyYbTSMmfxJZpVNKAp9bpihHON1zHlqZ4JR38Eg TKiPCdcTXQRrn7a3g8iG3KdR/+jE6mE= 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-314-cidckHfYPoaGU8bquPSGdQ-1; Tue, 04 Oct 2022 08:41:06 -0400 X-MC-Unique: cidckHfYPoaGU8bquPSGdQ-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 D3C2D185A79C; Tue, 4 Oct 2022 12:41:05 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.40.192.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFA5717583; Tue, 4 Oct 2022 12:41:03 +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 27/46] KVM: x86: Make kvm_hv_get_assist_page() return 0/-errno Date: Tue, 4 Oct 2022 14:39:37 +0200 Message-Id: <20221004123956.188909-28-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=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 Convert kvm_hv_get_assist_page() to return 'int' and propagate possible errors from kvm_read_guest_cached(). Suggested-by: Sean Christopherson Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 8 ++++---- arch/x86/kvm/hyperv.h | 2 +- arch/x86/kvm/vmx/hyperv.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index fb8fd54a9498..ff56983ea2db 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -900,15 +900,15 @@ bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(kvm_hv_assist_page_enabled); -bool kvm_hv_get_assist_page(struct kvm_vcpu *vcpu) +int kvm_hv_get_assist_page(struct kvm_vcpu *vcpu) { struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); if (!hv_vcpu || !kvm_hv_assist_page_enabled(vcpu)) - return false; + return -EFAULT; - return !kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.pv_eoi.data, - &hv_vcpu->vp_assist_page, sizeof(struct hv_vp_assist_page)); + return kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.pv_eoi.data, + &hv_vcpu->vp_assist_page, sizeof(struct hv_vp_assist_page)); } EXPORT_SYMBOL_GPL(kvm_hv_get_assist_page); diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h index 81313e418b80..5157622c2fb3 100644 --- a/arch/x86/kvm/hyperv.h +++ b/arch/x86/kvm/hyperv.h @@ -108,7 +108,7 @@ int kvm_hv_activate_synic(struct kvm_vcpu *vcpu, bool dont_zero_synic_pages); void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu); bool kvm_hv_assist_page_enabled(struct kvm_vcpu *vcpu); -bool kvm_hv_get_assist_page(struct kvm_vcpu *vcpu); +int kvm_hv_get_assist_page(struct kvm_vcpu *vcpu); static inline struct kvm_vcpu_hv_stimer *to_hv_stimer(struct kvm_vcpu *vcpu, int timer_index) diff --git a/arch/x86/kvm/vmx/hyperv.c b/arch/x86/kvm/vmx/hyperv.c index 04a0bba58c7d..ae03d1fe0355 100644 --- a/arch/x86/kvm/vmx/hyperv.c +++ b/arch/x86/kvm/vmx/hyperv.c @@ -326,7 +326,7 @@ u64 nested_get_evmptr(struct kvm_vcpu *vcpu) { struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu); - if (unlikely(!kvm_hv_get_assist_page(vcpu))) + if (unlikely(kvm_hv_get_assist_page(vcpu))) return EVMPTR_INVALID; if (unlikely(!hv_vcpu->vp_assist_page.enlighten_vmentry)) -- 2.37.3