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 6C09CC6FD20 for ; Fri, 24 Mar 2023 15:17:03 +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=PCAFEXNmU4BK9muNruuIe0m8LK58Pob+5gKs6vyWoN8=; b=iYTrtB26dtZF9k bs5aJdxXO9faKRzjXRjOfRgM9TA9TtxcT0ipQ1QJpPlWqVaSicrMDdLzGV7+PnwQnYiyQUUc0FmB1 jiDfOt58tXGpzK3GArQZ+dwbaUGmST2Ll1PyqkL4kdu8yYYKOV//efF3bgnN0ip6geaIXKRrr2OBW wVemFhwFjIqoVQDdL+qtrOBnBCc6zwt7d0HcwslhHZOOjgZKfvyPymyopSBObs1qdIMH4XvLM0Ff4 F/sfgvzgwfbn2/PaHuv4eQ/6tykL8DalJFtdJNYaVBz83joQZnNuZzneCdKRVOdWcBU+/RnmDSNiF 7JkpLb79fPAtGnYdZUUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pfj4M-004lSv-0S; Fri, 24 Mar 2023 15:11:06 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pfj4F-004lOR-03 for linux-arm-kernel@lists.infradead.org; Fri, 24 Mar 2023 15:11:00 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8771C62B5D; Fri, 24 Mar 2023 15:10:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC22DC433EF; Fri, 24 Mar 2023 15:10:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679670657; bh=d5w/0sfkh44NdYDUsZ4zlkAagu8vzvh1sveYsdMQVFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xm2DHCfZtNt2Ff7ELEUqe0qnDjJg/7lYkzJUk2/8dY3w3SdocDsW7X5Z7cywP54yl h+Bq8J/XyEUGSFWdXGyjBvQtUXUDjzKAjogMuiw0URBfKseQPaHL547LujDhr1me3e sYhLf31KiVTZYQF7XoCd0oj/LDQcTXkspsAU9vMYFxvnjDqdgqxuw25X9EHnO3gsGO OSfXKXZcmInUri/BIgKkL0SCeRTTMfiwgf5B5MfaNEfNi1M1dEBe8VoQ/gFqi6/U5z zAhjDxBydP2HLSLPl+FQHu6VZqhntirS2zbTZ3p2nQA/vCImDPAFuKNErwSXvqc23U NV/G/aA90OlmQ== 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 ) id 1pfihM-002qBP-Am; Fri, 24 Mar 2023 14:47:20 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Ricardo Koller , Simon Veith , Reiji Watanabe , Colton Lewis , Joey Gouly , dwmw2@infradead.org Subject: [PATCH v3 14/18] KVM: arm64: nv: timers: Add a per-timer, per-vcpu offset Date: Fri, 24 Mar 2023 14:47:00 +0000 Message-Id: <20230324144704.4193635-15-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230324144704.4193635-1-maz@kernel.org> References: <20230324144704.4193635-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, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, ricarkol@google.com, sveith@amazon.de, reijiw@google.com, coltonlewis@google.com, joey.gouly@arm.com, dwmw2@infradead.org 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-20230324_081059_132876_6F4D9C2C X-CRM114-Status: GOOD ( 16.60 ) 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 Being able to set a global offset isn't enough. With NV, we also need to a per-vcpu, per-timer offset (for example, CNTVCT_EL0 being offset by CNTVOFF_EL2). Use a similar method as the VM-wide offset to have a timer point to the shadow register that contains the offset value. Reviewed-by: Colton Lewis Signed-off-by: Marc Zyngier --- arch/arm64/kvm/arch_timer.c | 13 ++++++++++--- include/kvm/arm_arch_timer.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 11047b3dfb5b..9666e0d0423e 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -89,10 +89,17 @@ u64 timer_get_cval(struct arch_timer_context *ctxt) static u64 timer_get_offset(struct arch_timer_context *ctxt) { - if (ctxt && ctxt->offset.vm_offset) - return *ctxt->offset.vm_offset; + u64 offset = 0; - return 0; + if (!ctxt) + return 0; + + if (ctxt->offset.vm_offset) + offset += *ctxt->offset.vm_offset; + if (ctxt->offset.vcpu_offset) + offset += *ctxt->offset.vcpu_offset; + + return offset; } static void timer_set_ctl(struct arch_timer_context *ctxt, u32 ctl) diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h index f093ea9f540d..209da0c2ac9f 100644 --- a/include/kvm/arm_arch_timer.h +++ b/include/kvm/arm_arch_timer.h @@ -29,6 +29,11 @@ struct arch_timer_offset { * structure. If NULL, assume a zero offset. */ u64 *vm_offset; + /* + * If set, pointer to one of the offsets in the vcpu's sysreg + * array. If NULL, assume a zero offset. + */ + u64 *vcpu_offset; }; struct arch_timer_vm_data { -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel