[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/4] tools/tests/x86_emulator: fix undefined behaviour in shift


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Edwin Torok <edwin.torok@xxxxxxxxxx>
  • Date: Tue, 3 Mar 2026 14:49:16 +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=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=ayOsLpThfJqd4rC0u7zujKcy9FTm8kkwUbInuB/ThCg=; b=QT+yClo5Q/Erah1DagfVXhsV/+nR9I/kGM/jZBugJH4wq5YCBuovCAaQLyxwBovMTvry9rm95zmhYSGbCx0xU/2W6PyLbNzF3LzFzvIKO7C8RUK6oAmb0n+MDMSOOiErFCjwfi8I+9nH+n2oTJMYdtXfhviCsb6I6JpD75lw43qiTzVelkhx4sroEoHElTCnKF0u9ht4kvZyT7IIkdAg1/yh8Grv5of24ah4ClpW944/8+ToRBDPrfxEI/m+EHYUzGV1ZDKqXQPFrzm7ZAZ2+qptm2diG8aR3tsCtdg3hrGs7jKoveKtd8ZUhdSAWIxSJucIDRhQeO43xVJmYUHaxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AdO9+cI2B0BjfDgxxvEEK7fM4i2A9Y23YKBUJ0dEh3Q9inltu/LQmmfyqxuGsX6VZLmtjd0CRSg6KYsNi3ahsdmpfsZnJRM1p1V5Avhm2RrHr0JjTTx3BWMKDXQ+hnYGwFBaL0tcWvgFG+4QhHCgxutqEx2ijixu/RDwDNO4HD+9NHr3/PBk61AJ68GFgzQVoTTAdkpwxFBdW9RvKADA/C1n1M2DpC4JLYoYeW7wkyvhBkrAl70Zzd+8rKUSbrLSx9ZVAFltQZWlbtGCkKGpSuX9UeOygg4tYSU9cadbNmozgDDzOFyji/WY2rdj0KrlFe0ppnUeG4RfcexuWz3x0Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 03 Mar 2026 14:49:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcp9gCO67+yoRhk0SyNFZDTeRIWLWc3oEAgAALkwA=
  • Thread-topic: [PATCH v2 3/4] tools/tests/x86_emulator: fix undefined behaviour in shift


> On 3 Mar 2026, at 14:07, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 27.02.2026 11:58, Edwin Török wrote:
>> --- a/tools/tests/x86_emulator/test_x86_emulator.c
>> +++ b/tools/tests/x86_emulator/test_x86_emulator.c
>> @@ -1100,7 +1100,7 @@ int main(int argc, char **argv)
>>     regs.edi    = (unsigned long)res;
>>     rc = x86_emulate(&ctxt, &emulops);
>>     if ( (rc != X86EMUL_OKAY) ||
>> -         (*res != ((0x2233445F << 2) | 2)) ||
>> +         (*res != ((0x2233445FUL << 2) | 2)) ||
> 
> Why the L when res is an array of unsigned int? With it dropped (happy
> to do so while committing):

You are right, it isn’t needed, making it unsigned is enough to avoid undefined 
behaviour.

Best regards,
—Edwin


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.