From patchwork Thu Nov 3 16:36:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13030609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C0B2C433FE for ; Thu, 3 Nov 2022 16:37:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.436879.691067 (Exim 4.92) (envelope-from ) id 1oqdCn-0007kM-PW; Thu, 03 Nov 2022 16:36:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 436879.691067; Thu, 03 Nov 2022 16:36:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdCn-0007kF-Mr; Thu, 03 Nov 2022 16:36:37 +0000 Received: by outflank-mailman (input) for mailman id 436879; Thu, 03 Nov 2022 16:36:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oqdCl-0007k8-UH for xen-devel@lists.xenproject.org; Thu, 03 Nov 2022 16:36:35 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ad908be4-5b95-11ed-91b5-6bf2151ebd3b; Thu, 03 Nov 2022 17:36:34 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8A1CA1F385; Thu, 3 Nov 2022 16:36:33 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3EA7213480; Thu, 3 Nov 2022 16:36:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BTUmDRHuY2NdSAAAMHmgww (envelope-from ); Thu, 03 Nov 2022 16:36:33 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ad908be4-5b95-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1667493393; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=N8W4oIeALHkDkc0s+2qqiC97IZ8xBjyHM6ZTLQ6KBMQ=; b=m+e4pIr7U1jmpOa9v53WsjZG5ot6rqm9m/CUraOhoWrv5DnAW1oMk5PYFF3DEkwmB25rY9 uZzC8NUyEz1LPuYM7mJPEZXEKDLRmpkUJayONEyKFrkC0M7FeRkig2CytY84o80gs0+4pt jQzpbP2VF0D7By95XbveBatqDk+/Lgw= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Henry Wang Subject: [PATCH-for-4.17] xen: fix generated code for calling hypercall handlers Date: Thu, 3 Nov 2022 17:36:31 +0100 Message-Id: <20221103163631.13145-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 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 << ". 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 Reviewed-by: Jan Beulich --- xen/scripts/gen_hypercall.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/scripts/gen_hypercall.awk b/xen/scripts/gen_hypercall.awk index 34840c514f..08b2f70bdb 100644 --- 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"); printf(" "); for (pl = 1; pl <= n_prios[ca]; pl++) { if (prios[ca, p_list[pl]] > 1) {