mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: Youling Tang <tangyouling@loongson.cn>
Cc: Jinyang He <hejinyang@loongson.cn>,
	loongarch@lists.linux.dev, Huacai Chen <chenhuacai@kernel.org>,
	WANG Xuerui <kernel@xen0n.name>,
	linux-kernel@vger.kernel.org
Subject: Re: "kernel ade access" oops on LoongArch
Date: Wed, 15 Feb 2023 21:06:21 +0800	[thread overview]
Message-ID: <1f2b697ee10ba1b1ea2e2128697e1924d2479d4c.camel@xry111.site> (raw)
In-Reply-To: <6268f221cfca8b7550ad0673246f09cd439ede05.camel@xry111.site>

On Wed, 2023-02-15 at 20:51 +0800, Xi Ruoyao wrote:
> On Wed, 2023-02-15 at 19:52 +0800, Xi Ruoyao wrote:
> > On Wed, 2023-02-15 at 16:35 +0800, Xi Ruoyao wrote:
> > > On Wed, 2023-02-15 at 16:25 +0800, Youling Tang wrote:
> > > > Can you modify the kernel as follows and test it, so as to avoid
> > > > possible relationship with the exception table data link
> > > > position
> > > > and
> > > > alignment rules (or use EXCEPTION_TABLE(12))?
> > > > 
> > > > --- a/arch/loongarch/kernel/vmlinux.lds.S
> > > > +++ b/arch/loongarch/kernel/vmlinux.lds.S
> > > > @@ -4,7 +4,6 @@
> > > >   #include <asm/thread_info.h>
> > > > 
> > > >   #define PAGE_SIZE _PAGE_SIZE
> > > > -#define RO_EXCEPTION_TABLE_ALIGN       4
> > > > 
> > > >   /*
> > > >    * Put .bss..swapper_pg_dir as the first thing in .bss. This
> > > > will
> > > > @@ -54,6 +53,8 @@ SECTIONS
> > > >          . = ALIGN(PECOFF_SEGMENT_ALIGN);
> > > >          _etext = .;
> > > > 
> > > > +       EXCEPTION_TABLE(16)
> > > > +
> > > 
> > > It seems the kernel refuses to boot after the change, but I'm not
> > > completely sure: I'm 5 km away from the board and operating it via
> > > ssh
> > > so maybe it's a reboot failure or network failure.  I'll report
> > > again in
> > > the evening.
> > 
> > It was a reboot failure.
> > 
> > Now it has booted successfully, but the stack trace still shows
> > (during
> > the 25th run of the make test t=... command).
> 
> Ouch, I know what's happening...
> 
> In the architecture-independent code we have something like
> 
> extern struct exception_table_entry a[], b[];
> bsearch(a, b - a);
> 
> According to the C standard, when you write "b - a" where a and b are
> pointers to type T, "b" and "a" must be pointers to elements in the
> same
> array of T.  So the compiler can assume ((uintptr_t)b - (uintptr_t)a)
> %
> 12 == 0 and optimize "b - a" to something like
> 
> (((uintptr_t)b - (uintptr_t)a) >> 2) * inv3
> 
> Here inv3 is the inversion of 3 in the modulo-2**64 integer ring, so
> the
> compiler can avoid an expensive divide instruction.  But in my vmlinux
> ((uintptr_t)b - (uintptr_t)a) is somehow not a multiple of 12:
> 
> (gdb) p ((uintptr_t)__stop___ex_table - (uintptr_t)__start___ex_table)
> % sizeof(struct exception_table_entry)
> $9 = 8
> 
> So I guess
> 
> #define RO_EXCEPTION_TABLE_ALIGN       12
> 
> will work.  I'll take a try...

No, it's not related...

The reason is the "LoongArch: Add vector extensions support" in my local
repo is not same as the version in loongarch-next!  My local version
contains some ".section __ex_table", and the content seems predates the
relative exception table change.

Sorry for wasted you guys an afternoon :(.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

      reply	other threads:[~2023-02-15 13:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14  8:46 Xi Ruoyao
2023-02-14 14:51 ` Huacai Chen
2023-02-15  4:52 ` Youling Tang
2023-02-15  5:35   ` Xi Ruoyao
2023-02-15  7:23     ` Youling Tang
2023-02-15  7:51       ` Jinyang He
2023-02-15  8:07         ` Xi Ruoyao
2023-02-15  8:25           ` Youling Tang
2023-02-15  8:35             ` Xi Ruoyao
2023-02-15 11:52               ` Xi Ruoyao
2023-02-15 12:51                 ` Xi Ruoyao
2023-02-15 13:06                   ` Xi Ruoyao [this message]

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=1f2b697ee10ba1b1ea2e2128697e1924d2479d4c.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenhuacai@kernel.org \
    --cc=hejinyang@loongson.cn \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=tangyouling@loongson.cn \
    /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

all inboxes | Powered by JetHome®