From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?GB2312?B?wu3A2g==?= Subject: Re: =?gb2312?b?W0JVR106IHdoZW4gdXNpbmcgYHhsIHJlc3RvcmVg?= =?gb2312?b?o6x4Y19ldnRjaG5fYWxsb2NfdW5ib3VuZCB3aWxsIHJhaXNlIHRo?= =?gb2312?b?aXMgZXJyb3I=?= Date: Fri, 4 Jan 2013 14:27:52 +0800 Message-ID: References: <20121226134131.GA25087@iceland> <20121226193312.GA28152@iceland> <1356612077.19238.20.camel@iceland> <1356691575.2917.13.camel@iceland> <1356955395.2917.41.camel@iceland> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7661497932659690307==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --===============7661497932659690307== Content-Type: multipart/alternative; boundary=e89a8f502b9243a05004d2709403 --e89a8f502b9243a05004d2709403 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable On Fri, Jan 4, 2013 at 11:23 AM, =C2=ED=C0=DA wrote: > > > On Mon, Dec 31, 2012 at 8:03 PM, Wei Liu wrote: > >> On Mon, 2012-12-31 at 03:10 +0000, =C2=ED=C0=DA wrote: >> > >> > >> > >> > I think the two files are mostly the same, but to be sure you >> > need to >> > look into the source file in both Linux and Xen. You should >> > start from >> > the hypervisor level, find out why it returns -EPERM. Root >> > user in Dom0 >> > has nothing to do with privilege in hypervisor level. >> > >> > >> > Wei. >> > >> > The scene is that there are more than 10 processes, each process calls >> > `xl restore` to start a VM where a virus sample will run to detect the >> > sample's behaviour about every 120 seconds. >> > For a long time, such as 5 days or 15 days, the xen server where the >> > processes run will raise this error with a certain probability. >> > Maybe it has something to do with the hypervisor's stability. >> >> This is not a usual scenario. Sorry I don't know how to reproduce this. >> >> But the code path in hypervisor for evtchn_alloc_unbound is quite short, >> you may try adding some debug output along the path to see which step >> fails then report back. >> >> >> Wei. >> >> BTW, it's needed to tell you my environment background; > I installed centos6.2 and then installed xen rpms from > http://xenbits.xen.org/people/mayoung/EL6.xen/. > > At present, I'm not sure what function used to add the debug statement (i= s > it printk?) and where to look for the debug log info (is it > /var/log/message?) . > > The returned errno is from src/xen/common/event_channel.c > 874-long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) > > > > 875{ > > > > 876 long rc; > > > > 877 > > > > 878 switch ( cmd ) > > > > 879 { > > > > 880 case EVTCHNOP_alloc_unbound: { > > > > 881 struct evtchn_alloc_unbound alloc_unbound; > > > > 882 if ( copy_from_guest(&alloc_unbound, arg, 1) !=3D 0 ) > > > > 883 return -EFAULT; > > > > 884 rc =3D evtchn_alloc_unbound(&alloc_unbound); // only > here returns -1(EPERM) , others return -EFAULT > > > 885 if ( (rc =3D=3D 0) && (copy_to_guest(arg, &alloc_unbound, 1) = !=3D 0) > ) > > > 886 rc =3D -EFAULT; /* Cleaning up here would be a mess! */ > > > > 887 break; > > > > 888 } > > > > Two statements below may affect the rc. > 124-static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) > > > > 125{ > > > > 126 struct evtchn *chn; > > > > 127 struct domain *d; > > > > 128 int port; > > > > 129 domid_t dom =3D alloc->dom; > > > > 130 long rc; > > > > 131 > > > > 132 rc =3D rcu_lock_target_domain_by_id(dom, &d); > > > > 133 if ( rc ) > > > > 134 return rc; > > > > 135 > > > > 136 spin_lock(&d->event_lock); > > > > 137 > > > > 138 if ( (port =3D get_free_port(d)) < 0 ) > > > > 139 ERROR_EXIT_DOM(port, d); > > > > 140 chn =3D evtchn_from_port(d, port); > > > > 141 > > > > 142 rc =3D xsm_evtchn_unbound(d, chn, alloc->remote_dom); > > > > 143 if ( rc ) > > > > 144 goto out; > > > > 145 > > > > 146 chn->state =3D ECS_UNBOUND; > > > > 147 if ( (chn->u.unbound.remote_domid =3D alloc->remote_dom) =3D=3D > DOMID_SELF ) > > > 148 chn->u.unbound.remote_domid =3D current->domain->domain_id; > 149 > > > > 150 alloc->port =3D port; > > > > 151 > > > > 152 out: > > > > 153 spin_unlock(&d->event_lock); > > > > 154 rcu_unlock_domain(d); > > > > 155 > > > > 156 return rc; > > > > 157} > > I looked into it again and found that it was caused probably by src/xen/common/domain.c: 421-int rcu_lock_target_domain_by_id(domid_t dom, struct domain **d) 422{ 423 if ( dom =3D=3D DOMID_SELF ) 424 { 425 *d =3D rcu_lock_current_domain(); 426 return 0; 427 } 428 429 if ( (*d =3D rcu_lock_domain_by_id(dom)) =3D=3D NULL ) 430 return -ESRCH; 431 432 if ( !IS_PRIV_FOR(current->domain, *d) ) 433 { 434 rcu_unlock_domain(*d); 435 return -EPERM; 436 } 437 438 return 0; 439} the macro `IS_PRIV_FOR` is defined here src/xen/include/xen/sched.h: 638#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target =3D=3D (_t))) *I couldn't understand that what IS_PRIV_FOR means?!* --e89a8f502b9243a05004d2709403 Content-Type: text/html; charset=GB2312 Content-Transfer-Encoding: quoted-printable

On Fri, Jan 4, 2013 at 11:23 AM, =C2=ED= =C0=DA <aware.why@gmail.com> wrote:


= On Mon, Dec 31, 2012 at 8:03 PM, Wei Liu <Wei.Liu2@citrix.com> wrote:
On Mon, 2012-12-31 at 03:10 +0000, =C2=ED=C0=DA wrote:
>
>
>
>         I think the two files are mostly the same,= but to be sure you
>         need to
>         look into the source file in both Linux an= d Xen. You should
>         start from
>         the hypervisor level, find out why it retu= rns -EPERM. Root
>         user in Dom0
>         has nothing to do with privilege in hyperv= isor level.
>
>
>         Wei.
>
> The scene is that there are more than 10 processes, each process calls=
> `xl restore` to start a VM where a virus sample will run to detect the=
> sample's behaviour  about every 120 seconds.
> For a long time, such as 5 days or 15 days, the xen server where the > processes run will raise this error with a certain probability.
> Maybe it has something to do with the hypervisor's stability.

This is not a usual scenario. Sorry I don't know how to reproduce= this.

But the code path in hypervisor for evtchn_alloc_unbound is quite short, you may try adding some debug output along the path to see which step
fails then report back.


Wei.

BTW, it's needed to t= ell you my environment background;
I installed centos6.2 and then inst= alled xen rpms from  http://xenbits.xen.org/people/mayoung/EL6.xen/.

At= present, I'm not sure what function used to add the debug statement (i= s it printk?) and where to look for the debug log info (is it /var/log/mess= age?)  .

The returned errno is from src/xen/common/event_channel.c
874-long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                  
 875{              =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =   
 876    long rc;        =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                  
 877               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 878    switch ( cmd )       =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;              
 879    {          =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =   
 880    case EVTCHNOP_alloc_unbound: {  = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 881        struct evtchn_alloc_un= bound alloc_unbound;                = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                
 882        if ( copy_from_guest(&= amp;alloc_unbound, arg, 1) !=3D 0 )           &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;           
 883            return -= EFAULT;                   &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;             
 884       &nbs= p;rc =3D evtchn_alloc_unbound(&alloc_unbound);     &nb= sp;   // only here returns -1(EPERM) ,  o= thers return -EFAULT              = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;        
 885        if ( (rc =3D=3D 0) &am= p;& (copy_to_guest(arg, &alloc_unbound, 1) !=3D 0) )     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =      
 886            rc =3D -= EFAULT; /* Cleaning up here would be a mess! */        =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =         
 887        break;     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                    
 888    }          =  

 
<= /blockquote>
Two statements below may affect the rc. 
124-static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)  = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                
 125{              =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =   
 126    struct evtchn *chn;     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;           
 127    struct domain *d;     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =             
 128    int         &nbs= p;  port;                 &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                  
 129    domid_t        d= om =3D alloc->dom;               &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;        
 130    long         &nb= sp; rc;                   &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                  
 131               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 132    rc =3D rcu_l= ock_target_domain_by_id(dom, &d);         &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =     
 133    if ( rc )        = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                 
 134        return rc;   &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                  
 135               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 136    spin_lock(&d->event_lock); &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;        
 137               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 138    if ( (port =3D get_free_port(d)) <= ; 0 )                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;
 139        ERROR_EXIT_DOM(port, d= );                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =        
 140    chn =3D evtchn_from_port(d, port); &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;  
 141               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 142    rc =3D xsm_e= vtchn_unbound(d, chn, alloc->remote_dom);       &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                   
 143    if ( rc )        = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                 
 144        goto out;    = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                 
 145               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 146    chn->state =3D ECS_UNBOUND;  = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;       
 147    if ( (chn->u.unbound.remote_domid= =3D alloc->remote_dom) =3D=3D DOMID_SELF )         =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                    <= /div>
 148        chn->u.unbound.remo= te_domid =3D current->domain->domain_id;      
149                 &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;
 150    alloc->port =3D port;   &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =             
 151               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 152 out:             &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                    &nbs= p;
 153    spin_unlock(&d->event_lock); =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;      
 154    rcu_unlock_domain(d);     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;         
 155               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;  
 156    return rc;       &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                  
 157}

I looked into it again and found that it was caused probably by sr= c/xen/common/domain.c:
 421-int rcu_lock_target_domain_b= y_id(domid_t dom, struct domain **d)           &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;     
 422{     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;           
 423    if = ( dom =3D=3D DOMID_SELF )               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                  
 424    { &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;           
 425     &n= bsp;  *d =3D rcu_lock_current_domain();         &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =             
 426     &n= bsp;  return 0;                = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;     
 427    } &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;           
 428     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;            
 429    if = ( (*d =3D rcu_lock_domain_by_id(dom)) =3D=3D NULL )       &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =  
 430     &n= bsp;  return -ESRCH;               =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;  
 431     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;            
 432    if ( !IS_PRIV_FOR(current->domain, *d) )   &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;            
&n= bsp;433    {               &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                   
&n= bsp;434        rcu_unlock_domain(*d);     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =    
&n= bsp;435        return -EPERM;       &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =          
&n= bsp;436    }             &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     = ;
 437     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;            
 438    ret= urn 0;                    = ;                     &nb= sp;                     &= nbsp;                    =                     &nbs= p;                     &n= bsp;                     =                      = ;                     &nb= sp;                     &= nbsp;     
 439}

the macro `IS_PRIV_FOR` is defined here sr= c/xen/include/xen/sched.h:
638#define IS_PRIV_FOR(_= d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target =3D=3D (= _t))) 

I could= n't understand that what  IS_PRIV_FOR  means?!=

--e89a8f502b9243a05004d2709403-- --===============7661497932659690307== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============7661497932659690307==--