Message ID | 20231120131027.854038-29-maz@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 0A1DAC54E76 for <linux-arm-kernel@archiver.kernel.org>; Mon, 20 Nov 2023 13:14:46 +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: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nPek7EL9GjUBhplJdrIVBDzPkpwjnWsjRkr9nE1jM+M=; b=QKmDzzXWb7Mi4N DS4MHDGzKoQjp1G4ZxbxQVnHoMIlaF1kd83MIg/AfB0W7eoRguQQ7bFouWit5HU2crKtw/CQ8uF0v wL4U00fNcerYHsV02uc6fhhDbcp7zZKjsAal6s6x4wfg1KRpCTyVyg57EN/c4Y5V2swa9fYjquWi8 XlPFpDKUgUzQk2IQC1VcyzaCLmp3Z/I37+qR9lGEpCLhHT/Bc/xFe1ugENTDfy/wqWuvXGLx1YzNu zPsGMIe/tqZCvDRXrNnlycgHBixLPnXa+s5//TjnqxVQ3x3R4zP3QYfYkylGhjni4ArlmGuybKqMv o8FkOTPl4PQCbAyOERuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r546K-00C5vI-2f; Mon, 20 Nov 2023 13:14:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r543T-00C4kz-2B for linux-arm-kernel@bombadil.infradead.org; Mon, 20 Nov 2023 13:11:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Ap9cEhShyp+yGDLsyv8dlY0rjMmOYXWJ9zvPN5hjsmg=; b=n+z752xw1s//VEhzz8WwseRgKw zvsU1ZVGGSUDGhUbSnoRCKr0Up7KfCBt/YbnRkNw2S07s5Vkd6jiIm75cdgMnu5kFP5h8RWhwRSmq meMTz/TRCVImlZze6T7PpBkq8ZmU9MGc/yjaGygYj2ZjGx7uRo7N3HRQscfne+AGgGqJelKyxOPOS zYtm3irrsghnM2IcxeuOKsyRMZXOw0AKU8oghlzm4MJu23t31G6XHTW26VjC48RlVGSSwkP+RY5Hx ztM8gI2sha96aYbfEpRI9U5DzHOaJL2jPPBisiuscd0h9HmNnUqLVs5KY5t5CVOKUcHjAhy1b6I+z qc6Mcawg==; Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r543M-00AyEr-0Q for linux-arm-kernel@lists.infradead.org; Mon, 20 Nov 2023 13:11:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id D5E5DB8171C; Mon, 20 Nov 2023 13:10:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16470C433CC; Mon, 20 Nov 2023 13:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700485858; bh=5DBiFNgj+CREZmY9jeeRQhQKYcgewSdvLDerRT8EBow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cgurBvk+NHNAqalG1NLzymPZ3yNuahqZ8KWV/fKJ1CQfeQ4LEynSrTE0dsjRy8Hqw DyfJB9P7VNkX2kf3KpiBpQnEe0jhQRjgjdSBhGqexZXiUCTT1ndyxhGTXQ97LmZFNh USvoSR7v2OqzIZPsQgD2DbtK7Jo30HmZQZEOymDk/3Ws09fnP3174i30lhI3c2GP4x n2P9lUZLuTs3N7lFoUB49aKl4BswKi63WqSvX0JN00lEPI6an4mnnHZ6kKQIZGSp0q jt6BwuNeQWIsHD0nWAOC1EjFu+x63srsdf/PaqomnsbaoW+yJKV4OvgNZUGYzN1I5N aHPy2he7kaTJw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <maz@kernel.org>) id 1r543E-00EjnU-97; Mon, 20 Nov 2023 13:10:56 +0000 From: Marc Zyngier <maz@kernel.org> To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Alexandru Elisei <alexandru.elisei@arm.com>, Andre Przywara <andre.przywara@arm.com>, Chase Conklin <chase.conklin@arm.com>, Christoffer Dall <christoffer.dall@arm.com>, Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>, Darren Hart <darren@os.amperecomputing.com>, Jintack Lim <jintack@cs.columbia.edu>, Russell King <rmk+kernel@armlinux.org.uk>, Miguel Luis <miguel.luis@oracle.com>, James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Zenghui Yu <yuzenghui@huawei.com> Subject: [PATCH v11 28/43] KVM: arm64: nv: Publish emulated timer interrupt state in the in-memory state Date: Mon, 20 Nov 2023 13:10:12 +0000 Message-Id: <20231120131027.854038-29-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231120131027.854038-1-maz@kernel.org> References: <20231120131027.854038-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com, andre.przywara@arm.com, chase.conklin@arm.com, christoffer.dall@arm.com, gankulkarni@os.amperecomputing.com, darren@os.amperecomputing.com, jintack@cs.columbia.edu, rmk+kernel@armlinux.org.uk, miguel.luis@oracle.com, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com 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-20231120_131104_304993_B2877D4C X-CRM114-Status: GOOD ( 12.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: arm64: Nested Virtualization support (FEAT_NV2 only)
|
expand
|
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index e3f6feef2c83..dba92bbe4617 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -447,6 +447,25 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, { int ret; + /* + * Paper over NV2 brokenness by publishing the interrupt status + * bit. This still results in a poor quality of emulation (guest + * writes will have no effect until the next exit). + * + * But hey, it's fast, right? + */ + if (is_hyp_ctxt(vcpu) && + (timer_ctx == vcpu_vtimer(vcpu) || timer_ctx == vcpu_ptimer(vcpu))) { + u32 ctl = timer_get_ctl(timer_ctx); + + if (new_level) + ctl |= ARCH_TIMER_CTRL_IT_STAT; + else + ctl &= ~ARCH_TIMER_CTRL_IT_STAT; + + timer_set_ctl(timer_ctx, ctl); + } + timer_ctx->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_irq(timer_ctx), timer_ctx->irq.level);
With FEAT_NV2, the EL0 timer state is entirely stored in memory, meaning that the hypervisor can only provide a very poor emulation. The only thing we can really do is to publish the interrupt state in the guest view of CNT{P,V}_CTL_EL0, and defer everything else to the next exit. Only FEAT_ECV will allow us to fix it, at the cost of extra trapping. Suggested-by: Chase Conklin <chase.conklin@arm.com> Suggested-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kvm/arch_timer.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)