From nobody Mon Apr 29 04:56:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1605114205; cv=none; d=zohomail.com; s=zohoarc; b=fBXhJQ6p4tm/ePymIb3NBu/PDMfg1ajTyv/fUXCNpcZEz+UB6saR5jXDxZgRB489CA6dMi8OB3Jcqrbp5e7+hRREuHaHocW2C2hPVP5PXwxo2aFO2cAOng7KlsVOQ9eZd3XcLqHOrXsLRxgAZuE++5jvTsV32r21m+OIsLafUMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605114205; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=3sz7QzmfEeYrVJsi+cy0yipPq5EW5RZprdYXhZEIdLU=; b=DQxC1IZvrpF6hSiA/IhXN4thSoiUs0fZ1EbO6BT6xWpqr5fWfhJNy7+AwHD5hFqh9AYuRR7I+wRb4XNasw6Nea21g1BlKmquXhiDFO9JAKDgdjLDVQIoFPI9Y//9m7Uqob5U7eInQXIngPgObPFLtukIc49V8xN6XDNUSd3qcRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1605114205013657.1615270517913; Wed, 11 Nov 2020 09:03:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-323-RR_Nbu8OODaqj3iKYBbFmg-1; Wed, 11 Nov 2020 12:01:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DA4C835B8E; Wed, 11 Nov 2020 17:01:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8725E5B4D0; Wed, 11 Nov 2020 17:01:03 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B9FE1180BAFF; Wed, 11 Nov 2020 17:00:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0ABH0unm002106 for ; Wed, 11 Nov 2020 12:00:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 18C6627BB7; Wed, 11 Nov 2020 17:00:56 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.40.194.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DBE0E28545 for ; Wed, 11 Nov 2020 17:00:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 62D60240B19; Wed, 11 Nov 2020 18:00:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605114203; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3sz7QzmfEeYrVJsi+cy0yipPq5EW5RZprdYXhZEIdLU=; b=U8JHrxYtHHy59UkcbSBpC1mdzRV+RpFkEkWR8dc6q5eX0MKMi036RoHF7IpkcqWMz51cI+ WaxIuqNKMwBNi4TEKirSkGNb+woUQWo2cSdB52csHegpjrzmvobCZRaUBzJmObKZByuhq5 jgIujawnooqRdfNdZVrSNz2BS/J95IQ= X-MC-Unique: RR_Nbu8OODaqj3iKYBbFmg-1 From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH] conf: Use unsigned long long for timer frequency Date: Wed, 11 Nov 2020 18:00:52 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Although the code in qemuProcessStartValidateTSC works as if the timer frequency was already unsigned long long (by using an appropriate temporary variable), the virDomainTimerDef structure actually defines frequency as unsigned long, which is not guaranteed to be 64b. Fixes support for frequencies higher than 2^32 - 1 on 32b systems. Signed-off-by: Jiri Denemark Reviewed-by: Martin Kletzander --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a3ca332279..9199771dc0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14053,7 +14053,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, } } =20 - ret =3D virXPathULong("string(./@frequency)", ctxt, &def->frequency); + ret =3D virXPathULongLong("string(./@frequency)", ctxt, &def->frequenc= y); if (ret =3D=3D -1) { def->frequency =3D 0; } else if (ret < 0) { @@ -22851,7 +22851,7 @@ virDomainTimerDefCheckABIStability(virDomainTimerDe= fPtr src, if (src->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC) { if (src->frequency !=3D dst->frequency) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target TSC frequency %lu does not match sour= ce %lu"), + _("Target TSC frequency %llu does not match sou= rce %llu"), dst->frequency, src->frequency); return false; } @@ -28166,7 +28166,7 @@ virDomainTimerDefFormat(virBufferPtr buf, =20 if (def->name =3D=3D VIR_DOMAIN_TIMER_NAME_TSC) { if (def->frequency > 0) - virBufferAsprintf(buf, " frequency=3D'%lu'", def->frequency); + virBufferAsprintf(buf, " frequency=3D'%llu'", def->frequency); =20 if (def->mode !=3D -1) { const char *mode diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 77656c8ae3..16c050a3ea 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2207,7 +2207,7 @@ struct _virDomainTimerDef { int track; /* boot|guest|wall */ =20 /* frequency & mode are only valid for name=3D'tsc' */ - unsigned long frequency; /* in Hz, unspecified =3D 0 */ + unsigned long long frequency; /* in Hz, unspecified =3D 0 */ int mode; /* auto|native|emulate|paravirt */ }; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b0c2a5efb5..0fecb9f6e7 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6357,7 +6357,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, break; case VIR_DOMAIN_TIMER_NAME_TSC: if (timer->frequency > 0) - virBufferAsprintf(&buf, ",tsc-frequency=3D%lu", timer->fre= quency); + virBufferAsprintf(&buf, ",tsc-frequency=3D%llu", timer->fr= equency); break; case VIR_DOMAIN_TIMER_NAME_ARMVTIMER: switch (timer->tickpolicy) { --=20 2.29.2