From patchwork Wed May 4 03:24:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12837101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 918A0C433F5 for ; Wed, 4 May 2022 03:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HbqVJ9zSCFKR9zum+bZUJS9+HqyOBgyDmQIzD5xxfiM=; b=c9ZwTQ/+/ML6lsetWIuhNYoNKn +xsGdMyp8/MpKxM5OumgaOyJCZjbqXYCJZ+xp4vAKUg/F6ZZj7hU3u/4MU+f+dUtugbeLLnTWLDEM yRvHv2Xii3TigUIr4hXilV4NzfLCQZg7sBKkX9pFDau7zbtZnR5NEhJVanqRA3UAYpElwi8ctUBE4 HPpnfXTJyfDsw66OUBv1IsaMXgrYiuV1c2rBvuE3cnQIrdljAA5kAx2H3k2U++NR2RgY4hfy8+9c5 2xqwyfuWA4+Z5D/JDWNHok57fdfnm3M1u7N8eBBy5Z4f6LNkFwdStTAMId3a9gNAo2NszdshGGTS/ En07gPvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nm5eL-008Z3z-Hg; Wed, 04 May 2022 03:26:01 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nm5dP-008YNo-S2 for linux-arm-kernel@lists.infradead.org; Wed, 04 May 2022 03:25:05 +0000 Received: by mail-pl1-x64a.google.com with SMTP id k2-20020a170902ba8200b0015613b12004so133900pls.22 for ; Tue, 03 May 2022 20:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+AoiNQohcEBqsbFrIdWlY/jTmle8ckchXi1SWA9QWT4=; b=kav6fAe1UysMDmLFspwmQhdq94eATQWRRD1D9FV5BfsaCSNOmOrjNgw6Ih/qFB2hFP KkA0WphPrzKlAu7jLnUAmQlX9FxYxSL5XR/uR+7vhqMeF14/CJ1Lt7Kk8/RxOE8/HMsv 9JA82R2w68LQCsjI+e2gky3CzbW1HNlOH5uc/fpUkHWRQJ9nbE4Edyxw55yDZ4+3d6AW 5DowfDS5+gFo08tAcOKj+dsadR4mQG1ftNfhXsKGd4iAq4zK/Abw/PW3qZYMuB5D+YT7 AtmKcQmParWgFNt2qlDPmkDx4K/08wQcTSDWA15Oj5c4uttCowpHBr0chaueffn/vOC1 S9fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+AoiNQohcEBqsbFrIdWlY/jTmle8ckchXi1SWA9QWT4=; b=Z+l3JIjr2YjV4SAPPgcrcFzKUAkkx0Ex5038EEWsE2+JfU7F+L+zWqAVjv8lilRTg6 TtXmLmIT1VefrPEelydrrnZzVRF6ksodIqUYT7bSMZQwPXSXPJlsMrS0ViKDANmiu9r2 2hMkzqD28/QdhTdpoV/NAyrbwMhmvbIU3g2wa4PuanQP6fZLqxs31GnxEeqyKNEEdCmC 3p3tfxlDPCh+25Il/qS+E9kJOdr0LPpmHGXLdHbbeFP3VzC1ZfnEEdr71pmJD4o/foVx ZQ3XvWyiwpKKpiTpq2PrHJbMRH3J1YvTr/Z++XyAv1r68WrxxQmKirhwrs0++QSGj4Ai kh0g== X-Gm-Message-State: AOAM531yOgHTieqiDmxC4v1sTB3ua2BdvNdBifosqtdzhjcKgSMl1nDR zdt0W/33oO7sJCTLUiDysLxj3jFflYc= X-Google-Smtp-Source: ABdhPJw5sIvY/+awP297IVop+k4KJmX4BmEL6dH1itNwUhQj0x3knFEX3fPK00huIqDZftTudy2YPYs+Wk8= X-Received: from oupton3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:21eb]) (user=oupton job=sendgmr) by 2002:a05:6a02:197:b0:382:a4b0:b9a8 with SMTP id bj23-20020a056a02019700b00382a4b0b9a8mr16376625pgb.325.1651634702101; Tue, 03 May 2022 20:25:02 -0700 (PDT) Date: Wed, 4 May 2022 03:24:39 +0000 In-Reply-To: <20220504032446.4133305-1-oupton@google.com> Message-Id: <20220504032446.4133305-6-oupton@google.com> Mime-Version: 1.0 References: <20220504032446.4133305-1-oupton@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v6 05/12] KVM: arm64: Return a value from check_vcpu_requests() From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, reijiw@google.com, ricarkol@google.com, Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220503_202503_956080_2BEBFB4B X-CRM114-Status: GOOD ( 15.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A subsequent change to KVM will introduce a vCPU request that could result in an exit to userspace. Change check_vcpu_requests() to return a value and document the function. Unconditionally return 1 for now. Signed-off-by: Oliver Upton --- arch/arm64/kvm/arm.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 77b8b870c0fc..efe54aba5cce 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -648,7 +648,16 @@ void kvm_vcpu_wfi(struct kvm_vcpu *vcpu) preempt_enable(); } -static void check_vcpu_requests(struct kvm_vcpu *vcpu) +/** + * check_vcpu_requests - check and handle pending vCPU requests + * @vcpu: the VCPU pointer + * + * Return: 1 if we should enter the guest + * 0 if we should exit to userspace + * < 0 if we should exit to userspace, where the return value indicates + * an error + */ +static int check_vcpu_requests(struct kvm_vcpu *vcpu) { if (kvm_request_pending(vcpu)) { if (kvm_check_request(KVM_REQ_SLEEP, vcpu)) @@ -678,6 +687,8 @@ static void check_vcpu_requests(struct kvm_vcpu *vcpu) kvm_pmu_handle_pmcr(vcpu, __vcpu_sys_reg(vcpu, PMCR_EL0)); } + + return 1; } static bool vcpu_mode_is_bad_32bit(struct kvm_vcpu *vcpu) @@ -793,7 +804,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) if (!ret) ret = 1; - check_vcpu_requests(vcpu); + if (ret > 0) + ret = check_vcpu_requests(vcpu); /* * Preparing the interrupts to be injected also