2008-11-18 07:53:41     The " Attempted to use a Supervisor register or instruction from User mode" problem

Document created by Aaronwu Employee on Aug 8, 2013
Version 1Show Document
  • View in full screen mode

2008-11-18 07:53:41     The " Attempted to use a Supervisor register or instruction from User mode" problem

haiping zeng (CHINA)

Message: 65439   

 

Hello everyone:

 

         I wanted to port the g723.1A(with the .asm format) to uclinux and the target is blackfin 533.when i run the test program, i encounter this problem , could someone can give me some advises?

 

=========================================================================

 

Target:

 

root:/mnt/asm_g723_for_uClinux/g723/test> ./test

Illegal use of supervisor resource

- Attempted to use a Supervisor register or instruction from User mode.

Supervisor resources are registers and instructions that are reserved

for Supervisor use: Supervisor only registers, all MMRs, and Supervisor

only instructions.

 

CURRENT PROCESS:

 

COMM=test PID=35

TEXT = 0x03d00040-0x03d0a9c0  DATA = 0x03d0a9d0-0x03d10010

BSS = 0x03d10010-0x03d29950   USER-STACK = 0x03d7ff84

 

return address: 0x03d032ae; contents of [PC-16...PC+8]:

9e08 e0e2 0003 9e00 9e08 0010 0c02 1828

5ccd e12a 0091 3443 3453 4422 5cd5 344b X

9c28 e0a2 0002 c803 1800 9e20 9c28 e140

 

RETE:  00000000  RETN: 03da6000  RETX: 03d032ae  RETS: 03d014dc

IPEND: 0030  SYSCFG: 0036

SEQSTAT: 0000002e    SP: 03da5f24

R0: 03d1ce6c    R1: 00000002    R2: 00000801    R3: 00000000

R4: ffffe800    R5: 00000000    R6: 03d1089c    R7: 03d297a4

P0: 000000f0    P1: 00000091    P2: fffff890    P3: fffff122

P4: 00000801    P5: 00000002    FP: 03d7feec

A0.w: c9be0000    A0.x: ffffffff    A1.w: d2ea4000    A1.x: ffffffff

LB0: 03d01087  LT0: 03d01086  LC0: 00000000

LB1: 03d05b07  LT1: 03d05ab2  LC1: 00000000

B0: 03d1ce6c  L0: 00000000  M0: 00000014  I0: 00000124

B1: 00000002  L1: 00000000  M1: 00000000  I1: fffff122

B2: 03d298e4  L2: 00000000  M2: 00000000  I2: 00000124

B3: 00000000  L3: 00000000  M3: 00000000  I3: 0000993a

 

USP: 03d7fb68   ASTAT: 02001004

DCPLB_FAULT_ADDR=fffff122

ICPLB_FAULT_ADDR=03d032ae

 

 

Hardware Trace:

0 Target : <0x00004de0> { _trap_c + 0x0 }

   Source : <0x0000874c> { _exception_to_level5 + 0xb4 }

1 Target : <0x00008698> { _exception_to_level5 + 0x0 }

   Source : <0x00008696> { _ex_trap_c + 0x5a }

2 Target : <0x000087c4> { _trap + 0x0 }

   Source : <0x03d032ac> [ test + 0x32ac ]

3 Target : <0x03d0329a> [ test + 0x329a ]

   Source : <0x03d03280> [ test + 0x3280 ]

4 Target : <0x03d0326e> [ test + 0x326e ]

   Source : <0x03d014d8> [ test + 0x14d8 ]

5 Target : <0x03d014b6> [ test + 0x14b6 ]

   Source : <0x03d01096> [ test + 0x1096 ]

6 Target : <0x03d00fe6> [ test + 0xfe6 ]

   Source : <0x03d0598c> [ test + 0x598c ]

7 Target : <0x03d05988> [ test + 0x5988 ]

   Source : <0x03d05bbe> [ test + 0x5bbe ]

8 Target : <0x03d0598e> [ test + 0x598e ]

   Source : <0x03d05984> [ test + 0x5984 ]

9 Target : <0x03d0597a> [ test + 0x597a ]

   Source : <0x03d05bbe> [ test + 0x5bbe ]

10 Target : <0x03d0598e> [ test + 0x598e ]

   Source : <0x03d05976> [ test + 0x5976 ]

11 Target : <0x03d0596c> [ test + 0x596c ]

   Source : <0x03d05bbe> [ test + 0x5bbe ]

12 Target : <0x03d0598e> [ test + 0x598e ]

   Source : <0x03d05968> [ test + 0x5968 ]

13 Target : <0x03d0595e> [ test + 0x595e ]

   Source : <0x03d05bbe> [ test + 0x5bbe ]

14 Target : <0x03d0598e> [ test + 0x598e ]

   Source : <0x03d0595a> [ test + 0x595a ]

15 Target : <0x03d0594c> [ test + 0x594c ]

   Source : <0x03d00fe2> [ test + 0xfe2 ]

Stack from 03da5f04:

        03d29934 00008750 001be78c 001be78c 001be788 00000034 7e787f3b 03d09ae6

        03d032ae 00000030 0000002e 00000000 03da6000 03d032ae 03d032ae 03d014dc

        03d1ce6c 02001004 03d05b07 03d01087 03d05ab2 03d01086 00000000 00000000

        d2ea4000 ffffffff c9be0000 ffffffff 00000000 03d298e4 00000002 03d1ce6c

        00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000014

        0000993a 00000124 fffff122 00000124 03d7fb68 03d7feec 00000002 00000801

Call Trace:

 

======================================================

 

Host:

 

from the Hardware Trace,we can see this :

 

2 Target : <0x000087c4> { _trap + 0x0 }

   Source : <0x03d032ac> [ test + 0x32ac ]

 

so I  used :$ bfin-uclinux-objdump -d g723/test/test.gdb |less

 

:/32ac ==> we can see the diassambly codes:

 

0000325a <Regen2>:

    325a:       02 0c           CC=R2==0x0;

    325c:       28 18           IF CC JUMP 32ac <Regen3>;

    325e:       cd 5c           P3=P5+(P1<<1);

    3260:       2a e1 91 00     P2=0x91 (X);

    3264:       43 34           I0=P3;

    3266:       53 34           I2=P3;

    3268:       22 44           P2-=P4;

    326a:       d5 5c           P3=P5+(P2<<1);

    326c:       4b 34           I1=P3;

    326e:       28 9c           R0.L=W[I1++];

    3270:       a2 e0 02 00     LSETUP(3274 <Regen2_1>,3274 <Regen2_1>)LC0=P0;

 

00003274 <Regen2_1>:

    3274:       03 c8 00 18     mnop || W[I0++]=R0.L || R0.L=W[I1++];

    3278:       20 9e 28 9c

    327c:       40 e1 00 60     R0.H=0x6000;

    3280:       c0 34           I0=B0;

    3282:       8a 34           I1=I2;

    3284:       09 9c           R1=[I1++];

    3286:       0c ca 81 e4     R3 = R0.H * R1.H, R2 = R0.H * R1.L || R1.L=W[I1++] || NOP;

    328a:       29 9c 00 00

    328e:       04 ce 13 c8     R4=PACK(R3.H,R2.H) || R1.H=W[I1++] || NOP;

    3292:       49 9c 00 00

    3296:       e2 e0 06 00     LSETUP(329a <Regen2_1+0x26>,32a2 <Regen2_1+0x2e>)LC0=P0>>1;

    329a:       0c ca 81 e4     R3 = R0.H * R1.H, R2 = R0.H * R1.L || R1=[I1++] || [I0++]=R4;

    329e:       09 9c 04 9e

    32a2:       04 ce 13 c8     R4=PACK(R3.H,R2.H) || [I2++]=R4 || NOP;

    32a6:       14 9e 00 00

    32aa:       10 00           RTS;

 

 

000032ac <Regen3>:

    32ac:       c0 34           I0=B0;

    32ae:       c9 34           I1=B1;

    32b0:       26 e1 03 01     R6=0x103 (X);

    32b4:       44 e1 00 00     R4.H=0x0;

    32b8:       00 cc 09 c0     R0=R1-|-R1  || R4.L=W[I3] || NOP;

    32bc:       3c 9d 00 00

    32c0:       09 cc 30 20     A0=R6 || W[I1++]=R0.L || NOP;

    32c4:       28 9e 00 00

    32c8:       25 e1 09 02     R5=0x209 (X);

    32cc:       a2 e0 0a 00     LSETUP(32d0 <Regen3+0x24>,32e0 <Regen3+0x34>)LC0=P0;

    32d0:       8b c0 25 29     R4 = (a0 += R4.L * R5.L) (FU);

    32d4:       09 c4 30 20     A0=R6;

    32d8:       0c ca 9c 01     R7 = R3.L * R4.L || W[I1++]=R0.L || NOP;

    32dc:       28 9e 00 00

    32e0:       47 9e           W[I0++]=R7.H;

    32e2:       3c 9f           W[I3]=R4.L;

    32e4:       e2 e0 02 10     LSETUP(32e8 <Regen3_2>,32e8 <Regen3_2>)LC0=P1>>1;

 

000032e8 <Regen3_2>:

    32e8:       08 9e           [I1++]=R0;

......

 

=============================================================================

 

The target environment:

 

blacfin 533

 

uClinux-dist-R06R2-RC2

 

blackfin-toolchain-06r2-5.i386.tar.gz

 

========================================================================

 

the source codes:

 

ADI_TOOLS_CG723_Regen:

       .global _ADI_TOOLS_CG723_Regen;

           b0=r0; //&DataBuff; b0 points to DataBuff

           b1=r1; //&Buff;     b1 points to Buff

           p0=240;

           p1=145;

           p5=r1;

           p4=r2;

           cc = R4< ADI_TOOLS_CG723_ERRMAXNUM;

           if cc jump Regen2;

        i0=b0;   //i0 points to DataBuff

        i1=b1;   //i1 points to Buff

        r0=0;

        w[i1++]=r0.l;

        lsetup(Regen1_2,Regen1_2) lc0=p1>>1;

Regen1_2:    [i1++]=r0;

        lsetup(Regen1_1,Regen1_3) lc0=p0>>1;

Regen1_1:     [i0++]=r0;

//        lsetup(Regen1_3,Regen1_3) lc0=p0>>1;

Regen1_3:    [i1++]=r0;

        rts;

Regen2:

        cc=r2==0;

        if cc jump Regen3;

        p3=p5+(p1<<1);  //p3 points to Buff[PitchMax]

        p2=145;

        i0=p3;          // i0 points to Buff[PitchMax]

        i2=p3;          // i2 points to Buff[PitchMax]

        p2-=p4;         // p2=145-Lag

        p3=p5+(p2<<1);  // p3 points to  Buff[PitchMax-Lag]

        i1=p3;          // i1 points to Buff[PitchMax-Lag]

        r0.l=w[i1++];

        lsetup(Regen2_1,Regen2_1) lc0=p0;

Regen2_1:    mnop||w[i0++]=r0.l||r0.l=w[i1++];

        r0.h=0x6000;

        i0=b0;   // i0 points to DataBuff

        i1=i2;   // i1 points to Buff[PitchMax]

        r1=[i1++];

//        r1.H=W[i1++];

        r2=r0.h*r1.l,r3=r0.h*r1.h||r1.L=w[i1++];

        r4=pack(r3.h,r2.h)||r1.H=w[i1++];

        loop Regen2_2 lc0=p0>>1;

        loop_begin Regen2_2;

           r2=r0.h*r1.l,r3=r0.h*r1.h||r1=[i1++]||[i0++]=r4;

           r4=pack(r3.h,r2.h)||[i2++]=r4;//||r1.H=W[i1++];

        loop_end Regen2_2;

        rts;

Regen3: i0=b0;

        i1=b1; // i1 points to Buff

        r6=259;

        r4.h=0;

        r0=r1-|-r1||r4.l=w[i3];

        A0=R6  || w[i1++]=r0.l;

        r5=521;

        loop Regen3_1 lc0=p0;

        loop_begin Regen3_1;

            r4=(A0+=r4.l*r5.l)(fu);

            A0=R6;

            r7=r3.l*r4.l || W[i1++]=r0.L; // r3.l=Gain, r4.l=*Sd

            w[i0++] = r7.h;

        loop_end Regen3_1;

 

        w[i3]=r4.l;

        lsetup(Regen3_2,Regen3_2) lc0=p1>>1;

Regen3_2:[i1++]=r0;

//        lsetup(Regen3_3,Regen3_3) lc0=p0>>1;

//Regen3_3:[i1++]=r0;

RegenEnd:

       rts;

QuoteReplyEditDelete

 

 

2008-11-18 08:50:28     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

Mike Frysinger (UNITED STATES)

Message: 65442   

 

there was a bug in older releases where the trace offsets would be wrong by 0x14 ... so add that to your 0x32ac to get 0x32c0

 

so that tells us your code is processing a bad pointer as your trace and disassembly shows

 

   Source : <0x03d032ac> [ test + 0x32ac + 0x14 ]

    32c0:       09 cc 30 20     A0=R6 || W[I1++]=R0.L || NOP;

    32c4:       28 9e 00 00

DCPLB_FAULT_ADDR=fffff122

I1: fffff122

QuoteReplyEditDelete

 

 

2008-11-18 22:00:16     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

haiping zeng (CHINA)

Message: 65469   

 

Thanks,Mike .

 

I have got what you mean! when i use the 2008 release ,there was no this bug!

 

but i was not port this new releases to my target(blackfin 533),and all our products must be run in the 2006 release.

 

how can i fix the bug in the uClinux-dist-R06R2-RC2?

QuoteReplyEditDelete

 

 

2008-11-18 22:05:28     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

Mike Frysinger (UNITED STATES)

Message: 65470   

 

all the traps code is in arch/blackfin/kernel/traps.c

 

QuoteReplyEditDelete

 

 

2008-11-19 01:52:52     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

haiping zeng (CHINA)

Message: 65472   

 

hi, mike;

 

As you mean,the bug in the old releases is not locate  the bad pointer in  my program correctly. And  in fact ,that still shows there is a bad pointer  in my program!if so ,what can i do to correct it ?

 

as follow show :

 

Source : <0x03d032ac> [ test + 0x32ac + 0x14 ]

    32c0:       09 cc 30 20     A0=R6 || W[I1++]=R0.L || NOP;

 

 

QuoteReplyEditDelete

 

 

2008-11-19 20:20:23     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

Mike Frysinger (UNITED STATES)

Message: 65563   

 

yes, the bug in the old release only affects the offset displayed in the trace buffer.  your code is still buggy.

 

my recommendation is you debug your code and find out where the bad pointer is coming from.  the wiki page i pointed you to early has recommendations for using gdb and such.

QuoteReplyEditDelete

 

 

2008-11-20 01:57:47     Re: The " Attempted to use a Supervisor register or instruction from User mode" problem

haiping zeng (CHINA)

Message: 65571   

 

OK,I will do it.Thanks Mike!

Attachments

    Outcomes