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

Re: [PATCH] x86/apic: Fix function typechecking in TSC Deadline errata check


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 21 Mar 2022 15:26:58 +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=0nwF8ZkQijh8KmoexSo2KCHR0pN9MhvySp0PIvPM7TY=; b=h5HKZcICpDi2qk3P7cIX7f+bHDxy4SBolnDMY5GCO5JIOw705Bkh20OmvgQ2epqpqODnS6rclBx9feMKP9ua7Ml6sQPuys1PKeCz782vbBOuatdVALhRPEh3aaDimgc627ZpRlxKoe8V3snJwK7WgVhHzvHoM8p9bwtUvY9gUUNekyv2goHh4FR+iS4cLfrMpp7/HDVIHsNnT75addc1GlfCenP5AaqQVDnn3NFibWQa/MnefTtECTcskNBm3yqPSVIwfdnsAHdS7iuvT2CG0dwZgkFHpVgeASqfxUPI2piuqzqOiJOBtSq9fplanEyPlNL2LUhXfh/nOBAlbatFbQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VD11Gb3hoeNHBANIT2jyprQdIEe9WwSaDZQ8W08ymsHv5fvc/c/IthQvY/UqDxryKYjQwd5uvT2PIJ3Z4Oi6uUfjgQCZMt3MBgtiLTWGw+YGMaJ5y0Ds3qcktss/O+zhpUI1hKem2sV6252IZ2xLMaRPlFcytTkYUjjxP57gjwteeIi+y+Cw8Mt+FlQCZ8tVHoSjwZfwo2ZcrtxdNYGAADGaQko2InwR9Xt6DphBdbQNZRtKDczjm5gkCNlIMjcl9q7d1DMjJXrUg1jI2XJRzezwK/28DWNcekCCdylP5sWBMlKuG8Rm9yf7iLnHfkbcU7ORKKsBsS2QofpT1aIu3Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 21 Mar 2022 14:27:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.03.2022 15:12, Andrew Cooper wrote:
> --- a/xen/arch/x86/apic.c
> +++ b/xen/arch/x86/apic.c
> @@ -1092,12 +1092,17 @@ static void setup_APIC_timer(void)
>      local_irq_restore(flags);
>  }
>  
> +#define DEADLINE_MODEL_FUNCT(m, fn) \
> +    { .vendor = X86_VENDOR_INTEL, .family = 6, .model = (m), \
> +      .feature = X86_FEATURE_TSC_DEADLINE, \
> +      .driver_data = fn + (0 * sizeof(fn == ((unsigned int (*)(void))NULL))) 
> }

Are you sure all compiler versions we support are happy about +
of a function pointer and a constant? Even if that constant is zero,
this is not legal as per the plain C spec.

Also strictly speaking you would want to parenthesize both uses of
fn.

>  #define DEADLINE_MODEL_MATCH(m, fr) \
>      { .vendor = X86_VENDOR_INTEL, .family = 6, .model = (m), \
>        .feature = X86_FEATURE_TSC_DEADLINE, \
>        .driver_data = (void *)(unsigned long)(fr) }

As long as we leave this in place, there's a (small) risk of the
wrong macro being used again if another hook would need adding here.
We might be safer if driver_data became "unsigned long" and the
void * cast was dropped from here (with an "unsigned long" cast
added in the new macro, which at the same time would address my
other concern above).

Jan




 


Rackspace

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