[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86/AMD: check divisor in amd_parse_freq()
- To: jbeulich@xxxxxxxx
- From: Stephen Cheng <stephen.cheng@xxxxxxxxxx>
- Date: Wed, 2 Dec 2026 13:49:57 +0800
- 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=arcselector10001; 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=+S6jLrYZy1Q1aStyOfMSUUMa0Dk0FNTPXpNIU9TkYTE=; b=OeLkA8/detgk/2RcuW6anx+nzqGiIQEpxGT4ez966Mgk6o2PjY9jGmCoPkMwhejSzIi+hPLkSZhN9IKg0iPr8QAOUfikHAalY6EIXu9ywRlrzgj9jQXQXtuHS7PIwqWsE+ocJSe6abKNcIeKiJphOYOQFxRUo5SUpB64Bq7RF2gEFRbHozVCKdwot6v6ecku+/2naYEbOuFUyO8FiGcEpNPtiPc3/v0elt2SQ1++U6j135xuakmDBc+0OERMwMsZ1TaDnd3+dXv5n93V/NG9aLiAByetbdHt0xf4Tq0//6q7aqHKyqGqlX6Qlc9/7XfpMoAMX0lSZTJkka8cr5vNxg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eaMcl6+vTe1Wm0Ug09lunU+2lqYmfAoEXoL2J4nVRbO/+lmLcbbQ3sTbtSC3yDXBvUxue/n2OzkmNThmUoymxWcFYSyl+p9/pyWiV3W+AfblZ2rAFoZBPkP8T9/Tg8RBsn8Z7Xi6gE+wa8P6ggOTuBjTPsiogqM7c+f2dVcRJ1YjicU1Gaih6Lm6Njn/0WbSb0T2wHA3I+4IlRPoALh18XliKa0pNYetMt4ErlGep9Glmo84WNEwImkad370RW6eSDTPnlsBcaSdpr3fTPEqk5Mks9xUICVN7DrIeXVv8SRi7zxlfOzCLN/jQV971SOJqNVDfLWrh/eL07GWEMW+9g==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: andrew.cooper3@xxxxxxxxxx, roger@xxxxxxxxxxxxxx, teddy.astie@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stephen Cheng <stephen.cheng@xxxxxxxxxx>
- Delivery-date: Wed, 02 Dec 2026 05:50:30 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 25/11/2026 07:37, Jan Beulich wrote:
> --- a/xen/arch/x86/cpu/amd.c
> +++ b/xen/arch/x86/cpu/amd.c
> @@ -497,6 +497,8 @@ static unsigned int attr_const amd_parse
> break;
>
> case 0x17 ... 0x19:
> + if (!(value & 0x3fff))
> + break;
> freq = ((value & 0xff) * 25 * 8) / ((value >> 8) & 0x3f);
> break;
The divisor is bits 13:8, but the 0x3fff mask also covers bits 7:0. So
the check is only true when both fields are 0. With bits 13:8 == 0 and
bits 7:0 != 0, e.g. value = 0x78, we still divide by zero.
Should this be !(value & 0x3f00), or !((value >> 8) & 0x3f) to match
the divisor expression?
Stephen
|