svn commit: r279958 - in stable: 10/share/mk 9/share/mk

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 17:45:34 2015
New Revision: 279958
URL: https://svnweb.freebsd.org/changeset/base/279958

Log:
  MFC 278682:
  Make the extra dependencies in DPADD be dependencies of PROG_FULL and
  SHLIB_NAME_FULL so that the full binary is relinked when a dependency
  changes.  Right now the existing full binary is left as-is and only
  the objcopy to remove debug symbols is run.

Modified:
  stable/10/share/mk/bsd.lib.mk
  stable/10/share/mk/bsd.prog.mk
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/9/share/mk/bsd.lib.mk
  stable/9/share/mk/bsd.prog.mk
Directory Properties:
  stable/9/share/mk/   (props changed)

Modified: stable/10/share/mk/bsd.lib.mk
==
--- stable/10/share/mk/bsd.lib.mk   Fri Mar 13 16:43:52 2015
(r279957)
+++ stable/10/share/mk/bsd.lib.mk   Fri Mar 13 17:45:34 2015
(r279958)
@@ -276,7 +276,7 @@ _EXTRADEPEND:
mv $$TMP ${DEPENDFILE}
 .if !defined(NO_EXTRADEPEND)  defined(SHLIB_NAME)
 .if defined(DPADD)  !empty(DPADD)
-   echo ${SHLIB_NAME}: ${DPADD}  ${DEPENDFILE}
+   echo ${SHLIB_NAME_FULL}: ${DPADD}  ${DEPENDFILE}
 .endif
 .endif
 

Modified: stable/10/share/mk/bsd.prog.mk
==
--- stable/10/share/mk/bsd.prog.mk  Fri Mar 13 16:43:52 2015
(r279957)
+++ stable/10/share/mk/bsd.prog.mk  Fri Mar 13 17:45:34 2015
(r279958)
@@ -167,15 +167,15 @@ CLEANFILES+= ${OBJS}
 _EXTRADEPEND:
 .if defined(LDFLAGS)  !empty(LDFLAGS:M-nostdlib)
 .if defined(DPADD)  !empty(DPADD)
-   echo ${PROG}: ${DPADD}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${DPADD}  ${DEPENDFILE}
 .endif
 .else
-   echo ${PROG}: ${LIBC} ${DPADD}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBC} ${DPADD}  ${DEPENDFILE}
 .if defined(PROG_CXX)
 .if ${MK_CLANG_IS_CC} != no  empty(CXXFLAGS:M-stdlib=libstdc++)
-   echo ${PROG}: ${LIBCPLUSPLUS}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBCPLUSPLUS}  ${DEPENDFILE}
 .else
-   echo ${PROG}: ${LIBSTDCPLUSPLUS}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBSTDCPLUSPLUS}  ${DEPENDFILE}
 .endif
 .endif
 .endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Konstantin Belousov
On Fri, Mar 13, 2015 at 11:13:22AM -0700, Nathan Whitehorn wrote:
 The compiler assumes that f14-f31 and v20-v31 are preserved by setjmp() 
 (and, e.g. glibc's setjmp() does in fact preserve them). It also tries 
 not to use those registers too much, so the practical impact is limited, 
 but it should actually be fixed.

I think that the setjmp/longjmp case would benefit greatly from the
versioning of the symbols.  Versioning cannot solve all ABI issues,
e.g. if you compiler used old machine/setjmp.h and then link resulting
.o with newer libc, but for complete builds it will help and keep
old binaries working not worse than now.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279959 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 18:04:07 2015
New Revision: 279959
URL: https://svnweb.freebsd.org/changeset/base/279959

Log:
  Use ahci_write_fis_d2h() for commands completion.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 17:45:34 2015
(r279958)
+++ head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 18:04:07 2015
(r279959)
@@ -773,8 +773,8 @@ handle_identify(struct ahci_port *p, int
 
hdr = (struct ahci_cmd_hdr *)(p-cmd_lst + slot * AHCI_CL_SIZE);
if (p-atapi || hdr-prdtl == 0) {
-   p-tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   p-is |= AHCI_P_IX_TFE;
+   ahci_write_fis_d2h(p, slot, cfis,
+   (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR);
} else {
uint16_t buf[256];
uint64_t sectors;
@@ -851,19 +851,16 @@ handle_identify(struct ahci_port *p, int
}
ahci_write_fis_piosetup(p);
write_prdt(p, slot, cfis, (void *)buf, sizeof(buf));
-   p-tfd = ATA_S_DSC | ATA_S_READY;
-   p-is |= AHCI_P_IX_DP;
-   p-ci = ~(1  slot);
+   ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY);
}
-   ahci_generate_intr(p-pr_sc);
 }
 
 static void
 handle_atapi_identify(struct ahci_port *p, int slot, uint8_t *cfis)
 {
if (!p-atapi) {
-   p-tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   p-is |= AHCI_P_IX_TFE;
+   ahci_write_fis_d2h(p, slot, cfis,
+   (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR);
} else {
uint16_t buf[256];
 
@@ -894,11 +891,8 @@ handle_atapi_identify(struct ahci_port *
buf[88] = (1  14 | 0x7f);
ahci_write_fis_piosetup(p);
write_prdt(p, slot, cfis, (void *)buf, sizeof(buf));
-   p-tfd = ATA_S_DSC | ATA_S_READY;
-   p-is |= AHCI_P_IX_DHR;
-   p-ci = ~(1  slot);
+   ahci_write_fis_d2h(p, slot, cfis, ATA_S_DSC | ATA_S_READY);
}
-   ahci_generate_intr(p-pr_sc);
 }
 
 static void
@@ -1479,9 +1473,7 @@ ahci_handle_cmd(struct ahci_port *p, int
p-mult_sectors = cfis[12];
p-tfd = ATA_S_DSC | ATA_S_READY;
}
-   p-is |= AHCI_P_IX_DP;
-   p-ci = ~(1  slot);
-   ahci_generate_intr(p-pr_sc);
+   ahci_write_fis_d2h(p, slot, cfis, p-tfd);
break;
case ATA_READ_DMA:
case ATA_WRITE_DMA:
@@ -1517,17 +1509,15 @@ ahci_handle_cmd(struct ahci_port *p, int
break;
case ATA_PACKET_CMD:
if (!p-atapi) {
-   p-tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   p-is |= AHCI_P_IX_TFE;
-   ahci_generate_intr(p-pr_sc);
+   ahci_write_fis_d2h(p, slot, cfis,
+   (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR);
} else
handle_packet_cmd(p, slot, cfis);
break;
default:
WPRINTF(Unsupported cmd:%02x\n, cfis[2]);
-   p-tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   p-is |= AHCI_P_IX_TFE;
-   ahci_generate_intr(p-pr_sc);
+   ahci_write_fis_d2h(p, slot, cfis,
+   (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR);
break;
}
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279962 - head/lib/libc/posix1e

2015-03-13 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Mar 13 18:42:43 2015
New Revision: 279962
URL: https://svnweb.freebsd.org/changeset/base/279962

Log:
  libc: plug memory leaks in edge cases for the posix1e code.
  
  CID:  1016705
  CID:  1016706
  CID:  1016707
  
  Differential Revision:https://reviews.freebsd.org/D2023

Modified:
  head/lib/libc/posix1e/acl_calc_mask.c
  head/lib/libc/posix1e/acl_strip.c

Modified: head/lib/libc/posix1e/acl_calc_mask.c
==
--- head/lib/libc/posix1e/acl_calc_mask.c   Fri Mar 13 18:38:02 2015
(r279961)
+++ head/lib/libc/posix1e/acl_calc_mask.c   Fri Mar 13 18:42:43 2015
(r279962)
@@ -104,6 +104,7 @@ acl_calc_mask(acl_t *acl_p)
/* if no mask exists, check acl_cnt... */
if (acl_int_new-acl_cnt == ACL_MAX_ENTRIES) {
errno = ENOMEM;
+   acl_free(acl_new);
return (-1);
}
/* ...and add the mask entry */

Modified: head/lib/libc/posix1e/acl_strip.c
==
--- head/lib/libc/posix1e/acl_strip.c   Fri Mar 13 18:38:02 2015
(r279961)
+++ head/lib/libc/posix1e/acl_strip.c   Fri Mar 13 18:42:43 2015
(r279962)
@@ -82,8 +82,10 @@ _posix1e_acl_strip_np(const acl_t aclp, 
 
have_mask_entry = 0;
acl_new = acl_init(ACL_MAX_ENTRIES);
-   if (acl_new == NULL)
+   if (acl_new == NULL) {
+   acl_free(acl_old);
return (NULL);
+   }
tag = ACL_UNDEFINED_TAG;
 
/* only save the default user/group/other entries */
@@ -94,16 +96,16 @@ _posix1e_acl_strip_np(const acl_t aclp, 
assert(_entry_brand(entry) == ACL_BRAND_POSIX);
 
if (acl_get_tag_type(entry, tag) == -1)
-   return (NULL);
+   goto fail;
 
switch(tag) {
case ACL_USER_OBJ:
case ACL_GROUP_OBJ:
case ACL_OTHER:
if (acl_get_tag_type(entry, tag) == -1)
-   return (NULL);
+   goto fail;
if (acl_get_permset(entry, perm) == -1)
-   return (NULL);
+   goto fail;
if (acl_create_entry(acl_new, entry_new) == -1)
return (NULL);
if (acl_set_tag_type(entry_new, tag) == -1)
@@ -120,6 +122,10 @@ _posix1e_acl_strip_np(const acl_t aclp, 
default:
break;
}
+fail:
+   acl_free(acl_new);
+   acl_free(acl_old);
+   return (NULL);
}
 
assert(_acl_brand(acl_new) == ACL_BRAND_POSIX);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Konstantin Belousov
On Fri, Mar 13, 2015 at 10:06:05AM -0700, Nathan Whitehorn wrote:
 One more thing I'd appreciate advice on: we have a much worse ABI issue 
 with setjmp(). On 32-bit systems, _JBLEN is too small to hold all the 
 nonvolatile vector registers. Do you have any ideas how to handle that?

There is no solution there.  On x86, both 32 and 64 bit, setjmp only
saves fpu control word (and mxcsr on amd64, where SSE2 is guaranteed to
be presented).  So only limited bits of the whole arch state is saved
and restored.  I suggest to just leave setjmp as it is.

In fact, FreeBSD cannot work on 486SX due to this.  Shell uses setjmp,
and despite kernel carefully handling FPU-less CPU, shell fails from the
beginning.

Please note that ucontext_t API was designed by System V group to handle
this deficiency in the setjmp/longjmp API, to cover the whole machine
context and provide almost-portable interface for non-local control flow
:/. As usual, SysV produced something which failed. In particular, the
size and layout of ucontext_t is user-visible and cannot be changed.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread John Baldwin
On Friday, March 13, 2015 10:14:27 AM Ian Lepore wrote:
 On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
  On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
   On Thu, 2015-03-12 at 17:02 -0400, Ryan Stone wrote:
On Thu, Mar 12, 2015 at 2:06 PM, Ian Lepore i...@freebsd.org wrote:

   Nullterminate strings returned via sysctl.

   PR:   195668


To quote the manpage:

 The *sbuf* family of functions allows one to safely
 allocate, construct and release bounded null-terminated
 strings in kernel space.

IMO the sbuf API is broken if we have to explicitly null-terminate the
string ourselves.
   
   If we want the nullterm to be counted in the length of data in the
   buffer (and thus get transmitted back across the syscall boundary) we
   need to put an explicit counted nullterm byte into the buffer.
   
   I had started down the path of making that (counting the nullterm byte
   as part of the data in the buffer) a feature of sbuf that you could set
   with a flag, but then whoever added sbuf_new_for_sysctl() didn't
   propagate the flags field through the new function and I decided to not
   go off into the weeds making a new flavor of that takes flags.
  
  One suggestion would be to consider using '\0' for a nul character instead 
  of
  a bare 0.  To me that communicates the intention more clearly to the reader.
  (One of the things I did not like about C++  C++11 was the use of 0 for
  NULL.  I much prefer nullptr and NULL in C over bare 0's for pointers for
  similar clarity reasons.)
  
 
 I have waffled back and forth between preferring 0 or '\0' for 30 years,
 I just seem to go through phases with nullterm expression.
 
 In general I'm glad I got called away to an onsite meeting yesterday and
 didn't get far with these changes, because the more I think about it,
 the less satisfied I am with this expedient fix.  The other fix I
 started on, where a new SBUF_COUNTNUL flag can be set to inform the
 sbuf_finish() code that you want the terminating nul counted in the data
 length just feels like a better fit for the overall automaticness of
 how the sbuf stuff works.

Hmm, I actually think that it's a bug that the terminating nul isn't included
when draining.  If we fixed that then I think that fixes most of these?
The places that explicitly use 'sysctl_handle_string()' with an sbuf
should probably just be using sbuf_len(sb) + 1' explicitly.  (Another
option would be to have a sysctl_handle_sbuf() that was a wrapper around
sysctl_handle_string() that included the + 1 to hide that detail if there is
more than one.)

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


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Nathan Whitehorn


On 03/13/15 10:23, Konstantin Belousov wrote:

On Fri, Mar 13, 2015 at 10:06:05AM -0700, Nathan Whitehorn wrote:

One more thing I'd appreciate advice on: we have a much worse ABI issue
with setjmp(). On 32-bit systems, _JBLEN is too small to hold all the
nonvolatile vector registers. Do you have any ideas how to handle that?

There is no solution there.  On x86, both 32 and 64 bit, setjmp only
saves fpu control word (and mxcsr on amd64, where SSE2 is guaranteed to
be presented).  So only limited bits of the whole arch state is saved
and restored.  I suggest to just leave setjmp as it is.

In fact, FreeBSD cannot work on 486SX due to this.  Shell uses setjmp,
and despite kernel carefully handling FPU-less CPU, shell fails from the
beginning.

Please note that ucontext_t API was designed by System V group to handle
this deficiency in the setjmp/longjmp API, to cover the whole machine
context and provide almost-portable interface for non-local control flow
:/. As usual, SysV produced something which failed. In particular, the
size and layout of ucontext_t is user-visible and cannot be changed.

We'll need to hack the compiler in this case, since it assumes setjmp() 
saves and restores the vector registers. I'm really not sure which 
option is worse.

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


svn commit: r279958 - in stable: 10/share/mk 9/share/mk

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 17:45:34 2015
New Revision: 279958
URL: https://svnweb.freebsd.org/changeset/base/279958

Log:
  MFC 278682:
  Make the extra dependencies in DPADD be dependencies of PROG_FULL and
  SHLIB_NAME_FULL so that the full binary is relinked when a dependency
  changes.  Right now the existing full binary is left as-is and only
  the objcopy to remove debug symbols is run.

Modified:
  stable/9/share/mk/bsd.lib.mk
  stable/9/share/mk/bsd.prog.mk
Directory Properties:
  stable/9/share/mk/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/share/mk/bsd.lib.mk
  stable/10/share/mk/bsd.prog.mk
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/share/mk/bsd.lib.mk
==
--- stable/9/share/mk/bsd.lib.mkFri Mar 13 16:43:52 2015
(r279957)
+++ stable/9/share/mk/bsd.lib.mkFri Mar 13 17:45:34 2015
(r279958)
@@ -275,7 +275,7 @@ _EXTRADEPEND:
mv $$TMP ${DEPENDFILE}
 .if !defined(NO_EXTRADEPEND)  defined(SHLIB_NAME)
 .if defined(DPADD)  !empty(DPADD)
-   echo ${SHLIB_NAME}: ${DPADD}  ${DEPENDFILE}
+   echo ${SHLIB_NAME_FULL}: ${DPADD}  ${DEPENDFILE}
 .endif
 .endif
 

Modified: stable/9/share/mk/bsd.prog.mk
==
--- stable/9/share/mk/bsd.prog.mk   Fri Mar 13 16:43:52 2015
(r279957)
+++ stable/9/share/mk/bsd.prog.mk   Fri Mar 13 17:45:34 2015
(r279958)
@@ -168,15 +168,15 @@ CLEANFILES+= ${OBJS}
 _EXTRADEPEND:
 .if defined(LDFLAGS)  !empty(LDFLAGS:M-nostdlib)
 .if defined(DPADD)  !empty(DPADD)
-   echo ${PROG}: ${DPADD}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${DPADD}  ${DEPENDFILE}
 .endif
 .else
-   echo ${PROG}: ${LIBC} ${DPADD}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBC} ${DPADD}  ${DEPENDFILE}
 .if defined(PROG_CXX)  !defined(EARLY_BUILD)
 .if !empty(CXXFLAGS:M-stdlib=libc++)
-   echo ${PROG}: ${LIBCPLUSPLUS}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBCPLUSPLUS}  ${DEPENDFILE}
 .else
-   echo ${PROG}: ${LIBSTDCPLUSPLUS}  ${DEPENDFILE}
+   echo ${PROG_FULL}: ${LIBSTDCPLUSPLUS}  ${DEPENDFILE}
 .endif
 .endif
 .endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Nathan Whitehorn


On 03/13/15 10:59, Konstantin Belousov wrote:

On Fri, Mar 13, 2015 at 10:45:46AM -0700, Nathan Whitehorn wrote:

We'll need to hack the compiler in this case, since it assumes setjmp()
saves and restores the vector registers. I'm really not sure which
option is worse.

Changing the compiler is arguably much worse than breaking ABI of the
tier 2 platform, indeed.  We must maintain the situation where the stock
build of the compilers work out of box.

Still, how the compiler' assumptions are laid out ?  It could be argued
that compilers on x86 also assume that FPU register file is restored by
longjmp.  %st* and %xmm* are defined as not preserved across function
calls, but I suspect that practical rule for setjmp() is that floating
vars better not be used in the target frame.

Hm, indeed f14-f31 and v20-v31 are marked as non-volatile for 64bit ABI.



The compiler assumes that f14-f31 and v20-v31 are preserved by setjmp() 
(and, e.g. glibc's setjmp() does in fact preserve them). It also tries 
not to use those registers too much, so the practical impact is limited, 
but it should actually be fixed.

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


svn commit: r279960 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 18:35:38 2015
New Revision: 279960
URL: https://svnweb.freebsd.org/changeset/base/279960

Log:
  Add support for PIO variants of READ/WRITE commands for AHCI disks.
  
  AHCI API hides all PIO specifics, so this functionality is almost free.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 18:04:07 2015
(r279959)
+++ head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 18:35:38 2015
(r279960)
@@ -520,12 +520,14 @@ ahci_handle_dma(struct ahci_port *p, int
readop = 1;
 
prdt += seek;
-   if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48 ||
-   cfis[2] == ATA_WRITE_FPDMA_QUEUED)
+   if (cfis[2] == ATA_WRITE || cfis[2] == ATA_WRITE48 ||
+   cfis[2] == ATA_WRITE_MUL || cfis[2] == ATA_WRITE_MUL48 ||
+   cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48 ||
+   cfis[2] == ATA_WRITE_FPDMA_QUEUED)
readop = 0;
 
if (cfis[2] == ATA_WRITE_FPDMA_QUEUED ||
-   cfis[2] == ATA_READ_FPDMA_QUEUED) {
+   cfis[2] == ATA_READ_FPDMA_QUEUED) {
lba = ((uint64_t)cfis[10]  40) |
((uint64_t)cfis[9]  32) |
((uint64_t)cfis[8]  24) |
@@ -536,7 +538,9 @@ ahci_handle_dma(struct ahci_port *p, int
if (!len)
len = 65536;
ncq = 1;
-   } else if (cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) {
+   } else if (cfis[2] == ATA_READ48 || cfis[2] == ATA_WRITE48 ||
+   cfis[2] == ATA_READ_MUL48 || cfis[2] == ATA_WRITE_MUL48 ||
+   cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) {
lba = ((uint64_t)cfis[10]  40) |
((uint64_t)cfis[9]  32) |
((uint64_t)cfis[8]  24) |
@@ -1475,6 +1479,14 @@ ahci_handle_cmd(struct ahci_port *p, int
}
ahci_write_fis_d2h(p, slot, cfis, p-tfd);
break;
+   case ATA_READ:
+   case ATA_WRITE:
+   case ATA_READ48:
+   case ATA_WRITE48:
+   case ATA_READ_MUL:
+   case ATA_WRITE_MUL:
+   case ATA_READ_MUL48:
+   case ATA_WRITE_MUL48:
case ATA_READ_DMA:
case ATA_WRITE_DMA:
case ATA_READ_DMA48:
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Konstantin Belousov
On Fri, Mar 13, 2015 at 10:45:46AM -0700, Nathan Whitehorn wrote:
 We'll need to hack the compiler in this case, since it assumes setjmp() 
 saves and restores the vector registers. I'm really not sure which 
 option is worse.

Changing the compiler is arguably much worse than breaking ABI of the
tier 2 platform, indeed.  We must maintain the situation where the stock
build of the compilers work out of box.

Still, how the compiler' assumptions are laid out ?  It could be argued
that compilers on x86 also assume that FPU register file is restored by
longjmp.  %st* and %xmm* are defined as not preserved across function
calls, but I suspect that practical rule for setjmp() is that floating
vars better not be used in the target frame.

Hm, indeed f14-f31 and v20-v31 are marked as non-volatile for 64bit ABI.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279961 - stable/10/sys/dev/drm2/i915

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 18:38:02 2015
New Revision: 279961
URL: https://svnweb.freebsd.org/changeset/base/279961

Log:
  MFC 270516:
  i915 driver - enable opregion handle; program CADL.
  
  add opregion handling for drm2 - which exposes some ACPI video configuration
  pieces that some Lenovo laptop models use to flesh out which video device
  to speak to.  This enables the brightness control in ACPI to work these 
models.
  
  The CADL bits are also important - it's used to figure out which ACPI
  events to hook the brightness buttons into.  It doesn't yet seem to work
  for me, but it does for the OP.
  
  PR:   190186, 198551
  Submitted by: Henry Hu henry.hu...@gmail.com

Modified:
  stable/10/sys/dev/drm2/i915/i915_drv.h
  stable/10/sys/dev/drm2/i915/i915_irq.c
  stable/10/sys/dev/drm2/i915/intel_opregion.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/drm2/i915/i915_drv.h
==
--- stable/10/sys/dev/drm2/i915/i915_drv.h  Fri Mar 13 18:35:38 2015
(r279960)
+++ stable/10/sys/dev/drm2/i915/i915_drv.h  Fri Mar 13 18:38:02 2015
(r279961)
@@ -1277,10 +1277,11 @@ extern void intel_iic_reset(struct drm_d
 
 /* intel_opregion.c */
 int intel_opregion_setup(struct drm_device *dev);
-extern int intel_opregion_init(struct drm_device *dev);
+extern void intel_opregion_init(struct drm_device *dev);
 extern void intel_opregion_fini(struct drm_device *dev);
-extern void opregion_asle_intr(struct drm_device *dev);
-extern void opregion_enable_asle(struct drm_device *dev);
+extern void intel_opregion_asle_intr(struct drm_device *dev);
+extern void intel_opregion_gse_intr(struct drm_device *dev);
+extern void intel_opregion_enable_asle(struct drm_device *dev);
 
 /* i915_gem_gtt.c */
 int i915_gem_init_aliasing_ppgtt(struct drm_device *dev);

Modified: stable/10/sys/dev/drm2/i915/i915_irq.c
==
--- stable/10/sys/dev/drm2/i915/i915_irq.c  Fri Mar 13 18:35:38 2015
(r279960)
+++ stable/10/sys/dev/drm2/i915/i915_irq.c  Fri Mar 13 18:38:02 2015
(r279961)
@@ -537,11 +537,7 @@ ivybridge_irq_handler(void *arg)
notify_ring(dev, dev_priv-rings[BCS]);
 
if (de_iir  DE_GSE_IVB) {
-#if 1
-   KIB_NOTYET();
-#else
intel_opregion_gse_intr(dev);
-#endif
}
 
if (de_iir  DE_PLANEA_FLIP_DONE_IVB) {
@@ -649,11 +645,7 @@ ironlake_irq_handler(void *arg)
notify_ring(dev, dev_priv-rings[BCS]);
 
if (de_iir  DE_GSE) {
-#if 1
-   KIB_NOTYET();
-#else
intel_opregion_gse_intr(dev);
-#endif
}
 
if (de_iir  DE_PLANEA_FLIP_DONE) {
@@ -1055,11 +1047,7 @@ i915_driver_irq_handler(void *arg)
 
 
if (blc_event || (iir  I915_ASLE_INTERRUPT)) {
-#if 1
-   KIB_NOTYET();
-#else
intel_opregion_asle_intr(dev);
-#endif
}
 
/* With MSI, interrupts are only generated when iir
@@ -1781,11 +1769,7 @@ i915_driver_irq_postinstall(struct drm_d
I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
}
 
-#if 1
-   KIB_NOTYET();
-#else
intel_opregion_enable_asle(dev);
-#endif
 
return 0;
 }

Modified: stable/10/sys/dev/drm2/i915/intel_opregion.c
==
--- stable/10/sys/dev/drm2/i915/intel_opregion.cFri Mar 13 18:35:38 
2015(r279960)
+++ stable/10/sys/dev/drm2/i915/intel_opregion.cFri Mar 13 18:38:02 
2015(r279961)
@@ -32,6 +32,9 @@ __FBSDID($FreeBSD$);
 #include dev/drm2/i915/i915_drm.h
 #include dev/drm2/i915/i915_drv.h
 #include dev/drm2/i915/intel_drv.h
+#include contrib/dev/acpica/include/acpi.h
+#include contrib/dev/acpica/include/accommon.h
+#include dev/acpica/acpivar.h
 
 #define PCI_ASLE 0xe4
 #define PCI_ASLS 0xfc
@@ -144,7 +147,7 @@ struct opregion_asle {
 #define ACPI_DIGITAL_OUTPUT (38)
 #define ACPI_LVDS_OUTPUT (48)
 
-#ifdef CONFIG_ACPI
+#if 1
 static u32 asle_set_backlight(struct drm_device *dev, u32 bclp)
 {
struct drm_i915_private *dev_priv = dev-dev_private;
@@ -289,6 +292,7 @@ void intel_opregion_enable_asle(struct d
 
 static struct intel_opregion *system_opregion;
 
+#if 0
 static int intel_opregion_video_event(struct notifier_block *nb,
  unsigned long val, void *data)
 {
@@ -319,6 +323,7 @@ static int intel_opregion_video_event(st
 static struct notifier_block intel_opregion_notifier = {
.notifier_call = intel_opregion_video_event,
 };
+#endif
 
 /*
  * Initialise the DIDL field in opregion. This passes a list of devices to
@@ -326,37 +331,72 @@ static struct notifier_block intel_opreg
  * (version 3)
  */
 
+static int acpi_is_video_device(ACPI_HANDLE devh) {
+   ACPI_HANDLE h;
+   if 

Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread Ian Lepore
On Fri, 2015-03-13 at 13:19 -0400, John Baldwin wrote:
 On Friday, March 13, 2015 10:14:27 AM Ian Lepore wrote:
  On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
   On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
[...]
  
  In general I'm glad I got called away to an onsite meeting yesterday and
  didn't get far with these changes, because the more I think about it,
  the less satisfied I am with this expedient fix.  The other fix I
  started on, where a new SBUF_COUNTNUL flag can be set to inform the
  sbuf_finish() code that you want the terminating nul counted in the data
  length just feels like a better fit for the overall automaticness of
  how the sbuf stuff works.
 
 Hmm, I actually think that it's a bug that the terminating nul isn't included
 when draining.  If we fixed that then I think that fixes most of these?
 The places that explicitly use 'sysctl_handle_string()' with an sbuf
 should probably just be using sbuf_len(sb) + 1' explicitly.  (Another
 option would be to have a sysctl_handle_sbuf() that was a wrapper around
 sysctl_handle_string() that included the + 1 to hide that detail if there is
 more than one.)
 

Some of the uses of sbuf for sysctl use sbuf_bcat() for dealing with
binary structs, so we can't just assume that a nullterm should be added
and included in the buffer length -- there needs to be some mechanism to
say explicitly this is an sbuf for a sysctl string (and more generally
this is an sbuf for a string where I want the nul byte counted as part
of the data because that could be useful in non-sysctl contexts too,
especially in userland).

-- Ian


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


svn commit: r279967 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 20:56:17 2015
New Revision: 279967
URL: https://svnweb.freebsd.org/changeset/base/279967

Log:
  Change prdbc value reporting.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 20:14:55 2015
(r279966)
+++ head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 20:56:17 2015
(r279967)
@@ -1662,6 +1662,9 @@ ata_ioreq_cb(struct blockif_req *br, int
 */
STAILQ_INSERT_TAIL(p-iofhd, aior, io_flist);
 
+   if (!err)
+   hdr-prdbc = aior-done;
+
if (dsm) {
if (aior-done != aior-len  !err) {
ahci_handle_dsm_trim(p, slot, cfis, aior-done);
@@ -1677,13 +1680,8 @@ ata_ioreq_cb(struct blockif_req *br, int
 
if (!err  aior-done == aior-len) {
tfd = ATA_S_READY | ATA_S_DSC;
-   if (ncq)
-   hdr-prdbc = 0;
-   else
-   hdr-prdbc = aior-len;
} else {
tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   hdr-prdbc = 0;
if (ncq)
p-serr |= (1  slot);
}
@@ -1738,6 +1736,9 @@ atapi_ioreq_cb(struct blockif_req *br, i
 */
STAILQ_INSERT_TAIL(p-iofhd, aior, io_flist);
 
+   if (!err)
+   hdr-prdbc = aior-done;
+
if (pending  !err) {
atapi_read(p, slot, cfis, aior-done, hdr-prdtl - pending);
goto out;
@@ -1745,12 +1746,10 @@ atapi_ioreq_cb(struct blockif_req *br, i
 
if (!err  aior-done == aior-len) {
tfd = ATA_S_READY | ATA_S_DSC;
-   hdr-prdbc = aior-len;
} else {
p-sense_key = ATA_SENSE_ILLEGAL_REQUEST;
p-asc = 0x21;
tfd = (p-sense_key  12) | ATA_S_READY | ATA_S_ERROR;
-   hdr-prdbc = 0;
}
 
cfis[4] = (cfis[4]  ~7) | ATA_I_CMD | ATA_I_IN;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279964 - in stable: 8/sys/dev/ipmi 9/sys/dev/ipmi

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 20:10:09 2015
New Revision: 279964
URL: https://svnweb.freebsd.org/changeset/base/279964

Log:
  MFC 278321:
  Use direct hardware access for internal requests for KCS and SMIC.  In
  particular, updates to the watchdog should no longer sleep.
  - Add a new IPMI_IO_LOCK for low-level I/O access.  Use this for
kcs_polled_request() and smic_polled_request().
  - Add a new backend callback ipmi_driver_request to handle a driver
request.  The new callback performs the request sychronously for KCS
and SMIC.  SSIF still defers the work to the worker thread since the
worker thread sleeps during request processing anyway.
  - Allocate driver requests on the stack rather than using malloc().

Modified:
  stable/9/sys/dev/ipmi/ipmi.c
  stable/9/sys/dev/ipmi/ipmi_kcs.c
  stable/9/sys/dev/ipmi/ipmi_smic.c
  stable/9/sys/dev/ipmi/ipmi_ssif.c
  stable/9/sys/dev/ipmi/ipmivars.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/8/sys/dev/ipmi/ipmi.c
  stable/8/sys/dev/ipmi/ipmi_kcs.c
  stable/8/sys/dev/ipmi/ipmi_smic.c
  stable/8/sys/dev/ipmi/ipmi_ssif.c
  stable/8/sys/dev/ipmi/ipmivars.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/ipmi/   (props changed)

Modified: stable/9/sys/dev/ipmi/ipmi.c
==
--- stable/9/sys/dev/ipmi/ipmi.cFri Mar 13 20:08:35 2015
(r279963)
+++ stable/9/sys/dev/ipmi/ipmi.cFri Mar 13 20:10:09 2015
(r279964)
@@ -49,6 +49,23 @@ __FBSDID($FreeBSD$);
 #include dev/ipmi/ipmivars.h
 #endif
 
+/*
+ * Driver request structures are allocated on the stack via alloca() to
+ * avoid calling malloc(), especially for the watchdog handler.
+ * To avoid too much stack growth, a previously allocated structure can
+ * be reused via IPMI_INIT_DRIVER_REQUEST(), but the caller should ensure
+ * that there is adequate reply/request space in the original allocation.
+ */
+#defineIPMI_INIT_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen)  
\
+   bzero((req), sizeof(struct ipmi_request));  \
+   ipmi_init_request((req), NULL, 0, (addr), (cmd), (reqlen), (replylen))
+
+#defineIPMI_ALLOC_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen) 
\
+   (req) = __builtin_alloca(sizeof(struct ipmi_request) +  \
+   (reqlen) + (replylen)); \
+   IPMI_INIT_DRIVER_REQUEST((req), (addr), (cmd), (reqlen),\
+   (replylen))
+
 #ifdef IPMB
 static int ipmi_ipmb_checksum(u_char, int);
 static int ipmi_ipmb_send_message(device_t, u_char, u_char, u_char,
@@ -181,8 +198,8 @@ ipmi_dtor(void *arg)
 */
dev-ipmi_closing = 1;
while (dev-ipmi_requests  0) {
-   msleep(dev-ipmi_requests, sc-ipmi_lock, PWAIT,
-   ipmidrain, 0);
+   msleep(dev-ipmi_requests, sc-ipmi_requests_lock,
+   PWAIT, ipmidrain, 0);
ipmi_purge_completed_requests(dev);
}
}
@@ -215,7 +232,7 @@ ipmi_ipmb_send_message(device_t dev, u_c
u_char slave_addr = 0x52;
int error;
 
-   req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+   IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
IPMI_SEND_MSG, data_len + 8, 0);
req-ir_request[0] = channel;
req-ir_request[1] = slave_addr;
@@ -231,7 +248,6 @@ ipmi_ipmb_send_message(device_t dev, u_c
 
ipmi_submit_driver_request(sc, req);
error = req-ir_error;
-   ipmi_free_request(req);
 
return (error);
 }
@@ -243,7 +259,7 @@ ipmi_handle_attn(struct ipmi_softc *sc)
int error;
 
device_printf(sc-ipmi_dev, BMC has a message\n);
-   req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+   IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
IPMI_GET_MSG_FLAGS, 0, 1);
 
ipmi_submit_driver_request(sc, req);
@@ -257,9 +273,7 @@ ipmi_handle_attn(struct ipmi_softc *sc)
watchdog about to go off);
}
if (req-ir_reply[0]  IPMI_MSG_AVAILABLE) {
-   ipmi_free_request(req);
-
-   req = ipmi_alloc_driver_request(
+   IPMI_ALLOC_DRIVER_REQUEST(req,
IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_MSG, 0,
16);
 
@@ -268,7 +282,6 @@ ipmi_handle_attn(struct ipmi_softc *sc)
}
}
error = req-ir_error;
-   ipmi_free_request(req);
 
return (error);
 }
@@ -478,15 +491,11 @@ ipmi_ioctl(struct cdev *cdev, u_long cmd
  * Request management.
  */
 
-/* Allocate a new request 

svn commit: r279964 - in stable: 8/sys/dev/ipmi 9/sys/dev/ipmi

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 20:10:09 2015
New Revision: 279964
URL: https://svnweb.freebsd.org/changeset/base/279964

Log:
  MFC 278321:
  Use direct hardware access for internal requests for KCS and SMIC.  In
  particular, updates to the watchdog should no longer sleep.
  - Add a new IPMI_IO_LOCK for low-level I/O access.  Use this for
kcs_polled_request() and smic_polled_request().
  - Add a new backend callback ipmi_driver_request to handle a driver
request.  The new callback performs the request sychronously for KCS
and SMIC.  SSIF still defers the work to the worker thread since the
worker thread sleeps during request processing anyway.
  - Allocate driver requests on the stack rather than using malloc().

Modified:
  stable/8/sys/dev/ipmi/ipmi.c
  stable/8/sys/dev/ipmi/ipmi_kcs.c
  stable/8/sys/dev/ipmi/ipmi_smic.c
  stable/8/sys/dev/ipmi/ipmi_ssif.c
  stable/8/sys/dev/ipmi/ipmivars.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/ipmi/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/9/sys/dev/ipmi/ipmi.c
  stable/9/sys/dev/ipmi/ipmi_kcs.c
  stable/9/sys/dev/ipmi/ipmi_smic.c
  stable/9/sys/dev/ipmi/ipmi_ssif.c
  stable/9/sys/dev/ipmi/ipmivars.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/8/sys/dev/ipmi/ipmi.c
==
--- stable/8/sys/dev/ipmi/ipmi.cFri Mar 13 20:08:35 2015
(r279963)
+++ stable/8/sys/dev/ipmi/ipmi.cFri Mar 13 20:10:09 2015
(r279964)
@@ -49,6 +49,23 @@ __FBSDID($FreeBSD$);
 #include dev/ipmi/ipmivars.h
 #endif
 
+/*
+ * Driver request structures are allocated on the stack via alloca() to
+ * avoid calling malloc(), especially for the watchdog handler.
+ * To avoid too much stack growth, a previously allocated structure can
+ * be reused via IPMI_INIT_DRIVER_REQUEST(), but the caller should ensure
+ * that there is adequate reply/request space in the original allocation.
+ */
+#defineIPMI_INIT_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen)  
\
+   bzero((req), sizeof(struct ipmi_request));  \
+   ipmi_init_request((req), NULL, 0, (addr), (cmd), (reqlen), (replylen))
+
+#defineIPMI_ALLOC_DRIVER_REQUEST(req, addr, cmd, reqlen, replylen) 
\
+   (req) = __builtin_alloca(sizeof(struct ipmi_request) +  \
+   (reqlen) + (replylen)); \
+   IPMI_INIT_DRIVER_REQUEST((req), (addr), (cmd), (reqlen),\
+   (replylen))
+
 #ifdef IPMB
 static int ipmi_ipmb_checksum(u_char, int);
 static int ipmi_ipmb_send_message(device_t, u_char, u_char, u_char,
@@ -180,8 +197,8 @@ ipmi_dtor(void *arg)
 */
dev-ipmi_closing = 1;
while (dev-ipmi_requests  0) {
-   msleep(dev-ipmi_requests, sc-ipmi_lock, PWAIT,
-   ipmidrain, 0);
+   msleep(dev-ipmi_requests, sc-ipmi_requests_lock,
+   PWAIT, ipmidrain, 0);
ipmi_purge_completed_requests(dev);
}
}
@@ -214,7 +231,7 @@ ipmi_ipmb_send_message(device_t dev, u_c
u_char slave_addr = 0x52;
int error;
 
-   req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+   IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
IPMI_SEND_MSG, data_len + 8, 0);
req-ir_request[0] = channel;
req-ir_request[1] = slave_addr;
@@ -230,7 +247,6 @@ ipmi_ipmb_send_message(device_t dev, u_c
 
ipmi_submit_driver_request(sc, req);
error = req-ir_error;
-   ipmi_free_request(req);
 
return (error);
 }
@@ -242,7 +258,7 @@ ipmi_handle_attn(struct ipmi_softc *sc)
int error;
 
device_printf(sc-ipmi_dev, BMC has a message\n);
-   req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0),
+   IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0),
IPMI_GET_MSG_FLAGS, 0, 1);
 
ipmi_submit_driver_request(sc, req);
@@ -256,9 +272,7 @@ ipmi_handle_attn(struct ipmi_softc *sc)
watchdog about to go off);
}
if (req-ir_reply[0]  IPMI_MSG_AVAILABLE) {
-   ipmi_free_request(req);
-
-   req = ipmi_alloc_driver_request(
+   IPMI_ALLOC_DRIVER_REQUEST(req,
IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_GET_MSG, 0,
16);
 
@@ -267,7 +281,6 @@ ipmi_handle_attn(struct ipmi_softc *sc)
}
}
error = req-ir_error;
-   ipmi_free_request(req);
 
return (error);
 }
@@ -477,15 +490,11 @@ ipmi_ioctl(struct cdev *cdev, u_long cmd
  * Request management.
  */
 
-/* Allocate a new request 

Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread John Baldwin
On Friday, March 13, 2015 02:42:13 PM Ian Lepore wrote:
 On Fri, 2015-03-13 at 14:34 -0400, John Baldwin wrote:
  On Friday, March 13, 2015 11:57:58 AM Ian Lepore wrote:
   On Fri, 2015-03-13 at 13:19 -0400, John Baldwin wrote:
On Friday, March 13, 2015 10:14:27 AM Ian Lepore wrote:
 On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
  On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
   [...]
 
 In general I'm glad I got called away to an onsite meeting yesterday 
 and
 didn't get far with these changes, because the more I think about it,
 the less satisfied I am with this expedient fix.  The other fix I
 started on, where a new SBUF_COUNTNUL flag can be set to inform the
 sbuf_finish() code that you want the terminating nul counted in the 
 data
 length just feels like a better fit for the overall automaticness of
 how the sbuf stuff works.

Hmm, I actually think that it's a bug that the terminating nul isn't 
included
when draining.  If we fixed that then I think that fixes most of these?
The places that explicitly use 'sysctl_handle_string()' with an sbuf
should probably just be using sbuf_len(sb) + 1' explicitly.  (Another
option would be to have a sysctl_handle_sbuf() that was a wrapper around
sysctl_handle_string() that included the + 1 to hide that detail if 
there is
more than one.)

   
   Some of the uses of sbuf for sysctl use sbuf_bcat() for dealing with
   binary structs, so we can't just assume that a nullterm should be added
   and included in the buffer length -- there needs to be some mechanism to
   say explicitly this is an sbuf for a sysctl string (and more generally
   this is an sbuf for a string where I want the nul byte counted as part
   of the data because that could be useful in non-sysctl contexts too,
   especially in userland).
  
  Humm, that would seem to be an abuse of the API really.  It is specifically
  designed for strings as someone else noted at the start of this thread (and
  as noted in the manpage).  If anything I'd argue that the use cases that 
  don't
  want a string should be the ones that should get a special flag in that case
  (or perhaps we should have a different little API to manage a buffer used 
  for
  a draining sysctl where the data is a binary blob instead of a string).  If
  you agree I'm happy to do some of the work (e.g. the different wrapper API).
  
 
 Given the existance of sbuf_bcpy() and sbuf_bcat() I'm not sure we can
 say using sbuf for binary data is any kind of violation; somebody just
 used the API that was provided to solve their problem.

Well, it still nul-terminates the result of those, so I think it's still
really dealing with strings.  Those can be useful for appending non
nul-terminated strings (for example using the d_namelen from a dirent).

However, I think an INCLUDENUL flag is fine.  It is a smaller change than
adding a new sysctl-drain API.

 Binary data is the exception in the sysctl case, and the idea of having
 sbuf_new_for_sysctl() assume you're setting up to handle a sysctl string
 and requiring the rare binary uses to do something different does make a
 lot of sense.  That might lead to a patch like the one below, which
 would automatically fix most of the current sysctl sbuf users, and the 2
 or 3 places that are using binary data would need to add a line:
   
sbuf_clear_flags(sbuf, SBUF_INCLUDENUL);
 
 I should mention too that the larger problem I'm trying to clean up is
 that some sysctl strings include the nul byte in the data returned to
 userland and some don't.  There are more direct callers of SYSCTL_OUT()
 that fail to add a nulterm, I have a whole separate set of fixes for
 those, but I'm becoming somewhat inclined to fix them by converting them
 to use sbuf and just make that the established idiom for returning
 dynamic strings via sysctl.

Either that or using sysctl_handle_string() when possible instead of
bare SYSCTL_OUT().

I think your patch is fine.  I agree this will be a much smaller change to
roll out. :)

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


Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread John Baldwin
On Friday, March 13, 2015 11:57:58 AM Ian Lepore wrote:
 On Fri, 2015-03-13 at 13:19 -0400, John Baldwin wrote:
  On Friday, March 13, 2015 10:14:27 AM Ian Lepore wrote:
   On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
 [...]
   
   In general I'm glad I got called away to an onsite meeting yesterday and
   didn't get far with these changes, because the more I think about it,
   the less satisfied I am with this expedient fix.  The other fix I
   started on, where a new SBUF_COUNTNUL flag can be set to inform the
   sbuf_finish() code that you want the terminating nul counted in the data
   length just feels like a better fit for the overall automaticness of
   how the sbuf stuff works.
  
  Hmm, I actually think that it's a bug that the terminating nul isn't 
  included
  when draining.  If we fixed that then I think that fixes most of these?
  The places that explicitly use 'sysctl_handle_string()' with an sbuf
  should probably just be using sbuf_len(sb) + 1' explicitly.  (Another
  option would be to have a sysctl_handle_sbuf() that was a wrapper around
  sysctl_handle_string() that included the + 1 to hide that detail if there is
  more than one.)
  
 
 Some of the uses of sbuf for sysctl use sbuf_bcat() for dealing with
 binary structs, so we can't just assume that a nullterm should be added
 and included in the buffer length -- there needs to be some mechanism to
 say explicitly this is an sbuf for a sysctl string (and more generally
 this is an sbuf for a string where I want the nul byte counted as part
 of the data because that could be useful in non-sysctl contexts too,
 especially in userland).

Humm, that would seem to be an abuse of the API really.  It is specifically
designed for strings as someone else noted at the start of this thread (and
as noted in the manpage).  If anything I'd argue that the use cases that don't
want a string should be the ones that should get a special flag in that case
(or perhaps we should have a different little API to manage a buffer used for
a draining sysctl where the data is a binary blob instead of a string).  If
you agree I'm happy to do some of the work (e.g. the different wrapper API).

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


svn commit: r279963 - in head/sys/dev: ahci ata mvs siis

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 20:08:35 2015
New Revision: 279963
URL: https://svnweb.freebsd.org/changeset/base/279963

Log:
  Fix SATA Gen3 speed constants.
  
  MFC after:1 week

Modified:
  head/sys/dev/ahci/ahci.h
  head/sys/dev/ata/ata-all.h
  head/sys/dev/mvs/mvs.h
  head/sys/dev/siis/siis.h

Modified: head/sys/dev/ahci/ahci.h
==
--- head/sys/dev/ahci/ahci.hFri Mar 13 18:42:43 2015(r279962)
+++ head/sys/dev/ahci/ahci.hFri Mar 13 20:08:35 2015(r279963)
@@ -93,7 +93,7 @@
 #define ATA_SS_SPD_NO_SPEED 0x
 #define ATA_SS_SPD_GEN1 0x0010
 #define ATA_SS_SPD_GEN2 0x0020
-#define ATA_SS_SPD_GEN3 0x0040
+#define ATA_SS_SPD_GEN3 0x0030
 
 #define ATA_SS_IPM_MASK 0x0f00
 #define ATA_SS_IPM_NO_DEVICE0x
@@ -131,7 +131,7 @@
 #define ATA_SC_SPD_NO_SPEED 0x
 #define ATA_SC_SPD_SPEED_GEN1   0x0010
 #define ATA_SC_SPD_SPEED_GEN2   0x0020
-#define ATA_SC_SPD_SPEED_GEN3   0x0040
+#define ATA_SC_SPD_SPEED_GEN3   0x0030
 
 #define ATA_SC_IPM_MASK 0x0f00
 #define ATA_SC_IPM_NONE 0x

Modified: head/sys/dev/ata/ata-all.h
==
--- head/sys/dev/ata/ata-all.h  Fri Mar 13 18:42:43 2015(r279962)
+++ head/sys/dev/ata/ata-all.h  Fri Mar 13 20:08:35 2015(r279963)
@@ -105,6 +105,7 @@
 #define ATA_SS_SPD_NO_SPEED 0x
 #define ATA_SS_SPD_GEN1 0x0010
 #define ATA_SS_SPD_GEN2 0x0020
+#define ATA_SS_SPD_GEN3 0x0030
 
 #define ATA_SS_IPM_MASK 0x0f00
 #define ATA_SS_IPM_NO_DEVICE0x
@@ -140,7 +141,7 @@
 #define ATA_SC_SPD_NO_SPEED 0x
 #define ATA_SC_SPD_SPEED_GEN1   0x0010
 #define ATA_SC_SPD_SPEED_GEN2   0x0020
-#define ATA_SC_SPD_SPEED_GEN3   0x0040
+#define ATA_SC_SPD_SPEED_GEN3   0x0030
 
 #define ATA_SC_IPM_MASK 0x0f00
 #define ATA_SC_IPM_NONE 0x

Modified: head/sys/dev/mvs/mvs.h
==
--- head/sys/dev/mvs/mvs.h  Fri Mar 13 18:42:43 2015(r279962)
+++ head/sys/dev/mvs/mvs.h  Fri Mar 13 20:08:35 2015(r279963)
@@ -263,7 +263,7 @@
 #defineSATA_SS_SPD_NO_SPEED 0x
 #defineSATA_SS_SPD_GEN1 0x0010
 #defineSATA_SS_SPD_GEN2 0x0020
-#defineSATA_SS_SPD_GEN3 0x0040
+#defineSATA_SS_SPD_GEN3 0x0030
 
 #defineSATA_SS_IPM_MASK 0x0f00
 #defineSATA_SS_IPM_NO_DEVICE0x
@@ -298,7 +298,7 @@
 #defineSATA_SC_SPD_NO_SPEED 0x
 #defineSATA_SC_SPD_SPEED_GEN1   0x0010
 #defineSATA_SC_SPD_SPEED_GEN2   0x0020
-#defineSATA_SC_SPD_SPEED_GEN3   0x0040
+#defineSATA_SC_SPD_SPEED_GEN3   0x0030
 
 #defineSATA_SC_IPM_MASK 0x0f00
 #defineSATA_SC_IPM_NONE 0x

Modified: head/sys/dev/siis/siis.h
==
--- head/sys/dev/siis/siis.hFri Mar 13 18:42:43 2015(r279962)
+++ head/sys/dev/siis/siis.hFri Mar 13 20:08:35 2015(r279963)
@@ -92,7 +92,7 @@
 #define ATA_SS_SPD_NO_SPEED 0x
 #define ATA_SS_SPD_GEN1 0x0010
 #define ATA_SS_SPD_GEN2 0x0020
-#define ATA_SS_SPD_GEN3 0x0040
+#define ATA_SS_SPD_GEN3 0x0030
 
 #define ATA_SS_IPM_MASK 0x0f00
 #define ATA_SS_IPM_NO_DEVICE0x
@@ -128,7 +128,7 @@
 #define ATA_SC_SPD_NO_SPEED 0x
 #define ATA_SC_SPD_SPEED_GEN1   0x0010
 #define ATA_SC_SPD_SPEED_GEN2   0x0020
-#define ATA_SC_SPD_SPEED_GEN3   0x0040
+#define ATA_SC_SPD_SPEED_GEN3   0x0030
 
 #define ATA_SC_IPM_MASK 0x0f00
 #define ATA_SC_IPM_NONE 0x
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread Ian Lepore
On Fri, 2015-03-13 at 14:34 -0400, John Baldwin wrote:
 On Friday, March 13, 2015 11:57:58 AM Ian Lepore wrote:
  On Fri, 2015-03-13 at 13:19 -0400, John Baldwin wrote:
   On Friday, March 13, 2015 10:14:27 AM Ian Lepore wrote:
On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
 On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
  [...]

In general I'm glad I got called away to an onsite meeting yesterday and
didn't get far with these changes, because the more I think about it,
the less satisfied I am with this expedient fix.  The other fix I
started on, where a new SBUF_COUNTNUL flag can be set to inform the
sbuf_finish() code that you want the terminating nul counted in the data
length just feels like a better fit for the overall automaticness of
how the sbuf stuff works.
   
   Hmm, I actually think that it's a bug that the terminating nul isn't 
   included
   when draining.  If we fixed that then I think that fixes most of these?
   The places that explicitly use 'sysctl_handle_string()' with an sbuf
   should probably just be using sbuf_len(sb) + 1' explicitly.  (Another
   option would be to have a sysctl_handle_sbuf() that was a wrapper around
   sysctl_handle_string() that included the + 1 to hide that detail if there 
   is
   more than one.)
   
  
  Some of the uses of sbuf for sysctl use sbuf_bcat() for dealing with
  binary structs, so we can't just assume that a nullterm should be added
  and included in the buffer length -- there needs to be some mechanism to
  say explicitly this is an sbuf for a sysctl string (and more generally
  this is an sbuf for a string where I want the nul byte counted as part
  of the data because that could be useful in non-sysctl contexts too,
  especially in userland).
 
 Humm, that would seem to be an abuse of the API really.  It is specifically
 designed for strings as someone else noted at the start of this thread (and
 as noted in the manpage).  If anything I'd argue that the use cases that don't
 want a string should be the ones that should get a special flag in that case
 (or perhaps we should have a different little API to manage a buffer used for
 a draining sysctl where the data is a binary blob instead of a string).  If
 you agree I'm happy to do some of the work (e.g. the different wrapper API).
 

Given the existance of sbuf_bcpy() and sbuf_bcat() I'm not sure we can
say using sbuf for binary data is any kind of violation; somebody just
used the API that was provided to solve their problem.

Binary data is the exception in the sysctl case, and the idea of having
sbuf_new_for_sysctl() assume you're setting up to handle a sysctl string
and requiring the rare binary uses to do something different does make a
lot of sense.  That might lead to a patch like the one below, which
would automatically fix most of the current sysctl sbuf users, and the 2
or 3 places that are using binary data would need to add a line:
  
   sbuf_clear_flags(sbuf, SBUF_INCLUDENUL);

I should mention too that the larger problem I'm trying to clean up is
that some sysctl strings include the nul byte in the data returned to
userland and some don't.  There are more direct callers of SYSCTL_OUT()
that fail to add a nulterm, I have a whole separate set of fixes for
those, but I'm becoming somewhat inclined to fix them by converting them
to use sbuf and just make that the established idiom for returning
dynamic strings via sysctl.

-- Ian
Index: sys/kern/kern_sysctl.c
===
--- sys/kern/kern_sysctl.c	(revision 279962)
+++ sys/kern/kern_sysctl.c	(working copy)
@@ -1807,7 +1807,7 @@ sbuf_new_for_sysctl(struct sbuf *s, char *buf, int
 struct sysctl_req *req)
 {
 
-	s = sbuf_new(s, buf, length, SBUF_FIXEDLEN);
+	s = sbuf_new(s, buf, length, SBUF_FIXEDLEN | SBUF_INCLUDENUL);
 	sbuf_set_drain(s, sbuf_sysctl_drain, req);
 	return (s);
 }
Index: sys/kern/subr_sbuf.c
===
--- sys/kern/subr_sbuf.c	(revision 279962)
+++ sys/kern/subr_sbuf.c	(working copy)
@@ -262,6 +262,28 @@ sbuf_uionew(struct sbuf *s, struct uio *uio, int *
 }
 #endif
 
+int
+sbuf_get_flags(struct sbuf *s)
+{
+
+	return (s-s_flags);
+}
+
+void
+sbuf_clear_flags(struct sbuf *s, int flags)
+{
+
+	s-s_flags = ~(flags  SBUF_USRFLAGMSK);
+}
+
+void
+sbuf_set_flags(struct sbuf *s, int flags)
+{
+
+
+	s-s_flags |= (flags  SBUF_USRFLAGMSK);
+}
+
 /*
  * Clear an sbuf and reset its position.
  */
@@ -697,11 +719,13 @@ sbuf_finish(struct sbuf *s)
 	assert_sbuf_integrity(s);
 	assert_sbuf_state(s, 0);
 
+	s-s_buf[s-s_len] = '\0';
+	if (s-s_flags  SBUF_INCLUDENUL)
+		s-s_len++;
 	if (s-s_drain_func != NULL) {
 		while (s-s_len  0  s-s_error == 0)
 			s-s_error = sbuf_drain(s);
 	}
-	s-s_buf[s-s_len] = '\0';
 	SBUF_SETFLAG(s, SBUF_FINISHED);
 #ifdef _KERNEL
 	return (s-s_error);
@@ -743,6 +767,10 @@ sbuf_len(struct sbuf *s)
 
 	if (s-s_error != 0)
 		return 

svn commit: r279966 - head/contrib/libxo/libxo

2015-03-13 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Mar 13 20:14:55 2015
New Revision: 279966
URL: https://svnweb.freebsd.org/changeset/base/279966

Log:
  Mark xo_err(3), xo_errx(3), and xo_errc(3) as __dead2.
  
  Differential Revision:https://reviews.freebsd.org/D2059
  Reviewed by:  marcel@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/libxo/libxo/xo.h

Modified: head/contrib/libxo/libxo/xo.h
==
--- head/contrib/libxo/libxo/xo.h   Fri Mar 13 20:14:35 2015
(r279965)
+++ head/contrib/libxo/libxo/xo.h   Fri Mar 13 20:14:55 2015
(r279966)
@@ -272,13 +272,13 @@ void
 xo_warnx (const char *fmt, ...);
 
 void
-xo_err (int eval, const char *fmt, ...);
+xo_err (int eval, const char *fmt, ...) __dead2;
 
 void
-xo_errx (int eval, const char *fmt, ...);
+xo_errx (int eval, const char *fmt, ...) __dead2;
 
 void
-xo_errc (int eval, int code, const char *fmt, ...);
+xo_errc (int eval, int code, const char *fmt, ...) __dead2;
 
 void
 xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279965 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 20:14:35 2015
New Revision: 279965
URL: https://svnweb.freebsd.org/changeset/base/279965

Log:
  Polish AHCI disk identify data and fix speed negotiation.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bhyve/ahci.h
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/ahci.h
==
--- head/usr.sbin/bhyve/ahci.h  Fri Mar 13 20:10:09 2015(r279964)
+++ head/usr.sbin/bhyve/ahci.h  Fri Mar 13 20:14:35 2015(r279965)
@@ -96,13 +96,14 @@
 #define ATA_SS_SPD_NO_SPEED 0x
 #define ATA_SS_SPD_GEN1 0x0010
 #define ATA_SS_SPD_GEN2 0x0020
-#define ATA_SS_SPD_GEN3 0x0040
+#define ATA_SS_SPD_GEN3 0x0030
 
 #define ATA_SS_IPM_MASK 0x0f00
 #define ATA_SS_IPM_NO_DEVICE0x
 #define ATA_SS_IPM_ACTIVE   0x0100
 #define ATA_SS_IPM_PARTIAL  0x0200
 #define ATA_SS_IPM_SLUMBER  0x0600
+#define ATA_SS_IPM_DEVSLEEP 0x0800
 
 #define ATA_SERROR  14
 #define ATA_SE_DATA_CORRECTED   0x0001
@@ -133,17 +134,19 @@
 #define ATA_SC_SPD_NO_SPEED 0x
 #define ATA_SC_SPD_SPEED_GEN1   0x0010
 #define ATA_SC_SPD_SPEED_GEN2   0x0020
-#define ATA_SC_SPD_SPEED_GEN3   0x0040
+#define ATA_SC_SPD_SPEED_GEN3   0x0030
 
 #define ATA_SC_IPM_MASK 0x0f00
 #define ATA_SC_IPM_NONE 0x
 #define ATA_SC_IPM_DIS_PARTIAL  0x0100
 #define ATA_SC_IPM_DIS_SLUMBER  0x0200
+#define ATA_SC_IPM_DIS_DEVSLEEP 0x0400
 
 #define ATA_SACTIVE 16
 
 #define AHCI_MAX_PORTS 32
 #define AHCI_MAX_SLOTS 32
+#define AHCI_MAX_IRQS  16
 
 /* SATA AHCI v1.0 register defines */
 #define AHCI_CAP0x00
@@ -208,6 +211,9 @@
 #defineAHCI_CAP2_BOH   0x0001
 #defineAHCI_CAP2_NVMP  0x0002
 #defineAHCI_CAP2_APST  0x0004
+#defineAHCI_CAP2_SDS   0x0008
+#defineAHCI_CAP2_SADM  0x0010
+#defineAHCI_CAP2_DESO  0x0020
 
 #define AHCI_OFFSET 0x100
 #define AHCI_STEP   0x80
@@ -265,6 +271,7 @@
 #define AHCI_P_CMD_ACTIVE   0x1000
 #define AHCI_P_CMD_PARTIAL  0x2000
 #define AHCI_P_CMD_SLUMBER  0x6000
+#define AHCI_P_CMD_DEVSLEEP 0x8000
 
 #define AHCI_P_TFD  0x20
 #define AHCI_P_SIG  0x24
@@ -284,6 +291,17 @@
 #defineAHCI_P_FBS_ADO_SHIFT 12
 #defineAHCI_P_FBS_DWE  0x000f
 #defineAHCI_P_FBS_DWE_SHIFT 16
+#define AHCI_P_DEVSLP   0x44
+#defineAHCI_P_DEVSLP_ADSE  0x0001
+#defineAHCI_P_DEVSLP_DSP   0x0002
+#defineAHCI_P_DEVSLP_DETO  0x03fc
+#defineAHCI_P_DEVSLP_DETO_SHIFT 2
+#defineAHCI_P_DEVSLP_MDAT  0x7c00
+#defineAHCI_P_DEVSLP_MDAT_SHIFT 10
+#defineAHCI_P_DEVSLP_DITO  0x01ff8000
+#defineAHCI_P_DEVSLP_DITO_SHIFT 15
+#defineAHCI_P_DEVSLP_DM0x0e00
+#defineAHCI_P_DEVSLP_DM_SHIFT 25
 
 /* Just to be sure, if building as module. */
 #if MAXPHYS  512 * 1024

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 20:10:09 2015
(r279964)
+++ head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 20:14:35 2015
(r279965)
@@ -431,7 +431,6 @@ ahci_port_stop(struct ahci_port *p)
 static void
 ahci_port_reset(struct ahci_port *pr)
 {
-   pr-sctl = 0;
pr-serr = 0;
pr-sact = 0;
pr-xfermode = ATA_UDMA6;
@@ -443,8 +442,11 @@ ahci_port_reset(struct ahci_port *pr)
pr-tfd = 0x7F;
return;
}
-   pr-ssts = ATA_SS_DET_PHY_ONLINE | ATA_SS_SPD_GEN2 |
-   ATA_SS_IPM_ACTIVE;
+   pr-ssts = ATA_SS_DET_PHY_ONLINE | ATA_SS_IPM_ACTIVE;
+   if (pr-sctl  ATA_SC_SPD_MASK)
+   pr-ssts |= (pr-sctl  ATA_SC_SPD_MASK);
+   else
+   pr-ssts |= ATA_SS_SPD_GEN3;
pr-tfd = (1  8) | ATA_S_DSC | ATA_S_DMA;
if (!pr-atapi) {
pr-sig = PxSIG_ATA;
@@ -470,6 +472,7 @@ ahci_reset(struct pci_ahci_softc *sc)
for (i = 0; i  sc-ports; i++) {
sc-port[i].ie = 0;
sc-port[i].is = 0;
+   sc-port[i].sctl = 0;
ahci_port_reset(sc-port[i]);
}
 }
@@ -807,26 +810,36 @@ handle_identify(struct ahci_port *p, int
buf[53] = (1  1 | 1  2);
if (p-mult_sectors)
buf[59] = (0x100 | p-mult_sectors);
-   buf[60] = 

svn commit: r279968 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 21:01:25 2015
New Revision: 279968
URL: https://svnweb.freebsd.org/changeset/base/279968

Log:
  Remove incorrect SERR register setting.
  
  At this point we have nothing to report through that register.
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/pci_ahci.c
==
--- head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 20:56:17 2015
(r279967)
+++ head/usr.sbin/bhyve/pci_ahci.c  Fri Mar 13 21:01:25 2015
(r279968)
@@ -1682,8 +1682,6 @@ ata_ioreq_cb(struct blockif_req *br, int
tfd = ATA_S_READY | ATA_S_DSC;
} else {
tfd = (ATA_E_ABORT  8) | ATA_S_READY | ATA_S_ERROR;
-   if (ncq)
-   p-serr |= (1  slot);
}
 
if (ncq) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279965 - head/usr.sbin/bhyve

2015-03-13 Thread John Baldwin
On Friday, March 13, 2015 08:14:35 PM Alexander Motin wrote:
 Author: mav
 Date: Fri Mar 13 20:14:35 2015
 New Revision: 279965
 URL: https://svnweb.freebsd.org/changeset/base/279965
 
 Log:
   Polish AHCI disk identify data and fix speed negotiation.
   
   MFC after:  2 weeks
 
 Modified:
   head/usr.sbin/bhyve/ahci.h
   head/usr.sbin/bhyve/pci_ahci.c
 
 Modified: head/usr.sbin/bhyve/ahci.h
 ==
 --- head/usr.sbin/bhyve/ahci.hFri Mar 13 20:10:09 2015
 (r279964)
 +++ head/usr.sbin/bhyve/ahci.hFri Mar 13 20:14:35 2015
 (r279965)
 @@ -96,13 +96,14 @@
  #define ATA_SS_SPD_NO_SPEED 0x
  #define ATA_SS_SPD_GEN1 0x0010
  #define ATA_SS_SPD_GEN2 0x0020
 -#define ATA_SS_SPD_GEN3 0x0040
 +#define ATA_SS_SPD_GEN3 0x0030
  
  #define ATA_SS_IPM_MASK 0x0f00
  #define ATA_SS_IPM_NO_DEVICE0x
  #define ATA_SS_IPM_ACTIVE   0x0100
  #define ATA_SS_IPM_PARTIAL  0x0200
  #define ATA_SS_IPM_SLUMBER  0x0600
 +#define ATA_SS_IPM_DEVSLEEP 0x0800

I wonder if it would make sense to have a shared header for these constants 
(given that
it seems they are copied in 4 other places for in-kernel drivers)?

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


svn commit: r279971 - in head/sys: amd64/amd64 amd64/include amd64/vmm amd64/vmm/intel amd64/vmm/io modules/vmm

2015-03-13 Thread Neel Natu
Author: neel
Date: Sat Mar 14 02:32:08 2015
New Revision: 279971
URL: https://svnweb.freebsd.org/changeset/base/279971

Log:
  Use lapic_ipi_alloc() to dynamically allocate IPI slots needed by bhyve when
  vmm.ko is loaded.
  
  Also relocate the 'justreturn' IPI handler to be alongside all other handlers.
  
  Requested by: kib

Deleted:
  head/sys/amd64/vmm/vmm_ipi.c
  head/sys/amd64/vmm/vmm_ipi.h
  head/sys/amd64/vmm/vmm_support.S
Modified:
  head/sys/amd64/amd64/apic_vector.S
  head/sys/amd64/include/smp.h
  head/sys/amd64/vmm/intel/ept.c
  head/sys/amd64/vmm/intel/vmx.c
  head/sys/amd64/vmm/io/vlapic.c
  head/sys/amd64/vmm/vmm.c
  head/sys/amd64/vmm/vmm_lapic.c
  head/sys/modules/vmm/Makefile

Modified: head/sys/amd64/amd64/apic_vector.S
==
--- head/sys/amd64/amd64/apic_vector.S  Sat Mar 14 00:30:41 2015
(r279970)
+++ head/sys/amd64/amd64/apic_vector.S  Sat Mar 14 02:32:08 2015
(r279971)
@@ -301,4 +301,35 @@ IDTVEC(rendezvous)
callsmp_rendezvous_action
callas_lapic_eoi
jmp doreti
+
+/*
+ * IPI handler whose purpose is to interrupt the CPU with minimum overhead.
+ * This is used by bhyve to force a host cpu executing in guest context to
+ * trap into the hypervisor.
+ *
+ * This handler is different from other IPI handlers in the following aspects:
+ *
+ * 1. It doesn't push a trapframe on the stack.
+ *
+ * This implies that a DDB backtrace involving 'justreturn' will skip the
+ * function that was interrupted by this handler.
+ *
+ * 2. It doesn't 'swapgs' when userspace is interrupted.
+ *
+ * The 'justreturn' handler does not access any pcpu data so it is not an
+ * issue. Moreover the 'justreturn' handler can only be interrupted by an NMI
+ * whose handler already doesn't trust GS.base when kernel code is interrupted.
+ */
+   .text
+   SUPERALIGN_TEXT
+IDTVEC(justreturn)
+   pushq   %rax
+   pushq   %rcx
+   pushq   %rdx
+   callas_lapic_eoi
+   popq%rdx
+   popq%rcx
+   popq%rax
+   jmp doreti_iret
+
 #endif /* SMP */

Modified: head/sys/amd64/include/smp.h
==
--- head/sys/amd64/include/smp.hSat Mar 14 00:30:41 2015
(r279970)
+++ head/sys/amd64/include/smp.hSat Mar 14 02:32:08 2015
(r279971)
@@ -54,6 +54,7 @@ inthand_t
IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */ 
IDTVEC(cpustop),/* CPU stops  waits to be restarted */
IDTVEC(cpususpend), /* CPU suspends  waits to be resumed */
+   IDTVEC(justreturn), /* interrupt CPU with minimum overhead */
IDTVEC(rendezvous); /* handle CPU rendezvous */
 
 struct pmap;

Modified: head/sys/amd64/vmm/intel/ept.c
==
--- head/sys/amd64/vmm/intel/ept.c  Sat Mar 14 00:30:41 2015
(r279970)
+++ head/sys/amd64/vmm/intel/ept.c  Sat Mar 14 02:32:08 2015
(r279971)
@@ -43,7 +43,6 @@ __FBSDID($FreeBSD$);
 #include machine/vmm.h
 
 #include vmx_cpufunc.h
-#include vmm_ipi.h
 #include ept.h
 
 #defineEPT_SUPPORTS_EXEC_ONLY(cap) ((cap)  (1UL  0))

Modified: head/sys/amd64/vmm/intel/vmx.c
==
--- head/sys/amd64/vmm/intel/vmx.c  Sat Mar 14 00:30:41 2015
(r279970)
+++ head/sys/amd64/vmm/intel/vmx.c  Sat Mar 14 02:32:08 2015
(r279971)
@@ -55,7 +55,6 @@ __FBSDID($FreeBSD$);
 #include vmm_lapic.h
 #include vmm_host.h
 #include vmm_ioport.h
-#include vmm_ipi.h
 #include vmm_ktr.h
 #include vmm_stat.h
 #include vatpic.h
@@ -175,7 +174,7 @@ static int posted_interrupts;
 SYSCTL_INT(_hw_vmm_vmx_cap, OID_AUTO, posted_interrupts, CTLFLAG_RD,
 posted_interrupts, 0, APICv posted interrupt support);
 
-static int pirvec;
+static int pirvec = -1;
 SYSCTL_INT(_hw_vmm_vmx, OID_AUTO, posted_interrupt_vector, CTLFLAG_RD,
 pirvec, 0, APICv posted interrupt vector);
 
@@ -485,8 +484,8 @@ static int
 vmx_cleanup(void)
 {

-   if (pirvec != 0)
-   vmm_ipi_free(pirvec);
+   if (pirvec = 0)
+   lapic_ipi_free(pirvec);
 
if (vpid_unr != NULL) {
delete_unrhdr(vpid_unr);
@@ -694,8 +693,8 @@ vmx_init(int ipinum)
MSR_VMX_TRUE_PINBASED_CTLS, PINBASED_POSTED_INTERRUPT, 0,
tmp);
if (error == 0) {
-   pirvec = vmm_ipi_alloc();
-   if (pirvec == 0) {
+   pirvec = lapic_ipi_alloc(IDTVEC(justreturn));
+   if (pirvec  0) {
if (bootverbose) {
printf(vmx_init: unable to allocate 
posted interrupt vector\n);

Modified: 

Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Bruce Evans

On Fri, 13 Mar 2015, Konstantin Belousov wrote:


On Fri, Mar 13, 2015 at 10:45:46AM -0700, Nathan Whitehorn wrote:

We'll need to hack the compiler in this case, since it assumes setjmp()
saves and restores the vector registers. I'm really not sure which
option is worse.


Changing the compiler is arguably much worse than breaking ABI of the
tier 2 platform, indeed.  We must maintain the situation where the stock
build of the compilers work out of box.

Still, how the compiler' assumptions are laid out ?  It could be argued
that compilers on x86 also assume that FPU register file is restored by
longjmp.


That would be a compiler bug.


%st* and %xmm* are defined as not preserved across function
calls, but I suspect that practical rule for setjmp() is that floating
vars better not be used in the target frame.


Indeed.  They are not call-saved for ordinary functions, and it would be
stupid for the compiler to treat setjmp() differently, since setjmp()
wants to clobber the registers even more than an ordinary functions.


Hm, indeed f14-f31 and v20-v31 are marked as non-volatile for 64bit ABI.


Powerpc has zillions of call-saved registers (I know little about powerpc,
but checked this in its gcc .md file).

There are complications for the FP environment.  setjmp() is specified
to save its environoment and longjmp() is specified to restore the
environment saved by setjmp().  Environments seem to be under-specified.
Floating point has an state that is actually called an environment, but
is this part of the execution environment?  Anyway, it is clear that
most call-saved parts of the FP environment should be saved and restored
(so that longjmp from signal handlers has a chance of working), but the
exception flags should not be restored (since restoring them would forget
exceptions).  x86 setjmp/longjump attempts to do this, but is still very
buggy:

- i386 _setjmp saves the i387 control word but not not the SSE control
  word (if any).  This is the setjmp that doesn't save the signal mask.
- i386 ___longjmp cannot restore the SSE control word since it was not
  saved.  (_longjmp is a weak alias for ___longjmp.  I don't know why
  _longjmp needs aliasing but _setjmp doesn't.  Similarly for the other
  5 *setjmp/*longjmp pairs in x86.)
- to preserve (that is, _not_ restore) the exception flags, someone
  removed the fninit that I wrote in all the i386 longjmps.  This broke:
  - cleaning up of the state.  Especially the tag word.  Cleaning is
needed for at least longjmp() from FreeBSD-[1-4]-compat signal
handlers which can be entered with any FP state
  - avoiding getting an exception when reloading the FP control word.
  The correct change is something like:
fnstsw %ax
fninit
fstenv tmp(%esp)
# set the pending-exception bit in %ax if there are any unmasked
#   exceptions for the _new_ cw, else clear it
# store %ax in tmp env
# copy saved cw from jmp_buf to tmp env
fldenv tmp(%esp)
# do related stuff for SSE (simpler)
  The trip through the tmp env is needed since there is no instruction
  to load the new status word from a registers; anyway, it would be
  difficult to load the cw and status word separately without risking a
  trap for one (fninit only cleans enough for the next instruction).
- i386 setjmp and __longjmp are identically broken.
- i386 sigsetjmp and __siglongjmp are not even identically broken.  They
  used to be almost identical copies of setjmp and __longjmp (sigsetjmp
  == setjmp in BSD).  They shouldn't exist except as strong aliases,
  but still do despite extensive use of weak aliases and namespace
  messes like the triply underscored ___longjmp.  No one removed the
  fninit's from them.  So they are missing most of the above bugs,
  but the exception flags are not preserved as intended.

- amd64 _setjmp, setjmp, and sigsetjmp are OK, except for the existence
  of sigsetjmp as a non-alias.  They do preserve mxcsr.  The bug of the
  existence of the file containing sigsetjmp was copied perfectly from
  i386, including my comments in it saying why it should not exist.
- amd64 ___longjmp does preserve SSE exceptions.  This requires merging
  the current exceptions with the saved control word in mxcsr.  SSE
  exceptions are synchronous, and ldmxcsr cannot trap, so I think it
  is not necessary to adjust the pending-exception flag (or there is no
  such flag in mxcsr).  amd64 _longjmp then has the same bugs as i386
  _longjmp restoring the i387 cw, tag word and pending-exception flag
  without trapping.
- amd64 __longjmp is like amd64 ___longjmp.
- amd64 __siglongjmp is not even like amd64 ___longjmp.  No one removed
  the fninit there either.

These details are of course arcane and rarely matter.  I tested the old
versions using longjmp from signal handlers.  FreeBSD-[1-4] signal handlers
get the interrupted FP context.  One interesting case is when the compiler
temporarily changes the rounding mode.  This may be interrupted by even a
non-FP related 

svn commit: r279969 - head/sys/dev/cxgbe

2015-03-13 Thread Navdeep Parhar
Author: np
Date: Sat Mar 14 00:02:53 2015
New Revision: 279969
URL: https://svnweb.freebsd.org/changeset/base/279969

Log:
  cxgbe(4):  fix if_media handling for T520-BT cards.  1Gbps and 100Mbps
  are valid for this card.
  
  MFC after:1 week

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cFri Mar 13 21:01:25 2015
(r279968)
+++ head/sys/dev/cxgbe/t4_main.cSat Mar 14 00:02:53 2015
(r279969)
@@ -2895,9 +2895,6 @@ build_medialist(struct port_info *pi, st
 
switch(pi-port_type) {
case FW_PORT_TYPE_BT_XFI:
-   ifmedia_add(media, m | IFM_10G_T, data, NULL);
-   break;
-
case FW_PORT_TYPE_BT_XAUI:
ifmedia_add(media, m | IFM_10G_T, data, NULL);
/* fall through */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279970 - in head/sys/x86: include x86 xen

2015-03-13 Thread Neel Natu
Author: neel
Date: Sat Mar 14 00:30:41 2015
New Revision: 279970
URL: https://svnweb.freebsd.org/changeset/base/279970

Log:
  Add x86 specific APIs 'lapic_ipi_alloc()' and 'lapic_ipi_free()' to allow IPI
  vectors to be dynamically allocated. This allows kernel modules like vmm.ko
  to allocate unique IPI slots when loaded (as opposed to hard allocating one
  or more vectors).
  
  Also, reorganize the fixed IPI vectors to create a contiguous space for
  dynamic IPI allocation.
  
  Reviewed by:  kib, jhb
  Differential Revision:https://reviews.freebsd.org/D2042

Modified:
  head/sys/x86/include/apicvar.h
  head/sys/x86/x86/local_apic.c
  head/sys/x86/xen/xen_apic.c

Modified: head/sys/x86/include/apicvar.h
==
--- head/sys/x86/include/apicvar.h  Sat Mar 14 00:02:53 2015
(r279969)
+++ head/sys/x86/include/apicvar.h  Sat Mar 14 00:30:41 2015
(r279970)
@@ -111,11 +111,8 @@
 #defineIPI_INVLPG  (APIC_IPI_INTS + 2)
 #defineIPI_INVLRNG (APIC_IPI_INTS + 3)
 #defineIPI_INVLCACHE   (APIC_IPI_INTS + 4)
-#ifdef __i386__
-#defineIPI_LAZYPMAP(APIC_IPI_INTS + 5) /* Lazy pmap release. */
-#endif
 /* Vector to handle bitmap based IPIs */
-#defineIPI_BITMAP_VECTOR   (APIC_IPI_INTS + 6) 
+#defineIPI_BITMAP_VECTOR   (APIC_IPI_INTS + 5) 
 
 /* IPIs handled by IPI_BITMAP_VECTOR */
 #defineIPI_AST 0   /* Generate software trap. */
@@ -124,8 +121,15 @@
 #define IPI_BITMAP_LAST IPI_HARDCLOCK
 #define IPI_IS_BITMAPED(x) ((x) = IPI_BITMAP_LAST)
 
-#defineIPI_STOP(APIC_IPI_INTS + 7) /* Stop CPU until 
restarted. */
-#defineIPI_SUSPEND (APIC_IPI_INTS + 8) /* Suspend CPU until 
restarted. */
+#defineIPI_STOP(APIC_IPI_INTS + 6) /* Stop CPU until 
restarted. */
+#defineIPI_SUSPEND (APIC_IPI_INTS + 7) /* Suspend CPU until 
restarted. */
+#ifdef __i386__
+#defineIPI_LAZYPMAP(APIC_IPI_INTS + 8) /* Lazy pmap release. */
+#defineIPI_DYN_FIRST   (APIC_IPI_INTS + 9)
+#else
+#defineIPI_DYN_FIRST   (APIC_IPI_INTS + 8)
+#endif
+#defineIPI_DYN_LAST(254)   /* IPIs allocated at 
runtime */
 
 /*
  * IPI_STOP_HARD does not need to occupy a slot in the IPI vector space since
@@ -224,6 +228,8 @@ struct apic_ops {
void(*ipi_raw)(register_t, u_int);
void(*ipi_vectored)(u_int, int);
int (*ipi_wait)(int);
+   int (*ipi_alloc)(inthand_t *ipifunc);
+   void(*ipi_free)(int vector);
 
/* LVT */
int (*set_lvt_mask)(u_int, u_int, u_char);
@@ -397,6 +403,20 @@ lapic_ipi_wait(int delay)
 }
 
 static inline int
+lapic_ipi_alloc(inthand_t *ipifunc)
+{
+
+   return (apic_ops.ipi_alloc(ipifunc));
+}
+
+static inline void
+lapic_ipi_free(int vector)
+{
+
+   return (apic_ops.ipi_free(vector));
+}
+
+static inline int
 lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked)
 {
 

Modified: head/sys/x86/x86/local_apic.c
==
--- head/sys/x86/x86/local_apic.c   Sat Mar 14 00:02:53 2015
(r279969)
+++ head/sys/x86/x86/local_apic.c   Sat Mar 14 00:30:41 2015
(r279970)
@@ -303,6 +303,8 @@ static int  native_lapic_set_lvt_polarit
enum intr_polarity pol);
 static int native_lapic_set_lvt_triggermode(u_int apic_id, u_int lvt,
enum intr_trigger trigger);
+static int native_lapic_ipi_alloc(inthand_t *ipifunc);
+static voidnative_lapic_ipi_free(int vector);
 
 struct apic_ops apic_ops = {
.create = native_lapic_create,
@@ -329,6 +331,8 @@ struct apic_ops apic_ops = {
.ipi_raw= native_lapic_ipi_raw,
.ipi_vectored   = native_lapic_ipi_vectored,
.ipi_wait   = native_lapic_ipi_wait,
+   .ipi_alloc  = native_lapic_ipi_alloc,
+   .ipi_free   = native_lapic_ipi_free,
 #endif
.set_lvt_mask   = native_lapic_set_lvt_mask,
.set_lvt_mode   = native_lapic_set_lvt_mode,
@@ -1761,4 +1765,60 @@ native_lapic_ipi_vectored(u_int vector, 
}
 #endif /* DETECT_DEADLOCK */
 }
+
+/*
+ * Since the IDT is shared by all CPUs the IPI slot update needs to be globally
+ * visible.
+ *
+ * Consider the case where an IPI is generated immediately after allocation:
+ * vector = lapic_ipi_alloc(ipifunc);
+ * ipi_selected(other_cpus, vector);
+ *
+ * In xAPIC mode a write to ICR_LO has serializing semantics because the
+ * APIC page is mapped as an uncached region. In x2APIC mode there is an
+ * explicit 'mfence' before the ICR MSR is written. Therefore in both cases
+ * the IDT slot update is globally visible before the IPI is delivered.
+ */
+static int
+native_lapic_ipi_alloc(inthand_t *ipifunc)

svn commit: r279947 - in head/share/doc: psd/title smm/title usd/title

2015-03-13 Thread Ed Maste
Author: emaste
Date: Fri Mar 13 07:29:49 2015
New Revision: 279947
URL: https://svnweb.freebsd.org/changeset/base/279947

Log:
  Remove UCB advertising clause per the letter dated July 22, 1999.

Modified:
  head/share/doc/psd/title/Title
  head/share/doc/smm/title/Title
  head/share/doc/usd/title/Title

Modified: head/share/doc/psd/title/Title
==
--- head/share/doc/psd/title/Title  Fri Mar 13 04:26:48 2015
(r279946)
+++ head/share/doc/psd/title/Title  Fri Mar 13 07:29:49 2015
(r279947)
@@ -9,11 +9,7 @@
 .\ 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.
-.\ 3. All advertising materials mentioning features or use of this software
-.\must display the following acknowledgement:
-.\This product includes software developed by the University of
-.\California, Berkeley and its contributors.
-.\ 4. Neither the name of the University nor the names of its contributors
+.\ 3. Neither the name of the University nor the names of its contributors
 .\may be used to endorse or promote products derived from this software
 .\without specific prior written permission.
 .\

Modified: head/share/doc/smm/title/Title
==
--- head/share/doc/smm/title/Title  Fri Mar 13 04:26:48 2015
(r279946)
+++ head/share/doc/smm/title/Title  Fri Mar 13 07:29:49 2015
(r279947)
@@ -9,11 +9,7 @@
 .\ 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.
-.\ 3. All advertising materials mentioning features or use of this software
-.\must display the following acknowledgement:
-.\This product includes software developed by the University of
-.\California, Berkeley and its contributors.
-.\ 4. Neither the name of the University nor the names of its contributors
+.\ 3. Neither the name of the University nor the names of its contributors
 .\may be used to endorse or promote products derived from this software
 .\without specific prior written permission.
 .\

Modified: head/share/doc/usd/title/Title
==
--- head/share/doc/usd/title/Title  Fri Mar 13 04:26:48 2015
(r279946)
+++ head/share/doc/usd/title/Title  Fri Mar 13 07:29:49 2015
(r279947)
@@ -9,11 +9,7 @@
 .\ 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.
-.\ 3. All advertising materials mentioning features or use of this software
-.\must display the following acknowledgement:
-.\This product includes software developed by the University of
-.\California, Berkeley and its contributors.
-.\ 4. Neither the name of the University nor the names of its contributors
+.\ 3. Neither the name of the University nor the names of its contributors
 .\may be used to endorse or promote products derived from this software
 .\without specific prior written permission.
 .\
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279949 - in head: lib/libstand sys/boot/amd64 sys/boot/efi/libefi sys/boot/ficl

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 09:38:16 2015
New Revision: 279949
URL: https://svnweb.freebsd.org/changeset/base/279949

Log:
  The System V ABI for amd64 allows functions to use space in a 128 byte
  redzone below the stack pointer for scratch space and requires
  interrupt and signal frames to avoid overwriting it. However, EFI uses
  the Windows ABI which does not support this. As a result, interrupt
  handlers in EFI push their interrupt frames directly on top of the
  stack pointer. If the compiler used the red zone in a function in the
  EFI loader, then a device interrupt that occurred while that function
  was running could trash its local variables.  In practice this happens
  fairly reliable when using gzipfs as an interrupt during decompression
  can trash the local variables in the inflate_table() function
  resulting in corrupted output or hangs.
  
  Fix this by disabling the redzone for amd64 EFI binaries. This
  requires building not only the loader but any libraries used by the
  loader without redzone support.
  
  Thanks to Jilles for pointing me at the redzone once I found the stack
  corruption.
  
  Differential Revision:https://reviews.freebsd.org/D2054
  Reviewed by:  imp
  MFC after:2 weeks
  Sponsored by: Cisco Systems, Inc.

Modified:
  head/lib/libstand/Makefile
  head/sys/boot/amd64/Makefile.inc
  head/sys/boot/efi/libefi/Makefile
  head/sys/boot/ficl/Makefile

Modified: head/lib/libstand/Makefile
==
--- head/lib/libstand/Makefile  Fri Mar 13 09:03:25 2015(r279948)
+++ head/lib/libstand/Makefile  Fri Mar 13 09:38:16 2015(r279949)
@@ -28,7 +28,7 @@ CFLAGS+=  -mno-mmx -mno-3dnow -mno-sse -m
 CFLAGS.gcc+=   -mpreferred-stack-boundary=2
 .endif
 .if ${MACHINE_CPUARCH} == amd64
-CFLAGS+=   -fPIC
+CFLAGS+=   -fPIC -mno-red-zone
 .endif
 .if ${MACHINE} == pc98
 CFLAGS+=   -Os

Modified: head/sys/boot/amd64/Makefile.inc
==
--- head/sys/boot/amd64/Makefile.incFri Mar 13 09:03:25 2015
(r279948)
+++ head/sys/boot/amd64/Makefile.incFri Mar 13 09:38:16 2015
(r279949)
@@ -5,7 +5,7 @@
 BINDIR?=   /boot
 
 # See conf/kern.mk for the correct set of these
-CFLAGS+=   -ffreestanding
+CFLAGS+=   -ffreestanding -mno-red-zone
 CFLAGS+=   -mno-mmx -mno-sse -mno-aes -mno-avx -msoft-float
 LDFLAGS+=  -nostdlib
 

Modified: head/sys/boot/efi/libefi/Makefile
==
--- head/sys/boot/efi/libefi/Makefile   Fri Mar 13 09:03:25 2015
(r279948)
+++ head/sys/boot/efi/libefi/Makefile   Fri Mar 13 09:38:16 2015
(r279949)
@@ -9,7 +9,7 @@ SRCS=   delay.c efi_console.c efinet.c efi
 SRCS+= nullconsole.c comconsole.c
 
 .if ${MACHINE_ARCH} == amd64
-CFLAGS+= -fPIC
+CFLAGS+= -fPIC -mno-red-zone
 .endif
 CFLAGS+= -I${.CURDIR}/../include
 CFLAGS+= -I${.CURDIR}/../include/${MACHINE_CPUARCH}

Modified: head/sys/boot/ficl/Makefile
==
--- head/sys/boot/ficl/Makefile Fri Mar 13 09:03:25 2015(r279948)
+++ head/sys/boot/ficl/Makefile Fri Mar 13 09:38:16 2015(r279949)
@@ -21,6 +21,9 @@ CFLAGS+=  -ffreestanding
 CFLAGS+=   -march=i386
 CFLAGS.gcc+=   -mpreferred-stack-boundary=2
 .endif
+.if ${MACHINE_CPUARCH} == amd64
+CFLAGS+=   -mno-red-zone
+.endif
 .if ${MACHINE_CPUARCH} == i386 || ${MACHINE_CPUARCH} == amd64
 CFLAGS+=   -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
 .endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread John Baldwin
On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
 On Thu, 2015-03-12 at 17:02 -0400, Ryan Stone wrote:
  On Thu, Mar 12, 2015 at 2:06 PM, Ian Lepore i...@freebsd.org wrote:
  
 Nullterminate strings returned via sysctl.
  
 PR:   195668
  
  
  To quote the manpage:
  
   The *sbuf* family of functions allows one to safely
   allocate, construct and release bounded null-terminated
   strings in kernel space.
  
  IMO the sbuf API is broken if we have to explicitly null-terminate the
  string ourselves.
 
 If we want the nullterm to be counted in the length of data in the
 buffer (and thus get transmitted back across the syscall boundary) we
 need to put an explicit counted nullterm byte into the buffer.
 
 I had started down the path of making that (counting the nullterm byte
 as part of the data in the buffer) a feature of sbuf that you could set
 with a flag, but then whoever added sbuf_new_for_sysctl() didn't
 propagate the flags field through the new function and I decided to not
 go off into the weeds making a new flavor of that takes flags.

One suggestion would be to consider using '\0' for a nul character instead of
a bare 0.  To me that communicates the intention more clearly to the reader.
(One of the things I did not like about C++  C++11 was the use of 0 for
NULL.  I much prefer nullptr and NULL in C over bare 0's for pointers for
similar clarity reasons.)

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


Re: svn commit: r279949 - in head: lib/libstand sys/boot/amd64 sys/boot/efi/libefi sys/boot/ficl

2015-03-13 Thread John Baldwin
On Friday, March 13, 2015 09:38:16 AM John Baldwin wrote:
 Author: jhb
 Date: Fri Mar 13 09:38:16 2015
 New Revision: 279949
 URL: https://svnweb.freebsd.org/changeset/base/279949
 
 Log:
   The System V ABI for amd64 allows functions to use space in a 128 byte
   redzone below the stack pointer for scratch space and requires
   interrupt and signal frames to avoid overwriting it. However, EFI uses
   the Windows ABI which does not support this. As a result, interrupt
   handlers in EFI push their interrupt frames directly on top of the
   stack pointer. If the compiler used the red zone in a function in the
   EFI loader, then a device interrupt that occurred while that function
   was running could trash its local variables.  In practice this happens
   fairly reliable when using gzipfs as an interrupt during decompression
   can trash the local variables in the inflate_table() function
   resulting in corrupted output or hangs.
   
   Fix this by disabling the redzone for amd64 EFI binaries. This
   requires building not only the loader but any libraries used by the
   loader without redzone support.
   
   Thanks to Jilles for pointing me at the redzone once I found the stack
   corruption.

Note that without this, gzipfs was effectively useless in the EFI loader
for any non-trivial cases (it was even useless in my trivial cases during
testing, but there might be some trivial case (zero-byte file or some
such) that can be decompressed quickly enough to not trigger a device
interrupt).

Also, while the redzone is cute and all, it seems to me that it is very
impractical for any ring 0 context.  Specifically, the CPU doesn't know
anything about it, and any interrupt or exception in ring 0 is going to
push the hardware-defined bits of the frame (%rip, etc.) on top of the
stack pointer overwriting part of the redzone.  (Our kernel is built with
-mno-red-zone as well.)  You could perhaps always use a dedicated stack
for all interrupts and faults via IST, but any nesting there would 
result in reusing a stack if you aren't careful (e.g. a fault in
interrupt context).  I suppose it might work to have one IST entry for
device interrupts, a second for most faults / exceptions, and a third for
double faults (double faults generally need a dedicated stack regardless).
Of course, all these dedicated stacks would have to be per-CPU (as the
double fault stack is) and any fault or interrupt would have to implicitly
pin the thread for the duration (probably not a big deal).

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


svn commit: r279950 - in head/sys/boot: amd64/efi efi/libefi

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 09:41:27 2015
New Revision: 279950
URL: https://svnweb.freebsd.org/changeset/base/279950

Log:
  Enable bzipfs support in the EFI loader.
  - Add bzipfs to the list of supported filesystems in the EFI loader.
  - Increase the heap size allocated for the EFI loader from 2MB to 3MB.
  
  Differential Revision:https://reviews.freebsd.org/D2053
  Reviewed by:  benno, emaste, imp
  MFC after:2 weeks
  Sponsored by: Cisco Systems, Inc.

Modified:
  head/sys/boot/amd64/efi/conf.c
  head/sys/boot/efi/libefi/libefi.c

Modified: head/sys/boot/amd64/efi/conf.c
==
--- head/sys/boot/amd64/efi/conf.c  Fri Mar 13 09:38:16 2015
(r279949)
+++ head/sys/boot/amd64/efi/conf.c  Fri Mar 13 09:41:27 2015
(r279950)
@@ -44,6 +44,7 @@ struct fs_ops *file_system[] = {
cd9660_fsops,
nfs_fsops,
gzipfs_fsops,
+   bzipfs_fsops,
NULL
 };
 

Modified: head/sys/boot/efi/libefi/libefi.c
==
--- head/sys/boot/efi/libefi/libefi.c   Fri Mar 13 09:38:16 2015
(r279949)
+++ head/sys/boot/efi/libefi/libefi.c   Fri Mar 13 09:41:27 2015
(r279950)
@@ -102,7 +102,7 @@ efi_main(EFI_HANDLE image_handle, EFI_SY
(void)console_control-SetMode(console_control,
EfiConsoleControlScreenText);
 
-   heapsize = 2 * 1024 * 1024;
+   heapsize = 3 * 1024 * 1024;
status = BS-AllocatePages(AllocateAnyPages, EfiLoaderData,
EFI_SIZE_TO_PAGES(heapsize), heap);
if (status != EFI_SUCCESS)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279948 - in head: sbin/ipfw sys/netinet sys/netpfil/ipfw

2015-03-13 Thread Andrey V. Elsukov
Author: ae
Date: Fri Mar 13 09:03:25 2015
New Revision: 279948
URL: https://svnweb.freebsd.org/changeset/base/279948

Log:
  Fix `ipfw fwd tablearg'. Use dedicated field nh4 in struct table_value
  to obtain IPv4 next hop address in tablearg case.
  
  Add `fwd tablearg' support for IPv6. ipfw(8) uses INADDR_ANY as next hop
  address in O_FORWARD_IP opcode for specifying tablearg case. For IPv6 we
  still use this opcode, but when packet identified as IPv6 packet, we
  obtain next hop address from dedicated field nh6 in struct table_value.
  
  Replace hopstore field in struct ip_fw_args with anonymous union and add
  hopstore6 field. Use this field to copy tablearg value for IPv6.
  
  Replace spare1 field in struct table_value with zoneid. Use it to keep
  scope zone id for link-local IPv6 addresses. Since spare1 was used
  internally, replace spare0 array with two variables spare0 and spare1.
  
  Use getaddrinfo(3)/getnameinfo(3) functions for parsing and formatting
  IPv6 addresses in table_value. Use zoneid field in struct table_value
  to store sin6_scope_id value.
  
  Since the kernel still uses embedded scope zone id to represent
  link-local addresses, convert next_hop6 address into this form before
  return from pfil processing. This also fixes in6_localip() check
  for link-local addresses.
  
  Differential Revision:https://reviews.freebsd.org/D2015
  Obtained from:Yandex LLC
  Sponsored by: Yandex LLC

Modified:
  head/sbin/ipfw/ipfw.8
  head/sbin/ipfw/tables.c
  head/sys/netinet/ip_fw.h
  head/sys/netpfil/ipfw/ip_fw2.c
  head/sys/netpfil/ipfw/ip_fw_pfil.c
  head/sys/netpfil/ipfw/ip_fw_private.h
  head/sys/netpfil/ipfw/ip_fw_table_value.c

Modified: head/sbin/ipfw/ipfw.8
==
--- head/sbin/ipfw/ipfw.8   Fri Mar 13 07:29:49 2015(r279947)
+++ head/sbin/ipfw/ipfw.8   Fri Mar 13 09:03:25 2015(r279948)
@@ -1,7 +1,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd Aug 13, 2014
+.Dd March 13, 2015
 .Dt IPFW 8
 .Os
 .Sh NAME
@@ -2078,6 +2078,8 @@ hook number to move packet to.
 maximum number of connections.
 .It Cm ipv4
 IPv4 nexthop to fwd packets to.
+.It Cm ipv6
+IPv6 nexthop to fwd packets to.
 .El
 .Pp
 The

Modified: head/sbin/ipfw/tables.c
==
--- head/sbin/ipfw/tables.c Fri Mar 13 07:29:49 2015(r279947)
+++ head/sbin/ipfw/tables.c Fri Mar 13 09:03:25 2015(r279948)
@@ -35,6 +35,7 @@
 #include netinet/in.h
 #include netinet/ip_fw.h
 #include arpa/inet.h
+#include netdb.h
 
 #include ipfw2.h
 
@@ -1384,6 +1385,7 @@ static void
 tentry_fill_value(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *arg,
 uint8_t type, uint32_t vmask)
 {
+   struct addrinfo hints, *res;
uint32_t a4, flag, val, vm;
ipfw_table_value *v;
uint32_t i;
@@ -1494,9 +1496,19 @@ tentry_fill_value(ipfw_obj_header *oh, i
}
break;
case IPFW_VTYPE_NH6:
-   if (strchr(n, ':') != NULL 
-   inet_pton(AF_INET6, n, v-nh6) == 1)
-   break;
+   if (strchr(n, ':') != NULL) {
+   memset(hints, 0, sizeof(hints));
+   hints.ai_family = AF_INET6;
+   hints.ai_flags = AI_NUMERICHOST;
+   if (getaddrinfo(n, NULL, hints, res) == 0) {
+   v-nh6 = ((struct sockaddr_in6 *)
+   res-ai_addr)-sin6_addr;
+   v-zoneid = ((struct sockaddr_in6 *)
+   res-ai_addr)-sin6_scope_id;
+   freeaddrinfo(res);
+   break;
+   }
+   }
etype = ipv6;
break;
}
@@ -1643,10 +1655,11 @@ static void
 table_show_value(char *buf, size_t bufsize, ipfw_table_value *v,
 uint32_t vmask, int print_ip)
 {
+   char abuf[INET6_ADDRSTRLEN + IF_NAMESIZE + 2];
+   struct sockaddr_in6 sa6;
uint32_t flag, i, l;
size_t sz;
struct in_addr a4;
-   char abuf[INET6_ADDRSTRLEN];
 
sz = bufsize;
 
@@ -1702,8 +1715,15 @@ table_show_value(char *buf, size_t bufsi
l = snprintf(buf, sz, %d,, v-dscp);
break;
case IPFW_VTYPE_NH6:
-   inet_ntop(AF_INET6, v-nh6, abuf, sizeof(abuf));
-   l = snprintf(buf, sz, %s,, abuf);
+   sa6.sin6_family = AF_INET6;
+   sa6.sin6_len = sizeof(sa6);
+   sa6.sin6_addr = v-nh6;
+   sa6.sin6_port = 0;
+   

svn commit: r279951 - head/sbin/ifconfig

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 09:45:06 2015
New Revision: 279951
URL: https://svnweb.freebsd.org/changeset/base/279951

Log:
  Simplify string mangling in ifmaybeload().
  - Use strlcpy() instead of strcpy().
  - Use strlcat() instead of a strlcpy() with a magic number subtracted
from the length.
  - Replace strncmp(..., strlen(foo) + 1) with strcmp(...).
  
  Differential Revision:https://reviews.freebsd.org/D1814
  Reviewed by:  rpaulo
  MFC after:2 weeks

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Fri Mar 13 09:41:27 2015
(r279950)
+++ head/sbin/ifconfig/ifconfig.c   Fri Mar 13 09:45:06 2015
(r279951)
@@ -1280,9 +1280,8 @@ ifmaybeload(const char *name)
}
 
/* turn interface and unit into module name */
-   strcpy(ifkind, if_);
-   strlcpy(ifkind + MOD_PREFIX_LEN, ifname,
-   sizeof(ifkind) - MOD_PREFIX_LEN);
+   strlcpy(ifkind, if_, sizeof(ifkind));
+   strlcat(ifkind, ifname, sizeof(ifkind));
 
/* scan files in kernel */
mstat.version = sizeof(struct module_stat);
@@ -1299,8 +1298,8 @@ ifmaybeload(const char *name)
cp = mstat.name;
}
/* already loaded? */
-   if (strncmp(ifname, cp, strlen(ifname) + 1) == 0 ||
-   strncmp(ifkind, cp, strlen(ifkind) + 1) == 0)
+   if (strcmp(ifname, cp) == 0 ||
+   strcmp(ifkind, cp) == 0)
return;
}
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Konstantin Belousov
On Thu, Mar 12, 2015 at 02:46:53PM -0700, Nathan Whitehorn wrote:
 
 On 03/12/15 14:35, Konstantin Belousov wrote:
  On Thu, Mar 12, 2015 at 02:29:43PM -0700, Nathan Whitehorn wrote:
  On 03/12/15 14:22, Konstantin Belousov wrote:
  On Thu, Mar 12, 2015 at 09:15:39PM +, Nathan Whitehorn wrote:
  Author: nwhitehorn
  Date: Thu Mar 12 21:15:38 2015
  New Revision: 279937
  URL: https://svnweb.freebsd.org/changeset/base/279937
 
  Log:
  Provide VSX context in ucontext(3) API.
 
  Modified:
  head/sys/powerpc/include/ucontext.h
  head/sys/powerpc/powerpc/exec_machdep.c
 
  Modified: head/sys/powerpc/include/ucontext.h
  ==
  --- head/sys/powerpc/include/ucontext.h  Thu Mar 12 20:14:48 2015
  (r279936)
  +++ head/sys/powerpc/include/ucontext.h  Thu Mar 12 21:15:38 2015
  (r279937)
  @@ -46,6 +46,7 @@ typedef struct __mcontext {
   uint32_tmc_av[2];
   register_t  mc_frame[42];
   uint64_tmc_fpreg[33];
  +uint64_tmc_vsxfpreg[32];/* low-order half of 
  VSR0-31 */
 } mcontext_t __aligned(16);
 
 #if defined(_KERNEL)  defined(__powerpc64__)
  @@ -60,6 +61,7 @@ typedef struct __mcontext32 {
   uint32_tmc_av[2];
   uint32_tmc_frame[42];
   uint64_tmc_fpreg[33];
  +uint64_tmc_vsxfpreg[32];/* low-order half of 
  VSR0-31 */
 } mcontext32_t __aligned(16);
 #endif
  It looks as if you broken the ABI compatibility by the change.  Am I 
  wrong ?
 
  That is correct. It's a tier-2 platform and -CURRENT, so I'm not sure
  it's worth the compatibility shims. I'm happy to add them if you think
  otherwise.
  You are main maintainer of PowerPC port, IMO, so it is your decision.
 
  Note that 'this is current' argument is not applicable, since the change
  also breaks stable/* binaries.
 
  I do understand the argument of PowerPC being tier 2 architecture, but this
  makes me sad.  Anyway, it is yours.  For x86, I have to introduce
  getcontextx(3) mechanism.
 
 This is a good point. I'll try to fix it. Is my understanding of how 
 this works correct?
 
 1. Provide a sysarch() for the extended FPU state.
 2. Implement getcontextx() in the C library to fill extra properties if 
 required.
 3. Store state for signal trampoline in variable-sized stack area
4. Implement __getcontextx_size() and __fillcontextx2() for use
in the deferred signal delivery while libthr is in critical section,
see lib/libthr/thread/thr_sig.c:check_deferred_signal().

 
 Implementation of (2) seems to rely on having spare members in ucontext, 
 which PowerPC unfortunately does not have. Is there a way around that?
Indeed, this is very unfortunate.

My concern is that typical application allocating ucontext_t on stack or
by mallocing it, would get silent memory corruption after the extension
of mcontext_t.  It seems indeed that ABI breakage cannot be completely
avoided, but it could be significantly reduced IMO.  Is it true that
mc_avec is only valid when _MC_AV_VALID bit is set ?

If yes, we can introduce another mcontext flag, say _MC_XSTATE_VALID,
which is mutually exclusive with the _MC_AC_VALID. The new flag
indicates that there is external data, and the data is pointed to by
some word placed in the previous mc_avec file, say mc_avec[0]. The
altivec registers file content is moved into that external data area as
well. Providing the external area size in mc_avec[1] allows to extend
that block in the future-compatible manner.

This way, applications which use ucontext_t and which are not aware about
VSX, get the expected behaviour, possibly without seeing altivec.  I.e.
in typical case, we do not get random memory corruption.

Meantime, I have a question. I looked at the powerpc/include/ucontex.h
and tried to match it with the PowerISA specs 2.06 and 2.07. From what I
understand, mc_fpreg corresponds to the floating-point registers file,
mc_avec and mc_av to the 'Vector Facility Registers'.  But I fail to see
what would match the 
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
file. The 7.2.1 Vector-Scalar Registers says 'Sixty-four 128-bit VSRs
are provided'.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279952 - in head: etc/defaults share/man/man5

2015-03-13 Thread John Baldwin
Author: jhb
Date: Fri Mar 13 09:50:29 2015
New Revision: 279952
URL: https://svnweb.freebsd.org/changeset/base/279952

Log:
  - Align comment for df flags variable in periodic.conf.
  - Note default value of df flags variable in periodoc.conf(5).
  
  MFC after:1 week

Modified:
  head/etc/defaults/periodic.conf
  head/share/man/man5/periodic.conf.5

Modified: head/etc/defaults/periodic.conf
==
--- head/etc/defaults/periodic.conf Fri Mar 13 09:45:06 2015
(r279951)
+++ head/etc/defaults/periodic.conf Fri Mar 13 09:50:29 2015
(r279952)
@@ -89,7 +89,7 @@ daily_news_expire_enable=YES
# Run 
 
 # 400.status-disks
 daily_status_disks_enable=YES# Check disk 
status
-daily_status_disks_df_flags=-l -h# df(1) flags for check
+daily_status_disks_df_flags=-l -h# df(1) flags for check
 
 # 401.status-graid
 daily_status_graid_enable=NO # Check graid(8)

Modified: head/share/man/man5/periodic.conf.5
==
--- head/share/man/man5/periodic.conf.5 Fri Mar 13 09:45:06 2015
(r279951)
+++ head/share/man/man5/periodic.conf.5 Fri Mar 13 09:50:29 2015
(r279952)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd January 15, 2015
+.Dd March 13, 2015
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
@@ -335,6 +335,8 @@ utility when
 .Va daily_status_disks_enable
 is set to
 .Dq Li YES .
+The default is
+.Fl l Fl h .
 .It Va daily_status_zfs_enable
 .Pq Vt bool
 Set to
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279954 - head/usr.sbin/autofs

2015-03-13 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Mar 13 12:27:59 2015
New Revision: 279954
URL: https://svnweb.freebsd.org/changeset/base/279954

Log:
  Get executable direct maps to work.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/autofs/automountd.c

Modified: head/usr.sbin/autofs/automountd.c
==
--- head/usr.sbin/autofs/automountd.c   Fri Mar 13 11:26:02 2015
(r279953)
+++ head/usr.sbin/autofs/automountd.c   Fri Mar 13 12:27:59 2015
(r279954)
@@ -177,7 +177,7 @@ handle_request(const struct autofs_daemo
const char *map;
struct node *root, *parent, *node;
FILE *f;
-   char *options, *fstype, *nobrowse, *retrycnt, *tmp;
+   char *key, *options, *fstype, *nobrowse, *retrycnt, *tmp;
int error;
bool wildcards;
 
@@ -199,11 +199,25 @@ handle_request(const struct autofs_daemo
map = adr-adr_from + 4; /* 4 for strlen(map ); */
root = node_new_root();
if (adr-adr_prefix[0] == '\0' || strcmp(adr-adr_prefix, /) == 0) {
+   /*
+* Direct map.  autofs(4) doesn't have a way to determine
+* correct map key, but since it's a direct map, we can just
+* use adr_path instead.
+*/
parent = root;
+   key = checked_strdup(adr-adr_path);
} else {
+   /*
+* Indirect map.
+*/
parent = node_new_map(root, checked_strdup(adr-adr_prefix),
NULL,  checked_strdup(map),
checked_strdup([kernel request]), lineno);
+
+   if (adr-adr_key[0] == '\0')
+   key = NULL;
+   else
+   key = checked_strdup(adr-adr_key);
}
 
/*
@@ -213,8 +227,7 @@ handle_request(const struct autofs_daemo
 * needs to be done for maps with wildcard entries, but also
 * for special and executable maps.
 */
-   parse_map(parent, map, adr-adr_key[0] != '\0' ? adr-adr_key : NULL,
-   wildcards);
+   parse_map(parent, map, key, wildcards);
if (!wildcards)
wildcards = node_has_wildcards(parent);
if (wildcards)
@@ -222,8 +235,8 @@ handle_request(const struct autofs_daemo
else
log_debugx(map does not contain wildcard entries);
 
-   if (adr-adr_key[0] != '\0')
-   node_expand_wildcard(root, adr-adr_key);
+   if (key != NULL)
+   node_expand_wildcard(root, key);
 
node = node_find(root, adr-adr_path);
if (node == NULL) {
@@ -248,7 +261,7 @@ handle_request(const struct autofs_daemo
node-n_config_file, node-n_config_line);
 
nobrowse = pick_option(nobrowse, options);
-   if (nobrowse != NULL  adr-adr_key[0] == '\0') {
+   if (nobrowse != NULL  key == NULL) {
log_debugx(skipping map %s due to \nobrowse\ 
option; exiting, map);
done(0, true);
@@ -265,12 +278,12 @@ handle_request(const struct autofs_daemo
 */
create_subtree(node, incomplete_hierarchy);
 
-   if (incomplete_hierarchy  adr-adr_key[0] != '\0') {
+   if (incomplete_hierarchy  key != NULL) {
/*
 * We still need to create the single subdirectory
 * user is trying to access.
 */
-   tmp = concat(adr-adr_path, '/', adr-adr_key);
+   tmp = concat(adr-adr_path, '/', key);
node = node_find(root, tmp);
if (node != NULL)
create_subtree(node, false);
@@ -288,8 +301,8 @@ handle_request(const struct autofs_daemo
log_debugx(found node defined at %s:%d; it is a mountpoint,
node-n_config_file, node-n_config_line);
 
-   node_expand_ampersand(node,
-   adr-adr_key[0] != '\0' ? adr-adr_key : NULL);
+   if (key != NULL)
+   node_expand_ampersand(node, key);
error = node_expand_defined(node);
if (error != 0) {
log_errx(1, variable expansion failed for %s; 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279955 - in head: etc etc/autofs usr.sbin/autofs

2015-03-13 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Mar 13 12:44:46 2015
New Revision: 279955
URL: https://svnweb.freebsd.org/changeset/base/279955

Log:
  Add -noauto autofs map, for automatic handling of fstab entries
  marked noauto.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Added:
  head/etc/autofs/special_noauto   (contents, props changed)
Modified:
  head/etc/auto_master
  head/etc/autofs/Makefile
  head/usr.sbin/autofs/auto_master.5

Modified: head/etc/auto_master
==
--- head/etc/auto_masterFri Mar 13 12:27:59 2015(r279954)
+++ head/etc/auto_masterFri Mar 13 12:44:46 2015(r279955)
@@ -6,3 +6,4 @@
 # When using the -media special map, make sure to edit devd.conf(5)
 # to move the call to automount -c out of the comments section.
 #/media-media  -nosuid
+#/--noauto

Modified: head/etc/autofs/Makefile
==
--- head/etc/autofs/MakefileFri Mar 13 12:27:59 2015(r279954)
+++ head/etc/autofs/MakefileFri Mar 13 12:44:46 2015(r279955)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-FILES= include_ldap special_hosts special_media special_null
+FILES= include_ldap special_hosts special_media special_noauto 
special_null
 
 NO_OBJ=
 FILESDIR=  /etc/autofs

Added: head/etc/autofs/special_noauto
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/etc/autofs/special_noauto  Fri Mar 13 12:44:46 2015
(r279955)
@@ -0,0 +1,29 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+print_available() {
+   sed 's/#.*//' /etc/fstab | awk '$4 ~ /noauto/ { print $2 }'
+}
+
+print_one() {
+   local _mntpoint
+
+   _mntpoint=${1%/}
+   
+   sed 's/#.*//' /etc/fstab | awk '
+   $2 == '${_mntpoint}'  $4 ~ /noauto/ {
+   if ($1 ~ /:/) { dev=$1 } else { dev=:$1 }
+   print -fstype= $3 , $4, dev
+   }'
+}
+
+if [ $# -eq 0 ]; then
+   print_available
+   exit 0
+fi
+
+print_one $1
+exit 0
+

Modified: head/usr.sbin/autofs/auto_master.5
==
--- head/usr.sbin/autofs/auto_master.5  Fri Mar 13 12:27:59 2015
(r279954)
+++ head/usr.sbin/autofs/auto_master.5  Fri Mar 13 12:44:46 2015
(r279955)
@@ -27,7 +27,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd January 9, 2015
+.Dd March 13, 2015
 .Dt AUTO_MASTER 5
 .Os
 .Sh NAME
@@ -260,6 +260,11 @@ when they are automatically created.
 .It Li -media
 Query devices that are not yet mounted, but contain valid filesystems.
 Generally used to access files on removable media.
+.It Li -noauto
+Mount filesystems configured in
+.Xr fstab 5
+as noauto.
+This needs to be set up as a direct map.
 .It Li -null
 Prevent
 .Xr automountd 8
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279953 - head/usr.sbin/autofs

2015-03-13 Thread Edward Tomasz Napierala
Author: trasz
Date: Fri Mar 13 11:26:02 2015
New Revision: 279953
URL: https://svnweb.freebsd.org/changeset/base/279953

Log:
  Rework the concat() algorithm to be correct in all cases.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/usr.sbin/autofs/common.c

Modified: head/usr.sbin/autofs/common.c
==
--- head/usr.sbin/autofs/common.c   Fri Mar 13 09:50:29 2015
(r279952)
+++ head/usr.sbin/autofs/common.c   Fri Mar 13 11:26:02 2015
(r279953)
@@ -92,6 +92,7 @@ char *
 concat(const char *s1, char separator, const char *s2)
 {
char *result;
+   char s1last, s2first;
int ret;
 
if (s1 == NULL)
@@ -99,14 +100,22 @@ concat(const char *s1, char separator, c
if (s2 == NULL)
s2 = ;
 
-   /*
-* If s2 starts with separator - skip it; otherwise concatenating
-* / and /foo would end up returning //foo.
-*/
-   if (s2[0] == separator)
-   s2++;
+   if (s1[0] == '\0')
+   s1last = '\0';
+   else
+   s1last = s1[strlen(s1) - 1];
 
-   if (s1[0] == '\0' || s2[0] == '\0' || s1[strlen(s1) - 1] == separator) {
+   s2first = s2[0];
+
+   if (s1last == separator  s2first == separator) {
+   /*
+* If s1 ends with the separator and s2 begins with
+* it - skip the latter; otherwise concatenating /
+* and /foo would end up returning //foo.
+*/
+   ret = asprintf(result, %s%s, s1, s2 + 1);
+   } else if (s1last == separator || s2first == separator ||
+   s1[0] == '\0' || s2[0] == '\0') {
ret = asprintf(result, %s%s, s1, s2);
} else {
ret = asprintf(result, %s%c%s, s1, separator, s2);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Nathan Whitehorn



On 03/13/15 01:47, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 02:46:53PM -0700, Nathan Whitehorn wrote:

On 03/12/15 14:35, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 02:29:43PM -0700, Nathan Whitehorn wrote:

On 03/12/15 14:22, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 09:15:39PM +, Nathan Whitehorn wrote:

Author: nwhitehorn
Date: Thu Mar 12 21:15:38 2015
New Revision: 279937
URL: https://svnweb.freebsd.org/changeset/base/279937

Log:
 Provide VSX context in ucontext(3) API.

Modified:
 head/sys/powerpc/include/ucontext.h
 head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/include/ucontext.h
==
--- head/sys/powerpc/include/ucontext.h Thu Mar 12 20:14:48 2015
(r279936)
+++ head/sys/powerpc/include/ucontext.h Thu Mar 12 21:15:38 2015
(r279937)
@@ -46,6 +46,7 @@ typedef struct __mcontext {
uint32_tmc_av[2];
register_t  mc_frame[42];
uint64_tmc_fpreg[33];
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
} mcontext_t __aligned(16);

#if defined(_KERNEL)  defined(__powerpc64__)

@@ -60,6 +61,7 @@ typedef struct __mcontext32 {
uint32_tmc_av[2];
uint32_tmc_frame[42];
uint64_tmc_fpreg[33];
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
} mcontext32_t __aligned(16);
#endif

It looks as if you broken the ABI compatibility by the change.  Am I wrong ?


That is correct. It's a tier-2 platform and -CURRENT, so I'm not sure
it's worth the compatibility shims. I'm happy to add them if you think
otherwise.

You are main maintainer of PowerPC port, IMO, so it is your decision.

Note that 'this is current' argument is not applicable, since the change
also breaks stable/* binaries.

I do understand the argument of PowerPC being tier 2 architecture, but this
makes me sad.  Anyway, it is yours.  For x86, I have to introduce
getcontextx(3) mechanism.


This is a good point. I'll try to fix it. Is my understanding of how
this works correct?

1. Provide a sysarch() for the extended FPU state.
2. Implement getcontextx() in the C library to fill extra properties if
required.
3. Store state for signal trampoline in variable-sized stack area

4. Implement __getcontextx_size() and __fillcontextx2() for use
in the deferred signal delivery while libthr is in critical section,
see lib/libthr/thread/thr_sig.c:check_deferred_signal().


OK.


Implementation of (2) seems to rely on having spare members in ucontext,
which PowerPC unfortunately does not have. Is there a way around that?

Indeed, this is very unfortunate.

My concern is that typical application allocating ucontext_t on stack or
by mallocing it, would get silent memory corruption after the extension
of mcontext_t.  It seems indeed that ABI breakage cannot be completely
avoided, but it could be significantly reduced IMO.  Is it true that
mc_avec is only valid when _MC_AV_VALID bit is set ?


That is correct.


If yes, we can introduce another mcontext flag, say _MC_XSTATE_VALID,
which is mutually exclusive with the _MC_AC_VALID. The new flag
indicates that there is external data, and the data is pointed to by
some word placed in the previous mc_avec file, say mc_avec[0]. The
altivec registers file content is moved into that external data area as
well. Providing the external area size in mc_avec[1] allows to extend
that block in the future-compatible manner.

This way, applications which use ucontext_t and which are not aware about
VSX, get the expected behaviour, possibly without seeing altivec.  I.e.
in typical case, we do not get random memory corruption.


OK, I guess that's reasonable. I'll think about this some and try to get 
some code written in the next few days.



Meantime, I have a question. I looked at the powerpc/include/ucontex.h
and tried to match it with the PowerISA specs 2.06 and 2.07. From what I
understand, mc_fpreg corresponds to the floating-point registers file,
mc_avec and mc_av to the 'Vector Facility Registers'.  But I fail to see
what would match the
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
file. The 7.2.1 Vector-Scalar Registers says 'Sixty-four 128-bit VSRs
are provided'.



The 64 128-bit registers are a superset of the existing registers. 
Registers 33-64 are just the Altivec registers, with no changes. 
Registers 1-32 are the normal floating point registers, but widened to 
128 bits from 64. What I had tried to do was to keep the layout of the 
bottom part of the structure unchanged for compatibility by storing only 
the extra half of registers 1-32 in a separate area. In particular, I 
wanted to keep the FP registers readable in a consecutive way.

-Nathan
___
svn-src-all@freebsd.org mailing list

svn commit: r279956 - head/sbin/ipfw

2015-03-13 Thread Andrey V. Elsukov
Author: ae
Date: Fri Mar 13 13:46:50 2015
New Revision: 279956
URL: https://svnweb.freebsd.org/changeset/base/279956

Log:
  Properly initialize scope zone id when next hop address stored
  directly in the O_FORWARD_IP6 opcode. Use getnameinfo(3) to formatting
  the IPv6 addresses of such opcodes.
  
  Obtained from:Yandex LLC
  Sponsored by: Yandex LLC

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Fri Mar 13 12:44:46 2015(r279955)
+++ head/sbin/ipfw/ipfw2.c  Fri Mar 13 13:46:50 2015(r279956)
@@ -1525,11 +1525,14 @@ show_static_rule(struct cmdline_opts *co
 
case O_FORWARD_IP6:
{
-   char buf[4 + INET6_ADDRSTRLEN + 1];
+   char buf[INET6_ADDRSTRLEN + IF_NAMESIZE + 2];
ipfw_insn_sa6 *s = (ipfw_insn_sa6 *)cmd;
 
-   bprintf(bp, fwd %s, inet_ntop(AF_INET6,
-   s-sa.sin6_addr, buf, sizeof(buf)));
+   bprintf(bp, fwd );
+   if (getnameinfo((const struct sockaddr *)s-sa,
+   sizeof(struct sockaddr_in6), buf, sizeof(buf),
+   NULL, 0, NI_NUMERICHOST) == 0)
+   bprintf(bp, %s, buf);
if (s-sa.sin6_port)
bprintf(bp, ,%d, s-sa.sin6_port);
}
@@ -3741,8 +3744,8 @@ chkarg:
p-sa.sin6_family = AF_INET6;
p-sa.sin6_port = port_number;
p-sa.sin6_flowinfo = 0;
-   p-sa.sin6_scope_id = 0;
-   /* No table support for v6 yet. */
+   p-sa.sin6_scope_id =
+   ((struct sockaddr_in6 *)result)-sin6_scope_id;
bcopy(((struct sockaddr_in6*)result)-sin6_addr,
p-sa.sin6_addr, sizeof(p-sa.sin6_addr));
} else {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


svn commit: r279957 - head/usr.sbin/bhyve

2015-03-13 Thread Alexander Motin
Author: mav
Date: Fri Mar 13 16:43:52 2015
New Revision: 279957
URL: https://svnweb.freebsd.org/changeset/base/279957

Log:
  Add DSM TRIM command support for virtual AHCI disks.
  
  It works only for virtual disks backed by ZVOLs and raw devices supporting
  BIO_DELETE.  Virtual disks backed by files won't report this capability.
  
  MFC after:2 weeks
  Relnotes: yes

Modified:
  head/usr.sbin/bhyve/block_if.c
  head/usr.sbin/bhyve/block_if.h
  head/usr.sbin/bhyve/pci_ahci.c

Modified: head/usr.sbin/bhyve/block_if.c
==
--- head/usr.sbin/bhyve/block_if.c  Fri Mar 13 13:46:50 2015
(r279956)
+++ head/usr.sbin/bhyve/block_if.c  Fri Mar 13 16:43:52 2015
(r279957)
@@ -59,7 +59,8 @@ __FBSDID($FreeBSD$);
 enum blockop {
BOP_READ,
BOP_WRITE,
-   BOP_FLUSH
+   BOP_FLUSH,
+   BOP_DELETE
 };
 
 enum blockstat {
@@ -81,6 +82,7 @@ struct blockif_ctxt {
int bc_magic;
int bc_fd;
int bc_ischr;
+   int bc_candelete;
int bc_rdonly;
off_t   bc_size;
int bc_sectsz;
@@ -172,6 +174,7 @@ static void
 blockif_proc(struct blockif_ctxt *bc, struct blockif_elem *be)
 {
struct blockif_req *br;
+   off_t arg[2];
int err;
 
br = be-be_req;
@@ -197,6 +200,17 @@ blockif_proc(struct blockif_ctxt *bc, st
} else if (fsync(bc-bc_fd))
err = errno;
break;
+   case BOP_DELETE:
+   if (!bc-bc_candelete)
+   err = EOPNOTSUPP;
+   else if (bc-bc_ischr) {
+   arg[0] = br-br_offset;
+   arg[1] = br-br_iov[0].iov_len;
+   if (ioctl(bc-bc_fd, DIOCGDELETE, arg))
+   err = errno;
+   } else
+   err = EOPNOTSUPP;
+   break;
default:
err = EINVAL;
break;
@@ -276,9 +290,10 @@ blockif_open(const char *optstr, const c
char *nopt, *xopts;
struct blockif_ctxt *bc;
struct stat sbuf;
+   struct diocgattr_arg arg;
off_t size, psectsz, psectoff;
int extra, fd, i, sectsz;
-   int nocache, sync, ro;
+   int nocache, sync, ro, candelete;
 
pthread_once(blockif_once, blockif_init);
 
@@ -332,6 +347,7 @@ blockif_open(const char *optstr, const c
 size = sbuf.st_size;
sectsz = DEV_BSIZE;
psectsz = psectoff = 0;
+   candelete = 0;
if (S_ISCHR(sbuf.st_mode)) {
if (ioctl(fd, DIOCGMEDIASIZE, size)  0 ||
ioctl(fd, DIOCGSECTORSIZE, sectsz)) {
@@ -343,6 +359,10 @@ blockif_open(const char *optstr, const c
assert(sectsz != 0);
if (ioctl(fd, DIOCGSTRIPESIZE, psectsz) == 0  psectsz  0)
ioctl(fd, DIOCGSTRIPEOFFSET, psectoff);
+   strlcpy(arg.name, GEOM::candelete, sizeof(arg.name));
+   arg.len = sizeof(arg.value.i);
+   if (ioctl(fd, DIOCGATTR, arg) == 0)
+   candelete = arg.value.i;
} else
psectsz = sbuf.st_blksize;
 
@@ -355,6 +375,7 @@ blockif_open(const char *optstr, const c
bc-bc_magic = BLOCKIF_SIG;
bc-bc_fd = fd;
bc-bc_ischr = S_ISCHR(sbuf.st_mode);
+   bc-bc_candelete = candelete;
bc-bc_rdonly = ro;
bc-bc_size = size;
bc-bc_sectsz = sectsz;
@@ -434,6 +455,14 @@ blockif_flush(struct blockif_ctxt *bc, s
 }
 
 int
+blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq)
+{
+
+   assert(bc-bc_magic == BLOCKIF_SIG);
+   return (blockif_request(bc, breq, BOP_DELETE));
+}
+
+int
 blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq)
 {
struct blockif_elem *be;
@@ -634,3 +663,11 @@ blockif_is_ro(struct blockif_ctxt *bc)
assert(bc-bc_magic == BLOCKIF_SIG);
return (bc-bc_rdonly);
 }
+
+int
+blockif_candelete(struct blockif_ctxt *bc)
+{
+
+   assert(bc-bc_magic == BLOCKIF_SIG);
+   return (bc-bc_candelete);
+}

Modified: head/usr.sbin/bhyve/block_if.h
==
--- head/usr.sbin/bhyve/block_if.h  Fri Mar 13 13:46:50 2015
(r279956)
+++ head/usr.sbin/bhyve/block_if.h  Fri Mar 13 16:43:52 2015
(r279957)
@@ -58,9 +58,11 @@ int  blockif_sectsz(struct blockif_ctxt *
 void   blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off);
 intblockif_queuesz(struct blockif_ctxt *bc);
 intblockif_is_ro(struct blockif_ctxt *bc);
+intblockif_candelete(struct blockif_ctxt *bc);
 intblockif_read(struct blockif_ctxt *bc, struct blockif_req *breq);
 intblockif_write(struct blockif_ctxt *bc, 

Re: svn commit: r279932 - head/sys/vm

2015-03-13 Thread Ian Lepore
On Fri, 2015-03-13 at 06:24 -0400, John Baldwin wrote:
 On Thursday, March 12, 2015 05:24:51 PM Ian Lepore wrote:
  On Thu, 2015-03-12 at 17:02 -0400, Ryan Stone wrote:
   On Thu, Mar 12, 2015 at 2:06 PM, Ian Lepore i...@freebsd.org wrote:
   
  Nullterminate strings returned via sysctl.
   
  PR:   195668
   
   
   To quote the manpage:
   
The *sbuf* family of functions allows one to safely
allocate, construct and release bounded null-terminated
strings in kernel space.
   
   IMO the sbuf API is broken if we have to explicitly null-terminate the
   string ourselves.
  
  If we want the nullterm to be counted in the length of data in the
  buffer (and thus get transmitted back across the syscall boundary) we
  need to put an explicit counted nullterm byte into the buffer.
  
  I had started down the path of making that (counting the nullterm byte
  as part of the data in the buffer) a feature of sbuf that you could set
  with a flag, but then whoever added sbuf_new_for_sysctl() didn't
  propagate the flags field through the new function and I decided to not
  go off into the weeds making a new flavor of that takes flags.
 
 One suggestion would be to consider using '\0' for a nul character instead of
 a bare 0.  To me that communicates the intention more clearly to the reader.
 (One of the things I did not like about C++  C++11 was the use of 0 for
 NULL.  I much prefer nullptr and NULL in C over bare 0's for pointers for
 similar clarity reasons.)
 

I have waffled back and forth between preferring 0 or '\0' for 30 years,
I just seem to go through phases with nullterm expression.

In general I'm glad I got called away to an onsite meeting yesterday and
didn't get far with these changes, because the more I think about it,
the less satisfied I am with this expedient fix.  The other fix I
started on, where a new SBUF_COUNTNUL flag can be set to inform the
sbuf_finish() code that you want the terminating nul counted in the data
length just feels like a better fit for the overall automaticness of
how the sbuf stuff works.

-- Ian


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


Re: svn commit: r279937 - in head/sys/powerpc: include powerpc

2015-03-13 Thread Nathan Whitehorn



On 03/13/15 01:47, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 02:46:53PM -0700, Nathan Whitehorn wrote:

On 03/12/15 14:35, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 02:29:43PM -0700, Nathan Whitehorn wrote:

On 03/12/15 14:22, Konstantin Belousov wrote:

On Thu, Mar 12, 2015 at 09:15:39PM +, Nathan Whitehorn wrote:

Author: nwhitehorn
Date: Thu Mar 12 21:15:38 2015
New Revision: 279937
URL: https://svnweb.freebsd.org/changeset/base/279937

Log:
 Provide VSX context in ucontext(3) API.

Modified:
 head/sys/powerpc/include/ucontext.h
 head/sys/powerpc/powerpc/exec_machdep.c

Modified: head/sys/powerpc/include/ucontext.h
==
--- head/sys/powerpc/include/ucontext.h Thu Mar 12 20:14:48 2015
(r279936)
+++ head/sys/powerpc/include/ucontext.h Thu Mar 12 21:15:38 2015
(r279937)
@@ -46,6 +46,7 @@ typedef struct __mcontext {
uint32_tmc_av[2];
register_t  mc_frame[42];
uint64_tmc_fpreg[33];
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
} mcontext_t __aligned(16);

#if defined(_KERNEL)  defined(__powerpc64__)

@@ -60,6 +61,7 @@ typedef struct __mcontext32 {
uint32_tmc_av[2];
uint32_tmc_frame[42];
uint64_tmc_fpreg[33];
+   uint64_tmc_vsxfpreg[32];/* low-order half of VSR0-31 */
} mcontext32_t __aligned(16);
#endif

It looks as if you broken the ABI compatibility by the change.  Am I wrong ?


That is correct. It's a tier-2 platform and -CURRENT, so I'm not sure
it's worth the compatibility shims. I'm happy to add them if you think
otherwise.

You are main maintainer of PowerPC port, IMO, so it is your decision.

Note that 'this is current' argument is not applicable, since the change
also breaks stable/* binaries.

I do understand the argument of PowerPC being tier 2 architecture, but this
makes me sad.  Anyway, it is yours.  For x86, I have to introduce
getcontextx(3) mechanism.


This is a good point. I'll try to fix it. Is my understanding of how
this works correct?

1. Provide a sysarch() for the extended FPU state.
2. Implement getcontextx() in the C library to fill extra properties if
required.
3. Store state for signal trampoline in variable-sized stack area

4. Implement __getcontextx_size() and __fillcontextx2() for use
in the deferred signal delivery while libthr is in critical section,
see lib/libthr/thread/thr_sig.c:check_deferred_signal().


Implementation of (2) seems to rely on having spare members in ucontext,
which PowerPC unfortunately does not have. Is there a way around that?

Indeed, this is very unfortunate.


One more thing I'd appreciate advice on: we have a much worse ABI issue 
with setjmp(). On 32-bit systems, _JBLEN is too small to hold all the 
nonvolatile vector registers. Do you have any ideas how to handle that?

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