Date: Tue, 13 Oct 2015 20:57:37 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r289267 - in projects/collation: kerberos5/lib share/mk sys/dev/ioat sys/dev/ntb/if_ntb sys/dev/ntb/ntb_hw sys/netinet usr.bin/truss usr.sbin/config Message-ID: <201510132057.t9DKvbDW064947@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Tue Oct 13 20:57:37 2015 New Revision: 289267 URL: https://svnweb.freebsd.org/changeset/base/289267 Log: Merge from head Added: projects/collation/usr.bin/truss/aarch64-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/aarch64-freebsd.c projects/collation/usr.bin/truss/amd64-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/amd64-freebsd.c projects/collation/usr.bin/truss/amd64-freebsd32.c - copied unchanged from r289266, head/usr.bin/truss/amd64-freebsd32.c projects/collation/usr.bin/truss/arm-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/arm-freebsd.c projects/collation/usr.bin/truss/i386-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/i386-freebsd.c projects/collation/usr.bin/truss/makesyscallsconf.sh - copied unchanged from r289266, head/usr.bin/truss/makesyscallsconf.sh projects/collation/usr.bin/truss/mips-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/mips-freebsd.c projects/collation/usr.bin/truss/powerpc-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/powerpc-freebsd.c projects/collation/usr.bin/truss/powerpc64-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/powerpc64-freebsd.c projects/collation/usr.bin/truss/powerpc64-freebsd32.c - copied unchanged from r289266, head/usr.bin/truss/powerpc64-freebsd32.c projects/collation/usr.bin/truss/sparc64-freebsd.c - copied unchanged from r289266, head/usr.bin/truss/sparc64-freebsd.c Deleted: projects/collation/usr.bin/truss/aarch64-fbsd.c projects/collation/usr.bin/truss/amd64-fbsd.c projects/collation/usr.bin/truss/amd64-fbsd32.c projects/collation/usr.bin/truss/amd64cloudabi64.conf projects/collation/usr.bin/truss/amd64linux32.conf projects/collation/usr.bin/truss/arm-fbsd.c projects/collation/usr.bin/truss/fbsd32.conf projects/collation/usr.bin/truss/i386-fbsd.c projects/collation/usr.bin/truss/i386.conf projects/collation/usr.bin/truss/i386linux.conf projects/collation/usr.bin/truss/mips-fbsd.c projects/collation/usr.bin/truss/powerpc-fbsd.c projects/collation/usr.bin/truss/powerpc64-fbsd.c projects/collation/usr.bin/truss/sparc64-fbsd.c Modified: projects/collation/kerberos5/lib/Makefile projects/collation/share/mk/bsd.subdir.mk projects/collation/sys/dev/ioat/ioat_internal.h projects/collation/sys/dev/ntb/if_ntb/if_ntb.c projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.c projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.h projects/collation/sys/dev/ntb/ntb_hw/ntb_regs.h projects/collation/sys/netinet/sctp_timer.c projects/collation/usr.bin/truss/Makefile projects/collation/usr.bin/truss/Makefile.depend.amd64 projects/collation/usr.bin/truss/amd64-cloudabi64.c projects/collation/usr.bin/truss/amd64-linux32.c projects/collation/usr.bin/truss/i386-linux.c projects/collation/usr.sbin/config/mkmakefile.c Directory Properties: projects/collation/ (props changed) projects/collation/share/ (props changed) projects/collation/sys/ (props changed) Modified: projects/collation/kerberos5/lib/Makefile ============================================================================== --- projects/collation/kerberos5/lib/Makefile Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/kerberos5/lib/Makefile Tue Oct 13 20:57:37 2015 (r289267) @@ -7,6 +7,5 @@ SUBDIR= libasn1 libgssapi_krb5 libgssapi SUBDIR+= libkafs5 # requires krb_err.h from libkrb5 SUBDIR_DEPEND_libkafs5= libkrb5 -SUBDIR_PARALLEL= .include <bsd.subdir.mk> Modified: projects/collation/share/mk/bsd.subdir.mk ============================================================================== --- projects/collation/share/mk/bsd.subdir.mk Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/share/mk/bsd.subdir.mk Tue Oct 13 20:57:37 2015 (r289267) @@ -25,14 +25,17 @@ # This is a variant of install, which will # put the stuff into the right "distribution". # -# afterinstall, all, all-man, beforeinstall, checkdpadd, clean, -# cleandepend, cleandir, cleanilinks depend, install, lint, -# maninstall, manlint, obj, objlink, realinstall, regress, tags +# See ALL_SUBDIR_TARGETS for list of targets that will recurse. +# Custom targets can be added to SUBDIR_TARGETS in src.conf. # .if !target(__<bsd.subdir.mk>__) __<bsd.subdir.mk>__: +ALL_SUBDIR_TARGETS= all all-man checkdpadd clean cleandepend cleandir \ + cleanilinks cleanobj depend distribute lint maninstall manlint obj \ + objlink realinstall regress tags ${SUBDIR_TARGETS} + .include <bsd.init.mk> .if !defined(NEED_SUBDIR) @@ -85,9 +88,7 @@ ${SUBDIR:N.WAIT}: .PHONY .MAKE # Work around parsing of .if nested in .for by putting .WAIT string into a var. __wait= .WAIT -.for __target in all all-man checkdpadd clean cleandepend cleandir \ - cleanilinks depend distribute lint maninstall manlint obj objlink \ - realinstall regress tags ${SUBDIR_TARGETS} +.for __target in ${ALL_SUBDIR_TARGETS} .ifdef SUBDIR_PARALLEL __subdir_targets= .for __dir in ${SUBDIR} Modified: projects/collation/sys/dev/ioat/ioat_internal.h ============================================================================== --- projects/collation/sys/dev/ioat/ioat_internal.h Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/dev/ioat/ioat_internal.h Tue Oct 13 20:57:37 2015 (r289267) @@ -65,7 +65,7 @@ ioat_bus_space_write_8_lower_first(bus_s bus_space_write_4(tag, handle, offset + 4, val >> 32); } -#ifdef i386 +#ifdef __i386__ #define ioat_bus_space_read_8 ioat_bus_space_read_8_lower_first #define ioat_bus_space_write_8 ioat_bus_space_write_8_lower_first #else Modified: projects/collation/sys/dev/ntb/if_ntb/if_ntb.c ============================================================================== --- projects/collation/sys/dev/ntb/if_ntb/if_ntb.c Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/dev/ntb/if_ntb/if_ntb.c Tue Oct 13 20:57:37 2015 (r289267) @@ -715,7 +715,7 @@ ntb_transport_link_up(struct ntb_transpo * @len: length of the data buffer * * Enqueue a new transmit buffer onto the transport queue from which a NTB - * payload will be transmitted. This assumes that a lock is behing held to + * payload will be transmitted. This assumes that a lock is being held to * serialize access to the qp. * * RETURNS: An appropriate ERRNO error value on error, or zero for success. @@ -809,7 +809,7 @@ ntb_tx_copy_task(struct ntb_transport_qp /* TODO: replace with bus_space_write */ hdr->flags = entry->flags | IF_NTB_DESC_DONE_FLAG; - ntb_ring_sdb(qp->ntb, qp->qp_num); + ntb_ring_doorbell(qp->ntb, qp->qp_num); /* * The entry length can only be zero if the packet is intended to be a @@ -1047,7 +1047,7 @@ ntb_transport_link_work(void *arg) /* send the local info, in the opposite order of the way we read it */ for (i = 0; i < num_mw; i++) { rc = ntb_write_remote_spad(ntb, IF_NTB_MW0_SZ_HIGH + (i * 2), - ntb_get_mw_size(ntb, i) >> 32); + (uint64_t)ntb_get_mw_size(ntb, i) >> 32); if (rc != 0) goto out; @@ -1311,7 +1311,7 @@ ntb_qp_link_cleanup(struct ntb_transport * * Notify NTB transport layer of client's desire to no longer receive data on * transport queue specified. It is the client's responsibility to ensure all - * entries on queue are purged or otherwise handled appropraitely. + * entries on queue are purged or otherwise handled appropriately. */ static void ntb_transport_link_down(struct ntb_transport_qp *qp) Modified: projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.c ============================================================================== --- projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.c Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.c Tue Oct 13 20:57:37 2015 (r289267) @@ -133,11 +133,11 @@ struct ntb_softc { uint8_t msix_cnt; } limits; struct { - uint32_t pdb; - uint32_t pdb_mask; - uint32_t sdb; - uint32_t sbar2_xlat; - uint32_t sbar4_xlat; + uint32_t ldb; + uint32_t ldb_mask; + uint32_t rdb; + uint32_t bar2_xlat; + uint32_t bar4_xlat; uint32_t spad_remote; uint32_t spad_local; uint32_t lnk_cntl; @@ -476,9 +476,9 @@ ntb_setup_interrupts(struct ntb_softc *n * Interrupt. The rest will be unmasked as callbacks are registered. */ if (ntb->type == NTB_SOC) - ntb_reg_write(8, ntb->reg_ofs.pdb_mask, ~0); + ntb_reg_write(8, ntb->reg_ofs.ldb_mask, ~0); else - ntb_reg_write(2, ntb->reg_ofs.pdb_mask, + ntb_reg_write(2, ntb->reg_ofs.ldb_mask, ~(1 << ntb->limits.max_db_bits)); num_vectors = MIN(pci_msix_count(ntb->device), @@ -578,7 +578,7 @@ handle_soc_irq(void *arg) struct ntb_db_cb *db_cb = arg; struct ntb_softc *ntb = db_cb->ntb; - ntb_reg_write(8, ntb->reg_ofs.pdb, (uint64_t) 1 << db_cb->db_num); + ntb_reg_write(8, ntb->reg_ofs.ldb, (uint64_t) 1 << db_cb->db_num); if (db_cb->callback != NULL) db_cb->callback(db_cb->data, db_cb->db_num); @@ -596,7 +596,7 @@ handle_xeon_irq(void *arg) * vectors, with the 4th having a single bit for link * interrupts. */ - ntb_reg_write(2, ntb->reg_ofs.pdb, + ntb_reg_write(2, ntb->reg_ofs.ldb, ((1 << ntb->bits_per_vector) - 1) << (db_cb->db_num * ntb->bits_per_vector)); @@ -616,7 +616,7 @@ handle_xeon_event_irq(void *arg) device_printf(ntb->device, "Error determining link status\n"); /* bit 15 is always the link bit */ - ntb_reg_write(2, ntb->reg_ofs.pdb, 1 << ntb->limits.max_db_bits); + ntb_reg_write(2, ntb->reg_ofs.ldb, 1 << ntb->limits.max_db_bits); } static void @@ -624,28 +624,28 @@ ntb_handle_legacy_interrupt(void *arg) { struct ntb_softc *ntb = arg; unsigned int i = 0; - uint64_t pdb64; - uint16_t pdb16; + uint64_t ldb64; + uint16_t ldb16; if (ntb->type == NTB_SOC) { - pdb64 = ntb_reg_read(8, ntb->reg_ofs.pdb); + ldb64 = ntb_reg_read(8, ntb->reg_ofs.ldb); - while (pdb64) { - i = ffs(pdb64); - pdb64 &= pdb64 - 1; + while (ldb64) { + i = ffs(ldb64); + ldb64 &= ldb64 - 1; handle_soc_irq(&ntb->db_cb[i]); } } else { - pdb16 = ntb_reg_read(2, ntb->reg_ofs.pdb); + ldb16 = ntb_reg_read(2, ntb->reg_ofs.ldb); - if ((pdb16 & XEON_DB_HW_LINK) != 0) { + if ((ldb16 & XEON_DB_HW_LINK) != 0) { handle_xeon_event_irq(ntb); - pdb16 &= ~XEON_DB_HW_LINK; + ldb16 &= ~XEON_DB_HW_LINK; } - while (pdb16 != 0) { - i = ffs(pdb16); - pdb16 &= pdb16 - 1; + while (ldb16 != 0) { + i = ffs(ldb16); + ldb16 &= ldb16 - 1; handle_xeon_irq(&ntb->db_cb[i]); } } @@ -709,32 +709,51 @@ ntb_setup_xeon(struct ntb_softc *ntb) val = pci_read_config(ntb->device, NTB_PPD_OFFSET, 1); connection_type = val & XEON_PPD_CONN_TYPE; + + if ((val & XEON_PPD_DEV_TYPE) != 0) + ntb->dev_type = NTB_DEV_USD; + else + ntb->dev_type = NTB_DEV_DSD; + + ntb->reg_ofs.ldb = XEON_PDOORBELL_OFFSET; + ntb->reg_ofs.ldb_mask = XEON_PDBMSK_OFFSET; + ntb->reg_ofs.spad_local = XEON_SPAD_OFFSET; + ntb->reg_ofs.bar2_xlat = XEON_SBAR2XLAT_OFFSET; + ntb->reg_ofs.bar4_xlat = XEON_SBAR4XLAT_OFFSET; + switch (connection_type) { case NTB_CONN_B2B: ntb->conn_type = NTB_CONN_B2B; + + /* + * reg_ofs.rdb and reg_ofs.spad_remote are effectively ignored + * with the NTB_REGS_THRU_MW errata mode enabled. (See + * ntb_ring_doorbell() and ntb_read/write_remote_spad().) + */ + ntb->reg_ofs.rdb = XEON_B2B_DOORBELL_OFFSET; + ntb->reg_ofs.spad_remote = XEON_B2B_SPAD_OFFSET; + + ntb->limits.max_spads = XEON_MAX_SPADS; break; - case NTB_CONN_CLASSIC: + case NTB_CONN_RP: + /* + * Every Xeon today needs NTB_REGS_THRU_MW, so punt on RP for + * now. + */ + KASSERT(HAS_FEATURE(NTB_REGS_THRU_MW), + ("Xeon without MW errata unimplemented")); + device_printf(ntb->device, + "NTB-RP disabled to due hardware errata.\n"); + return (ENXIO); + + case NTB_CONN_TRANSPARENT: default: device_printf(ntb->device, "Connection type %d not supported\n", connection_type); return (ENXIO); } - if ((val & XEON_PPD_DEV_TYPE) != 0) - ntb->dev_type = NTB_DEV_USD; - else - ntb->dev_type = NTB_DEV_DSD; - - ntb->reg_ofs.pdb = XEON_PDOORBELL_OFFSET; - ntb->reg_ofs.pdb_mask = XEON_PDBMSK_OFFSET; - ntb->reg_ofs.sbar2_xlat = XEON_SBAR2XLAT_OFFSET; - ntb->reg_ofs.sbar4_xlat = XEON_SBAR4XLAT_OFFSET; - ntb->reg_ofs.lnk_cntl = XEON_NTBCNTL_OFFSET; - ntb->reg_ofs.lnk_stat = XEON_LINK_STATUS_OFFSET; - ntb->reg_ofs.spad_local = XEON_SPAD_OFFSET; - ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - /* * There is a Xeon hardware errata related to writes to SDOORBELL or * B2BDOORBELL in conjunction with inbound access to NTB MMIO space, @@ -757,25 +776,20 @@ ntb_setup_xeon(struct ntb_softc *ntb) ntb_reg_write(8, XEON_PBAR4LMT_OFFSET, 0); - if (ntb->conn_type == NTB_CONN_B2B) { - ntb->reg_ofs.sdb = XEON_B2B_DOORBELL_OFFSET; - ntb->reg_ofs.spad_remote = XEON_B2B_SPAD_OFFSET; - ntb->limits.max_spads = XEON_MAX_SPADS; - } else { - ntb->reg_ofs.sdb = XEON_SDOORBELL_OFFSET; - ntb->reg_ofs.spad_remote = XEON_SPAD_OFFSET; - ntb->limits.max_spads = XEON_MAX_COMPAT_SPADS; - } + ntb->reg_ofs.lnk_cntl = XEON_NTBCNTL_OFFSET; + ntb->reg_ofs.lnk_stat = XEON_LINK_STATUS_OFFSET; + ntb->reg_ofs.spci_cmd = XEON_PCICMD_OFFSET; - ntb->limits.max_db_bits = XEON_MAX_DB_BITS; + ntb->limits.max_db_bits = XEON_MAX_DB_BITS; ntb->limits.msix_cnt = XEON_MSIX_CNT; ntb->bits_per_vector = XEON_DB_BITS_PER_VEC; configure_xeon_secondary_side_bars(ntb); /* Enable Bus Master and Memory Space on the secondary side */ - ntb_reg_write(2, ntb->reg_ofs.spci_cmd, - PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); + if (ntb->conn_type == NTB_CONN_B2B) + ntb_reg_write(2, ntb->reg_ofs.spci_cmd, + PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN); /* Enable link training */ ntb_reg_write(4, ntb->reg_ofs.lnk_cntl, @@ -796,10 +810,9 @@ ntb_setup_soc(struct ntb_softc *ntb) case NTB_CONN_B2B: ntb->conn_type = NTB_CONN_B2B; break; - case NTB_CONN_RP: default: - device_printf(ntb->device, "Connection type %d not supported\n", - connection_type); + device_printf(ntb->device, + "Unsupported NTB configuration (%d)\n", connection_type); return (ENXIO); } @@ -812,26 +825,19 @@ ntb_setup_soc(struct ntb_softc *ntb) pci_write_config(ntb->device, NTB_PPD_OFFSET, val | SOC_PPD_INIT_LINK, 4); - ntb->reg_ofs.pdb = SOC_PDOORBELL_OFFSET; - ntb->reg_ofs.pdb_mask = SOC_PDBMSK_OFFSET; - ntb->reg_ofs.sbar2_xlat = SOC_SBAR2XLAT_OFFSET; - ntb->reg_ofs.sbar4_xlat = SOC_SBAR4XLAT_OFFSET; + ntb->reg_ofs.ldb = SOC_PDOORBELL_OFFSET; + ntb->reg_ofs.ldb_mask = SOC_PDBMSK_OFFSET; + ntb->reg_ofs.rdb = SOC_B2B_DOORBELL_OFFSET; + ntb->reg_ofs.bar2_xlat = SOC_SBAR2XLAT_OFFSET; + ntb->reg_ofs.bar4_xlat = SOC_SBAR4XLAT_OFFSET; ntb->reg_ofs.lnk_cntl = SOC_NTBCNTL_OFFSET; ntb->reg_ofs.lnk_stat = SOC_LINK_STATUS_OFFSET; ntb->reg_ofs.spad_local = SOC_SPAD_OFFSET; + ntb->reg_ofs.spad_remote = SOC_B2B_SPAD_OFFSET; ntb->reg_ofs.spci_cmd = SOC_PCICMD_OFFSET; - if (ntb->conn_type == NTB_CONN_B2B) { - ntb->reg_ofs.sdb = SOC_B2B_DOORBELL_OFFSET; - ntb->reg_ofs.spad_remote = SOC_B2B_SPAD_OFFSET; - ntb->limits.max_spads = SOC_MAX_SPADS; - } else { - ntb->reg_ofs.sdb = SOC_PDOORBELL_OFFSET; - ntb->reg_ofs.spad_remote = SOC_SPAD_OFFSET; - ntb->limits.max_spads = SOC_MAX_COMPAT_SPADS; - } - - ntb->limits.max_db_bits = SOC_MAX_DB_BITS; + ntb->limits.max_spads = SOC_MAX_SPADS; + ntb->limits.max_db_bits = SOC_MAX_DB_BITS; ntb->limits.msix_cnt = SOC_MSIX_CNT; ntb->bits_per_vector = SOC_DB_BITS_PER_VEC; @@ -996,7 +1002,8 @@ ntb_handle_link_event(struct ntb_softc * ntb->link_status = NTB_LINK_UP; event = NTB_EVENT_HW_LINK_UP; - if (ntb->type == NTB_SOC) + if (ntb->type == NTB_SOC || + ntb->conn_type == NTB_CONN_TRANSPARENT) status = ntb_reg_read(2, ntb->reg_ofs.lnk_stat); else status = pci_read_config(ntb->device, @@ -1133,6 +1140,7 @@ ntb_unregister_event_callback(struct ntb * ntb_register_db_callback() - register a callback for doorbell interrupt * @ntb: pointer to ntb_softc instance * @idx: doorbell index to register callback, zero based + * @data: pointer to be returned to caller with every callback * @func: callback function to register * * This function registers a callback function for the doorbell interrupt @@ -1156,9 +1164,9 @@ ntb_register_db_callback(struct ntb_soft ntb->db_cb[idx].data = data; /* unmask interrupt */ - mask = ntb_reg_read(2, ntb->reg_ofs.pdb_mask); + mask = ntb_reg_read(2, ntb->reg_ofs.ldb_mask); mask &= ~(1 << (idx * ntb->bits_per_vector)); - ntb_reg_write(2, ntb->reg_ofs.pdb_mask, mask); + ntb_reg_write(2, ntb->reg_ofs.ldb_mask, mask); return (0); } @@ -1179,9 +1187,9 @@ ntb_unregister_db_callback(struct ntb_so if (idx >= ntb->allocated_interrupts || !ntb->db_cb[idx].callback) return; - mask = ntb_reg_read(2, ntb->reg_ofs.pdb_mask); + mask = ntb_reg_read(2, ntb->reg_ofs.ldb_mask); mask |= 1 << (idx * ntb->bits_per_vector); - ntb_reg_write(2, ntb->reg_ofs.pdb_mask, mask); + ntb_reg_write(2, ntb->reg_ofs.ldb_mask, mask); ntb->db_cb[idx].callback = NULL; } @@ -1430,16 +1438,16 @@ ntb_set_mw_addr(struct ntb_softc *ntb, u switch (NTB_MW_TO_BAR(mw)) { case NTB_B2B_BAR_1: - ntb_reg_write(8, ntb->reg_ofs.sbar2_xlat, addr); + ntb_reg_write(8, ntb->reg_ofs.bar2_xlat, addr); break; case NTB_B2B_BAR_2: - ntb_reg_write(8, ntb->reg_ofs.sbar4_xlat, addr); + ntb_reg_write(8, ntb->reg_ofs.bar4_xlat, addr); break; } } /** - * ntb_ring_sdb() - Set the doorbell on the secondary/external side + * ntb_ring_doorbell() - Set the doorbell on the secondary/external side * @ntb: pointer to ntb_softc instance * @db: doorbell to ring * @@ -1449,18 +1457,18 @@ ntb_set_mw_addr(struct ntb_softc *ntb, u * RETURNS: An appropriate ERRNO error value on error, or zero for success. */ void -ntb_ring_sdb(struct ntb_softc *ntb, unsigned int db) +ntb_ring_doorbell(struct ntb_softc *ntb, unsigned int db) { if (ntb->type == NTB_SOC) - ntb_reg_write(8, ntb->reg_ofs.sdb, (uint64_t) 1 << db); + ntb_reg_write(8, ntb->reg_ofs.rdb, (uint64_t) 1 << db); else { if (HAS_FEATURE(NTB_REGS_THRU_MW)) ntb_mw_write(2, XEON_SHADOW_PDOORBELL_OFFSET, ((1 << ntb->bits_per_vector) - 1) << (db * ntb->bits_per_vector)); else - ntb_reg_write(2, ntb->reg_ofs.sdb, + ntb_reg_write(2, ntb->reg_ofs.rdb, ((1 << ntb->bits_per_vector) - 1) << (db * ntb->bits_per_vector)); } Modified: projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.h ============================================================================== --- projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.h Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/dev/ntb/ntb_hw/ntb_hw.h Tue Oct 13 20:57:37 2015 (r289267) @@ -69,7 +69,7 @@ void *ntb_get_mw_vbase(struct ntb_softc vm_paddr_t ntb_get_mw_pbase(struct ntb_softc *ntb, unsigned int mw); u_long ntb_get_mw_size(struct ntb_softc *ntb, unsigned int mw); void ntb_set_mw_addr(struct ntb_softc *ntb, unsigned int mw, uint64_t addr); -void ntb_ring_sdb(struct ntb_softc *ntb, unsigned int db); +void ntb_ring_doorbell(struct ntb_softc *ntb, unsigned int db); bool ntb_query_link_status(struct ntb_softc *ntb); device_t ntb_get_device(struct ntb_softc *ntb); Modified: projects/collation/sys/dev/ntb/ntb_hw/ntb_regs.h ============================================================================== --- projects/collation/sys/dev/ntb/ntb_hw/ntb_regs.h Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/dev/ntb/ntb_hw/ntb_regs.h Tue Oct 13 20:57:37 2015 (r289267) @@ -29,8 +29,6 @@ #ifndef _NTB_REGS_H_ #define _NTB_REGS_H_ -#define NTB_LINK_ENABLE 0x0000 -#define NTB_LINK_DISABLE 0x0002 #define NTB_LINK_STATUS_ACTIVE 0x2000 #define NTB_LINK_SPEED_MASK 0x000f #define NTB_LINK_WIDTH_MASK 0x03f0 @@ -47,6 +45,7 @@ #define XEON_PCICMD_OFFSET 0x0504 #define XEON_DEVCTRL_OFFSET 0x0598 #define XEON_LINK_STATUS_OFFSET 0x01a2 +#define XEON_SLINK_STATUS_OFFSET 0x05a2 #define XEON_PBAR2LMT_OFFSET 0x0000 #define XEON_PBAR4LMT_OFFSET 0x0008 @@ -76,7 +75,6 @@ #define SOC_MSIX_CNT 34 #define SOC_MAX_SPADS 16 -#define SOC_MAX_COMPAT_SPADS 16 #define SOC_MAX_DB_BITS 34 #define SOC_DB_BITS_PER_VEC 1 @@ -117,6 +115,8 @@ #define SOC_LTSSMSTATEJMP_FORCEDETECT (1 << 2) #define SOC_IBIST_ERR_OFLOW 0x7fff7fff +#define NTB_CNTL_CFG_LOCK (1 << 0) +#define NTB_CNTL_LINK_DISABLE (1 << 1) #define NTB_CNTL_BAR23_SNOOP (1 << 2) #define NTB_CNTL_BAR45_SNOOP (1 << 6) #define SOC_CNTL_LINK_DOWN (1 << 16) @@ -130,7 +130,7 @@ #define SOC_PPD_CONN_TYPE 0x0300 #define SOC_PPD_DEV_TYPE 0x1000 -#define NTB_CONN_CLASSIC 0 +#define NTB_CONN_TRANSPARENT 0 #define NTB_CONN_B2B 1 #define NTB_CONN_RP 2 Modified: projects/collation/sys/netinet/sctp_timer.c ============================================================================== --- projects/collation/sys/netinet/sctp_timer.c Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/sys/netinet/sctp_timer.c Tue Oct 13 20:57:37 2015 (r289267) @@ -408,7 +408,11 @@ sctp_backoff_on_timeout(struct sctp_tcb int num_marked, int num_abandoned) { if (net->RTO == 0) { - net->RTO = stcb->asoc.minrto; + if (net->RTO_measured) { + net->RTO = stcb->asoc.minrto; + } else { + net->RTO = stcb->asoc.initial_rto; + } } net->RTO <<= 1; if (net->RTO > stcb->asoc.maxrto) { Modified: projects/collation/usr.bin/truss/Makefile ============================================================================== --- projects/collation/usr.bin/truss/Makefile Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/usr.bin/truss/Makefile Tue Oct 13 20:57:37 2015 (r289267) @@ -2,87 +2,64 @@ NO_WERROR= PROG= truss -SRCS= main.c setup.c syscalls.c syscalls.h ioctl.c - -.if exists(${.CURDIR}/${MACHINE_ARCH}-fbsd.c) -SRCS+= ${MACHINE_ARCH}-fbsd.c -.else -SRCS+= ${MACHINE_CPUARCH}-fbsd.c -.endif +SRCS= main.c setup.c syscalls.c ioctl.c .PATH: ${.CURDIR:H}/kdump SRCS+= utrace.c CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys -CLEANFILES= syscalls.master syscalls.h ioctl.c - -.SUFFIXES: .master - -syscalls.master: ${.CURDIR}/../../sys/kern/syscalls.master - cat ${.ALLSRC} > syscalls.master - -syscalls.h: syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh syscalls.master \ - ${.CURDIR}/i386.conf +CLEANFILES= ioctl.c ioctl.c: ${.CURDIR}/../kdump/mkioctls env MACHINE=${MACHINE} CPP="${CPP}" \ /bin/sh ${.CURDIR}/../kdump/mkioctls return ${DESTDIR}${INCLUDEDIR} > ${.TARGET} +# Define where to generate syscalls for each ABI. +ABI_SYSPATH.freebsd= sys/kern +ABI_SYSPATH.freebsd32= sys/compat/freebsd32 +ABI_SYSPATH.cloudabi64= sys/compat/cloudabi64 +ABI_SYSPATH.i386-linux= sys/i386/linux +ABI_SYSPATH.amd64-linux32= sys/amd64/linux32 + +ABIS+= freebsd +# Each ABI is expected to have an ABI.c, MACHINE_ARCH-ABI.c or +# MACHINE_CPUARCH-ABI.c file that will be used to map the syscall arguments. .if ${MACHINE_CPUARCH} == "i386" -SRCS+= i386-linux.c linux_syscalls.h -CLEANFILES+=i386l-syscalls.master linux_syscalls.h - -i386l-syscalls.master: ${.CURDIR}/../../sys/i386/linux/syscalls.master - cat ${.ALLSRC} > ${.TARGET} - -linux_syscalls.h: i386l-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \ - ${.CURDIR}/i386linux.conf +ABIS+= i386-linux .endif - .if ${MACHINE_CPUARCH} == "amd64" -SRCS+= amd64-linux32.c linux32_syscalls.h -CLEANFILES+=amd64l32-syscalls.master linux32_syscalls.h - -amd64l32-syscalls.master: ${.CURDIR}/../../sys/amd64/linux32/syscalls.master - cat ${.ALLSRC} > ${.TARGET} - -linux32_syscalls.h: amd64l32-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \ - ${.CURDIR}/amd64linux32.conf - -SRCS+= amd64-fbsd32.c freebsd32_syscalls.h -CLEANFILES+=fbsd32-syscalls.master freebsd32_syscalls.h - -fbsd32-syscalls.master: ${.CURDIR}/../../sys/compat/freebsd32/syscalls.master - cat ${.ALLSRC} > ${.TARGET} - -freebsd32_syscalls.h: fbsd32-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \ - ${.CURDIR}/fbsd32.conf - -SRCS+= amd64-cloudabi64.c cloudabi64_syscalls.h -CLEANFILES+=amd64cloudabi64-syscalls.master cloudabi64_syscalls.h - -amd64cloudabi64-syscalls.master: ${.CURDIR}/../../sys/compat/cloudabi64/syscalls.master - cat ${.ALLSRC} > ${.TARGET} - -cloudabi64_syscalls.h: amd64cloudabi64-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \ - ${.CURDIR}/amd64cloudabi64.conf +ABIS+= amd64-linux32 +ABIS+= freebsd32 +ABIS+= cloudabi64 .endif - .if ${MACHINE_ARCH} == "powerpc64" -SRCS+= powerpc-fbsd.c freebsd32_syscalls.h -CLEANFILES+=fbsd32-syscalls.master freebsd32_syscalls.h - -fbsd32-syscalls.master: ${.CURDIR}/../../sys/compat/freebsd32/syscalls.master - cat ${.ALLSRC} > ${.TARGET} +ABIS+= freebsd32 +.endif -freebsd32_syscalls.h: fbsd32-syscalls.master - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \ - ${.CURDIR}/fbsd32.conf +.for abi in ${ABIS} +# Find the right file to handle this ABI. +abi_src= +ABI_SRCS= ${abi}.c ${MACHINE_ARCH}-${abi}.c ${MACHINE_CPUARCH}-${abi}.c +.for f in ${ABI_SRCS} +.if exists(${.CURDIR}/${f}) && empty(abi_src) +abi_src= ${f} .endif +.endfor +SRCS:= ${SRCS} ${abi_src} ${abi}_syscalls.h +CLEANFILES+= ${abi}_syscalls.conf ${abi}_syscalls.master ${abi}_syscalls.h +${abi}_syscalls.conf: ${.CURDIR}/makesyscallsconf.sh + /bin/sh ${.CURDIR}/makesyscallsconf.sh ${abi} ${.TARGET} + +${abi}_syscalls.master: ${.CURDIR:H:H}/${ABI_SYSPATH.${abi}}/syscalls.master + cp -f ${.ALLSRC} ${.TARGET} + +${abi}_syscalls.h: ${abi}_syscalls.master ${abi}_syscalls.conf \ + ${.CURDIR:H:H}/sys/kern/makesyscalls.sh + /bin/sh ${.CURDIR:H:H}/sys/kern/makesyscalls.sh \ + ${abi}_syscalls.master ${abi}_syscalls.conf +# Eliminate compiler warning about non-static global. + sed -i '' '/^const char \*/s/^/static /' ${.TARGET}.tmp + mv ${.TARGET}.tmp ${.TARGET} +.endfor .include <bsd.prog.mk> Modified: projects/collation/usr.bin/truss/Makefile.depend.amd64 ============================================================================== --- projects/collation/usr.bin/truss/Makefile.depend.amd64 Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/usr.bin/truss/Makefile.depend.amd64 Tue Oct 13 20:57:37 2015 (r289267) @@ -19,12 +19,12 @@ DIRDEPS = \ # local dependencies - needed for -jN in clean tree amd64-cloudabi64.o: cloudabi64_syscalls.h amd64-cloudabi64.po: cloudabi64_syscalls.h -amd64-fbsd.o: syscalls.h -amd64-fbsd.po: syscalls.h -amd64-fbsd32.o: freebsd32_syscalls.h -amd64-fbsd32.po: freebsd32_syscalls.h -amd64-linux32.o: linux32_syscalls.h -amd64-linux32.po: linux32_syscalls.h +amd64-freebsd.o: freebsd_syscalls.h +amd64-freebsd.po: freebsd_syscalls.h +amd64-freebsd32.o: freebsd32_syscalls.h +amd64-freebsd32.po: freebsd32_syscalls.h +amd64-linux32.o: amd64-linux32_syscalls.h +amd64-linux32.po: amd64-linux32_syscalls.h ioctl.o: ioctl.c ioctl.po: ioctl.c .endif Copied: projects/collation/usr.bin/truss/aarch64-freebsd.c (from r289266, head/usr.bin/truss/aarch64-freebsd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/collation/usr.bin/truss/aarch64-freebsd.c Tue Oct 13 20:57:37 2015 (r289267, copy of r289266, head/usr.bin/truss/aarch64-freebsd.c) @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015 The FreeBSD Foundation + * + * Portions of this software were developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +/* FreeBSD/arm64-specific system call handling. */ + +#include <sys/ptrace.h> +#include <sys/syscall.h> + +#include <machine/reg.h> +#include <machine/armreg.h> +#include <machine/ucontext.h> + +#include <stdio.h> + +#include "truss.h" + +#include "freebsd_syscalls.h" + +static int +aarch64_fetch_args(struct trussinfo *trussinfo, u_int narg) +{ + struct reg regs; + struct current_syscall *cs; + lwpid_t tid; + u_int i, reg, syscall_num; + + tid = trussinfo->curthread->tid; + cs = &trussinfo->curthread->cs; + if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return (-1); + } + + /* + * FreeBSD has two special kinds of system call redirections -- + * SYS_syscall, and SYS___syscall. The former is the old syscall() + * routine, basically; the latter is for quad-aligned arguments. + * + * The system call argument count and code from ptrace() already + * account for these, but we need to skip over the first argument. + */ + syscall_num = regs.x[8]; + if (syscall_num == SYS_syscall || syscall_num == SYS___syscall) { + reg = 1; + syscall_num = regs.x[0]; + } else { + reg = 0; + } + + for (i = 0; i < narg && reg < 8; i++, reg++) + cs->args[i] = regs.x[reg]; + return (0); +} + +static int +aarch64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) +{ + struct reg regs; + lwpid_t tid; + + tid = trussinfo->curthread->tid; + if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return (-1); + } + + retval[0] = regs.x[0]; + retval[1] = regs.x[1]; + *errorp = !!(regs.spsr & PSR_C); + return (0); +} + +static struct procabi aarch64_freebsd = { + "FreeBSD ELF64", + syscallnames, + nitems(syscallnames), + aarch64_fetch_args, + aarch64_fetch_retval +}; + +PROCABI(aarch64_freebsd); Modified: projects/collation/usr.bin/truss/amd64-cloudabi64.c ============================================================================== --- projects/collation/usr.bin/truss/amd64-cloudabi64.c Tue Oct 13 20:55:21 2015 (r289266) +++ projects/collation/usr.bin/truss/amd64-cloudabi64.c Tue Oct 13 20:57:37 2015 (r289267) @@ -171,8 +171,8 @@ amd64_cloudabi64_fetch_retval(struct tru static struct procabi amd64_cloudabi64 = { "CloudABI ELF64", - cloudabi64_syscallnames, - nitems(cloudabi64_syscallnames), + syscallnames, + nitems(syscallnames), amd64_cloudabi64_fetch_args, amd64_cloudabi64_fetch_retval }; Copied: projects/collation/usr.bin/truss/amd64-freebsd.c (from r289266, head/usr.bin/truss/amd64-freebsd.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/collation/usr.bin/truss/amd64-freebsd.c Tue Oct 13 20:57:37 2015 (r289267, copy of r289266, head/usr.bin/truss/amd64-freebsd.c) @@ -0,0 +1,131 @@ +/* + * Copyright 1997 Sean Eric Fagan + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 Sean Eric Fagan + * 4. Neither the name of the author may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +/* FreeBSD/amd64-specific system call handling. */ + +#include <sys/ptrace.h> +#include <sys/syscall.h> + +#include <machine/reg.h> +#include <machine/psl.h> + +#include <stdio.h> + +#include "truss.h" + +#include "freebsd_syscalls.h" + +static int +amd64_fetch_args(struct trussinfo *trussinfo, u_int narg) +{ + struct ptrace_io_desc iorequest; + struct reg regs; + struct current_syscall *cs; + lwpid_t tid; + u_int i, reg; + + tid = trussinfo->curthread->tid; + cs = &trussinfo->curthread->cs; + if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return (-1); + } + + /* + * FreeBSD has two special kinds of system call redirections -- + * SYS_syscall, and SYS___syscall. The former is the old syscall() + * routine, basically; the latter is for quad-aligned arguments. + * + * The system call argument count and code from ptrace() already + * account for these, but we need to skip over %rax if it contains + * either of these values. + */ + reg = 0; + switch (regs.r_rax) { + case SYS_syscall: + case SYS___syscall: + reg++; + break; + } + + for (i = 0; i < narg && reg < 6; i++, reg++) { + switch (reg) { + case 0: cs->args[i] = regs.r_rdi; break; + case 1: cs->args[i] = regs.r_rsi; break; + case 2: cs->args[i] = regs.r_rdx; break; + case 3: cs->args[i] = regs.r_rcx; break; + case 4: cs->args[i] = regs.r_r8; break; + case 5: cs->args[i] = regs.r_r9; break; + } + } + if (narg > i) { + iorequest.piod_op = PIOD_READ_D; + iorequest.piod_offs = (void *)(regs.r_rsp + sizeof(register_t)); + iorequest.piod_addr = &cs->args[i]; + iorequest.piod_len = (narg - i) * sizeof(register_t); + ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); + if (iorequest.piod_len == 0) + return (-1); + } + + return (0); +} + +static int +amd64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) +{ + struct reg regs; + lwpid_t tid; + + tid = trussinfo->curthread->tid; + if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return (-1); + } + + retval[0] = regs.r_rax; + retval[1] = regs.r_rdx; + *errorp = !!(regs.r_rflags & PSL_C); + return (0); +} + +static struct procabi amd64_freebsd = { + "FreeBSD ELF64", + syscallnames, + nitems(syscallnames), + amd64_fetch_args, + amd64_fetch_retval +}; + +PROCABI(amd64_freebsd); Copied: projects/collation/usr.bin/truss/amd64-freebsd32.c (from r289266, head/usr.bin/truss/amd64-freebsd32.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/collation/usr.bin/truss/amd64-freebsd32.c Tue Oct 13 20:57:37 2015 (r289267, copy of r289266, head/usr.bin/truss/amd64-freebsd32.c) @@ -0,0 +1,137 @@ +/* + * Copyright 1997 Sean Eric Fagan + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 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 Sean Eric Fagan + * 4. Neither the name of the author may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +/* FreeBSD/amd64-freebsd32-specific system call handling. */ + +#include <sys/ptrace.h> +#include <sys/syscall.h> + +#include <machine/reg.h> +#include <machine/psl.h> + +#include <stdio.h> +#include <stdlib.h> + +#include "truss.h" + +#include "freebsd32_syscalls.h" + +static int +amd64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) +{ + struct ptrace_io_desc iorequest; + struct reg regs; + struct current_syscall *cs; + unsigned int args32[narg]; + unsigned long parm_offset; + lwpid_t tid; + u_int i; + + tid = trussinfo->curthread->tid; + cs = &trussinfo->curthread->cs; + if (ptrace(PT_GETREGS, tid, (caddr_t)®s, 0) < 0) { + fprintf(trussinfo->outfile, "-- CANNOT READ REGISTERS --\n"); + return (-1); + } + parm_offset = regs.r_rsp + sizeof(int); + + /* + * FreeBSD has two special kinds of system call redirections -- + * SYS_syscall, and SYS___syscall. The former is the old syscall() + * routine, basically; the latter is for quad-aligned arguments. + * + * The system call argument count and code from ptrace() already + * account for these, but we need to skip over the first argument. + */ + switch (regs.r_rax) { + case SYS_syscall: + parm_offset += sizeof(int); + break; + case SYS___syscall: + parm_offset += sizeof(quad_t); + break; + } + + iorequest.piod_op = PIOD_READ_D; + iorequest.piod_offs = (void *)parm_offset; + iorequest.piod_addr = args32; + iorequest.piod_len = sizeof(args32); + ptrace(PT_IO, tid, (caddr_t)&iorequest, 0); + if (iorequest.piod_len == 0) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510132057.t9DKvbDW064947>