<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/git/stable/linux.git/arch/csky, branch linux-5.7.y</title>
<subtitle>Linux kernel stable tree</subtitle>
<id>https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/atom?h=linux-5.7.y</id>
<link rel='self' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/atom?h=linux-5.7.y'/>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/'/>
<updated>2020-05-28T00:18:36+00:00</updated>
<entry>
<title>csky: Fixup CONFIG_DEBUG_RSEQ</title>
<updated>2020-05-28T00:18:36+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-26T06:34:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f36e0aab6f1f78d770ce859df3f07a9c5763ce5f'/>
<id>urn:sha1:f36e0aab6f1f78d770ce859df3f07a9c5763ce5f</id>
<content type='text'>
Put the rseq_syscall check point at the prologue of the syscall
will break the a0 ... a7. This will casue system call bug when
DEBUG_RSEQ is enabled.

So move it to the epilogue of syscall, but before syscall_trace.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Coding convention in entry.S</title>
<updated>2020-05-28T00:18:36+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-24T12:14:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=20f69538b9ab7175e1474a73e2793b8278846e1e'/>
<id>urn:sha1:20f69538b9ab7175e1474a73e2793b8278846e1e</id>
<content type='text'>
There is no fixup or feature in the patch, we only cleanup with:

 - Remove unnecessary reg used (r11, r12), just use r9 &amp; r10 &amp;
   syscallid regs as temp useage.
 - Add _TIF_SYSCALL_WORK and _TIF_WORK_MASK to gather macros.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup abiv2 syscall_trace break a4 &amp; a5</title>
<updated>2020-05-28T00:18:36+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-24T10:44:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e0bbb53843b5fdfe464b099217e3b9d97e8a75d7'/>
<id>urn:sha1:e0bbb53843b5fdfe464b099217e3b9d97e8a75d7</id>
<content type='text'>
Current implementation could destory a4 &amp; a5 when strace, so we need to get them
from pt_regs by SAVE_ALL.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup CONFIG_PREEMPT panic</title>
<updated>2020-05-28T00:18:36+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-24T08:03:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=900897591b2bf01154db8f59f6ecf8d60e60f15e'/>
<id>urn:sha1:900897591b2bf01154db8f59f6ecf8d60e60f15e</id>
<content type='text'>
log:
[    0.13373200] Calibrating delay loop...
[    0.14077600] ------------[ cut here ]------------
[    0.14116700] WARNING: CPU: 0 PID: 0 at kernel/sched/core.c:3790 preempt_count_add+0xc8/0x11c
[    0.14348000] DEBUG_LOCKS_WARN_ON((preempt_count() &lt; 0))Modules linked in:
[    0.14395100] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.6.0 #7
[    0.14410800]
[    0.14427400] Call Trace:
[    0.14450700] [&lt;807cd226&gt;] dump_stack+0x8a/0xe4
[    0.14473500] [&lt;80072792&gt;] __warn+0x10e/0x15c
[    0.14495900] [&lt;80072852&gt;] warn_slowpath_fmt+0x72/0xc0
[    0.14518600] [&lt;800a5240&gt;] preempt_count_add+0xc8/0x11c
[    0.14544900] [&lt;807ef918&gt;] _raw_spin_lock+0x28/0x68
[    0.14572600] [&lt;800e0eb8&gt;] vprintk_emit+0x84/0x2d8
[    0.14599000] [&lt;800e113a&gt;] vprintk_default+0x2e/0x44
[    0.14625100] [&lt;800e2042&gt;] vprintk_func+0x12a/0x1d0
[    0.14651300] [&lt;800e1804&gt;] printk+0x30/0x48
[    0.14677600] [&lt;80008052&gt;] lockdep_init+0x12/0xb0
[    0.14703800] [&lt;80002080&gt;] start_kernel+0x558/0x7f8
[    0.14730000] [&lt;800052bc&gt;] csky_start+0x58/0x94
[    0.14756600] irq event stamp: 34
[    0.14775100] hardirqs last  enabled at (33): [&lt;80067370&gt;] ret_from_exception+0x2c/0x72
[    0.14793700] hardirqs last disabled at (34): [&lt;800e0eae&gt;] vprintk_emit+0x7a/0x2d8
[    0.14812300] softirqs last  enabled at (32): [&lt;800655b0&gt;] __do_softirq+0x578/0x6d8
[    0.14830800] softirqs last disabled at (25): [&lt;8007b3b8&gt;] irq_exit+0xec/0x128

The preempt_count of reg could be destroyed after csky_do_IRQ without reload
from memory.

After reference to other architectures (arm64, riscv), we move preempt entry
into ret_from_exception and disable irq at the beginning of
ret_from_exception instead of RESTORE_ALL.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
Reported-by: Lu Baoquan &lt;lu.baoquan@intellif.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup raw_copy_from_user()</title>
<updated>2020-05-14T16:16:30+00:00</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2020-04-07T01:40:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=51bb38cb78363fdad1f89e87357b7bc73e39ba88'/>
<id>urn:sha1:51bb38cb78363fdad1f89e87357b7bc73e39ba88</id>
<content type='text'>
If raw_copy_from_user(to, from, N) returns K, callers expect
the first N - K bytes starting at to to have been replaced with
the contents of corresponding area starting at from and the last
K bytes of destination *left* *unmodified*.

What arch/sky/lib/usercopy.c is doing is broken - it can lead to e.g.
data corruption on write(2).

raw_copy_to_user() is inaccurate about return value, which is a bug,
but consequences are less drastic than for raw_copy_from_user().
And just what are those access_ok() doing in there?  I mean, look into
linux/uaccess.h; that's where we do that check (as well as zero tail
on failure in the callers that need zeroing).

AFAICS, all of that shouldn't be hard to fix; something like a patch
below might make a useful starting point.

I would suggest moving these macros into usercopy.c (they are never
used anywhere else) and possibly expanding them there; if you leave
them alive, please at least rename __copy_user_zeroing(). Again,
it must not zero anything on failed read.

Said that, I'm not sure we won't be better off simply turning
usercopy.c into usercopy.S - all that is left there is a couple of
functions, each consisting only of inline asm.

Guo Ren reply:

Yes, raw_copy_from_user is wrong, it's no need zeroing code.

unsigned long _copy_from_user(void *to, const void __user *from,
unsigned long n)
{
        unsigned long res = n;
        might_fault();
        if (likely(access_ok(from, n))) {
                kasan_check_write(to, n);
                res = raw_copy_from_user(to, from, n);
        }
        if (unlikely(res))
                memset(to + (n - res), 0, res);
        return res;
}
EXPORT_SYMBOL(_copy_from_user);

You are right and access_ok() should be removed.

but, how about:
do {
...
        "2:     stw     %3, (%1, 0)     \n"             \
+       "       subi    %0, 4          \n"               \
        "9:     stw     %4, (%1, 4)     \n"             \
+       "       subi    %0, 4          \n"               \
        "10:    stw     %5, (%1, 8)     \n"             \
+       "       subi    %0, 4          \n"               \
        "11:    stw     %6, (%1, 12)    \n"             \
+       "       subi    %0, 4          \n"               \
        "       addi    %2, 16          \n"             \
        "       addi    %1, 16          \n"             \

Don't expand __ex_table

AI Viro reply:

Hey, I've no idea about the instruction scheduling on csky -
if that doesn't slow the things down, all the better.  It's just
that copy_to_user() and friends are on fairly hot codepaths,
and in quite a few situations they will dominate the speed of
e.g. read(2).  So I tried to keep the fast path unchanged.
Up to the architecture maintainers, obviously.  Which would be
you...

As for the fixups size increase (__ex_table size is unchanged)...
You have each of those macros expanded exactly once.
So the size is not a serious argument, IMO - useless complexity
would be, if it is, in fact, useless; the size... not really,
especially since those extra subi will at least offset it.

Again, up to you - asm optimizations of (essentially)
memcpy()-style loops are tricky and can depend upon the
fairly subtle details of architecture.  So even on something
I know reasonably well I would resort to direct experiments
if I can't pass the buck to architecture maintainers.

It *is* worth optimizing - this is where read() from a file
that is already in page cache spends most of the time, etc.

Guo Ren reply:

Thx, after fixup some typo “sub %0, 4”, apply the patch.

TODO:
 - user copy/from codes are still need optimizing.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup gdbmacros.txt with name sp in thread_struct</title>
<updated>2020-05-14T16:16:18+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-14T08:04:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=67002814cf3b7265900003f6a49657847eeeb57d'/>
<id>urn:sha1:67002814cf3b7265900003f6a49657847eeeb57d</id>
<content type='text'>
The gdbmacros.txt use sp in thread_struct, but csky use ksp. This
cause bttnobp fail to excute.

TODO:
 - Still couldn't display the contents of stack.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup remove unnecessary save/restore PSR code</title>
<updated>2020-05-13T09:55:06+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-13T09:16:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9e2ca15322acc5a0a697305e02af9ce5ac881f66'/>
<id>urn:sha1:9e2ca15322acc5a0a697305e02af9ce5ac881f66</id>
<content type='text'>
All processes' PSR could success from SETUP_MMU, so need set it
in INIT_THREAD again.

And use a3 instead of r7 in __switch_to for code convention.

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup remove duplicate irq_disable</title>
<updated>2020-05-13T09:55:06+00:00</updated>
<author>
<name>Liu Yibin</name>
<email>jiulong@linux.alibaba.com</email>
</author>
<published>2020-05-13T07:54:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6633a5aa8eb6bda70eb3a9837efd28a67ccc6e0a'/>
<id>urn:sha1:6633a5aa8eb6bda70eb3a9837efd28a67ccc6e0a</id>
<content type='text'>
Interrupt has been disabled in __schedule() with local_irq_disable()
and enabled in finish_task_switch-&gt;finish_lock_switch() with
local_irq_enabled(), So needn't to disable irq here.

Signed-off-by: Liu Yibin &lt;jiulong@linux.alibaba.com&gt;
Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup calltrace panic</title>
<updated>2020-05-13T09:55:06+00:00</updated>
<author>
<name>Guo Ren</name>
<email>guoren@linux.alibaba.com</email>
</author>
<published>2020-05-13T07:15:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=18c07d23da5a48525b2955aa269b8bb108c19300'/>
<id>urn:sha1:18c07d23da5a48525b2955aa269b8bb108c19300</id>
<content type='text'>
The implementation of show_stack will panic with wrong fp:

addr    = *fp++;

because the fp isn't checked properly.

The current implementations of show_stack, wchan and stack_trace
haven't been designed properly, so just deprecate them.

This patch is a reference to riscv's way, all codes are modified from
arm's. The patch is passed with:

 - cat /proc/&lt;pid&gt;/stack
 - cat /proc/&lt;pid&gt;/wchan
 - echo c &gt; /proc/sysrq-trigger

Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
<entry>
<title>csky: Fixup perf callchain unwind</title>
<updated>2020-05-13T09:55:05+00:00</updated>
<author>
<name>Mao Han</name>
<email>han_mao@linux.alibaba.com</email>
</author>
<published>2020-04-20T04:55:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=229a0ddee1108a3f82a873e6cbbe35c92c540444'/>
<id>urn:sha1:229a0ddee1108a3f82a873e6cbbe35c92c540444</id>
<content type='text'>
 [ 5221.974084] Unable to handle kernel paging request at virtual address 0xfffff000, pc: 0x8002c18e
 [ 5221.985929] Oops: 00000000
 [ 5221.989488]
 [ 5221.989488] CURRENT PROCESS:
 [ 5221.989488]
 [ 5221.992877] COMM=callchain_test PID=11962
 [ 5221.995213] TEXT=00008000-000087e0 DATA=00009f1c-0000a018 BSS=0000a018-0000b000
 [ 5221.999037] USER-STACK=7fc18e20  KERNEL-STACK=be204680
 [ 5221.999037]
 [ 5222.003292] PC: 0x8002c18e (perf_callchain_kernel+0x3e/0xd4)
 [ 5222.007957] LR: 0x8002c198 (perf_callchain_kernel+0x48/0xd4)
 [ 5222.074873] Call Trace:
 [ 5222.074873] [&lt;800a248e&gt;] get_perf_callchain+0x20a/0x29c
 [ 5222.074873] [&lt;8009d964&gt;] perf_callchain+0x64/0x80
 [ 5222.074873] [&lt;8009dc1c&gt;] perf_prepare_sample+0x29c/0x4b8
 [ 5222.074873] [&lt;8009de6e&gt;] perf_event_output_forward+0x36/0x98
 [ 5222.074873] [&lt;800497e0&gt;] search_exception_tables+0x20/0x44
 [ 5222.074873] [&lt;8002cbb6&gt;] do_page_fault+0x92/0x378
 [ 5222.074873] [&lt;80098608&gt;] __perf_event_overflow+0x54/0xdc
 [ 5222.074873] [&lt;80098778&gt;] perf_swevent_hrtimer+0xe8/0x164
 [ 5222.074873] [&lt;8002ddd0&gt;] update_mmu_cache+0x0/0xd8
 [ 5222.074873] [&lt;8002c014&gt;] user_backtrace+0x58/0xc4
 [ 5222.074873] [&lt;8002c0b4&gt;] perf_callchain_user+0x34/0xd0
 [ 5222.074873] [&lt;800a2442&gt;] get_perf_callchain+0x1be/0x29c
 [ 5222.074873] [&lt;8009d964&gt;] perf_callchain+0x64/0x80
 [ 5222.074873] [&lt;8009d834&gt;] perf_output_sample+0x78c/0x858
 [ 5222.074873] [&lt;8009dc1c&gt;] perf_prepare_sample+0x29c/0x4b8
 [ 5222.074873] [&lt;8009de94&gt;] perf_event_output_forward+0x5c/0x98
 [ 5222.097846]
 [ 5222.097846] [&lt;800a0300&gt;] perf_event_exit_task+0x58/0x43c
 [ 5222.097846] [&lt;8006c874&gt;] hrtimer_interrupt+0x104/0x2ec
 [ 5222.097846] [&lt;800a0300&gt;] perf_event_exit_task+0x58/0x43c
 [ 5222.097846] [&lt;80437bb6&gt;] dw_apb_clockevent_irq+0x2a/0x4c
 [ 5222.097846] [&lt;8006c770&gt;] hrtimer_interrupt+0x0/0x2ec
 [ 5222.097846] [&lt;8005f2e4&gt;] __handle_irq_event_percpu+0xac/0x19c
 [ 5222.097846] [&lt;80437bb6&gt;] dw_apb_clockevent_irq+0x2a/0x4c
 [ 5222.097846] [&lt;8005f408&gt;] handle_irq_event_percpu+0x34/0x88
 [ 5222.097846] [&lt;8005f480&gt;] handle_irq_event+0x24/0x64
 [ 5222.097846] [&lt;8006218c&gt;] handle_level_irq+0x68/0xdc
 [ 5222.097846] [&lt;8005ec76&gt;] __handle_domain_irq+0x56/0xa8
 [ 5222.097846] [&lt;80450e90&gt;] ck_irq_handler+0xac/0xe4
 [ 5222.097846] [&lt;80029012&gt;] csky_do_IRQ+0x12/0x24
 [ 5222.097846] [&lt;8002a3a0&gt;] csky_irq+0x70/0x80
 [ 5222.097846] [&lt;800ca612&gt;] alloc_set_pte+0xd2/0x238
 [ 5222.097846] [&lt;8002ddd0&gt;] update_mmu_cache+0x0/0xd8
 [ 5222.097846] [&lt;800a0340&gt;] perf_event_exit_task+0x98/0x43c

The original fp check doesn't base on the real kernal stack region.
Invalid fp address may cause kernel panic.

Signed-off-by: Mao Han &lt;han_mao@linux.alibaba.com&gt;
Signed-off-by: Guo Ren &lt;guoren@linux.alibaba.com&gt;
</content>
</entry>
</feed>
