Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1255361rdb; Fri, 20 Oct 2023 12:56:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHp4Sww1MraJX8a3cSfj1vFqJtWblwkZA37h8pNbxOJ6nT57KES933M82+mqMj9xl6og/wR X-Received: by 2002:a17:902:fa87:b0:1c9:de48:fc78 with SMTP id lc7-20020a170902fa8700b001c9de48fc78mr3086209plb.7.1697831813766; Fri, 20 Oct 2023 12:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697831813; cv=none; d=google.com; s=arc-20160816; b=ijUth7RE7H/xuTG+2bUDtL/P4Sxy0IuZ/94nrCyi/bvYphCsN7d0YmfgRGeSPO7+gm mjh3Z5diEeUq/FuXE8u53ZWeIXwbay5f2JywnrQsoszTAcuFiKz+cp3afscZPscHpvtv LOjEQ4Duzkk/7lib0gWktwxdBw7X03dcD7tst9e8tx8OghAbtcrfk50vJaRul/W9rHxa hzNL2NeW2X+c2ZdQ3OvsqsDj+XPHwTxji5HQQwpMXLNCDOga6lkhy2UAWXON0SwXgDwe PMTCo0Kpst4diUWVADIaJ3veoZ98BPDQzXxya0EroR1eJ2z/8Kt9WWoBau26d6ZBg77r ydiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=JTKDneyFY0WeD/+jRYPk+/8e6ZTGSQ0Tsi/dfP7Oj48=; fh=Zqa9pQKdV1ogoxefhu2MEbaWEHbvjsGDNzwWyUJeGq4=; b=DxbKeFFEcSuPCzC26loAEK29o1smbt6gwSwVKHSOqKRvGFVGyoIjn4VhVQ8Ccs8SFl MZx1zAnQ4SkayFD8TrZpRw9ie1iM60+TqNuZBs+/TuPGVpLCsIIMWi2uiLsgROjOJWDf 6t6vUwPwij2UEWc239fvGxLBBUIkoYkCH65DiVuiKuUX9A+ke/FdPQO4TrWrz1gcFEhM bsSM46F4eLzAxkUQH+DIzSTH8y8bv1Csxgxw56KlJVyUceQP0xCDOrhJac9JirXa75SU 7rn4jJBoeKPQssPQVD8W2gaXWMKBc+EXGQEi7789EUCFzazi4iJRJC2j/xHEOHsUD4Q2 jKcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vMyItrr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001c9ad8ca211si2328349plh.18.2023.10.20.12.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 12:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vMyItrr9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 53A0080620A6; Fri, 20 Oct 2023 12:56:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbjJTT4j (ORCPT + 99 others); Fri, 20 Oct 2023 15:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjJTT4h (ORCPT ); Fri, 20 Oct 2023 15:56:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EC01D52 for ; Fri, 20 Oct 2023 12:56:36 -0700 (PDT) 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") Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 12:56:51 -0700 (PDT) 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.