Download A generic attack on hashing-based software tamper

Transcript
B.1. Kernel Source Code
* For Cheetah’s 64-bit VADDR space this is:
*
* VA[0 : (1<<63)] produce VPTE index [%g3
: 0]
* VA[0 : -(1<<63)] produce VPTE index [%g3-(1<<(63-PAGE SHIFT+3)) : %g3]
*
* If you’re paying attention you’ll notice that this means half of
* the VPTE table is above %g3 and half is below, low VA addresses
* map progressively upwards from %g3, and high VA addresses map
* progressively upwards towards %g3. This trick was needed to make
* the same 8 instruction handler work both for Spitfire/Blackbird’s
* peculiar VA space hole configuration and the full 64-bit VA space
* one of Cheetah at the same time.
*/
92
30
40
/* Ways we can get here:
*
* 1) Nucleus loads and stores to/from PA–>VA direct mappings.
* 2) Nucleus loads and stores to/from vmalloc() areas.
* 3) User loads and stores.
* 4) User space accesses by nucleus at tl0
*/
#if PAGE SHIFT == 13
/*
* To compute vpte offset, we need to do ((addr >> 13) << 3),
* which can be optimized to (addr >> 10) if bits 10/11/12 can
* be guaranteed to be 0 . . . mmu context.h does guarantee this
* by only using 10 bits in the hwcontext value.
*/
#define CREATE VPTE OFFSET1(r1, r2)
#define CREATE VPTE OFFSET2(r1, r2) \
srax
r1, 10, r2
#define CREATE VPTE NOP nop
#else
#define CREATE VPTE OFFSET1(r1, r2) \
srax
r1, PAGE SHIFT, r2
#define CREATE VPTE OFFSET2(r1, r2) \
sllx
r2, 3, r2
#define CREATE VPTE NOP
#endif
/* DTLB ** ICACHE line 1: Quick user TLB misses */
ldxa
[%g1 + %g1] ASI DMMU, %g4 ! Get TAG ACCESS
andcc
%g4, TAG CONTEXT BITS, %g0 ! From Nucleus?
mov
1, %g5
! For TL==3 test
from tl1 trap:
CREATE VPTE OFFSET1(%g4, %g6)
! Create VPTE offset
be,pn
%xcc, 3f
! Yep, special processing
CREATE VPTE OFFSET2(%g4, %g6)
! Create VPTE offset
cmp
%g5, 4
! Last trap level?
be,pn
%xcc, longpath
! Yep, cannot risk VPTE miss
50
60
70