From patchwork Fri Oct 21 15:35:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 6780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp765759wrr; Fri, 21 Oct 2022 08:40:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6BpU432wDFNaY3x55Gths64J36jWCAgPFF2uVABtkJ2Osvgvsp5DQ655f4kuPwV1i3xWzG X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr17537084edz.301.1666366809511; Fri, 21 Oct 2022 08:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666366809; cv=none; d=google.com; s=arc-20160816; b=08SlEltP7J9SfDCI9IWLtxRVu+gTaKY6qtt5/hM8ryzGOtUWDpH4iBHCLBTtVuX7uA cC0RQ6FEUBioa4wOk8lmOgtCcsXVFAmovDPJ1QHQQOWVhcgTlU1ULYv8TfdvfWh4zIjH DAO28jGxTg7Km41MsFShkAHg+CtfVpZ/rsqV8HALGia5hirYJ8LUyXGNvP+vbgJwC76v BKy4OJcg6SK2wXDUUJUdaZsDZtv2udjasP7mgby0C4ldOlHn/DMzHJimlpZJQs8QA6/w ivfbT6mBynZHhoHn2u7DGVeH4iTQEkTxaSkavRnZmmErAxP3KHvCgkhUkpWoDw2/JMmJ W5PA== 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=3NTZgRl5rgACD9+VWGUisahxCG4LNBN8j1dAJ4aXMwc=; b=UglrZnii6o5HHVGh2EoWY+tjnP0jUecm0XzWQ0OPX3oQzwEpktAq1olsLF5NsFcu3g IU3VaKRqc0pPXP4ss2kxkLESMMfKae8xO1ccfkx9hoen6ELyHaNB4qNU2qIYOvvfReBm 5ND7khNF3iZOyF8Pg8pqDXmWOj21Z4MHAX6UUT/WteWFEXrc55eJzYhXyd+83ihf8dhE LUu2XoVmv+yFdp/jKs00nKmGE9tZ/HyTaci+yRXNrcG1ytwKr6Rm6zA7VHSnpwFdVa01 1ZHTJ6Q/MG+ucf83y9Lj9H+uLdQMa4tulfb3SYXqmNjMPKgEeqj/uNYV1BkZXDZX94Oo twpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WvZWrTAF; 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 gb22-20020a170907961600b0072fc714c92fsi21646527ejc.902.2022.10.21.08.39.44; Fri, 21 Oct 2022 08:40:09 -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=WvZWrTAF; 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 S231225AbiJUPi1 (ORCPT + 99 others); Fri, 21 Oct 2022 11:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230381AbiJUPgz (ORCPT ); Fri, 21 Oct 2022 11:36:55 -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 5038E26DB3E for ; Fri, 21 Oct 2022 08:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666366595; 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=3NTZgRl5rgACD9+VWGUisahxCG4LNBN8j1dAJ4aXMwc=; b=WvZWrTAF21HkdY8yXWz7JLeb+w9IWxHO2gYmD36t/B8c9BHra57SA5zvQYEr0Yh6brhlNW PR0A+ybfc9JmXdBbMerahivS+CJWGs/wNcfavwi2bTs0JX+9+5YkJiUp1wEInevD0cL/Jh n/5XwyrnGZ87p8TIWOe5gN3zRpZmPvo= 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-610-c6s2Fb-tMfSIOkXTs2JMWQ-1; Fri, 21 Oct 2022 11:36:32 -0400 X-MC-Unique: c6s2Fb-tMfSIOkXTs2JMWQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B38AF3C1E721; Fri, 21 Oct 2022 15:36:31 +0000 (UTC) Received: from ovpn-192-65.brq.redhat.com (ovpn-192-65.brq.redhat.com [10.40.192.65]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7EEA40CA41F; Fri, 21 Oct 2022 15:36: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 v12 27/46] KVM: x86: Make kvm_hv_get_assist_page() return 0/-errno Date: Fri, 21 Oct 2022 17:35:02 +0200 Message-Id: <20221021153521.1216911-28-vkuznets@redhat.com> In-Reply-To: <20221021153521.1216911-1-vkuznets@redhat.com> References: <20221021153521.1216911-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.3 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747312243392409931?= X-GMAIL-MSGID: =?utf-8?q?1747312243392409931?= 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 90f37e58a9ed..404e1a968b02 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))