~fheimes/ubuntu/+source/linux/+git/bionic:master

Last commit made on 2018-11-08
Get this branch:
git clone -b master https://git.launchpad.net/~fheimes/ubuntu/+source/linux/+git/bionic
Only Frank Heimes can upload to this branch. If you are Frank Heimes please log in for upload directions.

Branch merges

Branch information

Recent commits

8fe43cd... by Harald Freudenberger <email address hidden>

s390/zcrypt: hex string mask improvements for apmask and aqmask.

The sysfs attributes /sys/bus/ap/apmask and /sys/bus/ap/aqmask
and the kernel command line arguments ap.apm and ap.aqm get
an improvement of the value parsing with this patch:

The mask values are bitmaps in big endian order starting with bit 0.
So adapter number 0 is the leftmost bit, mask is 0x8000... The sysfs
attributes and the kernel command line accept 2 different formats:
 - Absolute hex string starting with 0x like "0x12345678" does set
   the mask starting from left to right. If the given string is shorter
   than the mask it is padded with 0s on the right. If the string is
   longer than the mask an error comes back (EINVAL).
 - Relative format - a concatenation (done with ',') of the terms
   +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>]. <bitnr> may be any
   valid number (hex, decimal or octal) in the range 0...255.
   Here are some examples:
     "+0-15,+32,-128,-0xFF"
     "-0-255,+1-16,+0x128"

Signed-off-by: Harald Freudenberger <email address hidden>
Signed-off-by: Martin Schwidefsky <email address hidden>
(cherry picked from commit 3d8f60d38e249f989a7fca9c2370c31c3d5487e1)
Signed-off-by: Frank Heimes <email address hidden>

cde5361... by Harald Freudenberger <email address hidden>

s390/zcrypt: AP bus support for alternate driver(s)

The current AP bus, AP devices and AP device drivers implementation
uses a clearly defined mapping for binding AP devices to AP device
drivers. So for example a CEX6C queue will always be bound to the
cex4queue device driver.

The Linux Device Driver model has no sensitivity for more than one
device driver eligible for one device type. If there exist more than
one drivers matching to the device type, simple all drivers are tried
consecutively. There is no way to determine and influence the probing
order of the drivers.

With KVM there is a need to provide additional device drivers matching
to the very same type of AP devices. With a simple implementation the
KVM drivers run in competition to the regular drivers. Whichever
'wins' a device depends on build order and implementation details
within the common Linux Device Driver Model and is not
deterministic. However, a userspace process could figure out which
device should be bound to which driver and sort out the correct
binding by manipulating attributes in the sysfs.

If for security reasons a AP device must not get bound to the 'wrong'
device driver the sorting out has to be done within the Linux kernel
by the AP bus code. This patch modifies the behavior of the AP bus
for probing drivers for devices in a way that two sets of drivers are
usable. Two new bitmasks 'apmask' and 'aqmask' are used to mark a
subset of the APQN range for 'usable by the ap bus and the default
drivers' or 'not usable by the default drivers and thus available for
alternate drivers like vfio-xxx'. So an APQN which is addressed by
this masking only the default drivers will be probed. In contrary an
APQN which is not addressed by the masks will never be probed and
bound to default drivers but onny to alternate drivers.

Eventually the two masks give a way to divide the range of APQNs into
two pools: one pool of APQNs used by the AP bus and the default
drivers and thus via zcrypt drivers available to the userspace of the
system. And another pool where no zcrypt drivers are bound to and
which can be used by alternate drivers (like vfio-xxx) for their
needs. This division is hot-plug save and makes sure a APQN assigned
to an alternate driver is at no time somehow exploitable by the wrong
party.

The two masks are located in sysfs at /sys/bus/ap/apmask and
/sys/bus/ap/aqmask. The mask syntax is exactly the same as the
already existing mask attributes in the /sys/bus/ap directory (for
example ap_usage_domain_mask and ap_control_domain_mask).

By default all APQNs belong to the ap bus and the default drivers:

  cat /sys/bus/ap/apmask
  0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
  cat /sys/bus/ap/aqmask
  0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

The masks can be changed at boot time with the kernel command line
like this:

  ... ap.apmask=0xffff ap.aqmask=0x40

This would give these two pools:

  default drivers pool: adapter 0 - 15, domain 1
  alternate drivers pool: adapter 0 - 15, all but domain 1
      adapter 16-255, all domains

The sysfs attributes for this two masks are writeable and an
administrator is able to reconfigure the assignements on the fly by
writing new mask values into. With changing the mask(s) a revision of
the existing queue to driver bindings is done. So all APQNs which are
bound to the 'wrong' driver are reprobed via kernel function
device_reprobe() and thus the new correct driver will be assigned with
respect of the changed apmask and aqmask bits.

The mask values are bitmaps in big endian order starting with bit 0.
So adapter number 0 is the leftmost bit, mask is 0x8000... The sysfs
attributes accept 2 different formats:
- Absolute hex string starting with 0x like "0x12345678" does set
  the mask starting from left to right. If the given string is shorter
  than the mask it is padded with 0s on the right. If the string is
  longer than the mask an error comes back (EINVAL).
- '+' or '-' followed by a numerical value. Valid examples are "+1",
  "-13", "+0x41", "-0xff" and even "+0" and "-0". Only the addressed
  bit in the mask is switched on ('+') or off ('-').

This patch will also be the base for an upcoming extension to the
zcrypt drivers to be able to provide additional zcrypt device nodes
with filtering based on ap and aq masks.

Signed-off-by: Harald Freudenberger <email address hidden>
Signed-off-by: Martin Schwidefsky <email address hidden>
(cherry picked from commit 7e0bdbe5c21cb8316a694e46ad5aad339f6894a6)
Signed-off-by: Frank Heimes <email address hidden>

9f495fa... by Harald Freudenberger <email address hidden>

s390/zcrypt: code beautify

Code beautify by following most of the checkpatch suggestions:
 - SPDX license identifier line complains by checkpatch
 - missing space or newline complains by checkpatch
 - octal numbers for permssions complains by checkpatch
 - renaming of static sysfs functions complains by checkpatch
 - fix of block comment complains by checkpatch
 - fix printf like calls where function name instead of %s __func__
   was used
 - __packed instead of __attribute__((packed))
 - init to zero for static variables removed
 - use of DEVICE_ATTR_RO and DEVICE_ATTR_RW macros

No functional code changes or API changes!

Signed-off-by: Harald Freudenberger <email address hidden>
Signed-off-by: Martin Schwidefsky <email address hidden>
(cherry picked from commit ac2b96f351d7d222c46e524feca03005f3fa8d75)
Signed-off-by: Frank Heimes <email address hidden>

bcddeb8... by Harald Freudenberger

s390/zcrypt: Show load of cards and queues in sysfs

Show the current load value of cards and queues in sysfs.
The load value for each card and queue is maintained by
the zcrypt device driver for dispatching and load
balancing requests over the available devices.

This patch provides the load value to userspace via a
new read only sysfs attribute 'load' per card and queue.

Signed-off-by: Harald Freudenberger <email address hidden>
Signed-off-by: Martin Schwidefsky <email address hidden>
(cherry picked from commit 4a07750ba8f3f45f0be730f7370c2c21a7491cd7)
Signed-off-by: Frank Heimes <email address hidden>

f5e8485... by Harald Freudenberger <email address hidden>

s390/zcrypt: remove unused functions and declarations

The AP bus code is not available as kernel module any more.
There was some leftover code dealing with kernel module
exit which has been removed with this patch.

Signed-off-by: Harald Freudenberger <email address hidden>
Signed-off-by: Martin Schwidefsky <email address hidden>
(cherry picked from commit 2c957a8ad45991f3ef71da5c75ed2299f3d46a31)
Signed-off-by: Frank Heimes <email address hidden>

0f3d176... by Anchal Agarwal <email address hidden>

SAUCE: xen-blkfront: Fixed blkfront_restore to remove a call to negotiate_mq

BugLink: https://bugs.launchpad.net/bugs/1801305

The code for talk_to_blkback API changed in kernel-4.14.45 to include a call to
negotiate_mq. Subsequent calls causes kernel panic
[ 84.440105] Call Trace:
[ 84.443707] talk_to_blkback+0x6d/0x8b0 [xen_blkfront]
[ 84.449147] blkfront_restore+0x33/0x60 [xen_blkfront]
[ 84.453336] ? xenbus_read_otherend_details+0x50/0xb0
[ 84.457804] xenbus_dev_cancel+0x5f/0x160
[ 84.463286] ? xenbus_dev_resume+0x170/0x170
[ 84.466891] dpm_run_callback+0x3b/0x100
[ 84.470516] device_resume+0x10d/0x420
[ 84.473844] dpm_resume+0xfd/0x2f0
[ 84.476984] hibernation_snapshot+0x218/0x410
[ 84.480794] hibernate+0x14b/0x270
[ 84.484030] state_store+0x50/0x60
[ 84.487443] kernfs_fop_write+0x105/0x180
[ 84.492695] __vfs_write+0x36/0x160
[ 84.496672] ? __audit_syscall_entry+0xbc/0x110
[ 84.502123] vfs_write+0xad/0x1a0
[ 84.506857] SyS_write+0x52/0xc0
[ 84.511420] do_syscall_64+0x67/0x100
[ 84.516365] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
[ 84.522571] RIP: 0033:0x7f44a03407e4
[ 84.526210] RSP: 002b:00007ffd5e0ec3c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 84.534041] RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f44a03407e4
[ 84.542571] RDX: 0000000000000004 RSI: 0000000001e94990 RDI: 0000000000000001
[ 84.549142] RBP: 0000000001e94990 R08: 00007f44a060c8c0 R09: 00007f44a0c57740
[ 84.554658] R10: 00007f44a03cd320 R11: 0000000000000246 R12: 0000000000000004
[ 84.560411] R13: 0000000000000001 R14: 00007f44a060b760 R15: 0000000000000004
[ 84.565744] Code: 39 ab e8 00 00 00 77 8a 31 c0 5b 5d c3 44 8b 05 50 57 00 00 45 85 c0 0f 84 2f ff ff ff 89 c0 48 69 f8 e0 40 01 00 e9 30 ff ff ff <0f> 0b 48 8b 7b 28 48 c7 c2 78 58 16 a0 be f4 ff ff ff e8 7e 37
[ 84.580594] RIP: negotiate_mq+0x12b/0x150 [xen_blkfront] RSP: ffffc90000ebbc70

Signed-off-by: Anchal Agarwal <email address hidden>
Reviewed-by: Frank van der Linden <email address hidden>
Reviewed-by: Vallish Vaidyeshwara <email address hidden>
(cherry-picked from
 0035-xen-blkfront-Fixed-blkfront_restore-to-remove-a-call.patch
 in AWS 4.14 kernel SRPM)
Signed-off-by: Daniel Axtens <email address hidden>
Acked-by: Kleber Souza <email address hidden>
Acked-by: Stefan Bader <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>

6a96db1... by Munehisa Kamata

SAUCE: xen-blkfront: resurrect request-based mode

BugLink: https://bugs.launchpad.net/bugs/1801305

This change resurrect request-based mode which was completely dropped in
commit 907c3eb18e0b ("xen-blkfront: convert to blk-mq APIs").

Not to make the queue lock stale, resurrect per-device (vbd) lock in
blkfront_info which is never freed during Xen suspend and use it in
request-based mode. This is bascially the same as what the driver was
doing until commit 11659569f720 ("xen/blkfront: split per device
io_lock"). If the driver is in blk-mq mode, just use the lock(s) in
blkfront_ring_info.

In commit b7420c1eaeac ("drivers/amazon: xen-blkfront: resurrect
request-based mode"), we accidentally didn't bring piece of code which
empties the request queue while saving bios. The logic was originally
introduced in commit 402b27f9f2c2 ("xen-block: implement indirect
descriptors"). It seems to be still required for request-based mode,
so just do the same thing as before.

Note that some suspend/resume logic were moved from blkif_recover() to
blkfront_resume() in commit 7b427a59538a ("xen-blkfront: save uncompleted
reqs in blkfront_resume()"), so add the logic to blkfront_resume().

Forward-port notes: As part of this forward port, we are no longer
using out of tree xen-blkfront. Request based patch and its releated
per device vbd lock has now been ported on top of intree xen-blkfront.
For reference:
4.9 CR for resurrect request based mode: https://cr.amazon.com/r/6834653/
4.9 CR for resurrect per-device (vbd) lock: https://cr.amazon.com/r/7475903/
4.9 CR for empty the request queue while resuming: https://cr.amazon.com/r/7475918/
As part of forward-port, all the above 3 related patches, have been merged into
a single commit.
In 4.14.y kernel, we realized during forward-port and testing, that blk-mq stashes
the error code for request right after the request structure in memory. Care was
taken to not reuse this piece of memory for stashing error code in request mode
as this can cause memory corruption.
Hibernation: To not break git bisect and the hibernation feature, blkfront_freeze()
and blkfront_resume() were modified as well to support request-based mode.

Reported-by: Imre Palik <email address hidden>
Reviewed-by: Eduardo Valentin <email address hidden>
Reviewed-by: Munehisa Kamata <email address hidden>
Reviewed-by: Anchal Agarwal <email address hidden>
Signed-off-by: Munehisa Kamata <email address hidden>
Signed-off-by: Vallish Vaidyeshwara <email address hidden>

CR: https://cr.amazon.com/r/8309443
(cherry-picked from
 0026-xen-blkfront-resurrect-request-based-mode.patch
 in AWS 4.14 kernel SRPM)
Signed-off-by: Daniel Axtens <email address hidden>
Acked-by: Kleber Souza <email address hidden>
Acked-by: Stefan Bader <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>

104bec2... by Munehisa Kamata

SAUCE: xen-blkfront: add callbacks for PM suspend and hibernation

BugLink: https://bugs.launchpad.net/bugs/1801305

Add freeze and restore callbacks for PM suspend and hibernation support.
The freeze handler stops a block-layer queue and disconnect the frontend
from the backend while freeing ring_info and associated resources. The
restore handler re-allocates ring_info and re-connect to the backedend,
so the rest of the kernel can continue to use the block device
transparently.Also, the handlers are used for both PM
suspend and hibernation so that we can keep the existing suspend/resume
callbacks for Xen suspend without modification.
If a backend doesn't have commit 12ea729645ac ("xen/blkback: unmap all
persistent grants when frontend gets disconnected"), the frontend may see
massive amount of grant table warning when freeing resources.

 [ 36.852659] deferring g.e. 0xf9 (pfn 0xffffffffffffffff)
 [ 36.855089] xen:grant_table: WARNING: g.e. 0x112 still in use!

In this case, persistent grants would need to be disabled.

Ensure no reqs/rsps in rings before disconnecting. When disconnecting
the frontend from the backend in blkfront_freeze(), there still may be
unconsumed requests or responses in the rings, especially when the
backend is backed by network-based device. If the frontend gets
disconnected with such reqs/rsps remaining there, it can cause
grant warnings and/or losing reqs/rsps by freeing pages afterward.
This can lead resumed kernel into unrecoverable state like unexpected
freeing of grant page and/or hung task due to the lost reqs or rsps.
Therefore we have to ensure that there is no unconsumed requests or
responses before disconnecting.

Actually, the frontend just needs to wait for some amount of time so that
the backend can process the requests, put responses and notify the
frontend back. Timeout used here is based on some heuristic. If we somehow
hit the timeout, it would mean something serious happens in the backend,
the frontend will just return an error to PM core and PM suspend/hibernation
will be aborted. This may be something should be fixed by the backend side,
but a frontend side fix is probably still worth doing to work with
broader backends.

Backport Note:
Unlike 4.9 kernel, blk-mq is default for 4.14 kernel and request-based
mode cod eis not included in this frontend driver.

Signed-off-by: Munehisa Kamata <email address hidden>
Signed-off-by: Anchal Agarwal <email address hidden>
Reviewed-by: Munehisa Kamata <email address hidden>
Reviewed-by: Eduardo Valentin <email address hidden>
CR: https://cr.amazon.com/r/8297625/
(cherry-picked from
 0018-xen-blkfront-add-callbacks-for-PM-suspend-and-hibern.patch
 in AWS 4.14 kernel SRPM)
Signed-off-by: Daniel Axtens <email address hidden>
Acked-by: Kleber Souza <email address hidden>
Acked-by: Stefan Bader <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>

905079e... by Munehisa Kamata

SAUCE: xenbus: add freeze/thaw/restore callbacks support

BugLink: https://bugs.launchpad.net/bugs/1801305

Since commit b3e96c0c7562 ("xen: use freeze/restore/thaw PM events for
suspend/resume/chkpt"), xenbus uses PMSG_FREEZE, PMSG_THAW and
PMSG_RESTORE events for Xen suspend. However, they're actually assigned
to xenbus_dev_suspend(), xenbus_dev_cancel() and xenbus_dev_resume()
respectively, and only suspend and resume callbacks are supported at
driver level. To support PM suspend and PM hibernation, modify the bus
level PM callbacks to invoke not only device driver's suspend/resume but
also freeze/thaw/restore.

Note that we'll use freeze/restore callbacks even for PM suspend whereas
suspend/resume callbacks are normally used in the case, becausae the
existing xenbus device drivers already have suspend/resume callbacks
specifically designed for Xen suspend. So we can allow the device
drivers to keep the existing callbacks wihtout modification.

Signed-off-by: Munehisa Kamata <email address hidden>
Signed-off-by: Anchal Agarwal <email address hidden>
Reviewed-by: Munehisa Kamata <email address hidden>
Reviewed-by: Eduardo Valentin <email address hidden>
CR: https://cr.amazon.com/r/8273200/
(cherry-picked from
 0015-xenbus-add-freeze-thaw-restore-callbacks-support.patch
 in AWS 4.14 kernel SRPM)
Signed-off-by: Daniel Axtens <email address hidden>
Acked-by: Kleber Souza <email address hidden>
Acked-by: Stefan Bader <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>

c5a5567... by Munehisa Kamata

SAUCE: xen/manage: introduce helper function to know the on-going suspend mode

BugLink: https://bugs.launchpad.net/bugs/1801305

Introduce simple functions which help to know the on-going suspend mode
so that other Xen-related code can behave differently according to the
current suspend mode.

Signed-off-by: Munehisa Kamata <email address hidden>
Signed-off-by: Anchal Agarwal <email address hidden>
Reviewed-by: Alakesh Haloi <email address hidden>
Reviewed-by: Sebastian Biemueller <email address hidden>
Reviewed-by: Munehisa Kamata <email address hidden>
Reviewed-by: Eduardo Valentin <email address hidden>
CR: https://cr.amazon.com/r/8273190/
(cherry-picked from
 0014-xen-manage-introduce-helper-function-to-know-the-on-.patch
 in AWS 4.14 kernel SRPM)
Signed-off-by: Daniel Axtens <email address hidden>
Acked-by: Kleber Souza <email address hidden>
Acked-by: Stefan Bader <email address hidden>
Signed-off-by: Khalid Elmously <email address hidden>