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

Re: [PATCH] x86/altp2m: help gcc13 to avoid it emitting a warning


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 13 Mar 2023 13:17:41 +0000
  • 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=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=mZ9meqrnwLm4tCcSdDK3DC7S1mPw6undEotOl6ih1DE=; b=SmapysPI7+XXo8dRzRXQuCtrNbLVVHQa816glOsqNemtNuqFjsxKs3UTBAvgpJ19kFxNbre8BqVaVkpd2pBIoFvd9gOBRj72vnekSo9L14ca9VO3kZszkaQ/NHDe9S7sqH74pXBCM52Nxsl/McEZHJf1LINUbZqdjsTRfzznDYyUYuQJDXCFBPjEQUHaZweHZZUGtt6f7bWUoMX4pq50yqkgwkv7ic7mJdHpmsulJNi996rCrz0Bne1osc792sDRilwHTWQ7h2CY82sbCdBHhkPR08noCJ194xamip9iaKS+X2HlEHSqa1xUVUb7LVBDcnsXVDfhAnmxi/XSHXFp9w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VyM800N+N8HSkuXOezeO1cJ0AR7UQo5M4S9Wh23nYVGaZIndnfgF/7Ddagbl5V7+itf80QgWBmaYJj8B3fatW90wmYR06R1MJP/+adCtMwdQTZ6Ns5SizZ2U/Kk9oX6aa1bJquWeJCLNnpYDLmMaNH3ZBGZAFGrgExP2i10Mb6px9K9tHu79JToGKMB8s1FKmw84cgmStqj67IJIxYnAZBbMD2Poznw8gwQaje1SZRBgc5xbxOPUgY13J+Lbzpsz4C9rMhvhK3yotu2HSiHA1LXo49A311Q4NWazyAi/x98DBj2wdfnwpa7yqwFr8jPz9RW7CpuqP8PYrDCh0HfeLg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>
  • Delivery-date: Mon, 13 Mar 2023 13:33:57 +0000
  • Ironport-data: A9a23:DkeEJ606H6Wsa+rfo/bD5QNwkn2cJEfYwER7XKvMYLTBsI5bp2EDm zEeDGuEPP2NMzSmL48jaN+3oUNQvMSHmtBmTwo4pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS+HuDgNyo4GlD5gdnPqgQ1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfIUV17 acZayo2YQGc2v7om7PkG7FDiZF2RCXrFNt3VnBI6xj8VapjZK+ZBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxouC6Kk1AZPLvFabI5fvSjQ8lPk1nej WXB52njWTkRNcCFyCrD+XWp7gPKtXKqCd1PT+DjnhJsqHi63U8xKgYxbgWU/uOUzReaZ+puN FNBr0LCqoB3riRHVOLVXRe1vXqFtR40QMdLHqsx7wTl4rrZ5UOVC3YJShZFacc6r4kmSDoyz FiLktj1Qzt1v9W9Vna15rqS6zSoNkA9LmIcZClCUQoM5fHipp0+ilTESdMLOKyoiJvzEDL5w TGPpQA/gakeiYgA0KDTwLzcqzelp5yMSxFv4AzSBj6h9lkgO9LjYJG041/G6/oGNJyeUlSKo HkDnY6Z8fwKCpaO0ieKRY3hAY2U2hpMCxWE6XYHInXr323FF6KLFWyI3AxDGQ==
  • Ironport-hdrordr: A9a23:xRmjOKHqSq94EgzcpLqE18eALOsnbusQ8zAXPo5KOGVom62j5r iTdZEgvyMc5wxhPU3I9erwWpVoBEmslqKdgrNxAV7BZniDhILAFugLhrcKgQeBJ8SUzJ876U 4PSdkZNDQyNzRHZATBjTVQ3+xO/DBPys6Vuds=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03/03/2023 7:31 am, Jan Beulich wrote:
> Switches of altp2m-s always expect a valid altp2m to be in place (and
> indeed altp2m_vcpu_initialise() sets the active one to be at index 0).
> The compiler, however, cannot know that, and hence it cannot eliminate
> p2m_get_altp2m()'s case of returnin (literal) NULL. If then the compiler
> decides to special case that code path in the caller, the dereference in
> instances of
>
>     atomic_dec(&p2m_get_altp2m(v)->active_vcpus);
>
> can, to the code generator, appear to be NULL dereferences, leading to
>
> In function 'atomic_dec',
>     inlined from '...' at ...:
> ./arch/x86/include/asm/atomic.h:182:5: error: array subscript 0 is outside 
> array bounds of 'int[0]' [-Werror=array-bounds=]
>
> Aid the compiler by adding a BUG_ON() checking the return value of the
> problematic p2m_get_altp2m(). Since with the use of the local variable
> the 2nd p2m_get_altp2m() each will look questionable at the first glance
> (Why is the local variable not used here?), open-code the only relevant
> piece of p2m_get_altp2m() there.
>
> To avoid repeatedly doing these transformations, and also to limit how
> "bad" the open-coding really is, convert the entire operation to an
> inline helper, used by all three instances (and accepting the redundant
> BUG_ON(idx >= MAX_ALTP2M) in two of the three cases).
>
> Reported-by: Charles Arnold <carnold@xxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>





 


Rackspace

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