svn commit: r359067 - head/share/examples/ipfw

2020-03-18 Thread Hiroki Sato
Author: hrs
Date: Wed Mar 18 08:00:46 2020
New Revision: 359067
URL: https://svnweb.freebsd.org/changeset/base/359067

Log:
  -F is GNU diff specific, not implemented in BSD diff.
  
  Reported by:  ko...@ryuhoku.jp
  MFC after:3 days

Modified:
  head/share/examples/ipfw/change_rules.sh

Modified: head/share/examples/ipfw/change_rules.sh
==
--- head/share/examples/ipfw/change_rules.shWed Mar 18 05:28:36 2020
(r359066)
+++ head/share/examples/ipfw/change_rules.shWed Mar 18 08:00:46 2020
(r359067)
@@ -149,7 +149,7 @@ cat 

svn commit: r359068 - in head: . libexec/rc/rc.d

2020-03-18 Thread Hiroki Sato
Author: hrs
Date: Wed Mar 18 08:17:24 2020
New Revision: 359068
URL: https://svnweb.freebsd.org/changeset/base/359068

Log:
  Remove /etc/host.conf, which was automatically generated from
  nsswitch.conf for backward compatibility.  This file was used
  over 19 years ago, before introducing nsdispatch() in the
  name-service lookup APIs.
  
  MFC after:3 days

Deleted:
  head/libexec/rc/rc.d/nsswitch
Modified:
  head/ObsoleteFiles.inc
  head/libexec/rc/rc.d/Makefile

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Wed Mar 18 08:00:46 2020(r359067)
+++ head/ObsoleteFiles.inc  Wed Mar 18 08:17:24 2020(r359068)
@@ -36,6 +36,10 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200318: host.conf was deprecated a long time ago.
+OLD_FILES+=etc/host.conf
+OLD_FILES+=etc/rc.d/nsswitch
+
 # 20200310: new clang import which bumps version from 9.0.1 to 10.0.0.
 OLD_FILES+=usr/lib/clang/9.0.1/include/cuda_wrappers/algorithm
 OLD_FILES+=usr/lib/clang/9.0.1/include/cuda_wrappers/complex

Modified: head/libexec/rc/rc.d/Makefile
==
--- head/libexec/rc/rc.d/Makefile   Wed Mar 18 08:00:46 2020
(r359067)
+++ head/libexec/rc/rc.d/Makefile   Wed Mar 18 08:17:24 2020
(r359068)
@@ -74,7 +74,6 @@ CONFS=DAEMON \
nfsuserd \
nisdomain \
${_nscd} \
-   nsswitch \
ntpdate \
${_opensm} \
os-release \
___
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: r359069 - in head/libexec/rc: . rc.d

2020-03-18 Thread Leandro Lupori
Author: luporl
Date: Wed Mar 18 13:09:47 2020
New Revision: 359069
URL: https://svnweb.freebsd.org/changeset/base/359069

Log:
  Add fsck_flags config option
  
  On UFS with SU+J, sometimes fsck's default recovery from journal marks the
  filesystem as clean but some errors remain.
  
  With SU only, default fsck in preen mode sometimes thinks all errors have
  been fixed but some still remain.
  
  To address the issues above, this change adds a new config option:
  fsck_flags.  By default it's set to -p, but the user may change it to -y
  or -f -y, for instance, to force a full fsck after a system crash.
  
  Submitted by: jhibbits@ (original version)
  Reviewed by:  mckusick
  Differential Revision:https://reviews.freebsd.org/D24087

Modified:
  head/libexec/rc/rc.conf
  head/libexec/rc/rc.d/fsck

Modified: head/libexec/rc/rc.conf
==
--- head/libexec/rc/rc.conf Wed Mar 18 08:17:24 2020(r359068)
+++ head/libexec/rc/rc.conf Wed Mar 18 13:09:47 2020(r359069)
@@ -101,6 +101,7 @@ geli_autodetach="YES"   # Automatically detach on last c
 
 root_rw_mount="YES"# Set to NO to inhibit remounting root read-write.
 root_hold_delay="30"   # Time to wait for root mount hold release.
+fsck_flags="-p"# May be changed to -f (or -f -y) to force a 
full fsck
 fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails.
 fsck_y_flags="-T ffs:-R -T ufs:-R" # Additional flags for fsck -y
 background_fsck="YES"  # Attempt to run fsck in the background where possible.

Modified: head/libexec/rc/rc.d/fsck
==
--- head/libexec/rc/rc.d/fsck   Wed Mar 18 08:17:24 2020(r359068)
+++ head/libexec/rc/rc.d/fsck   Wed Mar 18 13:09:47 2020(r359069)
@@ -25,10 +25,11 @@ fsck_start()
trap : 3
 
check_startmsgs && echo "Starting file system checks:"
+   # Background fsck can only be run with -p
if checkyesno background_fsck; then
fsck -F -p
else
-   fsck -p
+   fsck ${fsck_flags}
fi
 
err=$?
@@ -37,10 +38,11 @@ fsck_start()
"available; retrying"
root_hold_wait
check_startmsgs && echo "Restarting file system checks:"
+   # Background fsck can only be run with -p
if checkyesno background_fsck; then
fsck -F -p
else
-   fsck -p
+   fsck ${fsck_flags}
fi
err=$?
fi
___
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: r359070 - head/sys/dev/usb/net

2020-03-18 Thread Ed Maste
Author: emaste
Date: Wed Mar 18 14:16:14 2020
New Revision: 359070
URL: https://svnweb.freebsd.org/changeset/base/359070

Log:
  if_muge: use C99 bool for boolean vars

Modified:
  head/sys/dev/usb/net/if_muge.c

Modified: head/sys/dev/usb/net/if_muge.c
==
--- head/sys/dev/usb/net/if_muge.c  Wed Mar 18 13:09:47 2020
(r359069)
+++ head/sys/dev/usb/net/if_muge.c  Wed Mar 18 14:16:14 2020
(r359070)
@@ -389,9 +389,10 @@ lan78xx_eeprom_read_raw(struct muge_softc *sc, uint16_
 {
usb_ticks_t start_ticks;
const usb_ticks_t max_ticks = USB_MS_TO_TICKS(1000);
-   int err, locked;
+   int err;
uint32_t val, saved;
uint16_t i;
+   bool locked;
 
locked = mtx_owned(&sc->sc_mtx); /* XXX */
if (!locked)
@@ -483,9 +484,10 @@ static int
 lan78xx_otp_read_raw(struct muge_softc *sc, uint16_t off, uint8_t *buf,
 uint16_t buflen)
 {
-   int locked, err;
+   int err;
uint32_t val;
uint16_t i;
+   bool locked;
locked = mtx_owned(&sc->sc_mtx);
if (!locked)
MUGE_LOCK(sc);
@@ -659,8 +661,8 @@ static int
 lan78xx_miibus_readreg(device_t dev, int phy, int reg)
 {
struct muge_softc *sc = device_get_softc(dev);
-   int locked;
uint32_t addr, val;
+   bool locked;
 
val = 0;
locked = mtx_owned(&sc->sc_mtx);
@@ -712,8 +714,8 @@ static int
 lan78xx_miibus_writereg(device_t dev, int phy, int reg, int val)
 {
struct muge_softc *sc = device_get_softc(dev);
-   int locked;
uint32_t addr;
+   bool locked;
 
if (sc->sc_phyno != phy)
return (0);
@@ -760,10 +762,10 @@ lan78xx_miibus_statchg(device_t dev)
struct muge_softc *sc = device_get_softc(dev);
struct mii_data *mii = uether_getmii(&sc->sc_ue);
struct ifnet *ifp;
-   int locked;
int err;
uint32_t flow = 0;
uint32_t fct_flow = 0;
+   bool locked;
 
locked = mtx_owned(&sc->sc_mtx);
if (!locked)
___
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: r359071 - head/usr.bin/posixshmcontrol

2020-03-18 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Wed Mar 18 15:02:09 2020
New Revision: 359071
URL: https://svnweb.freebsd.org/changeset/base/359071

Log:
  Document that posixshmcontrol first appeared in 12.1
  
  Also while here, I am addressing some linting issues.
  
  PR:   243132
  Submitted by: Noah Altunian 
  Approved by:  bcr (mentor)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24112

Modified:
  head/usr.bin/posixshmcontrol/posixshmcontrol.1

Modified: head/usr.bin/posixshmcontrol/posixshmcontrol.1
==
--- head/usr.bin/posixshmcontrol/posixshmcontrol.1  Wed Mar 18 14:16:14 
2020(r359070)
+++ head/usr.bin/posixshmcontrol/posixshmcontrol.1  Wed Mar 18 15:02:09 
2020(r359071)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 30, 2019
+.Dd March 18, 2020
 .Dt POSIXSHMCONTROL 1
 .Os
 .Sh NAME
@@ -99,7 +99,7 @@ Argument to the
 .Fl s
 option specifies new length.
 The human-friendly 'k', 'm', 'g' suffixes can be used, see
-.Xr expand_number 3.
+.Xr expand_number 3 .
 If the option is not specified, assumed length is zero.
 .El
 .Pp
@@ -143,10 +143,12 @@ and then enlarge it to 1M, use the sequence of command
 The
 .Nm
 command appeared in
-.Fx 13.0 .
+.Fx 12.1 .
 .Sh AUTHORS
 The
 .Nm
 command and this manual page were written by
 .An Konstantin Belousov Aq Mt k...@freebsd.org
-under sponsorship from The FreeBSD Foundation.
+under sponsorship from The
+.Fx
+Foundation.
___
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: r359072 - head/stand/lua

2020-03-18 Thread Ryan Moeller
Author: freqlabs
Date: Wed Mar 18 16:21:11 2020
New Revision: 359072
URL: https://svnweb.freebsd.org/changeset/base/359072

Log:
  loader: Add a "kernel.loaded" hook
  
  This hook can be useful, for example to run a local function to choose
  different modules to load when a user has picked a different kernel
  from the menu.
  
  Reviewed by:  kevans
  Approved by:  mav (mentor)
  MFC after:1 week
  Sponsored by: iXsystems, Inc.
  Differential Revision:https://reviews.freebsd.org/D24115

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==
--- head/stand/lua/config.lua   Wed Mar 18 15:02:09 2020(r359071)
+++ head/stand/lua/config.lua   Wed Mar 18 16:21:11 2020(r359072)
@@ -623,7 +623,7 @@ end
 function config.loadelf()
local xen_kernel = loader.getenv('xen_kernel')
local kernel = config.kernel_selected or config.kernel_loaded
-   local loaded, status
+   local status
 
if xen_kernel ~= nil then
print(MSG_XENKERNLOADING)
@@ -633,11 +633,10 @@ function config.loadelf()
end
end
print(MSG_KERNLOADING)
-   loaded = config.loadKernel(kernel)
-
-   if not loaded then
+   if not config.loadKernel(kernel) then
return false
end
+   hook.runAll("kernel.loaded")
 
print(MSG_MODLOADING)
status = loadModule(modules, not config.verbose)
___
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: r358989 - in head/stand/efi: libefi loader loader/arch/arm loader/arch/arm64

2020-03-18 Thread Ruslan Garipov
On 3/17/2020 5:16 PM, Tomoaki AOKI wrote:
> Hi! Thanks for your respond.
> 
> Unfortunately, no.
> I'm running on ThinkPad P52, which has no com connector installed.
> No USB serial interface connected.
> 
> `efi-show -g global -v ConOut` on loader prompt shows
> 
> global NV,BS,RS ConOut =
> PciRoot(0,0)/Pci((0x1,oxo)/Pci(0x0,0x0)/AcpiAdr(0x80010100)
> 
> Moreover, my previous idea didn't help.
> 
> Neither
>  console="vidconsole"
>  console="eficonsole"
>  console="efi_console"
> nor
>  console="efi"
> in /boot/loader.conf works.
> 
> Defining / undefining TERM_EMU on build are untested.
> 
> Is there any setting for /boot/loader.conf to control the behavior?
> 
> 
> Regards.
> 
> 
> On Mon, 16 Mar 2020 08:26:56 +0200
> Toomas Soome  wrote:
> 
>> Hi!
>>
>> This means, your system has UART serial device 〓 you can check this from 
>> loader prompt: efi-show -g global -v ConOut or with efivar from running 
>> system. This w  ould trigger efi console driver to use 
>> TERM_EMU, which can be turned off by user and doing that would cause ESC 
>> sequences to be passed directly to console. Might that be true in your case?
>>
>> rgds,
>> toomas
>>
>>> On 15. Mar 2020, at 17:17, Tomoaki AOKI  wrote:
>>>
>>> Hi.
>>>
>>> This broke loader menu display on efifb. At least on amd64.
>>> ESC sequences without ESC character are shown.
>>> Key input (at least 1, 2 and enter) works OK.
>>> I suspect outputs for SIO is sent to efifb and ESC codes are ignored.
>>>
>>> Reverting this fixes the issue.
I got the same issue with loader menu when was upgrading from r358827 to
r359028 (x86-64).

But unfortunately the broken menu is just a part of my problem.  The
real pain is that a FreeBSD 13.0-CURRENT system hosted by VMware ESXi or
Workstation doesn't boot anymore after r358989.  An ugly workaround[1]
(exiting from the loader menu into the loader prompt, running ls or
show, scrolling the result down and then executing boot) I found some
time ago doesn't work anymore.  After running boot/boot -s/selecting
menu item, a hypervisor just shuts session down with the following
message: ``The firmware encountered an unexpected exception. The virtual
machine cannot boot.''

The virtual guests don't have any UART (even USB) serial devices in
their settings.  efi-show prints result similar to what Tomoaki got:

OK efi-show -g global -v CounOut
global NV,BS,RS ConOut = PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80014310)

Undefining TERM_EMU doesn't help.  I had completely removed CFLAGS
assignment with TERM_EMU from stand/efi/libefi/Makefile and rebuilt
kernel/world -- nothing changed.  I don't define TERM_EMU in my
make.conf or/and src.conf.

Reverting this revision fix booting (and menu, of course).

FreeBSD on physical hardware boots just fine with this revision, but has
corrupted loader menu.

Toomas, please help us to fix this.  I can live with the broken menu,
but I don't want to revert this revision every time I will upgrade my
virtual machines after r359028 now.

[1]
https://old.reddit.com/r/freebsd/comments/drxqlm/failed_to_do_efi_boot_on_a_vmware_virtual_machine/f6om6p2/
>>>
>>> Not tried (not enough time for now as I'm mainly using stable/12),
>>> but possibly calling efi_cons_probe() from efi_cons_init() would be
>>> needed, as ome codes are moved from the latter to the former.
>>>
>>>
 Author: tsoome
 Date: Sat Mar 14 06:36:03 2020
 New Revision: 358989
 URL: https://svnweb.freebsd.org/changeset/base/358989

 Log:
  loader: add comconsole implementation on top of SIO protocol

  Provide comconsole on top of SIO for arm platforms (x86 does use bios
>>> version).

 Added:
  head/stand/efi/loader/efiserialio.c   (contents, props changed)
 Modified:
  head/stand/efi/libefi/efi_console.c
  head/stand/efi/loader/arch/arm/Makefile.inc
  head/stand/efi/loader/arch/arm64/Makefile.inc
  head/stand/efi/loader/conf.c
  head/stand/efi/loader/main.c

 Modified: head/stand/efi/libefi/efi_console.c
 ==
 --- head/stand/efi/libefi/efi_console.cSat Mar 14 05:57:22
>>> 2020(r358988)
 +++ head/stand/efi/libefi/efi_console.c
>>> Sat Mar 14 06:36:03 2020(r358989)
 @@ -377,9 +377,22 @@ efi_cons_respond(void *s __unused, const void *buf __u
 {
 }

 +/*
 + * Set up conin/conout/coninex to make sure we have input ready.
 + */
 static void
 efi_cons_probe(struct console *cp)
 {
 +  EFI_STATUS status;
 +
 +  conout = ST->ConOut;
 +  conin = ST->ConIn;
 +
 +  status = BS->OpenProtocol(ST->ConsoleInHandle,
>>> &simple_input_ex_guid,
 +  (void **)&coninex, IH, NULL,
>>> EFI_OPEN_PROTOCOL_GET_PROTOCOL);
 +  if (status != EFI_SUCCESS)
 +  coninex = NULL;
 +
cp->c_flags |= C_PRESENTIN | C_PRESENTOUT;
 }

 @@ -889,15 +902,7 @@ efi_cons_init(int arg)
   

Re: svn commit: r359046 - head/share/mk

2020-03-18 Thread Brooks Davis
On Wed, Mar 18, 2020 at 12:29:24PM +0900, Hiroki Sato wrote:
> Brooks Davis  wrote
>   in <202003171817.02hihwdy035...@repo.freebsd.org>:
> 
> br> Author: brooks
> br> Date: Tue Mar 17 18:17:32 2020
> br> New Revision: 359046
> br> URL: https://svnweb.freebsd.org/changeset/base/359046
> br>
> br> Log:
> br>   Support SUBDIR.${MK_FOO}.${MK_BAR} expresssions.
> br>
> br>   This allows simplification of Makefiles where some SUBDIR entries depend
> br>   on two things (e.g. something that depends on C++ and some other knob).
> 
>  Just my two cents, but SUBDIR.${MK_FOO:M${MK_BAR}:M${MK_BAZ}}= dir
>  should do the trick.  I am not sure how many variables we need to
>  support in practice, adding ".yes.yes..." in bsd.subdir.mk looks less
>  flexible to me.

IMO that's lousy from a readability perspective.  It's remotely
conceivable that supporting three variables might make sense, but more
seems vanishingly unlikely and even so, it's trivial to add more cases.

-- Brooks


signature.asc
Description: PGP signature


svn commit: r359073 - head/stand/lua

2020-03-18 Thread Ryan Moeller
Author: freqlabs
Date: Wed Mar 18 17:01:03 2020
New Revision: 359073
URL: https://svnweb.freebsd.org/changeset/base/359073

Log:
  Fixup line lost from previous commit (r359072)
  
  Reviewed by:  kevans
  Approved by:  mav (mentor)
  MFC after:1 week
  Sponsored by: iXsystems, Inc.
  Differential Revision:https://reviews.freebsd.org/D24115

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==
--- head/stand/lua/config.lua   Wed Mar 18 16:21:11 2020(r359072)
+++ head/stand/lua/config.lua   Wed Mar 18 17:01:03 2020(r359073)
@@ -646,5 +646,6 @@ end
 
 hook.registerType("config.loaded")
 hook.registerType("config.reloaded")
+hook.registerType("kernel.loaded")
 hook.registerType("modules.loaded")
 return config
___
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: r358989 - in head/stand/efi: libefi loader loader/arch/arm loader/arch/arm64

2020-03-18 Thread Toomas Soome via svn-src-head


> On 18. Mar 2020, at 18:40, Ruslan Garipov  wrote:
> 
> On 3/17/2020 5:16 PM, Tomoaki AOKI wrote:
>> Hi! Thanks for your respond.
>> 
>> Unfortunately, no.
>> I'm running on ThinkPad P52, which has no com connector installed.
>> No USB serial interface connected.
>> 
>> `efi-show -g global -v ConOut` on loader prompt shows
>> 
>> global NV,BS,RS ConOut =
>> PciRoot(0,0)/Pci((0x1,oxo)/Pci(0x0,0x0)/AcpiAdr(0x80010100)
>> 
>> Moreover, my previous idea didn't help.
>> 
>> Neither
>> console="vidconsole"
>> console="eficonsole"
>> console="efi_console"
>> nor
>> console="efi"
>> in /boot/loader.conf works.
>> 
>> Defining / undefining TERM_EMU on build are untested.
>> 
>> Is there any setting for /boot/loader.conf to control the behavior?
>> 
>> 
>> Regards.
>> 
>> 
>> On Mon, 16 Mar 2020 08:26:56 +0200
>> Toomas Soome  wrote:
>> 
>>> Hi!
>>> 
>>> This means, your system has UART serial device 〓 you can check this from 
>>> loader prompt: efi-show -g global -v ConOut or with efivar from running 
>>> system. This w ould trigger efi console driver to use 
>>> TERM_EMU, which can be turned off by user and doing that would cause ESC 
>>> sequences to be passed directly to console. Might that be true in your case?
>>> 
>>> rgds,
>>> toomas
>>> 
 On 15. Mar 2020, at 17:17, Tomoaki AOKI  wrote:
 
 Hi.
 
 This broke loader menu display on efifb. At least on amd64.
 ESC sequences without ESC character are shown.
 Key input (at least 1, 2 and enter) works OK.
 I suspect outputs for SIO is sent to efifb and ESC codes are ignored.
 
 Reverting this fixes the issue.
> I got the same issue with loader menu when was upgrading from r358827 to
> r359028 (x86-64).
> 
> But unfortunately the broken menu is just a part of my problem.  The
> real pain is that a FreeBSD 13.0-CURRENT system hosted by VMware ESXi or
> Workstation doesn't boot anymore after r358989.  An ugly workaround[1]
> (exiting from the loader menu into the loader prompt, running ls or
> show, scrolling the result down and then executing boot) I found some
> time ago doesn't work anymore.  After running boot/boot -s/selecting
> menu item, a hypervisor just shuts session down with the following
> message: ``The firmware encountered an unexpected exception. The virtual
> machine cannot boot.''
> 
> The virtual guests don't have any UART (even USB) serial devices in
> their settings.  efi-show prints result similar to what Tomoaki got:
> 
> OK efi-show -g global -v CounOut
> global NV,BS,RS ConOut = PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80014310)
> 
> Undefining TERM_EMU doesn't help.  I had completely removed CFLAGS
> assignment with TERM_EMU from stand/efi/libefi/Makefile and rebuilt
> kernel/world -- nothing changed.  I don't define TERM_EMU in my
> make.conf or/and src.conf.
> 
> Reverting this revision fix booting (and menu, of course).
> 
> FreeBSD on physical hardware boots just fine with this revision, but has
> corrupted loader menu.
> 
> Toomas, please help us to fix this.  I can live with the broken menu,
> but I don't want to revert this revision every time I will upgrade my
> virtual machines after r359028 now.


Hi!

The build, are you doing build with -DNO_CLEAN? or can you run make clean in 
stand and then build it again? Otherwise, if you can poke me on irc, I’d like 
to get to the bottom of this.

Regarding the issue with vm, I am afraid the roots are going much deeper there. 
I have not got to the exact cause (and therefore a fix), but the problem is not 
about this specific patch. The problem is about memory map, specifically one 
just before and after we switch off Boot Services. 

rgds,
toomas


> 
> [1]
> https://old.reddit.com/r/freebsd/comments/drxqlm/failed_to_do_efi_boot_on_a_vmware_virtual_machine/f6om6p2/
>  
> 
 
 Not tried (not enough time for now as I'm mainly using stable/12),
 but possibly calling efi_cons_probe() from efi_cons_init() would be
 needed, as ome codes are moved from the latter to the former.
 
 
> Author: tsoome
> Date: Sat Mar 14 06:36:03 2020
> New Revision: 358989
> URL: https://svnweb.freebsd.org/changeset/base/358989
> 
> Log:
> loader: add comconsole implementation on top of SIO protocol
> 
> Provide comconsole on top of SIO for arm platforms (x86 does use bios
 version).
> 
> Added:
> head/stand/efi/loader/efiserialio.c   (contents, props changed)
> Modified:
> head/stand/efi/libefi/efi_console.c
> head/stand/efi/loader/arch/arm/Makefile.inc
> head/stand/efi/loader/arch/arm64/Makefile.inc
> head/stand/efi/loader/conf.c
> head/stand/efi/loader/main.c
> 
> Modified: head/stand/efi/libefi/efi_console.c
> ==
> --- head/stand/efi/libefi/efi_console.c   Sat Mar 

svn commit: r359082 - in head: contrib/llvm-project/clang/include/clang/AST contrib/llvm-project/clang/include/clang/Sema contrib/llvm-project/clang/lib/AST contrib/llvm-project/clang/lib/Lex contr...

2020-03-18 Thread Dimitry Andric
Author: dim
Date: Wed Mar 18 18:26:53 2020
New Revision: 359082
URL: https://svnweb.freebsd.org/changeset/base/359082

Log:
  Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
  llvmorg-10.0.0-rc4-5-g52c365aa9ca.  The actual release should follow Real
  Soon Now.
  
  PR: 244251
  MFC after:  6 weeks

Modified:
  head/contrib/llvm-project/clang/include/clang/AST/Expr.h
  head/contrib/llvm-project/clang/include/clang/AST/Stmt.h
  head/contrib/llvm-project/clang/include/clang/Sema/Sema.h
  head/contrib/llvm-project/clang/include/clang/Sema/Template.h
  head/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp
  head/contrib/llvm-project/clang/lib/Lex/Pragma.cpp
  head/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp
  head/contrib/llvm-project/clang/lib/Sema/SemaExprCXX.cpp
  head/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
  head/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp
  head/contrib/llvm-project/clang/lib/Sema/TreeTransform.h
  head/contrib/llvm-project/clang/lib/Serialization/ASTReaderDecl.cpp
  head/contrib/llvm-project/clang/lib/Serialization/ASTReaderStmt.cpp
  head/contrib/llvm-project/clang/lib/Serialization/ASTWriterStmt.cpp
  head/contrib/llvm-project/clang/tools/driver/driver.cpp
  head/contrib/llvm-project/llvm/include/llvm/Support/ManagedStatic.h
  head/contrib/llvm-project/llvm/include/llvm/Support/Timer.h
  head/contrib/llvm-project/llvm/lib/Support/Timer.cpp
  head/lib/clang/include/VCSVersion.inc
  head/lib/clang/include/llvm/Support/VCSRevision.h
Directory Properties:
  head/contrib/llvm-project/   (props changed)
  head/contrib/llvm-project/clang/   (props changed)
  head/contrib/llvm-project/llvm/   (props changed)

Modified: head/contrib/llvm-project/clang/include/clang/AST/Expr.h
==
--- head/contrib/llvm-project/clang/include/clang/AST/Expr.hWed Mar 18 
18:21:58 2020(r359081)
+++ head/contrib/llvm-project/clang/include/clang/AST/Expr.hWed Mar 18 
18:26:53 2020(r359082)
@@ -3955,14 +3955,18 @@ class StmtExpr : public Expr {
   Stmt *SubStmt;
   SourceLocation LParenLoc, RParenLoc;
 public:
-  StmtExpr(CompoundStmt *substmt, QualType T,
-   SourceLocation lp, SourceLocation rp, bool InDependentContext) :
-// Note: we treat a statement-expression in a dependent context as always
-// being value- and instantiation-dependent. This matches the behavior of
-// lambda-expressions and GCC.
-Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
- T->isDependentType(), InDependentContext, InDependentContext, false),
-SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) {}
+  StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParenLoc,
+   SourceLocation RParenLoc, unsigned TemplateDepth)
+  : // We treat a statement-expression in a dependent context as
+// always being value- and instantiation-dependent. This matches the
+// behavior of lambda-expressions and GCC.
+Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
+ TemplateDepth != 0, TemplateDepth != 0, false),
+SubStmt(SubStmt), LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
+// FIXME: A templated statement expression should have an associated
+// DeclContext so that nested declarations always have a dependent context.
+StmtExprBits.TemplateDepth = TemplateDepth;
+  }
 
   /// Build an empty statement expression.
   explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }
@@ -3978,6 +3982,8 @@ class StmtExpr : public Expr {
   void setLParenLoc(SourceLocation L) { LParenLoc = L; }
   SourceLocation getRParenLoc() const { return RParenLoc; }
   void setRParenLoc(SourceLocation L) { RParenLoc = L; }
+
+  unsigned getTemplateDepth() const { return StmtExprBits.TemplateDepth; }
 
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == StmtExprClass;

Modified: head/contrib/llvm-project/clang/include/clang/AST/Stmt.h
==
--- head/contrib/llvm-project/clang/include/clang/AST/Stmt.hWed Mar 18 
18:21:58 2020(r359081)
+++ head/contrib/llvm-project/clang/include/clang/AST/Stmt.hWed Mar 18 
18:26:53 2020(r359082)
@@ -588,6 +588,18 @@ class alignas(void *) Stmt { (protected)
 unsigned Kind : 2;
   };
 
+  class StmtExprBitfields {
+friend class ASTStmtReader;
+friend class StmtExpr;
+
+unsigned : NumExprBits;
+
+/// The number of levels of template parameters enclosing this statement
+/// expression. Used to determine if a statement expression remains
+/// dependent after instantiation.
+unsigned TemplateDepth;
+  };
+
   //===--- C++ Expression bitfields classes ---===//
 
   class CXXOperatorCallExprBitfields {
@@ -995,6 +1007,9 @@ class alignas(void *) Stmt { (protected)
 GenericSelectionExprBitfields GenericSel

Re: svn commit: r358989 - in head/stand/efi: libefi loader loader/arch/arm loader/arch/arm64

2020-03-18 Thread Ruslan Garipov
On 3/18/2020 10:29 PM, Toomas Soome via svn-src-head wrote:
> 
> 
>> On 18. Mar 2020, at 18:40, Ruslan Garipov  wrote:
>>
>> On 3/17/2020 5:16 PM, Tomoaki AOKI wrote:
>>> Hi! Thanks for your respond.
>>>
>>> Unfortunately, no.
>>> I'm running on ThinkPad P52, which has no com connector installed.
>>> No USB serial interface connected.
>>>
>>> `efi-show -g global -v ConOut` on loader prompt shows
>>>
>>> global NV,BS,RS ConOut =
>>> PciRoot(0,0)/Pci((0x1,oxo)/Pci(0x0,0x0)/AcpiAdr(0x80010100)
>>>
>>> Moreover, my previous idea didn't help.
>>>
>>> Neither
>>> console="vidconsole"
>>> console="eficonsole"
>>> console="efi_console"
>>> nor
>>> console="efi"
>>> in /boot/loader.conf works.
>>>
>>> Defining / undefining TERM_EMU on build are untested.
>>>
>>> Is there any setting for /boot/loader.conf to control the behavior?
>>>
>>>
>>> Regards.
>>>
>>>
>>> On Mon, 16 Mar 2020 08:26:56 +0200
>>> Toomas Soome  wrote:
>>>
 Hi!

 This means, your system has UART serial device 〓 you can check this from 
 loader prompt: efi-show -g global -v ConOut or with efivar from running 
 system. This would trigger efi console driver to use 
 TERM_EMU, which can be turned off by user and doing that would cause ESC 
 sequences to be passed directly to console. Might that be true in your 
 case?

 rgds,
 toomas

> On 15. Mar 2020, at 17:17, Tomoaki AOKI  wrote:
>
> Hi.
>
> This broke loader menu display on efifb. At least on amd64.
> ESC sequences without ESC character are shown.
> Key input (at least 1, 2 and enter) works OK.
> I suspect outputs for SIO is sent to efifb and ESC codes are ignored.
>
> Reverting this fixes the issue.
>> I got the same issue with loader menu when was upgrading from r358827 to
>> r359028 (x86-64).
>>
>> But unfortunately the broken menu is just a part of my problem.  The
>> real pain is that a FreeBSD 13.0-CURRENT system hosted by VMware ESXi or
>> Workstation doesn't boot anymore after r358989.  An ugly workaround[1]
>> (exiting from the loader menu into the loader prompt, running ls or
>> show, scrolling the result down and then executing boot) I found some
>> time ago doesn't work anymore.  After running boot/boot -s/selecting
>> menu item, a hypervisor just shuts session down with the following
>> message: ``The firmware encountered an unexpected exception. The virtual
>> machine cannot boot.''
>>
>> The virtual guests don't have any UART (even USB) serial devices in
>> their settings.  efi-show prints result similar to what Tomoaki got:
>>
>> OK efi-show -g global -v CounOut
>> global NV,BS,RS ConOut = PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80014310)
>>
>> Undefining TERM_EMU doesn't help.  I had completely removed CFLAGS
>> assignment with TERM_EMU from stand/efi/libefi/Makefile and rebuilt
>> kernel/world -- nothing changed.  I don't define TERM_EMU in my
>> make.conf or/and src.conf.
>>
>> Reverting this revision fix booting (and menu, of course).
>>
>> FreeBSD on physical hardware boots just fine with this revision, but has
>> corrupted loader menu.
>>
>> Toomas, please help us to fix this.  I can live with the broken menu,
>> but I don't want to revert this revision every time I will upgrade my
>> virtual machines after r359028 now.
> 
> 
> Hi!
> 
> The build, are you doing build with -DNO_CLEAN? or can you run make clean in 
> stand and then build it again? Otherwise, if you can poke me on irc, I’d like 
> to get to the bottom of this.
Hello!

I'm sorry, currently I have no access to either IRC, nor my build
machine.  Therefore, I can't show you the build log.  NO_CLEAN -- no, I
don't use it.  What I've actually done regarding to testing TERM_EMU: I
removed `CFLAGS+= -DTERM_EMU` (and the .if condition wrapping this line)
from the Makefile, removed /usr/obj directory, and buildworld and
buildkernel then.  And then install rebuilt kernel/userland on a target
machine.  Nothing changed, but it should?

> 
> Regarding the issue with vm, I am afraid the roots are going much deeper 
> there. I have not got to the exact cause (and therefore a fix), but the 
> problem is not about this specific patch. The problem is about memory map, 
> specifically one just before and after we switch off Boot Services. 
That's a very bad news for me.  Looking at HEAD's commit list I hope
that's a known problem?  Or should I open a PR on bugs.FreeBSD.org?

Moreover, I believe the next snapshot of the CURRENT (which will be made
after r358989) made by the release team will be unbootable on VMware
hypervisors.

> 
> rgds,
> toomas
> 
> 
>>
>> [1]
>> https://old.reddit.com/r/freebsd/comments/drxqlm/failed_to_do_efi_boot_on_a_vmware_virtual_machine/f6om6p2/
>>  
>> 
>
> Not tried (not enough time for now as I'm mainly using stable/12),
> but possibly calling efi_cons_probe() from efi_cons_init()

svn commit: r359083 - head

2020-03-18 Thread Ed Maste
Author: emaste
Date: Wed Mar 18 20:12:46 2020
New Revision: 359083
URL: https://svnweb.freebsd.org/changeset/base/359083

Log:
  invoke _cleanobj_fast_depend_hack unconditionally
  
  Apparently make ${CLEANDIR} is leaving stale entries in .depend files;
  for now invoke the hacky cleanup in both the -DNO_CLEAN and normal
  (no -DNO_CLEAN) cases.
  
  In collaboration with:dim
  Sponsored by: The FreeBSD Foundation

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Wed Mar 18 18:26:53 2020(r359082)
+++ head/Makefile.inc1  Wed Mar 18 20:12:46 2020(r359083)
@@ -1082,9 +1082,10 @@ _cleanobj:
 .if defined(_LIBCOMPAT)
${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f 
Makefile.inc1 ${CLEANDIR}
 .endif
-.else
-   ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t 
_cleanobj_fast_depend_hack
 .endif # !defined(NO_CLEAN)
+   # XXX make cleandir left stale .depend files behind, so invoke the
+   # dependency cleanup hack unconditionally.
+   ${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t 
_cleanobj_fast_depend_hack
 _obj:
@echo
@echo "--"
___
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: r359083 - head

2020-03-18 Thread Ed Maste
On Wed, 18 Mar 2020 at 16:12, Ed Maste  wrote:
>
> Author: emaste
> Date: Wed Mar 18 20:12:46 2020
> New Revision: 359083
> URL: https://svnweb.freebsd.org/changeset/base/359083
>
> Log:
>   invoke _cleanobj_fast_depend_hack unconditionally
>
>   Apparently make ${CLEANDIR} is leaving stale entries in .depend files;
>   for now invoke the hacky cleanup in both the -DNO_CLEAN and normal
>   (no -DNO_CLEAN) cases.

To be clear this is a workaround; the make ${CLEANDIR} step in a
regular build (without -DNO_CLEAN) should remove the stale
dependencies. Once the underlying problem is fixed we can revert this
change.
___
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: r359084 - in head/contrib/llvm-project/lld/ELF: . Arch

2020-03-18 Thread Dimitry Andric
Author: dim
Date: Wed Mar 18 20:28:26 2020
New Revision: 359084
URL: https://svnweb.freebsd.org/changeset/base/359084

Log:
  Merge commit 00925aadb from llvm git (by Fangrui Song):
  
[ELF][PPC32] Fix canonical PLTs when the order does not match the PLT order
  
Reviewed By: Bdragon28
  
Differential Revision: https://reviews.llvm.org/D75394
  
  This is needed to fix miscompiled canonical PLTs on ppc32/lld10.
  
  Requested by: bdragon
  MFC after:6 weeks
  X-MFC-With:   358851
  Differential Revision: https://reviews.freebsd.org/D24109

Modified:
  head/contrib/llvm-project/lld/ELF/Arch/PPC.cpp
  head/contrib/llvm-project/lld/ELF/Relocations.cpp
  head/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
  head/contrib/llvm-project/lld/ELF/SyntheticSections.h
  head/contrib/llvm-project/lld/ELF/Writer.cpp

Modified: head/contrib/llvm-project/lld/ELF/Arch/PPC.cpp
==
--- head/contrib/llvm-project/lld/ELF/Arch/PPC.cpp  Wed Mar 18 20:12:46 
2020(r359083)
+++ head/contrib/llvm-project/lld/ELF/Arch/PPC.cpp  Wed Mar 18 20:28:26 
2020(r359084)
@@ -71,12 +71,11 @@ void writePPC32GlinkSection(uint8_t *buf, size_t numEn
   // non-GOT-non-PLT relocations referencing external functions for 
-fpie/-fPIE.
   uint32_t glink = in.plt->getVA(); // VA of .glink
   if (!config->isPic) {
-for (const Symbol *sym : in.plt->entries)
-  if (sym->needsPltAddr) {
-writePPC32PltCallStub(buf, sym->getGotPltVA(), nullptr, 0);
-buf += 16;
-glink += 16;
-  }
+for (const Symbol *sym : cast(in.plt)->canonical_plts) {
+  writePPC32PltCallStub(buf, sym->getGotPltVA(), nullptr, 0);
+  buf += 16;
+  glink += 16;
+}
   }
 
   // On PPC Secure PLT ABI, bl foo@plt jumps to a call stub, which loads an

Modified: head/contrib/llvm-project/lld/ELF/Relocations.cpp
==
--- head/contrib/llvm-project/lld/ELF/Relocations.cpp   Wed Mar 18 20:12:46 
2020(r359083)
+++ head/contrib/llvm-project/lld/ELF/Relocations.cpp   Wed Mar 18 20:28:26 
2020(r359084)
@@ -1206,6 +1206,7 @@ static void processRelocAux(InputSectionBase &sec, Rel
   // PPC32 canonical PLT entries are at the beginning of .glink
   cast(sym).value = in.plt->headerSize;
   in.plt->headerSize += 16;
+  cast(in.plt)->canonical_plts.push_back(&sym);
 }
   }
   sym.needsPltAddr = true;

Modified: head/contrib/llvm-project/lld/ELF/SyntheticSections.cpp
==
--- head/contrib/llvm-project/lld/ELF/SyntheticSections.cpp Wed Mar 18 
20:12:46 2020(r359083)
+++ head/contrib/llvm-project/lld/ELF/SyntheticSections.cpp Wed Mar 18 
20:28:26 2020(r359084)
@@ -2446,12 +2446,9 @@ PltSection::PltSection()
 : SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".plt"),
   headerSize(target->pltHeaderSize) {
   // On PowerPC, this section contains lazy symbol resolvers.
-  if (config->emachine == EM_PPC || config->emachine == EM_PPC64) {
+  if (config->emachine == EM_PPC64) {
 name = ".glink";
 alignment = 4;
-// PLTresolve is at the end.
-if (config->emachine == EM_PPC)
-  footerSize = 64;
   }
 
   // On x86 when IBT is enabled, this section contains the second PLT (lazy
@@ -2467,11 +2464,6 @@ PltSection::PltSection()
 }
 
 void PltSection::writeTo(uint8_t *buf) {
-  if (config->emachine == EM_PPC) {
-writePPC32GlinkSection(buf, entries.size());
-return;
-  }
-
   // At beginning of PLT, we have code to call the dynamic
   // linker to resolve dynsyms at runtime. Write such code.
   target->writePltHeader(buf);
@@ -2489,7 +2481,7 @@ void PltSection::addEntry(Symbol &sym) {
 }
 
 size_t PltSection::getSize() const {
-  return headerSize + entries.size() * target->pltEntrySize + footerSize;
+  return headerSize + entries.size() * target->pltEntrySize;
 }
 
 bool PltSection::isNeeded() const {
@@ -2541,6 +2533,19 @@ void IpltSection::addSymbols() {
 target->addPltSymbols(*this, off);
 off += target->pltEntrySize;
   }
+}
+
+PPC32GlinkSection::PPC32GlinkSection() {
+  name = ".glink";
+  alignment = 4;
+}
+
+void PPC32GlinkSection::writeTo(uint8_t *buf) {
+  writePPC32GlinkSection(buf, entries.size());
+}
+
+size_t PPC32GlinkSection::getSize() const {
+  return headerSize + entries.size() * target->pltEntrySize + footerSize;
 }
 
 // This is an x86-only extra PLT section and used only when a security

Modified: head/contrib/llvm-project/lld/ELF/SyntheticSections.h
==
--- head/contrib/llvm-project/lld/ELF/SyntheticSections.h   Wed Mar 18 
20:12:46 2020(r359083)
+++ head/contrib/llvm-project/lld/ELF/SyntheticSections.h   Wed Mar 18 
20:28:26 2020(r359084)
@@ -684,7 +

Re: svn commit: r359053 - head/sys/kern

2020-03-18 Thread Konstantin Belousov
On Tue, Mar 17, 2020 at 07:25:01PM -0600, Ian Lepore wrote:
> On Tue, 2020-03-17 at 17:05 -0700, John Baldwin wrote:
> > On 3/17/20 3:36 PM, Ian Lepore wrote:
> > > On Tue, 2020-03-17 at 22:27 +, Conrad Meyer wrote:
> > > > Author: cem
> > > > Date: Tue Mar 17 22:27:16 2020
> > > > New Revision: 359053
> > > > URL: https://svnweb.freebsd.org/changeset/base/359053
> > > > 
> > > > Log:
> > > >   Implement sysctl kern.boot_id
> > > >   
> > > >   Boot IDs are random, opaque 128-bit identifiers that
> > > > distinguish distinct
> > > >   system boots.  A new ID is generated each time the system
> > > > boots.  Unlike
> > > >   kern.boottime, the value is not modified by NTP
> > > > adjustments.  It remains fixed
> > > >   until the machine is restarted.
> > > >   
> > > >   PR:   244867
> > > >   Reported by:  Ricardo Fraile 
> > > >   MFC after:I do not intend to, but feel free
> > > > 
> > > > Modified:
> > > >   head/sys/kern/kern_mib.c
> > > > 
> > > > Modified: head/sys/kern/kern_mib.c
> > > > =
> > > > =
> > > > --- head/sys/kern/kern_mib.cTue Mar 17 21:29:03 2020(
> > > > r359052)
> > > > +++ head/sys/kern/kern_mib.cTue Mar 17 22:27:16 2020(
> > > > r359053)
> > > > @@ -448,6 +448,32 @@ SYSCTL_PROC(_kern, KERN_HOSTID, hostid,
> > > >  CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE
> > > > | CTLFLAG_CAPRD,
> > > >  NULL, 0, sysctl_hostid, "LU", "Host ID");
> > > >  
> > > > +static struct mtx bootid_lk;
> > > > +MTX_SYSINIT(bootid_lock, &bootid_lk, "bootid generator lock",
> > > > MTX_DEF);
> > > > +
> > > > +static int
> > > > +sysctl_bootid(SYSCTL_HANDLER_ARGS)
> > > > +{
> > > > +   static uint8_t boot_id[16];
> > > > +   static bool initialized = false;
> > > > +
> > > > +   mtx_lock(&bootid_lk);
> > > > +   if (!initialized) {
> > > > +   if (!is_random_seeded()) {
> > > > +   mtx_unlock(&bootid_lk);
> > > > +   return (ENXIO);
> > > > +   }
> > > > +   arc4random_buf(boot_id, sizeof(boot_id));
> > > > +   initialized = true;
> > > > +   }
> > > > +   mtx_unlock(&bootid_lk);
> > > > +
> > > > +   return (SYSCTL_OUT(req, boot_id, sizeof(boot_id)));
> > > > +}
> > > > +SYSCTL_PROC(_kern, OID_AUTO, boot_id,
> > > > +CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE |
> > > > CTLFLAG_CAPRD,
> > > > +NULL, 0, sysctl_bootid, "", "Random boot ID");
> > > > +
> > > >  /*
> > > >   * The osrelease string is copied from the global (osrelease in
> > > > vers.c) into
> > > >   * prison0 by a sysinit and is inherited by child jails if notG
> > > > changed at jail
> > > 
> > > This seems a bit complex.  Why run a sysinit to init a mutex so
> > > that
> > > you can safely do a lazy init of boot_id?  Seems like it would be
> > > much
> > > easier to just use a sysinit at SI_SUB_LAST to init boot_id before
> > > sysctl can reference it.
> > 
> > Presumably you may not have enough entropy by SI_SUB_LAST to generate
> > it?
> > 
> 
> I thought arc4random in the kernel could provide random numbers
> immediately (and definitely after jitter in device attachment times at
> the end of kernel init)?  This doesn't seem like the kind of thing that
> needs crypto-strength randomness.

I think that a large simplification can come from the random driver
initializing the boot_id variable immediately before setting things
so that is_random_seeded() start returning true.

But even this might be too complex,  Why not copy the value from the
boottime on boot, and not ever touch it after.
___
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: r359085 - head/contrib/llvm-project/lld/ELF

2020-03-18 Thread Dimitry Andric
Author: dim
Date: Wed Mar 18 20:38:15 2020
New Revision: 359085
URL: https://svnweb.freebsd.org/changeset/base/359085

Log:
  Merge commit 315f8a55f from llvm git (by Fangrui Song):
  
[ELF][PPC32] Don't report "relocation refers to a discarded section"
for .got2
  
Similar to D63182 [ELF][PPC64] Don't report "relocation refers to a
discarded section" for .toc
  
Reviewed By: Bdragon28
  
Differential Revision: https://reviews.llvm.org/D75419
  
  This is needed to fix compile errors when building for ppc32/lld10.
  
  Requested by: bdragon
  MFC after:6 weeks
  X-MFC-With:   358851
  Differential Revision: https://reviews.freebsd.org/D24110

Modified:
  head/contrib/llvm-project/lld/ELF/InputSection.cpp
  head/contrib/llvm-project/lld/ELF/Relocations.cpp

Modified: head/contrib/llvm-project/lld/ELF/InputSection.cpp
==
--- head/contrib/llvm-project/lld/ELF/InputSection.cpp  Wed Mar 18 20:28:26 
2020(r359084)
+++ head/contrib/llvm-project/lld/ELF/InputSection.cpp  Wed Mar 18 20:38:15 
2020(r359085)
@@ -438,12 +438,13 @@ void InputSection::copyRelocations(uint8_t *buf, Array
   // hopefully creates a frame that is ignored at runtime. Also, don't warn
   // on .gcc_except_table and debug sections.
   //
-  // See the comment in maybeReportUndefined for PPC64 .toc .
+  // See the comment in maybeReportUndefined for PPC32 .got2 and PPC64 .toc
   auto *d = dyn_cast(&sym);
   if (!d) {
 if (!sec->name.startswith(".debug") &&
 !sec->name.startswith(".zdebug") && sec->name != ".eh_frame" &&
-sec->name != ".gcc_except_table" && sec->name != ".toc") {
+sec->name != ".gcc_except_table" && sec->name != ".got2" &&
+sec->name != ".toc") {
   uint32_t secIdx = cast(sym).discardedSecIdx;
   Elf_Shdr_Impl sec =
   CHECK(file->getObj().sections(), file)[secIdx];

Modified: head/contrib/llvm-project/lld/ELF/Relocations.cpp
==
--- head/contrib/llvm-project/lld/ELF/Relocations.cpp   Wed Mar 18 20:28:26 
2020(r359084)
+++ head/contrib/llvm-project/lld/ELF/Relocations.cpp   Wed Mar 18 20:38:15 
2020(r359085)
@@ -926,8 +926,12 @@ static bool maybeReportUndefined(Symbol &sym, InputSec
   // .toc and the .rela.toc are incorrectly not placed in the comdat. The ELF
   // spec says references from outside the group to a STB_LOCAL symbol are not
   // allowed. Work around the bug.
-  if (config->emachine == EM_PPC64 &&
-  cast(sym).discardedSecIdx != 0 && sec.name == ".toc")
+  //
+  // PPC32 .got2 is similar but cannot be fixed. Multiple .got2 is infeasible
+  // because .LC0-.LTOC is not representable if the two labels are in different
+  // .got2
+  if (cast(sym).discardedSecIdx != 0 &&
+  (sec.name == ".got2" || sec.name == ".toc"))
 return false;
 
   bool isWarning =
___
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: r359086 - head/contrib/llvm-project/llvm/lib/Transforms/Scalar

2020-03-18 Thread Dimitry Andric
Author: dim
Date: Wed Mar 18 20:44:40 2020
New Revision: 359086
URL: https://svnweb.freebsd.org/changeset/base/359086

Log:
  Merge commit b8ebc11f0 from llvm git (by Sanjay Patel):
  
[EarlyCSE] avoid crashing when detecting min/max/abs patterns (PR41083)
  
As discussed in PR41083:
https://bugs.llvm.org/show_bug.cgi?id=41083
...we can assert/crash in EarlyCSE using the current hashing scheme
and instructions with flags.
  
ValueTracking's matchSelectPattern() may rely on overflow (nsw, etc)
or other flags when detecting patterns such as min/max/abs composed
of compare+select. But the value numbering / hashing mechanism used
by EarlyCSE intersects those flags to allow more CSE.
  
Several alternatives to solve this are discussed in the bug report.
This patch avoids the issue by doing simple matching of min/max/abs
patterns that never requires instruction flags. We give up some CSE
power because of that, but that is not expected to result in much
actual performance difference because InstCombine will canonicalize
these patterns when possible. It even has this comment for abs/nabs:
  
  /// Canonicalize all these variants to 1 pattern.
  /// This makes CSE more likely.
  
(And this patch adds PhaseOrdering tests to verify that the expected
transforms are still happening in the standard optimization
pipelines.
  
I left this code to use ValueTracking's "flavor" enum values, so we
don't have to change the callers' code. If we decide to go back to
using the ValueTracking call (by changing the hashing algorithm
instead), it should be obvious how to replace this chunk.
  
Differential Revision: https://reviews.llvm.org/D74285
  
  This fixes an assertion when building the math/gsl port on PowerPC64.
  
  Requested by: pkubja
  MFC after:6 weeks
  X-MFC-With:   358851

Modified:
  head/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp

Modified: head/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
==
--- head/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp   Wed Mar 
18 20:38:15 2020(r359085)
+++ head/contrib/llvm-project/llvm/lib/Transforms/Scalar/EarlyCSE.cpp   Wed Mar 
18 20:44:40 2020(r359086)
@@ -152,13 +152,50 @@ static bool matchSelectWithOptionalNotCond(Value *V, V
 std::swap(A, B);
   }
 
-  // Set flavor if we find a match, or set it to unknown otherwise; in
-  // either case, return true to indicate that this is a select we can
-  // process.
-  if (auto *CmpI = dyn_cast(Cond))
-Flavor = matchDecomposedSelectPattern(CmpI, A, B, A, B).Flavor;
-  else
-Flavor = SPF_UNKNOWN;
+  // Match canonical forms of abs/nabs/min/max. We are not using 
ValueTracking's
+  // more powerful matchSelectPattern() because it may rely on instruction 
flags
+  // such as "nsw". That would be incompatible with the current hashing
+  // mechanism that may remove flags to increase the likelihood of CSE.
+
+  // These are the canonical forms of abs(X) and nabs(X) created by 
instcombine:
+  // %N = sub i32 0, %X
+  // %C = icmp slt i32 %X, 0
+  // %ABS = select i1 %C, i32 %N, i32 %X
+  //
+  // %N = sub i32 0, %X
+  // %C = icmp slt i32 %X, 0
+  // %NABS = select i1 %C, i32 %X, i32 %N
+  Flavor = SPF_UNKNOWN;
+  CmpInst::Predicate Pred;
+  if (match(Cond, m_ICmp(Pred, m_Specific(B), m_ZeroInt())) &&
+  Pred == ICmpInst::ICMP_SLT && match(A, m_Neg(m_Specific(B {
+// ABS: B < 0 ? -B : B
+Flavor = SPF_ABS;
+return true;
+  }
+  if (match(Cond, m_ICmp(Pred, m_Specific(A), m_ZeroInt())) &&
+  Pred == ICmpInst::ICMP_SLT && match(B, m_Neg(m_Specific(A {
+// NABS: A < 0 ? A : -A
+Flavor = SPF_NABS;
+return true;
+  }
+
+  if (!match(Cond, m_ICmp(Pred, m_Specific(A), m_Specific(B {
+// Check for commuted variants of min/max by swapping predicate.
+// If we do not match the standard or commuted patterns, this is not a
+// recognized form of min/max, but it is still a select, so return true.
+if (!match(Cond, m_ICmp(Pred, m_Specific(B), m_Specific(A
+  return true;
+Pred = ICmpInst::getSwappedPredicate(Pred);
+  }
+
+  switch (Pred) {
+  case CmpInst::ICMP_UGT: Flavor = SPF_UMAX; break;
+  case CmpInst::ICMP_ULT: Flavor = SPF_UMIN; break;
+  case CmpInst::ICMP_SGT: Flavor = SPF_SMAX; break;
+  case CmpInst::ICMP_SLT: Flavor = SPF_SMIN; break;
+  default: break;
+  }
 
   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: r359087 - head/contrib/llvm-project/libcxx/include

2020-03-18 Thread Dimitry Andric
Author: dim
Date: Wed Mar 18 20:50:30 2020
New Revision: 359087
URL: https://svnweb.freebsd.org/changeset/base/359087

Log:
  Merge commit 585a3cc31 from llvm git (by me):
  
Fix -Wdeprecated-copy-dtor and -Wdeprecated-dynamic-exception-spec
warnings.
  
Summary:
The former are like:
  
libcxx/include/typeinfo:322:11: warning: definition of implicit copy
constructor for 'bad_cast' is deprecated because it has a
user-declared destructor [-Wdeprecated-copy-dtor]
  virtual ~bad_cast() _NOEXCEPT;
^
libcxx/include/typeinfo:344:11: note: in implicit copy constructor
for 'std::bad_cast' first required here
throw bad_cast();
^
  
Fix these by adding an explicitly defaulted copy constructor.
  
The latter are like:
  
libcxx/include/codecvt:105:37: warning: dynamic exception
specifications are deprecated [-Wdeprecated-dynamic-exception-spec]
virtual int do_encoding() const throw();
  ^~~
  
Fix these by using the _NOEXCEPT macro instead.
  
Reviewers: EricWF, mclow.lists, ldionne, #libc
  
Reviewed By: EricWF, #libc
  
Subscribers: dexonsmith, libcxx-commits
  
Tags: #libc
  
Differential Revision: https://reviews.llvm.org/D76150
  
  This is because we use -Wsystem-headers during buildworld, and the two
  warnings above are now triggered by default with clang 10, preventing
  most C++ code from compiling without NO_WERROR.
  
  Requested by: brooks
  MFC after:6 weeks
  X-MFC-With:   358851
  Differential Revision: https://reviews.freebsd.org/D24049

Modified:
  head/contrib/llvm-project/libcxx/include/codecvt
  head/contrib/llvm-project/libcxx/include/exception
  head/contrib/llvm-project/libcxx/include/filesystem
  head/contrib/llvm-project/libcxx/include/future
  head/contrib/llvm-project/libcxx/include/ios
  head/contrib/llvm-project/libcxx/include/memory
  head/contrib/llvm-project/libcxx/include/regex
  head/contrib/llvm-project/libcxx/include/stdexcept
  head/contrib/llvm-project/libcxx/include/system_error
  head/contrib/llvm-project/libcxx/include/typeinfo

Modified: head/contrib/llvm-project/libcxx/include/codecvt
==
--- head/contrib/llvm-project/libcxx/include/codecvtWed Mar 18 20:44:40 
2020(r359086)
+++ head/contrib/llvm-project/libcxx/include/codecvtWed Mar 18 20:50:30 
2020(r359087)
@@ -102,11 +102,11 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8 (protec
 virtual result
 do_unshift(state_type& __st,
extern_type* __to, extern_type* __to_end, extern_type*& 
__to_nxt) const;
-virtual int do_encoding() const throw();
-virtual bool do_always_noconv() const throw();
+virtual int do_encoding() const _NOEXCEPT;
+virtual bool do_always_noconv() const _NOEXCEPT;
 virtual int do_length(state_type&, const extern_type* __frm, const 
extern_type* __end,
   size_t __mx) const;
-virtual int do_max_length() const throw();
+virtual int do_max_length() const _NOEXCEPT;
 };
 
 template <>
@@ -137,11 +137,11 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8 (prote
 virtual result
 do_unshift(state_type& __st,
extern_type* __to, extern_type* __to_end, extern_type*& 
__to_nxt) const;
-virtual int do_encoding() const throw();
-virtual bool do_always_noconv() const throw();
+virtual int do_encoding() const _NOEXCEPT;
+virtual bool do_always_noconv() const _NOEXCEPT;
 virtual int do_length(state_type&, const extern_type* __frm, const 
extern_type* __end,
   size_t __mx) const;
-virtual int do_max_length() const throw();
+virtual int do_max_length() const _NOEXCEPT;
 };
 
 template <>
@@ -172,11 +172,11 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8 (prote
 virtual result
 do_unshift(state_type& __st,
extern_type* __to, extern_type* __to_end, extern_type*& 
__to_nxt) const;
-virtual int do_encoding() const throw();
-virtual bool do_always_noconv() const throw();
+virtual int do_encoding() const _NOEXCEPT;
+virtual bool do_always_noconv() const _NOEXCEPT;
 virtual int do_length(state_type&, const extern_type* __frm, const 
extern_type* __end,
   size_t __mx) const;
-virtual int do_max_length() const throw();
+virtual int do_max_length() const _NOEXCEPT;
 };
 
 template 
 virtual result
 do_unshift(state_type& __st,
extern_type* __to, extern_type* __to_end, extern_type*& 
__to_nxt) const;
-virtual int do_encoding() const throw();
-virtual bool do_always_noconv() const throw();
+virtual int do_encoding() const _NOEXCEPT;
+virtual bool do_always_noconv() const _NOEXCEPT;
 virtual int do_length(state_type&, const extern_type* __frm, const 
extern_type* __end,
   size_t 

svn commit: r359088 - head/share/mk

2020-03-18 Thread Ed Maste
Author: emaste
Date: Wed Mar 18 21:15:45 2020
New Revision: 359088
URL: https://svnweb.freebsd.org/changeset/base/359088

Log:
  src.opts.mk: drop C++11 compiler conditional from OPENMP
  
  We no longer support older C++ compilers, so do not need to explicitly
  test for C++11 support.
  
  After r339946 we stopped running `cc --version` during cleandir/obj
  stages, so stopped setting COMPILER_FEATURES.  This in turn meant
  lib/libomp was excluded from the clean stage in a normal buildworld
  (i.e., one without -DNO_CLEAN), and this is what caused recent build
  failures with errors about missing ittnotify_static.c.
  
  This commit should obviate the need for the workaround committed in
  r359083.  Thanks to bdrewery for the insight and for pushing for a
  correct fix.  There are more cleanups to be done, but this change is
  a simplification and an improvement over r359083.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Mar 18 20:50:30 2020(r359087)
+++ head/share/mk/src.opts.mk   Wed Mar 18 21:15:45 2020(r359088)
@@ -377,8 +377,7 @@ BROKEN_OPTIONS+=HYPERV
 BROKEN_OPTIONS+=NVME
 .endif
 
-.if ${COMPILER_FEATURES:Mc++11} && \
-(${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64")
+.if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "powerpc64"
 __DEFAULT_YES_OPTIONS+=OPENMP
 .else
 __DEFAULT_NO_OPTIONS+=OPENMP
___
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: r359089 - head

2020-03-18 Thread Ed Maste
Author: emaste
Date: Wed Mar 18 21:20:10 2020
New Revision: 359089
URL: https://svnweb.freebsd.org/changeset/base/359089

Log:
  Revert r359083, fixed properly by r359088
  
  r359083 introduced a workaround for stale libomp dependencies during a
  regular (no -DNO_CLEAN) buildworld.  r359088 addressed the reason the
  clean step missed libomp, so revert the workaround.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Wed Mar 18 21:15:45 2020(r359088)
+++ head/Makefile.inc1  Wed Mar 18 21:20:10 2020(r359089)
@@ -1082,10 +1082,9 @@ _cleanobj:
 .if defined(_LIBCOMPAT)
${_+_}cd ${.CURDIR}; ${LIBCOMPATWMAKE} _NO_INCLUDE_COMPILERMK=t -f 
Makefile.inc1 ${CLEANDIR}
 .endif
-.endif # !defined(NO_CLEAN)
-   # XXX make cleandir left stale .depend files behind, so invoke the
-   # dependency cleanup hack unconditionally.
+.else
${_+_}cd ${.CURDIR}; ${WMAKE} _NO_INCLUDE_COMPILERMK=t 
_cleanobj_fast_depend_hack
+.endif # !defined(NO_CLEAN)
 _obj:
@echo
@echo "--"
___
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: r359090 - head/sys/x86/x86

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 21:24:34 2020
New Revision: 359090
URL: https://svnweb.freebsd.org/changeset/base/359090

Log:
  Widen the stored io_apic_id to 8 bits.
  
  It seems that the newer Intel chipset did that, and Linux reads 8
  bits. The only detail is that all seen datasheets, even under NDA,
  claim that io apic id is 4 bits.
  
  Submitted by: jeff
  Reviewed by:  jhb
  Tested by:flo, pho
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D23965

Modified:
  head/sys/x86/x86/io_apic.c

Modified: head/sys/x86/x86/io_apic.c
==
--- head/sys/x86/x86/io_apic.c  Wed Mar 18 21:20:10 2020(r359089)
+++ head/sys/x86/x86/io_apic.c  Wed Mar 18 21:24:34 2020(r359090)
@@ -94,7 +94,7 @@ struct ioapic_intsrc {
 struct ioapic {
struct pic io_pic;
u_int io_id:8;  /* logical ID */
-   u_int io_apic_id:4;
+   u_int io_apic_id:8;
u_int io_intbase:8; /* System Interrupt base */
u_int io_numintr:8;
u_int io_haseoi:1;
___
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: r359091 - head/share/mk

2020-03-18 Thread Ed Maste
Author: emaste
Date: Wed Mar 18 21:28:55 2020
New Revision: 359091
URL: https://svnweb.freebsd.org/changeset/base/359091

Log:
  src.opts.mk: remove remaining support for pre-C++11 C++ compilers
  
  Delete the conditions that forcibly disabled GOOGLETEST and LLDB for
  pre-C++11 C++ compilers, since we no longer support such compilers.
  
  Also delete the complicated method of defaulting LIBCPLUSPLUS to YES.
  
  Prodded by:   kevans
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Mar 18 21:24:34 2020(r359090)
+++ head/share/mk/src.opts.mk   Wed Mar 18 21:28:55 2020(r359091)
@@ -125,6 +125,7 @@ __DEFAULT_YES_OPTIONS = \
 LDNS \
 LDNS_UTILS \
 LEGACY_CONSOLE \
+LIBCPLUSPLUS \
 LIBPTHREAD \
 LIBTHR \
 LLD \
@@ -386,35 +387,9 @@ __DEFAULT_NO_OPTIONS+=OPENMP
 .include 
 
 #
-# MK_* options that default to "yes" if the compiler is a C++11 compiler.
-#
-.for var in \
-LIBCPLUSPLUS
-.if !defined(MK_${var})
-.if ${COMPILER_FEATURES:Mc++11}
-.if defined(WITHOUT_${var})
-MK_${var}:=no
-.else
-MK_${var}:=yes
-.endif
-.else
-.if defined(WITH_${var})
-MK_${var}:=yes
-.else
-MK_${var}:=no
-.endif
-.endif
-.endif
-.endfor
-
-#
 # Force some options off if their dependencies are off.
 # Order is somewhat important.
 #
-.if !${COMPILER_FEATURES:Mc++11}
-MK_GOOGLETEST:=no
-.endif
-
 .if ${MK_CAPSICUM} == "no"
 MK_CASPER:=no
 .endif
@@ -553,9 +528,5 @@ MK_${vv:H}:=${MK_${vv:T}}
 #
 # Set defaults for the MK_*_SUPPORT variables.
 #
-
-.if !${COMPILER_FEATURES:Mc++11}
-MK_LLDB:=  no
-.endif
 
 .endif #  !target()
___
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: r359092 - head/sys/x86/x86

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 21:31:35 2020
New Revision: 359092
URL: https://svnweb.freebsd.org/changeset/base/359092

Log:
  Stop (trying to) renumber io apics.
  
  It does not serve any purpose now, the io apic id is not seen by
  software, and some Intel documents claim that the register is
  implemented for FUD reasons.  More, renumbering seems to not work on
  new Intel machines which actually have mismatched MADT and hw IDs.
  
  On older machines where separate APIC bus existed, unique numbering of
  all APICs was required for bus arbitration to work, but it is no
  longer true (that machines were SMP from pre-Pentium IV era).
  
  When matching PCIe IOAPIC device against MADT-enumerated IOAPICs,
  compare io_apic_id from BAR against io_apic_id read from the
  MADT-pointed register page.
  
  Reviewed by:  jhb
  Tested by:flo (previous version), pho
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D23965

Modified:
  head/sys/x86/x86/io_apic.c

Modified: head/sys/x86/x86/io_apic.c
==
--- head/sys/x86/x86/io_apic.c  Wed Mar 18 21:28:55 2020(r359091)
+++ head/sys/x86/x86/io_apic.c  Wed Mar 18 21:31:35 2020(r359092)
@@ -94,7 +94,8 @@ struct ioapic_intsrc {
 struct ioapic {
struct pic io_pic;
u_int io_id:8;  /* logical ID */
-   u_int io_apic_id:8;
+   u_int io_apic_id:8; /* Id as enumerated by MADT */
+   u_int io_hw_apic_id:8;  /* Content of APIC ID register */
u_int io_intbase:8; /* System Interrupt base */
u_int io_numintr:8;
u_int io_haseoi:1;
@@ -634,15 +635,12 @@ ioapic_create(vm_paddr_t addr, int32_t apic_id, int in
io->pci_wnd = NULL;
mtx_lock_spin(&icu_lock);
io->io_id = next_id++;
-   io->io_apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT;
-   if (apic_id != -1 && io->io_apic_id != apic_id) {
-   ioapic_write(apic, IOAPIC_ID, apic_id << APIC_ID_SHIFT);
-   mtx_unlock_spin(&icu_lock);
-   io->io_apic_id = apic_id;
-   printf("ioapic%u: Changing APIC ID to %d\n", io->io_id,
-   apic_id);
-   } else
-   mtx_unlock_spin(&icu_lock);
+   io->io_hw_apic_id = ioapic_read(apic, IOAPIC_ID) >> APIC_ID_SHIFT;
+   io->io_apic_id = apic_id == -1 ? io->io_hw_apic_id : apic_id;
+   mtx_unlock_spin(&icu_lock);
+   if (io->io_hw_apic_id != apic_id)
+   printf("ioapic%u: MADT APIC ID %d != hw id %d\n", io->io_id,
+   apic_id, io->io_hw_apic_id);
if (intbase == -1) {
intbase = next_ioapic_base;
printf("ioapic%u: Assuming intbase of %d\n", io->io_id,
@@ -1017,14 +1015,14 @@ ioapic_pci_attach(device_t dev)
}
/* Then by apic id */
STAILQ_FOREACH(io, &ioapic_list, io_next) {
-   if (io->io_apic_id == apic_id)
+   if (io->io_hw_apic_id == apic_id)
goto found;
}
mtx_unlock_spin(&icu_lock);
if (bootverbose)
device_printf(dev,
-   "cannot match pci bar apic id %d against MADT\n",
-   apic_id);
+   "cannot match pci bar apic id %d against MADT, BAR0 %#jx\n",
+   apic_id, (uintmax_t)rman_get_start(res));
 fail:
bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
return (ENXIO);
@@ -1037,13 +1035,13 @@ found:
io->pci_dev = dev;
io->pci_wnd = res;
if (bootverbose && (io->io_paddr != (vm_paddr_t)rman_get_start(res) ||
-   io->io_apic_id != apic_id)) {
+   io->io_hw_apic_id != apic_id)) {
device_printf(dev, "pci%d:%d:%d:%d pci BAR0@%jx id %d "
-   "MADT id %d paddr@%jx\n",
+   "MADT id %d hw id %d paddr@%jx\n",
pci_get_domain(dev), pci_get_bus(dev),
pci_get_slot(dev), pci_get_function(dev),
(uintmax_t)rman_get_start(res), apic_id,
-   io->io_apic_id, (uintmax_t)io->io_paddr);
+   io->io_apic_id, io->io_hw_apic_id, (uintmax_t)io->io_paddr);
}
mtx_unlock_spin(&icu_lock);
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: r359093 - head/sys/x86/x86

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 21:34:52 2020
New Revision: 359093
URL: https://svnweb.freebsd.org/changeset/base/359093

Log:
  Do not spuriously re-enable disabled io_apic pin on EOI for some 
configurations.
  
  If EOI suppression is supported but reported ioapic version is so old
  that it does not has EOI register (weird virtualization setup), fix
  Intel trick of eoi-ing by flipping pin type (edge/level) to account
  for the disabled pin.
  
  Reported by:  Juniper
  Reviewed by:  jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential revision:https://reviews.freebsd.org/D23965

Modified:
  head/sys/x86/x86/io_apic.c

Modified: head/sys/x86/x86/io_apic.c
==
--- head/sys/x86/x86/io_apic.c  Wed Mar 18 21:31:35 2020(r359092)
+++ head/sys/x86/x86/io_apic.c  Wed Mar 18 21:34:52 2020(r359093)
@@ -193,8 +193,11 @@ _ioapic_eoi_source(struct intsrc *isrc, int locked)
low1 |= IOART_TRGREDG | IOART_INTMSET;
ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(src->io_intpin),
low1);
+   low1 = src->io_lowreg;
+   if (src->io_masked != 0)
+   low1 |= IOART_INTMSET;
ioapic_write(io->io_addr, IOAPIC_REDTBL_LO(src->io_intpin),
-   src->io_lowreg);
+   low1);
if (!locked)
mtx_unlock_spin(&icu_lock);
}
___
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: r359053 - head/sys/kern

2020-03-18 Thread Ian Lepore
On Wed, 2020-03-18 at 22:36 +0200, Konstantin Belousov wrote:
> On Tue, Mar 17, 2020 at 07:25:01PM -0600, Ian Lepore wrote:
> > On Tue, 2020-03-17 at 17:05 -0700, John Baldwin wrote:
> > > On 3/17/20 3:36 PM, Ian Lepore wrote:
> > > > On Tue, 2020-03-17 at 22:27 +, Conrad Meyer wrote:
> > > > > Author: cem
> > > > > Date: Tue Mar 17 22:27:16 2020
> > > > > New Revision: 359053
> > > > > URL: https://svnweb.freebsd.org/changeset/base/359053
> > > > > 
> > > > > Log:
> > > > >   Implement sysctl kern.boot_id
> > > > >   
> > > > >   Boot IDs are random, opaque 128-bit identifiers that
> > > > > distinguish distinct
> > > > >   system boots.  A new ID is generated each time the system
> > > > > boots.  Unlike
> > > > >   kern.boottime, the value is not modified by NTP
> > > > > adjustments.  It remains fixed
> > > > >   until the machine is restarted.
> > > > >   
> > > > >   PR: 244867
> > > > >   Reported by:Ricardo Fraile 
> > > > >   MFC after:  I do not intend to, but feel free
> > > > > 
> > > > > Modified:
> > > > >   head/sys/kern/kern_mib.c
> > > > > 
> > > > > Modified: head/sys/kern/kern_mib.c
> > > > > =
> > > > > 
> > > > > =
> > > > > --- head/sys/kern/kern_mib.c  Tue Mar 17 21:29:03 2020(
> > > > > r359052)
> > > > > +++ head/sys/kern/kern_mib.c  Tue Mar 17 22:27:16 2020(
> > > > > r359053)
> > > > > @@ -448,6 +448,32 @@ SYSCTL_PROC(_kern, KERN_HOSTID, hostid,
> > > > >  CTLTYPE_ULONG | CTLFLAG_RW | CTLFLAG_PRISON |
> > > > > CTLFLAG_MPSAFE
> > > > > > CTLFLAG_CAPRD,
> > > > > 
> > > > >  NULL, 0, sysctl_hostid, "LU", "Host ID");
> > > > >  
> > > > > +static struct mtx bootid_lk;
> > > > > +MTX_SYSINIT(bootid_lock, &bootid_lk, "bootid generator
> > > > > lock",
> > > > > MTX_DEF);
> > > > > +
> > > > > +static int
> > > > > +sysctl_bootid(SYSCTL_HANDLER_ARGS)
> > > > > +{
> > > > > + static uint8_t boot_id[16];
> > > > > + static bool initialized = false;
> > > > > +
> > > > > + mtx_lock(&bootid_lk);
> > > > > + if (!initialized) {
> > > > > + if (!is_random_seeded()) {
> > > > > + mtx_unlock(&bootid_lk);
> > > > > + return (ENXIO);
> > > > > + }
> > > > > + arc4random_buf(boot_id, sizeof(boot_id));
> > > > > + initialized = true;
> > > > > + }
> > > > > + mtx_unlock(&bootid_lk);
> > > > > +
> > > > > + return (SYSCTL_OUT(req, boot_id, sizeof(boot_id)));
> > > > > +}
> > > > > +SYSCTL_PROC(_kern, OID_AUTO, boot_id,
> > > > > +CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE |
> > > > > CTLFLAG_CAPRD,
> > > > > +NULL, 0, sysctl_bootid, "", "Random boot ID");
> > > > > +
> > > > >  /*
> > > > >   * The osrelease string is copied from the global (osrelease
> > > > > in
> > > > > vers.c) into
> > > > >   * prison0 by a sysinit and is inherited by child jails if
> > > > > notG
> > > > > changed at jail
> > > > 
> > > > This seems a bit complex.  Why run a sysinit to init a mutex so
> > > > that
> > > > you can safely do a lazy init of boot_id?  Seems like it would
> > > > be
> > > > much
> > > > easier to just use a sysinit at SI_SUB_LAST to init boot_id
> > > > before
> > > > sysctl can reference it.
> > > 
> > > Presumably you may not have enough entropy by SI_SUB_LAST to
> > > generate
> > > it?
> > > 
> > 
> > I thought arc4random in the kernel could provide random numbers
> > immediately (and definitely after jitter in device attachment times
> > at
> > the end of kernel init)?  This doesn't seem like the kind of thing
> > that
> > needs crypto-strength randomness.
> 
> I think that a large simplification can come from the random driver
> initializing the boot_id variable immediately before setting things
> so that is_random_seeded() start returning true.
> 
> But even this might be too complex,  Why not copy the value from the
> boottime on boot, and not ever touch it after.

On some systems (virtually all mips, arm, and some arm64 systems),
there is no RTC and boottime doesn't get set initially until ntpd or
something else in userland runs to set time.

-- 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: r359094 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 21:54:32 2020
New Revision: 359094
URL: https://svnweb.freebsd.org/changeset/base/359094

Log:
  mlx5_core: add sysctls to report device capabilities.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 21:34:52 2020
(r359093)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 21:54:32 2020
(r359094)
@@ -1298,6 +1298,9 @@ static int init_one(struct pci_dev *pdev,
int i,err;
struct sysctl_oid *pme_sysctl_node;
struct sysctl_oid *pme_err_sysctl_node;
+   struct sysctl_oid *cap_sysctl_node;
+   struct sysctl_oid *current_cap_sysctl_node;
+   struct sysctl_oid *max_cap_sysctl_node;
 
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
priv = &dev->priv;
@@ -1365,6 +1368,186 @@ static int init_one(struct pci_dev *pdev,
0, mlx5_pme_err_desc[2 * i + 1]);
}
 
+   cap_sysctl_node = SYSCTL_ADD_NODE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(device_get_sysctl_tree(bsddev)),
+   OID_AUTO, "caps", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+   "hardware capabilities raw bitstrings");
+   if (cap_sysctl_node == NULL) {
+   err = -ENOMEM;
+   goto clean_sysctl_ctx;
+   }
+   current_cap_sysctl_node = SYSCTL_ADD_NODE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(cap_sysctl_node),
+   OID_AUTO, "current", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+   "");
+   if (current_cap_sysctl_node == NULL) {
+   err = -ENOMEM;
+   goto clean_sysctl_ctx;
+   }
+   max_cap_sysctl_node = SYSCTL_ADD_NODE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(cap_sysctl_node),
+   OID_AUTO, "max", CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+   "");
+   if (max_cap_sysctl_node == NULL) {
+   err = -ENOMEM;
+   goto clean_sysctl_ctx;
+   }
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+   OID_AUTO, "general", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_cur[MLX5_CAP_GENERAL],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(max_cap_sysctl_node),
+   OID_AUTO, "general", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_max[MLX5_CAP_GENERAL],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+   OID_AUTO, "ether", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_cur[MLX5_CAP_ETHERNET_OFFLOADS],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(max_cap_sysctl_node),
+   OID_AUTO, "ether", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_max[MLX5_CAP_ETHERNET_OFFLOADS],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+   OID_AUTO, "odp", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_cur[MLX5_CAP_ODP],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(max_cap_sysctl_node),
+   OID_AUTO, "odp", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_max[MLX5_CAP_ODP],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+   OID_AUTO, "atomic", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_cur[MLX5_CAP_ATOMIC],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(max_cap_sysctl_node),
+   OID_AUTO, "atomic", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_max[MLX5_CAP_ATOMIC],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+   OID_AUTO, "roce", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_cur[MLX5_CAP_ROCE],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(max_cap_sysctl_node),
+   OID_AUTO, "roce", CTLFLAG_RD | CTLFLAG_MPSAFE,
+   &dev->hca_caps_max[MLX5_CAP_ROCE],
+   MLX5_UN_SZ_DW(hca_cap_union) * sizeof(u32), "IU", "");
+   SYSCTL_ADD_OPAQUE(&dev->sysctl_ctx,
+   SYSCTL_CHILDREN(current_cap_sysctl_node),
+

svn commit: r359095 - in head/sys/modules: ibcore linuxkpi mlx4 mlx4en mlx4ib mlx5 mlx5en mlx5fpga_tools mlx5ib rdma/krping

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:09:16 2020
New Revision: 359095
URL: https://svnweb.freebsd.org/changeset/base/359095

Log:
  Add pci_iov_if.h header as a dependency for Linuxkpi consumers.
  
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/modules/ibcore/Makefile
  head/sys/modules/linuxkpi/Makefile
  head/sys/modules/mlx4/Makefile
  head/sys/modules/mlx4en/Makefile
  head/sys/modules/mlx4ib/Makefile
  head/sys/modules/mlx5/Makefile
  head/sys/modules/mlx5en/Makefile
  head/sys/modules/mlx5fpga_tools/Makefile
  head/sys/modules/mlx5ib/Makefile
  head/sys/modules/rdma/krping/Makefile

Modified: head/sys/modules/ibcore/Makefile
==
--- head/sys/modules/ibcore/MakefileWed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/ibcore/MakefileWed Mar 18 22:09:16 2020
(r359095)
@@ -2,7 +2,7 @@
 .PATH:  ${SRCTOP}/sys/ofed/drivers/infiniband/core
 
 KMOD=  ibcore
-SRCS=  vnode_if.h device_if.h bus_if.h pci_if.h \
+SRCS=  vnode_if.h device_if.h bus_if.h pci_if.h pci_iov_if.h \
opt_inet.h opt_inet6.h \
ib_addr.c \
ib_agent.c \

Modified: head/sys/modules/linuxkpi/Makefile
==
--- head/sys/modules/linuxkpi/Makefile  Wed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/linuxkpi/Makefile  Wed Mar 18 22:09:16 2020
(r359095)
@@ -24,6 +24,7 @@ SRCS= linux_compat.c \
 SRCS+= bus_if.h \
device_if.h \
pci_if.h \
+   pci_iov_if.h \
vnode_if.h \
usb_if.h \
opt_usb.h \

Modified: head/sys/modules/mlx4/Makefile
==
--- head/sys/modules/mlx4/Makefile  Wed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx4/Makefile  Wed Mar 18 22:09:16 2020
(r359095)
@@ -2,7 +2,7 @@
 .PATH:  ${SRCTOP}/sys/dev/mlx4/mlx4_core
 
 KMOD=  mlx4
-SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
+SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h pci_iov_if.h \
opt_inet.h opt_inet6.h \
mlx4_alloc.c \
mlx4_catas.c \

Modified: head/sys/modules/mlx4en/Makefile
==
--- head/sys/modules/mlx4en/MakefileWed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx4en/MakefileWed Mar 18 22:09:16 2020
(r359095)
@@ -2,7 +2,7 @@
 .PATH:  ${SRCTOP}/sys/dev/mlx4/mlx4_en
 
 KMOD=  mlx4en
-SRCS=  device_if.h bus_if.h pci_if.h vnode_if.h \
+SRCS=  device_if.h bus_if.h pci_if.h pci_iov_if.h vnode_if.h \
opt_inet.h opt_inet6.h \
mlx4_en_cq.c \
mlx4_en_main.c \

Modified: head/sys/modules/mlx4ib/Makefile
==
--- head/sys/modules/mlx4ib/MakefileWed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx4ib/MakefileWed Mar 18 22:09:16 2020
(r359095)
@@ -2,7 +2,7 @@
 .PATH:  ${SRCTOP}/sys/dev/mlx4/mlx4_ib
 
 KMOD=  mlx4ib
-SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h \
+SRCS=  device_if.h bus_if.h vnode_if.h pci_if.h pci_iov_if.h \
opt_inet.h opt_inet6.h \
mlx4_ib_alias_GUID.c \
mlx4_ib_mcg.c \

Modified: head/sys/modules/mlx5/Makefile
==
--- head/sys/modules/mlx5/Makefile  Wed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx5/Makefile  Wed Mar 18 22:09:16 2020
(r359095)
@@ -33,7 +33,7 @@ mlx5_vport.c \
 mlx5_vsc.c \
 mlx5_wq.c \
 mlx5_gid.c \
-device_if.h bus_if.h vnode_if.h pci_if.h \
+device_if.h bus_if.h vnode_if.h pci_if.h pci_iov_if.h \
 opt_inet.h opt_inet6.h opt_rss.h opt_ratelimit.h
 
 CFLAGS+= -I${SRCTOP}/sys/ofed/include

Modified: head/sys/modules/mlx5en/Makefile
==
--- head/sys/modules/mlx5en/MakefileWed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx5en/MakefileWed Mar 18 22:09:16 2020
(r359095)
@@ -13,7 +13,7 @@ mlx5_en_rx.c \
 mlx5_en_rl.c \
 mlx5_en_txrx.c \
 mlx5_en_port_buffer.c \
-device_if.h bus_if.h vnode_if.h pci_if.h \
+device_if.h bus_if.h vnode_if.h pci_if.h pci_iov_if.h \
 opt_inet.h opt_inet6.h opt_rss.h opt_ratelimit.h \
 opt_kern_tls.h
 

Modified: head/sys/modules/mlx5fpga_tools/Makefile
==
--- head/sys/modules/mlx5fpga_tools/MakefileWed Mar 18 21:54:32 2020
(r359094)
+++ head/sys/modules/mlx5fpga_tools/MakefileWed Mar 18 22:09:16 2020
(r359095)
@@ -7,7 +7,7 @@ SRCS= \
mlx5fpga_tools_char.c
 
 SRCS+= \
-   device_if.h bus_if.h vnode_if.h pci_if.h \
+   device_if.h bus_if.h vnode_if.h pci_if.h pci_iov_if.h \
opt_inet.h opt_inet6.h opt_rss.h opt_ratelimit.h
 

svn commit: r359096 - in head/sys/compat/linuxkpi/common: include/linux src

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:10:49 2020
New Revision: 359096
URL: https://svnweb.freebsd.org/changeset/base/359096

Log:
  linuxkpi: Add infrastructure to pass FreeBSD IOV method calls into
  pci_driver methods.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/compat/linuxkpi/common/include/linux/pci.h
  head/sys/compat/linuxkpi/common/src/linux_pci.c

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Mar 18 22:09:16 
2020(r359095)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Wed Mar 18 22:10:49 
2020(r359096)
@@ -37,11 +37,13 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -201,6 +203,11 @@ struct pci_driver {
struct device_driverdriver;
const struct pci_error_handlers   *err_handler;
boolisdrm;
+   int  (*bsd_iov_init)(device_t dev, uint16_t num_vfs,
+   const nvlist_t *pf_config);
+   void  (*bsd_iov_uninit)(device_t dev);
+   int  (*bsd_iov_add_vf)(device_t dev, uint16_t vfnum,
+   const nvlist_t *vf_config);
 };
 
 struct pci_bus {

Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c
==
--- head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Mar 18 22:09:16 
2020(r359095)
+++ head/sys/compat/linuxkpi/common/src/linux_pci.c Wed Mar 18 22:10:49 
2020(r359096)
@@ -65,6 +65,9 @@ static device_detach_t linux_pci_detach;
 static device_suspend_t linux_pci_suspend;
 static device_resume_t linux_pci_resume;
 static device_shutdown_t linux_pci_shutdown;
+static pci_iov_init_t linux_pci_iov_init;
+static pci_iov_uninit_t linux_pci_iov_uninit;
+static pci_iov_add_vf_t linux_pci_iov_add_vf;
 
 static device_method_t pci_methods[] = {
DEVMETHOD(device_probe, linux_pci_probe),
@@ -73,6 +76,9 @@ static device_method_t pci_methods[] = {
DEVMETHOD(device_suspend, linux_pci_suspend),
DEVMETHOD(device_resume, linux_pci_resume),
DEVMETHOD(device_shutdown, linux_pci_shutdown),
+   DEVMETHOD(pci_iov_init, linux_pci_iov_init),
+   DEVMETHOD(pci_iov_uninit, linux_pci_iov_uninit),
+   DEVMETHOD(pci_iov_add_vf, linux_pci_iov_add_vf),
DEVMETHOD_END
 };
 
@@ -353,6 +359,47 @@ linux_pci_shutdown(device_t dev)
if (pdev->pdrv->shutdown != NULL)
pdev->pdrv->shutdown(pdev);
return (0);
+}
+
+static int
+linux_pci_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *pf_config)
+{
+   struct pci_dev *pdev;
+   int error;
+
+   linux_set_current(curthread);
+   pdev = device_get_softc(dev);
+   if (pdev->pdrv->bsd_iov_init != NULL)
+   error = pdev->pdrv->bsd_iov_init(dev, num_vfs, pf_config);
+   else
+   error = EINVAL;
+   return (error);
+}
+
+static void
+linux_pci_iov_uninit(device_t dev)
+{
+   struct pci_dev *pdev;
+
+   linux_set_current(curthread);
+   pdev = device_get_softc(dev);
+   if (pdev->pdrv->bsd_iov_uninit != NULL)
+   pdev->pdrv->bsd_iov_uninit(dev);
+}
+
+static int
+linux_pci_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *vf_config)
+{
+   struct pci_dev *pdev;
+   int error;
+
+   linux_set_current(curthread);
+   pdev = device_get_softc(dev);
+   if (pdev->pdrv->bsd_iov_add_vf != NULL)
+   error = pdev->pdrv->bsd_iov_add_vf(dev, vfnum, vf_config);
+   else
+   error = EINVAL;
+   return (error);
 }
 
 static int
___
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: r359097 - head/usr.sbin/ntp

2020-03-18 Thread Cy Schubert
Author: cy
Date: Wed Mar 18 22:14:25 2020
New Revision: 359097
URL: https://svnweb.freebsd.org/changeset/base/359097

Log:
  PACKAGE_STRING should be the same as PACKAGE_VERSION.
  
  MFC after:3 days

Modified:
  head/usr.sbin/ntp/config.h

Modified: head/usr.sbin/ntp/config.h
==
--- head/usr.sbin/ntp/config.h  Wed Mar 18 22:10:49 2020(r359096)
+++ head/usr.sbin/ntp/config.h  Wed Mar 18 22:14:25 2020(r359097)
@@ -1468,7 +1468,7 @@
 #define PACKAGE_NAME "ntp"
 
 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntp 4.2.8p12"
+#define PACKAGE_STRING "ntp 4.2.8p14"
 
 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "ntp"
___
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: r355570 - head/sys/dev/sound/pci/hda

2020-03-18 Thread Colin Percival
On 2019-12-09 11:25, Mark Johnston wrote:
> Author: markj
> Date: Mon Dec  9 19:25:15 2019
> New Revision: 355570
> URL: https://svnweb.freebsd.org/changeset/base/355570
> 
> Log:
>   Configure headphone redirection for the Dell L780 and X1 Carbon 7th gen.
>   
>   As we do for many other laptops, put the headphone jack and speakers in
>   the same association by default so that the generic sound device
>   automatically switches between them.
>   
> [...]
> - } else if (id == HDA_CODEC_ALC256 && subid == DELL_I7577_SUBVENDOR) {
> + } else if (id == HDA_CODEC_ALC256 && (subid == DELL_I7577_SUBVENDOR ||
> + subid == DELL_L7480_SUBVENDOR)) {
>   switch (nid) {
>   case 20:
>   patch = "as=1 seq=0";> [...]

This is what we need for the Dell Latitude 7390 too -- nid20 is the internal
speakers while nid33 is the headphone jack.  Can you make the change or walk
me through what needs to be done?  (I'm not sure how the _SUBVENDOR bit
works.)

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
___
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: r359098 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:17:01 2020
New Revision: 359098
URL: https://svnweb.freebsd.org/changeset/base/359098

Log:
  mlx5: Basic PCIe side of SR-IOV support.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:14:25 2020
(r359097)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:17:01 2020
(r359098)
@@ -45,6 +45,11 @@
 #include 
 #include "mlx5_core.h"
 #include "fs_core.h"
+#ifdef PCI_IOV
+#include 
+#include 
+#include 
+#endif
 
 static const char mlx5_version[] = "Mellanox Core driver "
DRIVER_VERSION " (" DRIVER_RELDATE ")";
@@ -513,12 +518,13 @@ static int set_hca_ctrl(struct mlx5_core_dev *dev)
return err;
 }
 
-static int mlx5_core_enable_hca(struct mlx5_core_dev *dev)
+static int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id)
 {
u32 out[MLX5_ST_SZ_DW(enable_hca_out)] = {0};
u32 in[MLX5_ST_SZ_DW(enable_hca_in)] = {0};
 
MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
+   MLX5_SET(enable_hca_in, in, function_id, func_id);
return mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
 }
 
@@ -853,8 +859,11 @@ mlx5_firmware_update(struct mlx5_core_dev *dev)
 static int mlx5_pci_init(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
 {
struct pci_dev *pdev = dev->pdev;
-   int err = 0;
+   device_t bsddev;
+   int err;
 
+   pdev = dev->pdev;
+   bsddev = pdev->dev.bsddev;
pci_set_drvdata(dev->pdev, dev);
strncpy(priv->name, dev_name(&pdev->dev), MLX5_MAX_NAME_LEN);
priv->name[MLX5_MAX_NAME_LEN - 1] = 0;
@@ -905,6 +914,10 @@ err_dbg:
 
 static void mlx5_pci_close(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
 {
+#ifdef PCI_IOV
+   if (MLX5_CAP_GEN(dev, eswitch_flow_table))
+   pci_iov_detach(dev->pdev->dev.bsddev);
+#endif
iounmap(dev->iseg);
release_bar(dev->pdev);
mlx5_pci_disable_device(dev);
@@ -1035,7 +1048,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, st
goto err_cmd_cleanup;
}
 
-   err = mlx5_core_enable_hca(dev);
+   err = mlx5_core_enable_hca(dev, 0);
if (err) {
mlx5_core_err(dev, "enable hca failed\n");
goto err_cmd_cleanup;
@@ -1295,6 +1308,9 @@ static int init_one(struct pci_dev *pdev,
struct mlx5_core_dev *dev;
struct mlx5_priv *priv;
device_t bsddev = pdev->dev.bsddev;
+#ifdef PCI_IOV
+   nvlist_t *pf_schema, *vf_schema;
+#endif
int i,err;
struct sysctl_oid *pme_sysctl_node;
struct sysctl_oid *pme_err_sysctl_node;
@@ -1578,6 +1594,19 @@ static int init_one(struct pci_dev *pdev,
 
mlx5_firmware_update(dev);
 
+#ifdef PCI_IOV
+   if (MLX5_CAP_GEN(dev, vport_group_manager)) {
+   pf_schema = pci_iov_schema_alloc_node();
+   vf_schema = pci_iov_schema_alloc_node();
+   err = pci_iov_attach(bsddev, pf_schema, vf_schema);
+   if (err != 0) {
+   device_printf(bsddev,
+   "Failed to initialize SR-IOV support, error %d\n",
+   err);
+   }
+   }
+#endif
+
pci_save_state(bsddev);
return 0;
 
@@ -1723,6 +1752,54 @@ static const struct pci_error_handlers mlx5_err_handle
.resume = mlx5_pci_resume
 };
 
+#ifdef PCI_IOV
+static int
+mlx5_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *pf_config)
+{
+   struct pci_dev *pdev;
+   struct mlx5_core_dev *core_dev;
+   struct mlx5_priv *priv;
+
+   pdev = device_get_softc(dev);
+   core_dev = pci_get_drvdata(pdev);
+   priv = &core_dev->priv;
+
+   return (0);
+}
+
+static void
+mlx5_iov_uninit(device_t dev)
+{
+   struct pci_dev *pdev;
+   struct mlx5_core_dev *core_dev;
+   struct mlx5_priv *priv;
+
+   pdev = device_get_softc(dev);
+   core_dev = pci_get_drvdata(pdev);
+   priv = &core_dev->priv;
+}
+
+static int
+mlx5_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *vf_config)
+{
+   struct pci_dev *pdev;
+   struct mlx5_core_dev *core_dev;
+   struct mlx5_priv *priv;
+   int error;
+
+   pdev = device_get_softc(dev);
+   core_dev = pci_get_drvdata(pdev);
+   priv = &core_dev->priv;
+
+   error = -mlx5_core_enable_hca(core_dev, vfnum + 1);
+   if (error != 0) {
+   mlx5_core_err(core_dev, "enabling VF %d failed, error %d\n",
+   vfnum, error);
+   }
+   return (error);
+}
+#endif
+
 static int mlx5_try_fast_unload(struct mlx5_core_dev *dev)
 {
bool fast_teardown, force_teardown;
@@ -1857,7 +1934,12 @@ struct pci_d

svn commit: r359099 - head/stand/efi/libefi

2020-03-18 Thread Toomas Soome
Author: tsoome
Date: Wed Mar 18 22:21:42 2020
New Revision: 359099
URL: https://svnweb.freebsd.org/changeset/base/359099

Log:
  loader.efi: handle efi_cons_init() failure cases better
  
  if we fail to allocate buffer, set up the TERM_EMU and continue.
  On output, use TERM_EMU in case we did fail to allocate buffer.

Modified:
  head/stand/efi/libefi/efi_console.c

Modified: head/stand/efi/libefi/efi_console.c
==
--- head/stand/efi/libefi/efi_console.c Wed Mar 18 22:17:01 2020
(r359098)
+++ head/stand/efi/libefi/efi_console.c Wed Mar 18 22:21:42 2020
(r359099)
@@ -855,27 +855,28 @@ efi_cons_update_mode(void)
tp.tp_row = rows;
tp.tp_col = cols;
buffer = malloc(rows * cols * sizeof(*buffer));
-   if (buffer == NULL)
-   return (false);
+   if (buffer != NULL) {
+   teken_set_winsize(&teken, &tp);
+   a = teken_get_defattr(&teken);
 
-   teken_set_winsize(&teken, &tp);
-   a = teken_get_defattr(&teken);
+   snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
+   env_setenv("teken.fg_color", EV_VOLATILE, env,
+   efi_set_colors, env_nounset);
+   snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
+   env_setenv("teken.bg_color", EV_VOLATILE, env,
+   efi_set_colors, env_nounset);
 
-   snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
-   env_setenv("teken.fg_color", EV_VOLATILE, env, efi_set_colors,
-   env_nounset);
-   snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
-   env_setenv("teken.bg_color", EV_VOLATILE, env, efi_set_colors,
-   env_nounset);
-
-   for (int row = 0; row < rows; row++) {
-   for (int col = 0; col < cols; col++) {
-   buffer[col + row * tp.tp_col].c = ' ';
-   buffer[col + row * tp.tp_col].a = *a;
+   for (int row = 0; row < rows; row++) {
+   for (int col = 0; col < cols; col++) {
+   buffer[col + row * tp.tp_col].c = ' ';
+   buffer[col + row * tp.tp_col].a = *a;
+   }
}
}
-   } else {
+   }
+
 #ifdef TERM_EMU
+   if (buffer == NULL) {
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
DEFAULT_BGCOLOR));
end_term();
@@ -883,8 +884,8 @@ efi_cons_update_mode(void)
curs_move(&curx, &cury, curx, cury);
fg_c = DEFAULT_FGCOLOR;
bg_c = DEFAULT_BGCOLOR;
-#endif
}
+#endif
 
snprintf(env, sizeof (env), "%u", (unsigned)rows);
setenv("LINES", env, 1);
@@ -1011,15 +1012,12 @@ efi_cons_putchar(int c)
 * Don't use Teken when we're doing pure serial, or a multiple console
 * with video "primary" because that's also serial.
 */
-   if ((mode & (RB_SERIAL | RB_MULTIPLE)) != 0) {
+   if ((mode & (RB_SERIAL | RB_MULTIPLE)) != 0 || buffer == NULL) {
input_byte(ch);
return;
}
 
-   if (buffer != NULL)
-   teken_input(&teken, &ch, sizeof (ch));
-   else
-   efi_cons_efiputchar(c);
+   teken_input(&teken, &ch, sizeof (ch));
 }
 
 static int
___
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: r358989 - in head/stand/efi: libefi loader loader/arch/arm loader/arch/arm64

2020-03-18 Thread Toomas Soome via svn-src-head


> On 18. Mar 2020, at 20:41, Ruslan Garipov  wrote:
> 
> On 3/18/2020 10:29 PM, Toomas Soome via svn-src-head wrote:
>> 
>> 
>>> On 18. Mar 2020, at 18:40, Ruslan Garipov  wrote:
>>> 
>>> On 3/17/2020 5:16 PM, Tomoaki AOKI wrote:
 Hi! Thanks for your respond.
 
 Unfortunately, no.
 I'm running on ThinkPad P52, which has no com connector installed.
 No USB serial interface connected.
 
 `efi-show -g global -v ConOut` on loader prompt shows
 
 global NV,BS,RS ConOut =
 PciRoot(0,0)/Pci((0x1,oxo)/Pci(0x0,0x0)/AcpiAdr(0x80010100)
 
 Moreover, my previous idea didn't help.
 
 Neither
 console="vidconsole"
 console="eficonsole"
 console="efi_console"
 nor
 console="efi"
 in /boot/loader.conf works.
 
 Defining / undefining TERM_EMU on build are untested.
 
 Is there any setting for /boot/loader.conf to control the behavior?
 
 
 Regards.
 
 
 On Mon, 16 Mar 2020 08:26:56 +0200
 Toomas Soome  wrote:
 
> Hi!
> 
> This means, your system has UART serial device 〓 you can check this from 
> loader prompt: efi-show -g global -v ConOut or with efivar from running 
> system. This w   ould trigger efi console driver to use 
> TERM_EMU, which can be turned off by user and doing that would cause ESC 
> sequences to be passed directly to console. Might that be true in your 
> case?
> 
> rgds,
> toomas
> 
>> On 15. Mar 2020, at 17:17, Tomoaki AOKI  
>> wrote:
>> 
>> Hi.
>> 
>> This broke loader menu display on efifb. At least on amd64.
>> ESC sequences without ESC character are shown.
>> Key input (at least 1, 2 and enter) works OK.
>> I suspect outputs for SIO is sent to efifb and ESC codes are ignored.
>> 
>> Reverting this fixes the issue.
>>> I got the same issue with loader menu when was upgrading from r358827 to
>>> r359028 (x86-64).
>>> 
>>> But unfortunately the broken menu is just a part of my problem.  The
>>> real pain is that a FreeBSD 13.0-CURRENT system hosted by VMware ESXi or
>>> Workstation doesn't boot anymore after r358989.  An ugly workaround[1]
>>> (exiting from the loader menu into the loader prompt, running ls or
>>> show, scrolling the result down and then executing boot) I found some
>>> time ago doesn't work anymore.  After running boot/boot -s/selecting
>>> menu item, a hypervisor just shuts session down with the following
>>> message: ``The firmware encountered an unexpected exception. The virtual
>>> machine cannot boot.''
>>> 
>>> The virtual guests don't have any UART (even USB) serial devices in
>>> their settings.  efi-show prints result similar to what Tomoaki got:
>>> 
>>> OK efi-show -g global -v CounOut
>>> global NV,BS,RS ConOut = PciRoot(0x0)/Pci(0x2,0x0)/AcpiAdr(0x80014310)
>>> 
>>> Undefining TERM_EMU doesn't help.  I had completely removed CFLAGS
>>> assignment with TERM_EMU from stand/efi/libefi/Makefile and rebuilt
>>> kernel/world -- nothing changed.  I don't define TERM_EMU in my
>>> make.conf or/and src.conf.
>>> 
>>> Reverting this revision fix booting (and menu, of course).
>>> 
>>> FreeBSD on physical hardware boots just fine with this revision, but has
>>> corrupted loader menu.
>>> 
>>> Toomas, please help us to fix this.  I can live with the broken menu,
>>> but I don't want to revert this revision every time I will upgrade my
>>> virtual machines after r359028 now.
>> 
>> 
>> Hi!
>> 
>> The build, are you doing build with -DNO_CLEAN? or can you run make clean in 
>> stand and then build it again? Otherwise, if you can poke me on irc, I’d 
>> like to get to the bottom of this.
> Hello!
> 
> I'm sorry, currently I have no access to either IRC, nor my build
> machine.  Therefore, I can't show you the build log.  NO_CLEAN -- no, I
> don't use it.  What I've actually done regarding to testing TERM_EMU: I
> removed `CFLAGS+= -DTERM_EMU` (and the .if condition wrapping this line)
> from the Makefile, removed /usr/obj directory, and buildworld and
> buildkernel then.  And then install rebuilt kernel/userland on a target
> machine.  Nothing changed, but it should?


Please try r359099.


> 
>> 
>> Regarding the issue with vm, I am afraid the roots are going much deeper 
>> there. I have not got to the exact cause (and therefore a fix), but the 
>> problem is not about this specific patch. The problem is about memory map, 
>> specifically one just before and after we switch off Boot Services. 
> That's a very bad news for me.  Looking at HEAD's commit list I hope
> that's a known problem?  Or should I open a PR on bugs.FreeBSD.org 
> ?


PR is always good idea. Finding the exact cause and getting sure fix is 
question of time. I have done quite amount of investigation, but I can not yet 
point the finger even as there is one known issue identified. *IF* I am correct 
about the issue, the fix will take some time as it is no

svn commit: r359100 - in head/sys: dev/mlx5 dev/mlx5/mlx5_core modules/mlx5

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:30:56 2020
New Revision: 359100
URL: https://svnweb.freebsd.org/changeset/base/359100

Log:
  mlx5: Restore eswitch management code from attic.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Added:
  head/sys/dev/mlx5/mlx5_core/eswitch.h   (contents, props changed)
  head/sys/dev/mlx5/mlx5_core/flow_table.h   (contents, props changed)
  head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c   (contents, props changed)
Modified:
  head/sys/dev/mlx5/driver.h
  head/sys/modules/mlx5/Makefile

Modified: head/sys/dev/mlx5/driver.h
==
--- head/sys/dev/mlx5/driver.h  Wed Mar 18 22:21:42 2020(r359099)
+++ head/sys/dev/mlx5/driver.h  Wed Mar 18 22:30:56 2020(r359100)
@@ -628,6 +628,8 @@ struct mlx5_priv {
struct mlx5_rl_tablerl_table;
 #endif
struct mlx5_pme_stats pme_stats;
+
+   struct mlx5_eswitch *eswitch;
 };
 
 enum mlx5_device_state {

Added: head/sys/dev/mlx5/mlx5_core/eswitch.h
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/mlx5/mlx5_core/eswitch.h   Wed Mar 18 22:30:56 2020
(r359100)
@@ -0,0 +1,169 @@
+/*-
+ * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef __MLX5_ESWITCH_H__
+#define __MLX5_ESWITCH_H__
+
+#include 
+#include 
+
+#define MLX5_MAX_UC_PER_VPORT(dev) \
+   (1 << MLX5_CAP_GEN(dev, log_max_current_uc_list))
+
+#define MLX5_MAX_MC_PER_VPORT(dev) \
+   (1 << MLX5_CAP_GEN(dev, log_max_current_mc_list))
+
+#define MLX5_L2_ADDR_HASH_SIZE (BIT(BITS_PER_BYTE))
+#define MLX5_L2_ADDR_HASH(addr) (addr[5])
+
+/* L2 -mac address based- hash helpers */
+struct l2addr_node {
+   struct hlist_node hlist;
+   u8addr[ETH_ALEN];
+};
+
+#define for_each_l2hash_node(hn, tmp, hash, i) \
+   for (i = 0; i < MLX5_L2_ADDR_HASH_SIZE; i++) \
+   hlist_for_each_entry_safe(hn, tmp, &hash[i], hlist)
+
+#define l2addr_hash_find(hash, mac, type) ({\
+   int ix = MLX5_L2_ADDR_HASH(mac);\
+   bool found = false; \
+   type *ptr = NULL;   \
+   \
+   hlist_for_each_entry(ptr, &hash[ix], node.hlist)\
+   if (ether_addr_equal(ptr->node.addr, mac)) {\
+   found = true;   \
+   break;  \
+   }   \
+   if (!found) \
+   ptr = NULL; \
+   ptr;\
+})
+
+#define l2addr_hash_add(hash, mac, type, gfp) ({\
+   int ix = MLX5_L2_ADDR_HASH(mac);\
+   type *ptr = NULL;   \
+   \
+   ptr = kzalloc(sizeof(type), gfp);   \
+   if (ptr) {  \
+   ether_addr_copy(ptr->node.addr, mac);   \
+   hlist_add_head(&ptr->node.hlist, &hash[ix]);\
+   }   \
+   ptr;\
+})
+
+#define l2addr_hash_del(ptr) ({ \
+   hlist_del(&ptr->node.hlist);

svn commit: r359101 - in head/sys/dev/mlx5: . mlx5_core mlx5_en

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:33:39 2020
New Revision: 359101
URL: https://svnweb.freebsd.org/changeset/base/359101

Log:
  mlx5: Integrate eswitch and mpfs management code.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
  head/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
  head/sys/dev/mlx5/mpfs.h

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c  Wed Mar 18 22:30:56 2020
(r359100)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c  Wed Mar 18 22:33:39 2020
(r359101)
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "mlx5_core.h"
 #include "eswitch.h"
 
@@ -212,81 +213,6 @@ static int modify_esw_vport_cvlan(struct mlx5_core_dev
return modify_esw_vport_context_cmd(dev, vport, in, sizeof(in));
 }
 
-/* HW L2 Table (MPFS) management */
-static int set_l2_table_entry_cmd(struct mlx5_core_dev *dev, u32 index,
- u8 *mac, u8 vlan_valid, u16 vlan)
-{
-   u32 in[MLX5_ST_SZ_DW(set_l2_table_entry_in)] = {0};
-   u32 out[MLX5_ST_SZ_DW(set_l2_table_entry_out)] = {0};
-   u8 *in_mac_addr;
-
-   MLX5_SET(set_l2_table_entry_in, in, opcode,
-MLX5_CMD_OP_SET_L2_TABLE_ENTRY);
-   MLX5_SET(set_l2_table_entry_in, in, table_index, index);
-   MLX5_SET(set_l2_table_entry_in, in, vlan_valid, vlan_valid);
-   MLX5_SET(set_l2_table_entry_in, in, vlan, vlan);
-
-   in_mac_addr = MLX5_ADDR_OF(set_l2_table_entry_in, in, mac_address);
-   ether_addr_copy(&in_mac_addr[2], mac);
-
-   return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
-}
-
-static int del_l2_table_entry_cmd(struct mlx5_core_dev *dev, u32 index)
-{
-   u32 in[MLX5_ST_SZ_DW(delete_l2_table_entry_in)] = {0};
-   u32 out[MLX5_ST_SZ_DW(delete_l2_table_entry_out)] = {0};
-
-   MLX5_SET(delete_l2_table_entry_in, in, opcode,
-MLX5_CMD_OP_DELETE_L2_TABLE_ENTRY);
-   MLX5_SET(delete_l2_table_entry_in, in, table_index, index);
-   return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
-}
-
-static int alloc_l2_table_index(struct mlx5_l2_table *l2_table, u32 *ix)
-{
-   int err = 0;
-
-   *ix = find_first_zero_bit(l2_table->bitmap, l2_table->size);
-   if (*ix >= l2_table->size)
-   err = -ENOSPC;
-   else
-   __set_bit(*ix, l2_table->bitmap);
-
-   return err;
-}
-
-static void free_l2_table_index(struct mlx5_l2_table *l2_table, u32 ix)
-{
-   __clear_bit(ix, l2_table->bitmap);
-}
-
-static int set_l2_table_entry(struct mlx5_core_dev *dev, u8 *mac,
- u8 vlan_valid, u16 vlan,
- u32 *index)
-{
-   struct mlx5_l2_table *l2_table = &dev->priv.eswitch->l2_table;
-   int err;
-
-   err = alloc_l2_table_index(l2_table, index);
-   if (err)
-   return err;
-
-   err = set_l2_table_entry_cmd(dev, *index, mac, vlan_valid, vlan);
-   if (err)
-   free_l2_table_index(l2_table, *index);
-
-   return err;
-}
-
-static void del_l2_table_entry(struct mlx5_core_dev *dev, u32 index)
-{
-   struct mlx5_l2_table *l2_table = &dev->priv.eswitch->l2_table;
-
-   del_l2_table_entry_cmd(dev, index);
-   free_l2_table_index(l2_table, index);
-}
-
 /* E-Switch FDB */
 static struct mlx5_flow_rule *
 esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport)
@@ -435,7 +361,7 @@ static int esw_add_uc_addr(struct mlx5_eswitch *esw, s
return -ENOMEM;
esw_uc->vport = vport;
 
-   err = set_l2_table_entry(esw->dev, mac, 0, 0, &esw_uc->table_index);
+   err = mlx5_mpfs_add_mac(esw->dev, &esw_uc->table_index, mac, 0, 0);
if (err)
goto abort;
 
@@ -467,7 +393,7 @@ static int esw_del_uc_addr(struct mlx5_eswitch *esw, s
esw_debug(esw->dev, "\tDELETE UC MAC: vport[%d] %pM index:%d fr(%p)\n",
  vport, mac, esw_uc->table_index, vaddr->flow_rule);
 
-   del_l2_table_entry(esw->dev, esw_uc->table_index);
+   mlx5_mpfs_del_mac(esw->dev, esw_uc->table_index);
 
if (vaddr->flow_rule)
mlx5_del_flow_rule(vaddr->flow_rule);

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c Wed Mar 18 22:30:56 2020
(r359100)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c Wed Mar 18 22:33:39 2020
(r359101)
@@ -39,7 +39,8 @@
 #defineMPFS_UNLOCK(dev) spin_unlock(&(dev)->mpfs.spinlock)
 
 int
-mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac)
+mlx5_mpfs_add_mac(struct mlx5_core_dev *dev, u32 *p_index, const u8 *mac,
+u8 vlan_valid, u16 

svn commit: r359102 - head/sys/dev/mlx5

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:38:57 2020
New Revision: 359102
URL: https://svnweb.freebsd.org/changeset/base/359102

Log:
  mlx5: Add 'follow' vport state, relevant for VFs.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/device.h

Modified: head/sys/dev/mlx5/device.h
==
--- head/sys/dev/mlx5/device.h  Wed Mar 18 22:33:39 2020(r359101)
+++ head/sys/dev/mlx5/device.h  Wed Mar 18 22:38:57 2020(r359102)
@@ -839,6 +839,7 @@ static inline int mlx5_host_is_le(void)
 enum {
VPORT_STATE_DOWN= 0x0,
VPORT_STATE_UP  = 0x1,
+   VPORT_STATE_FOLLOW  = 0x2,
 };
 
 enum {
___
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: r359103 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:40:26 2020
New Revision: 359103
URL: https://svnweb.freebsd.org/changeset/base/359103

Log:
  mlx5: Use eswitch interface to configure VFs steering.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:38:57 2020
(r359102)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:40:26 2020
(r359103)
@@ -39,11 +39,13 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include "mlx5_core.h"
+#include "eswitch.h"
 #include "fs_core.h"
 #ifdef PCI_IOV
 #include 
@@ -176,6 +178,10 @@ static struct mlx5_profile profiles[] = {
},
 };
 
+#ifdef PCI_IOV
+static const char iov_mac_addr_name[] = "mac-addr";
+#endif
+
 static int set_dma_caps(struct pci_dev *pdev)
 {
struct mlx5_core_dev *dev = pci_get_drvdata(pdev);
@@ -1236,6 +1242,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, 
 
mlx5_unregister_device(dev);
 
+   mlx5_eswitch_cleanup(dev->priv.eswitch);
mlx5_fpga_device_stop(dev);
mlx5_mpfs_destroy(dev);
mlx5_cleanup_fs(dev);
@@ -1596,12 +1603,20 @@ static int init_one(struct pci_dev *pdev,
 
 #ifdef PCI_IOV
if (MLX5_CAP_GEN(dev, vport_group_manager)) {
-   pf_schema = pci_iov_schema_alloc_node();
-   vf_schema = pci_iov_schema_alloc_node();
-   err = pci_iov_attach(bsddev, pf_schema, vf_schema);
-   if (err != 0) {
-   device_printf(bsddev,
+   err = mlx5_eswitch_init(dev);
+   if (err == 0) {
+   pf_schema = pci_iov_schema_alloc_node();
+   vf_schema = pci_iov_schema_alloc_node();
+   pci_iov_schema_add_unicast_mac(vf_schema,
+   iov_mac_addr_name, 0, NULL);
+   err = pci_iov_attach(bsddev, pf_schema, vf_schema);
+   if (err != 0) {
+   device_printf(bsddev,
"Failed to initialize SR-IOV support, error %d\n",
+   err);
+   }
+   } else {
+   mlx5_core_err(dev, "eswitch init failed, error %d\n",
err);
}
}
@@ -1759,12 +1774,14 @@ mlx5_iov_init(device_t dev, uint16_t num_vfs, const nv
struct pci_dev *pdev;
struct mlx5_core_dev *core_dev;
struct mlx5_priv *priv;
+   int err;
 
pdev = device_get_softc(dev);
core_dev = pci_get_drvdata(pdev);
priv = &core_dev->priv;
 
-   return (0);
+   err = mlx5_eswitch_enable_sriov(priv->eswitch, num_vfs);
+   return (-err);
 }
 
 static void
@@ -1777,6 +1794,8 @@ mlx5_iov_uninit(device_t dev)
pdev = device_get_softc(dev);
core_dev = pci_get_drvdata(pdev);
priv = &core_dev->priv;
+
+   mlx5_eswitch_disable_sriov(priv->eswitch);
 }
 
 static int
@@ -1785,16 +1804,32 @@ mlx5_iov_add_vf(device_t dev, uint16_t vfnum, const nv
struct pci_dev *pdev;
struct mlx5_core_dev *core_dev;
struct mlx5_priv *priv;
+   const void *mac;
+   size_t mac_size;
int error;
 
pdev = device_get_softc(dev);
core_dev = pci_get_drvdata(pdev);
priv = &core_dev->priv;
 
+   if (nvlist_exists_binary(vf_config, iov_mac_addr_name)) {
+   mac = nvlist_get_binary(vf_config, iov_mac_addr_name,
+   &mac_size);
+   error = -mlx5_eswitch_set_vport_mac(priv->eswitch,
+   vfnum + 1, __DECONST(u8 *, mac));
+   }
+
+   error = -mlx5_eswitch_set_vport_state(priv->eswitch, vfnum + 1,
+   VPORT_STATE_FOLLOW);
+   if (error != 0) {
+   mlx5_core_err(core_dev,
+   "upping vport for VF %d failed, error %d\n",
+   vfnum + 1, error);
+   }
error = -mlx5_core_enable_hca(core_dev, vfnum + 1);
if (error != 0) {
mlx5_core_err(core_dev, "enabling VF %d failed, error %d\n",
-   vfnum, error);
+   vfnum + 1, error);
}
return (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: r359104 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:43:39 2020
New Revision: 359104
URL: https://svnweb.freebsd.org/changeset/base/359104

Log:
  mlx5: Read number of VF ports from the SR-IOV cap.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/eswitch.h
  head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/mlx5_core/eswitch.h
==
--- head/sys/dev/mlx5/mlx5_core/eswitch.h   Wed Mar 18 22:40:26 2020
(r359103)
+++ head/sys/dev/mlx5/mlx5_core/eswitch.h   Wed Mar 18 22:43:39 2020
(r359104)
@@ -152,7 +152,7 @@ struct mlx5_esw_vport_info {
 };
 
 /* E-Switch API */
-int mlx5_eswitch_init(struct mlx5_core_dev *dev);
+int mlx5_eswitch_init(struct mlx5_core_dev *dev, int total_vports);
 void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
 void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe);
 int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs);

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c  Wed Mar 18 22:40:26 2020
(r359103)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c  Wed Mar 18 22:43:39 2020
(r359104)
@@ -1081,10 +1081,9 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *e
esw_enable_vport(esw, 0, UC_ADDR_CHANGE);
 }
 
-int mlx5_eswitch_init(struct mlx5_core_dev *dev)
+int mlx5_eswitch_init(struct mlx5_core_dev *dev, int total_vports)
 {
int l2_table_size = 1 << MLX5_CAP_GEN(dev, log_max_l2_table);
-   int total_vports = 1;
struct mlx5_eswitch *esw;
int vport_num;
int err;

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:40:26 2020
(r359103)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:43:39 2020
(r359104)
@@ -1317,6 +1317,7 @@ static int init_one(struct pci_dev *pdev,
device_t bsddev = pdev->dev.bsddev;
 #ifdef PCI_IOV
nvlist_t *pf_schema, *vf_schema;
+   int num_vfs, sriov_pos;
 #endif
int i,err;
struct sysctl_oid *pme_sysctl_node;
@@ -1603,7 +1604,14 @@ static int init_one(struct pci_dev *pdev,
 
 #ifdef PCI_IOV
if (MLX5_CAP_GEN(dev, vport_group_manager)) {
-   err = mlx5_eswitch_init(dev);
+   if (pci_find_extcap(bsddev, PCIZ_SRIOV, &sriov_pos) == 0) {
+   num_vfs = pci_read_config(bsddev, sriov_pos +
+   PCIR_SRIOV_TOTAL_VFS, 2);
+   } else {
+   mlx5_core_err(dev, "cannot find SR-IOV PCIe cap\n");
+   num_vfs = 0;
+   }
+   err = mlx5_eswitch_init(dev, 1 + num_vfs);
if (err == 0) {
pf_schema = pci_iov_schema_alloc_node();
vf_schema = pci_iov_schema_alloc_node();
@@ -1780,6 +1788,10 @@ mlx5_iov_init(device_t dev, uint16_t num_vfs, const nv
core_dev = pci_get_drvdata(pdev);
priv = &core_dev->priv;
 
+   if (priv->eswitch == NULL)
+   return (ENXIO);
+   if (priv->eswitch->total_vports < num_vfs + 1)
+   num_vfs = priv->eswitch->total_vports - 1;
err = mlx5_eswitch_enable_sriov(priv->eswitch, num_vfs);
return (-err);
 }
@@ -1811,6 +1823,9 @@ mlx5_iov_add_vf(device_t dev, uint16_t vfnum, const nv
pdev = device_get_softc(dev);
core_dev = pci_get_drvdata(pdev);
priv = &core_dev->priv;
+
+   if (vfnum + 1 >= priv->eswitch->total_vports)
+   return (ENXIO);
 
if (nvlist_exists_binary(vf_config, iov_mac_addr_name)) {
mac = nvlist_get_binary(vf_config, iov_mac_addr_name,
___
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: r359105 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:44:48 2020
New Revision: 359105
URL: https://svnweb.freebsd.org/changeset/base/359105

Log:
  mlx5: Route NIC_VPORT_CHANGE events to eswitch code.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_eq.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_eq.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_eq.c   Wed Mar 18 22:43:39 2020
(r359104)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_eq.c   Wed Mar 18 22:44:48 2020
(r359105)
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include "mlx5_core.h"
+#include "eswitch.h"
 
 #include "opt_rss.h"
 
@@ -65,7 +66,8 @@ enum {
   (1ull << MLX5_EVENT_TYPE_PORT_CHANGE)| \
   (1ull << MLX5_EVENT_TYPE_SRQ_CATAS_ERROR)| \
   (1ull << MLX5_EVENT_TYPE_SRQ_LAST_WQE)   | \
-  (1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT))
+  (1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT)   | \
+  (1ull << MLX5_EVENT_TYPE_NIC_VPORT_CHANGE))
 
 struct map_eq_in {
u64 mask;
@@ -353,6 +355,9 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, stru
 MLX5_DEV_EVENT_VPORT_CHANGE,
 (unsigned long)vport_num);
}
+   if (dev->priv.eswitch != NULL)
+   mlx5_eswitch_vport_event(dev->priv.eswitch,
+   eqe);
break;
 
case MLX5_EVENT_TYPE_FPGA_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: r359106 - head/sys/dev/mlx5/mlx5_core

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Wed Mar 18 22:47:14 2020
New Revision: 359106
URL: https://svnweb.freebsd.org/changeset/base/359106

Log:
  mlx5_core: lower the severity of message noting that no SR-IOV cap is present.
  
  Reviewed by:  hselasky
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_main.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:44:48 2020
(r359105)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_main.c Wed Mar 18 22:47:14 2020
(r359106)
@@ -1608,7 +1608,7 @@ static int init_one(struct pci_dev *pdev,
num_vfs = pci_read_config(bsddev, sriov_pos +
PCIR_SRIOV_TOTAL_VFS, 2);
} else {
-   mlx5_core_err(dev, "cannot find SR-IOV PCIe cap\n");
+   mlx5_core_info(dev, "cannot find SR-IOV PCIe cap\n");
num_vfs = 0;
}
err = mlx5_eswitch_init(dev, 1 + num_vfs);
___
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: r359110 - head/sys/dev/ciss

2020-03-18 Thread Alexander Motin
Author: mav
Date: Thu Mar 19 00:19:50 2020
New Revision: 359110
URL: https://svnweb.freebsd.org/changeset/base/359110

Log:
  Add missing STAILQ_INIT() in ciss_disable_adapter().
  
  I think it should fix reported panic after "ADAPTER HEARTBEAT FAILED".
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/dev/ciss/ciss.c

Modified: head/sys/dev/ciss/ciss.c
==
--- head/sys/dev/ciss/ciss.cWed Mar 18 23:53:34 2020(r359109)
+++ head/sys/dev/ciss/ciss.cThu Mar 19 00:19:50 2020(r359110)
@@ -3566,6 +3566,7 @@ ciss_disable_adapter(struct ciss_softc *sc)
 pci_disable_busmaster(sc->ciss_dev);
 sc->ciss_flags &= ~CISS_FLAG_RUNNING;
 
+STAILQ_INIT(&qh);
 for (i = 1; i < sc->ciss_max_requests; i++) {
cr = &sc->ciss_request[i];
if ((cr->cr_flags & CISS_REQ_BUSY) == 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: r359111 - head/sys/conf

2020-03-18 Thread Konstantin Belousov
Author: kib
Date: Thu Mar 19 00:53:31 2020
New Revision: 359111
URL: https://svnweb.freebsd.org/changeset/base/359111

Log:
  Add file for static compilation of mlx5.
  
  Sponsored by: Mellanox Technologies
  MFC after:2 weeks

Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Mar 19 00:19:50 2020(r359110)
+++ head/sys/conf/files Thu Mar 19 00:53:31 2020(r359111)
@@ -4725,6 +4725,8 @@ dev/mlx5/mlx5_core/mlx5_diagnostics.c 
optional mlx5 p
compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_eq.c   optional mlx5 pci   \
compile-with "${OFED_C}"
+dev/mlx5/mlx5_core/mlx5_eswitch.c  optional mlx5 pci   \
+   compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_fs_cmd.c   optional mlx5 pci   \
compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_fs_tree.c  optional mlx5 pci   \
___
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: r359112 - in head: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2020-03-18 Thread Alexander Motin
Author: mav
Date: Thu Mar 19 01:05:54 2020
New Revision: 359112
URL: https://svnweb.freebsd.org/changeset/base/359112

Log:
  MFOpenZFS: make zil max block size tunable
  
  We've observed that on some highly fragmented pools, most metaslab
  allocations are small (~2-8KB), but there are some large, 128K
  allocations.  The large allocations are for ZIL blocks.  If there is a
  lot of fragmentation, the large allocations can be hard to satisfy.
  
  The most common impact of this is that we need to check (and thus load)
  lots of metaslabs from the ZIL allocation code path, causing sync writes
  to wait for metaslabs to load, which can take a second or more.  In the
  worst case, we may not be able to satisfy the allocation, in which case
  the ZIL will resort to txg_wait_synced() to ensure the change is on
  disk.
  
  To provide a workaround for this, this change adds a tunable that can
  reduce the size of ZIL blocks.
  
  External-issue: DLPX-61719
  Reviewed-by: George Wilson 
  Reviewed-by: Paul Dagnelie 
  Reviewed-by: Brian Behlendorf 
  Signed-off-by: Matthew Ahrens 
  Closes #8865
  openzfs/zfs@b8738257c2607c73c731ce8e0fd73282b266d6ef
  
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c

Modified: head/cddl/contrib/opensolaris/cmd/ztest/ztest.c
==
--- head/cddl/contrib/opensolaris/cmd/ztest/ztest.c Thu Mar 19 00:53:31 
2020(r359111)
+++ head/cddl/contrib/opensolaris/cmd/ztest/ztest.c Thu Mar 19 01:05:54 
2020(r359112)
@@ -1544,7 +1544,7 @@ ztest_log_write(ztest_ds_t *zd, dmu_tx_t *tx, lr_write
if (zil_replaying(zd->zd_zilog, tx))
return;
 
-   if (lr->lr_length > ZIL_MAX_LOG_DATA)
+   if (lr->lr_length > zil_max_log_data(zd->zd_zilog))
write_state = WR_INDIRECT;
 
itx = zil_itx_create(TX_WRITE,

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h   Thu Mar 
19 00:53:31 2020(r359111)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h   Thu Mar 
19 01:05:54 2020(r359112)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  */
 
@@ -451,6 +451,9 @@ extern int  zil_bp_tree_add(zilog_t *zilog, const blkpt
 extern voidzil_set_sync(zilog_t *zilog, uint64_t syncval);
 
 extern voidzil_set_logbias(zilog_t *zilog, uint64_t slogval);
+
+extern uint64_tzil_max_copied_data(zilog_t *zilog);
+extern uint64_tzil_max_log_data(zilog_t *zilog);
 
 extern int zil_replay_disable;
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h  Thu Mar 
19 00:53:31 2020(r359111)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h  Thu Mar 
19 01:05:54 2020(r359112)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
  */
 
@@ -208,34 +208,19 @@ struct zilog {
uint_t  zl_prev_rotor;  /* rotor for zl_prev[] */
txg_node_t  zl_dirty_link;  /* protected by dp_dirty_zilogs list */
uint64_tzl_dirty_max_txg; /* highest txg used to dirty zilog */
+   /*
+* Max block size for this ZIL.  Note that this can not be changed
+* while the ZIL is in use because consumers (ZPL/zvol) need to take
+* this into account when deciding between WR_COPIED and WR_NEED_COPY
+* (see zil_max_copied_data()).
+*/
+   uint64_tzl_max_block_size;
 };
 
 typedef struct zil_bp_node {
dva_t   zn_dva;
avl_node_t  zn_node;
 } zil_bp_node_t;
-
-/*
- * Maximum amount of write data that can be put into single log block.
- */
-#defineZIL_MAX_LOG_DATA (SPA_OLD_MAXBLOCKSIZE - sizeof (zil_chain_t) - 
\
-sizeof (lr_write_t))
-#defineZIL_MAX_COPIED_DATA \
-((SPA_OLD_MAXBLOCKSIZE - sizeof (zil_chain_t)) / 2 - sizeof (lr_write_t))
-
-/*
- * Maximum amou

svn commit: r359118 - head/lib/libc/nls

2020-03-18 Thread Xin LI
Author: delphij
Date: Thu Mar 19 06:33:06 2020
New Revision: 359118
URL: https://svnweb.freebsd.org/changeset/base/359118

Log:
  Fix race condition in catopen(3).
  
  The current code uses a rwlock to protect the cached list, which
  in turn holds a list of catentry objects, and increments reference
  count while holding only read lock.
  
  Fix this by converting the reference counter to use atomic operations.
  
  While I'm there, also perform some clean ups around memory operations.
  
  PR:   202636
  Reported by:  Henry Hu 
  Reviewed by:  markj
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D24095

Modified:
  head/lib/libc/nls/msgcat.c

Modified: head/lib/libc/nls/msgcat.c
==
--- head/lib/libc/nls/msgcat.c  Thu Mar 19 03:37:02 2020(r359117)
+++ head/lib/libc/nls/msgcat.c  Thu Mar 19 06:33:06 2020(r359118)
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include  /* for ntohl() */
+#include 
 
 #include 
 #include 
@@ -76,19 +77,25 @@ __FBSDID("$FreeBSD$");
 
 #defineNLERR   ((nl_catd) -1)
 #define NLRETERR(errc)  { errno = errc; return (NLERR); }
-#define SAVEFAIL(n, l, e)  { WLOCK(NLERR); 
\
- np = malloc(sizeof(struct catentry)); 
\
+#define SAVEFAIL(n, l, e)  { np = calloc(1, sizeof(struct catentry));  
\
  if (np != NULL) { 
\
np->name = strdup(n);   
\
-   np->path = NULL;
\
np->catd = NLERR;   
\
-   np->refcount = 0;   
\
np->lang = (l == NULL) ? NULL : 
\
strdup(l);  
\
np->caterrno = e;   
\
-   SLIST_INSERT_HEAD(&cache, np, list);
\
+   if (np->name == NULL || 
\
+   (l != NULL && np->lang == NULL)) {  
\
+   free(np->name); 
\
+   free(np->lang); 
\
+   free(np);   
\
+   } else {
\
+   WLOCK(NLERR);   
\
+   SLIST_INSERT_HEAD(&cache, np,   
\
+   list);  
\
+   UNLOCK; 
\
+   }   
\
  } 
\
- UNLOCK;   
\
  errno = e;
\
}
 
@@ -152,7 +159,7 @@ catopen(const char *name, int type)
NLRETERR(np->caterrno);
} else {
/* Found cached successful entry */
-   np->refcount++;
+   atomic_add_int(&np->refcount, 1);
UNLOCK;
return (np->catd);
}
@@ -355,8 +362,7 @@ catclose(nl_catd catd)
WLOCK(-1);
SLIST_FOREACH(np, &cache, list) {
if (catd == np->catd) {
-   np->refcount--;
-   if (np->refcount == 0)
+   if (atomic_fetchadd_int(&np->refcount, -1) == 1)
catfree(np);
break;
}
@@ -376,6 +382,7 @@ load_msgcat(const char *path, const char *name, const 
nl_catd catd;
struct catentry *np;
void *data;
+   char *copy_path, *copy_name, *copy_lang;
int fd;
 
/* path/name will never be NULL here */
@@ -387,7 +394,7 @@ load_msgcat(const char *path, const char *name, const 
RLOCK(NLERR);
SLIST_FOREACH(np, &cache, list) {
if ((np->path != NULL) && (strcmp(np->path, path) == 0)) {
-   np->refcount++;
+   atomic_add_int(&np->refcount, 1);
UNLOCK;
return (np->catd);
}
@@ -432,7 +439,20 @@ load_msgcat(const char *path, const