5.11.3-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 590/775 USB: serial: mos7840: fix error code in mos7840_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit a70aa7dc60099bbdcbd6faca42a915d80f31161e upstream.
This should return -ENOMEM instead of 0 if the kmalloc() fails.
--- drivers/usb/serial/mos7840.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7840.c +3 -1
@@ -883,8 +883,10 @@ static int mos7840_write(struct tty_struif (urb->transfer_buffer ==NULL ) { urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); -if (!urb->transfer_buffer) +if (!urb->transfer_buffer) { + bytes_sent = -ENOMEM ; goto exit; + } } transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );
Greg Kroah-Hartman
maintainerPATCH 591/775 USB: serial: mos7720: fix error code in mos7720_write()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit fea7372cbc40869876df0f045e367f6f97a1666c upstream.
This code should return -ENOMEM if the kmalloc() fails but instead it returns success.
--- drivers/usb/serial/mos7720.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7720.c +3 -1
@@ -1092,8 +1092,10 @@ static int mos7720_write(struct tty_struif (urb->transfer_buffer ==NULL ) { urb->transfer_buffer =kmalloc (URB_TRANSFER_BUFFER_SIZE ,GFP_ATOMIC ); -if (!urb->transfer_buffer) +if (!urb->transfer_buffer) { + bytes_sent = -ENOMEM ; goto exit; + } } transfer_size =min (count,URB_TRANSFER_BUFFER_SIZE );
Greg Kroah-Hartman
maintainerPATCH 592/775 phy: lantiq: rcu-usb2: wait after clock enable
In reply to Greg Kroah-HartmanFrom: Mathias Kresin <[email protected]>
commit 36acd5e24e3000691fb8d1ee31cf959cb1582d35 upstream.
Commit 65dc2e725286 ("usb: dwc2: Update Core Reset programming flow.") revealed that the phy isn't ready immediately after enabling it's clocks. The dwc2_check_core_version() fails and the dwc2 usb driver errors out.
Add a short delay to let the phy get up and running. There isn't any documentation how much time is required, the value was chosen based on tests.
--- drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/phy/lantiq/phy-lantiq-rcu-usb2.c +9 -1
@@ -124,8 +124,16 @@ static int ltq_rcu_usb2_phy_power_on(strreset_control_deassert (priv->phy_reset); ret =clk_prepare_enable (priv->phy_gate_clk); -if (ret) +if (ret) {dev_err (dev,"failed to enable PHY gate\n" ); +return ret; + } + +/* +* at least the xrx200 usb2 phy requires some extra time to be +* operational after enabling the clock +*/ +usleep_range (100 ,200 );return ret; }
Greg Kroah-Hartman
maintainerPATCH 593/775 ALSA: usb-audio: Correct document for snd_usb_endpoint_free_all()
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 036f90dd92bb0aac66fdeec8386401dd396c6079 upstream.
The kerndoc comment for the new function snd_usb_endpoint_free_all() had a typo wrt the argument name. Fix it.
--- sound/usb/endpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/endpoint.c +1 -1
@@ -1451,7 +1451,7 @@ void snd_usb_endpoint_release(struct snd/** * snd_usb_endpoint_free_all: Free the resources of an snd_usb_endpoint -* @card: The chip +* @chip: The chip * * This free all endpoints and those resources */
Greg Kroah-Hartman
maintainerPATCH 594/775 ALSA: usb-audio: Handle invalid running state at releasing EP
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit d6cda4655e2a7612a1e48c49795a5330abc01c5a upstream.
When we stop an endpoint in release_urbs(), it ignores the inconsistent endpoint state and tries to release the resources. This shouldn't happen in theory, but it's still safer to abort the release and let the caller proper error handling.
Also, stop_and_unlink_urbs() called from release_urbs() does two step works, and it's more straightforward to split this to two functions again, so that the call from the PCM trigger won't take the path with sleeping.
This patch modifies the EP management code to adapt two points above.
--- sound/usb/endpoint.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
sound/usb/endpoint.c +21 -19
@@ -868,24 +868,22 @@ void snd_usb_endpoint_sync_pending_stop( }/* -* Stop and unlink active urbs. +* Stop active urbs * -* This function checks and clears EP_FLAG_RUNNING state. -* When @wait_sync is set, it waits until all pending URBs are killed. +* This function moves the EP to STOPPING state if it's being RUNNING. */ -static int stop_and_unlink_urbs (struct snd_usb_endpoint *ep,bool force, -bool wait_sync) +static int stop_urbs (struct snd_usb_endpoint *ep,bool force) {unsigned int i;if (!force &&atomic_read (&ep->chip->shutdown))/* to be sure... */ return -EBADFD ; -if (atomic_read (&ep->running)) +if (!force &&atomic_read (&ep->running))return -EBUSY ;if (!test_and_clear_bit (EP_FLAG_RUNNING , &ep->flags)) - goto out; +return 0 ;set_bit (EP_FLAG_STOPPING , &ep->flags);INIT_LIST_HEAD (&ep->ready_playback_urbs);
@@ -901,24 +899,25 @@ static int stop_and_unlink_urbs(struct s } } - out: -if (wait_sync) -return wait_clear_urbs (ep);return 0 ; }/* * release an endpoint's urbs */ -static void release_urbs (struct snd_usb_endpoint *ep,int force) +static int release_urbs (struct snd_usb_endpoint *ep,bool force) { -int i; +int i, err;/* route incoming urbs to nirvana */ snd_usb_endpoint_set_callback (ep,NULL ,NULL ,NULL ); -/* stop urbs */ -stop_and_unlink_urbs (ep, force, true); +/* stop and unlink urbs */ + err =stop_urbs (ep, force); +if (err) +return err; + +wait_clear_urbs (ep);for (i =0 ; i < ep->nurbs; i++)release_urb_ctx (&ep->urb[i]);
@@ -928,6 +927,7 @@ static void release_urbs(struct snd_usb_ ep->syncbuf =NULL ; ep->nurbs =0 ; +return 0 ; }/*
@@ -1118,7 +1118,7 @@ static int data_ep_set_params(struct sndreturn 0 ; out_of_memory: -release_urbs (ep,0 ); +release_urbs (ep, false);return -ENOMEM ; }
@@ -1162,7 +1162,7 @@ static int sync_ep_set_params(struct sndreturn 0 ; out_of_memory: -release_urbs (ep,0 ); +release_urbs (ep, false);return -ENOMEM ; }
@@ -1180,7 +1180,9 @@ static int snd_usb_endpoint_set_params(sint err;/* release old buffers, if any */ -release_urbs (ep,0 ); + err =release_urbs (ep, false); +if (err <0 ) +return err; ep->datainterval = fmt->datainterval; ep->maxpacksize = fmt->maxpacksize;
@@ -1433,7 +1435,7 @@ void snd_usb_endpoint_stop(struct snd_usWRITE_ONCE (ep->sync_source->sync_sink,NULL );if (!atomic_dec_return (&ep->running)) -stop_and_unlink_urbs (ep, false, false); +stop_urbs (ep, false); }/**
@@ -1446,7 +1448,7 @@ void snd_usb_endpoint_stop(struct snd_us*/ void snd_usb_endpoint_release (struct snd_usb_endpoint *ep) { -release_urbs (ep,1 ); +release_urbs (ep, true); }/**
Greg Kroah-Hartman
maintainerPATCH 595/775 ALSA: usb-audio: More strict state change in EP
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 5c2b301476ec493be15546f05e23414e2aa9d472 upstream.
The endpoint management has bit flags to indicate the current state, and we're dealing two things: the running bit and the stopping bit. There is a thin window in transition from the running to the stopping in stop_urbs(), and as long as the bit flags are used, it's difficult to plug.
This patch modifies the state management code to use the atomic int and follow the explicit three states, STOPPED, RUNNING and STOPPING. The state change is done via atomic_cmpxhg() for avoiding possible races, and check the state change more strictly. The unexpected state change is now handled as an error.
--- sound/usb/card.h | 2 +- sound/usb/endpoint.c | 42 ++++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 15 deletions(-)
sound/usb/card.h +1 -1
@@ -71,7 +71,7 @@ struct snd_usb_endpoint {unsigned char altsetting;/* corresponding alternate setting */ unsigned char ep_idx;/* endpoint array index */ -unsigned long flags;/* running bit flags */ +atomic_t state;/* running state */ void (*prepare_data_urb) (struct snd_usb_substream *subs,struct urb *urb);
sound/usb/endpoint.c +28 -14
108 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 596/775 ALSA: usb-audio: Dont avoid stopping the stream at disconnection
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 257d2d7e9e798305d65825cb82b0a7d1c0511e89 upstream.
In the later patch, we're going to issue the PCM sync_stop calls at disconnection. But currently the USB-audio driver can't handle it because it has a check of shutdown flag for stopping the URBs. This is basically superfluous (the stopping URBs are safe at disconnection state), so let's drop the check.
--- sound/usb/endpoint.c | 3 --- sound/usb/pcm.c | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-)
sound/usb/endpoint.c +0 -3
@@ -890,9 +890,6 @@ static int stop_urbs(struct snd_usb_endp {unsigned int i; -if (!force &&atomic_read (&ep->chip->shutdown))/* to be sure... */ -return -EBADFD ; -if (!force &&atomic_read (&ep->running))return -EBUSY ;
sound/usb/pcm.c +1 -4
@@ -270,10 +270,7 @@ static int snd_usb_pcm_sync_stop(struct {struct snd_usb_substream *subs = substream->runtime->private_data; -if (!snd_usb_lock_shutdown (subs->stream->chip)) { -sync_pending_stops (subs); -snd_usb_unlock_shutdown (subs->stream->chip); - } +sync_pending_stops (subs);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 597/775 ALSA: usb-audio: Add implicit fb quirk for BOSS GP-10
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 15447b64789d9ade71eb374d5ae1f37d0bbce0bd upstream.
BOSS GP-10 with 0582:0185 requires the similar quirk to make the implicit feedback working like other BOSS devices.
--- sound/usb/implicit.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/implicit.c +2 -0
@@ -73,6 +73,7 @@ static const struct snd_usb_implicit_fb_/* No quirk for playback but with capture quirk (see below) */ IMPLICIT_FB_SKIP_DEV (0x0582 ,0x0130 ),/* BOSS BR-80 */ IMPLICIT_FB_SKIP_DEV (0x0582 ,0x0171 ),/* BOSS RC-505 */ +IMPLICIT_FB_SKIP_DEV (0x0582 ,0x0185 ),/* BOSS GP-10 */ IMPLICIT_FB_SKIP_DEV (0x0582 ,0x0189 ),/* BOSS GT-100v2 */ IMPLICIT_FB_SKIP_DEV (0x0582 ,0x01d6 ),/* BOSS GT-1 */ IMPLICIT_FB_SKIP_DEV(0x0582, 0x01d8), /* BOSS Katana */
@@ -86,6 +87,7 @@ static const struct snd_usb_implicit_fb_static const struct snd_usb_implicit_fb_match capture_implicit_fb_quirks[] = {IMPLICIT_FB_FIXED_DEV (0x0582 ,0x0130 ,0x0d ,0x01 ),/* BOSS BR-80 */ IMPLICIT_FB_FIXED_DEV (0x0582 ,0x0171 ,0x0d ,0x01 ),/* BOSS RC-505 */ +IMPLICIT_FB_FIXED_DEV (0x0582 ,0x0185 ,0x0d ,0x01 ),/* BOSS GP-10 */ IMPLICIT_FB_FIXED_DEV (0x0582 ,0x0189 ,0x0d ,0x01 ),/* BOSS GT-100v2 */ IMPLICIT_FB_FIXED_DEV (0x0582 ,0x01d6 ,0x0d ,0x01 ),/* BOSS GT-1 */ IMPLICIT_FB_FIXED_DEV (0x0582 ,0x01d8 ,0x0d ,0x01 ),/* BOSS Katana */
Greg Kroah-Hartman
maintainerPATCH 598/775 ALSA: fireface: fix to parse sync status register of latter protocol
In reply to Greg Kroah-HartmanFrom: Takashi Sakamoto <[email protected]>
commit c50bfc8a6866775be39d7e747e83e8a5a9051e2e upstream.
Fireface UCX, UFX, and FF802 are categorized for latter protocol of the series. Current support for FF802 (and UFX) includes failure to parse sync status register and results in EIO.
Further investigation figures out that the content of register differs depending on models. This commit adds tables specific to FF802 and UFX to fix it.
--- sound/firewire/fireface/ff-protocol-latter.c | 118 ++++++++++++++++++++++----- 1 file changed, 100 insertions(+), 18 deletions(-)
sound/firewire/fireface/ff-protocol-latter.c +100 -18
@@ -15,6 +15,61 @@#define LATTER_FETCH_MODE 0xffff00000010ULL#define LATTER_SYNC_STATUS 0x0000801c0000ULL +// The content of sync status register differs between models. +// +// Fireface UCX: +// 0xf0000000: (unidentified) +// 0x0f000000: effective rate of sampling clock +// 0x00f00000: detected rate of word clock on BNC interface +// 0x000f0000: detected rate of ADAT or S/PDIF on optical interface +// 0x0000f000: detected rate of S/PDIF on coaxial interface +// 0x00000e00: effective source of sampling clock +// 0x00000e00: Internal +// 0x00000800: (unidentified) +// 0x00000600: Word clock on BNC interface +// 0x00000400: ADAT on optical interface +// 0x00000200: S/PDIF on coaxial or optical interface +// 0x00000100: Optical interface is used for ADAT signal +// 0x00000080: (unidentified) +// 0x00000040: Synchronized to word clock on BNC interface +// 0x00000020: Synchronized to ADAT or S/PDIF on optical interface +// 0x00000010: Synchronized to S/PDIF on coaxial interface +// 0x00000008: (unidentified) +// 0x00000004: Lock word clock on BNC interface +// 0x00000002: Lock ADAT or S/PDIF on optical interface +// 0x00000001: Lock S/PDIF on coaxial interface +// +// Fireface 802 (and perhaps UFX): +// 0xf0000000: effective rate of sampling clock +// 0x0f000000: detected rate of ADAT-B on 2nd optical interface +// 0x00f00000: detected rate of ADAT-A on 1st optical interface +// 0x000f0000: detected rate of AES/EBU on XLR or coaxial interface +// 0x0000f000: detected rate of word clock on BNC interface +// 0x00000e00: effective source of sampling clock +// 0x00000e00: internal +// 0x00000800: ADAT-B +// 0x00000600: ADAT-A +// 0x00000400: AES/EBU +// 0x00000200: Word clock +// 0x00000080: Synchronized to ADAT-B on 2nd optical interface +// 0x00000040: Synchronized to ADAT-A on 1st optical interface +// 0x00000020: Synchronized to AES/EBU on XLR or 2nd optical interface +// 0x00000010: Synchronized to word clock on BNC interface +// 0x00000008: Lock ADAT-B on 2nd optical interface +// 0x00000004: Lock ADAT-A on 1st optical interface +// 0x00000002: Lock AES/EBU on XLR or 2nd optical interface +// 0x00000001: Lock word clock on BNC interface +// +// The pattern for rate bits: +// 0x00: 32.0 kHz +// 0x01: 44.1 kHz +// 0x02: 48.0 kHz +// 0x04: 64.0 kHz +// 0x05: 88.2 kHz +// 0x06: 96.0 kHz +// 0x08: 128.0 kHz +// 0x09: 176.4 kHz +// 0x0a: 192.0 kHz static int parse_clock_bits (u32 data,unsigned int *rate,enum snd_ff_clock_src *src,enum snd_ff_unit_version unit_version)
@@ -23,35 +78,48 @@ static int parse_clock_bits(u32 data, ununsigned int rate;u32 flag; } *rate_entry, rate_entries[] = { - { 32000, 0x00000000, }, - { 44100, 0x01000000, }, - { 48000, 0x02000000, }, - { 64000, 0x04000000, }, - { 88200, 0x05000000, }, - { 96000, 0x06000000, }, - { 128000, 0x08000000, }, - { 176400, 0x09000000, }, - { 192000, 0x0a000000, }, + { 32000, 0x00, }, + { 44100, 0x01, }, + { 48000, 0x02, }, + { 64000, 0x04, }, + { 88200, 0x05, }, + { 96000, 0x06, }, + { 128000, 0x08, }, + { 176400, 0x09, }, + { 192000, 0x0a, }, };static const struct {enum snd_ff_clock_src src;u32 flag; - } *clk_entry, clk_entries[] = { + } *clk_entry, *clk_entries, ucx_clk_entries[] = { {SND_FF_CLOCK_SRC_SPDIF ,0x00000200 , }, {SND_FF_CLOCK_SRC_ADAT1 ,0x00000400 , }, {SND_FF_CLOCK_SRC_WORD ,0x00000600 , }, {SND_FF_CLOCK_SRC_INTERNAL ,0x00000e00 , }, + }, ufx_ff802_clk_entries[] = { + {SND_FF_CLOCK_SRC_WORD ,0x00000200 , }, + {SND_FF_CLOCK_SRC_SPDIF ,0x00000400 , }, + {SND_FF_CLOCK_SRC_ADAT1 ,0x00000600 , }, + {SND_FF_CLOCK_SRC_ADAT2 ,0x00000800 , }, + {SND_FF_CLOCK_SRC_INTERNAL ,0x00000e00 , }, }; +u32 rate_bits; +unsigned int clk_entry_count;int i; -if (unit_version !=SND_FF_UNIT_VERSION_UCX ) { -// e.g. 0x00fe0f20 but expected 0x00eff002. - data = ((data &0xf0f0f0f0 ) >>4 ) | ((data &0x0f0f0f0f ) <<4 ); +if (unit_version ==SND_FF_UNIT_VERSION_UCX ) { + rate_bits = (data &0x0f000000 ) >>24 ; + clk_entries = ucx_clk_entries; + clk_entry_count =ARRAY_SIZE (ucx_clk_entries); + }else { + rate_bits = (data &0xf0000000 ) >>28 ; + clk_entries = ufx_ff802_clk_entries; + clk_entry_count =ARRAY_SIZE (ufx_ff802_clk_entries); }for (i =0 ; i <ARRAY_SIZE (rate_entries); ++i) { rate_entry = rate_entries + i; -if ((data &0x0f000000 ) == rate_entry->flag) { +if (rate_bits == rate_entry->flag) { *rate = rate_entry->rate;break ; }
@@ -59,14 +127,14 @@ static int parse_clock_bits(u32 data, unif (i ==ARRAY_SIZE (rate_entries))return -EIO ; -for (i =0 ; i <ARRAY_SIZE (clk_entries); ++i) { +for (i =0 ; i < clk_entry_count; ++i) { clk_entry = clk_entries + i;if ((data &0x000e00 ) == clk_entry->flag) { *src = clk_entry->src;break ; } } -if (i ==ARRAY_SIZE (clk_entries)) +if (i == clk_entry_count)return -EIO ;return 0 ;
@@ -249,16 +317,22 @@ static void latter_dump_status(struct snchar *const label;u32 locked_mask;u32 synced_mask; - } *clk_entry, clk_entries[] = { + } *clk_entry, *clk_entries, ucx_clk_entries[] = { { "S/PDIF", 0x00000001, 0x00000010, }, { "ADAT", 0x00000002, 0x00000020, }, { "WDClk", 0x00000004, 0x00000040, }, + }, ufx_ff802_clk_entries[] = { + { "WDClk", 0x00000001, 0x00000010, }, + { "AES/EBU", 0x00000002, 0x00000020, }, + { "ADAT-A", 0x00000004, 0x00000040, }, + { "ADAT-B", 0x00000008, 0x00000080, }, };__le32 reg;u32 data;unsigned int rate;enum snd_ff_clock_src src;const char *label; +unsigned int clk_entry_count;int i;int err;
@@ -270,7 +344,15 @@ static void latter_dump_status(struct snsnd_iprintf (buffer,"External source detection:\n" ); -for (i =0 ; i <ARRAY_SIZE (clk_entries); ++i) { +if (ff->unit_version ==SND_FF_UNIT_VERSION_UCX ) { + clk_entries = ucx_clk_entries; + clk_entry_count =ARRAY_SIZE (ucx_clk_entries); + }else { + clk_entries = ufx_ff802_clk_entries; + clk_entry_count =ARRAY_SIZE (ufx_ff802_clk_entries); + } + +for (i =0 ; i < clk_entry_count; ++i) { clk_entry = clk_entries + i;snd_iprintf (buffer,"%s: " , clk_entry->label);if (data & clk_entry->locked_mask) {
Greg Kroah-Hartman
maintainerPATCH 599/775 ALSA: hda: Add another CometLake-H PCI ID
In reply to Greg Kroah-HartmanFrom: Kai Vehmanen <[email protected]>
commit 0d3070f5e6551d8a759619e85736e49a3bf40398 upstream.
Add one more HD Audio PCI ID for CometLake-H PCH.
--- sound/pci/hda/hda_intel.c | 2 ++ 1 file changed, 2 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2481,6 +2481,8 @@ static const struct pci_device_id azx_id/* CometLake-H */ { PCI_DEVICE(0x8086, 0x06C8), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, + { PCI_DEVICE(0x8086, 0xf1c8), + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, /* CometLake-S */ { PCI_DEVICE(0x8086, 0xa3f0), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
Greg Kroah-Hartman
maintainerPATCH 600/775 ALSA: hda/hdmi: Drop bogus check at closing a stream
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 056a3da5d07fc5d3ceacfa2cdf013c9d8df630bd upstream.
Some users reported the kernel WARNING with stack traces from hdmi_pcm_close(), and it's the line checking the per_cvt->assigned flag. This used to be a valid check in the past because the flag was turned on/off only at opening and closing a PCM stream. Meanwhile, since the introduction of the silent-stream mode, this flag may be turned on/off at the monitor connection/disconnection time, which isn't always associated with the PCM open/close. Hence this may lead to the inconsistent per_cvt->assigned flag at closing.
As the check itself became almost useless and confuses users as if it were a serious problem, just drop the check.
--- sound/pci/hda/patch_hdmi.c | 1 - 1 file changed, 1 deletion(-)
sound/pci/hda/patch_hdmi.c +0 -1
@@ -2130,7 +2130,6 @@ static int hdmi_pcm_close(struct hda_pcm goto unlock; } per_cvt =get_cvt (spec, cvt_idx); -snd_BUG_ON (!per_cvt->assigned); per_cvt->assigned =0 ; hinfo->nid =0 ;
Greg Kroah-Hartman
maintainerPATCH 601/775 ALSA: hda/realtek: modify EAPD in the ALC886
In reply to Greg Kroah-HartmanFrom: PeiSen Hou <[email protected]>
commit 4841b8e6318a7f0ae57c4e5ec09032ea057c97a8 upstream.
Modify 0x20 index 7 bit 5 to 1, make the 0x15 EAPD the same as 0x14.
--- sound/pci/hda/patch_realtek.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/pci/hda/patch_realtek.c +11 -0
@@ -1905,6 +1905,7 @@ enum {ALC889_FIXUP_FRONT_HP_NO_PRESENCE ,ALC889_FIXUP_VAIO_TT ,ALC888_FIXUP_EEE1601 , +ALC886_FIXUP_EAPD ,ALC882_FIXUP_EAPD ,ALC883_FIXUP_EAPD , ALC883_FIXUP_ACER_EAPD,
@@ -2238,6 +2239,15 @@ static const struct hda_fixup alc882_fix { } } }, + [ALC886_FIXUP_EAPD] = { + .type = HDA_FIXUP_VERBS, + .v.verbs = (const struct hda_verb[]) { + /* change to EAPD mode */ + { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, + { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 }, + { } + } + }, [ALC882_FIXUP_EAPD] = { .type = HDA_FIXUP_VERBS, .v.verbs = (const struct hda_verb[]) {
@@ -2510,6 +2520,7 @@ static const struct snd_pci_quirk alc882SND_PCI_QUIRK (0x106b ,0x4a00 ,"Macbook 5,2" ,ALC889_FIXUP_MBA11_VREF ),SND_PCI_QUIRK (0x1071 ,0x8258 ,"Evesham Voyaeger" ,ALC882_FIXUP_EAPD ), +SND_PCI_QUIRK (0x13fe ,0x1009 ,"Advantech MIT-W101" ,ALC886_FIXUP_EAPD ),SND_PCI_QUIRK (0x1458 ,0xa002 ,"Gigabyte EP45-DS3/Z87X-UD3H" ,ALC889_FIXUP_FRONT_HP_NO_PRESENCE ),SND_PCI_QUIRK (0x1458 ,0xa0b8 ,"Gigabyte AZ370-Gaming" ,ALC1220_FIXUP_GB_DUAL_CODECS ), SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950),
Greg Kroah-Hartman
maintainerPATCH 602/775 ALSA: hda/realtek: Quirk for HP Spectre x360 14 amp setup
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit c3bb2b521944ffbbc8c24b849f81977a9915fb5e upstream.
HP Spectre x360 14 model (PCI SSID 103c:87f7) seems requiring a unique setup for its external amp: the GPIO0 needs to be toggled on and off shortly at each device initialization via runtime PM.
This patch implements that workaround as well as the model option string, so that users with other devices may try the same workaround more easily.
--- sound/pci/hda/patch_realtek.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
sound/pci/hda/patch_realtek.c +29 -0
@@ -4291,6 +4291,28 @@ static void alc280_fixup_hp_gpio4(struct } } +/* HP Spectre x360 14 model needs a unique workaround for enabling the amp; +* it needs to toggle the GPIO0 once on and off at each time (bko#210633) +*/ +static void alc245_fixup_hp_x360_amp (struct hda_codec *codec, +const struct hda_fixup *fix,int action) +{ +struct alc_spec *spec = codec->spec; + +switch (action) { +case HDA_FIXUP_ACT_PRE_PROBE : + spec->gpio_mask |=0x01 ; + spec->gpio_dir |=0x01 ; +break ; +case HDA_FIXUP_ACT_INIT : +/* need to toggle GPIO to enable the amp */ +alc_update_gpio_data (codec,0x01 , true); +msleep (100 ); +alc_update_gpio_data (codec,0x01 , false); +break ; + } +} +static void alc_update_coef_led (struct hda_codec *codec,struct alc_coef_led *led,bool polarity,bool on)
@@ -6277,6 +6299,7 @@ enum {ALC280_FIXUP_HP_DOCK_PINS ,ALC269_FIXUP_HP_DOCK_GPIO_MIC1_LED ,ALC280_FIXUP_HP_9480M , +ALC245_FIXUP_HP_X360_AMP ,ALC288_FIXUP_DELL_HEADSET_MODE ,ALC288_FIXUP_DELL1_MIC_NO_PRESENCE , ALC288_FIXUP_DELL_XPS_13,
@@ -6982,6 +7005,10 @@ static const struct hda_fixup alc269_fix .type = HDA_FIXUP_FUNC, .v.func = alc280_fixup_hp_9480m, }, + [ALC245_FIXUP_HP_X360_AMP] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc245_fixup_hp_x360_amp, + }, [ALC288_FIXUP_DELL_HEADSET_MODE] = { .type = HDA_FIXUP_FUNC, .v.func = alc_fixup_headset_mode_dell_alc288,
@@ -7996,6 +8023,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x87c8 ,"HP" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x87f4 ,"HP" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x87f5 ,"HP" ,ALC287_FIXUP_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x87f7 ,"HP Spectre x360 14" ,ALC245_FIXUP_HP_X360_AMP ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -8368,6 +8396,7 @@ static const struct hda_model_fixup alc2 {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"}, {.id = ALC255_FIXUP_XIAOMI_HEADSET_MIC, .name = "alc255-xiaomi-headset"}, {.id = ALC274_FIXUP_HP_MIC, .name = "alc274-hp-mic-detect"}, + {.id = ALC245_FIXUP_HP_X360_AMP, .name = "alc245-hp-x360-amp"}, {} };#define ALC225_STANDARD_PINS \
Greg Kroah-Hartman
maintainerPATCH 603/775 MIPS: Ingenic: Disable HPTLB for D0 XBurst CPUs too
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit a5360958a3cd1d876aae1f504ae014658513e1af upstream.
The JZ4760 has the HPTLB as well, but has a XBurst CPU with a D0 CPUID.
Disable the HPTLB for all XBurst CPUs with a D0 CPUID. In the case where there is no HPTLB (e.g. for older SoCs), this won't have any side effect.
--- arch/mips/kernel/cpu-probe.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
arch/mips/kernel/cpu-probe.c +8 -7
@@ -1830,16 +1830,17 @@ static inline void cpu_probe_ingenic(str*/ case PRID_COMP_INGENIC_D0 : c->isa_level &= ~MIPS_CPU_ISA_M32R2 ; -break ; + fallthrough;/* * The config0 register in the XBurst CPUs with a processor ID of -* PRID_COMP_INGENIC_D1 has an abandoned huge page tlb mode, this -* mode is not compatible with the MIPS standard, it will cause -* tlbmiss and into an infinite loop (line 21 in the tlb-funcs.S) -* when starting the init process. After chip reset, the default -* is HPTLB mode, Write 0xa9000000 to cp0 register 5 sel 4 to -* switch back to VTLB mode to prevent getting stuck. +* PRID_COMP_INGENIC_D0 or PRID_COMP_INGENIC_D1 has an abandoned +* huge page tlb mode, this mode is not compatible with the MIPS +* standard, it will cause tlbmiss and into an infinite loop +* (line 21 in the tlb-funcs.S) when starting the init process. +* After chip reset, the default is HPTLB mode, Write 0xa9000000 +* to cp0 register 5 sel 4 to switch back to VTLB mode to prevent +* getting stuck. */ case PRID_COMP_INGENIC_D1 :write_c0_page_ctrl (XBURST_PAGECTRL_HPTLB_DIS );
Greg Kroah-Hartman
maintainerPATCH 604/775 MIPS: Support binutils configured with --enable-mips-fix-loongson3-llsc=yes
In reply to Greg Kroah-HartmanFrom: Aurelien Jarno <[email protected]>
commit 5373ae67c3aad1ab306cc722b5a80b831eb4d4d1 upstream.
Quoted 1 line
From version 2.35, binutils can be configured with
--enable-mips-fix-loongson3-llsc=yes, which means it defaults to -mfix-loongson3-llsc. This breaks labels which might then point at the wrong instruction.
The workaround to explicitly pass -mno-fix-loongson3-llsc has been added in Linux version 5.1, but is only enabled when building a Loongson 64 kernel. As vendors might use a common toolchain for building Loongson and non-Loongson kernels, just move that workaround to arch/mips/Makefile. At the same time update the comments to reflect the current status.
--- arch/mips/Makefile | 19 +++++++++++++++++++ arch/mips/loongson64/Platform | 22 ---------------------- 2 files changed, 19 insertions(+), 22 deletions(-)
arch/mips/Makefile +19 -0
@@ -136,6 +136,25 @@ cflags-$(CONFIG_SB1XXX_CORELIS) += $(cal # cflags-y += -fno-stack-check +# binutils from v2.35 when built with --enable-mips-fix-loongson3-llsc=yes, +# supports an -mfix-loongson3-llsc flag which emits a sync prior to each ll +# instruction to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h +# for a description). +# +# We disable this in order to prevent the assembler meddling with the +# instruction that labels refer to, ie. if we label an ll instruction: +# +# 1: ll v0, 0(a0) +# +# ...then with the assembler fix applied the label may actually point at a sync +# instruction inserted by the assembler, and if we were using the label in an +# exception table the table would no longer contain the address of the ll +# instruction. +# +# Avoid this by explicitly disabling that assembler behaviour. +# +cflags-y += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) + # # CPU-dependent compiler/assembler options for optimization. #
arch/mips/loongson64/Platform +0 -22
@@ -6,28 +6,6 @@ cflags-$(CONFIG_CPU_LOONGSON64) += -Wa,--trap # -# Some versions of binutils, not currently mainline as of 2019/02/04, support -# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction -# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a -# description). -# -# We disable this in order to prevent the assembler meddling with the -# instruction that labels refer to, ie. if we label an ll instruction: -# -# 1: ll v0, 0(a0) -# -# ...then with the assembler fix applied the label may actually point at a sync -# instruction inserted by the assembler, and if we were using the label in an -# exception table the table would no longer contain the address of the ll -# instruction. -# -# Avoid this by explicitly disabling that assembler behaviour. If upstream -# binutils does not merge support for the flag then we can revisit & remove -# this later - for now it ensures vendor toolchains don't cause problems. -# -cflags-$(CONFIG_CPU_LOONGSON64) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) - -# # binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a # as MIPS64 R2; older versions as just R1. This leaves the possibility open # that GCC might generate R2 code for -march=loongson3a which then is rejected
Greg Kroah-Hartman
maintainerPATCH 605/775 MIPS: VDSO: Use CLANG_FLAGS instead of filtering out --target=
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 76d7fff22be3e4185ee5f9da2eecbd8188e76b2c upstream.
Commit ee67855ecd9d ("MIPS: vdso: Allow clang's --target flag in VDSO cflags") allowed the '--target=' flag from the main Makefile to filter through to the vDSO. However, it did not bring any of the other clang specific flags for controlling the integrated assembler and the GNU tools locations (--prefix=, --gcc-toolchain=, and -no-integrated-as). Without these, we will get a warning (visible with tinyconfig):
arch/mips/vdso/elf.S:14:1: warning: DWARF2 only supports one section per compilation unit
.pushsection .note.Linux, "a",@note ; .balign 4 ; .long 2f - 1f ; .long 4484f - 3f ; .long 0 ; 1:.asciz "Linux" ; 2:.balign 4 ; 3:
^arch/mips/vdso/elf.S:34:2: warning: DWARF2 only supports one section per compilation unit
.section .mips_abiflags, "a"
^
All of these flags are bundled up under CLANG_FLAGS in the main Makefile and exported so that they can be added to Makefiles that set their own CFLAGS. Use this value instead of filtering out '--target=' so there is no warning and all of the tools are properly used.
--- arch/mips/vdso/Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
arch/mips/vdso/Makefile +1 -4
@@ -16,16 +16,13 @@ ccflags-vdso := \ $(filter -march=%,$(KBUILD_CFLAGS)) \ $(filter -m%-float,$(KBUILD_CFLAGS)) \ $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ + $(CLANG_FLAGS) \ -D__VDSO__ ifndef CONFIG_64BIT ccflags-vdso += -DBUILD_VDSO32 endif -ifdef CONFIG_CC_IS_CLANG -ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS)) -endif - # # The -fno-jump-tables flag only prevents the compiler from generating # jump tables but does not prevent the compiler from emitting absolute
Greg Kroah-Hartman
maintainerPATCH 606/775 Revert "MIPS: Octeon: Remove special handling of CONFIG_MIPS_ELF_APPENDED_DTB=y"
In reply to Greg Kroah-HartmanFrom: Kevin Hao <[email protected]>
commit fe82de91af83a9212b6c704b1ce6cf6d129a108b upstream.
This reverts commit d9df9fb901d25b941ab2cfb5b570d91fb2abf7a3.
For the OCTEON boards, it need to patch the built-in DTB before using it. Previously it judges if it is a built-in DTB by checking fw_passed_dtb. But after commit 37e5c69ffd41 ("MIPS: head.S: Init fw_passed_dtb to builtin DTB", the fw_passed_dtb is initialized even when using built-in DTB. This causes the OCTEON boards boot broken due to an unpatched built-in DTB is used. Revert the commit d9df9fb901d2 to restore the codes before the fw_passed_dtb is used and then fix this issue.
Fixed: 37e5c69ffd41 ("MIPS: head.S: Init fw_passed_dtb to builtin DTB")
--- arch/mips/cavium-octeon/setup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/mips/cavium-octeon/setup.c +6 -3
@@ -1149,12 +1149,15 @@ void __init device_tree_init(void)bool do_prune;bool fill_mac; -if (fw_passed_dtb) { - fdt = (void *)fw_passed_dtb; +#ifdef CONFIG_MIPS_ELF_APPENDED_DTB +if (!fdt_check_header (&__appended_dtb)) { + fdt = &__appended_dtb; do_prune = false; fill_mac = true;pr_info ("Using appended Device Tree.\n" ); - }else if (octeon_bootinfo->minor_version >=3 && octeon_bootinfo->fdt_addr) { + } else +#endif +if (octeon_bootinfo->minor_version >=3 && octeon_bootinfo->fdt_addr) { fdt =phys_to_virt (octeon_bootinfo->fdt_addr);if (fdt_check_header (fdt))panic ("Corrupt Device Tree passed to kernel." );
Greg Kroah-Hartman
maintainerPATCH 607/775 MIPS: compressed: fix build with enabled UBSAN
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
commit fc4cac4cfc437659ce445c3c47b807e1cc625b66 upstream.
Commit 1e35918ad9d1 ("MIPS: Enable Undefined Behavior Sanitizer UBSAN") added a possibility to build the entire kernel with UBSAN instrumentation for MIPS, with the exception for VDSO. However, self-extracting head wasn't been added to exceptions, so this occurs:
mips-alpine-linux-musl-ld: arch/mips/boot/compressed/decompress.o:
in function `FSE_buildDTable_wksp':
decompress.c:(.text.FSE_buildDTable_wksp+0x278): undefined reference to `__ubsan_handle_shift_out_of_bounds'
mips-alpine-linux-musl-ld: decompress.c:(.text.FSE_buildDTable_wksp+0x2a8):
undefined reference to `__ubsan_handle_shift_out_of_bounds'
mips-alpine-linux-musl-ld: decompress.c:(.text.FSE_buildDTable_wksp+0x2c4):
undefined reference to `__ubsan_handle_shift_out_of_bounds'
mips-alpine-linux-musl-ld: arch/mips/boot/compressed/decompress.o:
decompress.c:(.text.FSE_buildDTable_raw+0x9c): more undefined references to `__ubsan_handle_shift_out_of_bounds' follow
Add UBSAN_SANITIZE := n to mips/boot/compressed/Makefile to exclude it from instrumentation scope and fix this issue.
--- arch/mips/boot/compressed/Makefile | 1 + 1 file changed, 1 insertion(+)
arch/mips/boot/compressed/Makefile +1 -0
@@ -37,6 +37,7 @@ KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__AS # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n GCOV_PROFILE := n +UBSAN_SANITIZE := n # decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
Greg Kroah-Hartman
maintainerPATCH 608/775 Revert "bcache: Kill btree_io_wq"
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit 9f233ffe02e5cef611100cd8c5bcf4de26ca7bef upstream.
This reverts commit 56b30770b27d54d68ad51eccc6d888282b568cee.
With the btree using the system_wq, I seem to see a lot more desktop latency than I should.
After some more investigation, it looks like the original assumption of 56b3077 no longer is true, and bcache has a very high potential of congesting the system_wq. In turn, this introduces laggy desktop performance, IO stalls (at least with btrfs), and input events may be delayed.
So let's revert this. It's important to note that the semantics of using system_wq previously mean that btree_io_wq should be created before and destroyed after other bcache wqs to keep the same assumptions.
--- drivers/md/bcache/bcache.h | 2 ++ drivers/md/bcache/btree.c | 21 +++++++++++++++++++-- drivers/md/bcache/super.c | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-)
drivers/md/bcache/bcache.h +2 -0
@@ -1042,5 +1042,7 @@ void bch_debug_exit(void);void bch_debug_init (void );void bch_request_exit (void );int bch_request_init (void ); +void bch_btree_exit (void ); +int bch_btree_init (void );#endif /* _BCACHE_H */
drivers/md/bcache/btree.c +19 -2
@@ -99,6 +99,8 @@#define PTR_HASH (c, k) \ (((k)->ptr[0] >> c->bucket_bits) | PTR_GEN(k, 0)) +static struct workqueue_struct *btree_io_wq; +#define insert_lock (s, b) ((b)->level <= (s)->lock)
@@ -308,7 +310,7 @@ static void __btree_node_write_done(strubtree_complete_write (b, w);if (btree_node_dirty (b)) -schedule_delayed_work (&b->work,30 *HZ ); +queue_delayed_work (btree_io_wq, &b->work,30 *HZ );closure_return_with_destructor (cl, btree_node_write_unlock); }
@@ -481,7 +483,7 @@ static void bch_btree_leaf_dirty(structBUG_ON (!i->keys);if (!btree_node_dirty (b)) -schedule_delayed_work (&b->work,30 *HZ ); +queue_delayed_work (btree_io_wq, &b->work,30 *HZ );set_btree_node_dirty (b);
@@ -2764,3 +2766,18 @@ void bch_keybuf_init(struct keybuf *buf)spin_lock_init (&buf->lock);array_allocator_init (&buf->freelist); } + +void bch_btree_exit (void ) +{ +if (btree_io_wq) +destroy_workqueue (btree_io_wq); +} + +int __init bch_btree_init (void ) +{ + btree_io_wq =create_singlethread_workqueue ("bch_btree_io" ); +if (!btree_io_wq) +return -ENOMEM ; + +return 0 ; +}
drivers/md/bcache/super.c +4 -0
@@ -2821,6 +2821,7 @@ static void bcache_exit(void)destroy_workqueue (bcache_wq);if (bch_journal_wq)destroy_workqueue (bch_journal_wq); +bch_btree_exit ();if (bcache_major)unregister_blkdev (bcache_major,"bcache" );
@@ -2876,6 +2877,9 @@ static int __init bcache_init(void)return bcache_major; } +if (bch_btree_init ()) + goto err; + bcache_wq =alloc_workqueue ("bcache" ,WQ_MEM_RECLAIM ,0 );if (!bcache_wq) goto err;
Greg Kroah-Hartman
maintainerPATCH 609/775 bcache: Give btree_io_wq correct semantics again
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit d797bd9897e3559eb48d68368550d637d32e468c upstream.
Before killing btree_io_wq, the queue was allocated using create_singlethread_workqueue() which has WQ_MEM_RECLAIM. After killing it, it no longer had this property but system_wq is not single threaded.
Let's combine both worlds and make it multi threaded but able to reclaim memory.
--- drivers/md/bcache/btree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/btree.c +1 -1
@@ -2775,7 +2775,7 @@ void bch_btree_exit(void)int __init bch_btree_init (void ) { - btree_io_wq =create_singlethread_workqueue ("bch_btree_io" ); + btree_io_wq =alloc_workqueue ("bch_btree_io" ,WQ_MEM_RECLAIM ,0 );if (!btree_io_wq)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 610/775 bcache: Move journal work to new flush wq
In reply to Greg Kroah-HartmanFrom: Kai Krakow <[email protected]>
commit afe78ab46f638ecdf80a35b122ffc92c20d9ae5d upstream.
This is potentially long running and not latency sensitive, let's get it out of the way of other latency sensitive events.
As observed in the previous commit, the system_wq comes easily congested by bcache, and this fixes a few more stalls I was observing every once in a while.
Let's not make this WQ_MEM_RECLAIM as it showed to reduce performance of boot and file system operations in my tests. Also, without WQ_MEM_RECLAIM, I no longer see desktop stalls. This matches the previous behavior as system_wq also does no memory reclaim:
Quoted 2 lines
//
workqueue.c:system_wq=alloc_workqueue("events", 0, 0);
--- drivers/md/bcache/bcache.h | 1 + drivers/md/bcache/journal.c | 4 ++-- drivers/md/bcache/super.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-)
drivers/md/bcache/bcache.h +1 -0
@@ -1001,6 +1001,7 @@ void bch_write_bdev_super(struct cached_extern struct workqueue_struct *bcache_wq;extern struct workqueue_struct *bch_journal_wq; +extern struct workqueue_struct *bch_flush_wq;extern struct mutex bch_register_lock;extern struct list_head bch_cache_sets;
drivers/md/bcache/journal.c +2 -2
@@ -932,8 +932,8 @@ atomic_t *bch_journal(struct cache_set *journal_try_write (c); }else if (!w->dirty) { w->dirty = true; -schedule_delayed_work (&c->journal.work, -msecs_to_jiffies (c->journal_delay_ms)); +queue_delayed_work (bch_flush_wq, &c->journal.work, +msecs_to_jiffies (c->journal_delay_ms));spin_unlock (&c->journal.lock); }else {spin_unlock (&c->journal.lock);
drivers/md/bcache/super.c +16 -0
@@ -49,6 +49,7 @@ static int bcache_major;static DEFINE_IDA (bcache_device_idx);static wait_queue_head_t unregister_wait;struct workqueue_struct *bcache_wq; +struct workqueue_struct *bch_flush_wq;struct workqueue_struct *bch_journal_wq;
@@ -2821,6 +2822,8 @@ static void bcache_exit(void)destroy_workqueue (bcache_wq);if (bch_journal_wq)destroy_workqueue (bch_journal_wq); +if (bch_flush_wq) +destroy_workqueue (bch_flush_wq);bch_btree_exit ();if (bcache_major)
@@ -2884,6 +2887,19 @@ static int __init bcache_init(void)if (!bcache_wq) goto err; +/* +* Let's not make this `WQ_MEM_RECLAIM` for the following reasons: +* +* 1. It used `system_wq` before which also does no memory reclaim. +* 2. With `WQ_MEM_RECLAIM` desktop stalls, increased boot times, and +* reduced throughput can be observed. +* +* We still want to user our own queue to not congest the `system_wq`. +*/ + bch_flush_wq =alloc_workqueue ("bch_flush" ,0 ,0 ); +if (!bch_flush_wq) + goto err; + bch_journal_wq =alloc_workqueue ("bch_journal" ,WQ_MEM_RECLAIM ,0 );if (!bch_journal_wq) goto err;
Greg Kroah-Hartman
maintainerPATCH 611/775 Revert "drm/amd/display: Update NV1x SR latency values"
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 910f1601addae3e430fc7d3cd589d7622c5df693 upstream.
This reverts commit 4a3dea8932d3b1199680d2056dd91d31d94d70b7.
This causes blank screens for some users.
--- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +2 -2
@@ -408,8 +408,8 @@ static struct _vcs_dpi_soc_bounding_box_ }, }, .num_states = 5, - .sr_exit_time_us = 11.6, - .sr_enter_plus_exit_time_us = 13.9, + .sr_exit_time_us = 8.6, + .sr_enter_plus_exit_time_us = 10.9, .urgent_latency_us = 4.0, .urgent_latency_pixel_data_only_us = 4.0, .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
Greg Kroah-Hartman
maintainerPATCH 612/775 drm/amd/display: Add FPU wrappers to dcn21_validate_bandwidth()
In reply to Greg Kroah-HartmanFrom: Jan Kokemüller <[email protected]>
commit 41401ac67791810dd880345962339aa1bedd3c0d upstream.
dcn21_validate_bandwidth() calls functions that use floating point math. On my machine this sometimes results in simd exceptions when there are other FPU users such as KVM virtual machines running. The screen freezes completely in this case.
Wrapping the function with DC_FP_START()/DC_FP_END() seems to solve the problem. This mirrors the approach used for dcn20_validate_bandwidth.
Tested on a AMD Ryzen 7 PRO 4750U (Renoir).
--- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 2 - drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 20 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +1 -1
@@ -3245,7 +3245,7 @@ restore_dml_state:bool dcn20_validate_bandwidth (struct dc *dc,struct dc_state *context,bool fast_validate) { -bool voltage_supported = false; +bool voltage_supported;DC_FP_START (); voltage_supported =dcn20_validate_bandwidth_fp (dc, context, fast_validate);DC_FP_END ();
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +18 -2
@@ -1329,8 +1329,8 @@ validate_out:return out; } -bool dcn21_validate_bandwidth (struct dc *dc,struct dc_state *context, -bool fast_validate) +static noinline bool dcn21_validate_bandwidth_fp(struct dc *dc, +struct dc_state *context,bool fast_validate) {bool out = false;
@@ -1383,6 +1383,22 @@ validate_out:return out; } + +/* +* Some of the functions further below use the FPU, so we need to wrap this +* with DC_FP_START()/DC_FP_END(). Use the same approach as for +* dcn20_validate_bandwidth in dcn20_resource.c. +*/ +bool dcn21_validate_bandwidth (struct dc *dc,struct dc_state *context, +bool fast_validate) +{ +bool voltage_supported; +DC_FP_START (); + voltage_supported =dcn21_validate_bandwidth_fp (dc, context, fast_validate); +DC_FP_END (); +return voltage_supported; +} +static void dcn21_destroy_resource_pool (struct resource_pool **pool) {struct dcn21_resource_pool *dcn21_pool =TO_DCN21_RES_POOL (*pool);
Greg Kroah-Hartman
maintainerPATCH 613/775 drm/amd/display: Remove Assert from dcn10_get_dig_frontend
In reply to Greg Kroah-HartmanFrom: Eric Bernstein <[email protected]>
commit 83e6667b675f101fb66659dfa72e45d08773d763 upstream.
[Why]
In some cases, this function is called when DIG BE is not connected to DIG FE, in which case a value of zero isn't invalid and assert should not be hit.
[How]
Remove assert and handle ENGINE_ID_UNKNOWN result in calling function.
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c | 1 - drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.c +0 -1
@@ -480,7 +480,6 @@ unsigned int dcn10_get_dig_frontend(strubreak ;default :// invalid source select DIG -ASSERT (false); result =ENGINE_ID_UNKNOWN ; }
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +2 -0
@@ -539,6 +539,8 @@ void dcn30_init_hw(struct dc *dc) fe = dc->links[i]->link_enc->funcs->get_dig_frontend ( dc->links[i]->link_enc); +if (fe ==ENGINE_ID_UNKNOWN ) +continue ;for (j =0 ; j < dc->res_pool->stream_enc_count; j++) {if (fe == dc->res_pool->stream_enc[j]->id) {
Greg Kroah-Hartman
maintainerPATCH 614/775 drm/amd/display: Add vupdate_no_lock interrupts for DCN2.1
In reply to Greg Kroah-HartmanFrom: Rodrigo Siqueira <[email protected]>
commit 688f97ed3f5e339c0c2c09d9ee7ff23d5807b0a7 upstream.
When run igt@kms_vrr in a device that uses DCN2.1 architecture, we noticed multiple failures. Furthermore, when we tested a VRR demo, we noticed a system hang where the mouse pointer still works, but the entire system freezes; in this case, we don't see any dmesg warning or failure messages kernel. This happens due to a lack of vupdate_no_lock interrupt, making the userspace wait eternally to get the event back. For fixing this issue, we need to add the vupdate_no_lock interrupt in the interrupt list.
--- drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c | 22 +++++++++++ 1 file changed, 22 insertions(+)
drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c +22 -0
@@ -168,6 +168,11 @@ static const struct irq_source_info_func .ack = NULL }; +static const struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = { + .set =NULL , + .ack =NULL +}; +#undef BASE_INNER#define BASE_INNER (seg) DMU_BASE__INST0_SEG ## seg
@@ -230,6 +235,17 @@ static const struct irq_source_info_func .funcs = &vblank_irq_info_funcs\ } +/* vupdate_no_lock_int_entry maps to DC_IRQ_SOURCE_VUPDATEx, to match semantic +* of DCE's DC_IRQ_SOURCE_VUPDATEx. +*/ +#define vupdate_no_lock_int_entry (reg_num)\ + [DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\ + IRQ_REG_ENTRY(OTG, reg_num,\ + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_INT_EN,\ + OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_EVENT_CLEAR),\ + .funcs = &vupdate_no_lock_irq_info_funcs\ + } +#define vblank_int_entry (reg_num)\ [DC_IRQ_SOURCE_VBLANK1 + reg_num] = {\ IRQ_REG_ENTRY(OTG, reg_num,\
@@ -338,6 +354,12 @@ irq_source_info_dcn21[DAL_IRQ_SOURCES_NUvupdate_int_entry (3 ),vupdate_int_entry (4 ),vupdate_int_entry (5 ), +vupdate_no_lock_int_entry (0 ), +vupdate_no_lock_int_entry (1 ), +vupdate_no_lock_int_entry (2 ), +vupdate_no_lock_int_entry (3 ), +vupdate_no_lock_int_entry (4 ), +vupdate_no_lock_int_entry (5 ),vblank_int_entry (0 ),vblank_int_entry (1 ), vblank_int_entry(2),
Greg Kroah-Hartman
maintainerPATCH 615/775 Revert "drm/amd/display: reuse current context instead of recreating one"
In reply to Greg Kroah-HartmanFrom: Anson Jacob <[email protected]>
commit efc8278eecfd5e6fa36c5d41e71d038f534fe107 upstream.
This reverts commit 8866a67ab86cc0812e65c04f1ef02bcc41e24d68.
Reason for revert: This breaks hotplug of HDMI on some systems, resulting in a blank screen. Caused general hangs on boot/hotplugs.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 23 ++++++++++-------- drivers/gpu/drm/amd/display/dc/core/dc.c | 27 ++++++---------------- drivers/gpu/drm/amd/display/dc/dc_stream.h | 3 +- 3 files changed, 23 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +13 -10
@@ -1934,7 +1934,7 @@ static void dm_gpureset_commit_state(strdc_commit_updates_for_stream ( dm->dc, bundle->surface_updates, dc_state->stream_status->plane_count, - dc_state->streams[k], &bundle->stream_update); + dc_state->streams[k], &bundle->stream_update, dc_state); } cleanup:
@@ -1965,7 +1965,8 @@ static void dm_set_dpms_off(struct dc_li stream_update.stream = stream_state;dc_commit_updates_for_stream (stream_state->ctx->dc,NULL ,0 , - stream_state, &stream_update); + stream_state, &stream_update, + stream_state->ctx->dc->current_state);mutex_unlock (&adev->dm.dc_lock); }
@@ -7548,7 +7549,7 @@ static void amdgpu_dm_commit_planes(strustruct drm_crtc *pcrtc, bool wait_for_vblank) { - int i; + uint32_t i;uint64_t timestamp_ns;struct drm_plane *plane;struct drm_plane_state *old_plane_state, *new_plane_state;
@@ -7589,7 +7590,7 @@ static void amdgpu_dm_commit_planes(struamdgpu_dm_commit_cursors (state);/* update planes when needed */ -for_each_oldnew_plane_in_state_reverse (state, plane, old_plane_state, new_plane_state, i) { +for_each_oldnew_plane_in_state (state, plane, old_plane_state, new_plane_state, i) {struct drm_crtc *crtc = new_plane_state->crtc;struct drm_crtc_state *new_crtc_state;struct drm_framebuffer *fb = new_plane_state->fb;
@@ -7812,7 +7813,8 @@ static void amdgpu_dm_commit_planes(stru bundle->surface_updates, planes_count, acrtc_state->stream, - &bundle->stream_update); + &bundle->stream_update, + dc_state);/** * Enable or disable the interrupts on the backend.
@@ -8148,13 +8150,13 @@ static void amdgpu_dm_atomic_commit_tailstruct dm_connector_state *dm_new_con_state =to_dm_connector_state (new_con_state);struct dm_connector_state *dm_old_con_state =to_dm_connector_state (old_con_state);struct amdgpu_crtc *acrtc =to_amdgpu_crtc (dm_new_con_state->base.crtc); -struct dc_surface_update surface_updates[MAX_SURFACES ]; +struct dc_surface_update dummy_updates[MAX_SURFACES ];struct dc_stream_update stream_update;struct dc_info_packet hdr_packet;struct dc_stream_status *status =NULL ;bool abm_changed, hdr_changed, scaling_changed; -memset (&surface_updates,0 ,sizeof (surface_updates)); +memset (&dummy_updates,0 ,sizeof (dummy_updates));memset (&stream_update,0 ,sizeof (stream_update));if (acrtc) {
@@ -8211,15 +8213,16 @@ static void amdgpu_dm_atomic_commit_tail* To fix this, DC should permit updating only stream properties. */ for (j =0 ; j < status->plane_count; j++) - surface_updates[j].surface = status->plane_states[j]; + dummy_updates[j].surface = status->plane_states[0 ];mutex_lock (&dm->dc_lock);dc_commit_updates_for_stream (dm->dc, - surface_updates, + dummy_updates, status->plane_count, dm_new_crtc_state->stream, - &stream_update); + &stream_update, + dc_state);mutex_unlock (&dm->dc_lock); }
drivers/gpu/drm/amd/display/dc/core/dc.c +8 -19
@@ -2679,7 +2679,8 @@ void dc_commit_updates_for_stream(structstruct dc_surface_update *srf_updates, int surface_count, struct dc_stream_state *stream, - struct dc_stream_update *stream_update) + struct dc_stream_update *stream_update, + struct dc_state *state) { const struct dc_stream_status *stream_status;enum surface_update_type update_type;
@@ -2698,12 +2699,6 @@ void dc_commit_updates_for_stream(structif (update_type >=UPDATE_TYPE_FULL ) { -struct dc_plane_state *new_planes[MAX_SURFACES ]; - -memset (new_planes,0 ,sizeof (new_planes)); - -for (i =0 ; i < surface_count; i++) - new_planes[i] = srf_updates[i].surface;/* initialize scratch memory for building context */ context =dc_create_state (dc);
@@ -2712,21 +2707,15 @@ void dc_commit_updates_for_stream(structreturn ; } -dc_resource_state_copy_construct ( - dc->current_state, context); +dc_resource_state_copy_construct (state, context); -/*remove old surfaces from context */ -if (!dc_rem_all_planes_for_stream (dc, stream, context)) { -DC_ERROR ("Failed to remove streams for new validate context!\n" ); -return ; - } +for (i =0 ; i < dc->res_pool->pipe_count; i++) { +struct pipe_ctx *new_pipe = &context->res_ctx.pipe_ctx[i]; +struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i]; -/* add surface to context */ -if (!dc_add_all_planes_for_stream (dc, stream, new_planes, surface_count, context)) { -DC_ERROR ("Failed to add streams for new validate context!\n" ); -return ; +if (new_pipe->plane_state && new_pipe->plane_state != old_pipe->plane_state) + new_pipe->plane_state->force_full_update = true; } - }
drivers/gpu/drm/amd/display/dc/dc_stream.h +2 -1
@@ -283,7 +283,8 @@ void dc_commit_updates_for_stream(structstruct dc_surface_update *srf_updates, int surface_count, struct dc_stream_state *stream, - struct dc_stream_update *stream_update); + struct dc_stream_update *stream_update, + struct dc_state *state);/* * Log the current stream state. */
Greg Kroah-Hartman
maintainerPATCH 616/775 drm/amdkfd: Fix recursive lock warnings
In reply to Greg Kroah-HartmanFrom: Felix Kuehling <[email protected]>
commit 1fb8b1fc4dd1035a264c81d15d41f05884cc8058 upstream.
memalloc_nofs_save/restore are no longer sufficient to prevent recursive lock warnings when holding locks that can be taken in MMU notifiers. Use memalloc_noreclaim_save/restore instead.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2 -2
@@ -243,11 +243,11 @@ get_sh_mem_bases_nybble_64(struct kfd_prstatic inline void dqm_lock (struct device_queue_manager *dqm) {mutex_lock (&dqm->lock_hidden); - dqm->saved_flags =memalloc_nofs_save (); + dqm->saved_flags =memalloc_noreclaim_save (); }static inline void dqm_unlock (struct device_queue_manager *dqm) { -memalloc_nofs_restore (dqm->saved_flags); +memalloc_noreclaim_restore (dqm->saved_flags);mutex_unlock (&dqm->lock_hidden); }
Greg Kroah-Hartman
maintainerPATCH 617/775 drm/amdgpu: fix CGTS_TCC_DISABLE register offset on gfx10.3
In reply to Greg Kroah-HartmanFrom: Marek Olšák <[email protected]>
commit 4112c00354004cbb1bf56f0114fa9951bf6b13ed upstream.
This fixes incorrect TCC harvesting info reported to userspace. The impact was a very very tiny performance degradation (unnecessary GL2 cache flushes).
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10 -12
@@ -71,6 +71,11 @@#define GB_ADDR_CONFIG__NUM_PKRS__SHIFT 0x8#define GB_ADDR_CONFIG__NUM_PKRS_MASK 0x00000700L +#define mmCGTS_TCC_DISABLE_gc_10_3 0x5006 +#define mmCGTS_TCC_DISABLE_gc_10_3_BASE_IDX 1 +#define mmCGTS_USER_TCC_DISABLE_gc_10_3 0x5007 +#define mmCGTS_USER_TCC_DISABLE_gc_10_3_BASE_IDX 1 +#define mmCP_MEC_CNTL_Sienna_Cichlid 0x0f55#define mmCP_MEC_CNTL_Sienna_Cichlid_BASE_IDX 0#define mmRLC_SAFE_MODE_Sienna_Cichlid 0x4ca0
@@ -99,10 +104,6 @@#define mmGCR_GENERAL_CNTL_Sienna_Cichlid 0x1580#define mmGCR_GENERAL_CNTL_Sienna_Cichlid_BASE_IDX 0 -#define mmCGTS_TCC_DISABLE_Vangogh 0x5006 -#define mmCGTS_TCC_DISABLE_Vangogh_BASE_IDX 1 -#define mmCGTS_USER_TCC_DISABLE_Vangogh 0x5007 -#define mmCGTS_USER_TCC_DISABLE_Vangogh_BASE_IDX 1#define mmGOLDEN_TSC_COUNT_UPPER_Vangogh 0x0025#define mmGOLDEN_TSC_COUNT_UPPER_Vangogh_BASE_IDX 1#define mmGOLDEN_TSC_COUNT_LOWER_Vangogh 0x0026
@@ -4942,15 +4943,12 @@ static void gfx_v10_0_get_tcc_info(struc/* TCCs are global (not instanced). */ uint32_t tcc_disable; -switch (adev->asic_type) { -case CHIP_VANGOGH : - tcc_disable =RREG32_SOC15 (GC ,0 , mmCGTS_TCC_DISABLE_Vangogh) | -RREG32_SOC15 (GC ,0 , mmCGTS_USER_TCC_DISABLE_Vangogh); -break ; -default : +if (adev->asic_type >=CHIP_SIENNA_CICHLID ) { + tcc_disable =RREG32_SOC15 (GC ,0 , mmCGTS_TCC_DISABLE_gc_10_3) | +RREG32_SOC15 (GC ,0 , mmCGTS_USER_TCC_DISABLE_gc_10_3); + }else { tcc_disable =RREG32_SOC15 (GC ,0 , mmCGTS_TCC_DISABLE) | -RREG32_SOC15 (GC ,0 , mmCGTS_USER_TCC_DISABLE); -break ; +RREG32_SOC15 (GC ,0 , mmCGTS_USER_TCC_DISABLE); } adev->gfx.config.tcc_disabled_mask =
Greg Kroah-Hartman
maintainerPATCH 618/775 drm/amdgpu: Set reference clock to 100Mhz on Renoir (v2)
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 6e80fb8ab04f6c4f377e2fd422bdd1855beb7371 upstream.
Fixes the rlc reference clock used for GPU timestamps. Value is 100Mhz. Confirmed with hardware team.
v2: reword commit message.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/soc15.c +2 -0
@@ -241,6 +241,8 @@ static u32 soc15_get_xclk(struct amdgpu_ {u32 reference_clock = adev->clock.spll.reference_freq; +if (adev->asic_type ==CHIP_RENOIR ) +return 10000 ;if (adev->asic_type ==CHIP_RAVEN )return reference_clock /4 ;
Greg Kroah-Hartman
maintainerPATCH 619/775 drm/amdgpu: fix shutdown and poweroff process failed with s0ix
In reply to Greg Kroah-HartmanFrom: Prike Liang <[email protected]>
commit b092b19602cfd47de1eeeb3a1b03822afd86b136 upstream.
In the shutdown and poweroff opt on the s0i3 system we still need un-gate the gfx clock gating and power gating before destory amdgpu device.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 9 ++++++++- 3 files changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
@@ -1003,6 +1003,12 @@ struct amdgpu_device {bool in_suspend;bool in_hibernate; +/* +* The combination flag in_poweroff_reboot_com used to identify the poweroff +* and reboot opt in the s0i3 system-wide suspend. +*/ +bool in_poweroff_reboot_com; +atomic_t in_gpu_reset;enum pp_mp1_state mp1_state;struct rw_semaphore reset_sem;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
@@ -2666,7 +2666,8 @@ static int amdgpu_device_ip_suspend_phas {int i, r; -if (!amdgpu_acpi_is_s0ix_supported (adev) ||amdgpu_in_reset (adev)) { +if (adev->in_poweroff_reboot_com || + !amdgpu_acpi_is_s0ix_supported (adev) ||amdgpu_in_reset (adev)) {amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE );amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE ); }
@@ -3726,7 +3727,8 @@ int amdgpu_device_suspend(struct drm_devamdgpu_fence_driver_suspend (adev); -if (!amdgpu_acpi_is_s0ix_supported (adev) ||amdgpu_in_reset (adev)) +if (adev->in_poweroff_reboot_com || + !amdgpu_acpi_is_s0ix_supported (adev) ||amdgpu_in_reset (adev)) r =amdgpu_device_ip_suspend_phase2 (adev);else amdgpu_gfx_state_change_set (adev, sGpuChangeState_D3Entry);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +8 -1
@@ -1266,7 +1266,9 @@ amdgpu_pci_shutdown(struct pci_dev *pdev*/ if (!amdgpu_passthrough (adev)) adev->mp1_state =PP_MP1_STATE_UNLOAD ; + adev->in_poweroff_reboot_com = true;amdgpu_device_ip_suspend (adev); + adev->in_poweroff_reboot_com = false; adev->mp1_state =PP_MP1_STATE_NONE ; }
@@ -1308,8 +1310,13 @@ static int amdgpu_pmops_thaw(struct devistatic int amdgpu_pmops_poweroff (struct device *dev) {struct drm_device *drm_dev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (drm_dev); +int r; -return amdgpu_device_suspend (drm_dev, true); + adev->in_poweroff_reboot_com = true; + r =amdgpu_device_suspend (drm_dev, true); + adev->in_poweroff_reboot_com = false; +return r; }static int amdgpu_pmops_restore (struct device *dev)
Greg Kroah-Hartman
maintainerPATCH 620/775 drm/ttm: Fix a memory leak
In reply to Greg Kroah-HartmanFrom: xinhui pan <[email protected]>
commit 7a8a4b0729a8807e37196e44629b31ee03f88872 upstream.
Free the memory on failure.
Also no need to re-alloc memory on retry.
--- drivers/gpu/drm/ttm/ttm_bo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +6 -3
@@ -967,8 +967,10 @@ static int ttm_bo_bounce_temp_buffer(strreturn ret;/* move to the bounce domain */ ret =ttm_bo_handle_move_mem (bo, &hop_mem, false, ctx,NULL ); -if (ret) +if (ret) { +ttm_resource_free (bo, &hop_mem);return ret; + }return 0 ; }
@@ -1000,18 +1002,19 @@ static int ttm_bo_move_buffer(struct ttm* stop and the driver will be called to make * the second hop. */ -bounce: ret =ttm_bo_mem_space (bo, placement, &mem, ctx);if (ret)return ret; +bounce: ret =ttm_bo_handle_move_mem (bo, &mem, false, ctx, &hop);if (ret == -EMULTIHOP ) { ret =ttm_bo_bounce_temp_buffer (bo, &mem, ctx, &hop);if (ret) -return ret; + goto out;/* try and move to final place now. */ goto bounce; } +out:if (ret)ttm_resource_free (bo, &mem);return ret;
Greg Kroah-Hartman
maintainerPATCH 621/775 drm/nouveau/kms: handle mDP connectors
In reply to Greg Kroah-HartmanFrom: Karol Herbst <[email protected]>
commit d1f5a3fc85566e9ddce9361ef180f070367e6eab upstream.
In some cases we have the handle those explicitly as the fallback connector type detection fails and marks those as eDP connectors.
Attempting to use such a connector with mutter leads to a crash of mutter as it ends up with two eDP displays.
Information is taken from the official DCB documentation.
--- drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h | 1 + drivers/gpu/drm/nouveau/nouveau_connector.c | 1 + 2 files changed, 2 insertions(+)
drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h +1 -0
@@ -14,6 +14,7 @@ enum dcb_connector_type {DCB_CONNECTOR_LVDS_SPWG =0x41 ,DCB_CONNECTOR_DP =0x46 , DCB_CONNECTOR_eDP =0x47 , + DCB_CONNECTOR_mDP =0x48 ,DCB_CONNECTOR_HDMI_0 =0x60 ,DCB_CONNECTOR_HDMI_1 =0x61 , DCB_CONNECTOR_HDMI_C = 0x63,
drivers/gpu/drm/nouveau/nouveau_connector.c +1 -0
@@ -1210,6 +1210,7 @@ drm_conntype_from_dcb(enum dcb_connectorcase DCB_CONNECTOR_DMS59_DP0 :case DCB_CONNECTOR_DMS59_DP1 :case DCB_CONNECTOR_DP : +case DCB_CONNECTOR_mDP :case DCB_CONNECTOR_USB_C :return DRM_MODE_CONNECTOR_DisplayPort;case DCB_CONNECTOR_eDP :return DRM_MODE_CONNECTOR_eDP;case DCB_CONNECTOR_HDMI_0 :
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Greg Kroah-Hartman
maintainerPATCH 622/775 drm/modes: Switch to 64bit maths to avoid integer overflow
In reply to Greg Kroah-HartmanFrom: Ville Syrjälä <[email protected]>
commit 5b34ab52401f0f1f191bcb83a182c83b506f4763 upstream.
The new >8k CEA modes have dotclocks reaching 5.94 GHz, which means our clock*1000 will now overflow the 32bit unsigned integer. Switch to 64bit maths to avoid it.
--- drivers/gpu/drm/drm_modes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_modes.c +2 -2
@@ -762,7 +762,7 @@ int drm_mode_vrefresh(const struct drm_dif (mode->htotal ==0 || mode->vtotal ==0 )return 0 ; - num = mode->clock *1000 ; + num = mode->clock; den = mode->htotal * mode->vtotal;if (mode->flags &DRM_MODE_FLAG_INTERLACE )
@@ -772,7 +772,7 @@ int drm_mode_vrefresh(const struct drm_dif (mode->vscan >1 ) den *= mode->vscan; -return DIV_ROUND_CLOSEST (num, den); +return DIV_ROUND_CLOSEST_ULL (mul_u32_u32 (num,1000 ), den); }EXPORT_SYMBOL (drm_mode_vrefresh);
Greg Kroah-Hartman
maintainerPATCH 623/775 drm/sched: Cancel and flush all outstanding jobs before finish.
In reply to Greg Kroah-HartmanFrom: Andrey Grodzovsky <[email protected]>
commit e582951baabba3e278c97169d0acc1e09b24a72e upstream.
To avoid any possible use after free.
--- drivers/gpu/drm/scheduler/sched_main.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +3 -0
@@ -891,6 +891,9 @@ void drm_sched_fini(struct drm_gpu_schedif (sched->thread)kthread_stop (sched->thread); +/* Confirm no work left behind accessing device structures */ +cancel_delayed_work_sync (&sched->work_tdr); + sched->ready = false; }EXPORT_SYMBOL (drm_sched_fini);
Greg Kroah-Hartman
maintainerPATCH 624/775 drm/panel: kd35t133: allow using non-continuous dsi clock
In reply to Greg Kroah-HartmanFrom: Heiko Stuebner <[email protected]>
commit d922d58fedcd98ba625e89b625a98e222b090b10 upstream.
The panel is able to work when dsi clock is non-continuous, thus the system power consumption can be reduced using such feature.
Add MIPI_DSI_CLOCK_NON_CONTINUOUS to panel's mode_flags.
Also the flag actually becomes necessary after
commit c6d94e37bdbb ("drm/bridge/synopsys: dsi: add support for non-continuous HS clock") and without it the panel only emits stripes instead of output.
--- drivers/gpu/drm/panel/panel-elida-kd35t133.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-elida-kd35t133.c +2 -1
@@ -265,7 +265,8 @@ static int kd35t133_probe(struct mipi_ds dsi->lanes =1 ; dsi->format =MIPI_DSI_FMT_RGB888 ; dsi->mode_flags =MIPI_DSI_MODE_VIDEO |MIPI_DSI_MODE_VIDEO_BURST | -MIPI_DSI_MODE_LPM |MIPI_DSI_MODE_EOT_PACKET ; +MIPI_DSI_MODE_LPM |MIPI_DSI_MODE_EOT_PACKET | +MIPI_DSI_CLOCK_NON_CONTINUOUS ;drm_panel_init (&ctx->panel, &dsi->dev, &kd35t133_funcs,DRM_MODE_CONNECTOR_DSI );
Greg Kroah-Hartman
maintainerPATCH 625/775 drm/rockchip: Require the YTR modifier for AFBC
In reply to Greg Kroah-HartmanFrom: Alyssa Rosenzweig <[email protected]>
commit 5f94e3571459abb626077aedb65d71264c2a58c0 upstream.
The AFBC decoder used in the Rockchip VOP assumes the use of the YUV-like colourspace transform (YTR). YTR is lossless for RGB(A) buffers, which covers the RGBA8 and RGB565 formats supported in vop_convert_afbc_format. Use of YTR is signaled with the AFBC_FORMAT_MOD_YTR modifier, which prior to this commit was missing. As such, a producer would have to generate buffers that do not use YTR, which the VOP would erroneously decode as YTR, leading to severe visual corruption.
The upstream AFBC support was developed against a captured frame, which failed to exercise modifier support. Prior to bring-up of AFBC in Mesa (in the Panfrost driver), no open userspace respected modifier reporting. As such, this change is not expected to affect broken userspaces.
Tested on RK3399 with Panfrost and Weston.
--- drivers/gpu/drm/rockchip/rockchip_drm_vop.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +11 -0
@@ -17,9 +17,20 @@#define NUM_YUV2YUV_COEFFICIENTS 12 +/* AFBC supports a number of configurable modes. Relevant to us is block size +* (16x16 or 32x8), storage modifiers (SPARSE, SPLIT), and the YUV-like +* colourspace transform (YTR). 16x16 SPARSE mode is always used. SPLIT mode +* could be enabled via the hreg_block_split register, but is not currently +* handled. The colourspace transform is implicitly always assumed by the +* decoder, so consumers must use this transform as well. +* +* Failure to match modifiers will cause errors displaying AFBC buffers +* produced by conformant AFBC producers, including Mesa. +*/ #define ROCKCHIP_AFBC_MOD \ DRM_FORMAT_MOD_ARM_AFBC( \ AFBC_FORMAT_MOD_BLOCK_SIZE_16x16 | AFBC_FORMAT_MOD_SPARSE \ + | AFBC_FORMAT_MOD_YTR \ )enum vop_data_format {
Greg Kroah-Hartman
maintainerPATCH 626/775 ASoC: siu: Fix build error by a wrong const prefix
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit ae07f5c7c5e9ebca5b9d6471bb4b99a9da5c6d88 upstream.
A const prefix was put wrongly in the middle at the code refactoring commit 932eaf7c7904 ("ASoC: sh: siu_pcm: remove snd_pcm_ops"), which leads to a build error as:
sound/soc/sh/siu_pcm.c:546:8: error: expected '{' before 'const'
Also, another inconsistency is that the declaration of siu_component misses the const prefix.
This patch corrects both failures.
--- sound/soc/sh/siu.h | 2 +- sound/soc/sh/siu_pcm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/sh/siu.h +1 -1
@@ -169,7 +169,7 @@ static inline u32 siu_read32(u32 __iomem#define SIU_BRGBSEL (0x108 / sizeof(u32))#define SIU_BRRB (0x10c / sizeof(u32)) -extern struct snd_soc_component_driver siu_component; +extern const struct snd_soc_component_driver siu_component;extern struct siu_info *siu_i2s_data;int siu_init_port (int port,struct siu_port **port_info,struct snd_card *card);
sound/soc/sh/siu_pcm.c +1 -1
@@ -543,7 +543,7 @@ static void siu_pcm_free(struct snd_soc_dev_dbg (pcm->card->dev,"%s\n" , __func__); } -struct const snd_soc_component_driver siu_component = { +const struct snd_soc_component_driver siu_component = { .name =DRV_NAME , .open = siu_pcm_open, .close = siu_pcm_close,
Greg Kroah-Hartman
maintainerPATCH 627/775 selinux: fix inconsistency between inode_getxattr and inode_listsecurity
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
commit a9ffe682c58aaff643764547f5420e978b6e0830 upstream.
When inode has no listxattr op of its own (e.g. squashfs) vfs_listxattr calls the LSM inode_listsecurity hooks to list the xattrs that LSMs will intercept in inode_getxattr hooks.
When selinux LSM is installed but not initialized, it will list the security.selinux xattr in inode_listsecurity, but will not intercept it in inode_getxattr. This results in -ENODATA for a getxattr call for an xattr returned by listxattr.
This situation was manifested as overlayfs failure to copy up lower files from squashfs when selinux is built-in but not initialized, because ovl_copy_xattr() iterates the lower inode xattrs by vfs_listxattr() and vfs_getxattr().
Match the logic of inode_listsecurity to that of inode_getxattr and do not list the security.selinux xattr if selinux is not initialized.
--- security/selinux/hooks.c | 4 ++++ 1 file changed, 4 insertions(+)
security/selinux/hooks.c +4 -0
@@ -3413,6 +3413,10 @@ static int selinux_inode_setsecurity(strstatic int selinux_inode_listsecurity (struct inode *inode,char *buffer,size_t buffer_size) {const int len =sizeof (XATTR_NAME_SELINUX ); + +if (!selinux_initialized (&selinux_state)) +return 0 ; +if (buffer && len <= buffer_size)memcpy (buffer,XATTR_NAME_SELINUX , len);return len;
Greg Kroah-Hartman
maintainerPATCH 628/775 erofs: initialized fields can only be observed after bit is set
In reply to Greg Kroah-HartmanFrom: Gao Xiang <[email protected]>
commit ce063129181312f8781a047a50be439c5859747b upstream.
Currently, although set_bit() & test_bit() pairs are used as a fast- path for initialized configurations. However, these atomic ops are actually relaxed forms. Instead, load-acquire & store-release form is needed to make sure uninitialized fields won't be observed in advance here (yet no such corresponding bitops so use full barriers instead.)
--- fs/erofs/xattr.c | 10 +++++++++- fs/erofs/zmap.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-)
fs/erofs/xattr.c +9 -1
@@ -48,8 +48,14 @@ static int init_inode_xattrs(struct inodint ret =0 ;/* the most case is that xattrs of this inode are initialized. */ -if (test_bit (EROFS_I_EA_INITED_BIT , &vi->flags)) +if (test_bit (EROFS_I_EA_INITED_BIT , &vi->flags)) { +/* +* paired with smp_mb() at the end of the function to ensure +* fields will only be observed after the bit is set. +*/ +smp_mb ();return 0 ; + }if (wait_on_bit_lock (&vi->flags,EROFS_I_BL_XATTR_BIT ,TASK_KILLABLE ))return -ERESTARTSYS ;
@@ -137,6 +143,8 @@ static int init_inode_xattrs(struct inod }xattr_iter_end (&it, atomic_map); +/* paired with smp_mb() at the beginning of the function. */ +smp_mb ();set_bit (EROFS_I_EA_INITED_BIT , &vi->flags); out_unlock:
fs/erofs/zmap.c +9 -1
@@ -36,8 +36,14 @@ static int z_erofs_fill_inode_lazy(strucvoid *kaddr;struct z_erofs_map_header *h; -if (test_bit (EROFS_I_Z_INITED_BIT , &vi->flags)) +if (test_bit (EROFS_I_Z_INITED_BIT , &vi->flags)) { +/* +* paired with smp_mb() at the end of the function to ensure +* fields will only be observed after the bit is set. +*/ +smp_mb ();return 0 ; + }if (wait_on_bit_lock (&vi->flags,EROFS_I_BL_Z_BIT ,TASK_KILLABLE ))return -ERESTARTSYS ;
@@ -83,6 +89,8 @@ static int z_erofs_fill_inode_lazy(struc vi->z_physical_clusterbits[1 ] = vi->z_logical_clusterbits + ((h->h_clusterbits >>5 ) &7 ); +/* paired with smp_mb() at the beginning of the function */ +smp_mb ();set_bit (EROFS_I_Z_INITED_BIT , &vi->flags); unmap_done:kunmap_atomic (kaddr);
Greg Kroah-Hartman
maintainerPATCH 629/775 tpm_tis: Fix check_locality for correct locality acquisition
In reply to Greg Kroah-HartmanFrom: James Bottomley <[email protected]>
commit 3d9ae54af1d02a7c0edc55c77d7df2b921e58a87 upstream.
The TPM TIS specification says the TPM signals the acquisition of locality when the TMP_ACCESS_REQUEST_USE bit goes to one *and* the TPM_ACCESS_REQUEST_USE bit goes to zero. Currently we only check the former not the latter, so check both. Adding the check on TPM_ACCESS_REQUEST_USE should fix the case where the locality is re-requested before the TPM has released it. In this case the locality may get released briefly before it is reacquired, which causes all sorts of problems. However, with the added check, TPM_ACCESS_REQUEST_USE should remain 1 until the second request for the locality is granted.
--- drivers/char/tpm/tpm_tis_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +2 -1
@@ -125,7 +125,8 @@ static bool check_locality(struct tpm_chif (rc <0 )return false; -if ((access & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) == +if ((access & (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID + |TPM_ACCESS_REQUEST_USE )) == (TPM_ACCESS_ACTIVE_LOCALITY |TPM_ACCESS_VALID )) { priv->locality = l;return true;
Greg Kroah-Hartman
maintainerPATCH 630/775 tpm_tis: Clean up locality release
In reply to Greg Kroah-HartmanFrom: James Bottomley <[email protected]>
commit e42acf104d6e0bd7ccd2f09103d5be5e6d3c637c upstream.
The current release locality code seems to be based on the misunderstanding that the TPM interrupts when a locality is released:
it doesn't, only when the locality is acquired.
Furthermore, there seems to be no point in waiting for the locality to be released. All it does is penalize the last TPM user. However, if there's no next TPM user, this is a pointless wait and if there is a next TPM user, they'll pay the penalty waiting for the new locality (or possibly not if it's the same as the old locality).
Fix the code by making release_locality as simple write to release with no waiting for completion.
--- drivers/char/tpm/tpm_tis_core.c | 47 ---------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -46
@@ -135,58 +135,13 @@ static bool check_locality(struct tpm_chreturn false; } -static bool locality_inactive (struct tpm_chip *chip,int l) -{ -struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev); -int rc; -u8 access; - - rc =tpm_tis_read8 (priv,TPM_ACCESS (l), &access); -if (rc <0 ) -return false; - -if ((access & (TPM_ACCESS_VALID |TPM_ACCESS_ACTIVE_LOCALITY )) - ==TPM_ACCESS_VALID ) -return true; - -return false; -} -static int release_locality (struct tpm_chip *chip,int l) {struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev); -unsigned long stop, timeout; -long rc;tpm_tis_write8 (priv,TPM_ACCESS (l),TPM_ACCESS_ACTIVE_LOCALITY ); - stop = jiffies + chip->timeout_a; - -if (chip->flags &TPM_CHIP_FLAG_IRQ ) { -again: - timeout = stop - jiffies; -if ((long )timeout <=0 ) -return -1 ; - - rc =wait_event_interruptible_timeout (priv->int_queue, - (locality_inactive (chip, l)), - timeout); - -if (rc >0 ) -return 0 ; - -if (rc == -ERESTARTSYS &&freezing (current)) { -clear_thread_flag (TIF_SIGPENDING ); - goto again; - } - }else { -do { -if (locality_inactive (chip, l)) -return 0 ; -tpm_msleep (TPM_TIMEOUT ); - }while (time_before (jiffies, stop)); - } -return -1 ; +return 0 ; }static int request_locality (struct tpm_chip *chip,int l)
Greg Kroah-Hartman
maintainerPATCH 631/775 KEYS: trusted: Fix incorrect handling of tpm_get_random()
In reply to Greg Kroah-HartmanFrom: Jarkko Sakkinen <[email protected]>
commit 5df16caada3fba3b21cb09b85cdedf99507f4ec1 upstream.
When tpm_get_random() was introduced, it defined the following API for the return value:
1. A positive value tells how many bytes of random data was generated.
2. A negative value on error.
However, in the call sites the API was used incorrectly, i.e. as it would only return negative values and otherwise zero. Returning he positive read counts to the user space does not make any possible sense.
Fix this by returning -EIO when tpm_get_random() returns a positive value.
--- security/keys/trusted-keys/trusted_tpm1.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
security/keys/trusted-keys/trusted_tpm1.c +17 -3
@@ -403,9 +403,12 @@ static int osap(struct tpm_buf *tb, struint ret; ret =tpm_get_random (chip, ononce,TPM_NONCE_SIZE ); -if (ret !=TPM_NONCE_SIZE ) +if (ret <0 )return ret; +if (ret !=TPM_NONCE_SIZE ) +return -EIO ; +tpm_buf_reset (tb,TPM_TAG_RQU_COMMAND ,TPM_ORD_OSAP );tpm_buf_append_u16 (tb, type);tpm_buf_append_u32 (tb, handle);
@@ -496,8 +499,12 @@ static int tpm_seal(struct tpm_buf *tb, goto out; ret =tpm_get_random (chip, td->nonceodd,TPM_NONCE_SIZE ); +if (ret <0 ) +return ret; +if (ret !=TPM_NONCE_SIZE ) - goto out; +return -EIO ; + ordinal =htonl (TPM_ORD_SEAL ); datsize =htonl (datalen); pcrsize =htonl (pcrinfosize);
@@ -601,9 +608,12 @@ static int tpm_unseal(struct tpm_buf *tb ordinal =htonl (TPM_ORD_UNSEAL ); ret =tpm_get_random (chip, nonceodd,TPM_NONCE_SIZE ); +if (ret <0 ) +return ret; +if (ret !=TPM_NONCE_SIZE ) {pr_info ("trusted_key: tpm_get_random failed (%d)\n" , ret); -return ret; +return -EIO ; } ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE, enonce1, nonceodd, cont, sizeof(uint32_t),
@@ -1013,8 +1023,12 @@ static int trusted_instantiate(struct kecase Opt_new: key_len = payload->key_len; ret =tpm_get_random (chip, payload->key, key_len); +if (ret <0 ) + goto out; +if (ret != key_len) {pr_info ("trusted_key: key_create failed (%d)\n" , ret); + ret = -EIO ; goto out; }if (tpm2)
Greg Kroah-Hartman
maintainerPATCH 632/775 KEYS: trusted: Fix migratable=1 failing
In reply to Greg Kroah-HartmanFrom: Jarkko Sakkinen <[email protected]>
commit 8da7520c80468c48f981f0b81fc1be6599e3b0ad upstream.
Consider the following transcript:
$ keyctl add trusted kmk "new 32 blobauth=helloworld keyhandle=80000000 migratable=1" @u add_key: Invalid argument
The documentation has the following description:
migratable= 0|1 indicating permission to reseal to new PCR values,
default 1 (resealing allowed)
The consequence is that "migratable=1" should succeed. Fix this by allowing this condition to pass instead of return -EINVAL.
[*] Documentation/security/keys/trusted-encrypted.rst
--- security/keys/trusted-keys/trusted_tpm1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/trusted-keys/trusted_tpm1.c +1 -1
@@ -801,7 +801,7 @@ static int getoptions(char *c, struct trcase Opt_migratable:if (*args[0 ].from =='0' ) pay->migratable =0 ; -else +else if (*args[0 ].from !='1' )return -EINVAL ;break ;case Opt_pcrlock:
Greg Kroah-Hartman
maintainerPATCH 633/775 KEYS: trusted: Reserve TPM for seal and unseal operations
In reply to Greg Kroah-HartmanFrom: Jarkko Sakkinen <[email protected]>
commit 8c657a0590de585b1115847c17b34a58025f2f4b upstream.
When TPM 2.0 trusted keys code was moved to the trusted keys subsystem, the operations were unwrapped from tpm_try_get_ops() and tpm_put_ops(), which are used to take temporarily the ownership of the TPM chip. The ownership is only taken inside tpm_send(), but this is not sufficient, as in the key load TPM2_CC_LOAD, TPM2_CC_UNSEAL and TPM2_FLUSH_CONTEXT need to be done as a one single atom.
Take the TPM chip ownership before sending anything with tpm_try_get_ops() and tpm_put_ops(), and use tpm_transmit_cmd() to send TPM commands instead of tpm_send(), reverting back to the old behaviour.
Acked-by Sumit Garg <[email protected]>
--- drivers/char/tpm/tpm.h | 4 ---- include/linux/tpm.h | 5 ++++- security/keys/trusted-keys/trusted_tpm2.c | 22 ++++++++++++++++++---- 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/char/tpm/tpm.h +0 -4
@@ -164,8 +164,6 @@ extern const struct file_operations tpmrextern struct idr dev_nums_idr;ssize_t tpm_transmit (struct tpm_chip *chip,u8 *buf,size_t bufsiz); -ssize_t tpm_transmit_cmd (struct tpm_chip *chip,struct tpm_buf *buf, -size_t min_rsp_body_length,const char *desc);int tpm_get_timeouts (struct tpm_chip *);int tpm_auto_startup (struct tpm_chip *chip);
@@ -194,8 +192,6 @@ static inline void tpm_msleep(unsigned iint tpm_chip_start (struct tpm_chip *chip);void tpm_chip_stop (struct tpm_chip *chip);struct tpm_chip *tpm_find_get_ops (struct tpm_chip *chip); -__must_check int tpm_try_get_ops (struct tpm_chip *chip); -void tpm_put_ops (struct tpm_chip *chip);struct tpm_chip *tpm_chip_alloc (struct device *dev,const struct tpm_class_ops *ops);
include/linux/tpm.h +4 -1
@@ -397,6 +397,10 @@ static inline u32 tpm2_rc_value(u32 rc)#if defined(CONFIG_TCG_TPM ) || defined(CONFIG_TCG_TPM_MODULE )extern int tpm_is_tpm2 (struct tpm_chip *chip); +extern __must_check int tpm_try_get_ops (struct tpm_chip *chip); +extern void tpm_put_ops (struct tpm_chip *chip); +extern ssize_t tpm_transmit_cmd (struct tpm_chip *chip,struct tpm_buf *buf, +size_t min_rsp_body_length,const char *desc);extern int tpm_pcr_read (struct tpm_chip *chip,u32 pcr_idx,struct tpm_digest *digest); extern int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
@@ -410,7 +414,6 @@ static inline int tpm_is_tpm2(struct tpm {return -ENODEV ; } -static inline int tpm_pcr_read (struct tpm_chip *chip,int pcr_idx,struct tpm_digest *digest) {
security/keys/trusted-keys/trusted_tpm2.c +18 -4
@@ -83,6 +83,12 @@ int tpm2_seal_trusted(struct tpm_chip *cif (rc)return rc; + rc =tpm_buf_init (&buf,TPM2_ST_SESSIONS ,TPM2_CC_CREATE ); +if (rc) { +tpm_put_ops (chip); +return rc; + } +tpm_buf_append_u32 (&buf, options->keyhandle); tpm2_buf_append_auth(&buf, TPM2_RS_PW, NULL /* nonce */, 0,
@@ -130,7 +136,7 @@ int tpm2_seal_trusted(struct tpm_chip *c goto out; } - rc =tpm_send (chip, buf.data,tpm_buf_length (&buf)); + rc =tpm_transmit_cmd (chip, &buf,4 ,"sealing data" );if (rc) goto out;
@@ -157,6 +163,7 @@ out: rc = -EPERM ; } +tpm_put_ops (chip);return rc; }
@@ -211,7 +218,7 @@ static int tpm2_load_cmd(struct tpm_chip goto out; } - rc =tpm_send (chip, buf.data,tpm_buf_length (&buf)); + rc =tpm_transmit_cmd (chip, &buf,4 ,"loading blob" );if (!rc) *blob_handle =be32_to_cpup ( (__be32 *) &buf.data[TPM_HEADER_SIZE ]);
@@ -260,7 +267,7 @@ static int tpm2_unseal_cmd(struct tpm_ch options->blobauth/* hmac */ , TPM_DIGEST_SIZE); - rc =tpm_send (chip, buf.data,tpm_buf_length (&buf)); + rc =tpm_transmit_cmd (chip, &buf,6 ,"unsealing" );if (rc >0 ) rc = -EPERM ;
@@ -304,12 +311,19 @@ int tpm2_unseal_trusted(struct tpm_chipu32 blob_handle;int rc; - rc =tpm2_load_cmd (chip, payload, options, &blob_handle); + rc =tpm_try_get_ops (chip);if (rc)return rc; + rc =tpm2_load_cmd (chip, payload, options, &blob_handle); +if (rc) + goto out; + rc =tpm2_unseal_cmd (chip, payload, options, blob_handle);tpm2_flush_context (chip, blob_handle); +out: +tpm_put_ops (chip); +return rc; }
Greg Kroah-Hartman
maintainerPATCH 634/775 btrfs: do not cleanup upper nodes in btrfs_backref_cleanup_node
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 7e2a870a599d4699a626ec26430c7a1ab14a2a49 upstream.
Zygo reported the following panic when testing my error handling patches for relocation:
kernel BUG at fs/btrfs/backref.c:2545!
invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 3 PID: 8472 Comm: btrfs Tainted: G W 14
Hardware name: QEMU Standard PC (i440FX + PIIX, Call Trace: btrfs_backref_error_cleanup+0x4df/0x530 build_backref_tree+0x1a5/0x700 ? _raw_spin_unlock+0x22/0x30 ? release_extent_buffer+0x225/0x280 ? free_extent_buffer.part.52+0xd7/0x140 relocate_tree_blocks+0x2a6/0xb60 ? kasan_unpoison_shadow+0x35/0x50 ? do_relocation+0xc10/0xc10 ? kasan_kmalloc+0x9/0x10 ? kmem_cache_alloc_trace+0x6a3/0xcb0 ? free_extent_buffer.part.52+0xd7/0x140 ? rb_insert_color+0x342/0x360 ? add_tree_block.isra.36+0x236/0x2b0 relocate_block_group+0x2eb/0x780 ? merge_reloc_roots+0x470/0x470 btrfs_relocate_block_group+0x26e/0x4c0 btrfs_relocate_chunk+0x52/0x120 btrfs_balance+0xe2e/0x18f0 ? pvclock_clocksource_read+0xeb/0x190 ? btrfs_relocate_chunk+0x120/0x120 ? lock_contended+0x620/0x6e0 ? do_raw_spin_lock+0x1e0/0x1e0 ? do_raw_spin_unlock+0xa8/0x140 btrfs_ioctl_balance+0x1f9/0x460 btrfs_ioctl+0x24c8/0x4380 ? __kasan_check_read+0x11/0x20 ? check_chain_key+0x1f4/0x2f0 ? __asan_loadN+0xf/0x20 ? btrfs_ioctl_get_supported_features+0x30/0x30 ? kvm_sched_clock_read+0x18/0x30 ? check_chain_key+0x1f4/0x2f0 ? lock_downgrade+0x3f0/0x3f0 ? handle_mm_fault+0xad6/0x2150 ? do_vfs_ioctl+0xfc/0x9d0 ? ioctl_file_clone+0xe0/0xe0 ? check_flags.part.50+0x6c/0x1e0 ? check_flags.part.50+0x6c/0x1e0 ? check_flags+0x26/0x30 ? lock_is_held_type+0xc3/0xf0 ? syscall_enter_from_user_mode+0x1b/0x60 ? do_syscall_64+0x13/0x80 ? rcu_read_lock_sched_held+0xa1/0xd0 ? __kasan_check_read+0x11/0x20 ? __fget_light+0xae/0x110 __x64_sys_ioctl+0xc3/0x100 do_syscall_64+0x37/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This occurs because of this check
if (RB_EMPTY_NODE(&upper->rb_node))
BUG_ON(!list_empty(&node->upper));
As we are dropping the backref node, if we discover that our upper node in the edge we just cleaned up isn't linked into the cache that we are now done with this node, thus the BUG_ON().
However this is an erroneous assumption, as we will look up all the references for a node first, and then process the pending edges. All of the 'upper' nodes in our pending edges won't be in the cache's rb_tree yet, because they haven't been processed. We could very well have many edges still left to cleanup on this node.
The fact is we simply do not need this check, we can just process all of the edges only for this node, because below this check we do the following
if (list_empty(&upper->lower)) {
list_add_tail(&upper->lower, &cache->leaves);
upper->lowest = 1;}
If the upper node truly isn't used yet, then we add it to the cache->leaves list to be cleaned up later. If it is still used then the last child node that has it linked into its node will add it to the leaves list and then it will be cleaned up.
Fix this problem by dropping this logic altogether. With this fix I no longer see the panic when testing with error injection in the backref code.
--- fs/btrfs/backref.c | 7 ------- 1 file changed, 7 deletions(-)
fs/btrfs/backref.c +0 -7
@@ -2541,13 +2541,6 @@ void btrfs_backref_cleanup_node(struct blist_del (&edge->list[UPPER ]);btrfs_backref_free_edge (cache, edge); -if (RB_EMPTY_NODE (&upper->rb_node)) { -BUG_ON (!list_empty (&node->upper)); -btrfs_backref_drop_node (cache, node); - node = upper; - node->lowest =1 ; -continue ; - }/* * Add the node to leaf node list if no other child block * cached.
Greg Kroah-Hartman
maintainerPATCH 635/775 btrfs: do not warn if we cant find the reloc root when looking up backref
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit f78743fbdae1bb31bc9c9233c3590a5048782381 upstream.
The backref code is looking for a reloc_root that corresponds to the given fs root. However any number of things could have gone wrong while initializing that reloc_root, like ENOMEM while trying to allocate the root itself, or EIO while trying to write the root item. This would result in no corresponding reloc_root being in the reloc root cache, and thus would return NULL when we do the find_reloc_root() call.
Because of this we do not want to WARN_ON(). This presumably was meant to catch developer errors, cases where we messed up adding the reloc root. However we can easily hit this case with error injection, and thus should not do a WARN_ON().
--- fs/btrfs/backref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/backref.c +1 -1
@@ -2617,7 +2617,7 @@ static int handle_direct_tree_backref(st/* Only reloc backref cache cares about a specific root */ if (cache->is_reloc) { root =find_reloc_root (cache->fs_info, cur->bytenr); -if (WARN_ON (!root)) +if (!root)return -ENOENT ; cur->root = root; }else {
Greg Kroah-Hartman
maintainerPATCH 636/775 btrfs: add asserts for deleting backref cache nodes
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit eddda68d97732ce05ca145f8e85e8a447f65cdad upstream.
A weird KASAN problem that Zygo reported could have been easily caught if we checked for basic things in our backref freeing code. We have two methods of freeing a backref node
- btrfs_backref_free_node: this just is kfree() essentially.
- btrfs_backref_drop_node: this actually unlinks the node and cleans up everything and then calls btrfs_backref_free_node().
We should mostly be using btrfs_backref_drop_node(), to make sure the node is properly unlinked from the backref cache, and only use btrfs_backref_free_node() when we know the node isn't actually linked to the backref cache. We made a mistake here and thus got the KASAN splat.
Make this style of issue easier to find by adding some ASSERT()'s to btrfs_backref_free_node() and adjusting our deletion stuff to properly init the list so we can rely on list_empty() checks working properly.
BUG: KASAN: use-after-free in btrfs_backref_cleanup_node+0x18a/0x420
Read of size 8 at addr ffff888112402950 by task btrfs/28836
CPU: 0 PID: 28836 Comm: btrfs Tainted: G W 5.10.0-e35f27394290-for-next+ #23
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
Call Trace:
dump_stack+0xbc/0xf9
? btrfs_backref_cleanup_node+0x18a/0x420
print_address_description.constprop.8+0x21/0x210
? record_print_text.cold.34+0x11/0x11
? btrfs_backref_cleanup_node+0x18a/0x420
? btrfs_backref_cleanup_node+0x18a/0x420
kasan_report.cold.10+0x20/0x37
? btrfs_backref_cleanup_node+0x18a/0x420
__asan_load8+0x69/0x90
btrfs_backref_cleanup_node+0x18a/0x420
btrfs_backref_release_cache+0x83/0x1b0
relocate_block_group+0x394/0x780
? merge_reloc_roots+0x4a0/0x4a0
btrfs_relocate_block_group+0x26e/0x4c0
btrfs_relocate_chunk+0x52/0x120
btrfs_balance+0xe2e/0x1900
? check_flags.part.50+0x6c/0x1e0
? btrfs_relocate_chunk+0x120/0x120
? kmem_cache_alloc_trace+0xa06/0xcb0
? _copy_from_user+0x83/0xc0
btrfs_ioctl_balance+0x3a7/0x460
btrfs_ioctl+0x24c8/0x4360
? __kasan_check_read+0x11/0x20
? check_chain_key+0x1f4/0x2f0
? __asan_loadN+0xf/0x20
? btrfs_ioctl_get_supported_features+0x30/0x30
? kvm_sched_clock_read+0x18/0x30
? check_chain_key+0x1f4/0x2f0
? lock_downgrade+0x3f0/0x3f0
? handle_mm_fault+0xad6/0x2150
? do_vfs_ioctl+0xfc/0x9d0
? ioctl_file_clone+0xe0/0xe0
? check_flags.part.50+0x6c/0x1e0
? check_flags.part.50+0x6c/0x1e0
? check_flags+0x26/0x30
? lock_is_held_type+0xc3/0xf0
? syscall_enter_from_user_mode+0x1b/0x60
? do_syscall_64+0x13/0x80
? rcu_read_lock_sched_held+0xa1/0xd0
? __kasan_check_read+0x11/0x20
? __fget_light+0xae/0x110
__x64_sys_ioctl+0xc3/0x100
do_syscall_64+0x37/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f4c4bdfe427
RSP: 002b:00007fff33ee6df8 EFLAGS: 00000202 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fff33ee6e98 RCX: 00007f4c4bdfe427
RDX: 00007fff33ee6e98 RSI: 00000000c4009420 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000003 R09: 0000000000000078
R10: fffffffffffff59d R11: 0000000000000202 R12: 0000000000000001
R13: 0000000000000000 R14: 00007fff33ee8a34 R15: 0000000000000001
Allocated by task 28836:
kasan_save_stack+0x21/0x50
__kasan_kmalloc.constprop.18+0xbe/0xd0
kasan_kmalloc+0x9/0x10
kmem_cache_alloc_trace+0x410/0xcb0
btrfs_backref_alloc_node+0x46/0xf0
btrfs_backref_add_tree_node+0x60d/0x11d0
build_backref_tree+0xc5/0x700
relocate_tree_blocks+0x2be/0xb90
relocate_block_group+0x2eb/0x780
btrfs_relocate_block_group+0x26e/0x4c0
btrfs_relocate_chunk+0x52/0x120
btrfs_balance+0xe2e/0x1900
btrfs_ioctl_balance+0x3a7/0x460
btrfs_ioctl+0x24c8/0x4360
__x64_sys_ioctl+0xc3/0x100
do_syscall_64+0x37/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 28836:
kasan_save_stack+0x21/0x50
kasan_set_track+0x20/0x30
kasan_set_free_info+0x1f/0x30
__kasan_slab_free+0xf3/0x140
kasan_slab_free+0xe/0x10
kfree+0xde/0x200
btrfs_backref_error_cleanup+0x452/0x530
build_backref_tree+0x1a5/0x700
relocate_tree_blocks+0x2be/0xb90
relocate_block_group+0x2eb/0x780
btrfs_relocate_block_group+0x26e/0x4c0
btrfs_relocate_chunk+0x52/0x120
btrfs_balance+0xe2e/0x1900
btrfs_ioctl_balance+0x3a7/0x460
btrfs_ioctl+0x24c8/0x4360
__x64_sys_ioctl+0xc3/0x100
do_syscall_64+0x37/0x80
entry_SYSCALL_64_after_hwframe+0x44/0xa9
The buggy address belongs to the object at ffff888112402900
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 80 bytes inside of
128-byte region [ffff888112402900, ffff888112402980)
The buggy address belongs to the page:
page:0000000028b1cd08 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888131c810c0 pfn:0x112402
flags: 0x17ffe0000000200(slab)
raw: 017ffe0000000200 ffffea000424f308 ffffea0007d572c8 ffff888100040440
raw: ffff888131c810c0 ffff888112402000 0000000100000009 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888112402800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888112402880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888112402900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888112402980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff888112402a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb--- fs/btrfs/backref.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/btrfs/backref.h +6 -3
@@ -296,6 +296,9 @@ static inline void btrfs_backref_free_no struct btrfs_backref_node *node) {if (node) { +ASSERT (list_empty (&node->list)); +ASSERT (list_empty (&node->lower)); +ASSERT (node->eb ==NULL ); cache->nr_nodes--;btrfs_put_root (node->root);kfree (node);
@@ -340,11 +343,11 @@ static inline void btrfs_backref_drop_nostatic inline void btrfs_backref_drop_node (struct btrfs_backref_cache *tree,struct btrfs_backref_node *node) { -BUG_ON (!list_empty (&node->upper)); +ASSERT (list_empty (&node->upper));btrfs_backref_drop_node_buffer (node); -list_del (&node->list); -list_del (&node->lower); +list_del_init (&node->list); +list_del_init (&node->lower);if (!RB_EMPTY_NODE (&node->rb_node))rb_erase (&node->rb_node, &tree->rb_root);btrfs_backref_free_node (tree, node);
Greg Kroah-Hartman
maintainerPATCH 637/775 btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 867ed321f90d06aaba84e2c91de51cd3038825ef upstream.
While testing my error handling patches, I added a error injection site at btrfs_inc_extent_ref, to validate the error handling I added was doing the correct thing. However I hit a pretty ugly corruption while doing this check, with the following error injection stack trace:
btrfs_inc_extent_ref
btrfs_copy_root
create_reloc_root
btrfs_init_reloc_root
btrfs_record_root_in_trans
btrfs_start_transaction
btrfs_update_inode
btrfs_update_time
touch_atime
file_accessed
btrfs_file_mmap
This is because we do not catch the error from btrfs_inc_extent_ref, which in practice would be ENOMEM, which means we lose the extent references for a root that has already been allocated and inserted, which is the problem. Fix this by aborting the transaction if we fail to do the reference modification.
--- fs/btrfs/ctree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +3 -2
@@ -221,9 +221,10 @@ int btrfs_copy_root(struct btrfs_trans_h ret =btrfs_inc_ref (trans, root, cow,1 ); else ret =btrfs_inc_ref (trans, root, cow,0 ); - -if (ret) +if (ret) { +btrfs_abort_transaction (trans, ret);return ret; + }btrfs_mark_buffer_dirty (cow); *cow_ret = cow;
Greg Kroah-Hartman
maintainerPATCH 638/775 btrfs: fix reloc root leak with 0 ref reloc roots on recovery
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit c78a10aebb275c38d0cfccae129a803fe622e305 upstream.
When recovering a relocation, if we run into a reloc root that has 0 refs we simply add it to the reloc_control->reloc_roots list, and then clean it up later. The problem with this is __del_reloc_root() doesn't do anything if the root isn't in the radix tree, which in this case it won't be because we never call __add_reloc_root() on the reloc_root.
This exit condition simply isn't correct really. During normal operation we can remove ourselves from the rb tree and then we're meant to clean up later at merge_reloc_roots() time, and this happens correctly. During recovery we're depending on free_reloc_roots() to drop our references, but we're short-circuiting.
Fix this by continuing to check if we're on the list and dropping ourselves from the reloc_control root list and dropping our reference appropriately. Change the corresponding BUG_ON() to an ASSERT() that does the correct thing if we aren't in the rb tree.
--- fs/btrfs/relocation.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/relocation.c +1 -3
@@ -668,9 +668,7 @@ static void __del_reloc_root(struct btrfRB_CLEAR_NODE (&node->rb_node); }spin_unlock (&rc->reloc_root_tree.lock); -if (!node) -return ; -BUG_ON ((struct btrfs_root *)node->data != root); +ASSERT (!node || (struct btrfs_root *)node->data == root); }/*
Greg Kroah-Hartman
maintainerPATCH 639/775 btrfs: splice remaining dirty_bgs onto the transaction dirty bg list
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 938fcbfb0cbcf532a1869efab58e6009446b1ced upstream.
While doing error injection testing with my relocation patches I hit the following assert:
assertion failed: list_empty(&block_group->dirty_list), in fs/btrfs/block-group.c:3356
------------[ cut here ]------------ kernel BUG at fs/btrfs/ctree.h:3357! invalid opcode: 0000 [#1] SMP NOPTI CPU: 0 PID: 24351 Comm: umount Tainted: G W 5.10.0-rc3+ #193 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-2.fc32 04/01/2014 RIP: 0010:assertfail.constprop.0+0x18/0x1a RSP: 0018:ffffa09b019c7e00 EFLAGS: 00010282 RAX: 0000000000000056 RBX: ffff8f6492c18000 RCX: 0000000000000000 RDX: ffff8f64fbc27c60 RSI: ffff8f64fbc19050 RDI: ffff8f64fbc19050 RBP: ffff8f6483bbdc00 R08: 0000000000000000 R09: 0000000000000000 R10: ffffa09b019c7c38 R11: ffffffff85d70928 R12: ffff8f6492c18100 R13: ffff8f6492c18148 R14: ffff8f6483bbdd70 R15: dead000000000100 FS: 00007fbfda4cdc40(0000) GS:ffff8f64fbc00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fbfda666fd0 CR3: 000000013cf66002 CR4: 0000000000370ef0 Call Trace: btrfs_free_block_groups.cold+0x55/0x55 close_ctree+0x2c5/0x306 ? fsnotify_destroy_marks+0x14/0x100 generic_shutdown_super+0x6c/0x100 kill_anon_super+0x14/0x30 btrfs_kill_super+0x12/0x20 deactivate_locked_super+0x36/0xa0 cleanup_mnt+0x12d/0x190 task_work_run+0x5c/0xa0 exit_to_user_mode_prepare+0x1b1/0x1d0 syscall_exit_to_user_mode+0x54/0x280 entry_SYSCALL_64_after_hwframe+0x44/0xa9
This happened because I injected an error in btrfs_cow_block() while running the dirty block groups. When we run the dirty block groups, we splice the list onto a local list to process. However if an error occurs, we only cleanup the transactions dirty block group list, not any pending block groups we have on our locally spliced list.
In fact if we fail to allocate a path in this function we'll also fail to clean up the splice list.
Fix this by splicing the list back onto the transaction dirty block group list so that the block groups are cleaned up. Then add a 'out' label and have the error conditions jump to out so that the errors are handled properly. This also has the side-effect of fixing a problem where we would clear 'ret' on error because we unconditionally ran btrfs_run_delayed_refs().
--- fs/btrfs/block-group.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
fs/btrfs/block-group.c +12 -7
@@ -2564,8 +2564,10 @@ again:if (!path) { path =btrfs_alloc_path (); -if (!path) -return -ENOMEM ; +if (!path) { + ret = -ENOMEM ; + goto out; + } }/*
@@ -2659,16 +2661,14 @@ again:btrfs_put_block_group (cache);if (drop_reserve)btrfs_delayed_refs_rsv_release (fs_info,1 ); - -if (ret) -break ; -/* * Avoid blocking other tasks for too long. It might even save * us from writing caches for block groups that are going to be * removed. */ mutex_unlock (&trans->transaction->cache_write_mutex); +if (ret) + goto out;mutex_lock (&trans->transaction->cache_write_mutex); }mutex_unlock (&trans->transaction->cache_write_mutex);
@@ -2692,7 +2692,12 @@ again: goto again; }spin_unlock (&cur_trans->dirty_bgs_lock); - }else if (ret <0 ) { + } +out: +if (ret <0 ) { +spin_lock (&cur_trans->dirty_bgs_lock); +list_splice_init (&dirty, &cur_trans->dirty_bgs); +spin_unlock (&cur_trans->dirty_bgs_lock);btrfs_cleanup_dirty_bgs (cur_trans, fs_info); }
Greg Kroah-Hartman
maintainerPATCH 640/775 btrfs: handle space_info::total_bytes_pinned inside the delayed ref itself
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 2187374f35fe9cadbddaa9fcf0c4121365d914e8 upstream.
Currently we pass things around to figure out if we maybe freeing data based on the state of the delayed refs head. This makes the accounting sort of confusing and hard to follow, as it's distinctly separate from the delayed ref heads stuff, but also depends on it entirely.
Fix this by explicitly adjusting the space_info->total_bytes_pinned in the delayed refs code. We now have two places where we modify this counter, once where we create the delayed and destroy the delayed refs, and once when we pin and unpin the extents. This means there is a slight overlap between delayed refs and the pin/unpin mechanisms, but this is simply used by the ENOSPC infrastructure to determine if we need to commit the transaction, so there's no adverse affect from this, we might simply commit thinking it will give us enough space when it might not.
--- fs/btrfs/block-group.c | 10 +---- fs/btrfs/delayed-ref.c | 51 +++++++++++++++---------- fs/btrfs/delayed-ref.h | 16 ++++++-- fs/btrfs/extent-tree.c | 97 ++++++------------------------------------------- fs/btrfs/space-info.h | 17 ++++++++ 5 files changed, 74 insertions(+), 117 deletions(-)
fs/btrfs/block-group.c +3 -7
@@ -1371,9 +1371,7 @@ void btrfs_delete_unused_bgs(struct btrfbtrfs_space_info_update_bytes_pinned (fs_info, space_info, -block_group->pinned); space_info->bytes_readonly += block_group->pinned; -percpu_counter_add_batch (&space_info->total_bytes_pinned, - -block_group->pinned, -BTRFS_TOTAL_BYTES_PINNED_BATCH ); +__btrfs_mod_total_bytes_pinned (space_info, -block_group->pinned); block_group->pinned =0 ;spin_unlock (&block_group->lock);
@@ -2901,10 +2899,8 @@ int btrfs_update_block_group(struct btrfspin_unlock (&cache->lock);spin_unlock (&cache->space_info->lock); -percpu_counter_add_batch ( - &cache->space_info->total_bytes_pinned, - num_bytes, -BTRFS_TOTAL_BYTES_PINNED_BATCH ); +__btrfs_mod_total_bytes_pinned (cache->space_info, + num_bytes);set_extent_dirty (&trans->transaction->pinned_extents, bytenr, bytenr + num_bytes -1 ,GFP_NOFS | __GFP_NOFAIL);
fs/btrfs/delayed-ref.c +30 -21
133 lines not on this page · raw message
fs/btrfs/delayed-ref.h +12 -4
@@ -326,6 +326,16 @@ static inline void btrfs_put_delayed_ref } } +static inline u64 btrfs_ref_head_to_space_flags ( +struct btrfs_delayed_ref_head *head_ref) +{ +if (head_ref->is_data) +return BTRFS_BLOCK_GROUP_DATA ; +else if (head_ref->is_system) +return BTRFS_BLOCK_GROUP_SYSTEM ; +return BTRFS_BLOCK_GROUP_METADATA ; +} +static inline void btrfs_put_delayed_ref_head (struct btrfs_delayed_ref_head *head) {if (refcount_dec_and_test (&head->refs))
@@ -334,12 +344,10 @@ static inline void btrfs_put_delayed_refint btrfs_add_delayed_tree_ref (struct btrfs_trans_handle *trans,struct btrfs_ref *generic_ref, -struct btrfs_delayed_extent_op *extent_op, -int *old_ref_mod,int *new_ref_mod); +struct btrfs_delayed_extent_op *extent_op);int btrfs_add_delayed_data_ref (struct btrfs_trans_handle *trans,struct btrfs_ref *generic_ref, -u64 reserved,int *old_ref_mod, -int *new_ref_mod); +u64 reserved);int btrfs_add_delayed_extent_op (struct btrfs_trans_handle *trans,u64 bytenr,u64 num_bytes,struct btrfs_delayed_extent_op *extent_op);
fs/btrfs/extent-tree.c +12 -85
203 lines not on this page · raw message
fs/btrfs/space-info.h +17 -0
@@ -152,4 +152,21 @@ static inline void btrfs_space_info_freeint btrfs_reserve_data_bytes (struct btrfs_fs_info *fs_info,u64 bytes,enum btrfs_reserve_flush_enum flush); +static inline void __btrfs_mod_total_bytes_pinned ( +struct btrfs_space_info *space_info, +s64 mod) +{ +percpu_counter_add_batch (&space_info->total_bytes_pinned, mod, +BTRFS_TOTAL_BYTES_PINNED_BATCH ); +} + +static inline void btrfs_mod_total_bytes_pinned (struct btrfs_fs_info *fs_info, +u64 flags,s64 mod) +{ +struct btrfs_space_info *space_info =btrfs_find_space_info (fs_info, flags); + +ASSERT (space_info); +__btrfs_mod_total_bytes_pinned (space_info, mod); +} +#endif /* BTRFS_SPACE_INFO_H */
Greg Kroah-Hartman
maintainerPATCH 641/775 btrfs: account for new extents being deleted in total_bytes_pinned
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 81e75ac74ecba929d1e922bf93f9fc467232e39f upstream.
My recent patch set "A variety of lock contention fixes", found here
https://lore.kernel.org/linux-btrfs/[email protected]/
(Tracked in https://github.com/btrfs/linux/issues/86)
that reduce lock contention on the extent root by running delayed refs less often resulted in a regression in generic/371. This test fallocate()'s the fs until it's full, deletes all the files, and then tries to fallocate() until full again.
Before these patches we would run all of the delayed refs during flushing, and then would commit the transaction because we had plenty of pinned space to recover in order to allocate. However my patches made it so we weren't running the delayed refs as aggressively, which meant that we appeared to have less pinned space when we were deciding to commit the transaction.
We use the space_info->total_bytes_pinned to approximate how much space we have pinned. It's approximate because if we remove a reference to an extent we may free it, but there may be more references to it than we know of at that point, but we account it as pinned at the creation time, and then it's properly accounted when the delayed ref runs.
The way we account for pinned space is if the delayed_ref_head->total_ref_mod is < 0, because that is clearly a freeing option. However there is another case, and that is where ->total_ref_mod == 0 && ->must_insert_reserved == 1.
When we allocate a new extent, we have ->total_ref_mod == 1 and we have ->must_insert_reserved == 1. This is used to indicate that it is a brand new extent and will need to have its extent entry added before we modify any references on the delayed ref head. But if we subsequently remove that extent reference, our ->total_ref_mod will be 0, and that space will be pinned and freed. Accounting for this case properly allows for generic/371 to pass with my delayed refs patches applied.
It's important to note that this problem exists without the referenced patches, it just was uncovered by them.
--- fs/btrfs/delayed-ref.c | 5 +++++ fs/btrfs/extent-tree.c | 33 +++++++++++++++++++-------------- 2 files changed, 24 insertions(+), 14 deletions(-)
fs/btrfs/delayed-ref.c +5 -0
@@ -732,11 +732,16 @@ static noinline void update_existing_hea* 2. We were negative and went to 0 or positive, so no longer can say * that the space would be pinned, decrement our counter from the * total_bytes_pinned counter. +* 3. We are now at 0 and have ->must_insert_reserved set, which means +* this was a new allocation and then we dropped it, and thus must +* add our space to the total_bytes_pinned counter. */ if (existing->total_ref_mod <0 && old_ref_mod >=0 )btrfs_mod_total_bytes_pinned (fs_info, flags, existing->num_bytes);else if (existing->total_ref_mod >=0 && old_ref_mod <0 )btrfs_mod_total_bytes_pinned (fs_info, flags, -existing->num_bytes); +else if (existing->total_ref_mod ==0 && existing->must_insert_reserved) +btrfs_mod_total_bytes_pinned (fs_info, flags, existing->num_bytes);spin_unlock (&existing->lock); }
fs/btrfs/extent-tree.c +19 -14
@@ -1754,23 +1754,28 @@ void btrfs_cleanup_ref_head_accounting(s {int nr_items =1 ;/* Dropping this ref head update. */ -if (head->total_ref_mod <0 ) { +/* +* We had csum deletions accounted for in our delayed refs rsv, we need +* to drop the csum leaves for this update from our delayed_refs_rsv. +*/ +if (head->total_ref_mod <0 && head->is_data) { +spin_lock (&delayed_refs->lock); + delayed_refs->pending_csums -= head->num_bytes; +spin_unlock (&delayed_refs->lock); + nr_items +=btrfs_csum_bytes_to_leaves (fs_info, head->num_bytes); + } + +/* +* We were dropping refs, or had a new ref and dropped it, and thus must +* adjust down our total_bytes_pinned, the space may or may not have +* been pinned and so is accounted for properly in the pinned space by +* now. +*/ +if (head->total_ref_mod <0 || + (head->total_ref_mod ==0 && head->must_insert_reserved)) {u64 flags =btrfs_ref_head_to_space_flags (head);btrfs_mod_total_bytes_pinned (fs_info, flags, -head->num_bytes); - -/* -* We had csum deletions accounted for in our delayed refs rsv, -* we need to drop the csum leaves for this update from our -* delayed_refs_rsv. -*/ -if (head->is_data) { -spin_lock (&delayed_refs->lock); - delayed_refs->pending_csums -= head->num_bytes; -spin_unlock (&delayed_refs->lock); - nr_items +=btrfs_csum_bytes_to_leaves (fs_info, - head->num_bytes); - } }btrfs_delayed_refs_rsv_release (fs_info, nr_items);
Greg Kroah-Hartman
maintainerPATCH 642/775 btrfs: fix extent buffer leak on failure to copy root
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 72c9925f87c8b74f36f8e75a4cd93d964538d3ca upstream.
At btrfs_copy_root(), if the call to btrfs_inc_ref() fails we end up returning without unlocking and releasing our reference on the extent buffer named "cow" we previously allocated with btrfs_alloc_tree_block().
So fix that by unlocking the extent buffer and dropping our reference on it before returning.
--- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
@@ -222,6 +222,8 @@ int btrfs_copy_root(struct btrfs_trans_helse ret =btrfs_inc_ref (trans, root, cow,0 );if (ret) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 643/775 drm/i915/gt: Flush before changing register state
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit d5109f739c9f14a3bda249cb48b16de1065932f0 upstream.
Flush; invalidate; change registers; invalidate; flush.
Will this finally work on every device? Or will Baytrail complain again?
On the positive side, we immediately see the benefit of having hsw-gt1 in CI.
Testcase: igt/gem_render_tiled_blits # hsw-gt1
--- drivers/gpu/drm/i915/gt/gen7_renderclear.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/gt/gen7_renderclear.c +1 -0
@@ -393,6 +393,7 @@ static void emit_batch(struct i915_vma * desc_count);/* Reset inherited context registers */ +gen7_emit_pipeline_flush (&cmds);gen7_emit_pipeline_invalidate (&cmds);batch_add (&cmds,MI_LOAD_REGISTER_IMM (2 ));batch_add (&cmds,i915_mmio_reg_offset (CACHE_MODE_0_GEN7 ));
Greg Kroah-Hartman
maintainerPATCH 644/775 drm/i915/gt: Correct surface base address for renderclear
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit 81ce8f04aa96f7f6cae05770f68b5d15be91f5a2 upstream.
The surface_state_base is an offset into the batch, so we need to pass the correct batch address for STATE_BASE_ADDRESS.
--- drivers/gpu/drm/i915/gt/gen7_renderclear.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/gen7_renderclear.c +1 -1
@@ -240,7 +240,7 @@ gen7_emit_state_base_address(struct batc/* general */ *cs++ =batch_addr (batch) |BASE_ADDRESS_MODIFY ;/* surface */ - *cs++ =batch_addr (batch) | surface_state_base |BASE_ADDRESS_MODIFY ; + *cs++ = (batch_addr (batch) + surface_state_base) |BASE_ADDRESS_MODIFY ;/* dynamic */ *cs++ =batch_addr (batch) |BASE_ADDRESS_MODIFY ;/* indirect */
Greg Kroah-Hartman
maintainerPATCH 645/775 crypto: arm64/sha - add missing module aliases
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 0df07d8117c3576f1603b05b84089742a118d10a upstream.
The accelerated, instruction based implementations of SHA1, SHA2 and SHA3 are autoloaded based on CPU capabilities, given that the code is modest in size, and widely used, which means that resolving the algo name, loading all compatible modules and picking the one with the highest priority is taken to be suboptimal.
However, if these algorithms are requested before this CPU feature based matching and autoloading occurs, these modules are not even considered, and we end up with suboptimal performance.
So add the missing module aliases for the various SHA implementations.
--- arch/arm64/crypto/sha1-ce-glue.c | 1 + arch/arm64/crypto/sha2-ce-glue.c | 2 ++ arch/arm64/crypto/sha3-ce-glue.c | 4 ++++ arch/arm64/crypto/sha512-ce-glue.c | 2 ++ 4 files changed, 9 insertions(+)
arch/arm64/crypto/sha1-ce-glue.c +1 -0
@@ -19,6 +19,7 @@MODULE_DESCRIPTION ("SHA1 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha1" );struct sha1_ce_state {struct sha1_state sst;
arch/arm64/crypto/sha2-ce-glue.c +2 -0
@@ -19,6 +19,8 @@MODULE_DESCRIPTION ("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha224" ); +MODULE_ALIAS_CRYPTO ("sha256" );struct sha256_ce_state {struct sha256_state sst;
arch/arm64/crypto/sha3-ce-glue.c +4 -0
@@ -23,6 +23,10 @@MODULE_DESCRIPTION ("SHA3 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha3-224" ); +MODULE_ALIAS_CRYPTO ("sha3-256" ); +MODULE_ALIAS_CRYPTO ("sha3-384" ); +MODULE_ALIAS_CRYPTO ("sha3-512" ); asmlinkage void sha3_ce_transform(u64 *st, const u8 *data, int blocks,int md_len);
arch/arm64/crypto/sha512-ce-glue.c +2 -0
@@ -23,6 +23,8 @@MODULE_DESCRIPTION ("SHA-384/SHA-512 secure hash using ARMv8 Crypto Extensions" );MODULE_AUTHOR ("Ard Biesheuvel <[email protected]>" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_CRYPTO ("sha384" ); +MODULE_ALIAS_CRYPTO ("sha512" ); asmlinkage void sha512_ce_transform(struct sha512_state *sst, u8 const *src,int blocks);
Greg Kroah-Hartman
maintainerPATCH 646/775 crypto: aesni - prevent misaligned buffers on the stack
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit a13ed1d15b07a04b1f74b2df61ff7a5e47f45dd8 upstream.
The GCM mode driver uses 16 byte aligned buffers on the stack to pass the IV to the asm helpers, but unfortunately, the x86 port does not guarantee that the stack pointer is 16 byte aligned upon entry in the first place. Since the compiler is not aware of this, it will not emit the additional stack realignment sequence that is needed, and so the alignment is not guaranteed to be more than 8 bytes.
So instead, allocate some padding on the stack, and realign the IV pointer by hand.
--- arch/x86/crypto/aesni-intel_glue.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
arch/x86/crypto/aesni-intel_glue.c +16 -12
@@ -686,7 +686,8 @@ static int gcmaes_crypt_by_sg(bool enc,struct crypto_aead *tfm =crypto_aead_reqtfm (req);unsigned long auth_tag_len =crypto_aead_authsize (tfm);const struct aesni_gcm_tfm_s *gcm_tfm = aesni_gcm_tfm; - struct gcm_context_data data AESNI_ALIGN_ATTR; +u8 databuf[sizeof (struct gcm_context_data ) + (AESNI_ALIGN -8 )]__aligned(8) ; +struct gcm_context_data *data =PTR_ALIGN ((void *)databuf,AESNI_ALIGN );struct scatter_walk dst_sg_walk = {};unsigned long left = req->cryptlen;unsigned long len, srclen, dstlen;
@@ -735,8 +736,7 @@ static int gcmaes_crypt_by_sg(bool enc, }kernel_fpu_begin (); - gcm_tfm->init (aes_ctx, &data, iv, - hash_subkey, assoc, assoclen); + gcm_tfm->init (aes_ctx, data, iv, hash_subkey, assoc, assoclen);if (req->src != req->dst) {while (left) { src =scatterwalk_map (&src_sg_walk);
@@ -746,10 +746,10 @@ static int gcmaes_crypt_by_sg(bool enc, len =min (srclen, dstlen);if (len) {if (enc) - gcm_tfm->enc_update (aes_ctx, &data, + gcm_tfm->enc_update (aes_ctx, data, dst, src, len);else - gcm_tfm->dec_update (aes_ctx, &data, + gcm_tfm->dec_update (aes_ctx, data, dst, src, len); } left -= len;
@@ -767,10 +767,10 @@ static int gcmaes_crypt_by_sg(bool enc, len =scatterwalk_clamp (&src_sg_walk, left);if (len) {if (enc) - gcm_tfm->enc_update (aes_ctx, &data, + gcm_tfm->enc_update (aes_ctx, data, src, src, len);else - gcm_tfm->dec_update (aes_ctx, &data, + gcm_tfm->dec_update (aes_ctx, data, src, src, len); } left -= len;
@@ -779,7 +779,7 @@ static int gcmaes_crypt_by_sg(bool enc,scatterwalk_done (&src_sg_walk,1 , left); } } - gcm_tfm->finalize (aes_ctx, &data, authTag, auth_tag_len); + gcm_tfm->finalize (aes_ctx, data, authTag, auth_tag_len);kernel_fpu_end ();if (!assocmem)
@@ -828,7 +828,8 @@ static int helper_rfc4106_encrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct aesni_rfc4106_gcm_ctx *ctx =aesni_rfc4106_gcm_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );unsigned int i;__be32 counter =cpu_to_be32 (1 );
@@ -855,7 +856,8 @@ static int helper_rfc4106_decrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct aesni_rfc4106_gcm_ctx *ctx =aesni_rfc4106_gcm_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );unsigned int i;if (unlikely (req->assoclen !=16 && req->assoclen !=20 ))
@@ -985,7 +987,8 @@ static int generic_gcmaes_encrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct generic_gcmaes_ctx *ctx =generic_gcmaes_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );__be32 counter =cpu_to_be32 (1 );memcpy (iv, req->iv,12 );
@@ -1001,7 +1004,8 @@ static int generic_gcmaes_decrypt(structstruct crypto_aead *tfm =crypto_aead_reqtfm (req);struct generic_gcmaes_ctx *ctx =generic_gcmaes_ctx_get (tfm);void *aes_ctx = &(ctx->aes_key_expanded); - u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); +u8 ivbuf[16 + (AESNI_ALIGN -8 )]__aligned(8) ; +u8 *iv =PTR_ALIGN (&ivbuf[0 ],AESNI_ALIGN );memcpy (iv, req->iv,12 ); *((__be32 *)(iv+12 )) = counter;
Greg Kroah-Hartman
maintainerPATCH 647/775 crypto: michael_mic - fix broken misalignment handling
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit e1b2d980f03b833442768c1987d5ad0b9a58cfe7 upstream.
The Michael MIC driver uses the cra_alignmask to ensure that pointers presented to its update and finup/final methods are 32-bit aligned. However, due to the way the shash API works, this is no guarantee that the 32-bit reads occurring in the update method are also aligned, as the size of the buffer presented to update may be of uneven length. For instance, an update() of 3 bytes followed by a misaligned update() of 4 or more bytes will result in a misaligned access using an accessor that is not suitable for this.
On most architectures, this does not matter, and so setting the cra_alignmask is pointless. On architectures where this does matter, setting the cra_alignmask does not actually solve the problem.
So let's get rid of the cra_alignmask, and use unaligned accessors instead, where appropriate.
--- crypto/michael_mic.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-)
crypto/michael_mic.c +12 -19
@@ -7,7 +7,7 @@* Copyright (c) 2004 Jouni Malinen <[email protected]> */ #include <crypto/internal/hash.h> -#include <asm/byteorder.h> +#include <asm/unaligned.h> #include <linux/init.h> #include <linux/module.h> #include <linux/string.h>
@@ -19,7 +19,7 @@ struct michael_mic_ctx { };struct michael_mic_desc_ctx { -u8 pending[4 ]; +__le32 pending;size_t pending_len;u32 l, r;
@@ -60,13 +60,12 @@ static int michael_update(struct shash_d unsigned int len) {struct michael_mic_desc_ctx *mctx =shash_desc_ctx (desc); -const __le32 *src;if (mctx->pending_len) {int flen =4 - mctx->pending_len;if (flen > len) flen = len; -memcpy (&mctx->pending[mctx->pending_len], data, flen); +memcpy ((u8 *)&mctx->pending + mctx->pending_len, data, flen); mctx->pending_len += flen; data += flen; len -= flen;
@@ -74,23 +73,21 @@ static int michael_update(struct shash_dif (mctx->pending_len <4 )return 0 ; - src = (const __le32 *)mctx->pending; - mctx->l ^=le32_to_cpup (src); + mctx->l ^=le32_to_cpu (mctx->pending);michael_block (mctx->l, mctx->r); mctx->pending_len =0 ; } - src = (const __le32 *)data; -while (len >=4 ) { - mctx->l ^=le32_to_cpup (src++); + mctx->l ^=get_unaligned_le32 (data);michael_block (mctx->l, mctx->r); + data +=4 ; len -=4 ; }if (len >0 ) { mctx->pending_len = len; -memcpy (mctx->pending, src, len); +memcpy (&mctx->pending, data, len); }return 0 ;
@@ -100,8 +97,7 @@ static int michael_update(struct shash_dstatic int michael_final (struct shash_desc *desc,u8 *out) {struct michael_mic_desc_ctx *mctx =shash_desc_ctx (desc); -u8 *data = mctx->pending; -__le32 *dst = (__le32 *)out; +u8 *data = (u8 *)&mctx->pending;/* Last block and padding (0x5a, 4..7 x 0) */ switch (mctx->pending_len) {
@@ -123,8 +119,8 @@ static int michael_final(struct shash_de/* l ^= 0; */ michael_block (mctx->l, mctx->r); - dst[0 ] =cpu_to_le32 (mctx->l); - dst[1 ] =cpu_to_le32 (mctx->r); +put_unaligned_le32 (mctx->l, out); +put_unaligned_le32 (mctx->r, out +4 );return 0 ; }
@@ -135,13 +131,11 @@ static int michael_setkey(struct crypto_ {struct michael_mic_ctx *mctx =crypto_shash_ctx (tfm); -const __le32 *data = (const __le32 *)key; -if (keylen !=8 )return -EINVAL ; - mctx->l =le32_to_cpu (data[0 ]); - mctx->r =le32_to_cpu (data[1 ]); + mctx->l =get_unaligned_le32 (key); + mctx->r =get_unaligned_le32 (key +4 );return 0 ; }
@@ -156,7 +150,6 @@ static struct shash_alg alg = { .cra_name = "michael_mic", .cra_driver_name = "michael_mic-generic", .cra_blocksize = 8, - .cra_alignmask = 3, .cra_ctxsize = sizeof(struct michael_mic_ctx), .cra_module = THIS_MODULE, }
Greg Kroah-Hartman
maintainerPATCH 648/775 crypto: sun4i-ss - checking sg length is not sufficient
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 7bdcd851fa7eb66e8922aa7f6cba9e2f2427a7cf upstream.
The optimized cipher function need length multiple of 4 bytes. But it get sometimes odd length.
This is due to SG data could be stored with an offset.
So the fix is to check also if the offset is aligned with 4 bytes.
--- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +2 -2
@@ -201,12 +201,12 @@ static int sun4i_ss_cipher_poll(struct s* we can use the SS optimized function */ while (in_sg && no_chunk ==1 ) { -if (in_sg->length %4 ) +if ((in_sg->length | in_sg->offset) &3u ) no_chunk =0 ; in_sg =sg_next (in_sg); }while (out_sg && no_chunk ==1 ) { -if (out_sg->length %4 ) +if ((out_sg->length | out_sg->offset) &3u ) no_chunk =0 ; out_sg =sg_next (out_sg); }
Greg Kroah-Hartman
maintainerPATCH 649/775 crypto: sun4i-ss - IV register does not work on A10 and A13
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit b756f1c8fc9d84e3f546d7ffe056c5352f4aab05 upstream.
Allwinner A10 and A13 SoC have a version of the SS which produce invalid IV in IVx register.
Instead of adding a variant for those, let's convert SS to produce IV directly from data.
--- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 34 ++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +28 -6
@@ -20,6 +20,7 @@ static int noinline_for_stack sun4i_ss_ounsigned int ivsize =crypto_skcipher_ivsize (tfm);struct sun4i_cipher_req_ctx *ctx =skcipher_request_ctx (areq);u32 mode = ctx->mode; +void *backup_iv =NULL ;/* when activating SS, the default FIFO space is SS_RX_DEFAULT(32) */ u32 rx_cnt =SS_RX_DEFAULT ;u32 tx_cnt =0 ;
@@ -44,6 +45,13 @@ static int noinline_for_stack sun4i_ss_oreturn -EINVAL ; } +if (areq->iv && ivsize >0 && mode &SS_DECRYPTION ) { + backup_iv =kzalloc (ivsize,GFP_KERNEL ); +if (!backup_iv) +return -ENOMEM ; +scatterwalk_map_and_copy (backup_iv, areq->src, areq->cryptlen - ivsize, ivsize,0 ); + } +spin_lock_irqsave (&ss->slock, flags);for (i =0 ; i < op->keylen; i +=4 )
@@ -117,9 +125,12 @@ static int noinline_for_stack sun4i_ss_o }while (oleft);if (areq->iv) { -for (i =0 ; i <4 && i < ivsize /4 ; i++) { - v =readl (ss->base +SS_IV0 + i *4 ); - *(u32 *)(areq->iv + i *4 ) = v; +if (mode &SS_DECRYPTION ) { +memcpy (areq->iv, backup_iv, ivsize); +kfree_sensitive (backup_iv); + }else { +scatterwalk_map_and_copy (areq->iv, areq->dst, areq->cryptlen - ivsize, + ivsize,0 ); } }
@@ -174,6 +185,7 @@ static int sun4i_ss_cipher_poll(struct sunsigned int ileft = areq->cryptlen;unsigned int oleft = areq->cryptlen;unsigned int todo; +void *backup_iv =NULL ;struct sg_mapping_iter mi, mo;unsigned long pi =0 , po =0 ;/* progress for in and out */ bool miter_err;
@@ -217,6 +229,13 @@ static int sun4i_ss_cipher_poll(struct sif (need_fallback)return sun4i_ss_cipher_poll_fallback (areq); +if (areq->iv && ivsize >0 && mode &SS_DECRYPTION ) { + backup_iv =kzalloc (ivsize,GFP_KERNEL ); +if (!backup_iv) +return -ENOMEM ; +scatterwalk_map_and_copy (backup_iv, areq->src, areq->cryptlen - ivsize, ivsize,0 ); + } +spin_lock_irqsave (&ss->slock, flags);for (i =0 ; i < op->keylen; i +=4 )
@@ -345,9 +364,12 @@ static int sun4i_ss_cipher_poll(struct ssg_miter_stop (&mo); }if (areq->iv) { -for (i =0 ; i <4 && i < ivsize /4 ; i++) { - v =readl (ss->base +SS_IV0 + i *4 ); - *(u32 *)(areq->iv + i *4 ) = v; +if (mode &SS_DECRYPTION ) { +memcpy (areq->iv, backup_iv, ivsize); +kfree_sensitive (backup_iv); + }else { +scatterwalk_map_and_copy (areq->iv, areq->dst, areq->cryptlen - ivsize, + ivsize,0 ); } }
Greg Kroah-Hartman
maintainerPATCH 650/775 crypto: sun4i-ss - handle BigEndian for cipher
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 5ab6177fa02df15cd8a02a1f1fb361d2d5d8b946 upstream.
Ciphers produce invalid results on BE.
Key and IV need to be written in LE.
--- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +6 -6
@@ -54,13 +54,13 @@ static int noinline_for_stack sun4i_ss_ospin_lock_irqsave (&ss->slock, flags); -for (i =0 ; i < op->keylen; i +=4 ) -writel (*(op->key + i /4 ), ss->base +SS_KEY0 + i); +for (i =0 ; i < op->keylen /4 ; i++) +writesl (ss->base +SS_KEY0 + i *4 , &op->key[i],1 );if (areq->iv) {for (i =0 ; i <4 && i < ivsize /4 ; i++) { v = *(u32 *)(areq->iv + i *4 ); -writel (v, ss->base +SS_IV0 + i *4 ); +writesl (ss->base +SS_IV0 + i *4 , &v,1 ); } }writel (mode, ss->base +SS_CTL );
@@ -238,13 +238,13 @@ static int sun4i_ss_cipher_poll(struct sspin_lock_irqsave (&ss->slock, flags); -for (i =0 ; i < op->keylen; i +=4 ) -writel (*(op->key + i /4 ), ss->base +SS_KEY0 + i); +for (i =0 ; i < op->keylen /4 ; i++) +writesl (ss->base +SS_KEY0 + i *4 , &op->key[i],1 );if (areq->iv) {for (i =0 ; i <4 && i < ivsize /4 ; i++) { v = *(u32 *)(areq->iv + i *4 ); -writel (v, ss->base +SS_IV0 + i *4 ); +writesl (ss->base +SS_IV0 + i *4 , &v,1 ); } }writel (mode, ss->base +SS_CTL );
Greg Kroah-Hartman
maintainerPATCH 651/775 crypto: sun4i-ss - initialize need_fallback
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 4ec8977b921fd9d512701e009ce8082cb94b5c1c upstream.
The need_fallback is never initialized and seem to be always true at runtime. So all hardware operations are always bypassed.
--- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +1 -1
@@ -194,7 +194,7 @@ static int sun4i_ss_cipher_poll(struct sunsigned int obo =0 ;/* offset in bufo*/ unsigned int obl =0 ;/* length of data in bufo */ unsigned long flags; -bool need_fallback; +bool need_fallback = false;if (!areq->cryptlen)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 652/775 soc: samsung: exynos-asv: dont defer early on not-supported SoCs
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
commit 0458b88267c637fb872b0359da9ff0b243081e9e upstream.
Check if the SoC is really supported before gathering the needed resources. This fixes endless deferred probe on some SoCs other than Exynos5422 (like Exynos5410).
--- drivers/soc/samsung/exynos-asv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/soc/samsung/exynos-asv.c +5 -5
@@ -119,11 +119,6 @@ static int exynos_asv_probe(struct platfu32 product_id =0 ;int ret, i; - cpu_dev =get_cpu_device (0 ); - ret =dev_pm_opp_get_opp_count (cpu_dev); -if (ret <0 ) -return -EPROBE_DEFER ; - asv =devm_kzalloc (&pdev->dev,sizeof (*asv),GFP_KERNEL );if (!asv)return -ENOMEM ;
@@ -144,6 +139,11 @@ static int exynos_asv_probe(struct platfreturn -ENODEV ; } + cpu_dev =get_cpu_device (0 ); + ret =dev_pm_opp_get_opp_count (cpu_dev); +if (ret <0 ) +return -EPROBE_DEFER ; + ret =of_property_read_u32 (pdev->dev.of_node,"samsung,asv-bin" , &asv->of_bin);if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 653/775 soc: samsung: exynos-asv: handle reading revision register error
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 4561560dfb4f847a0b327d48bdd1f45bf1b6261f upstream.
If regmap_read() fails, the product_id local variable will contain random value from the stack. Do not try to parse such value and fail the ASV driver probe.
--- drivers/soc/samsung/exynos-asv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/soc/samsung/exynos-asv.c +7 -1
@@ -129,7 +129,13 @@ static int exynos_asv_probe(struct platfreturn PTR_ERR (asv->chipid_regmap); } -regmap_read (asv->chipid_regmap,EXYNOS_CHIPID_REG_PRO_ID , &product_id); + ret =regmap_read (asv->chipid_regmap,EXYNOS_CHIPID_REG_PRO_ID , + &product_id); +if (ret <0 ) { +dev_err (&pdev->dev,"Cannot read revision from ChipID: %d\n" , + ret); +return -ENODEV ; + }switch (product_id &EXYNOS_MASK ) {case 0xE5422000 :
Greg Kroah-Hartman
maintainerPATCH 654/775 seccomp: Add missing return in non-void function
In reply to Greg Kroah-HartmanFrom: Paul Cercueil <[email protected]>
commit 04b38d012556199ba4c31195940160e0c44c64f0 upstream.
We don't actually care about the value, since the kernel will panic before that; but a value should nonetheless be returned, otherwise the compiler will complain.
--- kernel/seccomp.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/seccomp.c +2 -0
@@ -1284,6 +1284,8 @@ static int __seccomp_filter(int this_sys const bool recheck_after_trace) {BUG (); + +return -1 ; }#endif
Greg Kroah-Hartman
maintainerPATCH 655/775 arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL)
In reply to Greg Kroah-HartmanFrom: Timothy E Baldwin <[email protected]>
commit df84fe94708985cdfb78a83148322bcd0a699472 upstream.
Since commit f086f67485c5 ("arm64: ptrace: add support for syscall emulation"), if system call number -1 is called and the process is being traced with PTRACE_SYSCALL, for example by strace, the seccomp check is skipped and -ENOSYS is returned unconditionally (unless altered by the tracer) rather than carrying out action specified in the seccomp filter.
The consequence of this is that it is not possible to reliably strace a seccomp based implementation of a foreign system call interface in which r7/x8 is permitted to be -1 on entry to a system call.
Also trace_sys_enter and audit_syscall_entry are skipped if a system call is skipped.
Fix by removing the in_syscall(regs) check restoring the previous behaviour which is like AArch32, x86 (which uses generic code) and everything else.
--- arch/arm64/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/ptrace.c +1 -1
@@ -1796,7 +1796,7 @@ int syscall_trace_enter(struct pt_regs *if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {tracehook_report_syscall (regs,PTRACE_SYSCALL_ENTER ); -if (!in_syscall (regs) || (flags & _TIF_SYSCALL_EMU)) +if (flags & _TIF_SYSCALL_EMU)return NO_SYSCALL ; }
Greg Kroah-Hartman
maintainerPATCH 656/775 misc: rtsx: init of rts522a add OCP power off when no card is present
In reply to Greg Kroah-HartmanFrom: Ricky Wu <[email protected]>
commit 920fd8a70619074eac7687352c8f1c6f3c2a64a5 upstream.
Power down OCP for power consumption
when no SD/MMC card is present
--- drivers/misc/cardreader/rts5227.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/cardreader/rts5227.c +5 -0
@@ -398,6 +398,11 @@ static int rts522a_extra_init_hw(struct {rts5227_extra_init_hw (pcr); +/* Power down OCP for power consumption */ +if (!pcr->card_exist) +rtsx_pci_write_register (pcr,FPDCTL ,OC_POWER_DOWN , +OC_POWER_DOWN ); +rtsx_pci_write_register (pcr,FUNC_FORCE_CTL ,FUNC_FORCE_UPME_XMT_DBG ,FUNC_FORCE_UPME_XMT_DBG );rtsx_pci_write_register (pcr,PCLK_CTL ,0x04 ,0x04 );
Greg Kroah-Hartman
maintainerPATCH 657/775 drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue
In reply to Greg Kroah-HartmanFrom: Sabyrzhan Tasbolatov <[email protected]>
commit 2fd10bcf0310b9525b2af9e1f7aa9ddd87c3772e upstream.
syzbot found WARNING in qp_broker_alloc[1] in qp_host_alloc_queue() when num_pages is 0x100001, giving queue_size + queue_page_size bigger than KMALLOC_MAX_SIZE for kzalloc(), resulting order >= MAX_ORDER condition.
queue_size + queue_page_size=0x8000d8, where KMALLOC_MAX_SIZE=0x400000.
[1]
Call Trace: alloc_pages include/linux/gfp.h:547 [inline] kmalloc_order+0x40/0x130 mm/slab_common.c:837 kmalloc_order_trace+0x15/0x70 mm/slab_common.c:853 kmalloc_large include/linux/slab.h:481 [inline] __kmalloc+0x257/0x330 mm/slub.c:3959 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:682 [inline] qp_host_alloc_queue drivers/misc/vmw_vmci/vmci_queue_pair.c:540 [inline] qp_broker_create drivers/misc/vmw_vmci/vmci_queue_pair.c:1351 [inline] qp_broker_alloc+0x936/0x2740 drivers/misc/vmw_vmci/vmci_queue_pair.c:1739
--- drivers/misc/vmw_vmci/vmci_queue_pair.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/vmw_vmci/vmci_queue_pair.c +3 -0
@@ -537,6 +537,9 @@ static struct vmci_queue *qp_host_alloc_ queue_page_size = num_pages *sizeof (*queue->kernel_if->u.h.page); +if (queue_size + queue_page_size >KMALLOC_MAX_SIZE ) +return NULL ; + queue =kzalloc (queue_size + queue_page_size,GFP_KERNEL );if (queue) { queue->q_header =NULL ;
Greg Kroah-Hartman
maintainerPATCH 658/775 pstore: Fix typo in compression option name
In reply to Greg Kroah-HartmanFrom: Jiri Bohac <[email protected]>
commit 19d8e9149c27b689c6224f5c84b96a159342195a upstream.
Both pstore_compress() and decompress_record() use a mistyped config option name ("PSTORE_COMPRESSION" instead of "PSTORE_COMPRESS"). As a result compression and decompression of pstore records was always disabled.
Use the correct config option name.
--- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/pstore/platform.c +2 -2
@@ -269,7 +269,7 @@ static int pstore_compress(const void *i {int ret; -if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION )) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ))return -EINVAL ; ret =crypto_comp_compress (tfm, in, inlen, out, &outlen);
@@ -671,7 +671,7 @@ static void decompress_record(struct pstint unzipped_len;char *unzipped, *workspace; -if (!IS_ENABLED (CONFIG_PSTORE_COMPRESSION ) || !record->compressed) +if (!IS_ENABLED (CONFIG_PSTORE_COMPRESS ) || !record->compressed)return ;/* Only PSTORE_TYPE_DMESG support compression. */
Greg Kroah-Hartman
maintainerPATCH 659/775 dts64: mt7622: fix slow sd card access
In reply to Greg Kroah-HartmanFrom: Frank Wunderlich <[email protected]>
commit dc2e76175417e69c41d927dba75a966399f18354 upstream.
Fix extreme slow speed (200MB takes ~20 min) on writing sdcard on bananapi-r64 by adding reset-control for mmc1 like it's done for mmc0/emmc.
--- arch/arm64/boot/dts/mediatek/mt7622.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +2 -0
@@ -698,6 +698,8 @@ clocks = <&pericfg CLK_PERI_MSDC30_1_PD>, <&topckgen CLK_TOP_AXI_SEL>; clock-names = "source", "hclk"; + resets = <&pericfg MT7622_PERI_MSDC1_SW_RST>; + reset-names = "hrst"; status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 660/775 arm64: dts: agilex: fix phy interface bit shift for gmac1 and gmac2
In reply to Greg Kroah-HartmanFrom: Dinh Nguyen <[email protected]>
commit b7ff3a447d100c999d9848353ef8a4046831d893 upstream.
The shift for the phy_intf_sel bit in the system manager for gmac1 and gmac2 should be 0.
--- arch/arm64/boot/dts/intel/socfpga_agilex.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/intel/socfpga_agilex.dtsi +2 -2
@@ -166,7 +166,7 @@ rx-fifo-depth = <16384>; snps,multicast-filter-bins = <256>; iommus = <&smmu 2>; - altr,sysmgr-syscon = <&sysmgr 0x48 8>; + altr,sysmgr-syscon = <&sysmgr 0x48 0>; clocks = <&clkmgr AGILEX_EMAC1_CLK>, <&clkmgr AGILEX_EMAC_PTP_CLK>; clock-names = "stmmaceth", "ptp_ref"; status = "disabled";
@@ -184,7 +184,7 @@ rx-fifo-depth = <16384>; snps,multicast-filter-bins = <256>; iommus = <&smmu 3>; - altr,sysmgr-syscon = <&sysmgr 0x4c 16>; + altr,sysmgr-syscon = <&sysmgr 0x4c 0>; clocks = <&clkmgr AGILEX_EMAC2_CLK>, <&clkmgr AGILEX_EMAC_PTP_CLK>; clock-names = "stmmaceth", "ptp_ref"; status = "disabled";
Greg Kroah-Hartman
maintainerPATCH 661/775 staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c
In reply to Greg Kroah-HartmanFrom: Ilya Lipnitskiy <[email protected]>
commit 1f92798cbe7fe923479cff754dd06dd23d352e36 upstream.
Also use KBUILD_MODNAME for module name.
This driver is only used by RALINK MIPS MT7621 SoCs. Tested by building against that target using OpenWrt with Linux 5.10.10.
Fixes the following error:
error: the following would cause module name conflict:
drivers/dma/mediatek/mtk-hsdma.ko drivers/staging/mt7621-dma/mtk-hsdma.ko
---
drivers/staging/mt7621-dma/Makefile | 2
drivers/staging/mt7621-dma/hsdma-mt7621.c | 760 ++++++++++++++++++++++++++++++
drivers/staging/mt7621-dma/mtk-hsdma.c | 760 ------------------------------
3 files changed, 761 insertions(+), 761 deletions(-)
rename drivers/staging/mt7621-dma/{mtk-hsdma.c => hsdma-mt7621.c} (99%)drivers/staging/mt7621-dma/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o +obj-$(CONFIG_MTK_HSDMA) += hsdma-mt7621.o ccflags-y += -I$(srctree)/drivers/dma
drivers/staging/mt7621-dma/hsdma-mt7621.c new file +760 -0
760 lines not on this page · raw message
drivers/staging/mt7621-dma/mtk-hsdma.c deleted +0 -760
760 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 662/775 staging: gdm724x: Fix DMA from stack
In reply to Greg Kroah-HartmanFrom: Amey Narkhede <[email protected]>
commit 7c3a0635cd008eaca9a734dc802709ee0b81cac5 upstream.
Stack allocated buffers cannot be used for DMA on all architectures so allocate hci_packet buffer using kmalloc.
--- drivers/staging/gdm724x/gdm_usb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/staging/gdm724x/gdm_usb.c +7 -3
@@ -56,20 +56,24 @@ static int gdm_usb_recv(void *priv_dev,static int request_mac_address (struct lte_udev *udev) { -u8 buf[16 ] = {0 ,}; -struct hci_packet *hci = (struct hci_packet *)buf; +struct hci_packet *hci;struct usb_device *usbdev = udev->usbdev;int actual;int ret =-1 ; + hci =kmalloc (struct_size (hci, data,1 ),GFP_KERNEL ); +if (!hci) +return -ENOMEM ; + hci->cmd_evt =gdm_cpu_to_dev16 (udev->gdm_ed,LTE_GET_INFORMATION ); hci->len =gdm_cpu_to_dev16 (udev->gdm_ed,1 ); hci->data[0 ] =MAC_ADDRESS ; - ret =usb_bulk_msg (usbdev,usb_sndbulkpipe (usbdev,2 ), buf,5 , + ret =usb_bulk_msg (usbdev,usb_sndbulkpipe (usbdev,2 ), hci,5 , &actual,1000 ); udev->request_mac_addr =1 ; +kfree (hci);return ret; }
Greg Kroah-Hartman
maintainerPATCH 663/775 staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table
In reply to Greg Kroah-HartmanFrom: Martin Kaiser <[email protected]>
commit 7a8d2f1908a59003e55ef8691d09efb7fbc51625 upstream.
The Edimax EW-7811UN V2 uses an RTL8188EU chipset and works with this driver.
--- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8188eu/os_dep/usb_intf.c +1 -0
@@ -41,6 +41,7 @@ static const struct usb_device_id rtw_us {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */ {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */ {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ + {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811UN V2 */ {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ {} /* Terminating entry */ };
Greg Kroah-Hartman
maintainerPATCH 664/775 floppy: reintroduce O_NDELAY fix
In reply to Greg Kroah-HartmanFrom: Jiri Kosina <[email protected]>
commit 8a0c014cd20516ade9654fc13b51345ec58e7be8 upstream.
This issue was originally fixed in 09954bad4 ("floppy: refactor open() flags handling").
The fix as a side-effect, however, introduce issue for open(O_ACCMODE) that is being used for ioctl-only open. I wrote a fix for that, but instead of it being merged, full revert of 09954bad4 was performed, re-introducing the O_NDELAY / O_NONBLOCK issue, and it strikes again.
This is a forward-port of the original fix to current codebase; the original submission had the changelog below:
====
Commit 09954bad4 ("floppy: refactor open() flags handling"), as a side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that this is being used setfdprm userspace for ioctl-only open().
Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE) modes, while still keeping the original O_NDELAY bug fixed.
--- drivers/block/floppy.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/block/floppy.c +15 -15
@@ -4121,23 +4121,23 @@ static int floppy_open(struct block_deviif (fdc_state[FDC (drive)].rawcmd ==1 ) fdc_state[FDC (drive)].rawcmd =2 ; -if (!(mode &FMODE_NDELAY )) { -if (mode & (FMODE_READ |FMODE_WRITE )) { - drive_state[drive].last_checked =0 ; -clear_bit (FD_OPEN_SHOULD_FAIL_BIT , - &drive_state[drive].flags); -if (bdev_check_media_change (bdev)) -floppy_revalidate (bdev->bd_disk); -if (test_bit (FD_DISK_CHANGED_BIT , &drive_state[drive].flags)) - goto out; -if (test_bit (FD_OPEN_SHOULD_FAIL_BIT , &drive_state[drive].flags)) - goto out; - } - res = -EROFS ; -if ((mode &FMODE_WRITE ) && - !test_bit (FD_DISK_WRITABLE_BIT , &drive_state[drive].flags)) +if (mode & (FMODE_READ |FMODE_WRITE )) { + drive_state[drive].last_checked =0 ; +clear_bit (FD_OPEN_SHOULD_FAIL_BIT , &drive_state[drive].flags); +if (bdev_check_media_change (bdev)) +floppy_revalidate (bdev->bd_disk); +if (test_bit (FD_DISK_CHANGED_BIT , &drive_state[drive].flags)) + goto out; +if (test_bit (FD_OPEN_SHOULD_FAIL_BIT , &drive_state[drive].flags)) goto out; } + + res = -EROFS ; + +if ((mode &FMODE_WRITE ) && + !test_bit (FD_DISK_WRITABLE_BIT , &drive_state[drive].flags)) + goto out; +mutex_unlock (&open_lock);mutex_unlock (&floppy_mutex);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 665/775 media: i2c: max9286: fix access to unallocated memory
In reply to Greg Kroah-HartmanFrom: Tomi Valkeinen <[email protected]>
commit e88ccf09e79cf33cac40316ba69c820d9eebc82b upstream.
The asd allocated with v4l2_async_notifier_add_fwnode_subdev() must be of size max9286_asd, otherwise access to max9286_asd->source will go to unallocated memory.
--- drivers/media/i2c/max9286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/max9286.c +1 -1
@@ -580,7 +580,7 @@ static int max9286_v4l2_notifier_registe asd =v4l2_async_notifier_add_fwnode_subdev (&priv->notifier, source->fwnode, -sizeof (*asd)); +sizeof (struct max9286_asd ));if (IS_ERR (asd)) {dev_err (dev,"Failed to add subdev for source %u: %ld" , i,PTR_ERR (asd));
Greg Kroah-Hartman
maintainerPATCH 666/775 media: v4l: ioctl: Fix memory leak in video_usercopy
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit fb18802a338b36f675a388fc03d2aa504a0d0899 upstream.
When an IOCTL with argument size larger than 128 that also used array arguments were handled, two memory allocations were made but alas, only the latter one of them was released. This happened because there was only a single local variable to hold such a temporary allocation.
Fix this by adding separate variables to hold the pointers to the temporary allocations.
--- drivers/media/v4l2-core/v4l2-ioctl.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/media/v4l2-core/v4l2-ioctl.c +14 -18
@@ -3283,7 +3283,7 @@ video_usercopy(struct file *file, unsign v4l2_kioctl func) {char sbuf[128 ]; -void *mbuf =NULL ; +void *mbuf =NULL , *array_buf =NULL ;void *parg = (void *)arg;long err = -EINVAL ;bool has_array_args;
@@ -3318,27 +3318,21 @@ video_usercopy(struct file *file, unsign has_array_args = err;if (has_array_args) { -/* -* When adding new types of array args, make sure that the -* parent argument to ioctl (which contains the pointer to the -* array) fits into sbuf (so that mbuf will still remain -* unused up to here). -*/ - mbuf =kvmalloc (array_size,GFP_KERNEL ); + array_buf =kvmalloc (array_size,GFP_KERNEL ); err = -ENOMEM ; -if (NULL == mbuf) +if (array_buf ==NULL ) goto out_array_args; err = -EFAULT ;if (in_compat_syscall ()) - err =v4l2_compat_get_array_args (file, mbuf, user_ptr, - array_size, orig_cmd, - parg); + err =v4l2_compat_get_array_args (file, array_buf, + user_ptr, array_size, + orig_cmd, parg);else - err =copy_from_user (mbuf, user_ptr, array_size) ? + err =copy_from_user (array_buf, user_ptr, array_size) ? -EFAULT :0 ;if (err) goto out_array_args; - *kernel_ptr = mbuf; + *kernel_ptr = array_buf; }/* Handles IOCTL */
@@ -3360,12 +3354,13 @@ video_usercopy(struct file *file, unsignif (in_compat_syscall ()) {int put_err; - put_err =v4l2_compat_put_array_args (file, user_ptr, mbuf, - array_size, orig_cmd, - parg); + put_err =v4l2_compat_put_array_args (file, user_ptr, + array_buf, + array_size, + orig_cmd, parg);if (put_err) err = put_err; - }else if (copy_to_user (user_ptr, mbuf, array_size)) { + }else if (copy_to_user (user_ptr, array_buf, array_size)) { err = -EFAULT ; } goto out_array_args;
@@ -3381,6 +3376,7 @@ out_array_args:if (video_put_user ((void __user *)arg, parg, cmd, orig_cmd)) err = -EFAULT ; out: +kvfree (array_buf);kvfree (mbuf);return err; }
Greg Kroah-Hartman
maintainerPATCH 667/775 media: ir_toy: add another IR Droid device
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 4487e0215560392bd11c9de08d60824d72c89cd9 upstream.
This device is also supported.
--- drivers/media/rc/ir_toy.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/rc/ir_toy.c +1 -0
@@ -491,6 +491,7 @@ static void irtoy_disconnect(struct usb_static const struct usb_device_id irtoy_table[] = { {USB_DEVICE_INTERFACE_CLASS (0x04d8 ,0xfd08 ,USB_CLASS_CDC_DATA ) }, + {USB_DEVICE_INTERFACE_CLASS (0x04d8 ,0xf58b ,USB_CLASS_CDC_DATA ) }, { } };
Greg Kroah-Hartman
maintainerPATCH 668/775 media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt()
In reply to Greg Kroah-HartmanFrom: Pavel Machek <[email protected]>
commit 334de4b45892f7e67074e1b1b2ac36fd3e091118 upstream.
Loop was useless as it would always exit on the first iteration. Fix it with right condition.
--- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/ipu3-cio2.c +1 -1
@@ -1269,7 +1269,7 @@ static int cio2_subdev_set_fmt(struct v4 fmt->format.code = formats[0 ].mbus_code;for (i =0 ; i <ARRAY_SIZE (formats); i++) { -if (formats[i].mbus_code == fmt->format.code) { +if (formats[i].mbus_code == mbus_code) { fmt->format.code = mbus_code;break ; }
Greg Kroah-Hartman
maintainerPATCH 669/775 media: marvell-ccic: power up the device on mclk enable
In reply to Greg Kroah-HartmanFrom: Lubomir Rintel <[email protected]>
commit 655ae29da72a693cf294bba3c3322e662ff75bd3 upstream.
Writing to REG_CLKCTRL with the power off causes a hang. Enable the device first.
--- drivers/media/platform/marvell-ccic/mcam-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/marvell-ccic/mcam-core.c +2 -0
@@ -931,6 +931,7 @@ static int mclk_enable(struct clk_hw *hw mclk_div =2 ; } +pm_runtime_get_sync (cam->dev);clk_enable (cam->clk[0 ]);mcam_reg_write (cam,REG_CLKCTRL , (mclk_src <<29 ) | mclk_div);mcam_ctlr_power_up (cam);
@@ -944,6 +945,7 @@ static void mclk_disable(struct clk_hw *mcam_ctlr_power_down (cam);clk_disable (cam->clk[0 ]); +pm_runtime_put (cam->dev); } static unsigned long mclk_recalc_rate(struct clk_hw *hw,
Greg Kroah-Hartman
maintainerPATCH 670/775 media: smipcie: fix interrupt handling and IR timeout
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 6532923237b427ed30cc7b4486f6f1ccdee3c647 upstream.
After the first IR message, interrupts are no longer received. In addition, the code generates a timeout IR message of 10ms but sets the timeout value to 100ms, so no timeout was ever generated.
--- drivers/media/pci/smipcie/smipcie-ir.c | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-)
drivers/media/pci/smipcie/smipcie-ir.c +27 -21
@@ -60,38 +60,44 @@ static void smi_ir_decode(struct smi_rc {struct smi_dev *dev = ir->dev;struct rc_dev *rc_dev = ir->rc_dev; -u32 dwIRControl, dwIRData; -u8 index, ucIRCount, readLoop; +u32 control, data; +u8 index, ir_count, read_loop; - dwIRControl =smi_read (IR_Init_Reg); + control =smi_read (IR_Init_Reg); -if (dwIRControl & rbIRVld) { - ucIRCount = (u8 )smi_read (IR_Data_Cnt); +dev_dbg (&rc_dev->dev,"ircontrol: 0x%08x\n" , control); - readLoop = ucIRCount/4 ; -if (ucIRCount %4 ) - readLoop +=1 ; -for (index =0 ; index < readLoop; index++) { - dwIRData =smi_read (IR_DATA_BUFFER_BASE + (index *4 )); - - ir->irData[index*4 +0 ] = (u8)(dwIRData); - ir->irData[index*4 +1 ] = (u8)(dwIRData >>8 ); - ir->irData[index*4 +2 ] = (u8)(dwIRData >>16 ); - ir->irData[index*4 +3 ] = (u8)(dwIRData >>24 ); +if (control & rbIRVld) { + ir_count = (u8 )smi_read (IR_Data_Cnt); + +dev_dbg (&rc_dev->dev,"ircount %d\n" , ir_count); + + read_loop = ir_count /4 ; +if (ir_count %4 ) + read_loop +=1 ; +for (index =0 ; index < read_loop; index++) { + data =smi_read (IR_DATA_BUFFER_BASE + (index *4 )); +dev_dbg (&rc_dev->dev,"IRData 0x%08x\n" , data); + + ir->irData[index *4 +0 ] = (u8)(data); + ir->irData[index *4 +1 ] = (u8)(data >>8 ); + ir->irData[index *4 +2 ] = (u8)(data >>16 ); + ir->irData[index *4 +3 ] = (u8)(data >>24 ); } -smi_raw_process (rc_dev, ir->irData, ucIRCount); -smi_set (IR_Init_Reg, rbIRVld); +smi_raw_process (rc_dev, ir->irData, ir_count); } -if (dwIRControl & rbIRhighidle) { +if (control & rbIRhighidle) {struct ir_raw_event rawir = {}; +dev_dbg (&rc_dev->dev,"high idle\n" ); + rawir.pulse =0 ; rawir.duration =SMI_SAMPLE_PERIOD *SMI_SAMPLE_IDLEMIN ;ir_raw_event_store_with_filter (rc_dev, &rawir); -smi_set (IR_Init_Reg, rbIRhighidle); } +smi_set (IR_Init_Reg, rbIRVld);ir_raw_event_handle (rc_dev); }
@@ -150,7 +156,7 @@ int smi_ir_init(struct smi_dev *dev) rc_dev->dev.parent = &dev->pci_dev->dev; rc_dev->map_name = dev->info->rc_map; - rc_dev->timeout =MS_TO_US (100 ); + rc_dev->timeout =SMI_SAMPLE_PERIOD *SMI_SAMPLE_IDLEMIN ; rc_dev->rx_resolution =SMI_SAMPLE_PERIOD ; ir->rc_dev = rc_dev;
@@ -173,7 +179,7 @@ void smi_ir_exit(struct smi_dev *dev)struct smi_rc *ir = &dev->ir;struct rc_dev *rc_dev = ir->rc_dev; -smi_ir_stop (ir);rc_unregister_device (rc_dev); +smi_ir_stop (ir); ir->rc_dev =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 671/775 x86/virt: Eat faults on VMXOFF in reboot flows
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit aec511ad153556640fb1de38bfe00c69464f997f upstream.
Silently ignore all faults on VMXOFF in the reboot flows as such faults are all but guaranteed to be due to the CPU not being in VMX root. Because (a) VMXOFF may be executed in NMI context, e.g. after VMXOFF but before CR4.VMXE is cleared, (b) there's no way to query the CPU's VMX state without faulting, and (c) the whole point is to get out of VMX root, eating faults is the simplest way to achieve the desired behaior.
Technically, VMXOFF can fault (or fail) for other reasons, but all other fault and failure scenarios are mode related, i.e. the kernel would have to magically end up in RM, V86, compat mode, at CPL>0, or running with the SMI Transfer Monitor active. The kernel is beyond hosed if any of those scenarios are encountered; trying to do something fancy in the error path to handle them cleanly is pointless.
Message-Id: <[email protected]>
--- arch/x86/include/asm/virtext.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
arch/x86/include/asm/virtext.h +12 -5
@@ -30,15 +30,22 @@ static inline int cpu_has_vmx(void) } -/** Disable VMX on the current CPU +/** +* cpu_vmxoff() - Disable VMX on the current CPU * -* vmxoff causes a undefined-opcode exception if vmxon was not run -* on the CPU previously. Only call this function if you know VMX -* is enabled. +* Disable VMX and clear CR4.VMXE (even if VMXOFF faults) +* +* Note, VMXOFF causes a #UD if the CPU is !post-VMXON, but it's impossible to +* atomically track post-VMXON state, e.g. this may be called in NMI context. +* Eat all faults as all other faults on VMXOFF faults are mode related, i.e. +* faults are guaranteed to be due to the !post-VMXON check unless the CPU is +* magically in RM, VM86, compat mode, or at CPL>0. */ static inline void cpu_vmxoff (void ) { - asmvolatile ("vmxoff" ); +asm_volatile_goto ("1: vmxoff\n\t" + _ASM_EXTABLE(1b, %l[fault]) :::: fault); +fault:cr4_clear_bits (X86_CR4_VMXE ); }
Greg Kroah-Hartman
maintainerPATCH 672/775 x86/reboot: Force all cpus to exit VMX root if VMX is supported
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit ed72736183c45a413a8d6974dd04be90f514cb6b upstream.
Force all CPUs to do VMXOFF (via NMI shootdown) during an emergency reboot if VMX is _supported_, as VMX being off on the current CPU does not prevent other CPUs from being in VMX root (post-VMXON). This fixes a bug where a crash/panic reboot could leave other CPUs in VMX root and prevent them from being woken via INIT-SIPI-SIPI in the new kernel.
Message-Id: <[email protected]>
--- arch/x86/kernel/reboot.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
arch/x86/kernel/reboot.c +10 -20
@@ -538,31 +538,21 @@ static void emergency_vmx_disable_all(volocal_irq_disable ();/* -* We need to disable VMX on all CPUs before rebooting, otherwise -* we risk hanging up the machine, because the CPU ignores INIT -* signals when VMX is enabled. +* Disable VMX on all CPUs before rebooting, otherwise we risk hanging +* the machine, because the CPU blocks INIT when it's in VMX root. * -* We can't take any locks and we may be on an inconsistent -* state, so we use NMIs as IPIs to tell the other CPUs to disable -* VMX and halt. +* We can't take any locks and we may be on an inconsistent state, so +* use NMIs as IPIs to tell the other CPUs to exit VMX root and halt. * -* For safety, we will avoid running the nmi_shootdown_cpus() -* stuff unnecessarily, but we don't have a way to check -* if other CPUs have VMX enabled. So we will call it only if the -* CPU we are running on has VMX enabled. -* -* We will miss cases where VMX is not enabled on all CPUs. This -* shouldn't do much harm because KVM always enable VMX on all -* CPUs anyway. But we can miss it on the small window where KVM -* is still enabling VMX. +* Do the NMI shootdown even if VMX if off on _this_ CPU, as that +* doesn't prevent a different CPU from being in VMX root operation. */ -if (cpu_has_vmx () &&cpu_vmx_enabled ()) { -/* Disable VMX on this CPU. */ -cpu_vmxoff (); +if (cpu_has_vmx ()) { +/* Safely force _this_ CPU out of VMX root operation. */ +__cpu_emergency_vmxoff (); -/* Halt and disable VMX on the other CPUs */ +/* Halt and exit VMX root operation on the other CPUs. */ nmi_shootdown_cpus (vmxoff_nmi); - } }
Greg Kroah-Hartman
maintainerPATCH 673/775 x86/fault: Fix AMD erratum #91 errata fixup for user code
In reply to Greg Kroah-HartmanFrom: Andy Lutomirski <[email protected]>
commit 35f1c89b0cce247bf0213df243ed902989b1dcda upstream.
The recent rework of probe_kernel_address() and its conversion to get_kernel_nofault() inadvertently broke is_prefetch(). Before this change, probe_kernel_address() was used as a sloppy "read user or kernel memory" helper, but it doesn't do that any more. The new get_kernel_nofault() reads *kernel* memory only, which completely broke is_prefetch() for user access.
Adjust the code to the correct accessor based on access mode. The manual address bounds check is no longer necessary, since the accessor helpers (get_user() / get_kernel_nofault()) do the right thing all by themselves. As a bonus, by using the correct accessor, the open-coded address bounds check is not needed anymore.
[ bp: Massage commit message. ]
--- arch/x86/mm/fault.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
arch/x86/mm/fault.c +17 -10
@@ -54,7 +54,7 @@ kmmio_fault(struct pt_regs *regs, unsign* 32-bit mode: * * Sometimes AMD Athlon/Opteron CPUs report invalid exceptions on prefetch. -* Check that here and ignore it. +* Check that here and ignore it. This is AMD erratum #91. * * 64-bit mode: *
@@ -83,11 +83,7 @@ check_prefetch_opcode(struct pt_regs *re#ifdef CONFIG_X86_64 case 0x40 :/* -* In AMD64 long mode 0x40..0x4F are valid REX prefixes -* Need to figure out under what instruction mode the -* instruction was issued. Could check the LDT for lm, -* but for now it's good enough to assume that long -* mode only uses well known segments or kernel. +* In 64-bit mode 0x40..0x4F are valid REX prefixes */ return (!user_mode (regs) ||user_64bit_mode (regs));#endif
@@ -127,20 +123,31 @@ is_prefetch(struct pt_regs *regs, unsign instr = (void *)convert_ip_to_linear (current, regs); max_instr = instr +15 ; -if (user_mode (regs) && instr >= (unsigned char *)TASK_SIZE_MAX ) -return 0 ; +/* +* This code has historically always bailed out if IP points to a +* not-present page (e.g. due to a race). No one has ever +* complained about this. +*/ +pagefault_disable ();while (instr < max_instr) {unsigned char opcode; -if (get_kernel_nofault (opcode, instr)) -break ; +if (user_mode (regs)) { +if (get_user (opcode, instr)) +break ; + }else { +if (get_kernel_nofault (opcode, instr)) +break ; + } instr++;if (!check_prefetch_opcode (regs, instr, opcode, &prefetch))break ; } + +pagefault_enable ();return prefetch; }
Greg Kroah-Hartman
maintainerPATCH 674/775 x86/entry: Fix instrumentation annotation
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 15f720aabe71a5662c4198b22532d95bbeec80ef upstream.
Embracing a callout into instrumentation_begin() / instrumentation_begin() does not really make sense. Make the latter instrumentation_end().
--- arch/x86/entry/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/common.c +1 -1
@@ -270,7 +270,7 @@ __visible noinstr void xen_pv_evtchn_do_instrumentation_begin ();run_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); -instrumentation_begin (); +instrumentation_end ();set_irq_regs (old_regs);
Greg Kroah-Hartman
maintainerPATCH 675/775 powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan
In reply to Greg Kroah-HartmanFrom: Cédric Le Goater <[email protected]>
commit ed5b00a05c2ae95b59adc3442f45944ec632e794 upstream.
The "ibm,arch-vec-5-platform-support" property is a list of pairs of bytes representing the options and values supported by the platform firmware. At boot time, Linux scans this list and activates the available features it recognizes : Radix and XIVE.
A recent change modified the number of entries to loop on and 8 bytes, 4 pairs of { options, values } entries are always scanned. This is fine on KVM but not on PowerVM which can advertises less. As a consequence on this platform, Linux reads extra entries pointing to random data, interprets these as available features and tries to activate them, leading to a firmware crash in ibm,client-architecture-support.
Fix that by using the property length of "ibm,arch-vec-5-platform-support".
--- arch/powerpc/kernel/prom_init.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/powerpc/kernel/prom_init.c +4 -8
@@ -1331,14 +1331,10 @@ static void __init prom_check_platform_sif (prop_len >sizeof (vec))prom_printf ("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n" , prop_len); -prom_getprop (prom.chosen,"ibm,arch-vec-5-platform-support" , - &vec,sizeof (vec)); -for (i =0 ; i <sizeof (vec); i +=2 ) { -prom_debug ("%d: index = 0x%x val = 0x%x\n" , i /2 - , vec[i] - , vec[i +1 ]); -prom_parse_platform_support (vec[i], vec[i +1 ], - &supported); +prom_getprop (prom.chosen,"ibm,arch-vec-5-platform-support" , &vec,sizeof (vec)); +for (i =0 ; i < prop_len; i +=2 ) { +prom_debug ("%d: index = 0x%x val = 0x%x\n" , i /2 , vec[i], vec[i +1 ]); +prom_parse_platform_support (vec[i], vec[i +1 ], &supported); } }
Greg Kroah-Hartman
maintainerPATCH 676/775 rcu: Pull deferred rcuog wake up to rcu_eqs_enter() callers
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 54b7429efffc99e845ba9381bee3244f012a06c2 upstream.
Deferred wakeup of rcuog kthreads upon RCU idle mode entry is going to be handled differently whether initiated by idle, user or guest. Prepare with pulling that control up to rcu_eqs_enter() callers.
--- kernel/rcu/tree.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
kernel/rcu/tree.c +10 -1
@@ -644,7 +644,6 @@ static noinstr void rcu_eqs_enter(bool utrace_rcu_dyntick (TPS ("Start" ), rdp->dynticks_nesting,0 ,atomic_read (&rdp->dynticks));WARN_ON_ONCE (IS_ENABLED (CONFIG_RCU_EQS_DEBUG ) && !user && !is_idle_task (current)); rdp =this_cpu_ptr (&rcu_data); -do_nocb_deferred_wakeup (rdp);rcu_prepare_for_idle ();rcu_preempt_deferred_qs (current);
@@ -672,7 +671,10 @@ static noinstr void rcu_eqs_enter(bool u*/ void rcu_idle_enter (void ) { +struct rcu_data *rdp =this_cpu_ptr (&rcu_data); +lockdep_assert_irqs_disabled (); +do_nocb_deferred_wakeup (rdp);rcu_eqs_enter (false); }EXPORT_SYMBOL_GPL (rcu_idle_enter);
@@ -691,7 +693,14 @@ EXPORT_SYMBOL_GPL(rcu_idle_enter);*/ noinstr void rcu_user_enter(void) { +struct rcu_data *rdp =this_cpu_ptr (&rcu_data); +lockdep_assert_irqs_disabled (); + +instrumentation_begin (); +do_nocb_deferred_wakeup (rdp); +instrumentation_end (); +rcu_eqs_enter (true); }#endif /* CONFIG_NO_HZ_FULL */
Greg Kroah-Hartman
maintainerPATCH 677/775 rcu/nocb: Perform deferred wake up before last idles need_resched() check
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 43789ef3f7d61aa7bed0cb2764e588fc990c30ef upstream.
Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced.
Usually a local wake up happening while running the idle task is handled in one of the need_resched() checks carefully placed within the idle loop that can break to the scheduler.
Unfortunately the call to rcu_idle_enter() is already beyond the last generic need_resched() check and we may halt the CPU with a resched request unhandled, leaving the task hanging.
Fix this with splitting the rcuog wakeup handling from rcu_idle_enter() and place it before the last generic need_resched() check in the idle loop. It is then assumed that no call to call_rcu() will be performed after that in the idle loop until the CPU is put in low power mode.
--- include/linux/rcupdate.h | 2 ++ kernel/rcu/tree.c | 3 --- kernel/rcu/tree_plugin.h | 5 +++++ kernel/sched/idle.c | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
include/linux/rcupdate.h +2 -0
@@ -110,8 +110,10 @@ static inline void rcu_user_exit(void) {#ifdef CONFIG_RCU_NOCB_CPU void rcu_init_nohz (void ); +void rcu_nocb_flush_deferred_wakeup (void );#else /* #ifdef CONFIG_RCU_NOCB_CPU */ static inline void rcu_init_nohz (void ) { } +static inline void rcu_nocb_flush_deferred_wakeup (void ) { }#endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ /**
kernel/rcu/tree.c +0 -3
@@ -671,10 +671,7 @@ static noinstr void rcu_eqs_enter(bool u*/ void rcu_idle_enter (void ) { -struct rcu_data *rdp =this_cpu_ptr (&rcu_data); -lockdep_assert_irqs_disabled (); -do_nocb_deferred_wakeup (rdp);rcu_eqs_enter (false); }EXPORT_SYMBOL_GPL (rcu_idle_enter);
kernel/rcu/tree_plugin.h +5 -0
@@ -2187,6 +2187,11 @@ static void do_nocb_deferred_wakeup(strudo_nocb_deferred_wakeup_common (rdp); } +void rcu_nocb_flush_deferred_wakeup (void ) +{ +do_nocb_deferred_wakeup (this_cpu_ptr (&rcu_data)); +} +void __init rcu_init_nohz (void ) {int cpu;
kernel/sched/idle.c +1 -0
@@ -285,6 +285,7 @@ static void do_idle(void) }arch_cpu_idle_enter (); +rcu_nocb_flush_deferred_wakeup ();/* * In poll mode we reenable interrupts and spin. Also if we
Greg Kroah-Hartman
maintainerPATCH 678/775 rcu/nocb: Trigger self-IPI on late deferred wake up before user resume
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit f8bb5cae9616224a39cbb399de382d36ac41df10 upstream.
Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced.
Unfortunately the call to rcu_user_enter() is already past the last rescheduling opportunity before we resume to userspace or to guest mode. We may escape there with the woken task ignored.
The ultimate resort to fix every callsites is to trigger a self-IPI (nohz_full depends on arch to implement arch_irq_work_raise()) that will trigger a reschedule on IRQ tail or guest exit.
Eventually every site that want a saner treatment will need to carefully place a call to rcu_nocb_flush_deferred_wakeup() before the last explicit need_resched() check upon resume.
--- kernel/rcu/tree.c | 21 ++++++++++++++++++++- kernel/rcu/tree.h | 2 +- kernel/rcu/tree_plugin.h | 25 ++++++++++++++++--------- 3 files changed, 37 insertions(+), 11 deletions(-)
kernel/rcu/tree.c +20 -1
@@ -677,6 +677,18 @@ void rcu_idle_enter(void)EXPORT_SYMBOL_GPL (rcu_idle_enter);#ifdef CONFIG_NO_HZ_FULL + +/* +* An empty function that will trigger a reschedule on +* IRQ tail once IRQs get re-enabled on userspace resume. +*/ +static void late_wakeup_func (struct irq_work *work) +{ +} + +static DEFINE_PER_CPU(struct irq_work, late_wakeup_work) = +IRQ_WORK_INIT (late_wakeup_func); +/** * rcu_user_enter - inform RCU that we are resuming userspace. *
@@ -694,12 +706,19 @@ noinstr void rcu_user_enter(void)lockdep_assert_irqs_disabled (); +/* +* We may be past the last rescheduling opportunity in the entry code. +* Trigger a self IPI that will fire and reschedule once we resume to +* user/guest mode. +*/ instrumentation_begin (); -do_nocb_deferred_wakeup (rdp); +if (do_nocb_deferred_wakeup (rdp) &&need_resched ()) +irq_work_queue (this_cpu_ptr (&late_wakeup_work));instrumentation_end (); rcu_eqs_enter(true); } +#endif /* CONFIG_NO_HZ_FULL */ /**
kernel/rcu/tree.h +1 -1
@@ -433,7 +433,7 @@ static bool rcu_nocb_try_bypass(struct rstatic void __call_rcu_nocb_wake (struct rcu_data *rdp,bool was_empty,unsigned long flags);static int rcu_nocb_need_deferred_wakeup (struct rcu_data *rdp); -static void do_nocb_deferred_wakeup (struct rcu_data *rdp); +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp);static void rcu_boot_init_nocb_percpu_data (struct rcu_data *rdp);static void rcu_spawn_cpu_nocb_kthread (int cpu);static void __init rcu_spawn_nocb_kthreads (void );
kernel/rcu/tree_plugin.h +16 -9
@@ -1631,8 +1631,8 @@ bool rcu_is_nocb_cpu(int cpu)* Kick the GP kthread for this NOCB group. Caller holds ->nocb_lock * and this function releases it. */ -static void wake_nocb_gp (struct rcu_data *rdp,bool force, -unsigned long flags) +static bool wake_nocb_gp (struct rcu_data *rdp,bool force, +unsigned long flags) __releases(rdp->nocb_lock) {bool needwake = false;
@@ -1643,7 +1643,7 @@ static void wake_nocb_gp(struct rcu_datatrace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("AlreadyAwake" ));rcu_nocb_unlock_irqrestore (rdp, flags); -return ; +return false; }del_timer (&rdp->nocb_timer);rcu_nocb_unlock_irqrestore (rdp, flags);
@@ -1656,6 +1656,8 @@ static void wake_nocb_gp(struct rcu_dataraw_spin_unlock_irqrestore (&rdp_gp->nocb_gp_lock, flags);if (needwake)wake_up_process (rdp_gp->nocb_gp_kthread); + +return needwake; }/*
@@ -2152,20 +2154,23 @@ static int rcu_nocb_need_deferred_wakeup }/* Do a deferred wakeup of rcu_nocb_kthread(). */ -static void do_nocb_deferred_wakeup_common (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup_common (struct rcu_data *rdp) {unsigned long flags;int ndw; +int ret;rcu_nocb_lock_irqsave (rdp, flags);if (!rcu_nocb_need_deferred_wakeup (rdp)) {rcu_nocb_unlock_irqrestore (rdp, flags); -return ; +return false; } ndw =READ_ONCE (rdp->nocb_defer_wakeup);WRITE_ONCE (rdp->nocb_defer_wakeup,RCU_NOCB_WAKE_NOT ); -wake_nocb_gp (rdp, ndw ==RCU_NOCB_WAKE_FORCE , flags); + ret =wake_nocb_gp (rdp, ndw ==RCU_NOCB_WAKE_FORCE , flags);trace_rcu_nocb_wake (rcu_state.name, rdp->cpu,TPS ("DeferredWake" )); + +return ret; }/* Do a deferred wakeup of rcu_nocb_kthread() from a timer handler. */
@@ -2181,10 +2186,11 @@ static void do_nocb_deferred_wakeup_time* This means we do an inexact common-case check. Note that if * we miss, ->nocb_timer will eventually clean things up. */ -static void do_nocb_deferred_wakeup (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp) {if (rcu_nocb_need_deferred_wakeup (rdp)) -do_nocb_deferred_wakeup_common (rdp); +return do_nocb_deferred_wakeup_common (rdp); +return false; }void rcu_nocb_flush_deferred_wakeup (void )
@@ -2523,8 +2529,9 @@ static int rcu_nocb_need_deferred_wakeupreturn false; } -static void do_nocb_deferred_wakeup (struct rcu_data *rdp) +static bool do_nocb_deferred_wakeup (struct rcu_data *rdp) { +return false; }static void rcu_spawn_cpu_nocb_kthread (int cpu)
Greg Kroah-Hartman
maintainerPATCH 679/775 entry: Explicitly flush pending rcuog wakeup before last rescheduling point
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 47b8ff194c1fd73d58dc339b597d466fe48c8958 upstream.
Following the idle loop model, cleanly check for pending rcuog wakeup before the last rescheduling point on resuming to user mode. This way we can avoid to do it from rcu_user_enter() with the last resort self-IPI hack that enforces rescheduling.
--- kernel/entry/common.c | 7 +++++++ kernel/rcu/tree.c | 12 +++++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
kernel/entry/common.c +7 -0
@@ -184,6 +184,10 @@ static unsigned long exit_to_user_mode_l* enabled above. */ local_irq_disable_exit_to_user (); + +/* Check if any of the above work has queued a deferred wakeup */ +rcu_nocb_flush_deferred_wakeup (); + ti_work =READ_ONCE (current_thread_info ()->flags); }
@@ -197,6 +201,9 @@ static void exit_to_user_mode_prepare(stlockdep_assert_irqs_disabled (); +/* Flush pending rcuog wakeup before the last need_resched() check */ +rcu_nocb_flush_deferred_wakeup (); +if (unlikely (ti_work &EXIT_TO_USER_MODE_WORK )) ti_work =exit_to_user_mode_loop (regs, ti_work);
kernel/rcu/tree.c +7 -5
@@ -707,13 +707,15 @@ noinstr void rcu_user_enter(void)lockdep_assert_irqs_disabled ();/* -* We may be past the last rescheduling opportunity in the entry code. -* Trigger a self IPI that will fire and reschedule once we resume to -* user/guest mode. +* Other than generic entry implementation, we may be past the last +* rescheduling opportunity in the entry code. Trigger a self IPI +* that will fire and reschedule once we resume in user/guest mode. */ instrumentation_begin (); -if (do_nocb_deferred_wakeup (rdp) &&need_resched ()) -irq_work_queue (this_cpu_ptr (&late_wakeup_work)); +if (!IS_ENABLED (CONFIG_GENERIC_ENTRY ) || (current->flags &PF_VCPU )) { +if (do_nocb_deferred_wakeup (rdp) &&need_resched ()) +irq_work_queue (this_cpu_ptr (&late_wakeup_work)); + }instrumentation_end ();rcu_eqs_enter (true);
Greg Kroah-Hartman
maintainerPATCH 680/775 entry/kvm: Explicitly flush pending rcuog wakeup before last rescheduling point
In reply to Greg Kroah-HartmanFrom: Frederic Weisbecker <[email protected]>
commit 4ae7dc97f726ea95c58ac58af71cc034ad22d7de upstream.
Following the idle loop model, cleanly check for pending rcuog wakeup before the last rescheduling point upon resuming to guest mode. This way we can avoid to do it from rcu_user_enter() with the last resort self-IPI hack that enforces rescheduling.
--- arch/x86/kvm/x86.c | 1 + include/linux/entry-kvm.h | 14 ++++++++++++++ kernel/rcu/tree.c | 44 ++++++++++++++++++++++++++++++++++---------- kernel/rcu/tree_plugin.h | 1 + 4 files changed, 50 insertions(+), 10 deletions(-)
arch/x86/kvm/x86.c +1 -0
@@ -1782,6 +1782,7 @@ EXPORT_SYMBOL_GPL(kvm_emulate_wrmsr);bool kvm_vcpu_exit_request (struct kvm_vcpu *vcpu) { +xfer_to_guest_mode_prepare ();return vcpu->mode ==EXITING_GUEST_MODE ||kvm_request_pending (vcpu) ||xfer_to_guest_mode_work_pending (); }
include/linux/entry-kvm.h +14 -0
@@ -47,6 +47,20 @@ static inline int arch_xfer_to_guest_modint xfer_to_guest_mode_handle_work (struct kvm_vcpu *vcpu);/** +* xfer_to_guest_mode_prepare - Perform last minute preparation work that +* need to be handled while IRQs are disabled +* upon entering to guest. +* +* Has to be invoked with interrupts disabled before the last call +* to xfer_to_guest_mode_work_pending(). +*/ +static inline void xfer_to_guest_mode_prepare (void ) +{ +lockdep_assert_irqs_disabled (); +rcu_nocb_flush_deferred_wakeup (); +} + +/** * __xfer_to_guest_mode_work_pending - Check if work is pending * * Returns: True if work pending, False otherwise.
kernel/rcu/tree.c +34 -10
70 lines not on this page · raw message
kernel/rcu/tree_plugin.h +1 -0
@@ -2197,6 +2197,7 @@ void rcu_nocb_flush_deferred_wakeup(void {do_nocb_deferred_wakeup (this_cpu_ptr (&rcu_data)); } +EXPORT_SYMBOL_GPL (rcu_nocb_flush_deferred_wakeup);void __init rcu_init_nohz (void ) {
Greg Kroah-Hartman
maintainerPATCH 681/775 kprobes: Fix to delay the kprobes jump optimization
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
commit c85c9a2c6e368dc94907e63babb18a9788e5c9b6 upstream.
Commit 36dadef23fcc ("kprobes: Init kprobes in early_initcall") moved the kprobe setup in early_initcall(), which includes kprobe jump optimization.
The kprobes jump optimizer involves synchronize_rcu_tasks() which depends on the ksoftirqd and rcu_spawn_tasks_*(). However, since those are setup in core_initcall(), kprobes jump optimizer can not run at the early_initcall().
To avoid this issue, make the kprobe optimization disabled in the early_initcall() and enables it in subsys_initcall().
Note that non-optimized kprobes is still available after early_initcall(). Only jump optimization is delayed.
--- kernel/kprobes.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
kernel/kprobes.c +21 -10
@@ -861,7 +861,6 @@ out:cpus_read_unlock (); } -#ifdef CONFIG_SYSCTL static void optimize_all_kprobes (void ) {struct hlist_head *head;
@@ -887,6 +886,7 @@ out:mutex_unlock (&kprobe_mutex); } +#ifdef CONFIG_SYSCTL static void unoptimize_all_kprobes (void ) {struct hlist_head *head;
@@ -2497,18 +2497,14 @@ static int __init init_kprobes(void) } } -#if defined(CONFIG_OPTPROBES ) -#if defined(__ARCH_WANT_KPROBES_INSN_SLOT) -/* Init kprobe_optinsn_slots */ - kprobe_optinsn_slots.insn_size =MAX_OPTINSN_SIZE ; -#endif -/* By default, kprobes can be optimized */ - kprobes_allow_optimization = true; -#endif -/* By default, kprobes are armed */ kprobes_all_disarmed = false; +#if defined(CONFIG_OPTPROBES ) && defined(__ARCH_WANT_KPROBES_INSN_SLOT) +/* Init kprobe_optinsn_slots for allocation */ + kprobe_optinsn_slots.insn_size =MAX_OPTINSN_SIZE ; +#endif + err =arch_init_kprobes ();if (!err) err =register_die_notifier (&kprobe_exceptions_nb);
@@ -2523,6 +2519,21 @@ static int __init init_kprobes(void) }early_initcall (init_kprobes); +#if defined(CONFIG_OPTPROBES ) +static int __init init_optprobes (void ) +{ +/* +* Enable kprobe optimization - this kicks the optimizer which +* depends on synchronize_rcu_tasks() and ksoftirqd, that is +* not spawned in early initcall. So delay the optimization. +*/ +optimize_all_kprobes (); + +return 0 ; +} +subsys_initcall (init_optprobes); +#endif +#ifdef CONFIG_DEBUG_FS static void report_probe (struct seq_file *pi,struct kprobe *p,const char *sym,int offset,char *modname,struct kprobe *pp)
Greg Kroah-Hartman
maintainerPATCH 682/775 arm64: Extend workaround for erratum 1024718 to all versions of Cortex-A55
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit c0b15c25d25171db4b70cc0b7dbc1130ee94017d upstream.
The erratum 1024718 affects Cortex-A55 r0p0 to r2p0. However we apply the work around for r0p0 - r1p0. Unfortunately this won't be fixed for the future revisions for the CPU. Thus extend the work around for all versions of A55, to cover for r2p0 and any future revisions.
--- arch/arm64/Kconfig | 2 +- arch/arm64/kernel/cpufeature.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -522,7 +522,7 @@ config ARM64_ERRATUM_1024718 help This option adds a workaround for ARM Cortex-A55 Erratum 1024718. - Affected Cortex-A55 cores (r0p0, r0p1, r1p0) could cause incorrect + Affected Cortex-A55 cores (all revisions) could cause incorrect update of the hardware dirty bit when the DBM/AP bits are updated without a break-before-make. The workaround is to disable the usage of hardware DBM locally on the affected cores. CPUs not affected by
arch/arm64/kernel/cpufeature.c +1 -1
@@ -1455,7 +1455,7 @@ static bool cpu_has_broken_dbm(void)/* List of CPUs which have broken DBM support. */ static const struct midr_range cpus[] = { #ifdef CONFIG_ARM64_ERRATUM_1024718 -MIDR_RANGE (MIDR_CORTEX_A55 ,0 ,0 ,1 ,0 ),// A55 r0p0 -r1p0 +MIDR_ALL_VERSIONS (MIDR_CORTEX_A55 ),/* Kryo4xx Silver (rdpe => r1p0) */ MIDR_REV (MIDR_QCOM_KRYO_4XX_SILVER ,0xd ,0xe ), #endif
Greg Kroah-Hartman
maintainerPATCH 683/775 iommu/arm-smmu-qcom: Fix mask extraction for bootloader programmed SMRs
In reply to Greg Kroah-HartmanFrom: Isaac J. Manjarres <[email protected]>
commit dead723e6f049e9fb6b05e5b93456982798ea961 upstream.
When extracting the mask for a SMR that was programmed by the bootloader, the SMR's valid bit is also extracted and is treated as part of the mask, which is not correct. Consider the scenario where an SMMU master whose context is determined by a bootloader programmed SMR is removed (omitting parts of device/driver core):
->iommu_release_device()
-> arm_smmu_release_device()
-> arm_smmu_master_free_smes()
-> arm_smmu_free_sme() /* Assume that the SME is now free */ -> arm_smmu_write_sme()
-> arm_smmu_write_smr() /* Construct SMR value using mask and SID */
Since the valid bit was considered as part of the mask, the SMR will be programmed as valid.
Fix the SMR mask extraction step for bootloader programmed SMRs by masking out the valid bit when we know that we're already working with a valid SMR.
--- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +2 -0
@@ -206,6 +206,8 @@ static int qcom_smmu_cfg_probe(struct ar smr =arm_smmu_gr0_read (smmu,ARM_SMMU_GR0_SMR (i));if (FIELD_GET (ARM_SMMU_SMR_VALID , smr)) { +/* Ignore valid bit for SMR mask extraction. */ + smr &= ~ARM_SMMU_SMR_VALID ; smmu->smrs[i].id =FIELD_GET (ARM_SMMU_SMR_ID , smr); smmu->smrs[i].mask =FIELD_GET (ARM_SMMU_SMR_MASK , smr); smmu->smrs[i].valid = true;
Greg Kroah-Hartman
maintainerPATCH 684/775 mailbox: arm_mhuv2: Skip calling kfree() with invalid pointer
In reply to Greg Kroah-HartmanFrom: Viresh Kumar <[email protected]>
commit 6b50df2b8c208a04d44b8df5b7baaf668ceb8fc3 upstream.
It is possible that 'data' passed to kfree() is set to a error value instead of allocated space. Make sure it doesn't get called with invalid pointer.
--- drivers/mailbox/arm_mhuv2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mailbox/arm_mhuv2.c +3 -1
@@ -699,7 +699,9 @@ static irqreturn_t mhuv2_receiver_interr ret =IRQ_HANDLED ; } -kfree (data); +if (!IS_ERR (data)) +kfree (data); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 685/775 arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails
In reply to Greg Kroah-HartmanFrom: qiuguorui1 <[email protected]>
commit 656d1d58d8e0958d372db86c24f0b2ea36f50888 upstream.
in function create_dtb(), if fdt_open_into() fails, we need to vfree buf before return.
--- arch/arm64/kernel/machine_kexec_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/kernel/machine_kexec_file.c +3 -1
@@ -182,8 +182,10 @@ static int create_dtb(struct kimage *ima/* duplicate a device tree blob */ ret =fdt_open_into (initial_boot_params, buf, buf_size); -if (ret) +if (ret) { +vfree (buf);return -EINVAL ; + } ret =setup_dtb (image, initrd_load_addr, initrd_len, cmdline, buf);
Greg Kroah-Hartman
maintainerPATCH 686/775 arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing
In reply to Greg Kroah-HartmanFrom: He Zhe <[email protected]>
commit d47422d953e258ad587b5edf2274eb95d08bdc7d upstream.
As stated in linux/errno.h, ENOTSUPP should never be seen by user programs. When we set up uprobe with 32-bit perf and arm64 kernel, we would see the following vague error without useful hint.
The sys_perf_event_open() syscall returned with 524 (INTERNAL ERROR:strerror_r(524, [buf], 128)=22)
Use EOPNOTSUPP instead to indicate such cases.
--- arch/arm64/kernel/probes/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/probes/uprobes.c +1 -1
@@ -38,7 +38,7 @@ int arch_uprobe_analyze_insn(struct arch/* TODO: Currently we do not support AARCH32 instruction probing */ if (mm->context.flags &MMCF_AARCH32 ) -return -ENOTSUPP ; +return -EOPNOTSUPP ;else if (!IS_ALIGNED (addr,AARCH64_INSN_SIZE ))return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 687/775 arm64 module: set plt* section addresses to 0x0
In reply to Greg Kroah-HartmanFrom: Shaoying Xu <[email protected]>
commit f5c6d0fcf90ce07ee0d686d465b19b247ebd5ed7 upstream.
These plt* and .text.ftrace_trampoline sections specified for arm64 have non-zero addressses. Non-zero section addresses in a relocatable ELF would confuse GDB when it tries to compute the section offsets and it ends up printing wrong symbol addresses. Therefore, set them to zero, which mirrors the change in commit 5d8591bc0fba ("module: set ksymtab/kcrctab* section addresses to 0x0").
--- arch/arm64/include/asm/module.lds.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/include/asm/module.lds.h +3 -3
@@ -1,7 +1,7 @@ #ifdef CONFIG_ARM64_MODULE_PLTS SECTIONS { - .plt (NOLOAD) : { BYTE(0) } - .init.plt (NOLOAD) : { BYTE(0) } - .text.ftrace_trampoline (NOLOAD) : { BYTE(0) } + .plt 0 (NOLOAD) : { BYTE(0) } + .init.plt 0 (NOLOAD) : { BYTE(0) } + .text.ftrace_trampoline 0 (NOLOAD) : { BYTE(0) } } #endif
Greg Kroah-Hartman
maintainerPATCH 688/775 arm64: spectre: Prevent lockdep splat on v4 mitigation enable path
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit a2c42bbabbe260b7626d8459093631a6e16ee0ee upstream.
The Spectre-v4 workaround is re-configured when resuming from suspend, as the firmware may have re-enabled the mitigation despite the user previously asking for it to be disabled.
Enabling or disabling the workaround can result in an undefined instruction exception on CPUs which implement PSTATE.SSBS but only allow it to be configured by adjusting the SPSR on exception return. We handle this by installing an 'undef hook' which effectively emulates the access.
Installing this hook requires us to take a couple of spinlocks both to avoid corrupting the internal list of hooks but also to ensure that we don't run into an unhandled exception. Unfortunately, when resuming from suspend, we haven't yet called rcu_idle_exit() and so lockdep gets angry about "suspicious RCU usage". In doing so, it tries to print a warning, which leads it to get even more suspicious, this time about itself:
| rcu_scheduler_active = 2, debug_locks = 1
| RCU used illegally from extended quiescent state!
| 1 lock held by swapper/0:
| #0: (logbuf_lock){-.-.}-{2:2}, at: vprintk_emit+0x88/0x198
|
| Call trace:
| dump_backtrace+0x0/0x1d8
| show_stack+0x18/0x24
| dump_stack+0xe0/0x17c
| lockdep_rcu_suspicious+0x11c/0x134
| trace_lock_release+0xa0/0x160
| lock_release+0x3c/0x290
| _raw_spin_unlock+0x44/0x80
| vprintk_emit+0xbc/0x198
| vprintk_default+0x44/0x6c
| vprintk_func+0x1f4/0x1fc
| printk+0x54/0x7c
| lockdep_rcu_suspicious+0x30/0x134
| trace_lock_acquire+0xa0/0x188
| lock_acquire+0x50/0x2fc
| _raw_spin_lock+0x68/0x80
| spectre_v4_enable_mitigation+0xa8/0x30c
| __cpu_suspend_exit+0xd4/0x1a8
| cpu_suspend+0xa0/0x104
| psci_cpu_suspend_enter+0x3c/0x5c
| psci_enter_idle_state+0x44/0x74
| cpuidle_enter_state+0x148/0x2f8
| cpuidle_enter+0x38/0x50
| do_idle+0x1f0/0x2b4Prevent these splats by running __cpu_suspend_exit() with RCU watching.
--- arch/arm64/kernel/suspend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/suspend.c +1 -1
@@ -119,7 +119,7 @@ int cpu_suspend(unsigned long arg, int (if (!ret) ret = -EOPNOTSUPP ; }else { -__cpu_suspend_exit (); +RCU_NONIDLE (__cpu_suspend_exit ()); }unpause_graph_tracing ();
Greg Kroah-Hartman
maintainerPATCH 689/775 riscv: Disable KSAN_SANITIZE for vDSO
In reply to Greg Kroah-HartmanFrom: Tobias Klauser <[email protected]>
commit f3d60f2a25e4417e1676161fe42115de3e3f98a2 upstream.
We use the generic C VDSO implementations of a handful of clock-related functions. When kasan is enabled this results in asan stub calls that are unlikely to be resolved by userspace, this just disables KASAN when building the VDSO.
Verified the fix on a kernel with KASAN enabled using vDSO selftests.
--- arch/riscv/kernel/vdso/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/kernel/vdso/Makefile +2 -1
@@ -32,9 +32,10 @@ CPPFLAGS_vdso.lds += -P -C -U$(ARCH) # Disable -pg to prevent insert call site CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os -# Disable gcov profiling for VDSO code +# Disable profiling and instrumentation for VDSO code GCOV_PROFILE := n KCOV_INSTRUMENT := n +KASAN_SANITIZE := n # Force dependency $(obj)/vdso.o: $(obj)/vdso.so
Greg Kroah-Hartman
maintainerPATCH 690/775 watchdog: qcom: Remove incorrect usage of QCOM_WDT_ENABLE_IRQ
In reply to Greg Kroah-HartmanFrom: Sai Prakash Ranjan <[email protected]>
commit a4f3407c41605d14f09e490045d0609990cd5d94 upstream.
As per register documentation, QCOM_WDT_ENABLE_IRQ which is BIT(1) of watchdog control register is wakeup interrupt enable bit and not related to bark interrupt at all, BIT(0) is used for that. So remove incorrect usage of this bit when supporting bark irq for pre-timeout notification. Currently with this bit set and bark interrupt specified, pre-timeout notification and/or watchdog reset/bite does not occur.
--- drivers/watchdog/qcom-wdt.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/watchdog/qcom-wdt.c +1 -12
@@ -22,7 +22,6 @@ enum wdt_reg { };#define QCOM_WDT_ENABLE BIT(0) -#define QCOM_WDT_ENABLE_IRQ BIT(1)static const u32 reg_offset_data_apcs_tmr[] = { [WDT_RST ] =0x38 ,
@@ -63,16 +62,6 @@ struct qcom_wdt *to_qcom_wdt(struct watc return container_of(wdd, struct qcom_wdt, wdd); } -static inline int qcom_get_enable (struct watchdog_device *wdd) -{ -int enable =QCOM_WDT_ENABLE ; - -if (wdd->pretimeout) - enable |=QCOM_WDT_ENABLE_IRQ ; - -return enable; -} -static irqreturn_t qcom_wdt_isr (int irq,void *arg) {struct watchdog_device *wdd = arg;
@@ -91,7 +80,7 @@ static int qcom_wdt_start(struct watchdowritel (1 ,wdt_addr (wdt,WDT_RST ));writel (bark * wdt->rate,wdt_addr (wdt,WDT_BARK_TIME ));writel (wdd->timeout * wdt->rate,wdt_addr (wdt,WDT_BITE_TIME )); -writel (qcom_get_enable (wdd),wdt_addr (wdt,WDT_EN )); +writel (QCOM_WDT_ENABLE ,wdt_addr (wdt,WDT_EN ));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 691/775 watchdog: mei_wdt: request stop on unregister
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit 740c0a57b8f1e36301218bf549f3c9cc833a60be upstream.
The MEI bus has a special behavior on suspend it destroys all the attached devices, this is due to the fact that also firmware context is not persistent across power flows.
If watchdog on MEI bus is ticking before suspending the firmware times out and reports that the OS is missing watchdog tick. Send the stop command to the firmware on watchdog unregistered to eliminate the false event on suspend.
This does not make the things worse from the user-space perspective as a user-space should re-open watchdog device after suspending before this patch.
--- drivers/watchdog/mei_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/mei_wdt.c +1 -0
@@ -382,6 +382,7 @@ static int mei_wdt_register(struct mei_wwatchdog_set_drvdata (&wdt->wdd, wdt);watchdog_stop_on_reboot (&wdt->wdd); +watchdog_stop_on_unregister (&wdt->wdd); ret =watchdog_register_device (&wdt->wdd);if (ret)
Greg Kroah-Hartman
maintainerPATCH 692/775 coresight: etm4x: Handle accesses to TRCSTALLCTLR
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit f72896063396b0cb205cbf0fd76ec6ab3ca11c8a upstream.
TRCSTALLCTLR register is only implemented if
TRCIDR3.STALLCTL == 0b1
Make sure the driver touches the register only it is implemented.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 9 ++++++--- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/hwtracing/coresight/coresight-etm4x-core.c +6 -3
@@ -226,7 +226,8 @@ static int etm4_enable_hw(struct etmv4_dwritel_relaxed (0x0 , drvdata->base +TRCAUXCTLR );writel_relaxed (config->eventctrl0, drvdata->base +TRCEVENTCTL0R );writel_relaxed (config->eventctrl1, drvdata->base +TRCEVENTCTL1R ); -writel_relaxed (config->stall_ctrl, drvdata->base +TRCSTALLCTLR ); +if (drvdata->stallctl) +writel_relaxed (config->stall_ctrl, drvdata->base +TRCSTALLCTLR );writel_relaxed (config->ts_ctrl, drvdata->base +TRCTSCTLR );writel_relaxed (config->syncfreq, drvdata->base +TRCSYNCPR );writel_relaxed (config->ccctlr, drvdata->base +TRCCCCTLR );
@@ -1288,7 +1289,8 @@ static int etm4_cpu_save(struct etmv4_dr state->trcauxctlr =readl (drvdata->base +TRCAUXCTLR ); state->trceventctl0r =readl (drvdata->base +TRCEVENTCTL0R ); state->trceventctl1r =readl (drvdata->base +TRCEVENTCTL1R ); - state->trcstallctlr =readl (drvdata->base +TRCSTALLCTLR ); +if (drvdata->stallctl) + state->trcstallctlr =readl (drvdata->base +TRCSTALLCTLR ); state->trctsctlr =readl (drvdata->base +TRCTSCTLR ); state->trcsyncpr =readl (drvdata->base +TRCSYNCPR ); state->trcccctlr =readl (drvdata->base +TRCCCCTLR );
@@ -1398,7 +1400,8 @@ static void etm4_cpu_restore(struct etmvwritel_relaxed (state->trcauxctlr, drvdata->base +TRCAUXCTLR );writel_relaxed (state->trceventctl0r, drvdata->base +TRCEVENTCTL0R );writel_relaxed (state->trceventctl1r, drvdata->base +TRCEVENTCTL1R ); -writel_relaxed (state->trcstallctlr, drvdata->base +TRCSTALLCTLR ); +if (drvdata->stallctl) +writel_relaxed (state->trcstallctlr, drvdata->base +TRCSTALLCTLR );writel_relaxed (state->trctsctlr, drvdata->base +TRCTSCTLR );writel_relaxed (state->trcsyncpr, drvdata->base +TRCSYNCPR );writel_relaxed (state->trcccctlr, drvdata->base +TRCCCCTLR );
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +1 -1
@@ -389,7 +389,7 @@ static ssize_t mode_store(struct device config->eventctrl1 &= ~BIT (12 );/* bit[8], Instruction stall bit */ -if (config->mode &ETM_MODE_ISTALL_EN ) +if ((config->mode &ETM_MODE_ISTALL_EN ) && (drvdata->stallctl == true)) config->stall_ctrl |=BIT (8 );else config->stall_ctrl &= ~BIT (8 );
Greg Kroah-Hartman
maintainerPATCH 693/775 mtd: spi-nor: sfdp: Fix last erase region marking
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 9166f4af32db74e1544a2149aef231ff24515ea3 upstream.
The place of spi_nor_region_mark_end() must be moved, because 'i' is re-used for the index of erase[].
--- drivers/mtd/spi-nor/sfdp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/spi-nor/sfdp.c +1 -2
@@ -858,6 +858,7 @@ spi_nor_init_non_uniform_erase_map(struc offset = (region[i].offset & ~SNOR_ERASE_FLAGS_MASK ) + region[i].size; } +spi_nor_region_mark_end (®ion[i -1 ]); save_uniform_erase_type = map->uniform_erase_type; map->uniform_erase_type = spi_nor_sort_erase_mask(map,
@@ -881,8 +882,6 @@ spi_nor_init_non_uniform_erase_map(strucif (!(regions_erase_type &BIT (erase[i].idx)))spi_nor_set_erase_type (&erase[i],0 ,0xFF ); -spi_nor_region_mark_end (®ion[i -1 ]); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 694/775 mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit abdf5a5ef9652bad4d58058bc22ddf23543ba3e1 upstream.
At the time spi_nor_region_check_overlay() is called, the erase types are sorted in ascending order of erase size. The 'erase_type' should be masked with 'BIT(erase[i].idx)' instead of 'BIT(i)'.
--- drivers/mtd/spi-nor/sfdp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/sfdp.c +1 -1
@@ -788,7 +788,7 @@ spi_nor_region_check_overlay(struct spi_int i;for (i =0 ; i <SNOR_ERASE_TYPE_MAX ; i++) { -if (!(erase_type &BIT (i))) +if (!(erase[i].size && erase_type &BIT (erase[i].idx)))continue ;if (region->size & erase[i].size_mask) {spi_nor_region_mark_overlay (region);
Greg Kroah-Hartman
maintainerPATCH 695/775 mtd: spi-nor: core: Fix erase type discovery for overlaid region
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 969b276718de37dfe66fce3a5633f611e8cd58fd upstream.
In case of overlaid regions in which their biggest erase size command overpasses in size the region's size, only the non-overlaid portion of the sector gets erased. For example, if a Sector Erase command is applied to a 256-kB range that is overlaid by 4-kB sectors, the overlaid 4-kB sectors are not affected by the erase.
For overlaid regions, 'region->size' is assigned to 'cmd->size' later in spi_nor_init_erase_cmd(), so 'erase->size' can be greater than 'len'.
--- drivers/mtd/spi-nor/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/core.c +5 -4
@@ -1364,14 +1364,15 @@ spi_nor_find_best_erase_type(const struc erase = &map->erase_type[i]; +/* Alignment is not mandatory for overlaid regions */ +if (region->offset &SNOR_OVERLAID_REGION && + region->size <= len) +return erase; +/* Don't erase more than what the user has asked for. */ if (erase->size > len)continue ; -/* Alignment is not mandatory for overlaid regions */ -if (region->offset &SNOR_OVERLAID_REGION ) -return erase; -spi_nor_div_by_erase_size (erase, addr, &rem);if (rem)continue ;
Greg Kroah-Hartman
maintainerPATCH 696/775 mtd: spi-nor: core: Add erase size check for erase command initialization
In reply to Greg Kroah-HartmanFrom: Takahiro Kuwano <[email protected]>
commit 58fa22f68fcaff20ce4d08a6adffa64f65ccd37d upstream.
Even if erase type is same as previous region, erase size can be different if the previous region is overlaid region. Since 'region->size' is assigned to 'cmd->size' for overlaid region, comparing 'erase->size' and 'cmd->size' can detect previous overlaid region.
--- drivers/mtd/spi-nor/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/spi-nor/core.c +1 -0
@@ -1516,6 +1516,7 @@ static int spi_nor_init_erase_cmd_list(s goto destroy_erase_cmd_list;if (prev_erase != erase || + erase->size != cmd->size || region->offset &SNOR_OVERLAID_REGION ) { cmd =spi_nor_init_erase_cmd (region, erase);if (IS_ERR (cmd)) {
Greg Kroah-Hartman
maintainerPATCH 697/775 mtd: spi-nor: hisi-sfc: Put child node np on error path
In reply to Greg Kroah-HartmanFrom: Pan Bian <[email protected]>
commit fe6653460ee7a7dbe0cd5fd322992af862ce5ab0 upstream.
Put the child node np when it fails to get or register device.
--- drivers/mtd/spi-nor/controllers/hisi-sfc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/controllers/hisi-sfc.c +3 -1
@@ -399,8 +399,10 @@ static int hisi_spi_nor_register_all(strfor_each_available_child_of_node (dev->of_node, np) { ret =hisi_spi_nor_register (np, host); -if (ret) +if (ret) { +of_node_put (np); goto fail; + }if (host->num_chip ==HIFMC_MAX_CHIP_NUM ) {dev_warn (dev,"Flash device number exceeds the maximum chipselect number\n" );
Greg Kroah-Hartman
maintainerPATCH 698/775 fs/affs: release old buffer head on error path
In reply to Greg Kroah-HartmanFrom: Pan Bian <[email protected]>
commit 70779b897395b330ba5a47bed84f94178da599f9 upstream.
The reference count of the old buffer head should be decremented on path that fails to get the new buffer head.
--- fs/affs/namei.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/affs/namei.c +3 -1
@@ -460,8 +460,10 @@ affs_xrename(struct inode *old_dir, strureturn -EIO ; bh_new =affs_bread (sb,d_inode (new_dentry)->i_ino); -if (!bh_new) +if (!bh_new) { +affs_brelse (bh_old);return -EIO ; + }/* Remove old header from its parent directory. */ affs_lock_dir (old_dir);
Greg Kroah-Hartman
maintainerPATCH 699/775 seq_file: document how per-entry resources are managed.
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit b3656d8227f4c45812c6b40815d8f4e446ed372a upstream.
Patch series "Fix some seq_file users that were recently broken".
A recent change to seq_file broke some users which were using seq_file in a non-"standard" way ... though the "standard" isn't documented, so they can be excused. The result is a possible leak - of memory in one case, of references to a 'transport' in the other.
These three patches:
1/ document and explain the problem
2/ fix the problem user in x86
3/ fix the problem user in net/sctp
This patch (of 3):
Users of seq_file will sometimes find it convenient to take a resource, such as a lock or memory allocation, in the ->start or ->next operations. These are per-entry resources, distinct from per-session resources which are taken in ->start and released in ->stop.
The preferred management of these is release the resource on the subsequent call to ->next or ->stop.
However prior to Commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") it happened that ->show would always be called after ->start or ->next, and a few users chose to release the resource in ->show.
This is no longer reliable. Since the mentioned commit, ->next will always come after a successful ->show (to ensure m->index is updated correctly), so the original ordering cannot be maintained.
This patch updates the documentation to clearly state the required behaviour. Other patches will fix the few problematic users.
[[email protected]: fix typo, per Willy]
--- Documentation/filesystems/seq_file.rst | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/filesystems/seq_file.rst +6 -0
@@ -217,6 +217,12 @@ between the calls to start() and stop(), is a reasonable thing to do. The seq_file code will also avoid taking any other locks while the iterator is active. +The iterater value returned by start() or next() is guaranteed to be +passed to a subsequent next() or stop() call. This allows resources +such as locks that were taken to be reliably released. There is *no* +guarantee that the iterator will be passed to show(), though in practice +it often will be. + Formatted output ================
Greg Kroah-Hartman
maintainerPATCH 700/775 x86: fix seq_file iteration for pat/memtype.c
In reply to Greg Kroah-HartmanFrom: NeilBrown <[email protected]>
commit 3d2fc4c082448e9c05792f9b2a11c1d5db408b85 upstream.
The memtype seq_file iterator allocates a buffer in the ->start and ->next functions and frees it in the ->show function. The preferred handling for such resources is to free them in the subsequent ->next or ->stop function call.
Since Commit 1f4aace60b0e ("fs/seq_file.c: simplify seq_file iteration code and interface") there is no guarantee that ->show will be called after ->next, so this function can now leak memory.
So move the freeing of the buffer to ->next and ->stop.
--- arch/x86/mm/pat/memtype.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/mm/pat/memtype.c +2 -2
@@ -1164,12 +1164,14 @@ static void *memtype_seq_start(struct sestatic void *memtype_seq_next (struct seq_file *seq,void *v,loff_t *pos) { +kfree (v); ++*pos;return memtype_get_idx (*pos); }static void memtype_seq_stop (struct seq_file *seq,void *v) { +kfree (v); }static int memtype_seq_show (struct seq_file *seq,void *v)
@@ -1181,8 +1183,6 @@ static int memtype_seq_show(struct seq_f entry_print->end, cattr_name(entry_print->type)); -kfree (entry_print); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 701/775 mm: memcontrol: fix swap undercounting in cgroup2
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
commit cae3af62b33aa931427a0f211e04347b22180b36 upstream.
When pages are swapped in, the VM may retain the swap copy to avoid repeated writes in the future. It's also retained if shared pages are faulted back in some processes, but not in others. During that time we have an in-memory copy of the page, as well as an on-swap copy. Cgroup1 and cgroup2 handle these overlapping lifetimes slightly differently due to the nature of how they account memory and swap:
Cgroup1 has a unified memory+swap counter that tracks a data page regardless whether it's in-core or swapped out. On swapin, we transfer the charge from the swap entry to the newly allocated swapcache page, even though the swap entry might stick around for a while. That's why we have a mem_cgroup_uncharge_swap() call inside mem_cgroup_charge().
Cgroup2 tracks memory and swap as separate, independent resources and thus has split memory and swap counters. On swapin, we charge the newly allocated swapcache page as memory, while the swap slot in turn must remain charged to the swap counter as long as its allocated too.
The cgroup2 logic was broken by commit 2d1c498072de ("mm: memcontrol: make swap tracking an integral part of memory control"), because it accidentally removed the do_memsw_account() check in the branch inside mem_cgroup_uncharge() that was supposed to tell the difference between the charge transfer in cgroup1 and the separate counters in cgroup2.
As a result, cgroup2 currently undercounts retained swap to varying
degrees: swap slots are cached up to 50% of the configured limit or total available swap space; partially faulted back shared pages are only limited by physical capacity. This in turn allows cgroups to significantly overconsume their alloted swap space.
Add the do_memsw_account() check back to fix this problem.
--- mm/memcontrol.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
mm/memcontrol.c +13 -1
@@ -6758,7 +6758,19 @@ int mem_cgroup_charge(struct page *page,memcg_check_events (memcg, page);local_irq_enable (); -if (PageSwapCache (page)) { +/* +* Cgroup1's unified memory+swap counter has been charged with the +* new swapcache page, finish the transfer by uncharging the swap +* slot. The swap slot would also get uncharged when it dies, but +* it can stick around indefinitely and we'd count the page twice +* the entire time. +* +* Cgroup2 has separate resource counters for memory and swap, +* so this is a non-issue here. Memory and swap charge lifetimes +* correspond 1:1 to page and swap slot lifetimes: we charge the +* page to memory here, and uncharge swap when the slot is freed. +*/ +if (do_memsw_account () &&PageSwapCache (page)) {swp_entry_t entry = { .val =page_private (page) };/* * The swap entry might not get freed for a long time,
Greg Kroah-Hartman
maintainerPATCH 702/775 mm: memcontrol: fix get_active_memcg return value
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
commit 1685bde6b9af55923180a76152036c7fb7176db0 upstream.
We use a global percpu int_active_memcg variable to store the remote memcg when we are in the interrupt context. But get_active_memcg always return the current->active_memcg or root_mem_cgroup. The remote memcg (set in the interrupt context) is ignored. This is not what we want. So fix it.
--- mm/memcontrol.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
mm/memcontrol.c +3 -7
@@ -1080,13 +1080,9 @@ static __always_inline struct mem_cgrouprcu_read_lock (); memcg =active_memcg (); -if (memcg) { -/* current->active_memcg must hold a ref. */ -if (WARN_ON_ONCE (!css_tryget (&memcg->css))) - memcg = root_mem_cgroup; -else - memcg = current->active_memcg; - } +/* remote memcg must hold a ref. */ +if (memcg &&WARN_ON_ONCE (!css_tryget (&memcg->css))) + memcg = root_mem_cgroup;rcu_read_unlock ();return memcg;
Greg Kroah-Hartman
maintainerPATCH 703/775 hugetlb: fix update_and_free_page contig page struct assumption
In reply to Greg Kroah-HartmanFrom: Mike Kravetz <[email protected]>
commit dbfee5aee7e54f83d96ceb8e3e80717fac62ad63 upstream.
page structs are not guaranteed to be contiguous for gigantic pages. The routine update_and_free_page can encounter a gigantic page, yet it assumes page structs are contiguous when setting page flags in subpages.
If update_and_free_page encounters non-contiguous page structs, we can see “BUG: Bad page state in process …” errors.
Non-contiguous page structs are generally not an issue. However, they can exist with a specific kernel configuration and hotplug operations. For
example: Configure the kernel with CONFIG_SPARSEMEM and !CONFIG_SPARSEMEM_VMEMMAP. Then, hotplug add memory for the area where the gigantic page will be allocated. Zi Yan outlined steps to reproduce here [1].
[1] https://lore.kernel.org/linux-mm/[email protected]/
--- mm/hugetlb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/hugetlb.c +4 -2
@@ -1312,14 +1312,16 @@ static inline void destroy_compound_gigastatic void update_and_free_page (struct hstate *h,struct page *page) {int i; +struct page *subpage = page;if (hstate_is_gigantic (h) && !gigantic_page_runtime_supported ())return ; h->nr_huge_pages--; h->nr_huge_pages_node[page_to_nid (page)]--; -for (i =0 ; i <pages_per_huge_page (h); i++) { - page[i].flags &= ~(1 << PG_locked |1 << PG_error | +for (i =0 ; i <pages_per_huge_page (h); + i++, subpage =mem_map_next (subpage, page, i)) { + subpage->flags &= ~(1 << PG_locked |1 << PG_error |1 << PG_referenced |1 << PG_dirty |1 << PG_active |1 << PG_private |1 << PG_writeback);
Greg Kroah-Hartman
maintainerPATCH 704/775 hugetlb: fix copy_huge_page_from_user contig page struct assumption
In reply to Greg Kroah-HartmanFrom: Mike Kravetz <[email protected]>
commit 3272cfc2525b3a2810a59312d7a1e6f04a0ca3ef upstream.
page structs are not guaranteed to be contiguous for gigantic pages. The routine copy_huge_page_from_user can encounter gigantic pages, yet it assumes page structs are contiguous when copying pages from user space.
Since page structs for the target gigantic page are not contiguous, the data copied from user space could overwrite other pages not associated with the gigantic page and cause data corruption.
Non-contiguous page structs are generally not an issue. However, they can exist with a specific kernel configuration and hotplug operations. For
example: Configure the kernel with CONFIG_SPARSEMEM and !CONFIG_SPARSEMEM_VMEMMAP. Then, hotplug add memory for the area where the gigantic page will be allocated.
--- mm/memory.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
mm/memory.c +6 -4
@@ -5204,17 +5204,19 @@ long copy_huge_page_from_user(struct pagvoid *page_kaddr;unsigned long i, rc =0 ;unsigned long ret_val = pages_per_huge_page *PAGE_SIZE ; +struct page *subpage = dst_page; -for (i =0 ; i < pages_per_huge_page; i++) { +for (i =0 ; i < pages_per_huge_page; + i++, subpage =mem_map_next (subpage, dst_page, i)) {if (allow_pagefault) - page_kaddr =kmap (dst_page + i); + page_kaddr =kmap (subpage);else - page_kaddr =kmap_atomic (dst_page + i); + page_kaddr =kmap_atomic (subpage); rc =copy_from_user (page_kaddr, (const void __user *)(src + i *PAGE_SIZE ),PAGE_SIZE );if (allow_pagefault) -kunmap (dst_page + i); +kunmap (subpage);else kunmap_atomic (page_kaddr);
Greg Kroah-Hartman
maintainerPATCH 705/775 mm/vmscan: restore zone_reclaim_mode ABI
In reply to Greg Kroah-HartmanFrom: Dave Hansen <[email protected]>
commit 519983645a9f2ec339cabfa0c6ef7b09be985dd0 upstream.
I went to go add a new RECLAIM_* mode for the zone_reclaim_mode sysctl. Like a good kernel developer, I also went to go update the documentation. I noticed that the bits in the documentation didn't match the bits in the #defines.
The VM never explicitly checks the RECLAIM_ZONE bit. The bit is, however implicitly checked when checking 'node_reclaim_mode==0'. The RECLAIM_ZONE #define was removed in a cleanup. That, by itself is fine.
But, when the bit was removed (bit 0) the _other_ bit locations also got changed. That's not OK because the bit values are documented to mean one specific thing. Users surely do not expect the meaning to change from kernel to kernel.
The end result is that if someone had a script that did:
sysctl vm.zone_reclaim_mode=1
it would have gone from enabling node reclaim for clean unmapped pages to writing out pages during node reclaim after the commit in question. That's not great.
Put the bits back the way they were and add a comment so something like this is a bit harder to do again. Update the documentation to make it clear that the first bit is ignored.
--- Documentation/admin-guide/sysctl/vm.rst | 10 +++++----- mm/vmscan.c | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-)
Documentation/admin-guide/sysctl/vm.rst +5 -5
@@ -983,11 +983,11 @@ that benefit from having their data cach left disabled as the caching effect is likely to be more important than data locality. -zone_reclaim may be enabled if it's known that the workload is partitioned -such that each partition fits within a NUMA node and that accessing remote -memory would cause a measurable performance reduction. The page allocator -will then reclaim easily reusable pages (those page cache pages that are -currently not used) before allocating off node pages. +Consider enabling one or more zone_reclaim mode bits if it's known that the +workload is partitioned such that each partition fits within a NUMA node +and that accessing remote memory would cause a measurable performance +reduction. The page allocator will take additional actions before +allocating off node pages. Allowing zone reclaim to write out pages stops processes that are writing large amounts of data from dirtying pages on other nodes. Zone
mm/vmscan.c +7 -2
@@ -4095,8 +4095,13 @@ module_init(kswapd_init)*/ int node_reclaim_mode__read_mostly ; -#define RECLAIM_WRITE (1<<0)/* Writeout pages during reclaim */ -#define RECLAIM_UNMAP (1<<1)/* Unmap pages during reclaim */ +/* +* These bit locations are exposed in the vm.zone_reclaim_mode sysctl +* ABI. New bits are OK, but existing bits can never change. +*/ +#define RECLAIM_ZONE (1<<0)/* Run shrink_inactive_list on the zone */ +#define RECLAIM_WRITE (1<<1)/* Writeout pages during reclaim */ +#define RECLAIM_UNMAP (1<<2)/* Unmap pages during reclaim */ /* * Priority for NODE_RECLAIM. This determines the fraction of pages
Greg Kroah-Hartman
maintainerPATCH 706/775 mm, compaction: make fast_isolate_freepages() stay within zone
In reply to Greg Kroah-HartmanFrom: Vlastimil Babka <[email protected]>
commit 6e2b7044c199229a3d20cefbd3184968238c4184 upstream.
Compaction always operates on pages from a single given zone when isolating both pages to migrate and freepages. Pageblock boundaries are intersected with zone boundaries to be safe in case zone starts or ends in the middle of pageblock. The use of pageblock_pfn_to_page() protects against non-contiguous pageblocks.
The functions fast_isolate_freepages() and fast_isolate_around() don't currently protect the fast freepage isolation thoroughly enough against these corner cases, and can result in freepage isolation operate outside of zone boundaries:
- in fast_isolate_freepages() if we get a pfn from the first pageblock of a zone that starts in the middle of that pageblock, 'highest' can be a pfn outside of the zone.
If we fail to isolate anything in this function, we may then call fast_isolate_around() on a pfn outside of the zone and there effectively do a set_pageblock_skip(page_to_pfn(highest)) which may currently hit a VM_BUG_ON() in some configurations
- fast_isolate_around() checks only the zone end boundary and not beginning, nor that the pageblock is contiguous (with pageblock_pfn_to_page()) so it's possible that we end up calling isolate_freepages_block() on a range of pfn's from two different zones and end up e.g. isolating freepages under the wrong zone's lock.
This patch should fix the above issues.
--- mm/compaction.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
mm/compaction.c +11 -5
@@ -1288,7 +1288,7 @@ static void fast_isolate_around(struct compact_control *cc, unsigned long pfn, unsigned long nr_isolated) { unsigned long start_pfn, end_pfn; -struct page *page =pfn_to_page (pfn); +struct page *page;/* Do not search around if there are enough pages already */ if (cc->nr_freepages >= cc->nr_migratepages)
@@ -1299,8 +1299,12 @@ fast_isolate_around(struct compact_contrreturn ;/* Pageblock boundaries */ - start_pfn =pageblock_start_pfn (pfn); - end_pfn =min (pageblock_end_pfn (pfn),zone_end_pfn (cc->zone)) -1 ; + start_pfn =max (pageblock_start_pfn (pfn), cc->zone->zone_start_pfn); + end_pfn =min (pageblock_end_pfn (pfn),zone_end_pfn (cc->zone)); + + page =pageblock_pfn_to_page (start_pfn, end_pfn, cc->zone); +if (!page) +return ;/* Scan before */ if (start_pfn != pfn) {
@@ -1402,7 +1406,8 @@ fast_isolate_freepages(struct compact_co pfn =page_to_pfn (freepage);if (pfn >= highest) - highest =pageblock_start_pfn (pfn); + highest =max (pageblock_start_pfn (pfn), + cc->zone->zone_start_pfn);if (pfn >= low_pfn) { cc->fast_search_fail =0 ;
@@ -1472,7 +1477,8 @@ fast_isolate_freepages(struct compact_co }else {if (cc->direct_compaction &&pfn_valid (min_pfn)) { page =pageblock_pfn_to_page (min_pfn, -pageblock_end_pfn (min_pfn), +min (pageblock_end_pfn (min_pfn), +zone_end_pfn (cc->zone)), cc->zone); cc->free_pfn = min_pfn; }
Greg Kroah-Hartman
maintainerPATCH 707/775 KVM: nSVM: fix running nested guests when npt=0
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit a04aead144fd938c2d9869eb187e5b9ea0009bae upstream.
In case of npt=0 on host, nSVM needs the same .inject_page_fault tweak as VMX has, to make sure that shadow mmu faults are injected as vmexits.
It is not clear why this is needed at all, but for now keep the same code as VMX and we'll fix it for both.
Based on a patch by Maxim Levitsky <[email protected]>.
--- arch/x86/kvm/svm/nested.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/x86/kvm/svm/nested.c +20 -0
@@ -51,6 +51,23 @@ static void nested_svm_inject_npf_exit(snested_svm_vmexit (svm); } +static void svm_inject_page_fault_nested (struct kvm_vcpu *vcpu,struct x86_exception *fault) +{ +struct vcpu_svm *svm =to_svm (vcpu); +WARN_ON (!is_guest_mode (vcpu)); + +if (vmcb_is_intercept (&svm->nested.ctl,INTERCEPT_EXCEPTION_OFFSET +PF_VECTOR ) && + !svm->nested.nested_run_pending) { + svm->vmcb->control.exit_code =SVM_EXIT_EXCP_BASE +PF_VECTOR ; + svm->vmcb->control.exit_code_hi =0 ; + svm->vmcb->control.exit_info_1 = fault->error_code; + svm->vmcb->control.exit_info_2 = fault->address; +nested_svm_vmexit (svm); + }else { +kvm_inject_page_fault (vcpu, fault); + } +} +static u64 nested_svm_get_tdp_pdptr (struct kvm_vcpu *vcpu,int index) {struct vcpu_svm *svm =to_svm (vcpu);
@@ -446,6 +463,9 @@ int enter_svm_guest_mode(struct vcpu_svmif (ret)return ret; +if (!npt_enabled) + svm->vcpu.arch.mmu->inject_page_fault = svm_inject_page_fault_nested; +svm_set_gif (svm, true);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 708/775 nvmem: qcom-spmi-sdam: Fix uninitialized pdev pointer
In reply to Greg Kroah-HartmanFrom: Subbaraman Narayanamurthy <[email protected]>
commit e2057ee29973b9741d43d3f475a6b02fb46a0e61 upstream.
"sdam->pdev" is uninitialized and it is used to print error logs. Fix it. Since device pointer can be used from sdam_config, use it directly thereby removing pdev pointer.
--- drivers/nvmem/qcom-spmi-sdam.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/nvmem/qcom-spmi-sdam.c +3 -4
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2017, 2020 The Linux Foundation. All rights reserved. +* Copyright (c) 2017, 2020-2021, The Linux Foundation. All rights reserved. */ #include <linux/device.h>
@@ -18,7 +18,6 @@#define SDAM_PBS_TRIG_CLR 0xE6struct sdam_chip { -struct platform_device *pdev;struct regmap *regmap;struct nvmem_config sdam_config;unsigned int base;
@@ -65,7 +64,7 @@ static int sdam_read(void *priv, unsigne size_t bytes) {struct sdam_chip *sdam = priv; -struct device *dev = &sdam->pdev->dev; +struct device *dev = sdam->sdam_config.dev;int rc;if (!sdam_is_valid (sdam, offset, bytes)) {
@@ -86,7 +85,7 @@ static int sdam_write(void *priv, unsign size_t bytes) {struct sdam_chip *sdam = priv; -struct device *dev = &sdam->pdev->dev; +struct device *dev = sdam->sdam_config.dev;int rc;if (!sdam_is_valid (sdam, offset, bytes)) {
Greg Kroah-Hartman
maintainerPATCH 709/775 module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols
In reply to Greg Kroah-HartmanFrom: Fangrui Song <[email protected]>
commit ebfac7b778fac8b0e8e92ec91d0b055f046b4604 upstream.
clang-12 -fno-pic (since
https://github.com/llvm/llvm-project/commit/a084c0388e2a59b9556f2de0083333232da3f1d6)
can emit call __stack_chk_fail@PLT instead of call __stack_chk_fail on x86. The two forms should have identical behaviors on x86-64 but the former causes GNU as<2.37 to produce an unreferenced undefined symbol _GLOBAL_OFFSET_TABLE_.
(On x86-32, there is an R_386_PC32 vs R_386_PLT32 difference but the linker behavior is identical as far as Linux kernel is concerned.)
Simply ignore _GLOBAL_OFFSET_TABLE_ for now, like what scripts/mod/modpost.c:ignore_undef_symbol does. This also fixes the problem for gcc/clang -fpie and -fpic, which may emit call foo@PLT for external function calls on x86.
Note: ld -z defs and dynamic loaders do not error for unreferenced undefined symbols so the module loader is reading too much. If we ever need to ignore more symbols, the code should be refactored to ignore unreferenced symbols.
--- kernel/module.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
kernel/module.c +19 -2
@@ -2348,6 +2348,21 @@ static int verify_exported_symbols(strucreturn 0 ; } +static bool ignore_undef_symbol (Elf_Half emachine,const char *name) +{ +/* +* On x86, PIC code and Clang non-PIC code may have call foo@PLT. GNU as +* before 2.37 produces an unreferenced _GLOBAL_OFFSET_TABLE_ on x86-64. +* i386 has a similar problem but may not deserve a fix. +* +* If we ever have to ignore many symbols, consider refactoring the code to +* only warn if referenced by a relocation. +*/ +if (emachine ==EM_386 || emachine ==EM_X86_64 ) +return !strcmp (name,"_GLOBAL_OFFSET_TABLE_" ); +return false; +} +/* Change all symbols so that st_value encodes the pointer directly. */ static int simplify_symbols (struct module *mod,const struct load_info *info) {
@@ -2395,8 +2410,10 @@ static int simplify_symbols(struct modulbreak ; } -/* Ok if weak. */ -if (!ksym &&ELF_ST_BIND (sym[i].st_info) ==STB_WEAK ) +/* Ok if weak or ignored. */ +if (!ksym && + (ELF_ST_BIND (sym[i].st_info) ==STB_WEAK || +ignore_undef_symbol (info->hdr->e_machine, name)))break ; ret =PTR_ERR (ksym) ?: -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 710/775 mmc: sdhci-esdhc-imx: fix kernel panic when remove module
In reply to Greg Kroah-HartmanFrom: Frank Li <[email protected]>
commit a56f44138a2c57047f1ea94ea121af31c595132b upstream.
In sdhci_esdhc_imx_remove() the SDHCI_INT_STATUS in read. Under some circumstances, this may be done while the device is runtime suspended, triggering the below splat.
Fix the problem by adding a pm_runtime_get_sync(), before reading the register, which will turn on clocks etc making the device accessible again.
[ 1811.323148] mmc1: card aaaa removed [ 1811.347483] Internal error: synchronous external abort: 96000210 [#1] PREEMPT SMP [ 1811.354988] Modules linked in: sdhci_esdhc_imx(-) sdhci_pltfm sdhci cqhci mmc_block mmc_core [last unloaded: mmc_core] [ 1811.365726] CPU: 0 PID: 3464 Comm: rmmod Not tainted 5.10.1-sd-99871-g53835a2e8186 #5 [ 1811.373559] Hardware name: Freescale i.MX8DXL EVK (DT) [ 1811.378705] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--) [ 1811.384723] pc : sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx] [ 1811.391090] lr : platform_drv_remove+0x2c/0x50 [ 1811.395536] sp : ffff800012c7bcb0 [ 1811.398855] x29: ffff800012c7bcb0 x28: ffff00002c72b900 [ 1811.404181] x27: 0000000000000000 x26: 0000000000000000 [ 1811.409497] x25: 0000000000000000 x24: 0000000000000000 [ 1811.414814] x23: ffff0000042b3890 x22: ffff800009127120 [ 1811.420131] x21: ffff00002c4c9580 x20: ffff0000042d0810 [ 1811.425456] x19: ffff0000042d0800 x18: 0000000000000020 [ 1811.430773] x17: 0000000000000000 x16: 0000000000000000 [ 1811.436089] x15: 0000000000000004 x14: ffff000004019c10 [ 1811.441406] x13: 0000000000000000 x12: 0000000000000020 [ 1811.446723] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f [ 1811.452040] x9 : fefefeff6364626d x8 : 7f7f7f7f7f7f7f7f [ 1811.457356] x7 : 78725e6473607372 x6 : 0000000080808080 [ 1811.462673] x5 : 0000000000000000 x4 : 0000000000000000 [ 1811.467990] x3 : ffff800011ac1cb0 x2 : 0000000000000000 [ 1811.473307] x1 : ffff8000091214d4 x0 : ffff8000133a0030 [ 1811.478624] Call trace: [ 1811.481081] sdhci_esdhc_imx_remove+0x28/0x15c [sdhci_esdhc_imx] [ 1811.487098] platform_drv_remove+0x2c/0x50 [ 1811.491198] __device_release_driver+0x188/0x230 [ 1811.495818] driver_detach+0xc0/0x14c [ 1811.499487] bus_remove_driver+0x5c/0xb0 [ 1811.503413] driver_unregister+0x30/0x60 [ 1811.507341] platform_driver_unregister+0x14/0x20 [ 1811.512048] sdhci_esdhc_imx_driver_exit+0x1c/0x3a8 [sdhci_esdhc_imx] [ 1811.518495] __arm64_sys_delete_module+0x19c/0x230 [ 1811.523291] el0_svc_common.constprop.0+0x78/0x1a0 [ 1811.528086] do_el0_svc+0x24/0x90 [ 1811.531405] el0_svc+0x14/0x20 [ 1811.534461] el0_sync_handler+0x1a4/0x1b0 [ 1811.538474] el0_sync+0x174/0x180 [ 1811.541801] Code: a9025bf5 f9403e95 f9400ea0 9100c000 (b9400000) [ 1811.547902] ---[ end trace 3fb1a3bd48ff7be5 ]---
--- drivers/mmc/host/sdhci-esdhc-imx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -1
@@ -1666,9 +1666,10 @@ static int sdhci_esdhc_imx_remove(structstruct sdhci_host *host =platform_get_drvdata (pdev);struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct pltfm_imx_data *imx_data =sdhci_pltfm_priv (pltfm_host); -int dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff ); +int dead;pm_runtime_get_sync (&pdev->dev); + dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff );pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);
Greg Kroah-Hartman
maintainerPATCH 711/775 mmc: sdhci-pci-o2micro: Bug fix for SDR104 HW tuning failure
In reply to Greg Kroah-HartmanFrom: Shirley Her <[email protected]>
commit 1ad9f88014ae1d5abccb6fe930bc4c5c311bdc05 upstream.
Force chip enter L0 power state during SDR104 HW tuning to avoid tuning failure
--- drivers/mmc/host/sdhci-pci-o2micro.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/mmc/host/sdhci-pci-o2micro.c +20 -0
@@ -33,6 +33,8 @@#define O2_SD_ADMA2 0xE7#define O2_SD_INF_MOD 0xF1#define O2_SD_MISC_CTRL4 0xFC +#define O2_SD_MISC_CTRL 0x1C0 +#define O2_SD_PWR_FORCE_L0 0x0002#define O2_SD_TUNING_CTRL 0x300#define O2_SD_PLL_SETTING 0x304#define O2_SD_MISC_SETTING 0x308
@@ -300,6 +302,8 @@ static int sdhci_o2_execute_tuning(struc {struct sdhci_host *host =mmc_priv (mmc);int current_bus_width =0 ; +u32 scratch32 =0 ; +u16 scratch =0 ;/* * This handler only implements the eMMC tuning that is specific to
@@ -312,6 +316,17 @@ static int sdhci_o2_execute_tuning(strucif (WARN_ON ((opcode !=MMC_SEND_TUNING_BLOCK_HS200 ) && (opcode !=MMC_SEND_TUNING_BLOCK )))return -EINVAL ; + +/* Force power mode enter L0 */ + scratch =sdhci_readw (host,O2_SD_MISC_CTRL ); + scratch |=O2_SD_PWR_FORCE_L0 ; +sdhci_writew (host, scratch,O2_SD_MISC_CTRL ); + +/* wait DLL lock, timeout value 5ms */ +if (readx_poll_timeout (sdhci_o2_pll_dll_wdt_control, host, + scratch32, (scratch32 &O2_DLL_LOCK_STATUS ),1 ,5000 )) +pr_warn ("%s: DLL can't lock in 5ms after force L0 during tuning.\n" , +mmc_hostname (host->mmc));/* * Judge the tuning reason, whether caused by dll shift * If cause by dll shift, should call sdhci_o2_dll_recovery
@@ -344,6 +359,11 @@ static int sdhci_o2_execute_tuning(strucsdhci_set_bus_width (host, current_bus_width); } +/* Cancel force power mode enter L0 */ + scratch =sdhci_readw (host,O2_SD_MISC_CTRL ); + scratch &= ~(O2_SD_PWR_FORCE_L0 ); +sdhci_writew (host, scratch,O2_SD_MISC_CTRL ); +sdhci_reset (host,SDHCI_RESET_CMD );sdhci_reset (host,SDHCI_RESET_DATA );
Greg Kroah-Hartman
maintainerPATCH 712/775 powerpc/32: Preserve cr1 in exception prolog stack check to fix build error
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 3642eb21256a317ac14e9ed560242c6d20cf06d9 upstream.
THREAD_ALIGN_SHIFT = THREAD_SHIFT + 1 = PAGE_SHIFT + 1 Maximum PAGE_SHIFT is 18 for 256k pages so THREAD_ALIGN_SHIFT is 19 at the maximum.
No need to clobber cr1, it can be preserved when moving r1 into CR when we check stack overflow.
This reduces the number of instructions in Machine Check Exception prolog and fixes a build failure reported by the kernel test robot on v5.10 stable when building with RTAS + VMAP_STACK + KVM. That build failure is due to too many instructions in the prolog hence not fitting between 0x200 and 0x300. Allthough the problem doesn't show up in mainline, it is still worth the change.
--- arch/powerpc/kernel/head_32.h | 2 +- arch/powerpc/kernel/head_book3s_32.S | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-)
arch/powerpc/kernel/head_32.h +1 -1
@@ -47,7 +47,7 @@ lwz r1,TASK_STACK-THREAD(r1) addi r1, r1, THREAD_SIZE - INT_FRAME_SIZE 1: - mtcrf 0x7f, r1 + mtcrf 0x3f, r1 bt 32 - THREAD_ALIGN_SHIFT, stack_overflow #else subi r11, r1, INT_FRAME_SIZE /* use r1 if kernel */
arch/powerpc/kernel/head_book3s_32.S +0 -6
@@ -278,12 +278,6 @@ MachineCheck: 7: EXCEPTION_PROLOG_2 addi r3,r1,STACK_FRAME_OVERHEAD #ifdef CONFIG_PPC_CHRP -#ifdef CONFIG_VMAP_STACK - mfspr r4, SPRN_SPRG_THREAD - tovirt(r4, r4) - lwz r4, RTAS_SP(r4) - cmpwi cr1, r4, 0 -#endif beq cr1, machine_check_tramp twi 31, 0, 0 #else
Greg Kroah-Hartman
maintainerPATCH 713/775 powerpc/kexec_file: fix FDT size estimation for kdump kernel
In reply to Greg Kroah-HartmanFrom: Hari Bathini <[email protected]>
commit 2377c92e37fe97bc5b365f55cf60f56dfc4849f5 upstream.
On systems with large amount of memory, loading kdump kernel through kexec_file_load syscall may fail with the below error:
"Failed to update fdt with linux,drconf-usable-memory property"
This happens because the size estimation for kdump kernel's FDT does not account for the additional space needed to setup usable memory properties. Fix it by accounting for the space needed to include linux,usable-memory & linux,drconf-usable-memory properties while estimating kdump kernel's FDT size.
--- arch/powerpc/include/asm/kexec.h | 1 + arch/powerpc/kexec/elf_64.c | 2 +- arch/powerpc/kexec/file_load_64.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/kexec.h +1 -0
@@ -136,6 +136,7 @@ int load_crashdump_segments_ppc64(structint setup_purgatory_ppc64 (struct kimage *image,const void *slave_code,const void *fdt,unsigned long kernel_load_addr,unsigned long fdt_load_addr); +unsigned int kexec_fdt_totalsize_ppc64 (struct kimage *image);int setup_new_fdt_ppc64 (const struct kimage *image,void *fdt,unsigned long initrd_load_addr,unsigned long initrd_len,const char *cmdline);
arch/powerpc/kexec/elf_64.c +1 -1
@@ -102,7 +102,7 @@ static void *elf64_load(struct kimage *ipr_debug ("Loaded initrd at 0x%lx\n" , initrd_load_addr); } - fdt_size =fdt_totalsize (initial_boot_params) *2 ; + fdt_size =kexec_fdt_totalsize_ppc64 (image); fdt =kmalloc (fdt_size,GFP_KERNEL );if (!fdt) {pr_err ("Not enough memory for the device tree.\n" );
arch/powerpc/kexec/file_load_64.c +35 -0
@@ -21,6 +21,7 @@#include <linux/memblock.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <asm/setup.h> #include <asm/drmem.h> #include <asm/kexec_ranges.h> #include <asm/crashdump-ppc64.h>
@@ -926,6 +927,40 @@ out: }/** +* kexec_fdt_totalsize_ppc64 - Return the estimated size needed to setup FDT +* for kexec/kdump kernel. +* @image: kexec image being loaded. +* +* Returns the estimated size needed for kexec/kdump kernel FDT. +*/ +unsigned int kexec_fdt_totalsize_ppc64 (struct kimage *image) +{ +unsigned int fdt_size; +u64 usm_entries; + +/* +* The below estimate more than accounts for a typical kexec case where +* the additional space is to accommodate things like kexec cmdline, +* chosen node with properties for initrd start & end addresses and +* a property to indicate kexec boot.. +*/ + fdt_size =fdt_totalsize (initial_boot_params) + (2 *COMMAND_LINE_SIZE ); +if (image->type !=KEXEC_TYPE_CRASH ) +return fdt_size; + +/* +* For kdump kernel, also account for linux,usable-memory and +* linux,drconf-usable-memory properties. Get an approximate on the +* number of usable memory entries and use for FDT size estimation. +*/ + usm_entries = ((memblock_end_of_DRAM () /drmem_lmb_size ()) + + (2 * (resource_size (&crashk_res) /drmem_lmb_size ()))); + fdt_size += (unsigned int )(usm_entries *sizeof (u64)); + +return fdt_size; +} + +/** * setup_new_fdt_ppc64 - Update the flattend device-tree of the kernel * being loaded. * @image: kexec image being loaded.
Greg Kroah-Hartman
maintainerPATCH 714/775 powerpc/32s: Add missing call to kuep_lock on syscall entry
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 57fdfbce89137ae85cd5cef48be168040a47dd13 upstream.
Userspace Execution protection and fast syscall entry were implemented independently from each other and were both merged in kernel 5.2, leading to syscall entry missing userspace execution protection.
On syscall entry, execution of user space memory must be locked in the same way as on exception entry.
--- arch/powerpc/kernel/entry_32.S | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/entry_32.S +3 -0
@@ -356,6 +356,9 @@ trace_syscall_entry_irq_off: .globl transfer_to_syscall transfer_to_syscall: +#ifdef CONFIG_PPC_BOOK3S_32 + kuep_lock r11, r12 +#endif #ifdef CONFIG_TRACE_IRQFLAGS andi. r12,r9,MSR_EE beq- trace_syscall_entry_irq_off
Greg Kroah-Hartman
maintainerPATCH 715/775 spmi: spmi-pmic-arb: Fix hw_irq overflow
In reply to Greg Kroah-HartmanFrom: Subbaraman Narayanamurthy <[email protected]>
commit d19db80a366576d3ffadf2508ed876b4c1faf959 upstream.
Currently, when handling the SPMI summary interrupt, the hw_irq number is calculated based on SID, Peripheral ID, IRQ index and APID. This is then passed to irq_find_mapping() to see if a mapping exists for this hw_irq and if available, invoke the interrupt handler. Since the IRQ index uses an "int" type, hw_irq which is of unsigned long data type can take a large value when SID has its MSB set to 1 and the type conversion happens. Because of this, irq_find_mapping() returns 0 as there is no mapping for this hw_irq. This ends up invoking cleanup_irq() as if the interrupt is spurious whereas it is actually a valid interrupt. Fix this by using the proper data type (u32) for id.
--- drivers/spmi/spmi-pmic-arb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/spmi/spmi-pmic-arb.c +2 -3
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved. +* Copyright (c) 2012-2015, 2017, 2021, The Linux Foundation. All rights reserved. */ #include <linux/bitmap.h> #include <linux/delay.h>
@@ -505,8 +505,7 @@ static void cleanup_irq(struct spmi_pmicstatic void periph_interrupt (struct spmi_pmic_arb *pmic_arb,u16 apid) {unsigned int irq; -u32 status; -int id; +u32 status, id;u8 sid = (pmic_arb->apid_data[apid].ppid >>8 ) &0xF ;u8 per = pmic_arb->apid_data[apid].ppid &0xFF ;
Greg Kroah-Hartman
maintainerPATCH 716/775 mei: bus: block send with vtag on non-conformat FW
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit b398d53cd421454d64850f8b1f6d609ede9042d9 upstream.
Block data send with vtag if either transport layer or FW client are not supporting vtags.
--- drivers/misc/mei/bus.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/misc/mei/bus.c +7 -0
@@ -60,6 +60,13 @@ ssize_t __mei_cl_send(struct mei_cl *cl, goto out; } +if (vtag) { +/* Check if vtag is supported by client */ + rets =mei_cl_vt_support_check (cl); +if (rets) + goto out; + } +if (length >mei_cl_mtu (cl)) { rets = -EFBIG ; goto out;
Greg Kroah-Hartman
maintainerPATCH 717/775 mei: fix transfer over dma with extended header
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit 1309ecc90f16ee9cc3077761e7f4474369747e6e upstream.
The size in header field for packet transferred over DMA includes size of the extended header.
Include extended header in size check.
Add size and sanity checks on extended header.
--- drivers/misc/mei/interrupt.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
drivers/misc/mei/interrupt.c +30 -3
@@ -295,12 +295,17 @@ static inline bool hdr_is_fixed(struct mstatic inline int hdr_is_valid (u32 msg_hdr) {struct mei_msg_hdr *mei_hdr; +u32 expected_len =0 ; mei_hdr = (struct mei_msg_hdr *)&msg_hdr;if (!msg_hdr || mei_hdr->reserved)return -EBADMSG ; -if (mei_hdr->dma_ring && mei_hdr->length !=MEI_SLOT_SIZE ) +if (mei_hdr->dma_ring) + expected_len +=MEI_SLOT_SIZE ; +if (mei_hdr->extended) + expected_len +=MEI_SLOT_SIZE ; +if (mei_hdr->length < expected_len)return -EBADMSG ;return 0 ;
@@ -324,6 +329,8 @@ int mei_irq_read_handler(struct mei_devistruct mei_cl *cl;int ret;u32 ext_meta_hdr_u32; +u32 hdr_size_left; +u32 hdr_size_ext;int i;int ext_hdr_end;
@@ -353,6 +360,7 @@ int mei_irq_read_handler(struct mei_devi } ext_hdr_end =1 ; + hdr_size_left = mei_hdr->length;if (mei_hdr->extended) {if (!dev->rd_msg_hdr[1 ]) {
@@ -363,8 +371,21 @@ int mei_irq_read_handler(struct mei_devidev_dbg (dev->dev,"extended header is %08x\n" , ext_meta_hdr_u32); } - meta_hdr = ((struct mei_ext_meta_hdr *) - dev->rd_msg_hdr +1 ); + meta_hdr = ((struct mei_ext_meta_hdr *)dev->rd_msg_hdr +1 ); +if (check_add_overflow ((u32 )sizeof (*meta_hdr), +mei_slots2data (meta_hdr->size), + &hdr_size_ext)) { +dev_err (dev->dev,"extended message size too big %d\n" , + meta_hdr->size); +return -EBADMSG ; + } +if (hdr_size_left < hdr_size_ext) { +dev_err (dev->dev,"corrupted message header len %d\n" , + mei_hdr->length); +return -EBADMSG ; + } + hdr_size_left -= hdr_size_ext; + ext_hdr_end = meta_hdr->size +2 ;for (i = dev->rd_msg_hdr_count; i < ext_hdr_end; i++) { dev->rd_msg_hdr[i] =mei_read_hdr (dev);
@@ -376,6 +397,12 @@ int mei_irq_read_handler(struct mei_devi }if (mei_hdr->dma_ring) { +if (hdr_size_left !=sizeof (dev->rd_msg_hdr[ext_hdr_end])) { +dev_err (dev->dev,"corrupted message header len %d\n" , + mei_hdr->length); +return -EBADMSG ; + } + dev->rd_msg_hdr[ext_hdr_end] =mei_read_hdr (dev); dev->rd_msg_hdr_count++; (*slots)--;
Greg Kroah-Hartman
maintainerPATCH 718/775 mei: me: emmitsburg workstation DID
In reply to Greg Kroah-HartmanFrom: Tomas Winkler <[email protected]>
commit 372726cb3957dbd69ded9a4e3419d5c6c3bc648e upstream.
Add Emmitsburg workstation DID.
--- drivers/misc/mei/hw-me-regs.h | 2 ++ drivers/misc/mei/pci-me.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/misc/mei/hw-me-regs.h +2 -0
@@ -101,6 +101,8 @@#define MEI_DEV_ID_MCC 0x4B70/* Mule Creek Canyon (EHL) */ #define MEI_DEV_ID_MCC_4 0x4B75/* Mule Creek Canyon 4 (EHL) */ +#define MEI_DEV_ID_EBG 0x1BE0/* Emmitsburg WS */ +/* * MEI HW Section */
drivers/misc/mei/pci-me.c +2 -0
@@ -107,6 +107,8 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_CDF, MEI_ME_PCH8_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_EBG, MEI_ME_PCH15_SPS_CFG)}, +/* required last entry */ {0, } };
Greg Kroah-Hartman
maintainerPATCH 719/775 mei: me: add adler lake point S DID
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit f7545efaf7950b240de6b8a20b9c3ffd7278538e upstream.
Add Adler Lake S device id.
--- drivers/misc/mei/hw-me-regs.h | 2 ++ drivers/misc/mei/pci-me.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/misc/mei/hw-me-regs.h +2 -0
@@ -103,6 +103,8 @@#define MEI_DEV_ID_EBG 0x1BE0/* Emmitsburg WS */ +#define MEI_DEV_ID_ADP_S 0x7AE8/* Alder Lake Point S */ +/* * MEI HW Section */
drivers/misc/mei/pci-me.c +2 -0
@@ -109,6 +109,8 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_EBG, MEI_ME_PCH15_SPS_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ADP_S, MEI_ME_PCH15_CFG)}, +/* required last entry */ {0, } };
Greg Kroah-Hartman
maintainerPATCH 720/775 mei: me: add adler lake point LP DID
In reply to Greg Kroah-HartmanFrom: Alexander Usyskin <[email protected]>
commit 930c922a987a02936000f15ea62988b7a39c27f5 upstream.
Add Adler Lake LP device id.
--- drivers/misc/mei/hw-me-regs.h | 1 + drivers/misc/mei/pci-me.c | 1 + 2 files changed, 2 insertions(+)
drivers/misc/mei/hw-me-regs.h +1 -0
@@ -104,6 +104,7 @@#define MEI_DEV_ID_EBG 0x1BE0/* Emmitsburg WS */ #define MEI_DEV_ID_ADP_S 0x7AE8/* Alder Lake Point S */ +#define MEI_DEV_ID_ADP_LP 0x7A60/* Alder Lake Point LP */ /* * MEI HW Section
drivers/misc/mei/pci-me.c +1 -0
@@ -110,6 +110,7 @@ static const struct pci_device_id mei_me {MEI_PCI_DEVICE(MEI_DEV_ID_EBG, MEI_ME_PCH15_SPS_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_ADP_S, MEI_ME_PCH15_CFG)}, + {MEI_PCI_DEVICE(MEI_DEV_ID_ADP_LP, MEI_ME_PCH15_CFG)},/* required last entry */ {0, }
Greg Kroah-Hartman
maintainerPATCH 721/775 gpio: pcf857x: Fix missing first interrupt
In reply to Greg Kroah-HartmanFrom: Maxim Kiselev <[email protected]>
commit a8002a35935aaefcd6a42ad3289f62bab947f2ca upstream.
If no n_latch value will be provided at driver probe then all pins will be used as an input:
gpio->out = ~n_latch;
In that case initial state for all pins is "one":
gpio->status = gpio->out;
So if pcf857x IRQ happens with change pin value from "zero" to "one" then we miss it, because of "one" from IRQ and "one" from initial state leaves corresponding pin unchanged:
change = (gpio->status ^ status) & gpio->irq_enabled;
The right solution will be to read actual state at driver probe.
--- drivers/gpio/gpio-pcf857x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pcf857x.c +1 -1
@@ -332,7 +332,7 @@ static int pcf857x_probe(struct i2c_clie* reset state. Otherwise it flags pins to be driven low. */ gpio->out = ~n_latch; - gpio->status = gpio->out; + gpio->status = gpio->read (gpio->client);/* Enable irqchip if we have an interrupt */ if (client->irq) {
Greg Kroah-Hartman
maintainerPATCH 722/775 mfd: gateworks-gsc: Fix interrupt type
In reply to Greg Kroah-HartmanFrom: Tim Harvey <[email protected]>
commit 8d9bf3c3e1451fc8de7b590040a868ade26d6b22 upstream.
The Gateworks System Controller has an active-low interrupt. Fix the interrupt request type.
--- drivers/mfd/gateworks-gsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/gateworks-gsc.c +1 -1
@@ -234,7 +234,7 @@ static int gsc_probe(struct i2c_client * ret =devm_regmap_add_irq_chip (dev, gsc->regmap, client->irq,IRQF_ONESHOT |IRQF_SHARED | -IRQF_TRIGGER_FALLING ,0 , +IRQF_TRIGGER_LOW ,0 , &gsc_irq_chip, &irq_data);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 723/775 printk: fix deadlock when kernel panic
In reply to Greg Kroah-HartmanFrom: Muchun Song <[email protected]>
commit 8a8109f303e25a27f92c1d8edd67d7cbbc60a4eb upstream.
printk_safe_flush_on_panic() caused the following deadlock on our server:
CPU0: CPU1:
panic rcu_dump_cpu_stacks
kdump_nmi_shootdown_cpus nmi_trigger_cpumask_backtrace
register_nmi_handler(crash_nmi_callback) printk_safe_flush
__printk_safe_flush
raw_spin_lock_irqsave(&read_lock)
// send NMI to other processors
apic_send_IPI_allbutself(NMI_VECTOR)
// NMI interrupt, dead loop
crash_nmi_callback
printk_safe_flush_on_panic
printk_safe_flush
__printk_safe_flush
// deadlock
raw_spin_lock_irqsave(&read_lock)DEADLOCK: read_lock is taken on CPU1 and will never get released.
It happens when panic() stops a CPU by NMI while it has been in the middle of printk_safe_flush().
Handle the lock the same way as logbuf_lock. The printk_safe buffers are flushed only when both locks can be safely taken. It can avoid the deadlock _in this particular case_ at expense of losing contents of printk_safe buffers.
Note: It would actually be safe to re-init the locks when all CPUs were
stopped by NMI. But it would require passing this information from arch-specific code. It is not worth the complexity. Especially because logbuf_lock and printk_safe buffers have been obsoleted by the lockless ring buffer.
--- kernel/printk/printk_safe.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
kernel/printk/printk_safe.c +12 -4
@@ -45,6 +45,8 @@ struct printk_safe_seq_buf { static DEFINE_PER_CPU(struct printk_safe_seq_buf, safe_print_seq); static DEFINE_PER_CPU(int, printk_context); +static DEFINE_RAW_SPINLOCK (safe_read_lock); +#ifdef CONFIG_PRINTK_NMI static DEFINE_PER_CPU(struct printk_safe_seq_buf, nmi_print_seq);#endif
@@ -180,8 +182,6 @@ static void report_message_lost(struct p*/ static void __printk_safe_flush (struct irq_work *work) { -static raw_spinlock_t read_lock = -__RAW_SPIN_LOCK_INITIALIZER (read_lock);struct printk_safe_seq_buf *s = container_of(work, struct printk_safe_seq_buf, work);unsigned long flags;
@@ -195,7 +195,7 @@ static void __printk_safe_flush(struct i* different CPUs. This is especially important when printing * a backtrace. */ -raw_spin_lock_irqsave (&read_lock, flags); +raw_spin_lock_irqsave (&safe_read_lock, flags); i =0 ; more:
@@ -232,7 +232,7 @@ more: out:report_message_lost (s); -raw_spin_unlock_irqrestore (&read_lock, flags); +raw_spin_unlock_irqrestore (&safe_read_lock, flags); }/**
@@ -278,6 +278,14 @@ void printk_safe_flush_on_panic(void)raw_spin_lock_init (&logbuf_lock); } +if (raw_spin_is_locked (&safe_read_lock)) { +if (num_online_cpus () >1 ) +return ; + +debug_locks_off (); +raw_spin_lock_init (&safe_read_lock); + } +printk_safe_flush (); }
Greg Kroah-Hartman
maintainerPATCH 724/775 exfat: fix shift-out-of-bounds in exfat_fill_super()
In reply to Greg Kroah-HartmanFrom: Namjae Jeon <[email protected]>
commit 78c276f5495aa53a8beebb627e5bf6a54f0af34f upstream.
syzbot reported a warning which could cause shift-out-of-bounds issue.
Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x183/0x22e lib/dump_stack.c:120 ubsan_epilogue lib/ubsan.c:148 [inline] __ubsan_handle_shift_out_of_bounds+0x432/0x4d0 lib/ubsan.c:395 exfat_read_boot_sector fs/exfat/super.c:471 [inline] __exfat_fill_super fs/exfat/super.c:556 [inline] exfat_fill_super+0x2acb/0x2d00 fs/exfat/super.c:624 get_tree_bdev+0x406/0x630 fs/super.c:1291 vfs_get_tree+0x86/0x270 fs/super.c:1496 do_new_mount fs/namespace.c:2881 [inline] path_mount+0x1937/0x2c50 fs/namespace.c:3211 do_mount fs/namespace.c:3224 [inline] __do_sys_mount fs/namespace.c:3432 [inline] __se_sys_mount+0x2f9/0x3b0 fs/namespace.c:3409 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xa9
exfat specification describe sect_per_clus_bits field of boot sector could be at most 25 - sect_size_bits and at least 0. And sect_size_bits can also affect this calculation, It also needs validation. This patch add validation for sect_per_clus_bits and sect_size_bits field of boot sector.
--- fs/exfat/exfat_raw.h | 4 ++++ fs/exfat/super.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-)
fs/exfat/exfat_raw.h +4 -0
@@ -77,6 +77,10 @@#define EXFAT_FILE_NAME_LEN 15 +#define EXFAT_MIN_SECT_SIZE_BITS 9 +#define EXFAT_MAX_SECT_SIZE_BITS 12 +#define EXFAT_MAX_SECT_PER_CLUS_BITS (x) (25 - (x)->sect_size_bits) +/* EXFAT: Main and Backup Boot Sector (512 bytes) */ struct boot_sector {__u8 jmp_boot[BOOTSEC_JUMP_BOOT_LEN ];
fs/exfat/super.c +26 -5
@@ -381,8 +381,7 @@ static int exfat_calibrate_blocksize(str {struct exfat_sb_info *sbi =EXFAT_SB (sb); -if (!is_power_of_2 (logical_sect) || - logical_sect <512 || logical_sect >4096 ) { +if (!is_power_of_2 (logical_sect)) {exfat_err (sb,"bogus logical sector size %u" , logical_sect);return -EIO ; }
@@ -451,6 +450,25 @@ static int exfat_read_boot_sector(structreturn -EINVAL ; } +/* +* sect_size_bits could be at least 9 and at most 12. +*/ +if (p_boot->sect_size_bits <EXFAT_MIN_SECT_SIZE_BITS || + p_boot->sect_size_bits >EXFAT_MAX_SECT_SIZE_BITS ) { +exfat_err (sb,"bogus sector size bits : %u\n" , + p_boot->sect_size_bits); +return -EINVAL ; + } + +/* +* sect_per_clus_bits could be at least 0 and at most 25 - sect_size_bits. +*/ +if (p_boot->sect_per_clus_bits >EXFAT_MAX_SECT_PER_CLUS_BITS (p_boot)) { +exfat_err (sb,"bogus sectors bits per cluster : %u\n" , + p_boot->sect_per_clus_bits); +return -EINVAL ; + } + sbi->sect_per_clus =1 << p_boot->sect_per_clus_bits; sbi->sect_per_clus_bits = p_boot->sect_per_clus_bits; sbi->cluster_size_bits = p_boot->sect_per_clus_bits +
@@ -477,16 +495,19 @@ static int exfat_read_boot_sector(struct sbi->used_clusters =EXFAT_CLUSTERS_UNTRACKED ;/* check consistencies */ -if (sbi->num_FAT_sectors << p_boot->sect_size_bits < - sbi->num_clusters *4 ) { +if ((u64 )sbi->num_FAT_sectors << p_boot->sect_size_bits < + (u64 )sbi->num_clusters *4 ) {exfat_err (sb,"bogus fat length" );return -EINVAL ; } +if (sbi->data_start_sector < - sbi->FAT1_start_sector + sbi->num_FAT_sectors * p_boot->num_fats) { + (u64 )sbi->FAT1_start_sector + + (u64 )sbi->num_FAT_sectors * p_boot->num_fats) {exfat_err (sb,"bogus data start sector" );return -EINVAL ; } +if (sbi->vol_flags &VOLUME_DIRTY )exfat_warn (sb,"Volume was not properly unmounted. Some data may be corrupt. Please run fsck." );if (sbi->vol_flags &MEDIA_FAILURE )
Greg Kroah-Hartman
maintainerPATCH 725/775 zonefs: Fix file size of zones in full condition
In reply to Greg Kroah-HartmanFrom: Shin'ichiro Kawasaki <[email protected]>
commit 059c01039c0185dbee7ed080f1f2bd22cb1e4dab upstream.
Per ZBC/ZAC/ZNS specifications, write pointers may not have valid values when zones are in full condition. However, when zonefs mounts a zoned block device, zonefs refers write pointers to set file size even when the zones are in full condition. This results in wrong file size. To fix this, refer maximum file size in place of write pointers for zones in full condition.
--- fs/zonefs/super.c | 3 +++ 1 file changed, 3 insertions(+)
fs/zonefs/super.c +3 -0
@@ -250,6 +250,9 @@ static loff_t zonefs_check_zone_conditio } inode->i_mode &= ~0222 ;return i_size_read (inode); +case BLK_ZONE_COND_FULL : +/* The write pointer of full zones is invalid. */ +return zi->i_max_size;default :if (zi->i_ztype ==ZONEFS_ZTYPE_CNV )return zi->i_max_size;
Greg Kroah-Hartman
maintainerPATCH 726/775 kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE
In reply to Greg Kroah-HartmanFrom: Chris Wilson <[email protected]>
commit bfe3911a91047557eb0e620f95a370aee6a248c7 upstream.
Userspace has discovered the functionality offered by SYS_kcmp and has started to depend upon it. In particular, Mesa uses SYS_kcmp for os_same_file_description() in order to identify when two fd (e.g. device or dmabuf) point to the same struct file. Since they depend on it for core functionality, lift SYS_kcmp out of the non-default CONFIG_CHECKPOINT_RESTORE into the selectable syscall category.
Rasmus Villemoes also pointed out that systemd uses SYS_kcmp to deduplicate the per-service file descriptor store.
Note that some distributions such as Ubuntu are already enabling CHECKPOINT_RESTORE in their configs and so, by extension, SYS_kcmp.
--- drivers/gpu/drm/Kconfig | 3 +++ fs/eventpoll.c | 4 ++-- include/linux/eventpoll.h | 2 +- init/Kconfig | 11 +++++++++++ kernel/Makefile | 2 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-)
drivers/gpu/drm/Kconfig +3 -0
@@ -15,6 +15,9 @@ menuconfig DRM select I2C_ALGOBIT select DMA_SHARED_BUFFER select SYNC_FILE +# gallium uses SYS_kcmp for os_same_file_description() to de-duplicate +# device and dmabuf fd. Let's make sure that is available for our userspace. + select KCMP help Kernel-level support for the Direct Rendering Infrastructure (DRI) introduced in XFree86 4.0. If you say Y here, you need to select
fs/eventpoll.c +2 -2
@@ -979,7 +979,7 @@ static struct epitem *ep_find(struct evereturn epir; } -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_KCMP static struct epitem *ep_find_tfd (struct eventpoll *ep,int tfd,unsigned long toff) {struct rb_node *rbp;
@@ -1021,7 +1021,7 @@ struct file *get_epoll_tfile_raw_ptr(str return file_raw; } -#endif /* CONFIG_CHECKPOINT_RESTORE */ +#endif /* CONFIG_KCMP */ /** * Adds a new entry to the tail of the list in a lockless way, i.e.
include/linux/eventpoll.h +1 -1
@@ -18,7 +18,7 @@ struct file;#ifdef CONFIG_EPOLL -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_KCMP struct file *get_epoll_tfile_raw_ptr (struct file *file,int tfd,unsigned long toff);#endif
init/Kconfig +11 -0
@@ -1193,6 +1193,7 @@ endif # NAMESPACES config CHECKPOINT_RESTORE bool "Checkpoint/restore support" select PROC_CHILDREN + select KCMP default n help Enables additional kernel features in a sake of checkpoint/restore.
@@ -1736,6 +1737,16 @@ config ARCH_HAS_MEMBARRIER_CALLBACKS config ARCH_HAS_MEMBARRIER_SYNC_CORE bool +config KCMP + bool "Enable kcmp() system call" if EXPERT + help + Enable the kernel resource comparison system call. It provides + user-space with the ability to compare two processes to see if they + share a common resource, such as a file descriptor or even virtual + memory space. + + If unsure, say N. + config RSEQ bool "Enable rseq() system call" if EXPERT default y
kernel/Makefile +1 -1
@@ -51,7 +51,7 @@ obj-y += livepatch/ obj-y += dma/ obj-y += entry/ -obj-$(CONFIG_CHECKPOINT_RESTORE) += kcmp.o +obj-$(CONFIG_KCMP) += kcmp.o obj-$(CONFIG_FREEZER) += freezer.o obj-$(CONFIG_PROFILING) += profile.o obj-$(CONFIG_STACKTRACE) += stacktrace.o
tools/testing/selftests/seccomp/seccomp_bpf.c +1 -1
@@ -315,7 +315,7 @@ TEST(kcmp) ret =__filecmp (getpid (),getpid (),1 ,1 );EXPECT_EQ (ret,0 );if (ret !=0 && errno ==ENOSYS ) -SKIP (return,"Kernel does not support kcmp() (missing CONFIG_CHECKPOINT_RESTORE?)" ); +SKIP (return,"Kernel does not support kcmp() (missing CONFIG_KCMP?)" ); }TEST (mode_strict_support)
Greg Kroah-Hartman
maintainerPATCH 727/775 thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error
In reply to Greg Kroah-HartmanFrom: Viresh Kumar <[email protected]>
commit a51afb13311cd85b2f638c691b2734622277d8f5 upstream.
freq_qos_update_request() returns 1 if the effective constraint value has changed, 0 if the effective constraint value has not changed, or a negative error code on failures.
The frequency constraints for CPUs can be set by different parts of the kernel. If the maximum frequency constraint set by other parts of the kernel are set at a lower value than the one corresponding to cooling state 0, then we will never be able to cool down the system as freq_qos_update_request() will keep on returning 0 and we will skip updating cpufreq_state and thermal pressure.
Fix that by doing the updates even in the case where freq_qos_update_request() returns 0, as we have effectively set the constraint to a new value even if the consolidated value of the actual constraint is unchanged because of external factors.
--- drivers/thermal/cpufreq_cooling.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/cpufreq_cooling.c +1 -1
@@ -441,7 +441,7 @@ static int cpufreq_set_cur_state(struct frequency =get_state_freq (cpufreq_cdev, state); ret =freq_qos_update_request (&cpufreq_cdev->qos_req, frequency); -if (ret >0 ) { +if (ret >=0 ) { cpufreq_cdev->cpufreq_state = state; cpus = cpufreq_cdev->policy->cpus; max_capacity =arch_scale_cpu_capacity (cpumask_first (cpus));
Greg Kroah-Hartman
maintainerPATCH 728/775 cpufreq: qcom-hw: drop devm_xxx() calls from init/exit hooks
In reply to Greg Kroah-HartmanFrom: Shawn Guo <[email protected]>
commit 67fc209b527d023db4d087c68e44e9790aa089ef upstream.
Commit f17b3e44320b ("cpufreq: qcom-hw: Use devm_platform_ioremap_resource() to simplify code") introduces a regression on platforms using the driver, by failing to initialise a policy, when one is created post hotplug.
When all the CPUs of a policy are hoptplugged out, the call to .exit() and later to devm_iounmap() does not release the memory region that was requested during devm_platform_ioremap_resource(). Therefore, a subsequent call to .init() will result in the following error, which will prevent a new policy to be initialised:
[ 3395.915416] CPU4: shutdown [ 3395.938185] psci: CPU4 killed (polled 0 ms) [ 3399.071424] CPU5: shutdown [ 3399.094316] psci: CPU5 killed (polled 0 ms) [ 3402.139358] CPU6: shutdown [ 3402.161705] psci: CPU6 killed (polled 0 ms) [ 3404.742939] CPU7: shutdown [ 3404.765592] psci: CPU7 killed (polled 0 ms) [ 3411.492274] Detected VIPT I-cache on CPU4 [ 3411.492337] GICv3: CPU4: found redistributor 400 region 0:0x0000000017ae0000 [ 3411.492448] CPU4: Booted secondary processor 0x0000000400 [0x516f802d] [ 3411.503654] qcom-cpufreq-hw 17d43000.cpufreq: can't request region for resource [mem 0x17d45800-0x17d46bff]
With that being said, the original code was tricky and skipping memory region request intentionally to hide this issue. The true cause is that those devm_xxx() device managed functions shouldn't be used for cpufreq init/exit hooks, because &pdev->dev is alive across the hooks and will not trigger auto resource free-up. Let's drop the use of device managed functions and manually allocate/free resources, so that the issue can be fixed properly.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 40 ++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-)
drivers/cpufreq/qcom-cpufreq-hw.c +32 -8
@@ -32,6 +32,7 @@ struct qcom_cpufreq_soc_data {struct qcom_cpufreq_data {void __iomem *base; +struct resource *res;const struct qcom_cpufreq_soc_data *soc_data; };
@@ -280,6 +281,7 @@ static int qcom_cpufreq_hw_cpu_init(strustruct of_phandle_args args;struct device_node *cpu_np;struct device *cpu_dev; +struct resource *res;void __iomem *base;struct qcom_cpufreq_data *data;int ret, index;
@@ -303,18 +305,33 @@ static int qcom_cpufreq_hw_cpu_init(stru index = args.args[0 ]; - base =devm_platform_ioremap_resource (pdev, index); -if (IS_ERR (base)) -return PTR_ERR (base); + res =platform_get_resource (pdev,IORESOURCE_MEM , index); +if (!res) { +dev_err (dev,"failed to get mem resource %d\n" , index); +return -ENODEV ; + } + +if (!request_mem_region (res->start,resource_size (res), res->name)) { +dev_err (dev,"failed to request resource %pR\n" , res); +return -EBUSY ; + } - data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL ); + base =ioremap (res->start,resource_size (res)); +if (IS_ERR (base)) { +dev_err (dev,"failed to map resource %pR\n" , res); + ret =PTR_ERR (base); + goto release_region; + } + + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data) { ret = -ENOMEM ; - goto error; + goto unmap_base; } data->soc_data =of_device_get_match_data (&pdev->dev); data->base = base; + data->res = res;/* HW should be in enabled state to proceed */ if (!(readl_relaxed (base + data->soc_data->reg_enable) &0x1 )) {
@@ -349,7 +366,11 @@ static int qcom_cpufreq_hw_cpu_init(strureturn 0 ; error: -devm_iounmap (dev, base); +kfree (data); +unmap_base: +iounmap (data->base); +release_region: +release_mem_region (res->start,resource_size (res));return ret; }
@@ -357,12 +378,15 @@ static int qcom_cpufreq_hw_cpu_exit(stru {struct device *cpu_dev =get_cpu_device (policy->cpu);struct qcom_cpufreq_data *data = policy->driver_data; -struct platform_device *pdev =cpufreq_get_driver_data (); +struct resource *res = data->res; +void __iomem *base = data->base;dev_pm_opp_remove_all_dynamic (cpu_dev);dev_pm_opp_of_cpumask_remove_table (policy->related_cpus);kfree (policy->freq_table); -devm_iounmap (&pdev->dev, data->base); +kfree (data); +iounmap (base); +release_mem_region (res->start,resource_size (res));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 729/775 cpufreq: intel_pstate: Change intel_pstate_get_hwp_max() argument
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit a45ee4d4e13b0e35a8ec7ea0bf9267243d57b302 upstream.
All of the callers of intel_pstate_get_hwp_max() access the struct cpudata object that corresponds to the given CPU already and the function itself needs to access that object (in order to update hwp_cap_cached), so modify the code to pass a struct cpudata pointer to it instead of the CPU number.
--- drivers/cpufreq/intel_pstate.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/cpufreq/intel_pstate.c +8 -8
@@ -819,13 +819,13 @@ static struct freq_attr *hwp_cpufreq_att NULL, }; -static void intel_pstate_get_hwp_max (unsigned int cpu,int *phy_max, +static void intel_pstate_get_hwp_max (struct cpudata *cpu,int *phy_max,int *current_max) {u64 cap; -rdmsrl_on_cpu (cpu,MSR_HWP_CAPABILITIES , &cap); -WRITE_ONCE (all_cpu_data[cpu]->hwp_cap_cached, cap); +rdmsrl_on_cpu (cpu->cpu,MSR_HWP_CAPABILITIES , &cap); +WRITE_ONCE (cpu->hwp_cap_cached, cap);if (global.no_turbo || global.turbo_disabled) *current_max =HWP_GUARANTEED_PERF (cap);else
@@ -1213,7 +1213,7 @@ static void update_qos_request(enum freqcontinue ;if (hwp_active) -intel_pstate_get_hwp_max (i, &turbo_max, &max_state); +intel_pstate_get_hwp_max (cpu, &turbo_max, &max_state);else turbo_max = cpu->pstate.turbo_pstate;
@@ -1723,7 +1723,7 @@ static void intel_pstate_get_cpu_pstatesif (hwp_active && !hwp_mode_bdw) {unsigned int phy_max, current_max; -intel_pstate_get_hwp_max (cpu->cpu, &phy_max, ¤t_max); +intel_pstate_get_hwp_max (cpu, &phy_max, ¤t_max); cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; cpu->pstate.turbo_pstate = phy_max; }else {
@@ -2207,7 +2207,7 @@ static void intel_pstate_update_perf_lim* rather than pure ratios. */ if (hwp_active) { -intel_pstate_get_hwp_max (cpu->cpu, &turbo_max, &max_state); +intel_pstate_get_hwp_max (cpu, &turbo_max, &max_state); }else { max_state = global.no_turbo || global.turbo_disabled ? cpu->pstate.max_pstate : cpu->pstate.turbo_pstate;
@@ -2322,7 +2322,7 @@ static void intel_pstate_verify_cpu_poliif (hwp_active) {int max_state, turbo_max; -intel_pstate_get_hwp_max (cpu->cpu, &turbo_max, &max_state); +intel_pstate_get_hwp_max (cpu, &turbo_max, &max_state); max_freq = max_state * cpu->pstate.scaling; }else { max_freq =intel_pstate_get_max_freq (cpu);
@@ -2709,7 +2709,7 @@ static int intel_cpufreq_cpu_init(structif (hwp_active) {u64 value; -intel_pstate_get_hwp_max (policy->cpu, &turbo_max, &max_state); +intel_pstate_get_hwp_max (cpu, &turbo_max, &max_state); policy->transition_delay_us =INTEL_CPUFREQ_TRANSITION_DELAY_HWP ;rdmsrl_on_cpu (cpu->cpu,MSR_HWP_REQUEST , &value);WRITE_ONCE (cpu->hwp_req_cached, value);
Greg Kroah-Hartman
maintainerPATCH 730/775 cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available
In reply to Greg Kroah-HartmanFrom: Chen Yu <[email protected]>
commit 6f67e060083a84a4cc364eab6ae40c717165fb0c upstream.
Currently, when turbo is disabled (either by BIOS or by the user), the intel_pstate driver reads the max non-turbo frequency from the package-wide MSR_PLATFORM_INFO(0xce) register.
However, on asymmetric platforms it is possible in theory that small and big core with HWP enabled might have different max non-turbo CPU frequency, because MSR_HWP_CAPABILITIES is per-CPU scope according to Intel Software Developer Manual.
The turbo max freq is already per-CPU in current code, so make similar change to the max non-turbo frequency as well.
--- drivers/cpufreq/intel_pstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +3 -2
@@ -1714,11 +1714,9 @@ static void intel_pstate_max_within_limistatic void intel_pstate_get_cpu_pstates (struct cpudata *cpu) { cpu->pstate.min_pstate = pstate_funcs.get_min (); - cpu->pstate.max_pstate = pstate_funcs.get_max (); cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical (); cpu->pstate.turbo_pstate = pstate_funcs.get_turbo (); cpu->pstate.scaling = pstate_funcs.get_scaling (); - cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;if (hwp_active && !hwp_mode_bdw) {unsigned int phy_max, current_max;
@@ -1726,9 +1724,12 @@ static void intel_pstate_get_cpu_pstatesintel_pstate_get_hwp_max (cpu, &phy_max, ¤t_max); cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; cpu->pstate.turbo_pstate = phy_max; + cpu->pstate.max_pstate =HWP_GUARANTEED_PERF (READ_ONCE (cpu->hwp_cap_cached)); }else { cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; + cpu->pstate.max_pstate = pstate_funcs.get_max (); } + cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling;if (pstate_funcs.get_aperf_mperf_shift) cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift ();
Greg Kroah-Hartman
maintainerPATCH 731/775 proc: dont allow async path resolution of /proc/thread-self components
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 0d4370cfe36b7f1719123b621a4ec4d9c7a25f89 upstream.
If this is attempted by an io-wq kthread, then return -EOPNOTSUPP as we don't currently support that. Once we can get task_pid_ptr() doing the right thing, then this can go away again.
Use PF_IO_WORKER for this to speciically target the io_uring workers. Modify the /proc/self/ check to use PF_IO_WORKER as well.
--- fs/proc/self.c | 2 +- fs/proc/thread_self.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
fs/proc/self.c +1 -1
@@ -20,7 +20,7 @@ static const char *proc_self_get_link(st* Not currently supported. Once we can inherit all of struct pid, * we can allow this. */ -if (current->flags &PF_KTHREAD ) +if (current->flags &PF_IO_WORKER )return ERR_PTR (-EOPNOTSUPP );if (!tgid)
fs/proc/thread_self.c +7 -0
@@ -17,6 +17,13 @@ static const char *proc_thread_self_get_pid_t pid =task_pid_nr_ns (current, ns);char *name; +/* +* Not currently supported. Once we can inherit all of struct pid, +* we can allow this. +*/ +if (current->flags &PF_IO_WORKER ) +return ERR_PTR (-EOPNOTSUPP ); +if (!pid)return ERR_PTR (-ENOENT ); name =kmalloc (10 +6 +10 +1 , dentry ?GFP_KERNEL :GFP_ATOMIC );
Greg Kroah-Hartman
maintainerPATCH 732/775 s390/vtime: fix inline assembly clobber list
In reply to Greg Kroah-HartmanFrom: Heiko Carstens <[email protected]>
commit b29c5093820d333eef22f58cd04ec0d089059c39 upstream.
The stck/stckf instruction used within the inline assembly within do_account_vtime() changes the condition code. This is not reflected with the clobber list, and therefore might result in incorrect code generation.
It seems unlikely that the compiler could generate incorrect code considering the surrounding C code, but it must still be fixed.
--- arch/s390/kernel/vtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/s390/kernel/vtime.c +2 -1
@@ -136,7 +136,8 @@ static int do_account_vtime(struct task_" stck %1" /* Store current tod clock value */ #endif : "=Q" (S390_lowcore.last_update_timer), - "=Q" (S390_lowcore.last_update_clock)); +"=Q" (S390_lowcore.last_update_clock) + : : "cc"); clock = S390_lowcore.last_update_clock - clock; timer -= S390_lowcore.last_update_timer;
Greg Kroah-Hartman
maintainerPATCH 733/775 virtio/s390: implement virtio-ccw revision 2 correctly
In reply to Greg Kroah-HartmanFrom: Cornelia Huck <[email protected]>
commit 182f709c5cff683e6732d04c78e328de0532284f upstream.
CCW_CMD_READ_STATUS was introduced with revision 2 of virtio-ccw, and drivers should only rely on it being implemented when they negotiated at least that revision with the device.
However, virtio_ccw_get_status() issued READ_STATUS for any device operating at least at revision 1. If the device accepts READ_STATUS regardless of the negotiated revision (which some implementations like QEMU do, even though the spec currently does not allow it), everything works as intended. While a device rejecting the command should also be handled gracefully, we will not be able to see any changes the device makes to the status, such as setting NEEDS_RESET or setting the status to zero after a completed reset.
We negotiated the revision to at most 1, as we never bumped the maximum revision; let's do that now and properly send READ_STATUS only if we are operating at least at revision 2.
--- drivers/s390/virtio/virtio_ccw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/virtio/virtio_ccw.c +2 -2
@@ -117,7 +117,7 @@ struct virtio_rev_info { };/* the highest virtio-ccw revision we support */ -#define VIRTIO_CCW_REV_MAX 1 +#define VIRTIO_CCW_REV_MAX 2struct virtio_ccw_vq_info {struct virtqueue *vq;
@@ -952,7 +952,7 @@ static u8 virtio_ccw_get_status(struct vu8 old_status = vcdev->dma_area->status;struct ccw1 *ccw; -if (vcdev->revision <1 ) +if (vcdev->revision <2 )return vcdev->dma_area->status; ccw =ccw_device_dma_zalloc (vcdev->cdev,sizeof (*ccw));
Greg Kroah-Hartman
maintainerPATCH 734/775 um: mm: check more comprehensively for stub changes
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 47da29763ec9a153b9b685bff9db659e4e09e494 upstream.
If userspace tries to change the stub, we need to kill it, because otherwise it can escape the virtual machine. In a few cases the stub checks weren't good, e.g. if userspace just tries to
mmap(0x100000 - 0x1000, 0x3000, ...)
it could succeed to get a new private/anonymous mapping replacing the stubs. Fix this by checking everywhere, and checking for _overlap_, not just direct changes.
--- arch/um/kernel/tlb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/um/kernel/tlb.c +11 -1
@@ -125,6 +125,9 @@ static int add_mmap(unsigned long virt,struct host_vm_op *last;int fd =-1 , ret =0 ; +if (virt + len >STUB_START && virt <STUB_END ) +return -EINVAL ; +if (hvc->userspace) fd =phys_mapping (phys, &offset);else
@@ -162,7 +165,7 @@ static int add_munmap(unsigned long addrstruct host_vm_op *last;int ret =0 ; -if ((addr >=STUB_START ) && (addr <STUB_END )) +if (addr + len >STUB_START && addr <STUB_END )return -EINVAL ;if (hvc->index !=0 ) {
@@ -192,6 +195,9 @@ static int add_mprotect(unsigned long adstruct host_vm_op *last;int ret =0 ; +if (addr + len >STUB_START && addr <STUB_END ) +return -EINVAL ; +if (hvc->index !=0 ) { last = &hvc->ops[hvc->index -1 ]; if ((last->type == MPROTECT) &&
@@ -472,6 +478,10 @@ void flush_tlb_page(struct vm_area_strucstruct mm_id *mm_id; address &=PAGE_MASK ; + +if (address >=STUB_START && address <STUB_END ) + goto kill; + pgd =pgd_offset (mm, address);if (!pgd_present (*pgd)) goto kill;
Greg Kroah-Hartman
maintainerPATCH 735/775 um: defer killing userspace on page table update failures
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit a7d48886cacf8b426e0079bca9639d2657cf2d38 upstream.
In some cases we can get to fix_range_common() with mmap_sem held, and in others we get there without it being held. For example, we get there with it held from sys_mprotect(), and without it held from fork_handler().
Avoid any issues in this and simply defer killing the task until it runs the next time. Do it on the mm so that another task that shares the same mm can't continue running afterwards.
--- arch/um/include/shared/skas/mm_id.h | 1 + arch/um/kernel/tlb.c | 7 +++---- arch/um/os-Linux/skas/process.c | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-)
arch/um/include/shared/skas/mm_id.h +1 -0
@@ -12,6 +12,7 @@ struct mm_id { int pid; } u;unsigned long stack; +int kill; };#endif
arch/um/kernel/tlb.c +3 -4
@@ -352,12 +352,11 @@ void fix_range_common(struct mm_struct */* This is not an else because ret is modified above */ if (ret) { +struct mm_id *mm_idp = ¤t->mm->context.id; +printk (KERN_ERR "fix_range_common: failed, killing current " "process: %d\n" ,task_tgid_vnr (current)); -/* We are under mmap_lock, release it such that current can terminate */ -mmap_write_unlock (current->mm); -force_sig (SIGKILL ); -do_signal (¤t->thread.regs); + mm_idp->kill =1 ; } }
arch/um/os-Linux/skas/process.c +4 -0
@@ -249,6 +249,7 @@ static int userspace_tramp(void *stack) }int userspace_pid[NR_CPUS ]; +int kill_userspace_mm[NR_CPUS ];/** * start_userspace() - prepare a new userspace process
@@ -342,6 +343,8 @@ void userspace(struct uml_pt_regs *regs,interrupt_end ();while (1 ) { +if (kill_userspace_mm[0 ]) +fatal_sigsegv ();/* * This can legitimately fail if the process loads a
@@ -663,4 +666,5 @@ void reboot_skas(void)void __switch_mm (struct mm_id *mm_idp) { userspace_pid[0 ] = mm_idp->u.pid; + kill_userspace_mm[0 ] = mm_idp->kill; }
Greg Kroah-Hartman
maintainerPATCH 736/775 irqchip/loongson-pch-msi: Use bitmap_zalloc() to allocate bitmap
In reply to Greg Kroah-HartmanFrom: Huacai Chen <[email protected]>
commit c1f664d2400e73d5ca0fcd067fa5847d2c789c11 upstream.
Currently we use bitmap_alloc() to allocate msi bitmap which should be initialized with zero. This is obviously wrong but it works because msi can fallback to legacy interrupt mode. So use bitmap_zalloc() instead.
--- drivers/irqchip/irq-loongson-pch-msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-loongson-pch-msi.c +1 -1
@@ -225,7 +225,7 @@ static int pch_msi_init(struct device_no goto err_priv; } - priv->msi_map =bitmap_alloc (priv->num_irqs,GFP_KERNEL ); + priv->msi_map =bitmap_zalloc (priv->num_irqs,GFP_KERNEL );if (!priv->msi_map) { ret = -ENOMEM ; goto err_priv;
Greg Kroah-Hartman
maintainerPATCH 737/775 f2fs: fix out-of-repair __setattr_copy()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit 2562515f0ad7342bde6456602c491b64c63fe950 upstream.
__setattr_copy() was copied from setattr_copy() in fs/attr.c, there is two missing patches doesn't cover this inner function, fix it.
Commit 7fa294c8991c ("userns: Allow chown and setgid preservation") Commit 23adbe12ef7d ("fs,userns: Change inode_capable to capable_wrt_inode_uidgid")
--- fs/f2fs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/file.c +2 -1
@@ -852,7 +852,8 @@ static void __setattr_copy(struct inodeif (ia_valid &ATTR_MODE ) {umode_t mode = attr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (inode->i_gid) && + !capable_wrt_inode_uidgid (inode,CAP_FSETID )) mode &= ~S_ISGID ;set_acl_inode (inode, mode); }
Greg Kroah-Hartman
maintainerPATCH 738/775 f2fs: enforce the immutable flag on open files
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
commit e0fcd01510ad025c9bbce704c5c2579294056141 upstream.
This patch ports commit 02b016ca7f99 ("ext4: enforce the immutable flag on open files") to f2fs.
According to the chattr man page, "a file with the 'i' attribute cannot be modified..." Historically, this was only enforced when the file was opened, per the rest of the description, "... and the file can not be opened in write mode".
There is general agreement that we should standardize all file systems to prevent modifications even for files that were opened at the time the immutable flag is set. Eventually, a change to enforce this at the VFS layer should be landing in mainline.
--- fs/f2fs/file.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/f2fs/file.c +17 -0
@@ -60,6 +60,9 @@ static vm_fault_t f2fs_vm_page_mkwrite(sbool need_alloc = true;int err =0 ; +if (unlikely (IS_IMMUTABLE (inode))) +return VM_FAULT_SIGBUS ; +if (unlikely (f2fs_cp_error (sbi))) { err = -EIO ; goto err;
@@ -870,6 +873,14 @@ int f2fs_setattr(struct dentry *dentry,if (unlikely (f2fs_cp_error (F2FS_I_SB (inode))))return -EIO ; +if (unlikely (IS_IMMUTABLE (inode))) +return -EPERM ; + +if (unlikely (IS_APPEND (inode) && + (attr->ia_valid & (ATTR_MODE |ATTR_UID | +ATTR_GID |ATTR_TIMES_SET )))) +return -EPERM ; +if ((attr->ia_valid &ATTR_SIZE ) && !f2fs_is_compress_backend_ready (inode))return -EOPNOTSUPP ;
@@ -4356,6 +4367,11 @@ static ssize_t f2fs_file_write_iter(struinode_lock (inode); } +if (unlikely (IS_IMMUTABLE (inode))) { + ret = -EPERM ; + goto unlock; + } + ret =generic_write_checks (iocb, from);if (ret >0 ) {bool preallocated = false;
@@ -4420,6 +4436,7 @@ write:if (ret >0 )f2fs_update_iostat (F2FS_I_SB (inode),APP_WRITE_IO , ret); } +unlock:inode_unlock (inode); out: trace_f2fs_file_write_iter(inode, iocb->ki_pos,
Greg Kroah-Hartman
maintainerPATCH 739/775 f2fs: flush data when enabling checkpoint back
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
commit b0ff4fe746fd028eef920ddc8c7b0361c1ede6ec upstream.
During checkpoint=disable period, f2fs bypasses all the synchronous IOs such as sync and fsync. So, when enabling it back, we must flush all of them in order to keep the data persistent. Otherwise, suddern power-cut right after enabling checkpoint will cause data loss.
--- fs/f2fs/super.c | 3 +++ 1 file changed, 3 insertions(+)
fs/f2fs/super.c +3 -0
@@ -1796,6 +1796,9 @@ restore_flag:static void f2fs_enable_checkpoint (struct f2fs_sb_info *sbi) { +/* we should flush all the data to keep data consistency */ +sync_inodes_sb (sbi->sb); +down_write (&sbi->gc_lock);f2fs_dirty_to_prefree (sbi);
Greg Kroah-Hartman
maintainerPATCH 740/775 cifs: fix DFS failover
In reply to Greg Kroah-HartmanFrom: Paulo Alcantara <[email protected]>
commit 8513222b9ef2709ba40cbda07b55d5fbcfdd4bc7 upstream.
In do_dfs_failover(), the mount_get_conns() function requires the full fs context in order to get new connection to server, so clone the original context and change it accordingly when retrying the DFS targets in the referral.
If failover was successful, then update original context with the new UNC, prefix path and ip address.
--- fs/cifs/connect.c | 123 +++++++++++++++++++++++++----------------------------- 1 file changed, 59 insertions(+), 64 deletions(-)
fs/cifs/connect.c +59 -64
@@ -3038,96 +3038,91 @@ static int update_vol_info(const structreturn 0 ; } -static int setup_dfs_tgt_conn (const char *path,const char *full_path, -const struct dfs_cache_tgt_iterator *tgt_it, -struct cifs_sb_info *cifs_sb,struct smb3_fs_context *ctx, -unsigned int *xid,struct TCP_Server_Info **server, -struct cifs_ses **ses,struct cifs_tcon **tcon) -{ -int rc; -struct dfs_info3_param ref = {0 }; -char *mdata =NULL ; -struct smb3_fs_context fake_ctx = {NULL }; -char *fake_devname =NULL ; - -cifs_dbg (FYI ,"%s: dfs path: %s\n" , __func__, path); - - rc =dfs_cache_get_tgt_referral (path, tgt_it, &ref); -if (rc) -return rc; - - mdata =cifs_compose_mount_options (cifs_sb->ctx->mount_options, - full_path +1 , &ref, - &fake_devname); -free_dfs_info_param (&ref); - -if (IS_ERR (mdata)) { - rc =PTR_ERR (mdata); - mdata =NULL ; - }else - rc =cifs_setup_volume_info (&fake_ctx, mdata, fake_devname); - -kfree (mdata); -kfree (fake_devname); - -if (!rc) { -/* -* We use a 'fake_ctx' here because we need pass it down to the -* mount_{get,put} functions to test connection against new DFS -* targets. -*/ -mount_put_conns (cifs_sb, *xid, *server, *ses, *tcon); - rc =mount_get_conns (&fake_ctx, cifs_sb, xid, server, ses, - tcon); -if (!rc || (*server && *ses)) { -/* -* We were able to connect to new target server. -* Update current context with new target server. -*/ - rc =update_vol_info (tgt_it, &fake_ctx, ctx); - } - } -smb3_cleanup_fs_context_contents (&fake_ctx); -return rc; -} -static int do_dfs_failover (const char *path,const char *full_path,struct cifs_sb_info *cifs_sb,struct smb3_fs_context *ctx,struct cifs_ses *root_ses,unsigned int *xid,struct TCP_Server_Info **server,struct cifs_ses **ses,struct cifs_tcon **tcon) {int rc; -struct dfs_cache_tgt_list tgt_list; +struct dfs_cache_tgt_list tgt_list = {0 };struct dfs_cache_tgt_iterator *tgt_it =NULL ; +struct smb3_fs_context tmp_ctx = {NULL };if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS )return -EOPNOTSUPP ; +cifs_dbg (FYI ,"%s: path=%s full_path=%s\n" , __func__, path, full_path); + rc =dfs_cache_noreq_find (path,NULL , &tgt_list);if (rc)return rc; +/* +* We use a 'tmp_ctx' here because we need pass it down to the mount_{get,put} functions to +* test connection against new DFS targets. +*/ + rc =smb3_fs_context_dup (&tmp_ctx, ctx); +if (rc) + goto out;for (;;) { +struct dfs_info3_param ref = {0 }; +char *fake_devname =NULL , *mdata =NULL ; +/* Get next DFS target server - if any */ rc =get_next_dfs_tgt (path, &tgt_list, &tgt_it);if (rc)break ; -/* Connect to next DFS target */ - rc =setup_dfs_tgt_conn (path, full_path, tgt_it, cifs_sb, ctx, xid, server, ses, - tcon); -if (!rc || (*server && *ses)) + + rc =dfs_cache_get_tgt_referral (path, tgt_it, &ref); +if (rc) +break ; + +cifs_dbg (FYI ,"%s: old ctx: UNC=%s prepath=%s\n" , __func__, tmp_ctx.UNC, + tmp_ctx.prepath); + + mdata =cifs_compose_mount_options (cifs_sb->ctx->mount_options, full_path +1 , &ref, + &fake_devname); +free_dfs_info_param (&ref); + +if (IS_ERR (mdata)) { + rc =PTR_ERR (mdata); + mdata =NULL ; + }else + rc =cifs_setup_volume_info (&tmp_ctx, mdata, fake_devname); + +kfree (mdata); +kfree (fake_devname); + +if (rc) +break ; + +cifs_dbg (FYI ,"%s: new ctx: UNC=%s prepath=%s\n" , __func__, tmp_ctx.UNC, + tmp_ctx.prepath); + +mount_put_conns (cifs_sb, *xid, *server, *ses, *tcon); + rc =mount_get_conns (&tmp_ctx, cifs_sb, xid, server, ses, tcon); +if (!rc || (*server && *ses)) { +/* +* We were able to connect to new target server. Update current context with +* new target server. +*/ + rc =update_vol_info (tgt_it, &tmp_ctx, ctx);break ; + } }if (!rc) { +cifs_dbg (FYI ,"%s: final ctx: UNC=%s prepath=%s\n" , __func__, tmp_ctx.UNC, + tmp_ctx.prepath);/* -* Update DFS target hint in DFS referral cache with the target -* server we successfully reconnected to. +* Update DFS target hint in DFS referral cache with the target server we +* successfully reconnected to. */ - rc =dfs_cache_update_tgthint (*xid, root_ses ? root_ses : *ses, - cifs_sb->local_nls, -cifs_remap (cifs_sb), path, - tgt_it); + rc =dfs_cache_update_tgthint (*xid, root_ses ? root_ses : *ses, cifs_sb->local_nls, +cifs_remap (cifs_sb), path, tgt_it); } + +out: +smb3_cleanup_fs_context_contents (&tmp_ctx);dfs_cache_free_tgts (&tgt_list);return rc; }