From nobody Fri Nov 22 07:15:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1718897867; cv=none; d=zohomail.com; s=zohoarc; b=iG3WnPBJiPciuw7kcvQFehl1wg6bgn0G6I8nSE+hbM4Ybz0YrmzQuN+WfhTCYr0WMa0tbN48WEn5bYkdgxsLnTPnUIRaTk3KIz/LXVPjYBbqtyYkJ1Dsj8KOO1mB/RkWnZr+leSpnbZ3xVL6FQCu152iiUNDuhaQ6pkHQPi8XbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718897867; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KC6rl9EXhuFpskqMgYdFWCq/EEUOO/iNi0wsiHqBJLw=; b=Gk+Kl+u/v9B/nM3THbuBWSPWK3Lu7+JW8q2b9kj3kjRgwG9jVr1hAiamoK1FDotcHlr3FwrmrGP7A4+VFRKWQhxs+sW/CnA/PzLoOS9QzqH2N9U/FfrjPu7JUoLKa88enIvo9FgREIoQmbW7dgKF+8pm7270naHvurA6Qwz17gs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1718897867231220.22830318917397; Thu, 20 Jun 2024 08:37:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.744811.1151930 (Exim 4.92) (envelope-from ) id 1sKJqs-00079m-KF; Thu, 20 Jun 2024 15:37:30 +0000 Received: by outflank-mailman (output) from mailman id 744811.1151930; Thu, 20 Jun 2024 15:37:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKJqs-00079f-Gz; Thu, 20 Jun 2024 15:37:30 +0000 Received: by outflank-mailman (input) for mailman id 744811; Thu, 20 Jun 2024 15:37:29 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sKJqr-00079V-DI for xen-devel@lists.xenproject.org; Thu, 20 Jun 2024 15:37:29 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id feb1685e-2f1a-11ef-b4bb-af5377834399; Thu, 20 Jun 2024 17:37:26 +0200 (CEST) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57d07f07a27so1108146a12.3 for ; Thu, 20 Jun 2024 08:37:26 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([2.223.45.79]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57cb72cdf52sm9852778a12.8.2024.06.20.08.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 08:37:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: feb1685e-2f1a-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1718897845; x=1719502645; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KC6rl9EXhuFpskqMgYdFWCq/EEUOO/iNi0wsiHqBJLw=; b=RXgOIF93hswGJyYrwymE4ZKfZjCMzj5W7hEavNPCCsjUjddxRqg0s7Xk+gximoEiyT 8Rw8qvx6+CZBPU8OG4QttBiU8THNVjryysl/7oI+mKRa848JSrzw//A6eoyPi8xrny3b SmCKg7Wi/i9sasvvMuT5y5MCaoIjxQ9u/TwIE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718897845; x=1719502645; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KC6rl9EXhuFpskqMgYdFWCq/EEUOO/iNi0wsiHqBJLw=; b=Ayho/P64d7jtM7zT/8WSW02TpbYSPhgrSqLXDxb3zsXlwHK3RJJBEUDNP3UPGGkvpO vGCjCbl679BLDKJtziq2vOhlSiwtIR9eCXlYdWBoNG1nabsqL7XRV1ByhDfrw7trsFtS 0nbSOo712vAsjOdBpiiGsJqlXApIuCmJJlzC4bjtXKzVNuTs4OnFS7mGjtfiPTDvnCiX E24TBLLSLsjU6JUCf+Datka0dvAiHCrI55cFNlq6U9/AGXyTs4uy06m2hdpGIYFv/Bup 6KG6A28OTk+PidihefbyO0H4VWIOCIhg7Lo3Me1krfNR9aVMcwFPXfj2muvG0gNnfgnh lI4g== X-Gm-Message-State: AOJu0Ywms+TH4cQDerslJat8Q9L2N4XNPbkwYfHMYZz+aiiCt0+9hRR6 m4sE/QJcOYFYEYDSdiDBkLL27vIMQ/cgWOJcWABGXZCW2khOgxVEHys3uybssqx8VLHZye98x6b y X-Google-Smtp-Source: AGHT+IHv9xbMjgfvHAw8tHesSqBG900ed11MhqqkeJFss7E4gUcRTNAh1AjCwGk1Z9JbKEHeJrTjbg== X-Received: by 2002:a50:cd1e:0:b0:57a:1e0a:379f with SMTP id 4fb4d7f45d1cf-57d18005efbmr2193314a12.16.1718897845342; Thu, 20 Jun 2024 08:37:25 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Oleksii Kurochko Subject: [XEN PATCH v2] x86/apic: Fix signed shift in io_apic.c Date: Thu, 20 Jun 2024 16:36:46 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1718897868453100001 Content-Type: text/plain; charset="utf-8" There exists bitshifts in the IOAPIC code where signed integers are shifted to the left by up to 31 bits, which is undefined behaviour. This patch fixes this by changing the integers from signed to unsigned. Signed-off-by: Matthew Barnes Reviewed-by: Jan Beulich Reviewed-by: Andrew Cooper --- Changes in v2: - Correct signed shifting in mask_and_ack_level_ioapic_irq() - Adjust bracket spacing to uphold Xen style - Improve commit message --- xen/arch/x86/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index b48a64246548..d9070601a26f 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -1692,7 +1692,7 @@ static void cf_check mask_and_ack_level_ioapic_irq(st= ruct irq_desc *desc) !io_apic_level_ack_pending(desc->irq)) move_masked_irq(desc); =20 - if ( !(v & (1 << (i & 0x1f))) ) { + if ( !(v & (1U << (i & 0x1f))) ) { spin_lock(&ioapic_lock); __edge_IO_APIC_irq(desc->irq); __level_IO_APIC_irq(desc->irq); @@ -1756,7 +1756,7 @@ static void cf_check end_level_ioapic_irq_new(struct = irq_desc *desc, u8 vector) !io_apic_level_ack_pending(desc->irq) ) move_native_irq(desc); =20 - if (!(v & (1 << (i & 0x1f)))) { + if ( !(v & (1U << (i & 0x1f))) ) { spin_lock(&ioapic_lock); __mask_IO_APIC_irq(desc->irq); __edge_IO_APIC_irq(desc->irq); --=20 2.34.1