[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: Neowutran <xen@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Sun, 18 Dec 2022 00:18:54 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=q3KoCmyHmJm16wFivrxH3UeEFyGbDKcU5m1dbLJFFLw=; b=GGLnSaa00RUsiDcynmcEyASLMGiw8/y0VPvpM9tZSNAxM8c0nuG94nYjQ7h2IRAWeH2TycRwsm6pgOgnEFopT4avExlej+qK9dXMBEhwfLQnD/qmm7R21AJ9EUEor/Ff/slq0mUftkKtO8Xpakkc0lrPMQaWPXZeE90pUKRljJDgA6EY1JjatNvClVUFm9NaVE0wSEmIbXGEYhp4sFwL/1LGvutTqpyVX/0UYEgr8Zzn1Yqq5ngRSoKiOFPd85ZCDJgnZWsozjsV2PzV6TxDExZlQtKi3sBY6qnMvl5Ptt0sObjRvWyb9I0H0vwjhuXv6f9aNzWJ3BTqrhWwRrvGeg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ktTEa2rBEAIQMrIfBGkJLrdmv7oIHRM9LxHWKZhAqeld7o86ZXyhPQnNUp4+YETyGRh4l6ZT1NzRrGa05aPtnXqhrVKdno8mFZ/DgjdbL4K1OIainYHxRn+2kCFRGXvwt7zFSh0mMqbw74QUXrQISB/Rq92gE8jz93TORp+4lEqOrN4G2JCGwOFebFwqBVnhN4bxd0ROPBItu5e+bXC46LG3ZA+I4CspsmzBlHLjuWBZECQV61Bh0+vcuyyBgS20MNWv4K/Z/e+6CemWA1c86HfBvW/xwdHo5IPcXgTSQHRynAkrzIFELdhPSyFnQ2dla/XvisGllGGkj4dektuhoA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Sun, 18 Dec 2022 00:19:15 +0000
- Ironport-data: A9a23:epHyd6mctnmQrH0KbAh04yvo5gy9J0RdPkR7XQ2eYbSJt1+Wr1Gzt xIbCj2CPfffYTHwL4p2OoiwoEsPsZ/dmoc1SAJtqCoxQyMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icf3grHmeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7aqaVA8w5ARkP6kR5QCGzRH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 eYbDj4MbkqNu8en+oOCR8togs0fc9a+aevzulk4pd3YJdAPZMiZBo/svJpf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkVU3jOmF3Nn9I7RmQe18mEqCq 32A1GP+GhwAb/SUyCaf82LqjejK9c/+cNJCReTnqqQ36LGV7korJRIEaVSnndeG1ESzUcBTO mwV4AN7+MDe82TuFLERRSaQsHOClhgRXMVND/cz7keK1Kq8yxaUAC0IQyBMbPQitdQqXno62 1mRhdTrCDdz9rqPRhq19L2ZsDezMig9NnIZaGkPSg5ty8bniJE+iFTIVNkLLUKuptj8GDW1y TbTqiE73+8XlZRTi/T9+k3biTWxoJSPVhQy+gjcQmOi6EV+eZKhYIurr1Pc6J6sMbqkc7VIh 1Bc8+D20QzEJcvlePClKAnVIIyU2g==
- Ironport-hdrordr: A9a23:4m/3oKrAREaioe0XfJS7jmgaV5oleYIsimQD101hICG9E/b1qy nKpp8mPHDP5wr5NEtPpTnjAsm9qALnlKKdiLN5Vd3OYOCMghrKEGgN1/qG/xTQXwH46+5Bxe NBXsFFebnN5IFB/KTH3DU=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHZEj8ndYrlW6+ypUatP8oqlCOlc65yyCEA
- Thread-topic: [Patch v1] Bug fix - Integer overflow when cpu frequency > u32 max value.
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).
As Elliot said, you need to submit a v2 with a Signed-off-by for the DCO
before the patch can be accepted.
A more succinct commit message would also be great - it wants to
describe what the bug is, and what the fix is. For this, the key term
is "overflow before widen" (or variation thereof) which is a common
class of bug in C.
Thanks,
~Andrew
|