[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Patch v1] Bug fix - Integer overflow when cpu frequency > u32 max value.
- To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>, Neowutran <xen@xxxxxxxxxxxxx>
- From: Jan Beulich <jbeulich@xxxxxxxx>
- Date: Mon, 19 Dec 2022 08:46:52 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4Z7TxHj/h86bO0ek8SqzZwC7tni++FSu6huM8H8Ul/s=; b=SU+j7eMHR4+MKHY67RcT7Y4jMcGiU4E4Ipridq7ImdAZmHNiXa403/G1j2JndBPXucbdNUTh022jMr9X6pF6b8baHZ9v2g1EpE0HYU/F8hO0ZHcr7dK9IQnWM0CZ1p7GaFYdpnynz/5YeAP8infOnqPti2wDDL+68hzrP2mIUJ5CILH6CDcgBkcYMyAQSi+kN/h+jcbV+LATj2l+uqCvZXQf9JhxcAruyYuVJS32Ec66wvbyKBNxK1lO/9ZH6n157JO2M9hQGDxJoc4v3ujr2GORCfjxrVyy2t1icu7YWqFEem6AJxFZSE9mBSTOY7mSfyfOiH+vUCFVcSpz6DVXdw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gp5e0YFzIr9W7WSXMsCjxSlXLDa2icOvw0pscus+l9cr8pxDljRi1ATnUohVMle7Wu1fNOV5TeT0k3+OmsnkthwPaSGQGQYy3O6beEIMXn8M6PTQ8t56BWp2kEx4KE+lV4iy84pp/zjbHW7s291zm1LxWe4YZcMttcqGpTU62odm4SAxQ5nuThcYC6eykrs4GZp8d824IKSTVwYr5n+rhWDEpa52GDh0lxorfto8y6EyyVPKwWIgIFynkRL8cGXrTp5pmd4NkM1mloSLWbclRGzdrjlRdvLjMl9UTy+iXsFH3/7mLI09Buedayfzfe0lyrrLjNsFaQ2oTYKbozHDmQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Mon, 19 Dec 2022 07:47:09 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 18.12.2022 01:18, Andrew Cooper wrote:
> On 17/12/2022 5:42 pm, Neowutran wrote:
>> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
>> index b01acd390d..7c77ec8902 100644
>> --- a/xen/arch/x86/time.c
>> +++ b/xen/arch/x86/time.c
>> @@ -2585,7 +2585,7 @@ int tsc_set_info(struct domain *d,
>> case TSC_MODE_ALWAYS_EMULATE:
>> d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
>> d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
>> - set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
>> + set_time_scale(&d->arch.vtsc_to_ns, (u64)d->arch.tsc_khz * 1000);
>
> Ah - I see you tracked down your bug in the end. One minor thing, we
> prefer to use (uint64_t) rather than (u64).
And yet better we like cast-less code, e.g. in this case by simply using
1000UL.
Jan
|