svn commit: r232541 - head/sys/fs/pseudofs

2012-03-05 Thread Konstantin Belousov
Author: kib
Date: Mon Mar  5 11:38:02 2012
New Revision: 232541
URL: http://svn.freebsd.org/changeset/base/232541

Log:
  Apply inlined vn_vget_ino() algorithm for .. lookup in pseudofs.
  
  Reported and tested by:   pho
  MFC after:2 weeks

Modified:
  head/sys/fs/pseudofs/pseudofs_vnops.c

Modified: head/sys/fs/pseudofs/pseudofs_vnops.c
==
--- head/sys/fs/pseudofs/pseudofs_vnops.c   Mon Mar  5 06:46:35 2012
(r232540)
+++ head/sys/fs/pseudofs/pseudofs_vnops.c   Mon Mar  5 11:38:02 2012
(r232541)
@@ -432,6 +432,7 @@ pfs_lookup(struct vop_cachedlookup_args 
struct pfs_vdata *pvd = vn-v_data;
struct pfs_node *pd = pvd-pvd_pn;
struct pfs_node *pn, *pdn = NULL;
+   struct mount *mp;
pid_t pid = pvd-pvd_pid;
char *pname;
int error, i, namelen, visible;
@@ -474,10 +475,26 @@ pfs_lookup(struct vop_cachedlookup_args 
PFS_RETURN (0);
}
 
+   mp = vn-v_mount;
+
/* parent */
if (cnp-cn_flags  ISDOTDOT) {
if (pd-pn_type == pfstype_root)
PFS_RETURN (EIO);
+   error = vfs_busy(mp, MBF_NOWAIT);
+   if (error != 0) {
+   vfs_ref(mp);
+   VOP_UNLOCK(vn, 0);
+   error = vfs_busy(mp, 0);
+   vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+   vfs_rel(mp);
+   if (error != 0)
+   PFS_RETURN(ENOENT);
+   if (vn-v_iflag  VI_DOOMED) {
+   vfs_unbusy(mp);
+   PFS_RETURN(ENOENT);
+   }
+   }
VOP_UNLOCK(vn, 0);
KASSERT(pd-pn_parent != NULL,
(%s(): non-root directory has no parent, __func__));
@@ -535,18 +552,28 @@ pfs_lookup(struct vop_cachedlookup_args 
goto failed;
}
 
-   error = pfs_vncache_alloc(vn-v_mount, vpp, pn, pid);
+   error = pfs_vncache_alloc(mp, vpp, pn, pid);
if (error)
goto failed;
 
-   if (cnp-cn_flags  ISDOTDOT)
-   vn_lock(vn, LK_EXCLUSIVE|LK_RETRY);
+   if (cnp-cn_flags  ISDOTDOT) {
+   vfs_unbusy(mp);
+   vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+   if (vn-v_iflag  VI_DOOMED) {
+   vput(*vpp);
+   *vpp = NULL;
+   PFS_RETURN(ENOENT);
+   }
+   }
if (cnp-cn_flags  MAKEENTRY  !(vn-v_iflag  VI_DOOMED))
cache_enter(vn, *vpp, cnp);
PFS_RETURN (0);
  failed:
-   if (cnp-cn_flags  ISDOTDOT)
-   vn_lock(vn, LK_EXCLUSIVE|LK_RETRY);
+   if (cnp-cn_flags  ISDOTDOT) {
+   vfs_unbusy(mp);
+   vn_lock(vn, LK_EXCLUSIVE | LK_RETRY);
+   *vpp = NULL;
+   }
PFS_RETURN(error);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


virtualbox fix for recent current (was Re: svn commit: r232264 - in head/sys: amd64/include i386/include pc98/include x86/include)

2012-03-05 Thread Tijl Coosemans
On Sunday 04 March 2012 22:30:56 Andrey Kosachenko wrote:
 On Tuesday, February 28, 2012 01:38:34 PM Tijl Coosemans wrote:
 Author: tijl
 Date: Tue Feb 28 18:38:33 2012
 New Revision: 232264
 URL: http://svn.freebsd.org/changeset/base/232264

 Log:
Copy amd64 _stdint.h to x86 and merge with i386 _stdint.h. Replace
amd64/i386/pc98 _stdint.h with stubs.

 Added:
head/sys/x86/include/_stdint.h
   - copied, changed from r232259, head/sys/amd64/include/_stdint.h
 Attempt to build 
 emulators/virtualbox-ose fails with the following error:
 
 ---
 kBuild: Compiling tstVMStructRC - 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/testcase/tstVMStructRC.cpp
 In file included from /usr/include/sys/types.h:63,
   from 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/include/iprt/types.h:85,
   from 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/include/VBox/types.h:30,
   from 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/testcase/tstVMStructRC.cpp:33:
 /usr/include/sys/_stdint.h:74: error: conflicting declaration 'typedef 
 __intptr_t intptr_t'
 ^^
 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/include/iprt/stdint.h:162:
  
 error: 'intptr_t' has a previous declaration as 'typedef long int intptr_t'
 /usr/include/sys/_stdint.h:78: error: conflicting declaration 'typedef 
 __uintptr_t uintptr_t'
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/include/iprt/stdint.h:165:
  
 error: 'uintptr_t' has a previous declaration as 'typedef long unsigned 
 int uintptr_t'
 kBuild: Compiling tstAsmStructsasm - 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/testcase/tstAsmStructsAsm.asm
 kBuild: Compiling tstGlobalConfig - 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/testcase/tstGlobalConfig.cpp
 kmk: *** 
 [/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/out/freebsd.amd64/release/obj/tstVMStructRC/tstVMStructRC.o]
  
 Error 1
 The failing command:
 @c++ -m32 -c -O2 -g -pipe -pedantic -Wshadow -Wall -Wextra 

Compiling with -m32 wasn't really supported (until now)...

 -Wno-missing-field-initializers -Wno-unused -Wno-trigraphs 
 -fdiagnostics-show-option -Wno-long-long -Wno-variadic-macros 
 -fno-exceptions -O2 -mtune=generic -fno-omit-frame-pointer -mno-sse 
 -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing -fno-stack-protector 
 -fvisibility=hidden -DVBOX_HAVE_VISIBILITY_HIDDEN 
 -DRT_USE_VISIBILITY_DEFAULT -fvisibility-inlines-hidden -fno-rtti -O0 
 -I/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/include
  
 -I/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/PATM
  
 -I/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/include 
 -I/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/out/freebsd.amd64/release
  
 -DVBOX -DVBOX_WITH_DEBUGGER -DVBOX_OSE -DVBOX_WITH_64_BITS_GUESTS 
 -DVBOX_WITH_HARDENING 
 -DRTPATH_APP_PRIVATE=\/usr/local/share/virtualbox-ose\ 
 -DRTPATH_APP_PRIVATE_ARCH=\/usr/local/lib/virtualbox\ 
 -DRTPATH_SHARED_LIBS=\/usr/local/lib/virtualbox\ 
 -DRTPATH_APP_DOCS=\/usr/local/share/doc/virtualbox-ose\ 
 -DRT_OS_FREEBSD -D__FREEBSD__ -DRT_ARCH_X86 -D__X86__ -DIN_RC 
 -DHC_ARCH_BITS=64 -DGC_ARCH_BITS=64 -DIN_VMM_RC -DIN_DIS -DIN_RT_RC 
 -DVBOX_WITH_RAW_MODE -DIPRT_DONT_USE_SYSTEM_STDINT_H 

...so virtualbox has hacks like IPRT_DONT_USE_SYSTEM_STDINT_H to make
it work. I've attached a patch that you can put in the port's files/
directory. I'll leave it to the port maintainers to commit it or work
out something else, because I think some hacks aren't necessary anymore
(on current).

 -Wp,-MD,/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/out/freebsd.amd64/release/obj/tstVMStructRC/tstVMStructRC.o.dep
  
 -Wp,-MT,/usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/out/freebsd.amd64/release/obj/tstVMStructRC/tstVMStructRC.o
  
 -Wp,-MP -o 
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/out/freebsd.amd64/release/obj/tstVMStructRC/tstVMStructRC.o
  
 /usr/ports/emulators/virtualbox-ose/work/VirtualBox-4.1.8_OSE/src/VBox/VMM/testcase/tstVMStructRC.cpp
 kmk: *** Waiting for unfinished jobs
 kmk: *** Exiting with status 2
 *** [do-build] Error code 2
 
 Stop in /usr/ports/emulators/virtualbox-ose.
 *** [build] Error code 1
 
 Stop in /usr/ports/emulators/virtualbox-ose.
 ---
--- include/iprt/types.h.orig   2012-03-05 10:48:48.0 +0100
+++ include/iprt/types.h2012-03-05 11:21:25.0 +0100
@@ -82,6 +82,8 @@
 #  include stddef.h
 #  define _UINT64_T_DECLARED
 #  define _INT64_T_DECLARED
+#  define _UINTPTR_T_DECLARED
+#  define _INTPTR_T_DECLARED
 #  include sys/types.h
 
 # elif defined(RT_OS_LINUX)  defined(__KERNEL__)


signature.asc
Description: This is 

svn commit: r232547 - head/sys/kern

2012-03-05 Thread Ivan Voras
Author: ivoras
Date: Mon Mar  5 14:19:43 2012
New Revision: 232547
URL: http://svn.freebsd.org/changeset/base/232547

Log:
  Print out process name and thread id in the debugging message.
  This is useful because the message can end up in system logs in
  non-debugging operation.
  
  Reviewed by:  attilio (earlier version)

Modified:
  head/sys/kern/kern_lock.c

Modified: head/sys/kern/kern_lock.c
==
--- head/sys/kern/kern_lock.c   Mon Mar  5 14:04:12 2012(r232546)
+++ head/sys/kern/kern_lock.c   Mon Mar  5 14:19:43 2012(r232547)
@@ -1277,8 +1277,9 @@ lockmgr_printinfo(const struct lock *lk)
(uintmax_t)LK_SHARERS(lk-lk_lock));
else {
td = lockmgr_xholder(lk);
-   printf(lock type %s: EXCL by thread %p (pid %d)\n,
-   lk-lock_object.lo_name, td, td-td_proc-p_pid);
+   printf(lock type %s: EXCL by thread %p 
+   (pid %d, %s, tid %d)\n, lk-lock_object.lo_name, td,
+   td-td_proc-p_pid, td-td_proc-p_comm, td-td_tid);
}
 
x = lk-lk_lock;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232548 - head/sbin/growfs

2012-03-05 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Mar  5 16:37:51 2012
New Revision: 232548
URL: http://svn.freebsd.org/changeset/base/232548

Log:
  Make growfs(8) mostly style compliant.  No functional changes,
  verified with MD5.

Modified:
  head/sbin/growfs/debug.c
  head/sbin/growfs/growfs.c

Modified: head/sbin/growfs/debug.c
==
--- head/sbin/growfs/debug.cMon Mar  5 14:19:43 2012(r232547)
+++ head/sbin/growfs/debug.cMon Mar  5 16:37:51 2012(r232548)
@@ -44,7 +44,6 @@ static const char rcsid[] =
   $FreeBSD$;
 #endif /* not lint */
 
-/* ** INCLUDES * */
 #include sys/param.h
 
 #include limits.h
@@ -57,15 +56,13 @@ static const char rcsid[] =
 
 #ifdef FS_DEBUG
 
-/* *** GLOBALS * */
-static FILE*dbg_log=NULL;
-static unsigned intindent=0;
+static FILE*dbg_log = NULL;
+static unsigned intindent = 0;
 
 /*
  * prototypes not done here, as they come with debug.h
  */
 
-/* ** dbg_open * */
 /*
  * Open the filehandle where all debug output has to go.
  */
@@ -74,14 +71,13 @@ dbg_open(const char *fn)
 {
 
if (strcmp(fn, -) == 0)
-   dbg_log=fopen(/dev/stdout, a);
+   dbg_log = fopen(/dev/stdout, a);
else
-   dbg_log=fopen(fn, a);
+   dbg_log = fopen(fn, a);
 
return;
 }
 
-/* * dbg_close * */
 /*
  * Close the filehandle where all debug output went to.
  */
@@ -89,15 +85,14 @@ void
 dbg_close(void)
 {
 
-   if(dbg_log) {
+   if (dbg_log) {
fclose(dbg_log);
-   dbg_log=NULL;
+   dbg_log = NULL;
}
 
return;
 }
 
-/* ** dbg_dump_hex * */
 /*
  * Dump out a full file system block in hex.
  */
@@ -106,17 +101,16 @@ dbg_dump_hex(struct fs *sb, const char *
 {
int i, j, k;
 
-   if(!dbg_log) {
+   if (!dbg_log)
return;
-   }
+
fprintf(dbg_log, = START HEXDUMP =\n);
fprintf(dbg_log, # %d@%lx: %s\n, indent, (unsigned long)mem, comment);
indent++;
-   for (i=0; isb-fs_bsize; i+=24) {
-   for (j=0; j3; j++) {
-   for (k=0; k8; k++) {
+   for (i = 0; i  sb-fs_bsize; i += 24) {
+   for (j = 0; j  3; j++) {
+   for (k = 0; k  8; k++)
fprintf(dbg_log, %02x , *mem++);
-   }
fprintf(dbg_log,   );
}
fprintf(dbg_log, \n);
@@ -127,7 +121,6 @@ dbg_dump_hex(struct fs *sb, const char *
return;
 }
 
-/* *** dbg_dump_fs * */
 /*
  * Dump the superblock.
  */
@@ -135,12 +128,11 @@ void
 dbg_dump_fs(struct fs *sb, const char *comment)
 {
 #ifdef FSMAXSNAP
-   int j;
+   int j;
 #endif /* FSMAXSNAP */
 
-   if(!dbg_log) {
+   if (!dbg_log)
return;
-   }
 
fprintf(dbg_log, = START SUPERBLOCK =\n);
fprintf(dbg_log, # %d@%lx: %s\n, indent, (unsigned long)sb, comment);
@@ -308,10 +300,10 @@ dbg_dump_fs(struct fs *sb, const char *c
sb-fs_pendinginodes);
 
 #ifdef FSMAXSNAP
-   for(j=0; jFSMAXSNAP; j++) {
+   for (j = 0; j  FSMAXSNAP; j++) {
fprintf(dbg_log, snapinum  int32_t[%2d]  0x%08x\n,
j, sb-fs_snapinum[j]);
-   if(!sb-fs_snapinum[j]) { /* list is dense */
+   if (!sb-fs_snapinum[j]) { /* list is dense */
break;
}
}
@@ -356,7 +348,6 @@ dbg_dump_fs(struct fs *sb, const char *c
return;
 }
 
-/* *** dbg_dump_cg * */
 /*
  * Dump a cylinder group.
  */
@@ -365,9 +356,8 @@ dbg_dump_cg(const char *comment, struct 
 {
int j;
 
-   if(!dbg_log) {
+   if (!dbg_log)
return;
-   }
 
fprintf(dbg_log, = START CYLINDER GROUP =\n);
fprintf(dbg_log, # %d@%lx: %s\n, indent, (unsigned long)cgr, comment);
@@ -383,7 +373,7 @@ dbg_dump_cg(const char *comment, struct 
fprintf(dbg_log, rotor int32_t0x%08x\n, cgr-cg_rotor);
fprintf(dbg_log, frotorint32_t0x%08x\n, cgr-cg_frotor);
fprintf(dbg_log, irotorint32_t0x%08x\n, cgr-cg_irotor);
-   for(j=0; jMAXFRAG; j++) {
+   for (j = 0; j  MAXFRAG; j++) {
fprintf(dbg_log, frsum int32_t[%d] 0x%08x\n, j,
cgr-cg_frsum[j]);
}
@@ -411,7 +401,6 @@ dbg_dump_cg(const char *comment, struct 
return;
 }
 
-/* 

svn commit: r232553 - head/share/man/man9

2012-03-05 Thread Sergey Kandaurov
Author: pluknet
Date: Mon Mar  5 17:38:44 2012
New Revision: 232553
URL: http://svn.freebsd.org/changeset/base/232553

Log:
  Fix typo. Bump .Dd for the previous change.

Modified:
  head/share/man/man9/pci.9

Modified: head/share/man/man9/pci.9
==
--- head/share/man/man9/pci.9   Mon Mar  5 17:33:01 2012(r232552)
+++ head/share/man/man9/pci.9   Mon Mar  5 17:38:44 2012(r232553)
@@ -537,7 +537,7 @@ The
 .Fn pci_release_msi
 function returns zero on success and an error on failure.
 .Pp
-.The
+The
 .Fn pci_count_msix
 function returns the maximum number of MSI-X messages supported by the
 device
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r232519 - head/sys/x86/include

2012-03-05 Thread John Baldwin
On Sunday, March 04, 2012 3:02:20 pm Tijl Coosemans wrote:
 Author: tijl
 Date: Sun Mar  4 20:02:20 2012
 New Revision: 232519
 URL: http://svn.freebsd.org/changeset/base/232519
 
 Log:
   Do not use INT64_C and UINT64_C to define 64 bit integer limits.  They
   aren't defined for C++ code unless __STDC_CONSTANT_MACROS is defined.
   
   Reported by:jhb

Thanks!

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226967 - head/sys/ufs/ufs

2012-03-05 Thread John Baldwin
On Saturday, March 03, 2012 11:38:43 am Peter Holm wrote:
 On Sat, Mar 03, 2012 at 01:01:32AM -0500, Rick Macklem wrote:
  John Baldwin wrote:
   On Friday, March 02, 2012 8:29:21 am Peter Holm wrote:
On Thu, Mar 01, 2012 at 04:47:41PM -0500, John Baldwin wrote:
 On Monday, October 31, 2011 11:01:47 am Peter Holm wrote:
  Author: pho
  Date: Mon Oct 31 15:01:47 2011
  New Revision: 226967
  URL: http://svn.freebsd.org/changeset/base/226967
 
  Log:
The kern_renameat() looks up the fvp using the DELETE flag,
which causes
the removal of the name cache entry for fvp.
 
Reported by: Anton Yuzhaninov citrin citrin ru
In collaboration with: kib
MFC after: 1 week
 
  Modified:
head/sys/ufs/ufs/ufs_vnops.c

 So I ran into this at work recently, and even this fix applied I
 was still
 seeing rename()'s that were seemingly not taking effect. After
 getting some
 extra KTR traces, I figured out that the same purge needs to be
 applied to the
 destination vnode. Specifically, the issue I ran into was that was
 renaming
 'foo' to 'bar', but lookups for 'bar' were still returning the old
 file. The
 reason was that a lookup after the namei(RENAME) of the
 destination while
 ufs_rename() had its locks dropped was readding the name cache
 entry for
 'bar', and then a cache_lookup() of 'bar' would return the old
 vnode as long
 as that vnode was valid (e.g. if it had a link in another
 location, or other
 processes had an open file descriptor for it). I'm currently
 testing the
 patch below:

   
I now have a scenario that fails, but not quite the same way you
describe.
   
It looks like this:
   
touch file1
echo xxx  file2
rename(file1, file2)
   
A different process performs stat() on both files in a tight loop.
   
Once in a while I observe that a stat() of file2, after the rename,
returns a link count of zero. Size is zero as expected, but the
inode
number of file2 is unchanged.
   
  Peter, were you doing a stat() using the file name, or an fstat()?
  (Using stat() with afile name might explain it, maybe??)
  
 
 Yes. Switching to open()/fstat() of the from file in the loop, makes
 the cache problem go away.

Using fstat avoids the changes of getting a stale name cache, so it just 
avoids the race altogether.  However, there is no reason I can think of why 
stat() should ever give you can inconsistent view of attributes.  You should 
always get a consistent snapshot of attributes.

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232561 - in head/sys: amd64/conf i386/conf

2012-03-05 Thread Jung-uk Kim
Author: jkim
Date: Mon Mar  5 18:47:42 2012
New Revision: 232561
URL: http://svn.freebsd.org/changeset/base/232561

Log:
  Fix few style nits.

Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/i386/conf/GENERIC

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Mon Mar  5 18:40:53 2012(r232560)
+++ head/sys/amd64/conf/GENERIC Mon Mar  5 18:47:42 2012(r232561)
@@ -168,7 +168,7 @@ device  psm # PS/2 mouse
 device kbdmux  # keyboard multiplexer
 
 device vga # VGA video card driver
-optionsVESA# add support for VESA BIOS Extensions
+optionsVESA# Add support for VESA BIOS Extensions (VBE)
 
 device splash  # Splash screen and screen saver support
 

Modified: head/sys/i386/conf/GENERIC
==
--- head/sys/i386/conf/GENERIC  Mon Mar  5 18:40:53 2012(r232560)
+++ head/sys/i386/conf/GENERIC  Mon Mar  5 18:47:42 2012(r232561)
@@ -173,7 +173,7 @@ device  psm # PS/2 mouse
 device kbdmux  # keyboard multiplexer
 
 device vga # VGA video card driver
-optionsVESA# add support for VESA BIOS Extensions
+optionsVESA# Add support for VESA BIOS Extensions (VBE)
 
 device splash  # Splash screen and screen saver support
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r232403 - in head/sys: dev/acpica dev/cardbus dev/pci powerpc/ofw sparc64/pci

2012-03-05 Thread John Baldwin
On Friday, March 02, 2012 5:38:07 pm Marius Strobl wrote:
 On Fri, Mar 02, 2012 at 05:18:37PM -0500, John Baldwin wrote:
  On Friday, March 02, 2012 4:45:52 pm Marius Strobl wrote:
   On Fri, Mar 02, 2012 at 08:38:05PM +, John Baldwin wrote:
Author: jhb
Date: Fri Mar  2 20:38:04 2012
New Revision: 232403
URL: http://svn.freebsd.org/changeset/base/232403

Log:
  - Add a bus_dma tag to each PCI bus that is a child of a Host-PCI 
bridge.
The tag enforces a single restriction that all DMA transactions 
must not
cross a 4GB boundary.  Note that while this restriction technically 
only
applies to PCI-express, this change applies it to all PCI devices 
as it
is simpler to implement that way and errs on the side of caution.
   
   Hrm, wouldn't it have been more appropriate to implement this in the
   Host-PCI bridges instead? Probably for anything but x86 this would
   allow to easily distinguish at least between PCI and PCI-Express capable
   bus hierarchies and would move the PAE workaround to the MD bits to
   where it belongs.
  
  The PAE workaround is dying as I've already fixed HEAD to make boundary 
  arguments
  use a bus_addr_t.  However, I committed it in this fashion so it can be 
  MFC'd
  since I can't merge the boundary KBI change.
  
  The reason I did not do this in the Host-PCI bridge drivers is that we 
  would have
  to do this in umpteen different drivers, and all for a change that is 
  mandated by
  the PCI spec and not specific to the various specs the Host-PCI bridge 
  drivers
  all cater to (OFW, ACPI, MPTable, various and sundry embedded platforms, 
  etc.).
  
 
 Well, on !x86 we don't have generic Host-PCI bridge drivers based on
 what you call specs here, but rather specific drivers for individual
 Host-PCI, Host-PCI-X and Host-PCI-Express chips. Whether the PCI*
 buses beneath these are enumerated using FDT, OFW etc. doesn't really
 matter in this context.

Yes, but the 4GB limit is also not specific to the things that make psycho(4)
differ from schizo(4).  We could at least have a common helper routine to
create the tag, but we'd still have a lot of duplicated code to implement
N bus_get_dma_tag methods, etc.  That type of setup is just begging to have
some random Host-PCI bridge driver forget to include the right logic.  It
seems simpler and safer to do it in one central place, so it is always
correct.

Also, while PCI-express is the only type of PCI whose specification enforces
a 4GB boundary, we have seen non-PCI-e PCI devices also need a 4GB boundary
(e.g. bge(4) devices behind an AMD HyperTransport PCI-X bridge).

Given all that, I think having older, non-PCI-e devices possibly use an
extra S/G element in the rare case that a transaction crosses a 4GB boundary
(which won't even happen with the 32-bit DVMA on sparc64 IIUC), is an ok
tradeoff to ensure this constraint is correctly defined for all platforms,
including future chipsets.

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232569 - head/share/man/man9

2012-03-05 Thread John Baldwin
Author: jhb
Date: Mon Mar  5 19:38:59 2012
New Revision: 232569
URL: http://svn.freebsd.org/changeset/base/232569

Log:
  Fix three instances of a missing word.
  
  Submitted by: bjk

Modified:
  head/share/man/man9/pci.9

Modified: head/share/man/man9/pci.9
==
--- head/share/man/man9/pci.9   Mon Mar  5 19:32:44 2012(r232568)
+++ head/share/man/man9/pci.9   Mon Mar  5 19:38:59 2012(r232569)
@@ -222,7 +222,7 @@ for standard capability IDs are defined 
 .In dev/pci/pcireg.h .
 If the capability is found, then
 .Fa *capreg
-is set the offset in configuration space of the capability register set,
+is set to the offset in configuration space of the capability register set,
 and
 .Fn pci_find_cap
 returns zero.
@@ -243,7 +243,7 @@ for standard extended capability IDs are
 .In dev/pci/pcireg.h .
 If the extended capability is found, then
 .Fa *capreg
-is set the offset in configuration space of the extended capability
+is set to the offset in configuration space of the extended capability
 register set, and
 .Fn pci_find_extcap
 returns zero.
@@ -265,7 +265,7 @@ for standard HyperTransport capability t
 .In dev/pci/pcireg.h .
 If the capability is found, then
 .Fa *capreg
-is set the offset in configuration space of the capability register set,
+is set to the offset in configuration space of the capability register set,
 and
 .Fn pci_find_htcap
 returns zero.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232570 - head/sys/boot/i386/boot2

2012-03-05 Thread John Baldwin
Author: jhb
Date: Mon Mar  5 19:53:17 2012
New Revision: 232570
URL: http://svn.freebsd.org/changeset/base/232570

Log:
  Fix boot2 to handle boot config files that only contain a custom path to
  a loader or kernel.  Specifically, kname cannot be pointed at cmd[] since
  it's value is change to be an empty string after the initial call to
  parse, and cmd[]'s value can be changed (thus losing a prior setting for
  kname) due to user input at the boot prompt.  While here, ensure that that
  initial boot config file text is nul-terminated, that ops is initialized
  to zero, and that kname is always initialized to a valid string.
  
  Tested by:Domagoj Smolcic  rank1seeker of gmail
  MFC after:1 week

Modified:
  head/sys/boot/i386/boot2/boot2.c

Modified: head/sys/boot/i386/boot2/boot2.c
==
--- head/sys/boot/i386/boot2/boot2.cMon Mar  5 19:38:59 2012
(r232569)
+++ head/sys/boot/i386/boot2/boot2.cMon Mar  5 19:53:17 2012
(r232570)
@@ -128,7 +128,7 @@ static struct dsk {
 unsigned start;
 int init;
 } dsk;
-static char cmd[512], cmddup[512];
+static char cmd[512], cmddup[512], knamebuf[1024];
 static const char *kname;
 static uint32_t opts;
 static int comspeed = SIOSPD;
@@ -223,7 +223,9 @@ main(void)
 {
 uint8_t autoboot;
 ino_t ino;
+size_t nbyte;
 
+opts = 0;
 kname = NULL;
 dmadat = (void *)(roundup2(__base + (int32_t)_end, 0x1) - __base);
 v86.ctl = V86_FLAGS;
@@ -240,8 +242,10 @@ main(void)
 autoboot = 1;
 
 if ((ino = lookup(PATH_CONFIG)) ||
-(ino = lookup(PATH_DOTCONFIG)))
-   fsread(ino, cmd, sizeof(cmd));
+(ino = lookup(PATH_DOTCONFIG))) {
+   nbyte = fsread(ino, cmd, sizeof(cmd) - 1);
+   cmd[nbyte] = '\0';
+}
 
 if (*cmd) {
memcpy(cmddup, cmd, sizeof(cmd));
@@ -258,9 +262,9 @@ main(void)
  * or in case of failure, try to load a kernel directly instead.
  */
 
-if (autoboot  !kname) {
+if (!kname) {
kname = PATH_BOOT3;
-   if (!keyhit(3*SECOND)) {
+   if (autoboot  !keyhit(3*SECOND)) {
load();
kname = PATH_KERNEL;
}
@@ -457,7 +461,12 @@ parse()
 ? DRV_HARD : 0) + drv;
dsk_meta = 0;
}
-kname = arg;
+   if ((i = ep - arg)) {
+   if ((size_t)i = sizeof(knamebuf))
+   return -1;
+   memcpy(knamebuf, arg, i + 1);
+   kname = knamebuf;
+   }
}
arg = p;
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232571 - head/share/man/man9

2012-03-05 Thread Sergey Kandaurov
Author: pluknet
Date: Mon Mar  5 20:04:28 2012
New Revision: 232571
URL: http://svn.freebsd.org/changeset/base/232571

Log:
  Actually bump date, sigh.

Modified:
  head/share/man/man9/pci.9

Modified: head/share/man/man9/pci.9
==
--- head/share/man/man9/pci.9   Mon Mar  5 19:53:17 2012(r232570)
+++ head/share/man/man9/pci.9   Mon Mar  5 20:04:28 2012(r232571)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd September 30, 2007
+.Dd March 5, 2012
 .Dt PCI 9
 .Os
 .Sh NAME
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232572 - head/libexec/rtld-elf

2012-03-05 Thread Konstantin Belousov
Author: kib
Date: Mon Mar  5 20:43:06 2012
New Revision: 232572
URL: http://svn.freebsd.org/changeset/base/232572

Log:
  The libmap.conf initialization is performed before TLS is functional.
  Since after r232498 the ctype macros require working access to
  thread-local variables, rtld crashes when libmap.conf is present.
  
  Use hand-made isspace1() macro which is enough to detect spaces in
  libmap.conf.
  
  Reported by:  alc, lme, many on current@
  Tested by:lme
  Reviewed by:  dim, kan
  MFC after:1 week

Modified:
  head/libexec/rtld-elf/libmap.c

Modified: head/libexec/rtld-elf/libmap.c
==
--- head/libexec/rtld-elf/libmap.c  Mon Mar  5 20:04:28 2012
(r232571)
+++ head/libexec/rtld-elf/libmap.c  Mon Mar  5 20:43:06 2012
(r232572)
@@ -3,7 +3,6 @@
  */
 
 #include stdio.h
-#include ctype.h
 #include string.h
 #include stdlib.h
 #include sys/queue.h
@@ -53,6 +52,12 @@ static int   closestrfn  (void * cookie);
 #defineiseol(c)(((c) == '#') || ((c) == '\0') || \
 ((c) == '\n') || ((c) == '\r'))
 
+/*
+ * Do not use ctype.h macros, which rely on working TLS.  It is
+ * too early to have thread-local variables functional.
+ */
+#defineisspace1(c) ((c) == ' ' || (c) == '\t')
+
 int
 lm_init (char *libmap_override)
 {
@@ -107,7 +112,7 @@ lmc_parse (FILE *fp)
t = f = c = NULL;
 
/* Skip over leading space */
-   while (isspace(*cp)) cp++;
+   while (isspace1(*cp)) cp++;
 
/* Found a comment or EOL */
if (iseol(*cp)) continue;
@@ -117,7 +122,7 @@ lmc_parse (FILE *fp)
cp++;
 
/* Skip leading space */
-   while (isspace(*cp)) cp++;
+   while (isspace1(*cp)) cp++;
 
/* Found comment, EOL or end of selector */
if  (iseol(*cp) || *cp == ']')
@@ -125,11 +130,11 @@ lmc_parse (FILE *fp)
 
c = cp++;
/* Skip to end of word */
-   while (!isspace(*cp)  !iseol(*cp)  *cp != ']')
+   while (!isspace1(*cp)  !iseol(*cp)  *cp != ']')
cp++;
 
/* Skip and zero out trailing space */
-   while (isspace(*cp)) *cp++ = '\0';
+   while (isspace1(*cp)) *cp++ = '\0';
 
/* Check if there is a closing brace */
if (*cp != ']') continue;
@@ -141,7 +146,7 @@ lmc_parse (FILE *fp)
 * There should be nothing except whitespace or comment
  from this point to the end of the line.
 */
-   while(isspace(*cp)) cp++;
+   while(isspace1(*cp)) cp++;
if (!iseol(*cp)) continue;
 
strcpy(prog, c);
@@ -151,20 +156,20 @@ lmc_parse (FILE *fp)
 
/* Parse the 'from' candidate. */
f = cp++;
-   while (!isspace(*cp)  !iseol(*cp)) cp++;
+   while (!isspace1(*cp)  !iseol(*cp)) cp++;
 
/* Skip and zero out the trailing whitespace */
-   while (isspace(*cp)) *cp++ = '\0';
+   while (isspace1(*cp)) *cp++ = '\0';
 
/* Found a comment or EOL */
if (iseol(*cp)) continue;
 
/* Parse 'to' mapping */
t = cp++;
-   while (!isspace(*cp)  !iseol(*cp)) cp++;
+   while (!isspace1(*cp)  !iseol(*cp)) cp++;
 
/* Skip and zero out the trailing whitespace */
-   while (isspace(*cp)) *cp++ = '\0';
+   while (isspace1(*cp)) *cp++ = '\0';
 
/* Should be no extra tokens at this point */
if (!iseol(*cp)) continue;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232574 - head/lib/libc/sys

2012-03-05 Thread Pawel Jakub Dawidek
Author: pjd
Date: Mon Mar  5 20:59:34 2012
New Revision: 232574
URL: http://svn.freebsd.org/changeset/base/232574

Log:
  Link EV_SET(3) to kqueue(2).
  
  MFC after:3 days

Modified:
  head/lib/libc/sys/Makefile.inc

Modified: head/lib/libc/sys/Makefile.inc
==
--- head/lib/libc/sys/Makefile.inc  Mon Mar  5 20:44:54 2012
(r232573)
+++ head/lib/libc/sys/Makefile.inc  Mon Mar  5 20:59:34 2012
(r232574)
@@ -165,7 +165,7 @@ MLINKS+=jail.2 jail_attach.2 \
jail.2 jail_remove.2 \
jail.2 jail_set.2
 MLINKS+=kldunload.2 kldunloadf.2
-MLINKS+=kqueue.2 kevent.2
+MLINKS+=kqueue.2 kevent.2 kqueue.2 EV_SET.3
 MLINKS+=link.2 linkat.2
 MLINKS+=madvise.2 posix_madvise.2
 MLINKS+=mkdir.2 mkdirat.2
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226967 - head/sys/ufs/ufs

2012-03-05 Thread Peter Holm
On Mon, Mar 05, 2012 at 12:38:57PM -0500, John Baldwin wrote:
 On Saturday, March 03, 2012 11:38:43 am Peter Holm wrote:
  On Sat, Mar 03, 2012 at 01:01:32AM -0500, Rick Macklem wrote:
   John Baldwin wrote:
On Friday, March 02, 2012 8:29:21 am Peter Holm wrote:
 On Thu, Mar 01, 2012 at 04:47:41PM -0500, John Baldwin wrote:
  On Monday, October 31, 2011 11:01:47 am Peter Holm wrote:
   Author: pho
   Date: Mon Oct 31 15:01:47 2011
   New Revision: 226967
   URL: http://svn.freebsd.org/changeset/base/226967
  
   Log:
 The kern_renameat() looks up the fvp using the DELETE flag,
 which causes
 the removal of the name cache entry for fvp.
  
 Reported by: Anton Yuzhaninov citrin citrin ru
 In collaboration with: kib
 MFC after: 1 week
  
   Modified:
 head/sys/ufs/ufs/ufs_vnops.c
 
  So I ran into this at work recently, and even this fix applied I
  was still
  seeing rename()'s that were seemingly not taking effect. After
  getting some
  extra KTR traces, I figured out that the same purge needs to be
  applied to the
  destination vnode. Specifically, the issue I ran into was that was
  renaming
  'foo' to 'bar', but lookups for 'bar' were still returning the old
  file. The
  reason was that a lookup after the namei(RENAME) of the
  destination while
  ufs_rename() had its locks dropped was readding the name cache
  entry for
  'bar', and then a cache_lookup() of 'bar' would return the old
  vnode as long
  as that vnode was valid (e.g. if it had a link in another
  location, or other
  processes had an open file descriptor for it). I'm currently
  testing the
  patch below:
 

 I now have a scenario that fails, but not quite the same way you
 describe.

 It looks like this:

 touch file1
 echo xxx  file2
 rename(file1, file2)

 A different process performs stat() on both files in a tight loop.

 Once in a while I observe that a stat() of file2, after the rename,
 returns a link count of zero. Size is zero as expected, but the
 inode
 number of file2 is unchanged.

   Peter, were you doing a stat() using the file name, or an fstat()?
   (Using stat() with afile name might explain it, maybe??)
   
  
  Yes. Switching to open()/fstat() of the from file in the loop, makes
  the cache problem go away.
 
 Using fstat avoids the changes of getting a stale name cache, so it just 
 avoids the race altogether.  However, there is no reason I can think of why 
 stat() should ever give you can inconsistent view of attributes.  You should 
 always get a consistent snapshot of attributes.
 

Maybe my test scenario is broken, but it sure looks like the link
count is zero, after the rename.

$ ./r9.sh
FAIL: old and new To inode number is identical
stat() before the rename():
fromFile.log: ino =4, nlink = 1, size = 0
toFile.log.00065: ino =   70, nlink = 1, size = 8

stat() after the rename():
toFile.log.00065: ino =   70, nlink = 0, size = 0
$ 

This on r232558 with r232401 reverted. No problem on a pristine
HEAD of cause.

http://people.freebsd.org/~pho/r9.sh

- Peter
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r226967 - head/sys/ufs/ufs

2012-03-05 Thread John Baldwin
On Monday, March 05, 2012 4:43:54 pm Peter Holm wrote:
 On Mon, Mar 05, 2012 at 12:38:57PM -0500, John Baldwin wrote:
  On Saturday, March 03, 2012 11:38:43 am Peter Holm wrote:
   On Sat, Mar 03, 2012 at 01:01:32AM -0500, Rick Macklem wrote:
John Baldwin wrote:
 On Friday, March 02, 2012 8:29:21 am Peter Holm wrote:
  On Thu, Mar 01, 2012 at 04:47:41PM -0500, John Baldwin wrote:
   On Monday, October 31, 2011 11:01:47 am Peter Holm wrote:
Author: pho
Date: Mon Oct 31 15:01:47 2011
New Revision: 226967
URL: http://svn.freebsd.org/changeset/base/226967
   
Log:
  The kern_renameat() looks up the fvp using the DELETE flag,
  which causes
  the removal of the name cache entry for fvp.
   
  Reported by: Anton Yuzhaninov citrin citrin ru
  In collaboration with: kib
  MFC after: 1 week
   
Modified:
  head/sys/ufs/ufs/ufs_vnops.c
  
   So I ran into this at work recently, and even this fix applied I
   was still
   seeing rename()'s that were seemingly not taking effect. After
   getting some
   extra KTR traces, I figured out that the same purge needs to be
   applied to the
   destination vnode. Specifically, the issue I ran into was that was
   renaming
   'foo' to 'bar', but lookups for 'bar' were still returning the old
   file. The
   reason was that a lookup after the namei(RENAME) of the
   destination while
   ufs_rename() had its locks dropped was readding the name cache
   entry for
   'bar', and then a cache_lookup() of 'bar' would return the old
   vnode as long
   as that vnode was valid (e.g. if it had a link in another
   location, or other
   processes had an open file descriptor for it). I'm currently
   testing the
   patch below:
  
 
  I now have a scenario that fails, but not quite the same way you
  describe.
 
  It looks like this:
 
  touch file1
  echo xxx  file2
  rename(file1, file2)
 
  A different process performs stat() on both files in a tight loop.
 
  Once in a while I observe that a stat() of file2, after the rename,
  returns a link count of zero. Size is zero as expected, but the
  inode
  number of file2 is unchanged.
 
Peter, were you doing a stat() using the file name, or an fstat()?
(Using stat() with afile name might explain it, maybe??)

   
   Yes. Switching to open()/fstat() of the from file in the loop, makes
   the cache problem go away.
  
  Using fstat avoids the changes of getting a stale name cache, so it just 
  avoids the race altogether.  However, there is no reason I can think of why 
  stat() should ever give you can inconsistent view of attributes.  You 
  should 
  always get a consistent snapshot of attributes.
  
 
 Maybe my test scenario is broken, but it sure looks like the link
 count is zero, after the rename.

Hmmm, I think it is more the size of zero I'm surprised at.  Presumably a vnode
whose only references are open file descriptors would have a link count of zero,
and so if this race were to occur, I would expect to see that.  However, I would
expect the file to have the 'xxx' contents, so a non-zero file.

Hmm, I wonder what happens if the only link to a file are hold counts (e.g. name
cache entries), but the usecount drops to zero.  Will UFS recycle the i-node in
that case?  If so, perhaps that could explain it?  Or even better, perhaps 
because
the usecount is zero, when the rename happens, UFS goes ahead and zeros out the
file.  That probably explains it then.  (Clearly we need to add a 4th reference
count to vnodes as it is far too simple as-is..)

 
 $ ./r9.sh
 FAIL: old and new To inode number is identical
 stat() before the rename():
 fromFile.log: ino =4, nlink = 1, size = 0
 toFile.log.00065: ino =   70, nlink = 1, size = 8
 
 stat() after the rename():
 toFile.log.00065: ino =   70, nlink = 0, size = 0
 $ 
 
 This on r232558 with r232401 reverted. No problem on a pristine
 HEAD of cause.
 
 http://people.freebsd.org/~pho/r9.sh
 
 - Peter
 

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232576 - head/sys/mips/mips

2012-03-05 Thread Juli Mallett
Author: jmallett
Date: Tue Mar  6 02:23:15 2012
New Revision: 232576
URL: http://svn.freebsd.org/changeset/base/232576

Log:
  In the trap messages that aid the primitive debugging environment of MIPS,
  include the tid as well, so it's easier to tell which thread of a process
  with multiple is responsible for a crash.

Modified:
  head/sys/mips/mips/trap.c

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Mon Mar  5 22:36:50 2012(r232575)
+++ head/sys/mips/mips/trap.c   Tue Mar  6 02:23:15 2012(r232576)
@@ -1312,15 +1312,19 @@ log_illegal_instruction(const char *msg,
pt_entry_t *ptep;
pd_entry_t *pdep;
unsigned int *addr;
-   struct proc *p = curproc;
+   struct thread *td;
+   struct proc *p;
register_t pc;
 
+   td = curthread;
+   p = td-td_proc;
+
 #ifdef SMP
printf(cpuid = %d\n, PCPU_GET(cpuid));
 #endif
pc = frame-pc + (DELAYBRANCH(frame-cause) ? 4 : 0);
-   log(LOG_ERR, %s: pid %d (%s), uid %d: pc %#jx ra %#jx\n,
-   msg, p-p_pid, p-p_comm,
+   log(LOG_ERR, %s: pid %d tid %ld (%s), uid %d: pc %#jx ra %#jx\n,
+   msg, p-p_pid, (long)td-td_tid, p-p_comm,
p-p_ucred ? p-p_ucred-cr_uid : -1,
(intmax_t)pc,
(intmax_t)frame-ra);
@@ -1357,12 +1361,16 @@ log_bad_page_fault(char *msg, struct tra
pt_entry_t *ptep;
pd_entry_t *pdep;
unsigned int *addr;
-   struct proc *p = curproc;
+   struct thread *td;
+   struct proc *p;
char *read_or_write;
register_t pc;
 
trap_type = ~T_USER;
 
+   td = curthread;
+   p = td-td_proc;
+
 #ifdef SMP
printf(cpuid = %d\n, PCPU_GET(cpuid));
 #endif
@@ -1381,8 +1389,8 @@ log_bad_page_fault(char *msg, struct tra
}
 
pc = frame-pc + (DELAYBRANCH(frame-cause) ? 4 : 0);
-   log(LOG_ERR, %s: pid %d (%s), uid %d: pc %#jx got a %s fault at 
%#jx\n,
-   msg, p-p_pid, p-p_comm,
+   log(LOG_ERR, %s: pid %d tid %ld (%s), uid %d: pc %#jx got a %s fault 
at %#jx\n,
+   msg, p-p_pid, (long)td-td_tid, p-p_comm,
p-p_ucred ? p-p_ucred-cr_uid : -1,
(intmax_t)pc,
read_or_write,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232577 - in head/sys/mips: include mips

2012-03-05 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 03:25:50 2012
New Revision: 232577
URL: http://svn.freebsd.org/changeset/base/232577

Log:
  Prepare for large TLS redo. Save pointer to the beginning of TLS area,
  and offset it only if requested by RDHWR handler. Otherwise things
  get overly complicated - we need to track whether address passsed in
  request for setting td_md.md_tls is already offseted or not.

Added:
  head/sys/mips/include/tls.h   (contents, props changed)
Modified:
  head/sys/mips/mips/trap.c
  head/sys/mips/mips/vm_machdep.c

Added: head/sys/mips/include/tls.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/mips/include/tls.h Tue Mar  6 03:25:50 2012(r232577)
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2012 Oleksandr Tymoshenko
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions, and the following disclaimer,
+ *without modification, immediately at the beginning of the file.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in
+ *the documentation and/or other materials provided with the
+ *distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ * 
+ */
+
+#ifndef__MIPS_TLS_H__
+#define__MIPS_TLS_H__
+
+/*
+ * TLS parameters
+ */
+
+#define TLS_TP_OFFSET  0x7000
+#define TLS_DTP_OFFSET 0x8000
+
+#ifdef __mips_n64
+#define TLS_TCB_SIZE   16
+#else
+#define TLS_TCB_SIZE   8
+#endif
+
+#endif /* __MIPS_TLS_H__ */

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Tue Mar  6 02:23:15 2012(r232576)
+++ head/sys/mips/mips/trap.c   Tue Mar  6 03:25:50 2012(r232577)
@@ -83,6 +83,7 @@ __FBSDID($FreeBSD$);
 #include machine/mips_opcode.h
 #include machine/frame.h
 #include machine/regnum.h
+#include machine/tls.h
 #include machine/asm.h
 
 #ifdef DDB
@@ -813,6 +814,7 @@ dofault:
if (inst.RType.rd == 29) {
frame_regs = (trapframe-zero);
frame_regs[inst.RType.rt] = 
(register_t)(intptr_t)td-td_md.md_tls;
+   frame_regs[inst.RType.rt] += 
TLS_TP_OFFSET + TLS_TCB_SIZE;
trapframe-pc += sizeof(int);
goto out;
}

Modified: head/sys/mips/mips/vm_machdep.c
==
--- head/sys/mips/mips/vm_machdep.c Tue Mar  6 02:23:15 2012
(r232576)
+++ head/sys/mips/mips/vm_machdep.c Tue Mar  6 03:25:50 2012
(r232577)
@@ -608,28 +608,9 @@ int
 cpu_set_user_tls(struct thread *td, void *tls_base)
 {
 
-   /* 
-* tls_base passed to this function 
- * from thr_new call and points to actual TCB struct, 
-* so we should add TP_OFFSET + sizeof(struct tcb)
-* to make it the same way TLS base is passed to 
-* MIPS_SET_TLS/MIPS_GET_TLS API 
-*/
-
-#ifdef __mips_n64
-#ifdef COMPAT_FREEBSD32
-   if (!SV_PROC_FLAG(td-td_proc, SV_ILP32)) {
-#endif
-   td-td_md.md_tls = (char*)tls_base + 0x7010;
-   return (0);
-#ifdef COMPAT_FREEBSD32
-   }
-#endif
-#endif
-#if !defined(__mips_n64) || defined(COMPAT_FREEBSD32)
-   td-td_md.md_tls = (char*)tls_base + 0x7008;
+   td-td_md.md_tls = (char*)tls_base;
+
return (0);
-#endif
 }
 
 #ifdef DDB
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232578 - head/libexec/rtld-elf/mips

2012-03-05 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 03:27:08 2012
New Revision: 232578
URL: http://svn.freebsd.org/changeset/base/232578

Log:
  - Switch to saving non-offseted pointer to TLS block in order too keep things 
simple

Modified:
  head/libexec/rtld-elf/mips/reloc.c
  head/libexec/rtld-elf/mips/rtld_machdep.h

Modified: head/libexec/rtld-elf/mips/reloc.c
==
--- head/libexec/rtld-elf/mips/reloc.c  Tue Mar  6 03:25:50 2012
(r232577)
+++ head/libexec/rtld-elf/mips/reloc.c  Tue Mar  6 03:27:08 2012
(r232578)
@@ -40,6 +40,7 @@ __FBSDID($FreeBSD$);
 #include inttypes.h
 
 #include machine/sysarch.h
+#include machine/tls.h
 
 #include debug.h
 #include rtld.h
@@ -622,8 +623,7 @@ allocate_initial_tls(Obj_Entry *objs)
 */
tls_static_space = tls_last_offset + tls_last_size + 
RTLD_STATIC_TLS_EXTRA;
 
-   tls = ((char *) allocate_tls(objs, NULL, TLS_TCB_SIZE, 8) 
-   + TLS_TP_OFFSET + TLS_TCB_SIZE);
+   tls = (char *) allocate_tls(objs, NULL, TLS_TCB_SIZE, 8);
 
sysarch(MIPS_SET_TLS, tls);
 }
@@ -636,8 +636,7 @@ __tls_get_addr(tls_index* ti)
 
sysarch(MIPS_GET_TLS, tls);
 
-   p = tls_get_addr_common((Elf_Addr**)((Elf_Addr)tls - TLS_TP_OFFSET 
-   - TLS_TCB_SIZE), ti-ti_module, ti-ti_offset + TLS_DTP_OFFSET);
+   p = tls_get_addr_common(tls, ti-ti_module, ti-ti_offset + 
TLS_DTP_OFFSET);
 
return (p);
 }

Modified: head/libexec/rtld-elf/mips/rtld_machdep.h
==
--- head/libexec/rtld-elf/mips/rtld_machdep.h   Tue Mar  6 03:25:50 2012
(r232577)
+++ head/libexec/rtld-elf/mips/rtld_machdep.h   Tue Mar  6 03:27:08 2012
(r232578)
@@ -31,6 +31,7 @@
 
 #include sys/types.h
 #include machine/atomic.h
+#include machine/tls.h
 
 struct Struct_Obj_Entry;
 
@@ -48,19 +49,6 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, 
 #define call_initfini_pointer(obj, target) \
(((InitFunc)(target))())
 
-/*
- * TLS
- */
-
-#define TLS_TP_OFFSET  0x7000
-#define TLS_DTP_OFFSET 0x8000
-
-#ifdef __mips_n64
-#define TLS_TCB_SIZE   16
-#else
-#define TLS_TCB_SIZE   8
-#endif
-
 typedef struct {
unsigned long ti_module;
unsigned long ti_offset;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232579 - head/lib/libthr/arch/mips/include

2012-03-05 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 03:27:58 2012
New Revision: 232579
URL: http://svn.freebsd.org/changeset/base/232579

Log:
  - Switch to saving non-offseted pointer to TLS block in order too keep things 
simple

Modified:
  head/lib/libthr/arch/mips/include/pthread_md.h

Modified: head/lib/libthr/arch/mips/include/pthread_md.h
==
--- head/lib/libthr/arch/mips/include/pthread_md.h  Tue Mar  6 03:27:08 
2012(r232578)
+++ head/lib/libthr/arch/mips/include/pthread_md.h  Tue Mar  6 03:27:58 
2012(r232579)
@@ -35,15 +35,11 @@
 
 #include sys/types.h
 #include machine/sysarch.h
+#include machine/tls.h
 #include stddef.h
 
 #defineCPU_SPINWAIT
 #defineDTV_OFFSET  offsetof(struct tcb, tcb_dtv)
-#ifdef __mips_n64
-#defineTP_OFFSET   0x7010
-#else
-#defineTP_OFFSET   0x7008
-#endif
 
 /*
  * Variant I tcb. The structure layout is fixed, don't blindly
@@ -65,7 +61,7 @@ static __inline void
 _tcb_set(struct tcb *tcb)
 {
 
-   sysarch(MIPS_SET_TLS, ((uint8_t*)tcb + TP_OFFSET));
+   sysarch(MIPS_SET_TLS, tcb);
 }
 
 /*
@@ -74,10 +70,10 @@ _tcb_set(struct tcb *tcb)
 static __inline struct tcb *
 _tcb_get(void)
 {
-   uint8_t *tcb;
+   struct tcb *tcb;
 
sysarch(MIPS_GET_TLS, tcb);
-   return ((struct tcb *)(tcb - TP_OFFSET));
+   return tcb;
 }
 
 extern struct pthread *_thr_initial;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232581 - head/lib/libc/mips/gen

2012-03-05 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 03:30:09 2012
New Revision: 232581
URL: http://svn.freebsd.org/changeset/base/232581

Log:
  Implement _set_tp

Modified:
  head/lib/libc/mips/gen/_set_tp.c

Modified: head/lib/libc/mips/gen/_set_tp.c
==
--- head/lib/libc/mips/gen/_set_tp.cTue Mar  6 03:29:46 2012
(r232580)
+++ head/lib/libc/mips/gen/_set_tp.cTue Mar  6 03:30:09 2012
(r232581)
@@ -29,7 +29,11 @@
 #include string.h
 #include stdint.h
 
+#include machine/sysarch.h
+
 void
 _set_tp(void *tp)
 {
+
+   sysarch(MIPS_SET_TLS, tp);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232582 - head/lib/libc/gen

2012-03-05 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Tue Mar  6 03:42:54 2012
New Revision: 232582
URL: http://svn.freebsd.org/changeset/base/232582

Log:
  - Switch ARM and MIPS to TLS Variant I
  - Fix TLS allocation  for Variant I: both rtld and libc allocators
  assume that tls_static_space includes space for TLS structure.
  So increment calculated static size by the size of it.

Modified:
  head/lib/libc/gen/tls.c

Modified: head/lib/libc/gen/tls.c
==
--- head/lib/libc/gen/tls.c Tue Mar  6 03:30:09 2012(r232581)
+++ head/lib/libc/gen/tls.c Tue Mar  6 03:42:54 2012(r232582)
@@ -66,11 +66,11 @@ void __libc_free_tls(void *tls, size_t t
 #error TLS_TCB_ALIGN undefined for target architecture
 #endif
 
-#if defined(__ia64__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__ia64__) || defined(__mips__) || \
+defined(__powerpc__)
 #define TLS_VARIANT_I
 #endif
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \
-defined(__arm__) || defined(__mips__)
+#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__)
 #define TLS_VARIANT_II
 #endif
 
@@ -308,6 +308,13 @@ _init_tls()
}
}
 
+#ifdef TLS_VARIANT_I
+   /*
+* tls_static_space should include space for TLS structure
+*/
+   tls_static_space += TLS_TCB_SIZE;
+#endif
+
tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
 
_set_tp(tls);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232583 - in head/sys/mips: include mips

2012-03-05 Thread Juli Mallett
Author: jmallett
Date: Tue Mar  6 07:47:28 2012
New Revision: 232583
URL: http://svn.freebsd.org/changeset/base/232583

Log:
  When emulating rdhwr for TLS, use the 32-bit offset under COMPAT_FREEBSD32.

Modified:
  head/sys/mips/include/tls.h
  head/sys/mips/mips/trap.c

Modified: head/sys/mips/include/tls.h
==
--- head/sys/mips/include/tls.h Tue Mar  6 03:42:54 2012(r232582)
+++ head/sys/mips/include/tls.h Tue Mar  6 07:47:28 2012(r232583)
@@ -32,6 +32,10 @@
 #ifndef__MIPS_TLS_H__
 #define__MIPS_TLS_H__
 
+#if defined(_KERNEL)  !defined(KLD_MODULE)  !defined(_STANDALONE)
+#include opt_compat.h
+#endif
+
 /*
  * TLS parameters
  */
@@ -41,6 +45,9 @@
 
 #ifdef __mips_n64
 #define TLS_TCB_SIZE   16
+#ifdef COMPAT_FREEBSD32
+#define TLS_TCB_SIZE32 8
+#endif
 #else
 #define TLS_TCB_SIZE   8
 #endif

Modified: head/sys/mips/mips/trap.c
==
--- head/sys/mips/mips/trap.c   Tue Mar  6 03:42:54 2012(r232582)
+++ head/sys/mips/mips/trap.c   Tue Mar  6 07:47:28 2012(r232583)
@@ -814,6 +814,11 @@ dofault:
if (inst.RType.rd == 29) {
frame_regs = (trapframe-zero);
frame_regs[inst.RType.rt] = 
(register_t)(intptr_t)td-td_md.md_tls;
+#if defined(__mips_n64)  defined(COMPAT_FREEBSD32)
+   if (SV_PROC_FLAG(td-td_proc, 
SV_ILP32))
+   
frame_regs[inst.RType.rt] += TLS_TP_OFFSET + TLS_TCB_SIZE32;
+   else
+#endif
frame_regs[inst.RType.rt] += 
TLS_TP_OFFSET + TLS_TCB_SIZE;
trapframe-pc += sizeof(int);
goto out;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r232584 - in head/sys/mips: include mips

2012-03-05 Thread Juli Mallett
Author: jmallett
Date: Tue Mar  6 07:50:45 2012
New Revision: 232584
URL: http://svn.freebsd.org/changeset/base/232584

Log:
  Fix two and a half oversights in COMPAT_FREEBSD32 related to contexts and
  TLS:
  o) The mc_tls field used to store the TLS base when doing context gets and
 restores was left a pointer and not converted to a 32-bit integer.  This
 had the bug of not correctly capturing the TLS value desired by the user,
 and the extra nastiness of making the structure the wrong size.
  o) The mc_tls field was not being saved by sendsig.  As a result, the TLS base
 would always be set to NULL when restoring from a signal handler.
  
  Thanks to gonzo for helping track down a bunch of other TLS bugs that came out
  of tracking these down.

Modified:
  head/sys/mips/include/ucontext.h
  head/sys/mips/mips/freebsd32_machdep.c

Modified: head/sys/mips/include/ucontext.h
==
--- head/sys/mips/include/ucontext.hTue Mar  6 07:47:28 2012
(r232583)
+++ head/sys/mips/include/ucontext.hTue Mar  6 07:50:45 2012
(r232584)
@@ -73,7 +73,7 @@ typedef struct __mcontext32 {
int mc_fpused;
int32_t mc_fpregs[33];
int32_t mc_fpc_eir;
-   void*mc_tls;
+   int32_t mc_tls;
int __spare__[8];
 } mcontext32_t;
 

Modified: head/sys/mips/mips/freebsd32_machdep.c
==
--- head/sys/mips/mips/freebsd32_machdep.c  Tue Mar  6 07:47:28 2012
(r232583)
+++ head/sys/mips/mips/freebsd32_machdep.c  Tue Mar  6 07:50:45 2012
(r232584)
@@ -222,7 +222,7 @@ get_mcontext32(struct thread *td, mconte
for (i = 0; i  33; i++)
mcp-mc_fpregs[i] = mcp64.mc_fpregs[i];
mcp-mc_fpc_eir = mcp64.mc_fpc_eir;
-   mcp-mc_tls = mcp64.mc_tls;
+   mcp-mc_tls = (int32_t)(intptr_t)mcp64.mc_tls;
 
return (0);
 }
@@ -244,7 +244,7 @@ set_mcontext32(struct thread *td, const 
for (i = 0; i  33; i++)
mcp64.mc_fpregs[i] = mcp-mc_fpregs[i];
mcp64.mc_fpc_eir = mcp-mc_fpc_eir;
-   mcp64.mc_tls = mcp-mc_tls;
+   mcp64.mc_tls = (void *)(intptr_t)mcp-mc_tls;
 
return (set_mcontext(td, mcp64));
 }
@@ -395,6 +395,7 @@ freebsd32_sendsig(sig_t catcher, ksiginf
sf.sf_uc.uc_mcontext.mc_pc = regs.r_regs[PC];
sf.sf_uc.uc_mcontext.mullo = regs.r_regs[MULLO];
sf.sf_uc.uc_mcontext.mulhi = regs.r_regs[MULHI];
+   sf.sf_uc.uc_mcontext.mc_tls = (int32_t)(intptr_t)td-td_md.md_tls;
sf.sf_uc.uc_mcontext.mc_regs[0] = UCONTEXT_MAGIC;  /* magic number */
for (i = 1; i  32; i++)
sf.sf_uc.uc_mcontext.mc_regs[i] = regs.r_regs[i];
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org