]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/log
mirror_ubuntu-zesty-kernel.git
7 years agousb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk
Samuel Thibault [Mon, 13 Mar 2017 19:50:08 +0000 (20:50 +0100)]
usb-core: Add LINEAR_FRAME_INTR_BINTERVAL USB quirk

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 3243367b209faed5c320a4e5f9a565ee2a2ba958 upstream.

Some USB 2.0 devices erroneously report millisecond values in
bInterval. The generic config code manages to catch most of them,
but in some cases it's not completely enough.

The case at stake here is a USB 2.0 braille device, which wants to
announce 10ms and thus sets bInterval to 10, but with the USB 2.0
computation that yields to 64ms.  It happens that one can type fast
enough to reach this interval and get the device buffers overflown,
leading to problematic latencies.  The generic config code does not
catch this case because the 64ms is considered a sane enough value.

This change thus adds a USB_QUIRK_LINEAR_FRAME_INTR_BINTERVAL quirk
to mark devices which actually report milliseconds in bInterval,
and marks Vario Ultra devices as needing it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agodvb-usb-firmware: don't do DMA on stack
Stefan Brüns [Sun, 12 Feb 2017 15:02:13 +0000 (13:02 -0200)]
dvb-usb-firmware: don't do DMA on stack

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 67b0503db9c29b04eadfeede6bebbfe5ddad94ef upstream.

The buffer allocation for the firmware data was changed in
commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
but the same applies for the reset value.

Fixes: 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agousb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval
Roger Quadros [Wed, 8 Mar 2017 14:05:43 +0000 (16:05 +0200)]
usb: gadget: f_uvc: Fix SuperSpeed companion descriptor's wBytesPerInterval

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 09424c50b7dff40cb30011c09114404a4656e023 upstream.

The streaming_maxburst module parameter is 0 offset (0..15)
so we must add 1 while using it for wBytesPerInterval
calculation for the SuperSpeed companion descriptor.

Without this host uvcvideo driver will always see the wrong
wBytesPerInterval for SuperSpeed uvc gadget and may not find
a suitable video interface endpoint.
e.g. for streaming_maxburst = 0 case it will always
fail as wBytePerInterval was evaluating to 0.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoACM gadget: fix endianness in notifications
Oliver Neukum [Tue, 14 Mar 2017 11:09:56 +0000 (12:09 +0100)]
ACM gadget: fix endianness in notifications

BugLink: http://bugs.launchpad.net/bugs/1677589
commit cdd7928df0d2efaa3270d711963773a08a4cc8ab upstream.

The gadget code exports the bitfield for serial status changes
over the wire in its internal endianness. The fix is to convert
to little endian before sending it over the wire.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
Tested-by: 家瑋 <momo1208@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoUSB: serial: qcserial: add Dell DW5811e
Bjørn Mork [Fri, 17 Mar 2017 16:21:28 +0000 (17:21 +0100)]
USB: serial: qcserial: add Dell DW5811e

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 436ecf5519d892397af133a79ccd38a17c25fa51 upstream.

This is a Dell branded Sierra Wireless EM7455.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoUSB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems
Dan Williams [Thu, 9 Mar 2017 17:32:28 +0000 (11:32 -0600)]
USB: serial: option: add Quectel UC15, UC20, EC21, and EC25 modems

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 6e9f44eaaef0df7b846e9316fa9ca72a02025d44 upstream.

Add Quectel UC15, UC20, EC21, and EC25.  The EC20 is handled by
qcserial due to a USB VID/PID conflict with an existing Acer
device.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoALSA: hda - Adding a group of pin definition to fix headset problem
Hui Wang [Thu, 23 Mar 2017 02:00:25 +0000 (10:00 +0800)]
ALSA: hda - Adding a group of pin definition to fix headset problem

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 3f307834e695f59dac4337a40316bdecfb9d0508 upstream.

A new Dell laptop needs to apply ALC269_FIXUP_DELL1_MIC_NO_PRESENCE to
fix the headset problem, and the pin definiton of this machine is not
in the pin quirk table yet, now adding it to the table.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoALSA: ctxfi: Fix the incorrect check of dma_set_mask() call
Takashi Iwai [Mon, 20 Mar 2017 09:08:19 +0000 (10:08 +0100)]
ALSA: ctxfi: Fix the incorrect check of dma_set_mask() call

BugLink: http://bugs.launchpad.net/bugs/1677589
commit f363a06642f28caaa78cb6446bbad90c73fe183c upstream.

In the commit [15c75b09f8d1: ALSA: ctxfi: Fallback DMA mask to 32bit],
I forgot to put "!" at dam_set_mask() call check in cthw20k1.c (while
cthw20k2.c is OK).  This patch fixes that obvious bug.

(As a side note: although the original commit was completely wrong,
 it's still working for most of machines, as it sets to 32bit DMA mask
 in the end.  So the bug severity is low.)

Fixes: 15c75b09f8d1 ("ALSA: ctxfi: Fallback DMA mask to 32bit")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
Takashi Iwai [Tue, 21 Mar 2017 12:56:04 +0000 (13:56 +0100)]
ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()

BugLink: http://bugs.launchpad.net/bugs/1677589
commit c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e upstream.

When snd_seq_pool_done() is called, it marks the closing flag to
refuse the further cell insertions.  But snd_seq_pool_done() itself
doesn't clear the cells but just waits until all cells are cleared by
the caller side.  That is, it's racy, and this leads to the endless
stall as syzkaller spotted.

This patch addresses the racy by splitting the setup of pool->closing
flag out of snd_seq_pool_done(), and calling it properly before
snd_seq_pool_done().

BugLink: http://lkml.kernel.org/r/CACT4Y+aqqy8bZA1fFieifNxR2fAfFQQABcBHj801+u5ePV0URw@mail.gmail.com
Reported-and-tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: sur40 - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:43:09 +0000 (11:43 -0700)]
Input: sur40 - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 92461f5d723037530c1f36cce93640770037812c upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory that lie beyond the end of the endpoint
array should a malicious device lack the expected endpoints.

Fixes: bdb5c57f209c ("Input: add sur40 driver for Samsung SUR40... ")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: kbtab - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:41:55 +0000 (11:41 -0700)]
Input: kbtab - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit cb1b494663e037253337623bf1ef2df727883cb7 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: cm109 - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:35:12 +0000 (11:35 -0700)]
Input: cm109 - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit ac2ee9ba953afe88f7a673e1c0c839227b1d7891 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Fixes: c04148f915e5 ("Input: add driver for USB VoIP phones with CM109...")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: yealink - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:37:01 +0000 (11:37 -0700)]
Input: yealink - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Fixes: aca951a22a1d ("[PATCH] input-driver-yealink-P1K-usb-phone")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: hanwang - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:39:29 +0000 (11:39 -0700)]
Input: hanwang - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit ba340d7b83703768ce566f53f857543359aa1b98 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack endpoints.

Fixes: bba5394ad3bd ("Input: add support for Hanwang tablets")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: ims-pcu - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:36:13 +0000 (11:36 -0700)]
Input: ims-pcu - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 1916d319271664241b7aa0cd2b05e32bdb310ce9 upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer should a malicious device lack control-interface endpoints.

Fixes: 628329d52474 ("Input: add IMS Passenger Control Unit driver")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: iforce - validate number of endpoints before using them
Johan Hovold [Thu, 16 Mar 2017 18:34:02 +0000 (11:34 -0700)]
Input: iforce - validate number of endpoints before using them

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 59cf8bed44a79ec42303151dd014fdb6434254bb upstream.

Make sure to check the number of endpoints to avoid dereferencing a
NULL-pointer or accessing memory that lie beyond the end of the endpoint
array should a malicious device lack the expected endpoints.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: i8042 - add noloop quirk for Dell Embedded Box PC 3000
Kai-Heng Feng [Tue, 7 Mar 2017 17:31:29 +0000 (09:31 -0800)]
Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 45838660e34d90db8d4f7cbc8fd66e8aff79f4fe upstream.

The aux port does not get detected without noloop quirk, so external PS/2
mouse cannot work as result.

The PS/2 mouse can work with this quirk.

BugLink: https://bugs.launchpad.net/bugs/1591053
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: elan_i2c - add ASUS EeeBook X205TA special touchpad fw
Matjaz Hegedic [Fri, 10 Mar 2017 22:33:09 +0000 (14:33 -0800)]
Input: elan_i2c - add ASUS EeeBook X205TA special touchpad fw

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 92ef6f97a66e580189a41a132d0f8a9f78d6ddce upstream.

EeeBook X205TA is yet another ASUS device with a special touchpad
firmware that needs to be accounted for during initialization, or
else the touchpad will go into an invalid state upon suspend/resume.
Adding the appropriate ic_type and product_id check fixes the problem.

Signed-off-by: Matjaz Hegedic <matjaz.hegedic@gmail.com>
Acked-by: KT Liao <kt.liao@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: ALPS - fix trackstick button handling on V8 devices
Masaki Ota [Fri, 17 Mar 2017 21:19:40 +0000 (14:19 -0700)]
Input: ALPS - fix trackstick button handling on V8 devices

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 47e6fb4212d09f325c0847d05985dd3d71553095 upstream.

Alps stick devices always have physical buttons, so we should not check
ALPS_BUTTONPAD flag to decide whether we should report them.

Fixes: 4777ac220c43 ("Input: ALPS - add touchstick support for SS5 hardware")
Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
Acked-by: Pali Rohar <pali.rohar@gmail.com>
Tested-by: Paul Donohue <linux-kernel@PaulSD.com>
Tested-by: Nick Fletcher <nick.m.fletcher@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoInput: ALPS - fix V8+ protocol handling (73 03 28)
Masaki Ota [Fri, 17 Mar 2017 21:10:57 +0000 (14:10 -0700)]
Input: ALPS - fix V8+ protocol handling (73 03 28)

BugLink: http://bugs.launchpad.net/bugs/1677589
commit e7348396c6d51b57c95c6646c390cd078e038e19 upstream.

Devices identified as E7="73 03 28" use slightly modified version of V8
protocol, with lower count per electrode, different offsets, and different
feature bits in OTP data.

Fixes: aeaa881f9b17 ("Input: ALPS - set DualPoint flag for 74 03 28 devices")
Signed-off-by: Masaki Ota <masaki.ota@jp.alps.com>
Acked-by: Pali Rohar <pali.rohar@gmail.com>
Tested-by: Paul Donohue <linux-kernel@PaulSD.com>
Tested-by: Nick Fletcher <nick.m.fletcher@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoHID: sony: Fix input device leak when connecting a DS4 twice using USB/BT
Roderick Colenbrander [Sat, 25 Feb 2017 00:14:15 +0000 (16:14 -0800)]
HID: sony: Fix input device leak when connecting a DS4 twice using USB/BT

BugLink: http://bugs.launchpad.net/bugs/1677589
commit a687c5765b5ae19fe559e14615ddc87ebb46d409 upstream.

When a user connects a DS4 twice using USB and BT, we reject the
second device connection after the setup work. We then perform
a cleanup, but during cleanup we are not removing the touchpad
device. This leads to leakage of an input device, which we would
never remove. It can likely result into a kernel oops as well
when the touchpad evdev node is accessed and the underlaying HID
device has been removed from the system.

[jkosina@suse.cz: added stable annotation]
Fixes: ac797b95f532 ("HID: sony: Make the DS4 touchpad a separate device")
Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: solve a NAPI race
Eric Dumazet [Fri, 17 Mar 2017 02:02:33 +0000 (19:02 -0700)]
net: solve a NAPI race

BugLink: http://bugs.launchpad.net/bugs/1677589
commit 39e6c8208d7b6fb9d2047850fb3327db567b564b upstream.

While playing with mlx4 hardware timestamping of RX packets, I found
that some packets were received by TCP stack with a ~200 ms delay...

Since the timestamp was provided by the NIC, and my probe was added
in tcp_v4_rcv() while in BH handler, I was confident it was not
a sender issue, or a drop in the network.

This would happen with a very low probability, but hurting RPC
workloads.

A NAPI driver normally arms the IRQ after the napi_complete_done(),
after NAPI_STATE_SCHED is cleared, so that the hard irq handler can grab
it.

Problem is that if another point in the stack grabs NAPI_STATE_SCHED bit
while IRQ are not disabled, we might have later an IRQ firing and
finding this bit set, right before napi_complete_done() clears it.

This can happen with busy polling users, or if gro_flush_timeout is
used. But some other uses of napi_schedule() in drivers can cause this
as well.

thread 1                                 thread 2 (could be on same cpu, or not)

// busy polling or napi_watchdog()
napi_schedule();
...
napi->poll()

device polling:
read 2 packets from ring buffer
                                          Additional 3rd packet is
available.
                                          device hard irq

                                          // does nothing because
NAPI_STATE_SCHED bit is owned by thread 1
                                          napi_schedule();

napi_complete_done(napi, 2);
rearm_irq();

Note that rearm_irq() will not force the device to send an additional
IRQ for the packet it already signaled (3rd packet in my example)

This patch adds a new NAPI_STATE_MISSED bit, that napi_schedule_prep()
can set if it could not grab NAPI_STATE_SCHED

Then napi_complete_done() properly reschedules the napi to make sure
we do not miss something.

Since we manipulate multiple bits at once, use cmpxchg() like in
sk_busy_loop() to provide proper transactions.

In v2, I changed napi_watchdog() to use a relaxed variant of
napi_schedule_prep() : No need to set NAPI_STATE_MISSED from this point.

In v3, I added more details in the changelog and clears
NAPI_STATE_MISSED in busy_poll_stop()

In v4, I added the ideas given by Alexander Duyck in v3 review

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoamd-xgbe: Fix the ECC-related bit position definitions
Lendacky, Thomas [Wed, 22 Mar 2017 22:25:27 +0000 (17:25 -0500)]
amd-xgbe: Fix the ECC-related bit position definitions

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit f43feef4e6acde10857fcbfdede790d6b3f2c71d ]

The ECC bit positions that describe whether the ECC interrupt is for
Tx, Rx or descriptor memory and whether the it is a single correctable
or double detected error were defined in incorrectly (reversed order).
Fix the bit position definitions for these settings so that the proper
ECC handling is performed.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agotcp: initialize icsk_ack.lrcvtime at session start time
Eric Dumazet [Wed, 22 Mar 2017 15:10:21 +0000 (08:10 -0700)]
tcp: initialize icsk_ack.lrcvtime at session start time

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 15bb7745e94a665caf42bfaabf0ce062845b533b ]

icsk_ack.lrcvtime has a 0 value at socket creation time.

tcpi_last_data_recv can have bogus value if no payload is ever received.

This patch initializes icsk_ack.lrcvtime for active sessions
in tcp_finish_connect(), and for passive sessions in
tcp_create_openreq_child()

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agogenetlink: fix counting regression on ctrl_dumpfamily()
Stanislaw Gruszka [Wed, 22 Mar 2017 15:08:33 +0000 (16:08 +0100)]
genetlink: fix counting regression on ctrl_dumpfamily()

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 1d2a6a5e4bf2921531071fcff8538623dce74efa ]

Commit 2ae0f17df1cd ("genetlink: use idr to track families") replaced

if (++n < fams_to_skip)
continue;
into:

if (n++ < fams_to_skip)
continue;

This subtle change cause that on retry ctrl_dumpfamily() call we omit
one family that failed to do ctrl_fill_info() on previous call, because
cb->args[0] = n number counts also family that failed to do
ctrl_fill_info().

Patch fixes the problem and avoid confusion in the future just decrease
n counter when ctrl_fill_info() fail.

User visible problem caused by this bug is failure to get access to
some genetlink family i.e. nl80211. However problem is reproducible
only if number of registered genetlink families is big enough to
cause second call of ctrl_dumpfamily().

Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Johannes Berg <johannes@sipsolutions.net>
Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agosocket, bpf: fix sk_filter use after free in sk_clone_lock
Daniel Borkmann [Wed, 22 Mar 2017 12:08:08 +0000 (13:08 +0100)]
socket, bpf: fix sk_filter use after free in sk_clone_lock

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit a97e50cc4cb67e1e7bff56f6b41cda62ca832336 ]

In sk_clone_lock(), we create a new socket and inherit most of the
parent's members via sock_copy() which memcpy()'s various sections.
Now, in case the parent socket had a BPF socket filter attached,
then newsk->sk_filter points to the same instance as the original
sk->sk_filter.

sk_filter_charge() is then called on the newsk->sk_filter to take a
reference and should that fail due to hitting max optmem, we bail
out and release the newsk instance.

The issue is that commit 278571baca2a ("net: filter: simplify socket
charging") wrongly combined the dismantle path with the failure path
of xfrm_sk_clone_policy(). This means, even when charging failed, we
call sk_free_unlock_clone() on the newsk, which then still points to
the same sk_filter as the original sk.

Thus, sk_free_unlock_clone() calls into __sk_destruct() eventually
where it tests for present sk_filter and calls sk_filter_uncharge()
on it, which potentially lets sk_omem_alloc wrap around and releases
the eBPF prog and sk_filter structure from the (still intact) parent.

Fix it by making sure that when sk_filter_charge() failed, we reset
newsk->sk_filter back to NULL before passing to sk_free_unlock_clone(),
so that we don't mess with the parents sk_filter.

Only if xfrm_sk_clone_policy() fails, we did reach the point where
either the parent's filter was NULL and as a result newsk's as well
or where we previously had a successful sk_filter_charge(), thus for
that case, we do need sk_filter_uncharge() to release the prior taken
reference on sk_filter.

Fixes: 278571baca2a ("net: filter: simplify socket charging")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoipv4: provide stronger user input validation in nl_fib_input()
Eric Dumazet [Wed, 22 Mar 2017 02:22:28 +0000 (19:22 -0700)]
ipv4: provide stronger user input validation in nl_fib_input()

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit c64c0b3cac4c5b8cb093727d2c19743ea3965c0b ]

Alexander reported a KMSAN splat caused by reads of uninitialized
field (tb_id_in) from user provided struct fib_result_nl

It turns out nl_fib_input() sanity tests on user input is a bit
wrong :

User can pretend nlh->nlmsg_len is big enough, but provide
at sendmsg() time a too small buffer.

Reported-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: bcmgenet: remove bcmgenet_internal_phy_setup()
Doug Berger [Tue, 21 Mar 2017 21:01:06 +0000 (14:01 -0700)]
net: bcmgenet: remove bcmgenet_internal_phy_setup()

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 31739eae738ccbe8b9d627c3f2251017ca03f4d2 ]

Commit 6ac3ce8295e6 ("net: bcmgenet: Remove excessive PHY reset")
removed the bcmgenet_mii_reset() function from bcmgenet_power_up() and
bcmgenet_internal_phy_setup() functions.  In so doing it broke the reset
of the internal PHY devices used by the GENETv1-GENETv3 which required
this reset before the UniMAC was enabled.  It also broke the internal
GPHY devices used by the GENETv4 because the config_init that installed
the AFE workaround was no longer occurring after the reset of the GPHY
performed by bcmgenet_phy_power_set() in bcmgenet_internal_phy_setup().
In addition the code in bcmgenet_internal_phy_setup() related to the
"enable APD" comment goes with the bcmgenet_mii_reset() so it should
have also been removed.

Commit bd4060a6108b ("net: bcmgenet: Power on integrated GPHY in
bcmgenet_power_up()") moved the bcmgenet_phy_power_set() call to the
bcmgenet_power_up() function, but failed to remove it from the
bcmgenet_internal_phy_setup() function.  Had it done so, the
bcmgenet_internal_phy_setup() function would have been empty and could
have been removed at that time.

Commit 5dbebbb44a6a ("net: bcmgenet: Software reset EPHY after power on")
was submitted to correct the functional problems introduced by
commit 6ac3ce8295e6 ("net: bcmgenet: Remove excessive PHY reset"). It
was included in v4.4 and made available on 4.3-stable. Unfortunately,
it didn't fully revert the commit because this bcmgenet_mii_reset()
doesn't apply the soft reset to the internal GPHY used by GENETv4 like
the previous one did. This prevents the restoration of the AFE work-
arounds for internal GPHY devices after the bcmgenet_phy_power_set() in
bcmgenet_internal_phy_setup().

This commit takes the alternate approach of removing the unnecessary
bcmgenet_internal_phy_setup() function which shouldn't have been in v4.3
so that when bcmgenet_mii_reset() was restored it should have only gone
into bcmgenet_power_up().  This will avoid the problems while also
removing the redundancy (and hopefully some of the confusion).

Fixes: 6ac3ce8295e6 ("net: bcmgenet: Remove excessive PHY reset")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoipv6: make sure to initialize sockc.tsflags before first use
Alexander Potapenko [Tue, 21 Mar 2017 16:14:27 +0000 (17:14 +0100)]
ipv6: make sure to initialize sockc.tsflags before first use

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit d515684d78148884d5fc425ba904c50f03844020 ]

In the case udp_sk(sk)->pending is AF_INET6, udpv6_sendmsg() would
jump to do_append_data, skipping the initialization of sockc.tsflags.
Fix the problem by moving sockc.tsflags initialization earlier.

The bug was detected with KMSAN.

Fixes: c14ac9451c34 ("sock: enable timestamping using control messages")
Signed-off-by: Alexander Potapenko <glider@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/mlx5e: Count LRO packets correctly
Gal Pressman [Tue, 21 Mar 2017 13:59:19 +0000 (15:59 +0200)]
net/mlx5e: Count LRO packets correctly

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 8ab7e2ae15d84ba758b2c8c6f4075722e9bd2a08 ]

RX packets statistics ('rx_packets' counter) used to count LRO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'rx_lro_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
     rx_packets: 435277
     rx_lro_packets: 35847
     rx_packets_phy: 1935066

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "rx_packets|rx_lro_packets"
     rx_packets: 1935066
     rx_lro_packets: 35847
     rx_packets_phy: 1935066

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/mlx5e: Count GSO packets correctly
Gal Pressman [Tue, 21 Mar 2017 13:59:18 +0000 (15:59 +0200)]
net/mlx5e: Count GSO packets correctly

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit d3a4e4da54c7adb420d5f48e89be913b14bdeff1 ]

TX packets statistics ('tx_packets' counter) used to count GSO packets
as one, even though it contains multiple segments.
This patch will increment the counter by the number of segments, and
align the driver with the behavior of other drivers in the stack.

Note that no information is lost in this patch due to 'tx_tso_packets'
counter existence.

Before, ethtool showed:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
     tx_packets: 61340
     tx_tso_packets: 60954
     tx_packets_phy: 2451115

Now, we will see the more logical statistics:
$ ethtool -S ens6 | egrep "tx_packets|tx_tso_packets"
     tx_packets: 2451115
     tx_tso_packets: 60954
     tx_packets_phy: 2451115

Fixes: e586b3b0baee ("net/mlx5: Ethernet Datapath files")
Signed-off-by: Gal Pressman <galp@mellanox.com>
Cc: kernel-team@fb.com
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/mlx5: Increase number of max QPs in default profile
Maor Gottlieb [Tue, 21 Mar 2017 13:59:17 +0000 (15:59 +0200)]
net/mlx5: Increase number of max QPs in default profile

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 5f40b4ed975c26016cf41953b7510fe90718e21c ]

With ConnectX-4 sharing SRQs from the same space as QPs, we hit a
limit preventing some applications to allocate needed QPs amount.
Double the size to 256K.

Fixes: e126ba97dba9e ('mlx5: Add driver for Mellanox Connect-IB adapters')
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/mlx5e: Use the proper UAPI values when offloading TC vlan actions
Or Gerlitz [Tue, 21 Mar 2017 13:59:15 +0000 (15:59 +0200)]
net/mlx5e: Use the proper UAPI values when offloading TC vlan actions

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 09c91ddf2cd33489c2c14edfef43ae38d412888e ]

Currently we use the non UAPI values and we miss erring on
the modify action which is not supported, fix that.

Fixes: 8b32580df1cb ('net/mlx5e: Add TC vlan action for SRIOV offloads')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/mlx5: Add missing entries for set/query rate limit commands
Or Gerlitz [Tue, 21 Mar 2017 13:59:12 +0000 (15:59 +0200)]
net/mlx5: Add missing entries for set/query rate limit commands

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 1f30a86c58093046dc3e49c23d2618894e098f7a ]

The switch cases for the rate limit set and query commands were
missing, which could get us wrong under fw error or driver reset
flow, fix that.

Fixes: 1466cc5b23d1 ('net/mlx5: Rate limit tables support')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Hadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: vrf: Reset rt6i_idev in local dst after put
David Ahern [Fri, 17 Mar 2017 23:07:11 +0000 (16:07 -0700)]
net: vrf: Reset rt6i_idev in local dst after put

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 3dc857f0e8fc22610a59cbb346ba62c6e921863f ]

The VRF driver takes a reference to the inet6_dev on the VRF device for
its rt6_local dst when handling local traffic through the VRF device as
a loopback. When the device is deleted the driver does a put on the idev
but does not reset rt6i_idev in the rt6_info struct. When the dst is
destroyed, dst_destroy calls ip6_dst_destroy which does a second put for
what is essentially the same reference causing it to be prematurely freed.
Reset rt6i_idev after the put in the vrf driver.

Fixes: b4869aa2f881e ("net: vrf: ipv6 support for local traffic to
                       local addresses")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoqmi_wwan: add Dell DW5811e
Bjørn Mork [Fri, 17 Mar 2017 16:20:48 +0000 (17:20 +0100)]
qmi_wwan: add Dell DW5811e

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 6bd845d1cf98b45c634baacb8381436dad3c2dd0 ]

This is a Dell branded Sierra Wireless EM7455. It is operating in
MBIM mode by default, but can be configured to provide two QMI/RMNET
functions.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: unix: properly re-increment inflight counter of GC discarded candidates
Andrey Ulanov [Wed, 15 Mar 2017 03:16:42 +0000 (20:16 -0700)]
net: unix: properly re-increment inflight counter of GC discarded candidates

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 7df9c24625b9981779afb8fcdbe2bb4765e61147 ]

Dmitry has reported that a BUG_ON() condition in unix_notinflight()
may be triggered by a simple code that forwards unix socket in an
SCM_RIGHTS message.
That is caused by incorrect unix socket GC implementation in unix_gc().

The GC first collects list of candidates, then (a) decrements their
"children's" inflight counter, (b) checks which inflight counters are
now 0, and then (c) increments all inflight counters back.
(a) and (c) are done by calling scan_children() with inc_inflight or
dec_inflight as the second argument.

Commit 6209344f5a37 ("net: unix: fix inflight counting bug in garbage
collector") changed scan_children() such that it no longer considers
sockets that do not have UNIX_GC_CANDIDATE flag. It also added a block
of code that that unsets this flag _before_ invoking
scan_children(, dec_iflight, ). This may lead to incorrect inflight
counters for some sockets.

This change fixes this bug by changing order of operations:
UNIX_GC_CANDIDATE is now unset only after all inflight counters are
restored to the original state.

  kernel BUG at net/unix/garbage.c:149!
  RIP: 0010:[<ffffffff8717ebf4>]  [<ffffffff8717ebf4>]
  unix_notinflight+0x3b4/0x490 net/unix/garbage.c:149
  Call Trace:
   [<ffffffff8716cfbf>] unix_detach_fds.isra.19+0xff/0x170 net/unix/af_unix.c:1487
   [<ffffffff8716f6a9>] unix_destruct_scm+0xf9/0x210 net/unix/af_unix.c:1496
   [<ffffffff86a90a01>] skb_release_head_state+0x101/0x200 net/core/skbuff.c:655
   [<ffffffff86a9808a>] skb_release_all+0x1a/0x60 net/core/skbuff.c:668
   [<ffffffff86a980ea>] __kfree_skb+0x1a/0x30 net/core/skbuff.c:684
   [<ffffffff86a98284>] kfree_skb+0x184/0x570 net/core/skbuff.c:705
   [<ffffffff871789d5>] unix_release_sock+0x5b5/0xbd0 net/unix/af_unix.c:559
   [<ffffffff87179039>] unix_release+0x49/0x90 net/unix/af_unix.c:836
   [<ffffffff86a694b2>] sock_release+0x92/0x1f0 net/socket.c:570
   [<ffffffff86a6962b>] sock_close+0x1b/0x20 net/socket.c:1017
   [<ffffffff81a76b8e>] __fput+0x34e/0x910 fs/file_table.c:208
   [<ffffffff81a771da>] ____fput+0x1a/0x20 fs/file_table.c:244
   [<ffffffff81483ab0>] task_work_run+0x1a0/0x280 kernel/task_work.c:116
   [<     inline     >] exit_task_work include/linux/task_work.h:21
   [<ffffffff8141287a>] do_exit+0x183a/0x2640 kernel/exit.c:828
   [<ffffffff8141383e>] do_group_exit+0x14e/0x420 kernel/exit.c:931
   [<ffffffff814429d3>] get_signal+0x663/0x1880 kernel/signal.c:2307
   [<ffffffff81239b45>] do_signal+0xc5/0x2190 arch/x86/kernel/signal.c:807
   [<ffffffff8100666a>] exit_to_usermode_loop+0x1ea/0x2d0
  arch/x86/entry/common.c:156
   [<     inline     >] prepare_exit_to_usermode arch/x86/entry/common.c:190
   [<ffffffff81009693>] syscall_return_slowpath+0x4d3/0x570
  arch/x86/entry/common.c:259
   [<ffffffff881478e6>] entry_SYSCALL_64_fastpath+0xc4/0xc6

Link: https://lkml.org/lkml/2017/3/6/252
Signed-off-by: Andrey Ulanov <andreyu@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: 6209344 ("net: unix: fix inflight counting bug in garbage collector")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoopenvswitch: Add missing case OVS_TUNNEL_KEY_ATTR_PAD
Kris Murphy [Thu, 16 Mar 2017 15:51:28 +0000 (10:51 -0500)]
openvswitch: Add missing case OVS_TUNNEL_KEY_ATTR_PAD

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 8f3dbfd79ed9ef9770305a7cc4e13dfd31ad2cd0 ]

Added a case for OVS_TUNNEL_KEY_ATTR_PAD to the switch statement
in ip_tun_from_nlattr in order to prevent the default case
returning an error.

Fixes: b46f6ded906e ("libnl: nla_put_be64(): align on a 64-bit area")
Signed-off-by: Kris Murphy <kriskend@linux.vnet.ibm.com>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoamd-xgbe: Fix jumbo MTU processing on newer hardware
Lendacky, Thomas [Wed, 15 Mar 2017 20:11:23 +0000 (15:11 -0500)]
amd-xgbe: Fix jumbo MTU processing on newer hardware

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 622c36f143fc9566ba49d7cec994c2da1182d9e2 ]

Newer hardware does not provide a cumulative payload length when multiple
descriptors are needed to handle the data. Once the MTU increases beyond
the size that can be handled by a single descriptor, the SKB does not get
built properly by the driver.

The driver will now calculate the size of the data buffers used by the
hardware.  The first buffer of the first descriptor is for packet headers
or packet headers and data when the headers can't be split. Subsequent
descriptors in a multi-descriptor chain will not use the first buffer. The
second buffer is used by all the descriptors in the chain for payload data.
Based on whether the driver is processing the first, intermediate, or last
descriptor it can calculate the buffer usage and build the SKB properly.

Tested and verified on both old and new hardware.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: properly release sk_frag.page
Eric Dumazet [Wed, 15 Mar 2017 20:21:28 +0000 (13:21 -0700)]
net: properly release sk_frag.page

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 ]

I mistakenly added the code to release sk->sk_frag in
sk_common_release() instead of sk_destruct()

TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call
sk_common_release() at close time, thus leaking one (order-3) page.

iSCSI is using such sockets.

Fixes: 5640f7685831 ("net: use a per task frag allocator")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled
Florian Fainelli [Wed, 15 Mar 2017 19:57:21 +0000 (12:57 -0700)]
net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 5371bbf4b295eea334ed453efa286afa2c3ccff3 ]

Suspending the PHY would be putting it in a low power state where it
may no longer allow us to do Wake-on-LAN.

Fixes: cc013fb48898 ("net: bcmgenet: correctly suspend and resume PHY device")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agonet/openvswitch: Set the ipv6 source tunnel key address attribute correctly
Or Gerlitz [Wed, 15 Mar 2017 16:10:47 +0000 (18:10 +0200)]
net/openvswitch: Set the ipv6 source tunnel key address attribute correctly

BugLink: http://bugs.launchpad.net/bugs/1677589
[ Upstream commit 3d20f1f7bd575d147ffa75621fa560eea0aec690 ]

When dealing with ipv6 source tunnel key address attribute
(OVS_TUNNEL_KEY_ATTR_IPV6_SRC) we are wrongly setting the tunnel
dst ip, fix that.

Fixes: 6b26ba3a7d95 ('openvswitch: netlink attributes for IPv6 tunneling')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Paul Blakey <paulb@mellanox.com>
Acked-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Joe Stringer <joe@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoUBUNTU: SAUCE: (no-up) net/mlx5: Avoid dereferencing uninitialized pointer
Talat Batheesh [Wed, 29 Mar 2017 10:49:31 +0000 (13:49 +0300)]
UBUNTU: SAUCE: (no-up) net/mlx5: Avoid dereferencing uninitialized pointer

BugLink: http://bugs.launchpad.net/bugs/1676786
In NETDEV_CHANGEUPPER event the upper_info field is valid
only when linking is true. Otherwise it should be ignored.

Fixes: 7907f23adc18 (net/mlx5: Implement RoCE LAG feature)
Signed-off-by: Talat Batheesh <talatb@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
Reviewed-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agodrivers: hv: Turn off write permission on the hypercall page
K. Y. Srinivasan [Thu, 9 Feb 2017 01:30:56 +0000 (18:30 -0700)]
drivers: hv: Turn off write permission on the hypercall page

BugLink: http://bugs.launchpad.net/bugs/1676635
The hypercall page only needs to be executable but currently it is setup to
be writable as well. Fix the issue.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Acked-by: Kees Cook <keescook@chromium.org>
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 372b1e91343e657a7cc5e2e2bcecd5140ac28119)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoUBUNTU: SAUCE: (no-up) hv: Supply vendor ID and package ABI
Tim Gardner [Tue, 28 Mar 2017 19:37:08 +0000 (13:37 -0600)]
UBUNTU: SAUCE: (no-up) hv: Supply vendor ID and package ABI

BugLink: http://bugs.launchpad.net/bugs/1193172
BugLink: http://bugs.launchpad.net/bugs/1676635
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv_utils: implement Hyper-V PTP source
Vitaly Kuznetsov [Sat, 4 Feb 2017 16:57:14 +0000 (09:57 -0700)]
hv_utils: implement Hyper-V PTP source

BugLink: http://bugs.launchpad.net/bugs/1676635
With TimeSync version 4 protocol support we started updating system time
continuously through the whole lifetime of Hyper-V guests. Every 5 seconds
there is a time sample from the host which triggers do_settimeofday[64]().
While the time from the host is very accurate such adjustments may cause
issues:
- Time is jumping forward and backward, some applications may misbehave.
- In case an NTP server runs in parallel and uses something else for time
  sync (network, PTP,...) system time will never converge.
- Systemd starts annoying you by printing "Time has been changed" every 5
  seconds to the system log.

Instead of doing in-kernel time adjustments offload the work to an
NTP client by exposing TimeSync messages as a PTP device. Users may now
decide what they want to use as a source.

I tested the solution with chrony, the config was:

 refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0

The result I'm seeing is accurate enough, the time delta between the guest
and the host is almost always within [-10us, +10us], the in-kernel solution
was giving us comparable results.

I also tried implementing PPS device instead of PTP by using not currently
used Hyper-V synthetic timers (we use only one of four for clockevent) but
with PPS source only chrony wasn't able to give me the required accuracy,
the delta often more that 100us.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3716a49a81ba19dda7202633a68b28564ba95eb5)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: export current Hyper-V clocksource
Vitaly Kuznetsov [Sat, 4 Feb 2017 16:57:13 +0000 (09:57 -0700)]
hv: export current Hyper-V clocksource

BugLink: http://bugs.launchpad.net/bugs/1676635
As a preparation to implementing Hyper-V PTP device supporting
.getcrosststamp we need to export a reference to the current Hyper-V
clocksource in use (MSR or TSC page).

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dee863b571b0a76e9c549ee99e8782bb4bc6502b)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: Fix the bug in generating the guest ID
K. Y. Srinivasan [Sat, 4 Feb 2017 15:46:23 +0000 (08:46 -0700)]
Drivers: hv: Fix the bug in generating the guest ID

BugLink: http://bugs.launchpad.net/bugs/1676635
Fix the bug in the generation of the guest ID. Without this fix
the host side telemetry code is broken.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Fixes: 352c9624242d ("Drivers: hv: vmbus: Move the definition of generate_guest_id()")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 9b06e1018abc65585b07c75c5b3f406dbabe7005)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: Log the negotiated IC versions.
Alex Ng [Sat, 28 Jan 2017 19:37:18 +0000 (12:37 -0700)]
Drivers: hv: Log the negotiated IC versions.

BugLink: http://bugs.launchpad.net/bugs/1676635
Log the negotiated IC versions.

Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1274a690f6b2bd2b37447c47e3062afa8aa43f93)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Use all supported IC versions to negotiate
Alex Ng [Sat, 28 Jan 2017 19:37:17 +0000 (12:37 -0700)]
Drivers: hv: vmbus: Use all supported IC versions to negotiate

BugLink: http://bugs.launchpad.net/bugs/1676635
Previously, we were assuming that each IC protocol version was tied to a
specific host version. For example, some Windows 10 preview hosts only
support v3 TimeSync even though driver assumes v4 is supported by all
Windows 10 hosts.

The guest will stop trying to negotiate even though older supported
versions may still be offered by the host.

Make IC version negotiation more robust by going through all versions
that are supported by the guest.

Fixes: 3da0401b4d0e ("Drivers: hv: utils: Fix the mapping between host
version and protocol to use")

Reported-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
Signed-off-by: Alex Ng <alexng@messages.microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a1656454131880980bc3a5313c8bf66ef5990c91)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: balloon: add a fall through comment to hv_memory_notifier()
Vitaly Kuznetsov [Sat, 28 Jan 2017 19:37:16 +0000 (12:37 -0700)]
Drivers: hv: balloon: add a fall through comment to hv_memory_notifier()

BugLink: http://bugs.launchpad.net/bugs/1676635
Coverity scan gives a warning when there is fall through in a switch
without a comment. This fall through is intentional as ol_waitevent needs
to be completed to unblock hv_mem_hot_add() allowing it to process next
requests regardless of the result of if we were able to online this block.

Reported-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ad6d41253bf91eabb41626683c35a712ba27a20c)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: restore TSC page cleanup before kexec
Vitaly Kuznetsov [Sat, 28 Jan 2017 19:37:15 +0000 (12:37 -0700)]
Drivers: hv: restore TSC page cleanup before kexec

BugLink: http://bugs.launchpad.net/bugs/1676635
We need to cleanup the TSC page before doing kexec/kdump or the new kernel
may crash if it tries to use it.

Fixes: 63ed4e0c67df ("Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5647dbf8f0807a35421bd0232247b02413ef2cab)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: restore hypervcall page cleanup before kexec
Vitaly Kuznetsov [Sat, 28 Jan 2017 19:37:14 +0000 (12:37 -0700)]
Drivers: hv: restore hypervcall page cleanup before kexec

BugLink: http://bugs.launchpad.net/bugs/1676635
We need to cleanup the hypercall page before doing kexec/kdump or the new
kernel may crash if it tries to use it. Reuse the now-empty hv_cleanup
function renaming it to hyperv_cleanup and moving to the arch specific
code.

Fixes: 8730046c1498 ("Drivers: hv vmbus: Move Hypercall page setup out of common code")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d6f3609d2b4c6d0eec01f398cb685e50da3e6013)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv_util: switch to using timespec64
Vitaly Kuznetsov [Sat, 28 Jan 2017 19:37:13 +0000 (12:37 -0700)]
hv_util: switch to using timespec64

BugLink: http://bugs.launchpad.net/bugs/1676635
do_settimeofday() is deprecated, use do_settimeofday64() instead.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 17244623a4c0f68d3f02c9c74d9b6ae259425826)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Cleanup hyperv_vmbus.h
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:59 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Cleanup hyperv_vmbus.h

BugLink: http://bugs.launchpad.net/bugs/1676635
Get rid of all unused definitions.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8e27a236312c4ab6dc8dbd303552b771d3569cf1)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Define an APIs to manage interrupt state
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:58 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Define an APIs to manage interrupt state

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of cleaning up architecture specific code, define APIs
to manage interrupt state.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 37e11d5c7052a5ca55ef807731c75218ea341b4c)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Define an API to retrieve virtual processor index
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:57 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Define an API to retrieve virtual processor index

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of cleaning up architecture specific code, define an API
to retrieve the virtual procesor index.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 7297ff0ca9db7e2d830841035b95d8b94b529142)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:56 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Define APIs to manipulate the synthetic interrupt controller

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of cleaning up architecture specific code, define APIs
to manipulate the interrupt controller state.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 06d1d98a839f196e94cb726008fb2118e430f356)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Define APIs to manipulate the event page
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:55 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Define APIs to manipulate the event page

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of cleaning up architecture specific code, define APIs
to manipulate the event page.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8e307bf82d76ab02e95a00d132d926f04db6ccab)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Define APIs to manipulate the message page
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:54 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Define APIs to manipulate the message page

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of cleaning up architecture specific code, define APIs
to manipulate the message page.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 155e4a2f28a59e5344dfa7c5d003161fe59a5bf2)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Get rid of an unsused variable
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:53 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Get rid of an unsused variable

BugLink: http://bugs.launchpad.net/bugs/1676635
The version variable while it is initialized is not used;
get rid of it.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d383877db60bcc7fd02d1051a90e078d731dfb59)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: util: Use hv_get_current_tick() to get current tick
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:52 +0000 (11:51 -0700)]
Drivers: hv: util: Use hv_get_current_tick() to get current tick

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to interact with Hyper-V in an instruction set
architecture independent way, use the new API to get the current
tick.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 305f7549c9298247723c255baddb7a54b4e63050)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Restructure the clockevents code
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:51 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Restructure the clockevents code

BugLink: http://bugs.launchpad.net/bugs/1676635
Move the relevant code that programs the hypervisor to an architecture
specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d5116b4091ecca271c249ede43a49c1245920558)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the code to signal end of message
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:50 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Move the code to signal end of message

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
code for signaling end of message.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e810e48c0c9a1a1ebb90cfe966bce6dc80ce08e7)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the check for hypercall page setup
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:49 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Move the check for hypercall page setup

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
check for detecting if the hypercall page is setup.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 73638cddaad861a5ebb2b119d8b318d4bded8f8d)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the crash notification function
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:48 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Move the crash notification function

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
crash notification function.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d058fa7e98ff01a4b4750a2210fc19906db3cbe1)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the extracting of Hypervisor version information
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:47 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Move the extracting of Hypervisor version information

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code,
extract hypervisor version information in an architecture specific
file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8de8af7e0873c4fdac2205327dff922819e16657)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code
K. Y. Srinivasan [Thu, 19 Jan 2017 18:51:46 +0000 (11:51 -0700)]
Drivers: hv: vmbus: Consolidate all Hyper-V specific clocksource code

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code,
consolidate all Hyper-V specific clocksource code to an architecture
specific code.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 63ed4e0c67df332681ebfef6eca6852da28d6300)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move Hypercall invocation code out of common code
K. Y. Srinivasan [Wed, 18 Jan 2017 23:45:03 +0000 (16:45 -0700)]
Drivers: hv: vmbus: Move Hypercall invocation code out of common code

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
hypercall invocation code to an architecture specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6ab42a66d2cc10afefea9f9e5d9a5ad5a836d254)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv vmbus: Move Hypercall page setup out of common code
K. Y. Srinivasan [Wed, 18 Jan 2017 23:45:02 +0000 (16:45 -0700)]
Drivers: hv vmbus: Move Hypercall page setup out of common code

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
hypercall page setup to an architecture specific file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8730046c1498e8fb8c9a124789893944e8ce8220)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the definition of generate_guest_id()
K. Y. Srinivasan [Wed, 18 Jan 2017 23:45:01 +0000 (16:45 -0700)]
Drivers: hv: vmbus: Move the definition of generate_guest_id()

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
definition of generate_guest_id() to x86 specific header file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 352c9624242d5836ad8a960826183011367871a4)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents
K. Y. Srinivasan [Wed, 18 Jan 2017 23:45:00 +0000 (16:45 -0700)]
Drivers: hv: vmbus: Move the definition of hv_x64_msr_hypercall_contents

BugLink: http://bugs.launchpad.net/bugs/1676635
As part of the effort to separate out architecture specific code, move the
definition of hv_x64_msr_hypercall_contents to x86 specific header file.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3f646ed70ccd1c4e5c1263d2922247d28c8e08f0)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: util: Backup: Fix a rescind processing issue
K. Y. Srinivasan [Fri, 23 Dec 2016 00:54:03 +0000 (16:54 -0800)]
Drivers: hv: util: Backup: Fix a rescind processing issue

BugLink: http://bugs.launchpad.net/bugs/1676635
VSS may use a char device to support the communication between
the user level daemon and the driver. When the VSS channel is rescinded
we need to make sure that the char device is fully cleaned up before
we can process a new VSS offer from the host. Implement this logic.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d77044d142e960f7b5f814a91ecb8bcf86aa552c)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: util: Fcopy: Fix a rescind processing issue
K. Y. Srinivasan [Fri, 23 Dec 2016 00:54:02 +0000 (16:54 -0800)]
Drivers: hv: util: Fcopy: Fix a rescind processing issue

BugLink: http://bugs.launchpad.net/bugs/1676635
Fcopy may use a char device to support the communication between
the user level daemon and the driver. When the Fcopy channel is rescinded
we need to make sure that the char device is fully cleaned up before
we can process a new Fcopy offer from the host. Implement this logic.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 20951c7535b5e6af46bc37b7142105f716df739c)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: util: kvp: Fix a rescind processing issue
K. Y. Srinivasan [Fri, 23 Dec 2016 00:54:01 +0000 (16:54 -0800)]
Drivers: hv: util: kvp: Fix a rescind processing issue

BugLink: http://bugs.launchpad.net/bugs/1676635
KVP may use a char device to support the communication between
the user level daemon and the driver. When the KVP channel is rescinded
we need to make sure that the char device is fully cleaned up before
we can process a new KVP offer from the host. Implement this logic.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5a66fecbf6aa528e375cbebccb1061cc58d80c84)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Fix a rescind handling bug
K. Y. Srinivasan [Fri, 23 Dec 2016 00:54:00 +0000 (16:54 -0800)]
Drivers: hv: vmbus: Fix a rescind handling bug

BugLink: http://bugs.launchpad.net/bugs/1676635
The host can rescind a channel that has been offered to the
guest and once the channel is rescinded, the host does not
respond to any requests on that channel. Deal with the case where
the guest may be blocked waiting for a response from the host.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ccb61f8a99e6c29df4fb96a65dad4fad740d5be9)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: make CPU offlining prevention fine-grained
Vitaly Kuznetsov [Wed, 7 Dec 2016 22:53:12 +0000 (14:53 -0800)]
hv: make CPU offlining prevention fine-grained

BugLink: http://bugs.launchpad.net/bugs/1676635
Since commit e513229b4c38 ("Drivers: hv: vmbus: prevent cpu offlining on
newer hypervisors") cpu offlining was disabled. It is still true that we
can't offline CPUs which have VMBus channels bound to them but we may have
'free' CPUs (e.v. we booted with maxcpus= parameter and onlined CPUs after
VMBus was initialized), these CPUs may be disabled without issues.

In future, we may even allow closing CPUs which have only sub-channels
assinged to them by closing these sub-channels. All devices will continue
to work.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 523b94087078f7f5ac10b7d9cd04277927031c39)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: switch to cpuhp state machine for synic init/cleanup
Vitaly Kuznetsov [Wed, 7 Dec 2016 22:53:11 +0000 (14:53 -0800)]
hv: switch to cpuhp state machine for synic init/cleanup

BugLink: http://bugs.launchpad.net/bugs/1676635
To make it possible to online/offline CPUs switch to cpuhp infrastructure
for doing hv_synic_init()/hv_synic_cleanup().

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 76d36ab79820430f73c584673aef10ba2446fced)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Prevent sending data on a rescinded channel
K. Y. Srinivasan [Wed, 7 Dec 2016 09:16:28 +0000 (01:16 -0800)]
Drivers: hv: vmbus: Prevent sending data on a rescinded channel

BugLink: http://bugs.launchpad.net/bugs/1676635
After the channel is rescinded, the host does not read from the rescinded channel.
Fail writes to a channel that has already been rescinded. If we permit writes on a
rescinded channel, since the host will not respond we will have situations where
we will be unable to unload vmbus drivers that cannot have any outstanding requests
to the host at the point they are unoaded.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e7e97dd8b77ee7366f2f8c70a033bf5fa05ec2e0)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: don't reset hv_context.tsc_page on crash
Vitaly Kuznetsov [Wed, 7 Dec 2016 09:16:27 +0000 (01:16 -0800)]
hv: don't reset hv_context.tsc_page on crash

BugLink: http://bugs.launchpad.net/bugs/1676635
It may happen that secondary CPUs are still alive and resetting
hv_context.tsc_page will cause a consequent crash in read_hv_clock_tsc()
as we don't check for it being not NULL there. It is safe as we're not
freeing this page anyways.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 56ef6718a1d8d77745033c5291e025ce18504159)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: init percpu_list in hv_synic_alloc()
Vitaly Kuznetsov [Wed, 7 Dec 2016 09:16:26 +0000 (01:16 -0800)]
hv: init percpu_list in hv_synic_alloc()

BugLink: http://bugs.launchpad.net/bugs/1676635
Initializing hv_context.percpu_list in hv_synic_alloc() helps to prevent a
crash in percpu_channel_enq() when not all CPUs were online during
initialization and it naturally belongs there.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3c7630d35009e6635e5b58d62de554fd5b6db5df)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agohv: allocate synic pages for all present CPUs
Vitaly Kuznetsov [Wed, 7 Dec 2016 09:16:25 +0000 (01:16 -0800)]
hv: allocate synic pages for all present CPUs

BugLink: http://bugs.launchpad.net/bugs/1676635
It may happen that not all CPUs are online when we do hv_synic_alloc() and
in case more CPUs come online later we may try accessing these allocated
structures.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 421b8f20d3c381b215f988b42428f56fc3b82405)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoDrivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()
Vitaly Kuznetsov [Wed, 7 Dec 2016 09:16:24 +0000 (01:16 -0800)]
Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()

BugLink: http://bugs.launchpad.net/bugs/1676635
DoS protection conditions were altered in WS2016 and now it's easy to get
-EAGAIN returned from vmbus_post_msg() (e.g. when we try changing MTU on a
netvsc device in a loop). All vmbus_post_msg() callers don't retry the
operation and we usually end up with a non-functional device or crash.

While host's DoS protection conditions are unknown to me my tests show that
it can take up to 10 seconds before the message is sent so doing udelay()
is not an option, we really need to sleep. Almost all vmbus_post_msg()
callers are ready to sleep but there is one special case:
vmbus_initiate_unload() which can be called from interrupt/NMI context and
we can't sleep there. I'm also not sure about the lonely
vmbus_send_tl_connect_request() which has no in-tree users but its external
users are most likely waiting for the host to reply so sleeping there is
also appropriate.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit c0bb03924f1a80e7f65900e36c8e6b3dc167c5f8)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "UBUNTU: SAUCE: (no-up) hv: Supply vendor ID and package ABI"
Tim Gardner [Tue, 28 Mar 2017 20:23:25 +0000 (14:23 -0600)]
Revert "UBUNTU: SAUCE: (no-up) hv: Supply vendor ID and package ABI"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 2400c988c0b5da90b7035bfce63f1105e66b3423.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "drivers: hv: Turn off write permission on the hypercall page"
Tim Gardner [Tue, 28 Mar 2017 20:22:06 +0000 (14:22 -0600)]
Revert "drivers: hv: Turn off write permission on the hypercall page"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 71a5a0559d132a6bb20e63e8e9c62fbd22666137.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: util: Backup: Fix a rescind processing issue"
Tim Gardner [Tue, 28 Mar 2017 20:21:56 +0000 (14:21 -0600)]
Revert "Drivers: hv: util: Backup: Fix a rescind processing issue"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 8da12e10a191c62830c277f35a4fa5403eb1bcd2.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: util: Fcopy: Fix a rescind processing issue"
Tim Gardner [Tue, 28 Mar 2017 20:21:46 +0000 (14:21 -0600)]
Revert "Drivers: hv: util: Fcopy: Fix a rescind processing issue"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit c9d4b38c5c386cab269664832fdcd9d6b878f998.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: util: kvp: Fix a rescind processing issue"
Tim Gardner [Tue, 28 Mar 2017 20:21:37 +0000 (14:21 -0600)]
Revert "Drivers: hv: util: kvp: Fix a rescind processing issue"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit ca0b5897e11ebcd15770561849f45f2c7a980d85.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: vmbus: Fix a rescind handling bug"
Tim Gardner [Tue, 28 Mar 2017 20:21:25 +0000 (14:21 -0600)]
Revert "Drivers: hv: vmbus: Fix a rescind handling bug"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 1b7d44c16f61522ee0c7b79d6f666a89c3244a5a.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: vmbus: Prevent sending data on a rescinded channel"
Tim Gardner [Tue, 28 Mar 2017 20:21:15 +0000 (14:21 -0600)]
Revert "Drivers: hv: vmbus: Prevent sending data on a rescinded channel"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 81afb2c5dfd49aab0f6a3240c83d975416b53245.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "hv: init percpu_list in hv_synic_alloc()"
Tim Gardner [Tue, 28 Mar 2017 20:21:04 +0000 (14:21 -0600)]
Revert "hv: init percpu_list in hv_synic_alloc()"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit db60c8d6cc34f9966be31c574ec20d577a6730a2.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "hv: allocate synic pages for all present CPUs"
Tim Gardner [Tue, 28 Mar 2017 20:20:54 +0000 (14:20 -0600)]
Revert "hv: allocate synic pages for all present CPUs"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 9b66ff22466f0f566fe688a0e77d03a4e7fb11de.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()"
Tim Gardner [Tue, 28 Mar 2017 20:20:42 +0000 (14:20 -0600)]
Revert "Drivers: hv: vmbus: Raise retry/wait limits in vmbus_post_msg()"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit 816725f684dd5d018c4314f79797d0ea8eccdd9b.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoRevert "hv: don't reset hv_context.tsc_page on crash"
Tim Gardner [Tue, 28 Mar 2017 20:20:30 +0000 (14:20 -0600)]
Revert "hv: don't reset hv_context.tsc_page on crash"

BugLink: http://bugs.launchpad.net/bugs/1676635
This reverts commit e7a2222fc8a0d23d0e6020f04cccc63ff545f9bf.

Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agopowerpc/64: Use optimized checksum routines on little-endian
Paul Mackerras [Thu, 3 Nov 2016 05:15:42 +0000 (16:15 +1100)]
powerpc/64: Use optimized checksum routines on little-endian

BugLink: http://bugs.launchpad.net/bugs/1670247
Currently we have optimized hand-coded assembly checksum routines for
big-endian 64-bit systems, but for little-endian we use the generic C
routines. This modifies the optimized routines to work for
little-endian. With this, we no longer need to enable
CONFIG_GENERIC_CSUM. This also fixes a couple of comments in
checksum_64.S so they accurately reflect what the associated instruction
does.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
[mpe: Use the more common __BIG_ENDIAN__]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit d4fde568a34a93897dfb9ae64cfe9dda9d5c908c)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agopowerpc/64: Fix checksum folding in csum_tcpudp_nofold and ip_fast_csum_nofold
Paul Mackerras [Thu, 3 Nov 2016 05:10:55 +0000 (16:10 +1100)]
powerpc/64: Fix checksum folding in csum_tcpudp_nofold and ip_fast_csum_nofold

BugLink: http://bugs.launchpad.net/bugs/1670247
These functions compute an IP checksum by computing a 64-bit sum and
folding it to 32 bits (the "nofold" in their names refers to folding
down to 16 bits).  However, doing (u32) (s + (s >> 32)) is not
sufficient to fold a 64-bit sum to 32 bits correctly.  The addition
can produce a carry out from bit 31, which needs to be added in to
the sum to produce the correct result.

To fix this, we copy the from64to32() function from lib/checksum.c
and use that.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit b492f7e4e07a28e706db26cf4943bb0911435426)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoscsi: storvsc: Workaround for virtual DVD SCSI version
Stephen Hemminger [Tue, 28 Mar 2017 16:40:17 +0000 (12:40 -0400)]
scsi: storvsc: Workaround for virtual DVD SCSI version

BugLink: http://bugs.launchpad.net/bugs/1674635
Hyper-V host emulation of SCSI for virtual DVD device reports SCSI
version 0 (UNKNOWN) but is still capable of supporting REPORTLUN.

Without this patch, a GEN2 Linux guest on Hyper-V will not boot 4.11
successfully with virtual DVD ROM device. What happens is that the SCSI
scan process falls back to doing sequential probing by INQUIRY.  But the
storvsc driver has a previous workaround that masks/blocks all errors
reports from INQUIRY (or MODE_SENSE) commands.  This workaround causes
the scan to then populate a full set of bogus LUN's on the target and
then sends kernel spinning off into a death spiral doing block reads on
the non-existent LUNs.

By setting the correct blacklist flags, the target with the DVD device
is scanned with REPORTLUN and that works correctly.

Patch needs to go in current 4.11, it is safe but not necessary in older
kernels.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f1c635b439a5c01776fe3a25b1e2dc546ea82e6f)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agopowerpc/powernv: Remove separate entry for OPAL real mode calls
Benjamin Herrenschmidt [Tue, 28 Mar 2017 16:54:45 +0000 (13:54 -0300)]
powerpc/powernv: Remove separate entry for OPAL real mode calls

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1675806
All entry points already read the MSR so they can easily do
the right thing.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit ab9bad0ead9ab179ace09988a3f1cfca122eb7c2)
Signed-off-by: Breno Leitao <breno.leitao@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agopowerpc/powernv: Initialise nest mmu
Alistair Popple [Tue, 28 Mar 2017 16:54:44 +0000 (13:54 -0300)]
powerpc/powernv: Initialise nest mmu

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1675806
POWER9 contains an off core mmu called the nest mmu (NMMU). This is
used by other hardware units on the chip to translate virtual
addresses into real addresses. The unit attempting an address
translation provides the majority of the context required for the
translation request except for the base address of the partition table
(ie. the PTCR) which needs to be programmed into the NMMU.

This patch adds a call to OPAL to set the PTCR for the nest mmu in
opal_init().

Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
(cherry picked from commit 1d0761d2557d1540727723e4f05395d53321d555)
Signed-off-by: Breno Leitao <breno.leitao@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
7 years agoKVM: PPC: Book 3S: XICS: Don't lock twice when checking for resend
Li Zhong [Tue, 28 Mar 2017 16:54:43 +0000 (13:54 -0300)]
KVM: PPC: Book 3S: XICS: Don't lock twice when checking for resend

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1675806
This patch improves the code that takes lock twice to check the resend flag
and do the actual resending, by checking the resend flag locklessly, and
add a boolean parameter check_resend to icp_[rm_]deliver_irq(), so the
resend flag can be checked in the lock when doing the delivery.

We need make sure when we clear the ics's bit in the icp's resend_map, we
don't miss the resend flag of the irqs that set the bit. It could be
ordered through the barrier in test_and_clear_bit(), and a newly added
wmb between setting irq's resend flag, and icp's resend_map.

Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
(cherry picked from commit 21acd0e4df04f02176e773468658c3cebff096bb)
Signed-off-by: Breno Leitao <breno.leitao@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>