All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Cc: Russell King <linux@armlinux.org.uk>,
	Nicolas Pitre <nico@fluxnic.net>, Arnd Bergmann <arnd@arndb.de>,
	Kees Cook <keescook@chromium.org>,
	Keith Packard <keithpac@amazon.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tony Lindgren <tony@atomide.com>,
	'Linux Samsung SOC' <linux-samsung-soc@vger.kernel.org>
Subject: Re: [PATCH v4 7/7] ARM: implement support for vmap'ed stacks
Date: Tue, 21 Dec 2021 11:46:43 +0100	[thread overview]
Message-ID: <fbd24aa1-4e04-feff-9125-482db22a05ef@samsung.com> (raw)
In-Reply-To: <b484dea4-da88-3e09-64c5-e1b5bb6cd639@kernel.org>

Hi Krzysztof,

On 21.12.2021 11:42, Krzysztof Kozlowski wrote:
> On 21/12/2021 11:38, Marek Szyprowski wrote:
>> On 22.11.2021 10:28, Ard Biesheuvel wrote:
>>> Wire up the generic support for managing task stack allocations via vmalloc,
>>> and implement the entry code that detects whether we faulted because of a
>>> stack overrun (or future stack overrun caused by pushing the pt_regs array)
>>>
>>> While this adds a fair amount of tricky entry asm code, it should be
>>> noted that it only adds a TST + branch to the svc_entry path. The code
>>> implementing the non-trivial handling of the overflow stack is emitted
>>> out-of-line into the .text section.
>>>
>>> Since on ARM, we rely on do_translation_fault() to keep PMD level page
>>> table entries that cover the vmalloc region up to date, we need to
>>> ensure that we don't hit such a stale PMD entry when accessing the
>>> stack. So we do a dummy read from the new stack while still running from
>>> the old one on the context switch path, and bump the vmalloc_seq counter
>>> when PMD level entries in the vmalloc range are modified, so that the MM
>>> switch fetches the latest version of the entries.
>>>
>>> Note that we need to increase the per-mode stack by 1 word, to gain some
>>> space to stash a GPR until we know it is safe to touch the stack.
>>> However, due to the cacheline alignment of the struct, this does not
>>> actually increase the memory footprint of the struct stack array at all.
>>>
>>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>>> Tested-by: Keith Packard <keithpac@amazon.com>
>>
>> This patch landed recently in linux-next 20211220 as commit a1c510d0adc6
>> ("ARM: implement support for vmap'ed stacks"). Sadly it breaks
>> suspend/resume operation on all ARM 32bit Exynos SoCs. Probably the
>> suspend/resume related code must be updated somehow (it partially works
>> on physical addresses and disabled MMU), but I didn't analyze it yet. If
>> you have any hints, let me know.
> Maybe this one would help?
> https://lore.kernel.org/lkml/20211218085843.212497-2-cuigaosheng1@huawei.com/

I forgot to mention. I've already checked it and it doesn't change/fix 
anything. It also doesn't break the old (pre-a1c510d0adc) code though.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


WARNING: multiple messages have this Message-ID (diff)
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Krzysztof Kozlowski <krzk@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Cc: Russell King <linux@armlinux.org.uk>,
	Nicolas Pitre <nico@fluxnic.net>, Arnd Bergmann <arnd@arndb.de>,
	Kees Cook <keescook@chromium.org>,
	Keith Packard <keithpac@amazon.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tony Lindgren <tony@atomide.com>,
	'Linux Samsung SOC' <linux-samsung-soc@vger.kernel.org>
Subject: Re: [PATCH v4 7/7] ARM: implement support for vmap'ed stacks
Date: Tue, 21 Dec 2021 11:46:43 +0100	[thread overview]
Message-ID: <fbd24aa1-4e04-feff-9125-482db22a05ef@samsung.com> (raw)
In-Reply-To: <b484dea4-da88-3e09-64c5-e1b5bb6cd639@kernel.org>

Hi Krzysztof,

On 21.12.2021 11:42, Krzysztof Kozlowski wrote:
> On 21/12/2021 11:38, Marek Szyprowski wrote:
>> On 22.11.2021 10:28, Ard Biesheuvel wrote:
>>> Wire up the generic support for managing task stack allocations via vmalloc,
>>> and implement the entry code that detects whether we faulted because of a
>>> stack overrun (or future stack overrun caused by pushing the pt_regs array)
>>>
>>> While this adds a fair amount of tricky entry asm code, it should be
>>> noted that it only adds a TST + branch to the svc_entry path. The code
>>> implementing the non-trivial handling of the overflow stack is emitted
>>> out-of-line into the .text section.
>>>
>>> Since on ARM, we rely on do_translation_fault() to keep PMD level page
>>> table entries that cover the vmalloc region up to date, we need to
>>> ensure that we don't hit such a stale PMD entry when accessing the
>>> stack. So we do a dummy read from the new stack while still running from
>>> the old one on the context switch path, and bump the vmalloc_seq counter
>>> when PMD level entries in the vmalloc range are modified, so that the MM
>>> switch fetches the latest version of the entries.
>>>
>>> Note that we need to increase the per-mode stack by 1 word, to gain some
>>> space to stash a GPR until we know it is safe to touch the stack.
>>> However, due to the cacheline alignment of the struct, this does not
>>> actually increase the memory footprint of the struct stack array at all.
>>>
>>> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>>> Tested-by: Keith Packard <keithpac@amazon.com>
>>
>> This patch landed recently in linux-next 20211220 as commit a1c510d0adc6
>> ("ARM: implement support for vmap'ed stacks"). Sadly it breaks
>> suspend/resume operation on all ARM 32bit Exynos SoCs. Probably the
>> suspend/resume related code must be updated somehow (it partially works
>> on physical addresses and disabled MMU), but I didn't analyze it yet. If
>> you have any hints, let me know.
> Maybe this one would help?
> https://lore.kernel.org/lkml/20211218085843.212497-2-cuigaosheng1@huawei.com/

I forgot to mention. I've already checked it and it doesn't change/fix 
anything. It also doesn't break the old (pre-a1c510d0adc) code though.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-12-21 10:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  9:28 [PATCH v4 0/7] ARM: add vmap'ed stack support Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 1/7] ARM: memcpy: use frame pointer as unwind anchor Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 2/7] ARM: memmove: " Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 3/7] ARM: memset: clean up unwind annotations Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 4/7] ARM: unwind: disregard unwind info before stack frame is set up Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 5/7] ARM: switch_to: clean up Thumb2 code path Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 6/7] ARM: entry: rework stack realignment code in svc_entry Ard Biesheuvel
2021-11-22  9:28 ` [PATCH v4 7/7] ARM: implement support for vmap'ed stacks Ard Biesheuvel
     [not found]   ` <CGME20211221103854eucas1p2592e38fcc84c1c3506fce87f1dab6739@eucas1p2.samsung.com>
2021-12-21 10:38     ` Marek Szyprowski
2021-12-21 10:38       ` Marek Szyprowski
2021-12-21 10:42       ` Krzysztof Kozlowski
2021-12-21 10:42         ` Krzysztof Kozlowski
2021-12-21 10:46         ` Marek Szyprowski [this message]
2021-12-21 10:46           ` Marek Szyprowski
2021-12-21 10:44       ` Ard Biesheuvel
2021-12-21 10:44         ` Ard Biesheuvel
2021-12-21 11:15         ` Marek Szyprowski
2021-12-21 11:15           ` Marek Szyprowski
2021-12-21 13:34           ` Ard Biesheuvel
2021-12-21 13:34             ` Ard Biesheuvel
2021-12-21 13:51             ` Marek Szyprowski
2021-12-21 13:51               ` Marek Szyprowski
2021-12-21 16:20               ` Ard Biesheuvel
2021-12-21 16:20                 ` Ard Biesheuvel
2021-12-21 21:56                 ` Marek Szyprowski
2021-12-21 21:56                   ` Marek Szyprowski
2021-12-23 14:23                   ` Ard Biesheuvel
2021-12-23 14:23                     ` Ard Biesheuvel
2021-12-28 14:39                     ` Geert Uytterhoeven
2021-12-28 14:39                       ` Geert Uytterhoeven
2021-12-28 16:12                       ` Geert Uytterhoeven
2021-12-28 16:12                         ` Geert Uytterhoeven
2021-12-28 16:27                         ` Ard Biesheuvel
2021-12-28 16:27                           ` Ard Biesheuvel
2022-01-05 11:08                       ` Jon Hunter
2022-01-05 11:08                         ` Jon Hunter
2022-01-05 11:12                         ` Ard Biesheuvel
2022-01-05 11:12                           ` Ard Biesheuvel
2022-01-05 11:33                           ` Jon Hunter
2022-01-05 11:33                             ` Jon Hunter
2022-01-05 13:53                             ` Russell King (Oracle)
2022-01-05 13:53                               ` Russell King (Oracle)
2022-01-05 16:49                           ` Jon Hunter
2022-01-05 16:49                             ` Jon Hunter
2022-01-05 17:02                             ` Ard Biesheuvel
2022-01-05 17:02                               ` Ard Biesheuvel

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=fbd24aa1-4e04-feff-9125-482db22a05ef@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=keescook@chromium.org \
    --cc=keithpac@amazon.com \
    --cc=krzk@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ndesaulniers@google.com \
    --cc=nico@fluxnic.net \
    --cc=tony@atomide.com \
    /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.