<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/arch/arc, branch v3.9.8</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/arch/arc?h=v3.9.8</id>
<link rel='self' href='https://git.amat.us/linux/atom/arch/arc?h=v3.9.8'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2013-06-07T19:52:26Z</updated>
<entry>
<title>ARC: copy_(to|from)_user() to honor usermode-access permissions</title>
<updated>2013-06-07T19:52:26Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-05-21T09:55:11Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ac645c6469dcc5a4bdbce8ed98e40182e8e54140'/>
<id>urn:sha1:ac645c6469dcc5a4bdbce8ed98e40182e8e54140</id>
<content type='text'>
commit a950549c675f2c8c504469dec7d780da8a6433dc upstream.

This manifested as grep failing psuedo-randomly:

--------------&gt;8---------------------
[ARCLinux]$ ip address show lo | grep inet
[ARCLinux]$ ip address show lo | grep inet
[ARCLinux]$ ip address show lo | grep inet
[ARCLinux]$
[ARCLinux]$ ip address show lo | grep inet
    inet 127.0.0.1/8 scope host lo
--------------&gt;8---------------------

ARC700 MMU provides fully orthogonal permission bits per page:
Ur, Uw, Ux, Kr, Kw, Kx

The user mode page permission templates used to have all Kernel mode
access bits enabled.
This caused a tricky race condition observed with uClibc buffered file
read and UNIX pipes.

1. Read access to an anon mapped page in libc .bss: write-protected
   zero_page mapped: TLB Entry installed with Ur + K[rwx]

2. grep calls libc:getc() -&gt; buffered read layer calls read(2) with the
   internal read buffer in same .bss page.
   The read() call is on STDIN which has been redirected to a pipe.
   read(2) =&gt; sys_read() =&gt; pipe_read() =&gt; copy_to_user()

3. Since page has Kernel-write permission (despite being user-mode
   write-protected), copy_to_user() suceeds w/o taking a MMU TLB-Miss
   Exception (page-fault for ARC). core-MM is unaware that kernel
   erroneously wrote to the reserved read-only zero-page (BUG #1)

4. Control returns to userspace which now does a write to same .bss page
   Since Linux MM is not aware that page has been modified by kernel, it
   simply reassigns a new writable zero-init page to mapping, loosing the
   prior write by kernel - effectively zero'ing out the libc read buffer
   under the hood - hence grep doesn't see right data (BUG #2)

The fix is to make all kernel-mode access permissions mirror the
user-mode ones. Note that the kernel still has full access to pages,
when accessed directly (w/o MMU) - this fix ensures that kernel-mode
access in copy_to_from() path uses the same faulting access model as for
pure user accesses to keep MM fully aware of page state.

The issue is peudo-random because it only shows up if the TLB entry
installed in #1 is present at the time of #3. If it is evicted out, due
to TLB pressure or some-such, then copy_to_user() does take a TLB Miss
Exception, with a routine write-to-anon COW processing installing a
fresh page for kernel writes and also usable as it is in userspace.

Further the issue was dormant for so long as it depends on where the
libc internal read buffer (in .bss) is mapped at runtime.
If it happens to reside in file-backed data mapping of libc (in the
page-aligned slack space trailing the file backed data), loader zero
padding the slack space, does the early cow page replacement, setting
things up at the very beginning itself.

With gcc 4.8 based builds, the libc buffer got pushed out to a real
anon mapping which triggers the issue.

Reported-by: Anton Kolesov &lt;akolesov@synopsys.com&gt;
Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>ARC: Add implicit compiler barrier to raw_local_irq* functions</title>
<updated>2013-04-08T23:10:26Z</updated>
<author>
<name>Christian Ruppert</name>
<email>christian.ruppert@abilis.com</email>
</author>
<published>2013-04-08T07:35:30Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=79e5f05edcbf85825d19eb8a425cd6c36c6c66f1'/>
<id>urn:sha1:79e5f05edcbf85825d19eb8a425cd6c36c6c66f1</id>
<content type='text'>
ARC irqsave/restore macros were missing the compiler barrier, causing a
stale load in irq-enabled region be used in irq-safe region, despite
being changed, because the register holding the value was still live.

The problem manifested as random crashes in timer code when stress
testing ARCLinux (3.9-rc3) on a !SMP &amp;&amp; !PREEMPT_COUNT

Here's the exact sequence which caused this:
 (0). tv1[x] &lt;----&gt; t1 &lt;---&gt; t2
 (1). mod_timer(t1) interrupted after it calls timer_pending()
 (2). mod_timer(t2) completes
 (3). mod_timer(t1) resumes but messes up the list
 (4). __runt_timers( ) uses bogus timer_list entry / crashes in
      timer-&gt;function

Essentially mod_timer() was racing against itself and while the spinlock
serialized the tv1[] timer link list, timer_pending() called outside the
spinlock, cached timer link list element in a register.
With low register pressure (and a deep register file), lack of barrier
in raw_local_irqsave() as well as preempt_disable (!PREEMPT_COUNT
version), there was nothing to force gcc to reload across the spinlock,
causing a stale value in reg be used for link list manipulation - ensuing
a corruption.

ARcompact disassembly which shows the culprit generated code:

mod_timer:
    push_s blink
    mov_s r13,r0	# timer, timer
..
    ###### timer_pending( )
    ld_s r3,[r13]       # &lt;------ &lt;variable&gt;.entry.next LOADED
    brne r3, 0, @.L163

.L163:
..
    ###### spin_lock_irq( )
    lr  r5, [status32]  # flags
    bic r4, r5, 6       # temp, flags,
    and.f 0, r5, 6      # flags,
    flag.nz r4

    ###### detach_if_pending( ) begins

    tst_s r3,r3  &lt;--------------
			# timer_pending( ) checks timer-&gt;entry.next
                        # r3 is NOT reloaded by gcc, using stale value
    beq.d @.L169
    mov.eq r0,0

    #####  detach_timer( ): __list_del( )

    ld r4,[r13,4]    	# &lt;variable&gt;.entry.prev, D.31439
    st r4,[r3,4]     	# &lt;variable&gt;.prev, D.31439
    st r3,[r4]       	# &lt;variable&gt;.next, D.30246

We initially tried to fix this by adding barrier() to preempt_* macros
for !PREEMPT_COUNT but Linus clarified that it was anything but wrong.
http://www.spinics.net/lists/kernel/msg1512709.html

[vgupta: updated commitlog]

Reported-by/Signed-off-by: Christian Ruppert &lt;christian.ruppert@abilis.com&gt;
Cc: Christian Ruppert &lt;christian.ruppert@abilis.com&gt;
Cc: Pierrick Hascoet &lt;pierrick.hascoet@abilis.com&gt;
Debugged-by/Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;

Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>ARC: Fix the typo in event identifier flags used by ptrace</title>
<updated>2013-03-20T13:15:45Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-03-20T11:23:14Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=367f3fcd9296977bc4689546f55c5f4a9c680e8d'/>
<id>urn:sha1:367f3fcd9296977bc4689546f55c5f4a9c680e8d</id>
<content type='text'>
orig_r8_IS_EXCPN and orig_r8_IS_BRKPT were same values due to a
copy/paste error. Although it looks bad and is wrong, it really doesn't
affect gdb working.

orig_r8_IS_BRKPT is the one relevant to debugging (breakpoints), since
it is used to provide EFA vs. ERET to a ptrace "stop_pc" request.

So when gdb has inserted a breakpoint, orig_r8_IS_BRKPT is already set,
and anything else (i.e. orig_r8_IS_EXCPN) becoming same as it, really
doesn't hurt gdb. The corollary case, could be nasty but nobody uses the
ptrace "stop_pc" request in that case

Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>arc: fix dma_address assignment during dma_map_sg()</title>
<updated>2013-03-19T10:04:53Z</updated>
<author>
<name>Pierrick Hascoet</name>
<email>pierrick.hascoet@abilis.com</email>
</author>
<published>2013-03-18T16:04:45Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2105fd550ca7dbdd490934f487852c2a399b20cf'/>
<id>urn:sha1:2105fd550ca7dbdd490934f487852c2a399b20cf</id>
<content type='text'>
Signed-off-by: Pierrick Hascoet &lt;pierrick.hascoet@abilis.com&gt;
Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: Remove SET_PERSONALITY (tracks cross-arch change)</title>
<updated>2013-03-18T09:07:05Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-03-02T07:01:39Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a37b2dc52b88ccd926099d852eae1bb324bc92eb'/>
<id>urn:sha1:a37b2dc52b88ccd926099d852eae1bb324bc92eb</id>
<content type='text'>
Tracks commit e72837e3e7b "default SET_PERSONALITY() in linux/elf.h"

Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: ABIv3: fork/vfork wrappers not needed in "no-legacy-syscall" ABI</title>
<updated>2013-03-11T13:31:10Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-03-04T10:31:35Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=180d406e4948faee6e63781f3e062f40ec7c6fc3'/>
<id>urn:sha1:180d406e4948faee6e63781f3e062f40ec7c6fc3</id>
<content type='text'>
When switching to clone() only ABI - I missed out pruning the low level
asm syscall wrappers

Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: ABIv3: Print the correct ABI ver</title>
<updated>2013-03-11T13:31:09Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-03-06T09:03:27Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8ff14bbc6a2083e83c6d387d025fb67ba639807c'/>
<id>urn:sha1:8ff14bbc6a2083e83c6d387d025fb67ba639807c</id>
<content type='text'>
Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: make allyesconfig build breakages</title>
<updated>2013-03-11T13:31:09Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-03-07T11:17:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1540c85b176180e5e0b312dd98db7f438baf8a24'/>
<id>urn:sha1:1540c85b176180e5e0b312dd98db7f438baf8a24</id>
<content type='text'>
  CC      drivers/mmc/host/mmc_spi.o
drivers/mmc/host/mmc_spi.c:118: error: redefinition of 'struct scratch'
make[3]: *** [drivers/mmc/host/mmc_spi.o] Error 1
make[2]: *** [drivers/mmc/host] Error 2
make[1]: *** [drivers/mmc] Error 2
make: *** [drivers] Error 2

  CC      arch/arc/kernel/kgdb.o
In file included from include/linux/kgdb.h:20,
                 from arch/arc/kernel/kgdb.c:11:
/home/vineetg/arc/k.org/arc-port/arch/arc/include/asm/kgdb.h:34:
warning: 'struct pt_regs' declared inside parameter list
/home/vineetg/arc/k.org/arc-port/arch/arc/include/asm/kgdb.h:34:
warning: its scope is only this definition or declaration, which is
probably not what you want
arch/arc/kernel/kgdb.c:172: error: conflicting types for 'kgdb_trap'

  CC      arch/arc/kernel/kgdb.o
arch/arc/kernel/kgdb.c: In function 'pt_regs_to_gdb_regs':
arch/arc/kernel/kgdb.c:62: error: dereferencing pointer to incomplete
type

Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: split elf.h into uapi and export it for userspace</title>
<updated>2013-02-27T14:30:26Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-02-27T12:57:13Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8ccfe6675fa974bd06d64f74d0fdee6a5267d2aa'/>
<id>urn:sha1:8ccfe6675fa974bd06d64f74d0fdee6a5267d2aa</id>
<content type='text'>
Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
<entry>
<title>ARC: Fixup the current ABI version</title>
<updated>2013-02-27T14:30:25Z</updated>
<author>
<name>Vineet Gupta</name>
<email>vgupta@synopsys.com</email>
</author>
<published>2013-02-27T12:53:27Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=17139053eb96bc09a6d6248aae17c9316f5bcd86'/>
<id>urn:sha1:17139053eb96bc09a6d6248aae17c9316f5bcd86</id>
<content type='text'>
The upstream kernel ABI (v3) is different from current out-of-tree (v2):
* no-legacy-syscalls
* user_regs_struct layout has changed

So we rev up the ABI version

Signed-off-by: Vineet Gupta &lt;vgupta@synopsys.com&gt;
</content>
</entry>
</feed>
