From nobody Tue Feb 10 05:41:15 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 1543352986698671.5770932991852; Tue, 27 Nov 2018 13:09:46 -0800 (PST) Received: from localhost ([::1]:44472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkc5-0005hy-BY for importer@patchew.org; Tue, 27 Nov 2018 16:09:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZw-0003NW-Km for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZt-0003lb-Dl for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:32 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:44894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZt-0003ki-53 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:29 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wARL4UXa109812; Tue, 27 Nov 2018 21:07:25 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2nxxkqej34-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Nov 2018 21:07:24 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wARL7O3r026561 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Nov 2018 21:07:24 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wARL7NFL010376; Tue, 27 Nov 2018 21:07:23 GMT Received: from ca-ldom147.us.oracle.com (/10.129.68.131) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Nov 2018 13:07:23 -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=sYGOOcVXsjJUlB8fmKB3HLVP631mfXchLtgCg7GzkfMDnNHtLhjBMKlvMhv4wPzi3p0B rIbNXBQsWqfxeCJXUcTbGWdXsAolv7yBtjAfQidq+ezND3ZPnvj0wdKoV1yJQAKkpjcN lpRJGegY170y3SLKEaCtBv/BfICWJ6bzZ1pF44MJ2MyT8qR2HR3yED5zx+7rM5pYDLMM 0vKM6AJVxooFMW+HeuX3WE82McEd3g+OGrrlv/SlzH5/vgyTIWGnjAsa5G0d2q4vrNa8 EeUjwSXumVNaV3cZkevamI2eYQqRQiaMbaxKal+iKmky6oxgrEmNPh/8TPDOE5opuj0y UA== From: Bijan Mottahedeh To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2018 13:07:17 -0800 Message-Id: <1543352837-21529-3-git-send-email-bijan.mottahedeh@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1543352837-21529-1-git-send-email-bijan.mottahedeh@oracle.com> References: <1543352837-21529-1-git-send-email-bijan.mottahedeh@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9090 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=610 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811270178 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC QEMU v2 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