From patchwork Mon Mar 18 11:20:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 10857393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0C0A1390 for ; Mon, 18 Mar 2019 11:23:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7E332937E for ; Mon, 18 Mar 2019 11:23:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC45729380; Mon, 18 Mar 2019 11:23:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2BC0B2937F for ; Mon, 18 Mar 2019 11:23:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5qKN-0004Gg-HC; Mon, 18 Mar 2019 11:21:11 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h5qKL-0004Fs-NA for xen-devel@lists.xenproject.org; Mon, 18 Mar 2019 11:21:09 +0000 X-Inumbo-ID: eda5028b-496f-11e9-bc90-bc764e045a96 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id e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taKJ8B3OfONUb4HXYNgQN6/ZBY6l0FIoejhwvYRosyJgEVvESF9Sl+XwyLOxfwIntKaOey HV7ok1O5f9ODs7VNcJS0Y7TEeXRa+iaghv6CT4K2bI0HQzo1k21cUZbpwcXRg5OmpH+Vd/pd m2lKfIszGIAOzVfMeCNxp05DDut1uY9N7dvFi2lsesxhD1jt2Y0coO+Dwk6LiGJ81kd3iGlc TBH9AVFzn8HxdQZ1+PVplV/yHvbIw+TA9Hv6sxCYhLFzk4ohkcUf7DyYwiPpgc/rB6jhzXhG tnXvBI11aaMBEQNCjX0BnveEQb9HeWi/vssMy/N3hGLT77IF9necDjzUdwlPq04kw+N6O5Ty FkBj7fYHZrL8C1v7z3vYc9RlHcMPDNis+N6f37oyCNYB9tsIE4ExVSpmXrKKfWaXl4YzxjMk ftVV374gpCSeBxZgITpOHjdrRmvUpYOBjJoVSPqtxqmOKMMWRIRYsMSApJ+fnDQbDIH5TBRi tY0QzrfNsOQAUwhwn4o7i+6ZTSRIiG9y30e/h6t1Hq8MgY6GX/OpLsl44Bkzdx1ZuWqbzUgi FCJ6ai2/TInetU5gHS0uy/YTJoC6RazCIMFI1OtPBIdPW476c/qT1Zqigwq2854VsCXl7uRP iZZNx4mtuNlFO5pSVfgONeXbT6rCKUJEGcXza1K4GCCItTG2MsywLEdMdXtfJIpTGIEG6mQ6 OR89gTolh+UURK0iWS12rjpx4MsZWXglMk3rR4wIboIOIW/+zjzXpY1A/Uw18yZNXt/I9RKk wqnyd9w3SaxoFoecksKiEOf2qT4Lw2KRpGtGfqbLD6NQ1ZHdkNm4vODQI= X-IronPort-AV: E=Sophos;i="5.58,493,1544486400"; d="scan'208";a="80850946" From: Paul Durrant To: Date: Mon, 18 Mar 2019 11:20:56 +0000 Message-ID: <20190318112059.21910-9-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190318112059.21910-1-paul.durrant@citrix.com> References: <20190318112059.21910-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v8 08/11] viridian: stop directly calling viridian_time_ref_count_freeze/thaw()... 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: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP ...from arch_domain_shutdown/pause/unpause(). A subsequent patch will introduce an implementaion of synthetic timers which will also need freeze/thaw hooks, so make the exported hooks more generic and call through to (re-named and static) time_ref_count_freeze/thaw functions. NOTE: This patch also introduces a new time_ref_count() helper to return the current counter value. This is currently only used by the MSR read handler but the synthetic timer code will also need to use it. Signed-off-by: Paul Durrant Reviewed-by: Wei Liu Acked-by: Jan Beulich --- Cc: Andrew Cooper Cc: "Roger Pau Monné" --- xen/arch/x86/domain.c | 12 ++++++------ xen/arch/x86/hvm/viridian/time.c | 24 +++++++++++++++++++++--- xen/include/asm-x86/hvm/viridian.h | 4 ++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 8d579e2cf9..02afa7518e 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -657,20 +657,20 @@ void arch_domain_destroy(struct domain *d) void arch_domain_shutdown(struct domain *d) { - if ( has_viridian_time_ref_count(d) ) - viridian_time_ref_count_freeze(d); + if ( is_viridian_domain(d) ) + viridian_time_domain_freeze(d); } void arch_domain_pause(struct domain *d) { - if ( has_viridian_time_ref_count(d) ) - viridian_time_ref_count_freeze(d); + if ( is_viridian_domain(d) ) + viridian_time_domain_freeze(d); } void arch_domain_unpause(struct domain *d) { - if ( has_viridian_time_ref_count(d) ) - viridian_time_ref_count_thaw(d); + if ( is_viridian_domain(d) ) + viridian_time_domain_thaw(d); } int arch_domain_soft_reset(struct domain *d) diff --git a/xen/arch/x86/hvm/viridian/time.c b/xen/arch/x86/hvm/viridian/time.c index 16fe41d411..71291d921c 100644 --- a/xen/arch/x86/hvm/viridian/time.c +++ b/xen/arch/x86/hvm/viridian/time.c @@ -91,7 +91,7 @@ static int64_t raw_trc_val(const struct domain *d) return scale_delta(tsc, &tsc_to_ns) / 100ul; } -void viridian_time_ref_count_freeze(const struct domain *d) +static void time_ref_count_freeze(const struct domain *d) { struct viridian_time_ref_count *trc = &d->arch.hvm.viridian->time_ref_count; @@ -100,7 +100,7 @@ void viridian_time_ref_count_freeze(const struct domain *d) trc->val = raw_trc_val(d) + trc->off; } -void viridian_time_ref_count_thaw(const struct domain *d) +static void time_ref_count_thaw(const struct domain *d) { struct viridian_time_ref_count *trc = &d->arch.hvm.viridian->time_ref_count; @@ -110,6 +110,24 @@ void viridian_time_ref_count_thaw(const struct domain *d) trc->off = (int64_t)trc->val - raw_trc_val(d); } +static int64_t time_ref_count(const struct domain *d) +{ + struct viridian_time_ref_count *trc = + &d->arch.hvm.viridian->time_ref_count; + + return raw_trc_val(d) + trc->off; +} + +void viridian_time_domain_freeze(const struct domain *d) +{ + time_ref_count_freeze(d); +} + +void viridian_time_domain_thaw(const struct domain *d) +{ + time_ref_count_thaw(d); +} + int viridian_time_wrmsr(struct vcpu *v, uint32_t idx, uint64_t val) { struct domain *d = v->domain; @@ -179,7 +197,7 @@ int viridian_time_rdmsr(const struct vcpu *v, uint32_t idx, uint64_t *val) printk(XENLOG_G_INFO "d%d: VIRIDIAN MSR_TIME_REF_COUNT: accessed\n", d->domain_id); - *val = raw_trc_val(d) + trc->off; + *val = time_ref_count(d); break; } diff --git a/xen/include/asm-x86/hvm/viridian.h b/xen/include/asm-x86/hvm/viridian.h index c65c044191..8146e2fc46 100644 --- a/xen/include/asm-x86/hvm/viridian.h +++ b/xen/include/asm-x86/hvm/viridian.h @@ -77,8 +77,8 @@ int guest_rdmsr_viridian(const struct vcpu *v, uint32_t idx, uint64_t *val); int viridian_hypercall(struct cpu_user_regs *regs); -void viridian_time_ref_count_freeze(const struct domain *d); -void viridian_time_ref_count_thaw(const struct domain *d); +void viridian_time_domain_freeze(const struct domain *d); +void viridian_time_domain_thaw(const struct domain *d); int viridian_vcpu_init(struct vcpu *v); int viridian_domain_init(struct domain *d);