From mboxrd@z Thu Jan 1 00:00:00 1970 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 A0F08C001DF for ; Fri, 20 Oct 2023 19:57:11 +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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rJFiga7AMvWr7V+dUp61d3nXOAAdLjuSStvkJ4Bx6Tk=; b=ViYmznyu5AF+UH 9RY6bHLG2DVYruQZ78Ed8KV4YN2cp2N/W9LvCTlJH9jDhaVP/ABue9qnNP853e8KrvjwE3YV5lM0v 2Vu9Yu1VFklyOPzL5Hkvr2gO53f4V+PCBKbw1hDfgtgJNuhWznqFUVNcKnM7vozkl8xPN9bTASqDF 1IlvkInU/C0fMVI/BnGuc/0BmcMe7UpBxzEJPM6yLMkU1Wwnw7eZMiZQ3/lRO0r9x5rOdqobJvORb tOFh+ZBnDwEFCqZtXggKk6CC7aMnF5oIKs86i5a81tgIElEPvn6IfpiBnWmlH6AQFlDgDiCXDJFho sSD2OryTc6l9rkmjEDOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qtvbx-002wrA-1R; Fri, 20 Oct 2023 19:56:45 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qtvbu-002wqK-03 for linux-arm-kernel@lists.infradead.org; Fri, 20 Oct 2023 19:56:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 62AE8B833DA; Fri, 20 Oct 2023 19:56:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF468C433C8; Fri, 20 Oct 2023 19:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697831795; bh=NEi38A+ZyZuP2q+k1dwMYaiAkpQJpDIG7wKFG/Rp0bo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vMyItrr9P52VmTSH7jcEA/S41cM3c+IXAHi7ZAhMRZxrya7KCWPCglUC5eYrVbQRG Nz/pIjSGedHyulbaeXMhXlyTMgARY0VABd+ixLMAzLnIjDmq6VEuNlgNzSunusl/II E/Sb6dztaLTfuHnZgYvu1Czak5CaGvzC6gQlVsiUqEyfgk70IxClA3q3Shq/VVSPbo 56Uk5Tpqajet+eoOmuQDZlJ2ytmly3Cyg6NOaSNPLiC/95UaYX50UCptzbHUw+P1Vg lO5ifYv2sB6iMNRtv93g61hDB5dACN7JbRRbEq2ZFKZyz0MkTYGbSBp1yWpCA4unud 86cSmh5chsEUA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qtvbl-006Dwn-5a; Fri, 20 Oct 2023 20:56:33 +0100 Date: Fri, 20 Oct 2023 20:56:32 +0100 Message-ID: <87ttql5aq7.wl-maz@kernel.org> From: Marc Zyngier To: Jan Henrik Weinstock Cc: oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Lukas =?UTF-8?B?SsO8bmdlcg==?= Subject: Re: KVM exit to userspace on WFI In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: jan@mwa.re, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@mwa.re X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231020_125642_225227_85FF0CC4 X-CRM114-Status: GOOD ( 16.48 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jan, On Fri, 20 Oct 2023 19:45:05 +0100, Jan Henrik Weinstock wrote: > > Hi all, > > I am looking for a way to have KVM_RUN exit back to userspace once the > vcpu encounters a WFI. It seems the kvm_run->request_interrupt_window > flag is currently ignored by arm64. Well, that's consistent with arm64 not being an x86 implementation. We can inject interrupts any time, and there is no notion of "interrupt window". > So my solution thus far is to > patch kvm_handle_wfx in arch/arm64/kvm/handle_exit.c and return to > userspace with KVM_EXIT_IRQ_WINDOW_OPEN - working example attached. > Any chance to get this (or something similar) mainline? Certainly not as such. For start, this won't hit all WFIs, but only those that actively trap. And we don't even *try* to trap WFx in a number of cases (vcpu alone in its run queue and/or direct injection). There isn't even any guarantee that WFx is anything other than a NOP (it is architecturally only a hint), in which case no trap applies. So your "working example" really isn't one, as the architecture doesn't give you a way to do what you're asking for. If you want to cause an exit, writing to 'immediate_exit' and delivering a signal is the way. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel