From nobody Thu Apr 18 18:10:36 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1574698524; cv=none; d=zohomail.com; s=zohoarc; b=DYVR3YbTlaxqX+SujPzEdzfUk/YaOdH71D8V/gXu6UiwQKL9r57BB7+0/4P/LkdlJr7rPFTyMp73sHiOfdXPKh8rKKeZSU+VsxW/nWcUrLtudZg2rQUf7H4WtNHFmuYipaeU7XiFbeYlTOJKCktMzC05d/Jj7spwd1STJKa9Jkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574698524; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=OQLXZrSTZ4iAXmgD9Wf3IZFlYQSBAtWHBD27/MqwsDI=; b=DpMy+cTKXZlx4LsXUIBSIHNjWrjDK/QABvrVdeJyMNty7dJuD87HD7M9XovzXchERyLKiY3I3lCRVp8ERQef4pXSrhnCX69klwJRJ2M58Sp0hOjmlvk2T+gAtheNfj4jY6yf0C2XzK/+vPCArBSoSZgvEmnlBVyTC47FnDaU1tY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157469852482445.24935036661236; Mon, 25 Nov 2019 08:15:24 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZH0U-0004fk-1p; Mon, 25 Nov 2019 16:14:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iZH0S-0004ff-RW for xen-devel@lists.xenproject.org; Mon, 25 Nov 2019 16:14:32 +0000 Received: from webmail.dornerworks.com (unknown [12.207.209.150]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id a70cefd6-0f9e-11ea-b08b-bc764e2007e4; Mon, 25 Nov 2019 16:14:28 +0000 (UTC) X-Inumbo-ID: a70cefd6-0f9e-11ea-b08b-bc764e2007e4 From: Jeff Kubascik To: Date: Mon, 25 Nov 2019 11:14:19 -0500 Message-ID: <20191125161419.75909-1-jeff.kubascik@dornerworks.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [172.27.13.171] X-ClientProxiedBy: Mcbain.dw.local (172.27.1.45) To Mcbain.dw.local (172.27.1.45) X-spam-status: No, score=-2.9 required=3.5 tests=ALL_TRUSTED, BAYES_00, MAILSHELL_SCORE_0_4 X-Spam-Flag: NO Subject: [Xen-devel] [PATCH] xen/arm: remove physical timer offset X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stewart Hildebrand , Volodymyr Babchuk , Stefano Stabellini , Julien Grall Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The physical timer traps apply an offset so that time starts at 0 for the guest. However, this offset is not currently applied to the physical counter. Per the ARMv8 Arch Reference Manual, the offset between the physical timer and counter should be 0. This removes the offset to make the timer and counter consistent. Xen time is at offset boot_count from the physical counter, so we need to take this into account when reading/writing to CNTP_CVAL. Signed-off-by: Jeff Kubascik --- xen/arch/arm/vtimer.c | 18 ++++++------------ xen/include/asm-arm/domain.h | 3 --- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index e6aebdac9e..4790b5ce58 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -62,7 +62,6 @@ static void virt_timer_expired(void *data) =20 int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *con= fig) { - d->arch.phys_timer_base.offset =3D NOW(); d->arch.virt_timer_base.offset =3D READ_SYSREG64(CNTPCT_EL0); d->time_offset_seconds =3D ticks_to_ns(d->arch.virt_timer_base.offset = - boot_count); do_div(d->time_offset_seconds, 1000000000); @@ -184,8 +183,7 @@ static bool vtimer_cntp_ctl(struct cpu_user_regs *regs,= uint32_t *r, bool read) =20 if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE ) { - set_timer(&v->arch.phys_timer.timer, - v->arch.phys_timer.cval + v->domain->arch.phys_timer= _base.offset); + set_timer(&v->arch.phys_timer.timer, v->arch.phys_timer.cval); } else stop_timer(&v->arch.phys_timer.timer); @@ -202,7 +200,7 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs= , uint32_t *r, if ( !ACCESS_ALLOWED(regs, EL0PTEN) ) return false; =20 - now =3D NOW() - v->domain->arch.phys_timer_base.offset; + now =3D NOW(); =20 if ( read ) { @@ -214,9 +212,7 @@ static bool vtimer_cntp_tval(struct cpu_user_regs *regs= , uint32_t *r, if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE ) { v->arch.phys_timer.ctl &=3D ~CNTx_CTL_PENDING; - set_timer(&v->arch.phys_timer.timer, - v->arch.phys_timer.cval + - v->domain->arch.phys_timer_base.offset); + set_timer(&v->arch.phys_timer.timer, v->arch.phys_timer.cval); } } return true; @@ -232,17 +228,15 @@ static bool vtimer_cntp_cval(struct cpu_user_regs *re= gs, uint64_t *r, =20 if ( read ) { - *r =3D ns_to_ticks(v->arch.phys_timer.cval); + *r =3D ns_to_ticks(v->arch.phys_timer.cval) + boot_count; } else { - v->arch.phys_timer.cval =3D ticks_to_ns(*r); + v->arch.phys_timer.cval =3D ticks_to_ns(*r - boot_count); if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE ) { v->arch.phys_timer.ctl &=3D ~CNTx_CTL_PENDING; - set_timer(&v->arch.phys_timer.timer, - v->arch.phys_timer.cval + - v->domain->arch.phys_timer_base.offset); + set_timer(&v->arch.phys_timer.timer, v->arch.phys_timer.cval); } } return true; diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h index 86ebdd2bcf..16a7150a95 100644 --- a/xen/include/asm-arm/domain.h +++ b/xen/include/asm-arm/domain.h @@ -65,9 +65,6 @@ struct arch_domain RELMEM_done, } relmem; =20 - struct { - uint64_t offset; - } phys_timer_base; struct { uint64_t offset; } virt_timer_base; --=20 2.17.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel