WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH] Fix cache flush bug of cpu offline

To: "Liu, Jinsong" <jinsong.liu@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH] Fix cache flush bug of cpu offline
From: Keir Fraser <keir@xxxxxxx>
Date: Fri, 11 Mar 2011 16:26:01 +0000
Cc: "Jiang, Yunhong" <yunhong.jiang@xxxxxxxxx>, "Shan, Haitao" <haitao.shan@xxxxxxxxx>, "Wei, Gang" <gang.wei@xxxxxxxxx>, "Yu, Ke" <ke.yu@xxxxxxxxx>, "Li, Xin" <xin.li@xxxxxxxxx>
Delivery-date: Fri, 11 Mar 2011 08:26:51 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:user-agent:date:subject:from:to:cc :message-id:thread-topic:thread-index:in-reply-to:mime-version :content-type:content-transfer-encoding; bh=WhMD8UxISa71iPT73Kqiv+ygoaTjuYcrMIEvWJ+Qk20=; b=SJbfXT6CBzQvBOvg12ATd/+HypTPB/6epPmxTmnLY9RjBGN/6mg79cgEa4Ba6MYUF8 p/4lhpxDhrWaqmcDENnibvSbJCseGXDyQfW+HGUH4pU1AE51GKluY/wxK+TmJuCjaPSM zm4aE3qQQK01uVpxQkk3dA4BHgItWsjf6kYng=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:user-agent:date:subject:from:to:cc:message-id:thread-topic :thread-index:in-reply-to:mime-version:content-type :content-transfer-encoding; b=o1uM7vS2pHabaFu3SCp9hXWriKI5U8Qzno/lQCQ3eTV19XOLgCXDP+XRJntpBRCwIc AOZJybRbYOEeqvZBLznFEyu3PsnNThXq9uTkgGW3dk/yfUre4WCEEu9DtB+tuVTIdWW5 ZvSF4GP4Z1rfwYM5TNpOFempv+dKZ/q8zMeO0=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <BC00F5384FCFC9499AF06F92E8B78A9E1FCCF29C97@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acvf+Wq8eUV5g7VvTPu6ARIzvUA0UgAD5esZ
Thread-topic: [PATCH] Fix cache flush bug of cpu offline
User-agent: Microsoft-Entourage/12.28.0.101117
On 11/03/2011 14:34, "Liu, Jinsong" <jinsong.liu@xxxxxxxxx> wrote:

> Fix cache flush bug of cpu offline
> 
> Current xen cpu offline logic flush cache too early, which potentially break
> cache coherency.
> wbinvd should be the last ops before cpu going into dead, otherwise cache may
> be dirty, 
> i.e, something like setting an A bit on page tables. Pointed out by Arjan van
> de Ven.

The position still seems a bit arbitrary. In the first hunk below, why is it
safe to wbinvd() outside the for-loop and before reading cx->entry_method,
but not before reading from processor_powers[]? It would be neater if we
could put the wbinvd() in a wrapper function for calling *dead_idle.

 -- Keir

> Signed-off-by: Liu, Jinsong <jinsong.liu@xxxxxxxxx>
> 
> diff -r 2dc3c1cc1bba xen/arch/x86/acpi/cpu_idle.c
> --- a/xen/arch/x86/acpi/cpu_idle.c Mon Mar 07 05:31:46 2022 +0800
> +++ b/xen/arch/x86/acpi/cpu_idle.c Thu Mar 10 23:40:51 2022 +0800
> @@ -562,11 +562,14 @@ static void acpi_dead_idle(void)
>      if ( (cx = &power->states[power->count-1]) == NULL )
>          goto default_halt;
>  
> +    /*
> +     * cache must be flashed as the last ops before cpu going into dead,
> +     * otherwise, cpu may dead with dirty data breaking cache coherency,
> +     * leading to strange errors.
> +     */
> +    wbinvd();
>      for ( ; ; )
>      {
> -        if ( !power->flags.bm_check && cx->type == ACPI_STATE_C3 )
> -            ACPI_FLUSH_CPU_CACHE();
> -
>          switch ( cx->entry_method )
>          {
>              case ACPI_CSTATE_EM_FFH:
> @@ -584,6 +587,7 @@ static void acpi_dead_idle(void)
>      }
>  
>  default_halt:
> +    wbinvd();
>      for ( ; ; )
>          halt();
>  }
> diff -r 2dc3c1cc1bba xen/arch/x86/domain.c
> --- a/xen/arch/x86/domain.c Mon Mar 07 05:31:46 2022 +0800
> +++ b/xen/arch/x86/domain.c Thu Mar 10 23:40:51 2022 +0800
> @@ -93,6 +93,12 @@ static void default_idle(void)
>  
>  static void default_dead_idle(void)
>  {
> +    /*
> +     * cache must be flashed as the last ops before cpu going into dead,
> +     * otherwise, cpu may dead with dirty data breaking cache coherency,
> +     * leading to strange errors.
> +     */
> +    wbinvd();
>      for ( ; ; )
>          halt();
>  }
> @@ -100,7 +106,6 @@ static void play_dead(void)
>  static void play_dead(void)
>  {
>      local_irq_disable();
> -    wbinvd();
>  
>      /*
>       * NOTE: After cpu_exit_clear, per-cpu variables are no longer
> accessible,



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel