From nobody Tue Feb 10 00:25:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541617306421132.5636708098308; Wed, 7 Nov 2018 11:01:46 -0800 (PST) Received: from localhost ([::1]:50216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKT57-0007xe-FD for importer@patchew.org; Wed, 07 Nov 2018 14:01:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKSsm-0000DT-96 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 13:48:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKSsh-00009g-VN for qemu-devel@nongnu.org; Wed, 07 Nov 2018 13:48:52 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:50798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gKSsh-00008N-K5 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 13:48:47 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wA7IhXjm138403; Wed, 7 Nov 2018 18:48:44 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2nh33u5anp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Nov 2018 18:48:44 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wA7Imh9A023508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 7 Nov 2018 18:48:43 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wA7ImgOl009795; Wed, 7 Nov 2018 18:48:43 GMT Received: from ca-ldom147.us.oracle.com (/10.129.68.131) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 07 Nov 2018 10:48:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=AGllmjqZqXGUbdVGVbK5KuCq0H/zp4Pl2RDWjkLhJLg=; b=Og3RhgcNmD2wW/EojMC8UBkM/ISEpYH7LABQbIrweYEW1aTHCPr6Mkym+0XhyGH83sLS OFUJk/W+oRNQ+cz2oMmEB/FDNm22+6kzyHOkRUEozgNhjWOyaWWjYM7/V+dKW4ahHdNk MMqZjKpNjhsDvk9EoDhXQQjZIXufaVPhw6TR5DxLRb8YZlvPFa16VcwMybX+EulEVkw3 sjEERlLM2I0MuOwG7ZCqVN4m68wu1aJDxI4tG1pUY60uNZbMLU4wxrVQtd/mhv3N5HKJ WAa0+MOnGEXpHaX7kHd5nbMCaFbjK8VbM4azTn4BvL4StjAYQEEKZJ0nrczf0SP74qz6 tg== From: Bijan Mottahedeh To: qemu-devel@nongnu.org Date: Wed, 7 Nov 2018 10:48:24 -0800 Message-Id: <1541616504-68526-3-git-send-email-bijan.mottahedeh@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541616504-68526-1-git-send-email-bijan.mottahedeh@oracle.com> References: <1541616504-68526-1-git-send-email-bijan.mottahedeh@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9070 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=620 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811070167 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 X-Mailman-Approved-At: Wed, 07 Nov 2018 13:59:21 -0500 Subject: [Qemu-devel] [RFC QEMU 2/2] arm/virt: Account for guest pause time X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Accumulate the total guest pause time and update the virtual counter offset register accordingly in order to account for that time before resuming the guest. Signed-off-by: Bijan Mottahedeh --- hw/intc/arm_gicv3_kvm.c | 39 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 1e11200..aabd508 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -30,6 +30,7 @@ #include "gicv3_internal.h" #include "vgic_common.h" #include "migration/blocker.h" +#include "target/arm/internals.h" =20 #ifdef DEBUG_GICV3_KVM #define DPRINTF(fmt, ...) \ @@ -745,9 +746,38 @@ static void vm_change_state_handler(void *opaque, int = running, { GICv3State *s =3D (GICv3State *)opaque; Error *err =3D NULL; + CPUState *cpu; + CPUARMState *env; + struct kvm_one_reg reg; int ret; + uint64_t cnt; =20 if (running) { + CPU_FOREACH(cpu) { + + env =3D (CPUARMState *)(cpu->env_ptr); + + if (!env->pause_start) { + continue; + } + + /* + * Accumulate the total pause time and set the + * counter virtual offset accordingly. + */ + cnt =3D gt_get_countervalue(env); + env->pause_total +=3D (cnt - env->pause_start); + env->cp15.cntvoff_el2 =3D cnt - env->pause_total; + + env->pause_start =3D 0; /* clear for next pause */ + reg.id =3D KVM_REG_ARM_TIMER_CNT; + reg.addr =3D (uintptr_t) &env->cp15.cntvoff_el2; + ret =3D kvm_vcpu_ioctl(cpu, KVM_SET_ONE_REG, ®); + if (ret) { + error_report("Set virtual counter offset failed: %d", ret); + abort(); + } + } return; } =20 @@ -760,6 +790,15 @@ static void vm_change_state_handler(void *opaque, int = running, if (ret < 0 && ret !=3D -EFAULT) { abort(); } + + CPU_FOREACH(cpu) { + /* + * Record the current pause start time. + */ + env =3D (CPUARMState *)(cpu->env_ptr); + cnt =3D gt_get_countervalue(env); + env->pause_start =3D cnt; + } } =20 =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e310ffc..bd0a56e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -602,6 +602,9 @@ typedef struct CPUARMState { struct CPUBreakpoint *cpu_breakpoint[16]; struct CPUWatchpoint *cpu_watchpoint[16]; =20 + uint64_t pause_start; /* start time of last pause */ + uint64_t pause_total; /* total pause time */ + /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; =20 --=20 1.8.3.1