From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 08/30] xen/x86: Mask out unknown features from Xen's capabilities Date: Fri, 12 Feb 2016 16:48:16 +0000 Message-ID: <56BE0CD0.9040208@citrix.com> References: <1454679743-18133-1-git-send-email-andrew.cooper3@citrix.com> <1454679743-18133-9-git-send-email-andrew.cooper3@citrix.com> <56BE19D902000078000D1850@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <56BE19D902000078000D1850@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Xen-devel List-Id: xen-devel@lists.xenproject.org On 12/02/16 16:43, Jan Beulich wrote: >>>> On 05.02.16 at 14:42, wrote: >> --- /dev/null >> +++ b/xen/arch/x86/cpuid.c >> @@ -0,0 +1,19 @@ >> +#include >> +#include >> + >> +const uint32_t known_features[] = INIT_KNOWN_FEATURES; >> + >> +static void __maybe_unused build_assertions(void) >> +{ >> + BUILD_BUG_ON(ARRAY_SIZE(known_features) != FSCAPINTS); > This is sort of redundant with ... > >> --- /dev/null >> +++ b/xen/include/asm-x86/cpuid.h >> @@ -0,0 +1,24 @@ >> +#ifndef __X86_CPUID_H__ >> +#define __X86_CPUID_H__ >> + >> +#include >> + >> +#define FSCAPINTS FEATURESET_NR_ENTRIES >> + >> +#ifndef __ASSEMBLY__ >> +#include >> + >> +extern const uint32_t known_features[FSCAPINTS]; > ... the use of FSCAPINTS here. You'd catch more mistakes if you > just used [] here. Not quite. The extern gives an explicit size so other translation units can use ARRAY_SIZE(). Without the BUILD_BUG_ON(), const uint32_t known_features[] can actually be longer than FSCAPINTS, and everything compiles fine. The BUILD_BUG_ON() were introduced following an off-by-one error generating INIT_KNOWN_FEATURES, where ARRAY_SIZE(known_features) was different in this translation unit than all others. > > But either way > Acked-by: Jan Beulich Thanks, ~Andrew