From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] MIPS: Allow vectored interrupt handler to reside everywhere for 64bit
Date: Fri, 22 Dec 2023 12:58:43 +0000 [thread overview]
Message-ID: <7249cb98-0b63-4ef6-8f6e-e29ac6c0a73f@flygoat.com> (raw)
In-Reply-To: <20231221125405.229100-1-tsbogend@alpha.franken.de>
在 2023/12/21 12:54, Thomas Bogendoerfer 写道:
> Setting up vector interrupts worked only with handlers, which resided
> in CKSEG0 space. This limits the kernel placement for 64bit platforms.
> By patching in the offset into vi_handlers[] instead of the full
> handler address, the vectored exception handler can load the
> address by itself and jump to it.
>
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Could you please keep me in Cc if you are going to propose a better
solution :-)
Thanks
- Jiaxun
> ---
> arch/mips/kernel/genex.S | 8 ++++----
> arch/mips/kernel/traps.c | 9 +++------
> 2 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
> index b6de8e88c1bd..a572ce36a24f 100644
> --- a/arch/mips/kernel/genex.S
> +++ b/arch/mips/kernel/genex.S
> @@ -272,18 +272,17 @@ NESTED(except_vec_vi, 0, sp)
> .set push
> .set noreorder
> PTR_LA v1, except_vec_vi_handler
> -FEXPORT(except_vec_vi_lui)
> - lui v0, 0 /* Patched */
> jr v1
> FEXPORT(except_vec_vi_ori)
> - ori v0, 0 /* Patched */
> + ori v0, zero, 0 /* Offset in vi_handlers[] */
> .set pop
> END(except_vec_vi)
> EXPORT(except_vec_vi_end)
>
> /*
> * Common Vectored Interrupt code
> - * Complete the register saves and invoke the handler which is passed in $v0
> + * Complete the register saves and invoke the handler, $v0 holds
> + * offset into vi_handlers[]
> */
> NESTED(except_vec_vi_handler, 0, sp)
> SAVE_TEMP
> @@ -331,6 +330,7 @@ NESTED(except_vec_vi_handler, 0, sp)
> /* Save task's sp on IRQ stack so that unwinding can follow it */
> LONG_S s1, 0(sp)
> 2:
> + PTR_L v0, vi_handlers(v0)
> jalr v0
>
> /* Restore sp */
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 246c6a6b0261..d90b18908692 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -2091,16 +2091,14 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
> * If no shadow set is selected then use the default handler
> * that does normal register saving and standard interrupt exit
> */
> - extern const u8 except_vec_vi[], except_vec_vi_lui[];
> + extern const u8 except_vec_vi[];
> extern const u8 except_vec_vi_ori[], except_vec_vi_end[];
> extern const u8 rollback_except_vec_vi[];
> const u8 *vec_start = using_rollback_handler() ?
> rollback_except_vec_vi : except_vec_vi;
> #if defined(CONFIG_CPU_MICROMIPS) || defined(CONFIG_CPU_BIG_ENDIAN)
> - const int lui_offset = except_vec_vi_lui - vec_start + 2;
> const int ori_offset = except_vec_vi_ori - vec_start + 2;
> #else
> - const int lui_offset = except_vec_vi_lui - vec_start;
> const int ori_offset = except_vec_vi_ori - vec_start;
> #endif
> const int handler_len = except_vec_vi_end - vec_start;
> @@ -2119,10 +2117,9 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
> #else
> handler_len);
> #endif
> - h = (u16 *)(b + lui_offset);
> - *h = (handler >> 16) & 0xffff;
> + /* insert offset into vi_handlers[] */
> h = (u16 *)(b + ori_offset);
> - *h = (handler & 0xffff);
> + *h = n * sizeof(handler);
> local_flush_icache_range((unsigned long)b,
> (unsigned long)(b+handler_len));
> }
next prev parent reply other threads:[~2023-12-22 12:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 12:54 [PATCH 1/2] MIPS: Allow vectored interrupt handler to reside everywhere for 64bit Thomas Bogendoerfer
2023-12-21 12:54 ` [PATCH 2/2] MIPS: Remove unused shadow GPR support from vector irq setup Thomas Bogendoerfer
2023-12-30 14:45 ` Thomas Bogendoerfer
2023-12-22 12:58 ` Jiaxun Yang [this message]
2023-12-30 14:45 ` [PATCH 1/2] MIPS: Allow vectored interrupt handler to reside everywhere for 64bit Thomas Bogendoerfer
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=7249cb98-0b63-4ef6-8f6e-e29ac6c0a73f@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.de \
/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