Re: svn commit: r357284 - in head: include lib/libc/stdio

2020-02-01 Thread Antoine Brodin
On Thu, Jan 30, 2020 at 4:31 AM Kyle Evans  wrote:
>
> Author: kevans
> Date: Thu Jan 30 03:31:16 2020
> New Revision: 357284
> URL: https://svnweb.freebsd.org/changeset/base/357284
>
> Log:
>   stdio: provide _unlocked variants of fflush, fputc, fputs, fread, fwrite
>
>   fflush_unlocked is currently desired in ports by sysutils/metalog, and
>   redefined as the locked fflush.
>
>   fputc_unlocked, fputs_unlocked, fread_unlocked, and fwrite_unlocked are
>   currently desired in ports by devel/elfutils, and redefined as the locked
>   fputs, fread, and fwrite respectively.
>
>   Reviewed by:  kib
>   MFC after:2 weeks
>   Differential Revision:https://reviews.freebsd.org/D23336

Hi,

It seems that this change broke lang/gcc* ports.

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


svn commit: r357397 - in head/sys: arm/conf arm/include conf

2020-02-01 Thread Warner Losh
Author: imp
Date: Sun Feb  2 06:52:10 2020
New Revision: 357397
URL: https://svnweb.freebsd.org/changeset/base/357397

Log:
  Remove old boardid/mach-types support.
  
  This has been long obsolete in linux and now that all armv4/5 support
  is gone, it can be retired too.

Deleted:
  head/sys/arm/conf/genboardid.awk
  head/sys/arm/conf/mach-types
  head/sys/arm/include/board.h
Modified:
  head/sys/conf/files.arm

Modified: head/sys/conf/files.arm
==
--- head/sys/conf/files.arm Sun Feb  2 06:52:04 2020(r357396)
+++ head/sys/conf/files.arm Sun Feb  2 06:52:10 2020(r357397)
@@ -89,11 +89,6 @@ arm/arm/unwind.c optionalddb | 
kdtrace_hooks | stack
 arm/arm/vm_machdep.c   standard
 arm/arm/vfp.c  standard
 arm/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32
-board_id.h standard   \
-   dependency  "$S/arm/conf/genboardid.awk $S/arm/conf/mach-types" \
-   compile-with"${AWK} -f $S/arm/conf/genboardid.awk 
$S/arm/conf/mach-types > board_id.h" \
-   no-obj no-implicit-rule before-depend  \
-   clean   "board_id.h"
 cddl/compat/opensolaris/kern/opensolaris_atomic.c  optional !armv7 !armv6 
zfs | !armv7 !armv6 dtrace compile-with "${CDDL_C}"
 cddl/dev/dtrace/arm/dtrace_asm.S   optional dtrace 
compile-with "${DTRACE_S}"
 cddl/dev/dtrace/arm/dtrace_subr.c  optional dtrace 
compile-with "${DTRACE_C}"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357395 - in head/sys/arm: conf ralink

2020-02-01 Thread Warner Losh
Author: imp
Date: Sun Feb  2 06:51:42 2020
New Revision: 357395
URL: https://svnweb.freebsd.org/changeset/base/357395

Log:
  Remove Ralink RT1310 support
  
  This armv5 SoC is being removed consistent with the removal of
  armv5 support, per discussions in arm@ mailing list.

Deleted:
  head/sys/arm/conf/RT1310
  head/sys/arm/ralink/files.ralink
  head/sys/arm/ralink/if_fv.c
  head/sys/arm/ralink/if_fvreg.h
  head/sys/arm/ralink/rt1310_gpio.c
  head/sys/arm/ralink/rt1310_intc.c
  head/sys/arm/ralink/rt1310_machdep.c
  head/sys/arm/ralink/rt1310_timer.c
  head/sys/arm/ralink/rt1310reg.h
  head/sys/arm/ralink/rt1310var.h
  head/sys/arm/ralink/std.ralink
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357396 - in head/sys/arm: conf mv mv/discovery mv/kirkwood mv/orion

2020-02-01 Thread Warner Losh
Author: imp
Date: Sun Feb  2 06:52:04 2020
New Revision: 357396
URL: https://svnweb.freebsd.org/changeset/base/357396

Log:
  Remove armv5 marvell support.
  
  Per plans to remove armv5 support, remove the armv5 marvell discovery,
  kirkwood and orion families.

Deleted:
  head/sys/arm/conf/DB-78XXX
  head/sys/arm/conf/DB-88F5XXX
  head/sys/arm/conf/DB-88F6XXX
  head/sys/arm/conf/DOCKSTAR
  head/sys/arm/conf/DREAMPLUG-1001
  head/sys/arm/conf/SHEEVAPLUG
  head/sys/arm/conf/TS7800
  head/sys/arm/conf/std.arm
  head/sys/arm/mv/armv5_machdep.c
  head/sys/arm/mv/discovery/discovery.c
  head/sys/arm/mv/discovery/files.db78xxx
  head/sys/arm/mv/discovery/std.db78xxx
  head/sys/arm/mv/files.mv
  head/sys/arm/mv/kirkwood/files.kirkwood
  head/sys/arm/mv/kirkwood/kirkwood.c
  head/sys/arm/mv/kirkwood/std.db88f6xxx
  head/sys/arm/mv/kirkwood/std.kirkwood
  head/sys/arm/mv/orion/db88f5xxx.c
  head/sys/arm/mv/orion/files.db88f5xxx
  head/sys/arm/mv/orion/files.ts7800
  head/sys/arm/mv/orion/orion.c
  head/sys/arm/mv/orion/std.db88f5xxx
  head/sys/arm/mv/orion/std.ts7800
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357394 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/ppbus sys/modules sys/modules/vpo

2020-02-01 Thread Warner Losh
Author: imp
Date: Sun Feb  2 04:53:27 2020
New Revision: 357394
URL: https://svnweb.freebsd.org/changeset/base/357394

Log:
  Remove vpo.4
  
  The Parallel Port SCSI adapter was interesting for 100MB ZIP drives, but is no
  longer used or maintained. Remove it from the tree.
  
  The Parallel Port microsequencer (microseq.9) is now mostly unused in the 
tree,
  but remains. PPI still refrences it, but doesn't use its full functionality.
  
  Relnotes: Yes
  Reviewed by: rgrimes@, Ihor Antonov
  Discussed on: arch@
  Differential Revision:  https://reviews.freebsd.org/D23389

Deleted:
  head/share/man/man4/vpo.4
  head/sys/dev/ppbus/immio.c
  head/sys/dev/ppbus/vpo.c
  head/sys/dev/ppbus/vpoio.c
  head/sys/dev/ppbus/vpoio.h
  head/sys/modules/vpo/Makefile
Modified:
  head/ObsoleteFiles.inc
  head/share/man/man4/Makefile
  head/share/man/man4/ppbus.4
  head/share/man/man9/microseq.9
  head/sys/conf/NOTES
  head/sys/conf/files
  head/sys/conf/options
  head/sys/modules/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Sun Feb  2 04:52:28 2020(r357393)
+++ head/ObsoleteFiles.inc  Sun Feb  2 04:53:27 2020(r357394)
@@ -36,6 +36,10 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200127: vpo removed
+OLD_FILES+=usr/share/man/man4/imm.4.gz
+OLD_FILES+=usr/share/man/man4/vpo.4.gz
+
 # 20200104: gcc libssp removed
 OLD_FILES+=usr/include/ssp/ssp.h
 OLD_FILES+=usr/include/ssp/stdio.h

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileSun Feb  2 04:52:28 2020
(r357393)
+++ head/share/man/man4/MakefileSun Feb  2 04:53:27 2020
(r357394)
@@ -553,7 +553,6 @@ MAN=aac.4 \
${_vmd.4} \
${_vmm.4} \
${_vmx.4} \
-   vpo.4 \
vr.4 \
vt.4 \
vte.4 \
@@ -740,7 +739,6 @@ MLINKS+=vge.4 if_vge.4
 MLINKS+=vlan.4 if_vlan.4
 MLINKS+=vxlan.4 if_vxlan.4
 MLINKS+=${_vmx.4} ${_if_vmx.4}
-MLINKS+=vpo.4 imm.4
 MLINKS+=vr.4 if_vr.4
 MLINKS+=vte.4 if_vte.4
 MLINKS+=${_vtnet.4} ${_if_vtnet.4}

Modified: head/share/man/man4/ppbus.4
==
--- head/share/man/man4/ppbus.4 Sun Feb  2 04:52:28 2020(r357393)
+++ head/share/man/man4/ppbus.4 Sun Feb  2 04:53:27 2020(r357394)
@@ -33,8 +33,6 @@
 .Sh SYNOPSIS
 .Cd "device ppbus"
 .Pp
-.Cd "device vpo"
-.Pp
 .Cd "device lpt"
 .Cd "device plip"
 .Cd "device ppi"
@@ -66,8 +64,6 @@ and non-standard software:
 .Pp
 .Bl -column "Driver" -compact
 .It Em Driver Ta Em Description
-.It Sy vpo Ta "VPI0 parallel to Adaptec AIC-7110 SCSI controller driver" .
-It uses standard and non-standard parallel port accesses.
 .It Sy ppi Ta "Parallel port interface for general I/O"
 .It Sy pps Ta "Pulse per second Timing Interface"
 .It Sy lpbb Ta "Philips official parallel port I2C bit-banging interface"
@@ -336,22 +332,11 @@ operation (opcodes are described in
 .Xr microseq 9 ) .
 Standard I/O operations are implemented at ppbus level whereas basic I/O
 operations and microseq language are coded at adapter level for efficiency.
-.Pp
-As an example, the
-.Xr vpo 4
-driver uses microsequences to implement:
-.Bl -bullet -offset indent
-.It
-a modified version of the NIBBLE transfer mode
-.It
-various I/O sequences to initialize, select and allocate the peripheral
-.El
 .Sh SEE ALSO
 .Xr lpt 4 ,
 .Xr plip 4 ,
 .Xr ppc 4 ,
 .Xr ppi 4 ,
-.Xr vpo 4
 .Sh HISTORY
 The
 .Nm

Modified: head/share/man/man9/microseq.9
==
--- head/share/man/man9/microseq.9  Sun Feb  2 04:52:28 2020
(r357393)
+++ head/share/man/man9/microseq.9  Sun Feb  2 04:53:27 2020
(r357394)
@@ -51,7 +51,7 @@ efficient code
 Before using microsequences, you are encouraged to look at
 .Xr ppc 4
 microsequencer implementation and an example of how using it in
-.Xr vpo 4 .
+.Xr ppi 4 .
 .Sh PPBUS register model
 .Ss Background
 The parallel port model chosen for ppbus is the PC parallel port model.
@@ -477,7 +477,7 @@ executed at ppbus layer.
 .Sh SEE ALSO
 .Xr ppbus 4 ,
 .Xr ppc 4 ,
-.Xr vpo 4
+.Xr ppi 4
 .Sh HISTORY
 The
 .Nm

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Sun Feb  2 04:52:28 2020(r357393)
+++ head/sys/conf/NOTES Sun Feb  2 04:53:27 2020(r357394)
@@ -2358,9 +2358,6 @@ devicesyr827  # Silergy Corp. DC/DC 
regulator
 # are automatically probed and attached when found.
 #
 # Supported devices:
-# vpo  Iomega Zip Drive
-#  Requires SCSI disk support ('scbus' and 'da'), best
-#  performance is achieved with ports in EPP 1.9 mode.
 # lpt  Parallel Printer
 # plip Parallel network interface
 # ppi  General-purpose I/O ("Geek Port") + 

svn commit: r357393 - in head: share/man/man4 sys/dev/ppbus

2020-02-01 Thread Warner Losh
Author: imp
Date: Sun Feb  2 04:52:28 2020
New Revision: 357393
URL: https://svnweb.freebsd.org/changeset/base/357393

Log:
  Add deprecation notice to vpo.4
  
  This driver has seen no real changes for almost 20 years. It's for
  hardware that's 25 years old. It has no reports of active use, nor
  has it been seen in the NYCBug dmesg database at all. Schedule
  its removal for 13.0.
  
  Reviewed by: rgrimes@ (earlier version)
  Relnote: Yes
  MFC After: 3 days
  Differential Revision: https://reviews.freebsd.org/D23403

Modified:
  head/share/man/man4/vpo.4
  head/sys/dev/ppbus/vpo.c

Modified: head/share/man/man4/vpo.4
==
--- head/share/man/man4/vpo.4   Sat Feb  1 23:46:30 2020(r357392)
+++ head/share/man/man4/vpo.4   Sun Feb  2 04:52:28 2020(r357393)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 14, 2004
+.Dd December 21, 2019
 .Dt VPO 4
 .Os
 .Sh NAME
@@ -39,6 +39,12 @@ For one or more SCSI busses:
 The
 .Nm
 driver provide access to parallel port Iomega Zip and Jaz drives.
+.Sh DEPRECATED
+The
+.Nm
+driver is now deprecated.
+It will be removed in
+.Fx 13.0 .
 .Sh HARDWARE
 The
 .Nm

Modified: head/sys/dev/ppbus/vpo.c
==
--- head/sys/dev/ppbus/vpo.cSat Feb  1 23:46:30 2020(r357392)
+++ head/sys/dev/ppbus/vpo.cSun Feb  2 04:52:28 2020(r357393)
@@ -126,6 +126,7 @@ vpo_probe(device_t dev)
return (error);
}
ppb_unlock(ppbus);
+   gone_in_dev(dev, 13, "Hardware no longer relevant");
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357392 - head/sys/vm

2020-02-01 Thread Jeff Roberson
Author: jeff
Date: Sat Feb  1 23:46:30 2020
New Revision: 357392
URL: https://svnweb.freebsd.org/changeset/base/357392

Log:
  Fix a bug in r356776 where the page allocator was not properly restored to
  the percpu page allocator after it had been temporarily overridden by
  startup_alloc.
  
  Reported by:  pho, bdragon

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Sat Feb  1 23:16:30 2020(r357391)
+++ head/sys/vm/uma_core.c  Sat Feb  1 23:46:30 2020(r357392)
@@ -2101,7 +2101,9 @@ zone_kva_available(uma_zone_t zone, void *unused)
if ((zone->uz_flags & UMA_ZFLAG_CACHE) != 0)
return;
KEG_GET(zone, keg);
-   if (keg->uk_allocf == startup_alloc)
+   if (keg->uk_flags & UMA_ZONE_PCPU)
+   keg->uk_allocf = pcpu_page_alloc;
+   else if (keg->uk_allocf == startup_alloc)
keg->uk_allocf = page_alloc;
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357391 - head/sys/dev/tpm

2020-02-01 Thread Konstantin Belousov
Author: kib
Date: Sat Feb  1 23:16:30 2020
New Revision: 357391
URL: https://svnweb.freebsd.org/changeset/base/357391

Log:
  Fix build.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/dev/tpm/tpm_crb.c

Modified: head/sys/dev/tpm/tpm_crb.c
==
--- head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 22:07:37 2020(r357390)
+++ head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 23:16:30 2020(r357391)
@@ -299,7 +299,7 @@ tpmcrb_cancel_cmd(struct tpm_sc *sc)
return (false);
}
 
-   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
+   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR);
return (true);
 }
 
@@ -331,7 +331,7 @@ tpmcrb_transmit(struct tpm_sc *sc, size_t length)
return (EIO);
}
/* Clear cancellation bit */
-   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
+   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR);
 
/* Switch device to idle state if necessary */
if (!(RD4(sc, TPM_CRB_CTRL_STS) & TPM_CRB_CTRL_STS_IDLE_BIT)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357389 - head/sys/x86/iommu

2020-02-01 Thread Doug Moore
Author: dougm
Date: Sat Feb  1 21:47:34 2020
New Revision: 357389
URL: https://svnweb.freebsd.org/changeset/base/357389

Log:
  In dmar_gas_lowermatch, skip searching a subtree if all its addresses are 
greater than lowaddr.
  In dmar_gas_uppermatch, skip searching a subtree if all its 
gaps-between-alloctions are too small.
  
  Reviewed by:  kib
  Tested by:pho
  Differential Revision:https://reviews.freebsd.org/D23391

Modified:
  head/sys/x86/iommu/intel_gas.c

Modified: head/sys/x86/iommu/intel_gas.c
==
--- head/sys/x86/iommu/intel_gas.c  Sat Feb  1 21:43:45 2020
(r357388)
+++ head/sys/x86/iommu/intel_gas.c  Sat Feb  1 21:47:34 2020
(r357389)
@@ -370,6 +370,8 @@ dmar_gas_lowermatch(struct dmar_gas_match_args *a, str
}
if (entry->free_down < a->size + a->offset + DMAR_PAGE_SIZE)
return (ENOMEM);
+   if (entry->first >= a->common->lowaddr)
+   return (ENOMEM);
child = RB_LEFT(entry, rb_entry);
if (child != NULL && 0 == dmar_gas_lowermatch(a, child))
return (0);
@@ -390,6 +392,8 @@ dmar_gas_uppermatch(struct dmar_gas_match_args *a, str
 {
struct dmar_map_entry *child;
 
+   if (entry->free_down < a->size + a->offset + DMAR_PAGE_SIZE)
+   return (ENOMEM);
if (entry->last < a->common->highaddr)
return (ENOMEM);
child = RB_LEFT(entry, rb_entry);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357388 - head/sys/dev/tpm

2020-02-01 Thread Dimitry Andric
Author: dim
Date: Sat Feb  1 21:43:45 2020
New Revision: 357388
URL: https://svnweb.freebsd.org/changeset/base/357388

Log:
  Amend r357367 by using register values from the TPM datasheet.
  
  As Ian Lepore noted, writing ~1 to a register might have a completely
  different effect than doing a regular read-modify-write operation.
  
  Follow the TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22
  datasheet instead, and use the actual values mentioned there:
  (uint32_t)1 to cancel the command, (uint32_t)0 to clear the field.
  
  MFC after:3 days

Modified:
  head/sys/dev/tpm/tpm_crb.c

Modified: head/sys/dev/tpm/tpm_crb.c
==
--- head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 20:38:38 2020(r357387)
+++ head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 21:43:45 2020(r357388)
@@ -70,7 +70,8 @@ __FBSDID("$FreeBSD$");
 #defineTPM_CRB_CTRL_STS_ERR_BITBIT(0)
 #defineTPM_CRB_CTRL_STS_IDLE_BIT   BIT(1)
 
-#defineTPM_CRB_CTRL_CANCEL_CMD BIT(0)
+#defineTPM_CRB_CTRL_CANCEL_CMD 0x1
+#defineTPM_CRB_CTRL_CANCEL_CLEAR   0x0
 
 #defineTPM_CRB_CTRL_START_CMD  BIT(0)
 
@@ -298,7 +299,7 @@ tpmcrb_cancel_cmd(struct tpm_sc *sc)
return (false);
}
 
-   WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
+   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
return (true);
 }
 
@@ -330,7 +331,7 @@ tpmcrb_transmit(struct tpm_sc *sc, size_t length)
return (EIO);
}
/* Clear cancellation bit */
-   WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
+   WR4(sc, TPM_CRB_CTRL_CANCEL, TPM_CRB_CTRL_CANCEL_CLEAR;
 
/* Switch device to idle state if necessary */
if (!(RD4(sc, TPM_CRB_CTRL_STS) & TPM_CRB_CTRL_STS_IDLE_BIT)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Conrad Meyer
Hi Dimitry,

On Sat, Feb 1, 2020 at 12:29 PM Conrad Meyer  wrote:
> Please un-disable the Makefile warnings removed in r357349 earlier, too.

Apologies, I just now caught up to my r357366 in my SVN email.  Thank you.

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


svn commit: r357387 - in head/sys: compat/linux kern sys

2020-02-01 Thread Mateusz Guzik
Author: mjg
Date: Sat Feb  1 20:38:38 2020
New Revision: 357387
URL: https://svnweb.freebsd.org/changeset/base/357387

Log:
  cache: replace kern___getcwd with vn_getcwd
  
  The previous routine was resulting in extra data copies most notably in
  linux_getcwd.

Modified:
  head/sys/compat/linux/linux_getcwd.c
  head/sys/kern/kern_sig.c
  head/sys/kern/vfs_cache.c
  head/sys/sys/syscallsubr.h
  head/sys/sys/vnode.h

Modified: head/sys/compat/linux/linux_getcwd.c
==
--- head/sys/compat/linux/linux_getcwd.cSat Feb  1 20:38:22 2020
(r357386)
+++ head/sys/compat/linux/linux_getcwd.cSat Feb  1 20:38:38 2020
(r357387)
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -60,28 +60,25 @@ __FBSDID("$FreeBSD$");
  * Find pathname of process's current directory.
  */
 int
-linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
+linux_getcwd(struct thread *td, struct linux_getcwd_args *uap)
 {
-   char *path;
-   int error, lenused;
+   char *buf, *retbuf;
+   size_t buflen;
+   int error;
 
-   /*
-* Linux returns ERANGE instead of EINVAL.
-*/
-   if (args->bufsize < 2)
+   buflen = uap->bufsize;
+   if (__predict_false(buflen < 2))
return (ERANGE);
+   if (buflen > LINUX_PATH_MAX)
+   buflen = LINUX_PATH_MAX;
 
-   path = malloc(LINUX_PATH_MAX, M_LINUX, M_WAITOK);
-
-   error = kern___getcwd(td, path, UIO_SYSSPACE, args->bufsize,
-   LINUX_PATH_MAX);
+   buf = malloc(buflen, M_TEMP, M_WAITOK);
+   error = vn_getcwd(td, buf, , );
if (error == 0) {
-   lenused = strlen(path) + 1;
-   error = copyout(path, args->buf, lenused);
+   error = copyout(retbuf, uap->buf, buflen);
if (error == 0)
-   td->td_retval[0] = lenused;
+   td->td_retval[0] = buflen;
}
-
-   free(path, M_LINUX);
+   free(buf, M_TEMP);
return (error);
 }

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cSat Feb  1 20:38:22 2020(r357386)
+++ head/sys/kern/kern_sig.cSat Feb  1 20:38:38 2020(r357387)
@@ -3608,6 +3608,7 @@ coredump(struct thread *td)
struct vnode *vp;
struct flock lf;
struct vattr vattr;
+   size_t fullpathsize;
int error, error1, locked;
char *name; /* name of corefile */
void *rl_cookie;
@@ -3711,13 +3712,14 @@ coredump(struct thread *td)
 * if the path of the core is relative, add the current dir in front if 
it.
 */
if (name[0] != '/') {
-   fullpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
-   if (kern___getcwd(td, fullpath, UIO_SYSSPACE, MAXPATHLEN, 
MAXPATHLEN) != 0) {
-   free(fullpath, M_TEMP);
+   fullpathsize = MAXPATHLEN;
+   freepath = malloc(fullpathsize, M_TEMP, M_WAITOK);
+   if (vn_getcwd(td, freepath, , ) != 0) {
+   free(freepath, M_TEMP);
goto out2;
}
devctl_safe_quote_sb(sb, fullpath);
-   free(fullpath, M_TEMP);
+   free(freepath, M_TEMP);
sbuf_putc(sb, '/');
}
devctl_safe_quote_sb(sb, name);

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb  1 20:38:22 2020(r357386)
+++ head/sys/kern/vfs_cache.c   Sat Feb  1 20:38:38 2020(r357387)
@@ -364,7 +364,7 @@ STATNODE_COUNTER(numposhits, "Number of cache hits (po
 STATNODE_COUNTER(numnegzaps,
 "Number of cache hits (negative) we do not want to cache");
 STATNODE_COUNTER(numneghits, "Number of cache hits (negative)");
-/* These count for kern___getcwd(), too. */
+/* These count for vn_getcwd(), too. */
 STATNODE_COUNTER(numfullpathcalls, "Number of fullpath search calls");
 STATNODE_COUNTER(numfullpathfail1, "Number of fullpath search errors 
(ENOTDIR)");
 STATNODE_COUNTER(numfullpathfail2,
@@ -2171,26 +2171,31 @@ vfs_cache_lookup(struct vop_lookup_args *ap)
 int
 sys___getcwd(struct thread *td, struct __getcwd_args *uap)
 {
+   char *buf, *retbuf;
+   size_t buflen;
+   int error;
 
-   return (kern___getcwd(td, uap->buf, UIO_USERSPACE, uap->buflen,
-   MAXPATHLEN));
+   buflen = uap->buflen;
+   if (__predict_false(buflen < 2))
+   return (EINVAL);
+   if (buflen > MAXPATHLEN)
+   buflen = MAXPATHLEN;
+
+   buf = malloc(buflen, M_TEMP, M_WAITOK);
+   error = vn_getcwd(td, buf, , );
+   if (error == 0)
+   error = copyout(retbuf, uap->buf, buflen);
+ 

svn commit: r357386 - head/sys/dev/tpm

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 20:38:22 2020
New Revision: 357386
URL: https://svnweb.freebsd.org/changeset/base/357386

Log:
  tpm(4): Fix 'go ready' in TPM 2.0 TIS driver
  
  tpmtis_go_ready() read the value of the TPM_STS register, ORed
  TPM_STS_CMD_READY with it, and wrote it back.  However, the TPM Profile
  (PTP) specification states that only one bit in the write request value may
  be set to 1, or else the entire write request is ignored.
  
  Fix by just writing TPM_STS_CMD_READY.
  
  Similarly, remove the call which clears the TPM_STS_CMD_READY flag in the
  same function.  It was being ignored for the same reason.
  
  Submitted by: Darrick Lew 
  Reviewed by:  vangyzen, myself
  MFC after:if you care about stable, you might want to do so
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D23081

Modified:
  head/sys/dev/tpm/tpm_tis.c

Modified: head/sys/dev/tpm/tpm_tis.c
==
--- head/sys/dev/tpm/tpm_tis.c  Sat Feb  1 20:37:11 2020(r357385)
+++ head/sys/dev/tpm/tpm_tis.c  Sat Feb  1 20:38:22 2020(r357386)
@@ -386,12 +386,11 @@ tpmtis_go_ready(struct tpm_sc *sc)
mask = TPM_STS_CMD_RDY;
sc->intr_type = TPM_INT_STS_CMD_RDY;
 
-   OR4(sc, TPM_STS, TPM_STS_CMD_RDY);
+   WR4(sc, TPM_STS, TPM_STS_CMD_RDY);
bus_barrier(sc->mem_res, TPM_STS, 4, BUS_SPACE_BARRIER_WRITE);
if (!tpm_wait_for_u32(sc, TPM_STS, mask, mask, TPM_TIMEOUT_B))
return (false);
 
-   AND4(sc, TPM_STS, ~TPM_STS_CMD_RDY);
return (true);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357385 - head/sys/kern

2020-02-01 Thread Mateusz Guzik
Author: mjg
Date: Sat Feb  1 20:37:11 2020
New Revision: 357385
URL: https://svnweb.freebsd.org/changeset/base/357385

Log:
  cache: return the total length from vn_fullpath1
  
  This removes strlen from getcwd.

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb  1 20:36:35 2020(r357384)
+++ head/sys/kern/vfs_cache.c   Sat Feb  1 20:37:11 2020(r357385)
@@ -388,7 +388,7 @@ STATNODE_COUNTER(shrinking_skipped,
 
 static void cache_zap_locked(struct namecache *ncp, bool neg_locked);
 static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode 
*rdir,
-char *buf, char **retbuf, size_t buflen);
+char *buf, char **retbuf, size_t *buflen);
 
 static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
 
@@ -2198,15 +2198,15 @@ kern___getcwd(struct thread *td, char *buf, enum uio_s
rdir = fdp->fd_rdir;
vrefact(rdir);
FILEDESC_SUNLOCK(fdp);
-   error = vn_fullpath1(td, cdir, rdir, tmpbuf, , buflen);
+   error = vn_fullpath1(td, cdir, rdir, tmpbuf, , );
vrele(rdir);
vrele(cdir);
 
if (!error) {
if (bufseg == UIO_SYSSPACE)
-   bcopy(bp, buf, strlen(bp) + 1);
+   bcopy(bp, buf, buflen);
else
-   error = copyout(bp, buf, strlen(bp) + 1);
+   error = copyout(bp, buf, buflen);
 #ifdef KTRACE
if (KTRPOINT(curthread, KTR_NAMEI))
ktrnamei(bp);
@@ -2226,18 +2226,20 @@ vn_fullpath(struct thread *td, struct vnode *vn, char 
char *buf;
struct filedesc *fdp;
struct vnode *rdir;
+   size_t buflen;
int error;
 
if (__predict_false(vn == NULL))
return (EINVAL);
 
-   buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+   buflen = MAXPATHLEN;
+   buf = malloc(buflen, M_TEMP, M_WAITOK);
fdp = td->td_proc->p_fd;
FILEDESC_SLOCK(fdp);
rdir = fdp->fd_rdir;
vrefact(rdir);
FILEDESC_SUNLOCK(fdp);
-   error = vn_fullpath1(td, vn, rdir, buf, retbuf, MAXPATHLEN);
+   error = vn_fullpath1(td, vn, rdir, buf, retbuf, );
vrele(rdir);
 
if (!error)
@@ -2258,12 +2260,14 @@ vn_fullpath_global(struct thread *td, struct vnode *vn
 char **retbuf, char **freebuf)
 {
char *buf;
+   size_t buflen;
int error;
 
if (__predict_false(vn == NULL))
return (EINVAL);
-   buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
-   error = vn_fullpath1(td, vn, rootvnode, buf, retbuf, MAXPATHLEN);
+   buflen = MAXPATHLEN;
+   buf = malloc(buflen, M_TEMP, M_WAITOK);
+   error = vn_fullpath1(td, vn, rootvnode, buf, retbuf, );
if (!error)
*freebuf = buf;
else
@@ -2338,14 +2342,17 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char
  */
 static int
 vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
-char *buf, char **retbuf, size_t buflen)
+char *buf, char **retbuf, size_t *len)
 {
int error, slash_prefixed;
 #ifdef KDTRACE_HOOKS
struct vnode *startvp = vp;
 #endif
struct vnode *vp1;
+   size_t buflen;
 
+   buflen = *len;
+
buflen--;
buf[buflen] = '\0';
error = 0;
@@ -2436,6 +2443,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, stru
 
SDT_PROBE3(vfs, namecache, fullpath, return, 0, startvp, buf + buflen);
*retbuf = buf + buflen;
+   *len -= buflen;
return (0);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357384 - head/sys/kern

2020-02-01 Thread Mateusz Guzik
Author: mjg
Date: Sat Feb  1 20:36:35 2020
New Revision: 357384
URL: https://svnweb.freebsd.org/changeset/base/357384

Log:
  cache: remove vnode -> path lookup disablement
  
  It seems to be of little to no use even when debugging.
  
  Interested parties can resurrect it and gate compilation with a macro.

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb  1 20:34:43 2020(r357383)
+++ head/sys/kern/vfs_cache.c   Sat Feb  1 20:36:35 2020(r357384)
@@ -2167,13 +2167,6 @@ vfs_cache_lookup(struct vop_lookup_args *ap)
return (error);
 }
 
-/*
- * XXX All of these sysctls would probably be more productive dead.
- */
-static int __read_mostly disablecwd;
-SYSCTL_INT(_debug, OID_AUTO, disablecwd, CTLFLAG_RW, , 0,
-   "Disable the getcwd syscall");
-
 /* Implementation of the getcwd syscall. */
 int
 sys___getcwd(struct thread *td, struct __getcwd_args *uap)
@@ -2192,8 +2185,6 @@ kern___getcwd(struct thread *td, char *buf, enum uio_s
struct vnode *cdir, *rdir;
int error;
 
-   if (__predict_false(disablecwd))
-   return (ENODEV);
if (__predict_false(buflen < 2))
return (EINVAL);
if (buflen > path_max)
@@ -2226,14 +2217,6 @@ kern___getcwd(struct thread *td, char *buf, enum uio_s
 }
 
 /*
- * Thus begins the fullpath magic.
- */
-
-static int __read_mostly disablefullpath;
-SYSCTL_INT(_debug, OID_AUTO, disablefullpath, CTLFLAG_RW, , 0,
-"Disable the vn_fullpath function");
-
-/*
  * Retrieve the full filesystem path that correspond to a vnode from the name
  * cache (if available)
  */
@@ -2245,8 +2228,6 @@ vn_fullpath(struct thread *td, struct vnode *vn, char 
struct vnode *rdir;
int error;
 
-   if (__predict_false(disablefullpath))
-   return (ENODEV);
if (__predict_false(vn == NULL))
return (EINVAL);
 
@@ -2279,8 +2260,6 @@ vn_fullpath_global(struct thread *td, struct vnode *vn
char *buf;
int error;
 
-   if (__predict_false(disablefullpath))
-   return (ENODEV);
if (__predict_false(vn == NULL))
return (EINVAL);
buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
@@ -2515,9 +2494,6 @@ vn_commname(struct vnode *vp, char *buf, u_int buflen)
  * Requires a locked, referenced vnode.
  * Vnode is re-locked on success or ENODEV, otherwise unlocked.
  *
- * If sysctl debug.disablefullpath is set, ENODEV is returned,
- * vnode is left locked and path remain untouched.
- *
  * If vp is a directory, the call to vn_fullpath_global() always succeeds
  * because it falls back to the ".." lookup if the namecache lookup fails.
  */
@@ -2531,10 +2507,6 @@ vn_path_to_global_path(struct thread *td, struct vnode
int error;
 
ASSERT_VOP_ELOCKED(vp, __func__);
-
-   /* Return ENODEV if sysctl debug.disablefullpath==1 */
-   if (__predict_false(disablefullpath))
-   return (ENODEV);
 
/* Construct global filesystem path from vp. */
VOP_UNLOCK(vp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357383 - in head/sys: fs/devfs fs/pseudofs fs/tmpfs kern sys

2020-02-01 Thread Mateusz Guzik
Author: mjg
Date: Sat Feb  1 20:34:43 2020
New Revision: 357383
URL: https://svnweb.freebsd.org/changeset/base/357383

Log:
  vfs: consistently use size_t for buflen around VOP_VPTOCNP

Modified:
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/fs/pseudofs/pseudofs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/kern/vfs_cache.c
  head/sys/kern/vfs_default.c
  head/sys/kern/vnode_if.src
  head/sys/sys/vnode.h

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Sat Feb  1 20:33:23 2020
(r357382)
+++ head/sys/fs/devfs/devfs_vnops.c Sat Feb  1 20:34:43 2020
(r357383)
@@ -274,7 +274,7 @@ devfs_vptocnp(struct vop_vptocnp_args *ap)
struct vnode **dvp = ap->a_vpp;
struct devfs_mount *dmp;
char *buf = ap->a_buf;
-   int *buflen = ap->a_buflen;
+   size_t *buflen = ap->a_buflen;
struct devfs_dirent *dd, *de;
int i, error;
 

Modified: head/sys/fs/pseudofs/pseudofs_vnops.c
==
--- head/sys/fs/pseudofs/pseudofs_vnops.c   Sat Feb  1 20:33:23 2020
(r357382)
+++ head/sys/fs/pseudofs/pseudofs_vnops.c   Sat Feb  1 20:34:43 2020
(r357383)
@@ -377,7 +377,7 @@ pfs_vptocnp(struct vop_vptocnp_args *ap)
struct pfs_node *pn;
struct mount *mp;
char *buf = ap->a_buf;
-   int *buflen = ap->a_buflen;
+   size_t *buflen = ap->a_buflen;
char pidbuf[PFS_NAMELEN];
pid_t pid = pvd->pvd_pid;
int len, i, error, locked;

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==
--- head/sys/fs/tmpfs/tmpfs_vnops.c Sat Feb  1 20:33:23 2020
(r357382)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Sat Feb  1 20:34:43 2020
(r357383)
@@ -1491,7 +1491,7 @@ tmpfs_vptocnp_dir(struct tmpfs_node *tn, struct tmpfs_
 
 static int
 tmpfs_vptocnp_fill(struct vnode *vp, struct tmpfs_node *tn,
-struct tmpfs_node *tnp, char *buf, int *buflen, struct vnode **dvp)
+struct tmpfs_node *tnp, char *buf, size_t *buflen, struct vnode **dvp)
 {
struct tmpfs_dirent *de;
int error, i;
@@ -1531,7 +1531,7 @@ tmpfs_vptocnp(struct vop_vptocnp_args *ap)
struct tmpfs_dirent *de;
struct tmpfs_mount *tm;
char *buf;
-   int *buflen;
+   size_t *buflen;
int error;
 
vp = ap->a_vp;

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb  1 20:33:23 2020(r357382)
+++ head/sys/kern/vfs_cache.c   Sat Feb  1 20:34:43 2020(r357383)
@@ -388,7 +388,7 @@ STATNODE_COUNTER(shrinking_skipped,
 
 static void cache_zap_locked(struct namecache *ncp, bool neg_locked);
 static int vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode 
*rdir,
-char *buf, char **retbuf, u_int buflen);
+char *buf, char **retbuf, size_t buflen);
 
 static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries");
 
@@ -2293,7 +2293,7 @@ vn_fullpath_global(struct thread *td, struct vnode *vn
 }
 
 int
-vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, u_int *buflen)
+vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen)
 {
struct vnode *dvp;
struct namecache *ncp;
@@ -2359,7 +2359,7 @@ vn_vptocnp(struct vnode **vp, struct ucred *cred, char
  */
 static int
 vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
-char *buf, char **retbuf, u_int buflen)
+char *buf, char **retbuf, size_t buflen)
 {
int error, slash_prefixed;
 #ifdef KDTRACE_HOOKS

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Sat Feb  1 20:33:23 2020(r357382)
+++ head/sys/kern/vfs_default.c Sat Feb  1 20:34:43 2020(r357383)
@@ -804,7 +804,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *ap)
struct vnode **dvp = ap->a_vpp;
struct ucred *cred = ap->a_cred;
char *buf = ap->a_buf;
-   int *buflen = ap->a_buflen;
+   size_t *buflen = ap->a_buflen;
char *dirbuf, *cpos;
int i, error, eofflag, dirbuflen, flags, locked, len, covered;
off_t off;

Modified: head/sys/kern/vnode_if.src
==
--- head/sys/kern/vnode_if.src  Sat Feb  1 20:33:23 2020(r357382)
+++ head/sys/kern/vnode_if.src  Sat Feb  1 20:34:43 2020(r357383)
@@ -640,7 +640,7 @@ vop_vptocnp {
OUT struct vnode **vpp;
IN struct ucred *cred;
INOUT char *buf;
-   INOUT int *buflen;
+   INOUT size_t *buflen;
 };
 
 

Modified: head/sys/sys/vnode.h
==
--- 

svn commit: r357382 - in head: include lib/libc/stdlib

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 20:33:23 2020
New Revision: 357382
URL: https://svnweb.freebsd.org/changeset/base/357382

Log:
  rand(3): Replace implementation with one backed by random(3) algorithm
  
  rand(3)'s standard C API is extremely limiting, but we can do better
  than the historical 32-bit state Park-Miller LCG we've shipped since
  2001: r73156.
  
  The justification provided at the time for not using random(3) was that
  rand_r(3) could not be made to use the same algorithm.  That is still
  true.  However, the irrelevance of rand_r(3) is increasingly obvious.
  Since that time, POSIX has marked the interface obsolescent.  rand_r(3)
  never became part of the standard C library.  If not for API
  compatibility reasons, I would just remove rand_r(3) entirely.
  
  So, I do not believe it is a problem for rand_r(3) and rand(3) to
  diverge.
  
  The 12 ABI is maintained with compatibility definitions, but this
  revision does subtly change the API of rand(3).  The sequences of
  pseudorandom numbers produced in programs built against new versions of
  libc will differ from programs built against prior versions of libc.
  
  Reviewed by:  kevans, markm
  MFC after:no
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D23290

Modified:
  head/include/stdlib.h
  head/lib/libc/stdlib/Symbol.map
  head/lib/libc/stdlib/rand.3
  head/lib/libc/stdlib/rand.c
  head/lib/libc/stdlib/random.3
  head/lib/libc/stdlib/random.c
  head/lib/libc/stdlib/random.h

Modified: head/include/stdlib.h
==
--- head/include/stdlib.h   Sat Feb  1 20:12:02 2020(r357381)
+++ head/include/stdlib.h   Sat Feb  1 20:33:23 2020(r357382)
@@ -73,7 +73,11 @@ typedef struct {
 #defineEXIT_FAILURE1
 #defineEXIT_SUCCESS0
 
-#defineRAND_MAX0x7ffd
+/*
+ * I.e., INT_MAX; rand(3) returns a signed integer but must produce output in
+ * the range [0, RAND_MAX], so half of the possible output range is unused.
+ */
+#defineRAND_MAX0x7fff
 
 __BEGIN_DECLS
 #ifdef _XLOCALE_H_

Modified: head/lib/libc/stdlib/Symbol.map
==
--- head/lib/libc/stdlib/Symbol.map Sat Feb  1 20:12:02 2020
(r357381)
+++ head/lib/libc/stdlib/Symbol.map Sat Feb  1 20:33:23 2020
(r357382)
@@ -54,8 +54,6 @@ FBSD_1.0 {
radixsort;
sradixsort;
rand_r;
-   rand;
-   srand;
srandom;
srandomdev;
initstate;
@@ -125,6 +123,8 @@ FBSD_1.5 {
 
 FBSD_1.6 {
qsort_s;
+   rand;
+   srand;
 };
 
 FBSDprivate_1.0 {

Modified: head/lib/libc/stdlib/rand.3
==
--- head/lib/libc/stdlib/rand.3 Sat Feb  1 20:12:02 2020(r357381)
+++ head/lib/libc/stdlib/rand.3 Sat Feb  1 20:33:23 2020(r357382)
@@ -32,7 +32,7 @@
 .\" @(#)rand.3 8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd December 14, 2019
+.Dd February 1, 2020
 .Dt RAND 3
 .Os
 .Sh NAME
@@ -59,49 +59,52 @@ Applications which require unpredictable random number
 instead.
 .Ef
 .Pp
-These interfaces are obsoleted by
-.Xr random 3 .
-.Pp
 The
 .Fn rand
 function computes a sequence of pseudo-random integers in the range
 of 0 to
-.Dv RAND_MAX
-(as defined by the header file
-.In stdlib.h ) .
+.Dv RAND_MAX ,
+inclusive.
 .Pp
 The
 .Fn srand
-function sets its argument
+function seeds the algorithm with the
 .Fa seed
-as the seed for a new sequence of
-pseudo-random numbers to be returned by
-.Fn rand .
-These sequences are repeatable by calling
+parameter.
+Repeatable sequences of
+.Fn rand
+output may be obtained by calling
 .Fn srand
-with the same seed value.
+with the same
+.Fa seed .
+.Fn rand
+is implicitly initialized as if
+.Fn srand "1"
+had been invoked explicitly.
 .Pp
-If no
-.Fa seed
-value is provided, the functions are automatically
-seeded with a value of 1.
-.Pp
-The
+In
+.Fx 13 ,
+.Fn rand
+is implemented using the same 128-byte state LFSR generator algorithm as
+.Xr random 3 .
+However, the legacy
 .Fn rand_r
-function
-provides the same functionality as
-.Fn rand .
-A pointer to the context value
-.Fa ctx
-must be supplied by the caller.
-.Pp
-For better generator quality, use
-.Xr random 3
-or
-.Xr lrand48 3 .
+function is not (and can not be, because of its limited
+.Fa *ctx
+size).
+.Fn rand_r
+implements the historical, poor-quality Park-Miller 32-bit LCG and should not
+be used in new designs.
+.Sh IMPLEMENTATION NOTES
+Since
+.Fx 13 ,
+.Fn rand
+is implemented with the same generator as
+.Xr random 3 ,
+so the low-order bits should no longer be significantly worse than the
+high-order bits.
 .Sh SEE ALSO
 .Xr arc4random 3 ,
-.Xr lrand48 3 ,
 .Xr random 3 ,
 .Xr random 4
 .Sh STANDARDS
@@ -115,5 +118,32 @@ conform to
 .Pp
 The
 .Fn rand_r
-function is marked as 

Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Conrad Meyer
On Sat, Feb 1, 2020 at 10:10 AM Dimitry Andric  wrote:
>
> On 1 Feb 2020, at 18:48, Ian Lepore  wrote:
> >
> > So you're going to switch from writing 0 to writing 0xfffe, and
> > just assume that will work the same?
> > ... [Caustic sarcasm elided]
>
> Hmm, the data sheet says:
>
> Writes ( 0001h): Cancel a command
> Writes ( h): Clears field when command has been cancelled
>
> It seems the other bits in the register are not used for anything.

This seems pretty typical for TPM registers (in my limited experience).

> So indeed it is probably better to explicitly define these values as 0x0
> and 0x1, and not use ~ or ! operators at all.

I would suggest using just a plain 0 for the clear-cancel register
write, unless the other bits are actually documented to have meaning,
and that meaning is not W1C.  My recollection is that many TPM
registers only have a single real valid bit, and of those that have
more than one, many are W1C.  (AND4/OR4 RMW are inappropriate for
W1C.)  We have at least one AND4/OR4 related bugfix pending in
phabricator related to this that I should go ahead and commit:
https://reviews.freebsd.org/D23081 .

I don't think the ~0x1 (0xff...fe) will actually do anything harmful
if the other bits are ignore.  But 0 is closer to the data sheet.

Please un-disable the Makefile warnings removed in r357349 earlier, too.

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


svn commit: r357381 - head/sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 20:12:02 2020
New Revision: 357381
URL: https://svnweb.freebsd.org/changeset/base/357381

Log:
  hwpstate_intel(4): Save admin-set EPP/EPB and restore after suspend

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 20:11:25 2020
(r357380)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 20:12:02 2020
(r357381)
@@ -90,8 +90,10 @@ struct hwp_softc {
boolhwp_pkg_ctrl;
boolhwp_pkg_ctrl_en;
boolhwp_perf_bias;
+   boolhwp_perf_bias_cached;
 
-   uint64_treq; /* Cached copy of last request */
+   uint64_treq; /* Cached copy of HWP_REQUEST */
+   uint64_thwp_energy_perf_bias;   /* Cache PERF_BIAS */
 
uint8_t high;
uint8_t guaranteed;
@@ -248,7 +250,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
struct hwp_softc *sc;
device_t dev;
struct pcpu *pc;
-   uint64_t requested;
+   uint64_t epb;
uint32_t val;
int ret;
 
@@ -266,13 +268,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
thread_unlock(curthread);
 
if (sc->hwp_pref_ctrl) {
-   if (sc->hwp_pkg_ctrl_en)
-   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST_PKG, );
-   else
-   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
-   if (ret)
-   goto out;
-   val = (requested & 
IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 24;
+   val = (sc->req & 
IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 24;
val = raw_to_percent(val);
} else {
/*
@@ -280,10 +276,15 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 * uses MSR_IA32_ENERGY_PERF_BIAS instead (Intel SDM §14.4.4).
 * This register is per-core (but not HT).
 */
-   ret = rdmsr_safe(MSR_IA32_ENERGY_PERF_BIAS, );
-   if (ret)
-   goto out;
-   val = requested & IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK;
+   if (!sc->hwp_perf_bias_cached) {
+   ret = rdmsr_safe(MSR_IA32_ENERGY_PERF_BIAS, );
+   if (ret)
+   goto out;
+   sc->hwp_energy_perf_bias = epb;
+   sc->hwp_perf_bias_cached = true;
+   }
+   val = sc->hwp_energy_perf_bias &
+   IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK;
val = raw_to_percent_perf_bias(val);
}
 
@@ -301,17 +302,23 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
if (sc->hwp_pref_ctrl) {
val = percent_to_raw(val);
 
-   requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
-   requested |= val << 24u;
+   sc->req =
+   ((sc->req & ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE)
+   | (val << 24u));
 
if (sc->hwp_pkg_ctrl_en)
-   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST_PKG, requested);
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST_PKG, sc->req);
else
-   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, sc->req);
} else {
-   requested = percent_to_raw_perf_bias(val);
-   MPASS((requested & ~IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK) == 
0);
-   ret = wrmsr_safe(MSR_IA32_ENERGY_PERF_BIAS, requested);
+   val = percent_to_raw_perf_bias(val);
+   MPASS((val & ~IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK) == 0);
+
+   sc->hwp_energy_perf_bias =
+   ((sc->hwp_energy_perf_bias &
+   ~IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK) | val);
+   ret = wrmsr_safe(MSR_IA32_ENERGY_PERF_BIAS,
+   sc->hwp_energy_perf_bias);
}
 
 out:
@@ -604,10 +611,21 @@ intel_hwpstate_resume(device_t dev)
}
if (sc->hwp_pkg_ctrl_en) {
ret = wrmsr_safe(MSR_IA32_HWP_REQUEST_PKG, sc->req);
-   if (ret)
+   if (ret) {
device_printf(dev,
"Failed to set autonomous HWP for package after "
"suspend\n");
+   goto out;
+   }
+   }
+   if (!sc->hwp_pref_ctrl && sc->hwp_perf_bias_cached) {
+   ret = wrmsr_safe(MSR_IA32_ENERGY_PERF_BIAS,
+   sc->hwp_energy_perf_bias);
+   if (ret) {
+   device_printf(dev,
+ 

svn commit: r357380 - head/sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 20:11:25 2020
New Revision: 357380
URL: https://svnweb.freebsd.org/changeset/base/357380

Log:
  hwpstate_intel(4): Print failure message only on failure
  
  X-MFC-With: r357379

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:50:10 2020
(r357379)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 20:11:25 2020
(r357380)
@@ -604,8 +604,10 @@ intel_hwpstate_resume(device_t dev)
}
if (sc->hwp_pkg_ctrl_en) {
ret = wrmsr_safe(MSR_IA32_HWP_REQUEST_PKG, sc->req);
-   device_printf(dev,
-   "Failed to set autonomous HWP for package after suspend\n");
+   if (ret)
+   device_printf(dev,
+   "Failed to set autonomous HWP for package after "
+   "suspend\n");
}
 
 out:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357379 - in head: share/man/man4 sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 19:50:10 2020
New Revision: 357379
URL: https://svnweb.freebsd.org/changeset/base/357379

Log:
  hwpstate_intel(4): Detect and support PKG variant
  
  If package-level control is present, we default to using it.  Per-core
  software control may be enabled by setting the machdep.hwpstate_pkg_ctrl
  tunable to "0" in loader.conf(5).

Modified:
  head/share/man/man4/hwpstate_intel.4
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/share/man/man4/hwpstate_intel.4
==
--- head/share/man/man4/hwpstate_intel.4Sat Feb  1 19:49:13 2020
(r357378)
+++ head/share/man/man4/hwpstate_intel.4Sat Feb  1 19:50:10 2020
(r357379)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 22, 2020
+.Dd February 1, 2020
 .Dt HWPSTATE_INTEL 4
 .Os
 .Sh NAME
@@ -49,7 +49,15 @@ Can be used to disable
 .Nm ,
 allowing other compatible drivers to manage performance states, like
 .Xr est 4 .
-.Pq default 0
+Defaults to
+.Dv Qq 0
+(enabled).
+.It Va machdep.hwpstate_pkg_ctrl
+Selects between package-level control (the default) and per-core control.
+.Dv Qq 1
+selects package-level control and
+.Dv Qq 0
+selects core-level control.
 .El
 .Sh SYSCTL VARIABLES
 The following

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:49:13 2020
(r357378)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:50:10 2020
(r357379)
@@ -88,6 +88,7 @@ struct hwp_softc {
boolhwp_activity_window;
boolhwp_pref_ctrl;
boolhwp_pkg_ctrl;
+   boolhwp_pkg_ctrl_en;
boolhwp_perf_bias;
 
uint64_treq; /* Cached copy of last request */
@@ -109,6 +110,11 @@ DRIVER_MODULE(hwpstate_intel, cpu, hwpstate_intel_driv
 hwpstate_intel_devclass, NULL, NULL);
 MODULE_VERSION(hwpstate_intel, 1);
 
+static bool hwpstate_pkg_ctrl_enable = true;
+SYSCTL_BOOL(_machdep, OID_AUTO, hwpstate_pkg_ctrl, CTLFLAG_RDTUN,
+_pkg_ctrl_enable, 0,
+"Set 1 (default) to enable package-level control, 0 to disable");
+
 static int
 intel_hwp_dump_sysctl_handler(SYSCTL_HANDLER_ARGS)
 {
@@ -260,7 +266,10 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
thread_unlock(curthread);
 
if (sc->hwp_pref_ctrl) {
-   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
+   if (sc->hwp_pkg_ctrl_en)
+   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST_PKG, );
+   else
+   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
if (ret)
goto out;
val = (requested & 
IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 24;
@@ -293,9 +302,12 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
val = percent_to_raw(val);
 
requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
-   requested |= val << 24;
+   requested |= val << 24u;
 
-   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+   if (sc->hwp_pkg_ctrl_en)
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST_PKG, requested);
+   else
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
} else {
requested = percent_to_raw_perf_bias(val);
MPASS((requested & ~IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK) == 
0);
@@ -347,7 +359,6 @@ intel_hwpstate_probe(device_t dev)
return (BUS_PROBE_NOWILDCARD);
 }
 
-/* FIXME: Need to support PKG variant */
 static int
 set_autonomous_hwp(struct hwp_softc *sc)
 {
@@ -421,13 +432,32 @@ set_autonomous_hwp(struct hwp_softc *sc)
sc->req &= ~IA32_HWP_REQUEST_MAXIMUM_PERFORMANCE;
sc->req |= sc->high << 8;
 
-   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, sc->req);
+   /* If supported, request package-level control for this CPU. */
+   if (sc->hwp_pkg_ctrl_en)
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, sc->req |
+   IA32_HWP_REQUEST_PACKAGE_CONTROL);
+   else
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, sc->req);
if (ret) {
device_printf(dev,
-   "Failed to setup autonomous HWP for cpu%d\n",
-   pc->pc_cpuid);
+   "Failed to setup%s autonomous HWP for cpu%d\n",
+   sc->hwp_pkg_ctrl_en ? " PKG" : "", pc->pc_cpuid);
+   goto out;
}
 
+   /* If supported, write the PKG-wide control MSR. */
+   if (sc->hwp_pkg_ctrl_en) {
+   /*
+* "The structure of the IA32_HWP_REQUEST_PKG MSR
+* (package-level) is identical to the IA32_HWP_REQUEST MSR
+* with the exception of the 

svn commit: r357378 - in head/sys/x86: cpufreq include

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 19:49:13 2020
New Revision: 357378
URL: https://svnweb.freebsd.org/changeset/base/357378

Log:
  hwpstate_intel(4): Add fallback EPP using PERF_BIAS MSR
  
  Per Intel SDM (Vol 3b Part 2), if HWP indicates EPP (energy-performance
  preference) is not supported, the hardware instead uses the ENERGY_PERF_BIAS
  MSR.  In the epp sysctl handler, fall back to that MSR if HWP does not
  support EPP and CPUID indicates the ENERGY_PERF_BIAS MSR is supported.

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c
  head/sys/x86/include/specialreg.h

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:46:02 2020
(r357377)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:49:13 2020
(r357378)
@@ -88,6 +88,7 @@ struct hwp_softc {
boolhwp_activity_window;
boolhwp_pref_ctrl;
boolhwp_pkg_ctrl;
+   boolhwp_perf_bias;
 
uint64_treq; /* Cached copy of last request */
 
@@ -215,6 +216,26 @@ raw_to_percent(int x)
return (round10(x * 1000 / 0xff));
 }
 
+/* Range of MSR_IA32_ENERGY_PERF_BIAS is more limited: 0-0xf. */
+static inline int
+percent_to_raw_perf_bias(int x)
+{
+   /*
+* Round up so that raw values present as nice round human numbers and
+* also round-trip to the same raw value.
+*/
+   MPASS(x <= 100 && x >= 0);
+   return (((0xf * x) + 50) / 100);
+}
+
+static inline int
+raw_to_percent_perf_bias(int x)
+{
+   /* Rounding to nice human numbers despite a step interval of 6.67%. */
+   MPASS(x <= 0xf && x >= 0);
+   return (((x * 20) / 0xf) * 5);
+}
+
 static int
 sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 {
@@ -227,7 +248,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 
dev = oidp->oid_arg1;
sc = device_get_softc(dev);
-   if (!sc->hwp_pref_ctrl)
+   if (!sc->hwp_pref_ctrl && !sc->hwp_perf_bias)
return (ENODEV);
 
pc = cpu_get_pcpu(dev);
@@ -238,11 +259,24 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
sched_bind(curthread, pc->pc_cpuid);
thread_unlock(curthread);
 
-   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
-   if (ret)
-   goto out;
-   val = (requested & IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 
24;
-   val = raw_to_percent(val);
+   if (sc->hwp_pref_ctrl) {
+   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
+   if (ret)
+   goto out;
+   val = (requested & 
IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 24;
+   val = raw_to_percent(val);
+   } else {
+   /*
+* If cpuid indicates EPP is not supported, the HWP controller
+* uses MSR_IA32_ENERGY_PERF_BIAS instead (Intel SDM §14.4.4).
+* This register is per-core (but not HT).
+*/
+   ret = rdmsr_safe(MSR_IA32_ENERGY_PERF_BIAS, );
+   if (ret)
+   goto out;
+   val = requested & IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK;
+   val = raw_to_percent_perf_bias(val);
+   }
 
MPASS(val >= 0 && val <= 100);
 
@@ -255,12 +289,18 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
goto out;
}
 
-   val = percent_to_raw(val);
+   if (sc->hwp_pref_ctrl) {
+   val = percent_to_raw(val);
 
-   requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
-   requested |= val << 24;
+   requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
+   requested |= val << 24;
 
-   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+   } else {
+   requested = percent_to_raw_perf_bias(val);
+   MPASS((requested & ~IA32_ENERGY_PERF_BIAS_POLICY_HINT_MASK) == 
0);
+   ret = wrmsr_safe(MSR_IA32_ENERGY_PERF_BIAS, requested);
+   }
 
 out:
thread_lock(curthread);
@@ -405,6 +445,7 @@ intel_hwpstate_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
 
+   /* eax */
if (cpu_power_eax & CPUTPM1_HWP_NOTIFICATION)
sc->hwp_notifications = true;
if (cpu_power_eax & CPUTPM1_HWP_ACTIVITY_WINDOW)
@@ -413,6 +454,10 @@ intel_hwpstate_attach(device_t dev)
sc->hwp_pref_ctrl = true;
if (cpu_power_eax & CPUTPM1_HWP_PKG)
sc->hwp_pkg_ctrl = true;
+
+   /* ecx */
+   if (cpu_power_ecx & CPUID_PERF_BIAS)
+   sc->hwp_perf_bias = true;
 
ret = set_autonomous_hwp(sc);
if (ret)

Modified: head/sys/x86/include/specialreg.h
==

svn commit: r357376 - head/sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 19:45:27 2020
New Revision: 357376
URL: https://svnweb.freebsd.org/changeset/base/357376

Log:
  hwpstate_intel(4): Error check epp sysctl & bail if HW does not support 
feature

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:40:11 2020
(r357375)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:45:27 2020
(r357376)
@@ -218,6 +218,7 @@ raw_to_percent(int x)
 static int
 sysctl_epp_select(SYSCTL_HANDLER_ARGS)
 {
+   struct hwp_softc *sc;
device_t dev;
struct pcpu *pc;
uint64_t requested;
@@ -225,6 +226,10 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
int ret;
 
dev = oidp->oid_arg1;
+   sc = device_get_softc(dev);
+   if (!sc->hwp_pref_ctrl)
+   return (ENODEV);
+
pc = cpu_get_pcpu(dev);
if (pc == NULL)
return (ENXIO);
@@ -233,7 +238,9 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
sched_bind(curthread, pc->pc_cpuid);
thread_unlock(curthread);
 
-   rdmsr_safe(MSR_IA32_HWP_REQUEST, );
+   ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, );
+   if (ret)
+   goto out;
val = (requested & IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE) >> 
24;
val = raw_to_percent(val);
 
@@ -253,7 +260,7 @@ sysctl_epp_select(SYSCTL_HANDLER_ARGS)
requested &= ~IA32_HWP_REQUEST_ENERGY_PERFORMANCE_PREFERENCE;
requested |= val << 24;
 
-   wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
+   ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, requested);
 
 out:
thread_lock(curthread);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357377 - in head/sys/x86: cpufreq include x86

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 19:46:02 2020
New Revision: 357377
URL: https://svnweb.freebsd.org/changeset/base/357377

Log:
  x86: Add/amend some power-management comments/macros
  
  No functional change.

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c
  head/sys/x86/include/specialreg.h
  head/sys/x86/x86/identcpu.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:45:27 2020
(r357376)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 19:46:02 2020
(r357377)
@@ -329,6 +329,14 @@ set_autonomous_hwp(struct hwp_softc *sc)
/* XXX: Many MSRs aren't readable until feature is enabled */
ret = wrmsr_safe(MSR_IA32_PM_ENABLE, 1);
if (ret) {
+   /*
+* This is actually a package-level MSR, and only the first
+* write is not ignored.  So it is harmless to enable it across
+* all devices, and this allows us not to care especially in
+* which order cores (and packages) are probed.  This error
+* condition should not happen given we gate on the HWP CPUID
+* feature flag, if the Intel SDM is correct.
+*/
device_printf(dev, "Failed to enable HWP for cpu%d (%d)\n",
pc->pc_cpuid, ret);
goto out;
@@ -350,6 +358,10 @@ set_autonomous_hwp(struct hwp_softc *sc)
goto out;
}
 
+   /*
+* High and low are static; "guaranteed" is dynamic; and efficient is
+* also dynamic.
+*/
sc->high = IA32_HWP_CAPABILITIES_HIGHEST_PERFORMANCE(caps);
sc->guaranteed = IA32_HWP_CAPABILITIES_GUARANTEED_PERFORMANCE(caps);
sc->efficient = IA32_HWP_CAPABILITIES_EFFICIENT_PERFORMANCE(caps);

Modified: head/sys/x86/include/specialreg.h
==
--- head/sys/x86/include/specialreg.h   Sat Feb  1 19:45:27 2020
(r357376)
+++ head/sys/x86/include/specialreg.h   Sat Feb  1 19:46:02 2020
(r357377)
@@ -566,6 +566,7 @@
 #defineMSR_IA32_TEMPERATURE_TARGET 0x1a2
 #defineMSR_TURBO_RATIO_LIMIT   0x1ad
 #defineMSR_TURBO_RATIO_LIMIT1  0x1ae
+#defineMSR_IA32_ENERGY_PERF_BIAS   0x1b0
 #defineMSR_DEBUGCTLMSR 0x1d9
 #defineMSR_LASTBRANCHFROMIP0x1db
 #defineMSR_LASTBRANCHTOIP  0x1dc

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Sat Feb  1 19:45:27 2020(r357376)
+++ head/sys/x86/x86/identcpu.c Sat Feb  1 19:46:02 2020(r357377)
@@ -119,9 +119,9 @@ u_int   cpu_mon_min_size;   /* MONITOR minimum 
range size,
 u_int  cpu_mon_max_size;   /* MONITOR minimum range size, bytes */
 u_int  cpu_maxphyaddr; /* Max phys addr width in bits */
 u_int  cpu_power_eax;  /* 06H: Power management leaf, %eax */
-u_int  cpu_power_ebx;  /* 06H: Power management leaf, %eax */
-u_int  cpu_power_ecx;  /* 06H: Power management leaf, %eax */
-u_int  cpu_power_edx;  /* 06H: Power management leaf, %eax */
+u_int  cpu_power_ebx;  /* 06H: Power management leaf, %ebx */
+u_int  cpu_power_ecx;  /* 06H: Power management leaf, %ecx */
+u_int  cpu_power_edx;  /* 06H: Power management leaf, %edx */
 char machine[] = MACHINE;
 
 SYSCTL_UINT(_hw, OID_AUTO, via_feature_rng, CTLFLAG_RD,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357375 - head/tests/sys/net

2020-02-01 Thread Kristof Provost
Author: kp
Date: Sat Feb  1 19:40:11 2020
New Revision: 357375
URL: https://svnweb.freebsd.org/changeset/base/357375

Log:
  tests: epair: Don't fail if we load if_epair
  
  kldload() returns a positive integer when it loads a ko, so check that the
  return value is -1 to detect error cases, not that it's different from zero.
  
  MFC after:3 days
  X-MFC-With:   r357234

Modified:
  head/tests/sys/net/if_epair.c

Modified: head/tests/sys/net/if_epair.c
==
--- head/tests/sys/net/if_epair.c   Sat Feb  1 18:23:51 2020
(r357374)
+++ head/tests/sys/net/if_epair.c   Sat Feb  1 19:40:11 2020
(r357375)
@@ -53,7 +53,7 @@ ATF_TC_BODY(params, tc)
int s;
 
s = kldload("if_epair");
-   if (s != 0 && errno != EEXIST)
+   if (s == -1 && errno != EEXIST)
atf_tc_fail("Failed to load if_epair");
 
s = socket(AF_INET, SOCK_DGRAM, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r357233 - head/sys/net

2020-02-01 Thread Kristof Provost



On 30 Jan 2020, at 16:34, Gleb Smirnoff wrote:


On Tue, Jan 28, 2020 at 10:44:25PM +, Kristof Provost wrote:
K> Author: kp
K> Date: Tue Jan 28 22:44:24 2020
K> New Revision: 357233
K> URL: https://svnweb.freebsd.org/changeset/base/357233
K>
K> Log:
K>   epair: Do not abuse params to register the second interface
K>
K>   if_epair used the 'params' argument to pass a pointer to the b 
interface

K>   through if_clone_create().
K>   This pointer can be controlled by userspace, which means it could 
be abused to

K>   trigger a panic. While this requires PRIV_NET_IFCREATE
K>   privileges those are assigned to vnet jails, which means that 
vnet jails

K>   could panic the system.
K>
K>   Reported by:Ilja Van Sprundel 
...
K> Modified: head/sys/net/if_clone.h
K> 
==

K> --- head/sys/net/if_clone.h   Tue Jan 28 21:46:59 2020(r357232)
K> +++ head/sys/net/if_clone.h   Tue Jan 28 22:44:24 2020(r357233)
K> @@ -79,7 +79,8 @@ int if_clone_list(struct if_clonereq *);
K>  struct if_clone *if_clone_findifc(struct ifnet *);
K>  void if_clone_addgroup(struct ifnet *, struct if_clone *);
K>
K> -/* The below interface used only by epair(4). */
K> +/* The below interfaces are used only by epair(4). */
K> +void if_clone_addif(struct if_clone *, struct ifnet *);
K>  int  if_clone_destroyif(struct if_clone *, struct ifnet *);

IMHO, makes sense to move all these declaration into if_epair.c 
itself.



Yeah, that does make sense.

One minor issue is that it turns out that if_clone_destroyif() isn’t 
just used by if_epair, but also by the wifi code.


How does this look?

diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c
index acc392ead16..452605b0464 100644
--- a/sys/net/if_clone.c
+++ b/sys/net/if_clone.c
	@@ -106,6 +106,9 @@ static int ifc_simple_match(struct if_clone *, 
const char *);
	 static int ifc_simple_create(struct if_clone *, char *, size_t, 
caddr_t);

 static int ifc_simple_destroy(struct if_clone *, struct ifnet *);

+/* The below interface is used only by epair(4). */
+void   if_clone_addif(struct if_clone *, struct ifnet *);
+
 static struct mtx if_cloners_mtx;
	 MTX_SYSINIT(if_cloners_lock, _cloners_mtx, "if_cloners lock", 
MTX_DEF);

 VNET_DEFINE_STATIC(int, if_cloners_count);
diff --git a/sys/net/if_clone.h b/sys/net/if_clone.h
index ed7d6f4d02d..c1ddf89c72d 100644
--- a/sys/net/if_clone.h
+++ b/sys/net/if_clone.h
@@ -79,8 +79,7 @@ int   if_clone_list(struct if_clonereq *);
 struct if_clone *if_clone_findifc(struct ifnet *);
 void   if_clone_addgroup(struct ifnet *, struct if_clone *);

-/* The below interfaces are used only by epair(4). */
-void   if_clone_addif(struct if_clone *, struct ifnet *);
+/* The below interface is  used only by epair(4) and ieee80211. */
 intif_clone_destroyif(struct if_clone *, struct ifnet *);

 #endif /* _KERNEL */
diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c
index 376bdbe9117..7eff03b840f 100644
--- a/sys/net/if_epair.c
+++ b/sys/net/if_epair.c
	@@ -94,6 +94,9 @@ SYSCTL_INT(_net_link_epair, OID_AUTO, epair_debug, 
CTLFLAG_RW,

 #defineDPRINTF(fmt, arg...)
 #endif

+/* if_clone private function, just for us. */
+extern void if_clone_addif(struct if_clone *, struct ifnet *);
+
 static void epair_nh_sintr(struct mbuf *);
	 static struct mbuf *epair_nh_m2cpuid(struct mbuf *, uintptr_t, u_int 
*);

 static void epair_nh_drainedcpu(u_int);

Best regards,
Kristof
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r357314 - in head/sys: conf kern sys vm

2020-02-01 Thread Li-Wen Hsu
On Fri, Jan 31, 2020 at 8:50 AM Jeff Roberson  wrote:
>
> Author: jeff
> Date: Fri Jan 31 00:49:51 2020
> New Revision: 357314
> URL: https://svnweb.freebsd.org/changeset/base/357314
>
> Log:
>   Implement a safe memory reclamation feature that is tightly coupled with 
> UMA.
>
>   This is in the same family of algorithms as Epoch/QSBR/RCU/PARSEC but is
>   a unique algorithm.  This has 3x the performance of epoch in a write heavy
>   workload with less than half of the read side cost.  The memory overhead
>   is significantly lessened by limiting the free-to-use latency.  A synthetic
>   test uses 1/20th of the memory vs Epoch.  There is significant further
>   discussion in the comments and code review.
>
>   This code should be considered experimental.  I will write a man page after
>   it has settled.  After further validation the VM will begin using this
>   feature to permit lockless page lookups.
>
>   Both markj and cperciva tested on arm64 at large core counts to verify
>   fences on weaker ordering architectures.  I will commit a stress testing
>   tool in a follow-up.
>
>   Reviewed by:  mmacy, markj, rlibby, hselasky
>   Discussed with:   sbahara
>   Differential Revision:https://reviews.freebsd.org/D22586

I found it might cause i386 boot fail:

Kernel page fault with the following non-sleepable locks held:
exclusive sleep mutex kernel arena (kernel arena) r = 0 (0x1d99d80)
locked @ /usr/src/sys/kern/subr_vmem.c:1344

Full backtrace is available at
https://ci.freebsd.org/job/FreeBSD-head-i386-test/8275/console

Please help checking this.

Thanks,
Li-Wen
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357374 - head/sys/vm

2020-02-01 Thread Mark Johnston
Author: markj
Date: Sat Feb  1 18:23:51 2020
New Revision: 357374
URL: https://svnweb.freebsd.org/changeset/base/357374

Log:
  Remove a couple of lingering usages of the page lock.
  
  Update vm_page_scan_contig() and vm_page_reclaim_run() to stop using
  vm_page_change_lock().  It has no use after r356157.  Remove
  vm_page_change_lock() now that it has no users.
  
  Remove an unncessary check for wirings in vm_page_scan_contig(), which
  was previously checking twice.  The check is racy until
  vm_page_reclaim_run() ensures that the page is unmapped, so one check is
  sufficient.
  
  Reviewed by:  jeff, kib (previous versions)
  Tested by:pho (previous version)
  Differential Revision:https://reviews.freebsd.org/D23279

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Sat Feb  1 17:54:46 2020(r357373)
+++ head/sys/vm/vm_page.c   Sat Feb  1 18:23:51 2020(r357374)
@@ -1156,23 +1156,6 @@ vm_page_xunbusy_hard_unchecked(vm_page_t m)
 }
 
 /*
- * Avoid releasing and reacquiring the same page lock.
- */
-void
-vm_page_change_lock(vm_page_t m, struct mtx **mtx)
-{
-   struct mtx *mtx1;
-
-   mtx1 = vm_page_lockptr(m);
-   if (*mtx == mtx1)
-   return;
-   if (*mtx != NULL)
-   mtx_unlock(*mtx);
-   *mtx = mtx1;
-   mtx_lock(mtx1);
-}
-
-/*
  * vm_page_unhold_pages:
  *
  * Unhold each of the pages that is referenced by the given array.
@@ -2444,7 +2427,6 @@ vm_page_t
 vm_page_scan_contig(u_long npages, vm_page_t m_start, vm_page_t m_end,
 u_long alignment, vm_paddr_t boundary, int options)
 {
-   struct mtx *m_mtx;
vm_object_t object;
vm_paddr_t pa;
vm_page_t m, m_run;
@@ -2458,7 +2440,6 @@ vm_page_scan_contig(u_long npages, vm_page_t m_start, 
KASSERT(powerof2(boundary), ("boundary is not a power of 2"));
m_run = NULL;
run_len = 0;
-   m_mtx = NULL;
for (m = m_start; m < m_end && run_len < npages; m += m_inc) {
KASSERT((m->flags & PG_MARKER) == 0,
("page %p is PG_MARKER", m));
@@ -2489,9 +2470,8 @@ vm_page_scan_contig(u_long npages, vm_page_t m_start, 
} else
KASSERT(m_run != NULL, ("m_run == NULL"));
 
-   vm_page_change_lock(m, _mtx);
-   m_inc = 1;
 retry:
+   m_inc = 1;
if (vm_page_wired(m))
run_ext = 0;
 #if VM_NRESERVLEVEL > 0
@@ -2504,23 +2484,17 @@ retry:
pa);
}
 #endif
-   else if ((object = m->object) != NULL) {
+   else if ((object =
+   (vm_object_t)atomic_load_ptr(>object)) != NULL) {
/*
 * The page is considered eligible for relocation if
 * and only if it could be laundered or reclaimed by
 * the page daemon.
 */
-   if (!VM_OBJECT_TRYRLOCK(object)) {
-   mtx_unlock(m_mtx);
-   VM_OBJECT_RLOCK(object);
-   mtx_lock(m_mtx);
-   if (m->object != object) {
-   /*
-* The page may have been freed.
-*/
-   VM_OBJECT_RUNLOCK(object);
-   goto retry;
-   }
+   VM_OBJECT_RLOCK(object);
+   if (object != m->object) {
+   VM_OBJECT_RUNLOCK(object);
+   goto retry;
}
/* Don't care: PG_NODUMP, PG_ZERO. */
if (object->type != OBJT_DEFAULT &&
@@ -2537,8 +2511,7 @@ retry:
vm_reserv_size(level)) - pa);
 #endif
} else if (object->memattr == VM_MEMATTR_DEFAULT &&
-   vm_page_queue(m) != PQ_NONE && !vm_page_busied(m) &&
-   !vm_page_wired(m)) {
+   vm_page_queue(m) != PQ_NONE && !vm_page_busied(m)) {
/*
 * The page is allocated but eligible for
 * relocation.  Extend the current run by one
@@ -2605,8 +2578,6 @@ retry:
}
}
}
-   if (m_mtx != NULL)
-   mtx_unlock(m_mtx);
if (run_len >= npages)
return (m_run);
return (NULL);
@@ -2634,7 +2605,6 @@ vm_page_reclaim_run(int req_class, int domain, u_long 
 vm_paddr_t high)
 {

Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Dimitry Andric
On 1 Feb 2020, at 18:55, Ian Lepore  wrote:
> 
> On Fri, 2020-01-31 at 19:36 +, Dimitry Andric wrote:
>> Author: dim
>> Date: Fri Jan 31 19:36:14 2020
>> New Revision: 357349
>> URL: https://svnweb.freebsd.org/changeset/base/357349
>> 
>> Log:
>>  Merge r357348 from the clang 10.0.0 import branch:
>> 
>>  Disable new clang 10.0.0 warnings about converting the result of shift
>>  operations to a boolean in tpm(4):
>> 
>>  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a 
>> boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
>>  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
>>^
>>  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 
>> 'TPM_CRB_CTRL_CANCEL_CMD'
>>  #define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
>>  ^
>>  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
>>  #define BIT(x) (1 << (x))
>>^
>> 
>>  Such warnings can be useful in C++ contexts, but not so much in kernel
>>  drivers, where this type of bit twiddling is commonplace.  So disable it
>>  for this case.
>> 
> 
> I think the point of the compiler warning about shift in a boolean
> context is the same as warning about assignment in a boolean
> context.  I.e,
> 
>   if (a << 3)
> 
> might be a typo for
> 
>   if (a < 3)
> 
> in the same way as "a = 3" might have been intended to be "a == 3".

Yes, clang inherited this warning from gcc, where it says in:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wint-in-bool-context

-Wint-in-bool-context
  Warn for suspicious use of integer values where boolean values are
  expected, such as conditional expressions (?:) using non-boolean
  integer constants in boolean context, like if (a <= b ? 2 : 3). Or
  left shifting of signed integers in boolean context, like for (a = 0;
  1 << a; a++);. Likewise for all kinds of multiplications regardless of
  the data type. This warning is enabled by -Wall.

-Dimitry



signature.asc
Description: Message signed with OpenPGP


Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Dimitry Andric
On 1 Feb 2020, at 18:48, Ian Lepore  wrote:
> 
> On Fri, 2020-01-31 at 23:36 +0100, Dimitry Andric wrote:
>> Hmm yes, you are quite right.  Other parts of the code also seem to
>> use ~TPM_XXX, and the WR4() inline function called takes a
>> uint32_t.  I'll revert my change and apply the tilde version instead!
>> 
>> -Dimitry
>> 
> 
> So you're going to switch from writing 0 to writing 0xfffe, and
> just assume that will work the same?  Like, without looking at the
> datasheet or TRM for the device?  Surely those other 31 bits you're
> turning on in a control register can't do anything important, can they?

Hmm, the data sheet says:

Writes ( 0001h): Cancel a command
Writes ( h): Clears field when command has been cancelled

It seems the other bits in the register are not used for anything.

So indeed it is probably better to explicitly define these values as 0x0
and 0x1, and not use ~ or ! operators at all.


> I haven't looked at the code, but I'll bet the other places that are
> using ~SYMBOLNAME are doing so in the context of read-modify-write in a
> way that preserves existing bits, which is completely different than
> just turning on 31 bits as a side effect of turning one bit off.

There aren't many places, but they tend to use the AND4() and OR4()
inline functions, which do are more usual pattern of read-modify-write.

I'll fix up the code again...

-Dimitry



signature.asc
Description: Message signed with OpenPGP


Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Ian Lepore
On Fri, 2020-01-31 at 19:36 +, Dimitry Andric wrote:
> Author: dim
> Date: Fri Jan 31 19:36:14 2020
> New Revision: 357349
> URL: https://svnweb.freebsd.org/changeset/base/357349
> 
> Log:
>   Merge r357348 from the clang 10.0.0 import branch:
>   
>   Disable new clang 10.0.0 warnings about converting the result of shift
>   operations to a boolean in tpm(4):
>   
>   sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a 
> boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
>   WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
> ^
>   sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 
> 'TPM_CRB_CTRL_CANCEL_CMD'
>   #define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
>   ^
>   sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
>   #define BIT(x) (1 << (x))
> ^
>   
>   Such warnings can be useful in C++ contexts, but not so much in kernel
>   drivers, where this type of bit twiddling is commonplace.  So disable it
>   for this case.
>   

I think the point of the compiler warning about shift in a boolean
context is the same as warning about assignment in a boolean
context.  I.e,

   if (a << 3)

might be a typo for 

   if (a < 3)

in the same way as "a = 3" might have been intended to be "a == 3".

When this type of bit twiddling is used in drivers, it's almost always
combined with an & or | operator, which I assume the compiler then
won't complain about (or you would have seen thousands of warnings
while compiling in dev/*).

-- Ian


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


svn commit: r357373 - head/sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 17:54:46 2020
New Revision: 357373
URL: https://svnweb.freebsd.org/changeset/base/357373

Log:
  intel_hwpstate(4): Use identcpu-cached cpuid 6 leaf
  
  No functional change.

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 17:30:45 2020
(r357372)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 17:54:46 2020
(r357373)
@@ -266,8 +266,6 @@ out:
 void
 intel_hwpstate_identify(driver_t *driver, device_t parent)
 {
-   uint32_t regs[4];
-
if (device_find_child(parent, "hwpstate_intel", -1) != NULL)
return;
 
@@ -279,25 +277,12 @@ intel_hwpstate_identify(driver_t *driver, device_t par
 
/*
 * Intel SDM 14.4.1 (HWP Programming Interfaces):
-*   The CPUID instruction allows software to discover the presence of
-*   HWP support in an Intel processor. Specifically, execute CPUID
-*   instruction with EAX=06H as input will return 5 bit flags covering
-*   the following aspects in bits 7 through 11 of CPUID.06H:EAX.
-*/
-
-   if (cpu_high < 6)
-   return;
-
-   /*
-* Intel SDM 14.4.1 (HWP Programming Interfaces):
 *   Availability of HWP baseline resource and capability,
 *   CPUID.06H:EAX[bit 7]: If this bit is set, HWP provides several new
 *   architectural MSRs: IA32_PM_ENABLE, IA32_HWP_CAPABILITIES,
 *   IA32_HWP_REQUEST, IA32_HWP_STATUS.
 */
-
-   do_cpuid(6, regs);
-   if ((regs[0] & CPUTPM1_HWP) == 0)
+   if ((cpu_power_eax & CPUTPM1_HWP) == 0)
return;
 
if (BUS_ADD_CHILD(parent, 10, "hwpstate_intel", -1) == NULL)
@@ -396,20 +381,18 @@ static int
 intel_hwpstate_attach(device_t dev)
 {
struct hwp_softc *sc;
-   uint32_t regs[4];
int ret;
 
sc = device_get_softc(dev);
sc->dev = dev;
 
-   do_cpuid(6, regs);
-   if (regs[0] & CPUTPM1_HWP_NOTIFICATION)
+   if (cpu_power_eax & CPUTPM1_HWP_NOTIFICATION)
sc->hwp_notifications = true;
-   if (regs[0] & CPUTPM1_HWP_ACTIVITY_WINDOW)
+   if (cpu_power_eax & CPUTPM1_HWP_ACTIVITY_WINDOW)
sc->hwp_activity_window = true;
-   if (regs[0] & CPUTPM1_HWP_PERF_PREF)
+   if (cpu_power_eax & CPUTPM1_HWP_PERF_PREF)
sc->hwp_pref_ctrl = true;
-   if (regs[0] & CPUTPM1_HWP_PKG)
+   if (cpu_power_eax & CPUTPM1_HWP_PKG)
sc->hwp_pkg_ctrl = true;
 
ret = set_autonomous_hwp(sc);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r357349 - in head/sys: conf modules/tpm

2020-02-01 Thread Ian Lepore
On Fri, 2020-01-31 at 23:36 +0100, Dimitry Andric wrote:
> Hmm yes, you are quite right.  Other parts of the code also seem to
> use ~TPM_XXX, and the WR4() inline function called takes a
> uint32_t.  I'll revert my change and apply the tilde version instead!
> 
> -Dimitry
> 

So you're going to switch from writing 0 to writing 0xfffe, and
just assume that will work the same?  Like, without looking at the
datasheet or TRM for the device?  Surely those other 31 bits you're
turning on in a control register can't do anything important, can they?

I haven't looked at the code, but I'll bet the other places that are
using ~SYMBOLNAME are doing so in the context of read-modify-write in a
way that preserves existing bits, which is completely different than
just turning on 31 bits as a side effect of turning one bit off.

-- Ian



> > On 31 Jan 2020, at 22:13, Conrad Meyer  wrote:
> > 
> > Hi Dimitry,
> > 
> > Do you think maybe the intent is to use ~TPM_CRB_CTRL_CANCEL_CMD
> > instead?  Plain "0" might also make sense.  But I think the
> > compiler
> > is right here and the warning should not be disabled — !BIT(foo)
> > doesn't really make sense for a register.  It happens to affect the
> > right bit only because CANCEL_CMD is BIT(0).
> > 
> > Thanks,
> > Conrad
> > 
> > On Fri, Jan 31, 2020 at 11:36 AM Dimitry Andric 
> > wrote:
> > > 
> > > Author: dim
> > > Date: Fri Jan 31 19:36:14 2020
> > > New Revision: 357349
> > > URL: https://svnweb.freebsd.org/changeset/base/357349
> > > 
> > > Log:
> > >  Merge r357348 from the clang 10.0.0 import branch:
> > > 
> > >  Disable new clang 10.0.0 warnings about converting the result of
> > > shift
> > >  operations to a boolean in tpm(4):
> > > 
> > >  sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of
> > > '<<' to a boolean; did you mean '(1 << (0)) != 0'? [-Werror,-
> > > Wint-in-bool-context]
> > >  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
> > >^
> > >  sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro
> > > 'TPM_CRB_CTRL_CANCEL_CMD'
> > >  #define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
> > >  ^
> > >  sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
> > >  #define BIT(x) (1 << (x))
> > >^
> > > 
> > >  Such warnings can be useful in C++ contexts, but not so much in
> > > kernel
> > >  drivers, where this type of bit twiddling is commonplace.  So
> > > disable it
> > >  for this case.
> > > 
> > >  MFC after:3 days
> > > 
> > > Modified:
> > >  head/sys/conf/files.amd64
> > >  head/sys/conf/kern.mk
> > >  head/sys/modules/tpm/Makefile
> > > Directory Properties:
> > >  head/   (props changed)
> > > 
> > > Modified: head/sys/conf/files.amd64
> > > =
> > > =
> > > --- head/sys/conf/files.amd64   Fri Jan 31 19:35:21
> > > 2020(r357348)
> > > +++ head/sys/conf/files.amd64   Fri Jan 31 19:36:14
> > > 2020(r357349)
> > > @@ -323,7 +323,8 @@
> > > dev/syscons/scvesactl.c optionalsc vga vesa
> > > dev/syscons/scvgarndr.coptionalsc vga
> > > dev/tpm/tpm.c  optionaltpm
> > > dev/tpm/tpm20.coptionaltpm
> > > -dev/tpm/tpm_crb.c  optionaltpm acpi
> > > +dev/tpm/tpm_crb.c  optionaltpm acpi \
> > > +   compile-with "${NORMAL_C} ${NO_WINT_IN_BOOL_CONTEXT}"
> > > dev/tpm/tpm_tis.c  optionaltpm acpi
> > > dev/tpm/tpm_acpi.c optionaltpm acpi
> > > dev/tpm/tpm_isa.c  optionaltpm isa
> > > 
> > > Modified: head/sys/conf/kern.mk
> > > =
> > > =
> > > --- head/sys/conf/kern.mk   Fri Jan 31 19:35:21
> > > 2020(r357348)
> > > +++ head/sys/conf/kern.mk   Fri Jan 31 19:36:14
> > > 2020(r357349)
> > > @@ -37,6 +37,9 @@ CWARNEXTRA+=  -Wno-error-shift-negative-value
> > > .if ${COMPILER_VERSION} >= 4
> > > CWARNEXTRA+=   -Wno-address-of-packed-member
> > > .endif
> > > +.if ${COMPILER_VERSION} >= 10
> > > +NO_WINT_IN_BOOL_CONTEXT=   -Wno-int-in-bool-context
> > > +.endif
> > > .endif
> > > 
> > > .if ${COMPILER_TYPE} == "gcc"
> > > 
> > > Modified: head/sys/modules/tpm/Makefile
> > > =
> > > =
> > > --- head/sys/modules/tpm/Makefile   Fri Jan 31 19:35:21
> > > 2020(r357348)
> > > +++ head/sys/modules/tpm/Makefile   Fri Jan 31 19:36:14
> > > 2020(r357349)
> > > @@ -11,3 +11,5 @@ SRCS+=tpm_isa.c tpm_acpi.c isa_if.h
> > > opt_acpi.h acpi_i
> > > SRCS+= tpm20.c tpm_crb.c tpm_tis.c opt_tpm.h
> > > 
> > > .include 
> > > +
> > > +CWARNFLAGS.tpm_crb.c+= ${NO_WINT_IN_BOOL_CONTEXT}
> 
> 


___

svn commit: r357372 - head/sys/x86/cpufreq

2020-02-01 Thread Conrad Meyer
Author: cem
Date: Sat Feb  1 17:30:45 2020
New Revision: 357372
URL: https://svnweb.freebsd.org/changeset/base/357372

Log:
  intel_hwpstate(4): Don't leak bound thread in error conditions
  
  I don't know why a Skylake CPU with the HWP feature bit present would trap
  on MSR reads of the HWP registers, but if this occurs, do not leave the
  attach thread bound.  This could conceivably cause reported hangs, although
  I have no evidence that this is the cause.
  
  Reported by:  ae@, Andreas Nilsson 
  X-MFC-With:   r357002

Modified:
  head/sys/x86/cpufreq/hwpstate_intel.c

Modified: head/sys/x86/cpufreq/hwpstate_intel.c
==
--- head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 17:13:52 2020
(r357371)
+++ head/sys/x86/cpufreq/hwpstate_intel.c   Sat Feb  1 17:30:45 2020
(r357372)
@@ -343,12 +343,20 @@ set_autonomous_hwp(struct hwp_softc *sc)
}
 
ret = rdmsr_safe(MSR_IA32_HWP_REQUEST, >req);
-   if (ret)
-   return (ret);
+   if (ret) {
+   device_printf(dev,
+   "Failed to read HWP request MSR for cpu%d (%d)\n",
+   pc->pc_cpuid, ret);
+   goto out;
+   }
 
ret = rdmsr_safe(MSR_IA32_HWP_CAPABILITIES, );
-   if (ret)
-   return (ret);
+   if (ret) {
+   device_printf(dev,
+   "Failed to read HWP capabilities MSR for cpu%d (%d)\n",
+   pc->pc_cpuid, ret);
+   goto out;
+   }
 
sc->high = IA32_HWP_CAPABILITIES_HIGHEST_PERFORMANCE(caps);
sc->guaranteed = IA32_HWP_CAPABILITIES_GUARANTEED_PERFORMANCE(caps);
@@ -372,7 +380,7 @@ set_autonomous_hwp(struct hwp_softc *sc)
ret = wrmsr_safe(MSR_IA32_HWP_REQUEST, sc->req);
if (ret) {
device_printf(dev,
-   "Failed to setup autonomous HWP for cpu%d (file a bug)\n",
+   "Failed to setup autonomous HWP for cpu%d\n",
pc->pc_cpuid);
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357371 - head/sys/riscv/sifive

2020-02-01 Thread Mitchell Horne
Author: mhorne
Date: Sat Feb  1 17:13:52 2020
New Revision: 357371
URL: https://svnweb.freebsd.org/changeset/base/357371

Log:
  prci: register tlclk as a fixed clock
  
  The PRCI exports tlclk as a constant fixed divisor clock, defined as 1/2
  of the coreclk frequency. In older FU540 device trees (such as the one
  provided by SiFive), tlclk is represented as its own entity, and is
  automatically registered as a fixed-divisor-clock. Unfortunately the
  upstream FU540 device tree (that we have in our tree) represents tlclk
  as an output of the PRCI block, and we must register it manually. At
  worst, users of the old device tree will end up with an unreferenced
  duplicate of tlclk.
  
  This fixes device attachment for the SiFive UART on newer device trees,
  since it references tlclk via the PRCI.
  
  Reviewed by:  kp
  Differential Revision:https://reviews.freebsd.org/D23406

Modified:
  head/sys/riscv/sifive/fu540_prci.c

Modified: head/sys/riscv/sifive/fu540_prci.c
==
--- head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:12:15 2020
(r357370)
+++ head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:13:52 2020
(r357371)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -119,6 +120,17 @@ struct prci_pll_def pll_clks[] = {
PLL(PRCI_CLK_GEMGXLPLL, "gemgxclk", PRCI_GEMGXLPLL_CFG0),
 };
 
+/* Fixed divisor clock TLCLK. */
+struct clk_fixed_def tlclk_def = {
+   .clkdef.id = PRCI_CLK_TLCLK,
+   .clkdef.name = "prci_tlclk",
+   .clkdef.parent_names = (const char *[]){"coreclk"},
+   .clkdef.parent_cnt = 1,
+   .clkdef.flags = CLK_NODE_STATIC_STRINGS,
+   .mult = 1,
+   .div = 2,
+};
+
 static int
 prci_clk_pll_init(struct clknode *clk, device_t dev)
 {
@@ -270,6 +282,16 @@ prci_attach(device_t dev)
clkdef.name = pll_clks[i].name;
prci_pll_register(sc, , pll_clks[i].reg);
}
+
+   /*
+* Register the fixed clock "tlclk".
+*
+* If an older device tree is being used, tlclk may appear as its own
+* entity in the device tree, under soc/tlclk. If this is the case it
+* will be registered automatically by the fixed_clk driver, and the
+* version we register here will be an unreferenced duplicate.
+*/
+   clknode_fixed_register(sc->clkdom, _def);
 
error = clkdom_finit(sc->clkdom);
if (error)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357370 - head/sys/riscv/sifive

2020-02-01 Thread Mitchell Horne
Author: mhorne
Date: Sat Feb  1 17:12:15 2020
New Revision: 357370
URL: https://svnweb.freebsd.org/changeset/base/357370

Log:
  prci: fix up compat
  
  Add two additional compat strings that can be used to identify the PRCI.
  
  With newer device trees the PRCI has two parents, hfclk and rtcclk, so
  allow the driver to attach when more than one parent is found.
  
  Reviewed by:  kp
  Differential Revision:https://reviews.freebsd.org/D23405

Modified:
  head/sys/riscv/sifive/fu540_prci.c

Modified: head/sys/riscv/sifive/fu540_prci.c
==
--- head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:09:56 2020
(r357369)
+++ head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:12:15 2020
(r357370)
@@ -52,6 +52,13 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+static struct ofw_compat_data compat_data[] = {
+   { "sifive,aloeprci0",   1 },
+   { "sifive,ux00prci0",   1 },
+   { "sifive,fu540-c000-prci", 1 },
+   { NULL, 0 },
+};
+
 static struct resource_spec prci_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
RESOURCE_SPEC_END
@@ -177,7 +184,7 @@ prci_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
 
-   if (!ofw_bus_is_compatible(dev, "sifive,aloeprci0"))
+   if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
 
device_set_desc(dev, "SiFive FU540 Power Reset Clocking Interrupt");
@@ -229,7 +236,7 @@ prci_attach(device_t dev)
node = ofw_bus_get_node(dev);
error = ofw_bus_parse_xref_list_get_length(node, "clocks",
"#clock-cells", );
-   if (error != 0 || ncells != 1) {
+   if (error != 0 || ncells < 1) {
device_printf(dev, "couldn't find parent clock\n");
goto fail;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357369 - head/sys/riscv/sifive

2020-02-01 Thread Mitchell Horne
Author: mhorne
Date: Sat Feb  1 17:09:56 2020
New Revision: 357369
URL: https://svnweb.freebsd.org/changeset/base/357369

Log:
  prci: register the DDR and GEMGX PLLs
  
  The PRCI module exports three PLLs. Currently only the coreclk/corepll
  is registered, so add the logic to register the DDR (memory) and GEMGX
  (ethernet) clocks as well. These clocks are unused at the moment.
  
  Reviewed by:  kp
  Differential Revision:https://reviews.freebsd.org/D23404

Modified:
  head/sys/riscv/sifive/fu540_prci.c

Modified: head/sys/riscv/sifive/fu540_prci.c
==
--- head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:03:31 2020
(r357368)
+++ head/sys/riscv/sifive/fu540_prci.c  Sat Feb  1 17:09:56 2020
(r357369)
@@ -50,6 +50,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 static struct resource_spec prci_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
RESOURCE_SPEC_END
@@ -68,6 +70,7 @@ struct prci_softc {
 
 struct prci_clk_pll_sc {
struct prci_softc   *parent_sc;
+   uint32_treg;
 };
 
 #definePRCI_LOCK(sc)   mtx_lock(&(sc)->mtx)
@@ -75,17 +78,40 @@ struct prci_clk_pll_sc {
 #definePRCI_ASSERT_LOCKED(sc)  mtx_assert(&(sc)->mtx, 
MA_OWNED);
 #definePRCI_ASSERT_UNLOCKED(sc)mtx_assert(&(sc)->mtx, 
MA_NOTOWNED);
 
-#definePRCI_COREPLL0x4
-#definePRCI_COREPLL_DIVR_MASK  0x3f
-#definePRCI_COREPLL_DIVR_SHIFT 0
-#definePRCI_COREPLL_DIVF_MASK  0x7fc0
-#definePRCI_COREPLL_DIVF_SHIFT 6
-#definePRCI_COREPLL_DIVQ_MASK  0x38000
-#definePRCI_COREPLL_DIVQ_SHIFT 15
+#definePRCI_COREPLL_CFG0   0x4
+#definePRCI_DDRPLL_CFG00xC
+#definePRCI_GEMGXLPLL_CFG0 0x1C
 
+#definePRCI_PLL_DIVR_MASK  0x3f
+#definePRCI_PLL_DIVR_SHIFT 0
+#definePRCI_PLL_DIVF_MASK  0x7fc0
+#definePRCI_PLL_DIVF_SHIFT 6
+#definePRCI_PLL_DIVQ_MASK  0x38000
+#definePRCI_PLL_DIVQ_SHIFT 15
+
 #definePRCI_READ(_sc, _reg)\
 bus_space_read_4((_sc)->bst, (_sc)->bsh, (_reg))
 
+struct prci_pll_def {
+   uint32_tid;
+   const char  *name;
+   uint32_treg;
+};
+
+#define PLL(_id, _name, _base) \
+{  \
+   .id = (_id),\
+   .name = (_name),\
+   .reg = (_base), \
+}
+
+/* PLL Clocks */
+struct prci_pll_def pll_clks[] = {
+   PLL(PRCI_CLK_COREPLL, "coreclk",  PRCI_COREPLL_CFG0),
+   PLL(PRCI_CLK_DDRPLL, "ddrclk",   PRCI_DDRPLL_CFG0),
+   PLL(PRCI_CLK_GEMGXLPLL, "gemgxclk", PRCI_GEMGXLPLL_CFG0),
+};
+
 static int
 prci_clk_pll_init(struct clknode *clk, device_t dev)
 {
@@ -121,11 +147,11 @@ prci_clk_pll_recalc(struct clknode *clk, uint64_t *fre
}
 
/* Calculate the PLL output */
-   val = PRCI_READ(sc->parent_sc, PRCI_COREPLL);
+   val = PRCI_READ(sc->parent_sc, sc->reg);
 
-   divf = (val & PRCI_COREPLL_DIVF_MASK) >> PRCI_COREPLL_DIVF_SHIFT;
-   divq = (val & PRCI_COREPLL_DIVQ_MASK) >> PRCI_COREPLL_DIVQ_SHIFT;
-   divr = (val & PRCI_COREPLL_DIVR_MASK) >> PRCI_COREPLL_DIVR_SHIFT;
+   divf = (val & PRCI_PLL_DIVF_MASK) >> PRCI_PLL_DIVF_SHIFT;
+   divq = (val & PRCI_PLL_DIVQ_MASK) >> PRCI_PLL_DIVQ_SHIFT;
+   divr = (val & PRCI_PLL_DIVR_MASK) >> PRCI_PLL_DIVR_SHIFT;
 
*freq = refclk / (divr + 1) * (2 * (divf + 1)) / (1 << divq);
 
@@ -160,7 +186,8 @@ prci_probe(device_t dev)
 }
 
 static void
-prci_pll_register(struct prci_softc *parent_sc, struct clknode_init_def 
*clkdef)
+prci_pll_register(struct prci_softc *parent_sc, struct clknode_init_def 
*clkdef,
+   uint32_t reg)
 {
struct clknode *clk;
struct prci_clk_pll_sc *sc;
@@ -172,6 +199,7 @@ prci_pll_register(struct prci_softc *parent_sc, struct
 
sc = clknode_get_softc(clk);
sc->parent_sc = parent_sc;
+   sc->reg = reg;
 
clknode_register(parent_sc->clkdom, clk);
 }
@@ -207,8 +235,6 @@ prci_attach(device_t dev)
}
 
bzero(, sizeof(clkdef));
-   clkdef.id = 0;
-   clkdef.name = "coreclk";
clkdef.parent_names = mallocarray(ncells, sizeof(char *), M_OFWPROP,
M_WAITOK);
for (i = 0; i < ncells; i++) {
@@ -232,7 +258,11 @@ prci_attach(device_t dev)
}
 
/* We can't free a clkdom, so from now on we cannot fail. */
-   prci_pll_register(sc, );
+   for (i = 0; i < nitems(pll_clks); i++) {
+   clkdef.id = pll_clks[i].id;
+   

svn commit: r357367 - head/sys/dev/tpm

2020-02-01 Thread Dimitry Andric
Author: dim
Date: Sat Feb  1 17:02:26 2020
New Revision: 357367
URL: https://svnweb.freebsd.org/changeset/base/357367

Log:
  Fix new clang 10.0.0 warnings about converting the result of shift
  operations to a boolean in tpm(4):
  
sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a 
boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 
'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
  ^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^
  
  In this case, the intent was to clear the zeroth bit, and leave the rest
  unaffected.  Therefore, the ~ operator should be used instead.
  
  Noticed by:   cem
  MFC after:3 days

Modified:
  head/sys/dev/tpm/tpm_crb.c

Modified: head/sys/dev/tpm/tpm_crb.c
==
--- head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 16:57:04 2020(r357366)
+++ head/sys/dev/tpm/tpm_crb.c  Sat Feb  1 17:02:26 2020(r357367)
@@ -298,7 +298,7 @@ tpmcrb_cancel_cmd(struct tpm_sc *sc)
return (false);
}
 
-   WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
+   WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
return (true);
 }
 
@@ -330,7 +330,7 @@ tpmcrb_transmit(struct tpm_sc *sc, size_t length)
return (EIO);
}
/* Clear cancellation bit */
-   WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
+   WR4(sc, TPM_CRB_CTRL_CANCEL, ~TPM_CRB_CTRL_CANCEL_CMD);
 
/* Switch device to idle state if necessary */
if (!(RD4(sc, TPM_CRB_CTRL_STS) & TPM_CRB_CTRL_STS_IDLE_BIT)) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357366 - in head/sys: conf modules/tpm

2020-02-01 Thread Dimitry Andric
Author: dim
Date: Sat Feb  1 16:57:04 2020
New Revision: 357366
URL: https://svnweb.freebsd.org/changeset/base/357366

Log:
  Revert r357349, since the clang 10.0.0 warning was actually correct, and
  the ! operator should have been a ~ instead:
  
Merge r357348 from the clang 10.0.0 import branch:
  
Disable new clang 10.0.0 warnings about converting the result of
shift operations to a boolean in tpm(4):
  
sys/dev/tpm/tpm_crb.c:301:32: error: converting the result of '<<' to a 
boolean; did you mean '(1 << (0)) != 0'? [-Werror,-Wint-in-bool-context]
  WR4(sc, TPM_CRB_CTRL_CANCEL, !TPM_CRB_CTRL_CANCEL_CMD);
^
sys/dev/tpm/tpm_crb.c:73:34: note: expanded from macro 
'TPM_CRB_CTRL_CANCEL_CMD'
#define TPM_CRB_CTRL_CANCEL_CMD BIT(0)
  ^
sys/dev/tpm/tpm20.h:60:19: note: expanded from macro 'BIT'
#define BIT(x) (1 << (x))
^
  
Such warnings can be useful in C++ contexts, but not so much in kernel
drivers, where this type of bit twiddling is commonplace.  So disable
it for this case.
  
  Noticed by:   cem
  MFC after:3 days

Modified:
  head/sys/conf/files.amd64
  head/sys/conf/kern.mk
  head/sys/modules/tpm/Makefile
Directory Properties:
  head/   (props changed)

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Sat Feb  1 11:31:45 2020(r357365)
+++ head/sys/conf/files.amd64   Sat Feb  1 16:57:04 2020(r357366)
@@ -323,8 +323,7 @@ dev/syscons/scvesactl.c optionalsc vga 
vesa
 dev/syscons/scvgarndr.coptionalsc vga
 dev/tpm/tpm.c  optionaltpm
 dev/tpm/tpm20.coptionaltpm
-dev/tpm/tpm_crb.c  optionaltpm acpi \
-   compile-with "${NORMAL_C} ${NO_WINT_IN_BOOL_CONTEXT}"
+dev/tpm/tpm_crb.c  optionaltpm acpi
 dev/tpm/tpm_tis.c  optionaltpm acpi
 dev/tpm/tpm_acpi.c optionaltpm acpi
 dev/tpm/tpm_isa.c  optionaltpm isa

Modified: head/sys/conf/kern.mk
==
--- head/sys/conf/kern.mk   Sat Feb  1 11:31:45 2020(r357365)
+++ head/sys/conf/kern.mk   Sat Feb  1 16:57:04 2020(r357366)
@@ -37,9 +37,6 @@ CWARNEXTRA+=  -Wno-error-shift-negative-value
 .if ${COMPILER_VERSION} >= 4
 CWARNEXTRA+=   -Wno-address-of-packed-member
 .endif
-.if ${COMPILER_VERSION} >= 10
-NO_WINT_IN_BOOL_CONTEXT=   -Wno-int-in-bool-context
-.endif
 .endif
 
 .if ${COMPILER_TYPE} == "gcc"

Modified: head/sys/modules/tpm/Makefile
==
--- head/sys/modules/tpm/Makefile   Sat Feb  1 11:31:45 2020
(r357365)
+++ head/sys/modules/tpm/Makefile   Sat Feb  1 16:57:04 2020
(r357366)
@@ -11,5 +11,3 @@ SRCS+=tpm_isa.c tpm_acpi.c isa_if.h opt_acpi.h acpi_i
 SRCS+= tpm20.c tpm_crb.c tpm_tis.c opt_tpm.h
 
 .include 
-
-CWARNFLAGS.tpm_crb.c+= ${NO_WINT_IN_BOOL_CONTEXT}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357365 - head/tests/sys/net

2020-02-01 Thread Kristof Provost
Author: kp
Date: Sat Feb  1 11:31:45 2020
New Revision: 357365
URL: https://svnweb.freebsd.org/changeset/base/357365

Log:
  tests: epair: Don't fail if the if_epair module is already loaded
  
  kldload() returns an error (EEXIST) if the module is already loaded.
  That's not a problem for us, so ignore that error.
  
  While here also clean up include statements.
  
  MFC after:3 days
  X-MFC-With:   r357234

Modified:
  head/tests/sys/net/if_epair.c

Modified: head/tests/sys/net/if_epair.c
==
--- head/tests/sys/net/if_epair.c   Sat Feb  1 10:25:13 2020
(r357364)
+++ head/tests/sys/net/if_epair.c   Sat Feb  1 11:31:45 2020
(r357365)
@@ -25,17 +25,19 @@
  * $FreeBSD$
  */
 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include 
 
+#include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -51,7 +53,7 @@ ATF_TC_BODY(params, tc)
int s;
 
s = kldload("if_epair");
-   if (s != 0)
+   if (s != 0 && errno != EEXIST)
atf_tc_fail("Failed to load if_epair");
 
s = socket(AF_INET, SOCK_DGRAM, 0);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357364 - head/share/man/man4

2020-02-01 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Sat Feb  1 10:25:13 2020
New Revision: 357364
URL: https://svnweb.freebsd.org/changeset/base/357364

Log:
  bridge.4: Remove notes about FreeBSD 6.2-7.2
  
  Reported by:  Mateusz Kwiatkowski
  Reviewed by:  brueffer
  Approved by:  bcr (mentor)
  Differential Revision: https://reviews.freebsd.org/D23393

Modified:
  head/share/man/man4/bridge.4

Modified: head/share/man/man4/bridge.4
==
--- head/share/man/man4/bridge.4Sat Feb  1 10:15:23 2020
(r357363)
+++ head/share/man/man4/bridge.4Sat Feb  1 10:25:13 2020
(r357364)
@@ -35,7 +35,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 16, 2017
+.Dd February 01, 2020
 .Dt IF_BRIDGE 4
 .Os
 .Sh NAME
@@ -480,13 +480,6 @@ ifconfig gif0 tunnel 1.2.3.4 5.6.7.8 up
 ifconfig bridge0 create
 ifconfig bridge0 addm fxp0 addm gif0 up
 .Ed
-.Pp
-Note that
-.Fx
-6.1, 6.2, 6.3, 7.0, 7.1, and 7.2 have a bug in the EtherIP protocol.
-For more details and workaround, see the
-.Xr gif 4
-manual page.
 .Sh SEE ALSO
 .Xr gif 4 ,
 .Xr ipf 4 ,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357363 - head/sys/geom

2020-02-01 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Feb  1 10:15:23 2020
New Revision: 357363
URL: https://svnweb.freebsd.org/changeset/base/357363

Log:
  The error variable is not really needed. Remove it.

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Sat Feb  1 09:13:11 2020(r357362)
+++ head/sys/geom/geom_disk.c   Sat Feb  1 10:15:23 2020(r357363)
@@ -268,7 +268,6 @@ g_disk_ioctl(struct g_provider *pp, u_long cmd, void *
 {
struct disk *dp;
struct g_disk_softc *sc;
-   int error;
 
sc = pp->private;
dp = sc->dp;
@@ -277,8 +276,7 @@ g_disk_ioctl(struct g_provider *pp, u_long cmd, void *
 
if (dp->d_ioctl == NULL)
return (ENOIOCTL);
-   error = dp->d_ioctl(dp, cmd, data, fflag, td);
-   return (error);
+   return (dp->d_ioctl(dp, cmd, data, fflag, td));
 }
 
 static off_t
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r357138 - head/bin/pwait

2020-02-01 Thread Pawel Jakub Dawidek
On 1/30/20 14:47, Jilles Tjoelker wrote:
> On 26-01-2020 11:49, Pawel Jakub Dawidek wrote:
>> Author: pjd
>> Date: Sun Jan 26 10:49:24 2020
>> New Revision: 357138
>> URL: https://svnweb.freebsd.org/changeset/base/357138
>>
>> Log:
>>    - Be consistent with using sysexits(3) codes.
>>    - Turn fprintf()+exit() into errx().
>>       Sponsored by:    Fudo Security
>>
>> Modified:
>>    head/bin/pwait/pwait.c
>>
>> Modified: head/bin/pwait/pwait.c
>> ==
>>
>> --- head/bin/pwait/pwait.c    Sun Jan 26 07:24:49 2020    (r357137)
>> +++ head/bin/pwait/pwait.c    Sun Jan 26 10:49:24 2020    (r357138)
>> @@ -53,8 +53,7 @@ static void
>>   usage(void)
>>   {
>>   -    fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n");
>> -    exit(EX_USAGE);
>> +    errx(EX_USAGE, "usage: pwait [-t timeout] [-v] pid ...");
> 
> This adds a "pwait: " before the line, which most other programs do not do.
> 

Reverted in r357362. Thanks.

-- 
Pawel Jakub Dawidek
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r357362 - head/bin/pwait

2020-02-01 Thread Pawel Jakub Dawidek
Author: pjd
Date: Sat Feb  1 09:13:11 2020
New Revision: 357362
URL: https://svnweb.freebsd.org/changeset/base/357362

Log:
  Restore previous usage presentation (without "pwait: " prefix).
  
  Pointed out by:   jilles

Modified:
  head/bin/pwait/pwait.c

Modified: head/bin/pwait/pwait.c
==
--- head/bin/pwait/pwait.c  Sat Feb  1 06:46:55 2020(r357361)
+++ head/bin/pwait/pwait.c  Sat Feb  1 09:13:11 2020(r357362)
@@ -53,7 +53,8 @@ static void
 usage(void)
 {
 
-   errx(EX_USAGE, "usage: pwait [-t timeout] [-ov] pid ...");
+   fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n");
+   exit(EX_USAGE);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"