All of lore.kernel.org
 help / color / mirror / Atom feed
From: shc_work@mail.ru (Alexander Shiyan)
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 10/10] ARM: FIQ: Get rid of init_FIQ()
Date: Fri, 23 Nov 2012 07:40:30 +0400	[thread overview]
Message-ID: <1353642030.851395840@f20.mail.ru> (raw)
In-Reply-To: <1353631803-4853-10-git-send-email-anton.vorontsov@linaro.org>

> The function only saves initial arch-specific "no FIQ" instruction, by
> placing the code into set_fiq_handler() we can:
> 
> - Have less code and logic in the platform-specific files;
> - Have the code that manages FIQ vector overwriting in one place, i.e.
>   don't spread the logic around.
> 
> p.s. Also, I noticed that we saved no_fiq_insn w/o bothering about
> !CONFIG_CPU_USE_DOMAINS case, but set_fiq_handler() handles this case
> specifically. I wonder, was that on purpose, e.g. it does not matter for
> init_FIQ(), or it was just overlooked? In the latter case, the patch fixes
> the issue.
...
> diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
> index 9bf3a60..3602df6 100644
> --- a/arch/arm/kernel/fiq.c
> +++ b/arch/arm/kernel/fiq.c
> @@ -49,6 +49,7 @@
>  #include <asm/mach/irq.h>
>  
>  static unsigned long no_fiq_insn;
> +static int got_no_fiq_insn;
>  
>  /* Default reacquire function
>   * - we always relinquish FIQ control
> @@ -78,11 +79,14 @@ void show_fiq_list(struct seq_file *p, int prec)
>  
>  void set_fiq_handler(void *start, unsigned int length)
>  {
> -#if defined(CONFIG_CPU_USE_DOMAINS)
> -	memcpy((void *)0xffff001c, start, length);
> -#else
> -	memcpy(vectors_page + 0x1c, start, length);
> +	unsigned long *addr = (void *)0xffff001c;
> +
> +#ifndef CONFIG_CPU_USE_DOMAINS
> +	addr = vectors_page + 0x1c;
>  #endif
> +	if (!cmpxchg(&got_no_fiq_insn, 0, 1))
> +		no_fiq_insn = *addr;
> +	memcpy(addr, start, length);
>  	flush_icache_range(0xffff001c, 0xffff001c + length);
>  	if (!vectors_high())
>  		flush_icache_range(0x1c, 0x1c + length);
> @@ -126,8 +130,3 @@ EXPORT_SYMBOL(__set_fiq_regs);	/* defined in fiqasm.S */
>  EXPORT_SYMBOL(__get_fiq_regs);	/* defined in fiqasm.S */
>  EXPORT_SYMBOL(claim_fiq);
>  EXPORT_SYMBOL(release_fiq);
> -
> -void __init init_FIQ(void)
> -{
> -	no_fiq_insn = *(unsigned long *)0xffff001c;

it seems that this is wrong. In this case we have an uninitialized variable and
sequential call claim_fiq and release_fiq could be fatal. FIXME please.

---

WARNING: multiple messages have this Message-ID (diff)
From: "Alexander Shiyan" <shc_work@mail.ru>
To: "Anton Vorontsov" <anton.vorontsov@linaro.org>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	linaro-kernel@lists.linaro.org,
	"Russell King" <linux@arm.linux.org.uk>,
	patches@linaro.org, linux-kernel@vger.kernel.org,
	"John Stultz" <john.stultz@linaro.org>,
	"Jason Wessel" <jason.wessel@windriver.com>,
	kernel-team@android.com, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 10/10] ARM: FIQ: Get rid of init_FIQ()
Date: Fri, 23 Nov 2012 07:40:30 +0400	[thread overview]
Message-ID: <1353642030.851395840@f20.mail.ru> (raw)
In-Reply-To: <1353631803-4853-10-git-send-email-anton.vorontsov@linaro.org>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 2200 bytes --]

> The function only saves initial arch-specific "no FIQ" instruction, by
> placing the code into set_fiq_handler() we can:
> 
> - Have less code and logic in the platform-specific files;
> - Have the code that manages FIQ vector overwriting in one place, i.e.
>   don't spread the logic around.
> 
> p.s. Also, I noticed that we saved no_fiq_insn w/o bothering about
> !CONFIG_CPU_USE_DOMAINS case, but set_fiq_handler() handles this case
> specifically. I wonder, was that on purpose, e.g. it does not matter for
> init_FIQ(), or it was just overlooked? In the latter case, the patch fixes
> the issue.
...
> diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
> index 9bf3a60..3602df6 100644
> --- a/arch/arm/kernel/fiq.c
> +++ b/arch/arm/kernel/fiq.c
> @@ -49,6 +49,7 @@
>  #include <asm/mach/irq.h>
>  
>  static unsigned long no_fiq_insn;
> +static int got_no_fiq_insn;
>  
>  /* Default reacquire function
>   * - we always relinquish FIQ control
> @@ -78,11 +79,14 @@ void show_fiq_list(struct seq_file *p, int prec)
>  
>  void set_fiq_handler(void *start, unsigned int length)
>  {
> -#if defined(CONFIG_CPU_USE_DOMAINS)
> -	memcpy((void *)0xffff001c, start, length);
> -#else
> -	memcpy(vectors_page + 0x1c, start, length);
> +	unsigned long *addr = (void *)0xffff001c;
> +
> +#ifndef CONFIG_CPU_USE_DOMAINS
> +	addr = vectors_page + 0x1c;
>  #endif
> +	if (!cmpxchg(&got_no_fiq_insn, 0, 1))
> +		no_fiq_insn = *addr;
> +	memcpy(addr, start, length);
>  	flush_icache_range(0xffff001c, 0xffff001c + length);
>  	if (!vectors_high())
>  		flush_icache_range(0x1c, 0x1c + length);
> @@ -126,8 +130,3 @@ EXPORT_SYMBOL(__set_fiq_regs);	/* defined in fiqasm.S */
>  EXPORT_SYMBOL(__get_fiq_regs);	/* defined in fiqasm.S */
>  EXPORT_SYMBOL(claim_fiq);
>  EXPORT_SYMBOL(release_fiq);
> -
> -void __init init_FIQ(void)
> -{
> -	no_fiq_insn = *(unsigned long *)0xffff001c;

it seems that this is wrong. In this case we have an uninitialized variable and
sequential call claim_fiq and release_fiq could be fatal. FIXME please.

---
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

  reply	other threads:[~2012-11-23  3:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-23  0:38 [PATCH resend 0/10] Get rid of FIQ_START/enable/disable_fiq() + some FIQ cleanups Anton Vorontsov
2012-11-23  0:38 ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 01/10] ARM: mach-rpc: Don't register FIQs with genirq Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 02/10] ARM: plat-s3c24xx: Don't use FIQ_START Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 03/10] [media] mx1_camera: Don't use {en,dis}able_fiq() calls Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 04/10] ASoC: imx: " Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 05/10] ARM: FIQ: Remove enable_fiq() and disable_fiq() calls Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:49 ` [PATCH 06/10] ARM: FIQ: Remove FIQ_START Anton Vorontsov
2012-11-23  0:49   ` Anton Vorontsov
2012-11-23  0:50 ` [PATCH 07/10] ARM: FIQ: Should include asm/mach/irq.h Anton Vorontsov
2012-11-23  0:50   ` Anton Vorontsov
2012-11-23  0:50 ` [PATCH 08/10] ARM: FIQ: Implement !CONFIG_FIQ stubs Anton Vorontsov
2012-11-23  0:50   ` Anton Vorontsov
2012-11-23  0:50 ` [PATCH 09/10] ARM: FIQ: Make show_fiq_list() return void Anton Vorontsov
2012-11-23  0:50   ` Anton Vorontsov
2012-11-23  0:50 ` [PATCH 10/10] ARM: FIQ: Get rid of init_FIQ() Anton Vorontsov
2012-11-23  0:50   ` Anton Vorontsov
2012-11-23  3:40   ` Alexander Shiyan [this message]
2012-11-23  3:40     ` Alexander Shiyan
2012-11-23  5:53     ` Anton Vorontsov
2012-11-23  5:53       ` Anton Vorontsov
2012-11-23  6:27       ` Re[2]: " Alexander Shiyan
2012-11-23  6:27         ` Alexander Shiyan
2012-11-23  6:50         ` Anton Vorontsov
2012-11-23  6:50           ` Anton Vorontsov
2012-11-23  7:36           ` Re[2]: " Alexander Shiyan
2012-11-23  7:36             ` Alexander Shiyan
2012-11-23  7:51             ` Anton Vorontsov
2012-11-23  7:51               ` Anton Vorontsov
2012-11-27  9:05               ` Anton Vorontsov
2012-11-27  9:05                 ` Anton Vorontsov
  -- strict thread matches above, loose matches on Subject: below --
2012-10-15 21:49 [PATCH resend 0/10] Get rid of FIQ_START/enable/disable_fiq() + some FIQ cleanups Anton Vorontsov
2012-10-15 21:51 ` [PATCH 10/10] ARM: FIQ: Get rid of init_FIQ() Anton Vorontsov
2012-10-15 21:51   ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353642030.851395840@f20.mail.ru \
    --to=shc_work@mail.ru \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.