From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH 1/6] trace: share t_info pages only in read-only mode Date: Tue, 29 Jun 2010 17:27:04 +0100 Message-ID: References: <4C2A2DDD0200007800008A5D@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4C2A2DDD0200007800008A5D@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Acked-by: George Dunlap On Tue, Jun 29, 2010 at 4:31 PM, Jan Beulich wrote: > There's no need to share writably the t_info pages (Dom0 only wants > [and needs] to read it) > > Signed-off-by: Jan Beulich > > --- 2010-06-15.orig/tools/xenmon/xenbaked.c =A0 =A0 2010-06-29 16:55:30.0= 00000000 +0200 > +++ 2010-06-15/tools/xenmon/xenbaked.c =A02010-06-28 10:23:01.000000000 += 0200 > @@ -84,7 +84,7 @@ typedef struct settings_st { > =A0} settings_t; > > =A0struct t_struct { > - =A0 =A0struct t_info *t_info; =A0/* Structure with information about in= dividual buffers */ > + =A0 =A0const struct t_info *t_info; /* Structure with information about= individual buffers */ > =A0 =A0 struct t_buf **meta; =A0 =A0/* Pointers to trace buffer metadata = */ > =A0 =A0 unsigned char **data; =A0 /* Pointers to trace buffer data areas = */ > =A0}; > @@ -376,9 +376,8 @@ static struct t_struct *map_tbufs(unsign > =A0 =A0 } > > =A0 =A0 /* Map t_info metadata structure */ > - =A0 =A0tbufs.t_info =3D xc_map_foreign_range(xc_handle, DOMID_XEN, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0tinfo_size, PROT_READ | PROT_WRITE, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0tbufs_mfn); > + =A0 =A0tbufs.t_info =3D xc_map_foreign_range(xc_handle, DOMID_XEN, tinf= o_size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0PROT_READ, tbufs_mfn); > > =A0 =A0 if ( tbufs.t_info =3D=3D 0 ) > =A0 =A0 { > @@ -404,7 +403,8 @@ static struct t_struct *map_tbufs(unsign > =A0 =A0 for(i=3D0; i =A0 =A0 { > > - =A0 =A0 =A0 =A0uint32_t *mfn_list =3D ((uint32_t *)tbufs.t_info) + tbuf= s.t_info->mfn_offset[i]; > + =A0 =A0 =A0 =A0const uint32_t *mfn_list =3D (const uint32_t *)tbufs.t_i= nfo > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 + t= bufs.t_info->mfn_offset[i]; > =A0 =A0 =A0 =A0 int j; > =A0 =A0 =A0 =A0 xen_pfn_t pfn_list[tbufs.t_info->tbuf_size]; > > --- 2010-06-15.orig/tools/xentrace/xentrace.c =A0 2010-06-29 16:55:30.000= 000000 +0200 > +++ 2010-06-15/tools/xentrace/xentrace.c =A0 =A0 =A0 =A02010-06-28 10:23:= 26.000000000 +0200 > @@ -63,7 +63,7 @@ typedef struct settings_st { > =A0} settings_t; > > =A0struct t_struct { > - =A0 =A0struct t_info *t_info; =A0/* Structure with information about in= dividual buffers */ > + =A0 =A0const struct t_info *t_info; /* Structure with information about= individual buffers */ > =A0 =A0 struct t_buf **meta; =A0 =A0/* Pointers to trace buffer metadata = */ > =A0 =A0 unsigned char **data; =A0 /* Pointers to trace buffer data areas = */ > =A0}; > @@ -475,9 +475,8 @@ static struct t_struct *map_tbufs(unsign > =A0 =A0 int i; > > =A0 =A0 /* Map t_info metadata structure */ > - =A0 =A0tbufs.t_info =3D xc_map_foreign_range(xc_handle, DOMID_XEN, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0tinfo_size, PROT_READ | PROT_WRITE, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0tbufs_mfn); > + =A0 =A0tbufs.t_info =3D xc_map_foreign_range(xc_handle, DOMID_XEN, tinf= o_size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0PROT_READ, tbufs_mfn); > > =A0 =A0 if ( tbufs.t_info =3D=3D 0 ) > =A0 =A0 { > @@ -503,7 +502,8 @@ static struct t_struct *map_tbufs(unsign > =A0 =A0 for(i=3D0; i =A0 =A0 { > > - =A0 =A0 =A0 =A0uint32_t *mfn_list =3D ((uint32_t *)tbufs.t_info) + tbuf= s.t_info->mfn_offset[i]; > + =A0 =A0 =A0 =A0const uint32_t *mfn_list =3D (const uint32_t *)tbufs.t_i= nfo > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 + t= bufs.t_info->mfn_offset[i]; > =A0 =A0 =A0 =A0 int j; > =A0 =A0 =A0 =A0 xen_pfn_t pfn_list[tbufs.t_info->tbuf_size]; > > --- 2010-06-15.orig/xen/common/trace.c =A02010-06-28 12:16:05.000000000 += 0200 > +++ 2010-06-15/xen/common/trace.c =A0 =A0 =A0 2010-06-28 11:58:37.0000000= 00 +0200 > @@ -309,7 +309,7 @@ void __init init_trace_bufs(void) > > =A0 =A0 for(i=3D0; i =A0 =A0 =A0 =A0 share_xen_page_with_privileged_guests( > - =A0 =A0 =A0 =A0 =A0 =A0virt_to_page(t_info) + i, XENSHARE_writable); > + =A0 =A0 =A0 =A0 =A0 =A0virt_to_page(t_info) + i, XENSHARE_readonly); > > =A0 =A0 if ( opt_tbuf_size =3D=3D 0 ) > =A0 =A0 { > > > >