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

Re: [PATCH-for-4.17] xen: fix generated code for calling hypercall handlers


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 3 Nov 2022 17:45:37 +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=ciM688YFTQ2O2s8+rccgGozuFycwStj+ET2HgOKN0Jc=; b=XQ6tt//dC5PtUYSGwDdZNWVAVSUDDzusfUhdIXmpzBkMf28qI5yK11pM7luNn8Cfokfw2216O+B1zfuODYgZGTiSwnM4YefG2EEbhLw5MUvxPGn8hbsOpeM8cstKemreG9waTpTaNckLIAH6EBE1E+yPKd9IsX+C8xavUrOBlYQYXSs4AzqnsqaNjShcu/4pLPoIXj9peHfxQT5/cPTtWaYYKSb/Gkmssxg12CpapUZW0bTnN7Js8s/T8fTntPYtDleTGI4XKlVDUowqM4TeICzyvfDdj4vSjPwKLThHYKf4/OoW07D5ZyIWR9XOCPqJsLbwUSHGp7O8//fO5Ogiiw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IUKtGXSkLvaco79hV0W2ZSiMcVT0KvJwfMYKCdznPrf9rlaPQm/BsiROJ19xSGURHjoA3qYBXS203no8zvqKzVgVEonJUsW2Jms/E3Ylj7vrc5U286D08e6KrO5qpzgA6I6hDEoftFRkLOem8gYYccIE83L5tELoW1jYTx/hUHqqOJkZnlWj1wtbexJviOxtnUT/+sulpjWujVzKllFKba24zySXKdfMVwoTu6aZLn3WegKgW5TpVA+DVtXNVuAnbDq9OJJtno78d49noJL7HtI/FeNX9D3edhyxjoPLwvlL+Vz09slfgu3Odw6Zwm6/lZqXfG5P1d4juwmbGh8eGQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 03 Nov 2022 16:45:46 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.11.2022 17:36, Juergen Gross wrote:
> The code generated for the call_handlers_*() macros needs to avoid
> undefined behavior when multiple handlers share the same priority.
> The issue is the hypercall number being unverified fed into the macros
> and then used to set a mask via "mask = 1ULL << <hypercall-number>".
> 
> Avoid a shift amount of more than 63 by setting mask to zero in case
> the hypercall number is too large.
> 
> Fixes: eca1f00d0227 ("xen: generate hypercall interface related code")
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
albeit preferably with ...

> --- a/xen/scripts/gen_hypercall.awk
> +++ b/xen/scripts/gen_hypercall.awk
> @@ -263,7 +263,7 @@ END {
>          printf("#define call_handlers_%s(num, ret, a1, a2, a3, a4, a5) 
> \\\n", ca);
>          printf("({ \\\n");
>          if (need_mask)
> -            printf("    uint64_t mask = 1ULL << num; \\\n");
> +            printf("    uint64_t mask = (num > 63) ? 0 : 1ULL << num; \\\n");

... "num" also properly parenthesized (this is part of a macro definition
in the output after all). Easy enough to take care of while committing.

Jan



 


Rackspace

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