public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>
To: Li Bin <huawei.libin@huawei.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Marcus Shawcroft <marcus.shawcroft@arm.com>,
	richard.earnshaw@arm.com, andrew.wafaa@arm.com,
	szabolcs.nagy@arm.com, masami.hiramatsu.pt@hitachi.com,
	geoff@infradead.org, takahiro.akashi@linaro.org,
	guohanjun@huawei.com, felix.yang@huawei.com,
	jiangjiji@huawei.com
Subject: Re: [PATCH] [AArch64] support -mfentry feature for arm64
Date: Thu, 14 Apr 2016 13:08:00 -0000	[thread overview]
Message-ID: <B6E2AECD-096C-489F-A217-8140E781E722@linaro.org> (raw)
In-Reply-To: <1457943260-30894-1-git-send-email-huawei.libin@huawei.com>

On Mar 14, 2016, at 11:14 AM, Li Bin <huawei.libin@huawei.com> wrote:
> 
> As ARM64 is entering enterprise world, machines can not be stopped for
> some critical enterprise production environment, that is, live patch as
> one of the RAS features is increasing more important for ARM64 arch now.
> 
> Now, the mainstream live patch implementation which has been merged in
> Linux kernel (x86/s390) is based on the 'ftrace with regs' feature, and
> this feature needs the help of gcc. 
> 
> This patch proposes a generic solution for arm64 gcc which called mfentry,
> following the example of x86, mips, s390, etc. and on these archs, this
> feature has been used to implement the ftrace feature 'ftrace with regs'
> to support live patch.
> 
> By now, there is an another solution from linaro [1], which proposes to
> implement a new option -fprolog-pad=N that generate a pad of N nops at the
> beginning of each function. This solution is a arch-independent way for gcc,
> but there may be some limitations which have not been recognized for Linux
> kernel to adapt to this solution besides the discussion on [2]

It appears that implementing -fprolog-pad=N option in GCC will not enable kernel live-patching support for AArch64.  The proposal for the option was to make GCC output a given number of NOPs at the beginning of each function, and then the kernel could use that NOP pad to insert whatever instructions it needs.  The modification of kernel instruction stream needs to be done atomically, and, unfortunately, it seems the kernel can use only architecture-provided atomicity primitives -- i.e., changing at most 8 bytes at a time.

From the kernel discussion thread it appears that the pad needs to be more than 8 bytes, and that the kernel can't update that atomically.  However if -mfentry approach is used, then we need to update only 4 (or 8) bytes of the pad, and we avoid the atomicity problem.

Therefore, [unless there is a clever multi-stage update process to atomically change NOPs to whatever we need,] I think we have to go with Li's -mfentry approach.

Comments?

--
Maxim Kuvyrkov
www.linaro.org


> , typically
> for powerpc archs. Furthermore I think there are no good reasons to promote
> the other archs (such as x86) which have implemented the feature 'ftrace with regs'
> to replace the current method with the new option, which may bring heavily
> target-dependent code adaption, as a result it becomes a arm64 dedicated
> solution, leaving kernel with two different forms of implementation. 
> 
> [1] https://gcc.gnu.org/ml/gcc/2015-10/msg00090.html
> [2] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/401854.html

  parent reply	other threads:[~2016-04-14 13:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14  8:13 Li Bin
2016-03-14  8:12 ` Li Bin
2016-04-14 13:08 ` Maxim Kuvyrkov [this message]
2016-04-14 13:15   ` Andrew Pinski
2016-04-14 15:58     ` Szabolcs Nagy
2016-04-18 13:26       ` Alexander Monakov
2016-04-18 13:34         ` Ramana Radhakrishnan
2016-04-18 13:44           ` Alexander Monakov
2016-04-18 13:57             ` Ramana Radhakrishnan
2016-04-18 14:03               ` Alexander Monakov
2016-04-18 14:31         ` Szabolcs Nagy
2016-04-18 15:54           ` Alexander Monakov
2016-04-19  6:46             ` AKASHI Takahiro
2016-04-19  6:13       ` AKASHI Takahiro
2016-04-19  6:44         ` Alexander Monakov
2016-04-20  0:33           ` AKASHI Takahiro
2016-04-20 10:02             ` Szabolcs Nagy
2016-04-15 15:40   ` Michael Matz
2016-04-15 17:29     ` Alexander Monakov
2016-04-17 15:06       ` Alexander Monakov
2016-04-18 12:12         ` Michael Matz
2016-04-19  6:26           ` AKASHI Takahiro
2016-04-19  6:39             ` Alexander Monakov
2016-04-20  1:23               ` AKASHI Takahiro
2016-04-20 16:45                 ` Szabolcs Nagy
2016-04-19 16:03           ` Torsten Duwe
2016-04-18 14:32       ` Andrew Haley
2016-04-18 17:13         ` Michael Matz
2016-04-18 17:17           ` Andrew Haley
2016-04-18 17:34             ` Michael Matz
2016-04-19  8:00               ` Andrew Haley
2016-04-19 13:19                 ` Michael Matz
2016-04-19 13:25                   ` Andrew Haley
2016-04-19 14:38                     ` Pedro Alves
2016-04-19 15:02                       ` Andrew Haley
2016-04-19  6:08   ` AKASHI Takahiro
  -- strict thread matches above, loose matches on Subject: below --
2015-10-22 13:24 Li Bin
2015-10-22 13:53 ` Marcus Shawcroft

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=B6E2AECD-096C-489F-A217-8140E781E722@linaro.org \
    --to=maxim.kuvyrkov@linaro.org \
    --cc=andrew.wafaa@arm.com \
    --cc=felix.yang@huawei.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=geoff@infradead.org \
    --cc=guohanjun@huawei.com \
    --cc=huawei.libin@huawei.com \
    --cc=jiangjiji@huawei.com \
    --cc=marcus.shawcroft@arm.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=richard.earnshaw@arm.com \
    --cc=szabolcs.nagy@arm.com \
    --cc=takahiro.akashi@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).