bdd57cbb rmacklem Nov. 26, 2021, 11:42 p.m.
For a LayoutReturn when using the Flexible File Layout,
error reports may be provided in the request.
Sanity check the size of these error reports and
check that they exist before calling nfsrv_flexlayouterr().

Reported by:
Tested by:
PR:	260012
MFC after:	2 weeks
22f7bcb5 rmacklem Nov. 26, 2021, 11:28 p.m.
Reported by:
Tested by:
PR:	259996
MFC after:	2 weeks
18790219 mjg Nov. 26, 2021, 7:32 p.m.
Reported by:	yasu
Fixes: 3ffcfa599e29686c ("vfs: add vop_stdadd_writecount_nomsync")
f89842a7 imp Nov. 26, 2021, 7:22 p.m.
4318dc9d imp Nov. 26, 2021, 7:22 p.m.
Remove the now-bogus WITH_NAND and WITHOUT_NAND flags.

Sponsored by:		Netflix
ae92ace0 andrew Nov. 26, 2021, 2:44 p.m.
With the update to llvm 13 we are able to tell the compiler it can find
the SSP canary relative to the register that holds the userspace stack
pointer. As this is unused in most of the kernel it can be used here
to point to a per-thread SSP canary.

As the kernel could be built with an old toolchain, e.g. when upgrading
from 13, add a warning that the options was enabled but the compiler
doesn't support it to both the build and kernel boot.

Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:
7b3642da markj Nov. 26, 2021, 2:39 p.m.
The compilation of several libraries under cddl/lib is not conditional
on MK_ZFS = "yes", so their dependency on libspl is not conditional
either.  Unbreak buildworld when WITHOUT_ZFS is set.

Reported by:	bz
Fixes:		9e9c651caceb ("cddl: fix missing ZFS library dependencies")
MFC after:	1 week
ff1e8581 avg Nov. 26, 2021, 2:20 p.m.
Most prominently, add support for a transfer where a write with no-stop
flag is followed by a write with no-start flag.  Logically, it's a
single larger write, but consumers may want to split it like that
because one part can be a register ID and the other part can be data to
be written to (or starting at) that register.

Such a transfer can be created by i2c tool and iic(4) driver, e.g., for
an EEPROM write at specific offset:
    i2c -m tr -a 0x50 -d w -w 16 -o 0 -c 8 -v < /dev/random

This should be fixed by new code that handles the end of data transfer
for both reads and writes.  It handles two existing conditions and one
new.  Namely:
- the last message has been completed -- end of transfer;
- a message has been completed and the next one requires the start
- a message has been completed and the next one should be sent without
  the start condition.

In the last case we simply switch to the next message and start sending
its data.  Reads without the start condition are not supported yet,
though.  That's because we NACK the last byte of the previous message,
so the device stops sending data.  To fix this we will need to add a
look-ahead at the next message when handling the penultimate byte of the
current one.

This change also fixed a bug where msg_idx was not incremented after a
read message.  Apparently, typically a read message is a last message in
a transfer, so the bug did not cause much trouble.

PR:		258994
MFC after:	3 weeks
00c07d95 avg Nov. 26, 2021, 2:18 p.m.
Assert that we are not receiving data beyond the requested length.
Assert that we have not NACK-ed incoming data prematurely.
Abort the current transfer if the incoming data is NACK-ed or not
NACK-ed unexpectedly.

Add debug logging of received data to complement logging of sent data.

MFC after:	3 weeks
aeacf172 avg Nov. 26, 2021, 2:18 p.m.
The write at the end of twsi_intr() already handles all cases, no need
to have another write for TWSI_STATUS_START / TWSI_STATUS_RPTD_START.

MFC after:	3 weeks
04622a7f avg Nov. 26, 2021, 2:17 p.m.
Previously the code set TWSI_CONTROL_ACK in twsi_transfer() based on
whether the first message had a length of one.  That was done regardless
of whether the message was a read or write and what kind of messages
followed it.
Now the bit is set or cleared while handling TWSI_STATUS_ADDR_R_ACK
state transition based on the current (read) message.

The old code did not correctly work in a scenario where a single byte
was read from an EEPROM device with two byte addressing.
For example:
    i2c -m tr -a 0x50 -d r -w 16 -o 0 -c 1 -v
The reason is that the first message (a write) has two bytes, so
TWSI_CONTROL_ACK was set and never cleared.
Since the controller did not send NACK the EEPROM sent more data resulting
in a buffer overrun.

While working on TWSI_STATUS_ADDR_R_ACK I also added support for
the zero-length read access and then I did the same for zero-length write
While rare, those types of I2C transactions are completely valid and are
used by some devices.

PR:		258994
MFC after:	3 weeks
a4fe8922 avg Nov. 26, 2021, 2:16 p.m.
twsi_error() is a new function that stops the current transfer and sets
up softc when an error condition is detected.
TWSI_STATUS_ARBITRATION_LOST are now handled explicitly rather than
via the catch-all unknown status.

Also, twsi_intr() now calls wakeup() in a single place when the
transfer is finished.

MFC after:	2 weeks
578707ed avg Nov. 26, 2021, 2:16 p.m.
- use 0x prefix for hex values
- print indexes and counts as decimals
- break too long lines

MFC after:	2 weeks
cb167e1a avg Nov. 26, 2021, 2:15 p.m.
MFC after:	2 weeks
bc02583c avg Nov. 26, 2021, 2:15 p.m.
MFC after:	2 weeks