5.18.4-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 282/339 cifs: fix potential deadlock in direct reclaim
In reply to Greg Kroah-HartmanFrom: Vincent Whitchurch <[email protected]>
[ Upstream commit cc391b694ff085f62f133e6b8f864d43a8e69dfd ]
The srv_mutex is used during writeback so cifs should ensure that allocations done when that mutex is held are done with GFP_NOFS, to avoid having direct reclaim ending up waiting for the same mutex and causing a deadlock. This is detected by lockdep with the splat below:
======================================================
WARNING: possible circular locking dependency detected
5.18.0 #70 Not tainted
------------------------------------------------------
kswapd0/49 is trying to acquire lock:
ffff8880195782e0 (&tcp_ses->srv_mutex){+.+.}-{3:3}, at: compound_send_recv
but task is already holding lock:
ffffffffa98e66c0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (fs_reclaim){+.+.}-{0:0}:
fs_reclaim_acquire
kmem_cache_alloc_trace
__request_module
crypto_alg_mod_lookup
crypto_alloc_tfm_node
crypto_alloc_shash
cifs_alloc_hash
smb311_crypto_shash_allocate
smb311_update_preauth_hash
compound_send_recv
cifs_send_recv
SMB2_negotiate
smb2_negotiate
cifs_negotiate_protocol
cifs_get_smb_ses
cifs_mount
cifs_smb3_do_mount
smb3_get_tree
vfs_get_tree
path_mount
__x64_sys_mount
do_syscall_64
entry_SYSCALL_64_after_hwframe -> #0 (&tcp_ses->srv_mutex){+.+.}-{3:3}:
__lock_acquire
lock_acquire
__mutex_lock
mutex_lock_nested
compound_send_recv
cifs_send_recv
SMB2_write
smb2_sync_write
cifs_write
cifs_writepage_locked
cifs_writepage
shrink_page_list
shrink_lruvec
shrink_node
balance_pgdat
kswapd
kthread
ret_from_fork
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(fs_reclaim);
lock(&tcp_ses->srv_mutex);
lock(fs_reclaim); lock(&tcp_ses->srv_mutex);
*** DEADLOCK ***
1 lock held by kswapd0/49:
#0: ffffffffa98e66c0 (fs_reclaim){+.+.}-{0:0}, at: balance_pgdat
stack backtrace: CPU: 2 PID: 49 Comm: kswapd0 Not tainted 5.18.0 #70 Call Trace: <TASK> dump_stack_lvl dump_stack print_circular_bug.cold check_noncircular __lock_acquire lock_acquire __mutex_lock mutex_lock_nested compound_send_recv cifs_send_recv SMB2_write smb2_sync_write cifs_write cifs_writepage_locked cifs_writepage shrink_page_list shrink_lruvec shrink_node balance_pgdat kswapd kthread ret_from_fork </TASK>
Fix this by using the memalloc_nofs_save/restore APIs around the places where the srv_mutex is held. Do this in a wrapper function for the lock/unlock of the srv_mutex, and rename the srv_mutex to avoid missing call sites in the conversion.
Note that there is another lockdep warning involving internal crypto locks, which was masked by this problem and is visible after this fix, see the discussion in this thread:
https://lore.kernel.org/all/[email protected]/
--- fs/cifs/cifs_swn.c | 4 ++-- fs/cifs/cifsencrypt.c | 8 ++++---- fs/cifs/cifsglob.h | 20 +++++++++++++++++++- fs/cifs/connect.c | 26 +++++++++++++------------- fs/cifs/dfs_cache.c | 4 ++-- fs/cifs/sess.c | 6 +++--- fs/cifs/smb1ops.c | 6 +++--- fs/cifs/smb2pdu.c | 6 +++--- fs/cifs/smbdirect.c | 4 ++-- fs/cifs/transport.c | 40 ++++++++++++++++++++-------------------- 10 files changed, 71 insertions(+), 53 deletions(-)
fs/cifs/cifs_swn.c +2 -2
@@ -465,7 +465,7 @@ static int cifs_swn_reconnect(struct cifs_tcon *tcon, struct sockaddr_storage *aint ret =0 ;/* Store the reconnect address */ -mutex_lock (&tcon->ses->server->srv_mutex); +cifs_server_lock (tcon->ses->server);if (cifs_sockaddr_equal (&tcon->ses->server->dstaddr, addr)) goto unlock;
@@ -501,7 +501,7 @@ static int cifs_swn_reconnect(struct cifs_tcon *tcon, struct sockaddr_storage *acifs_signal_cifsd_for_reconnect (tcon->ses->server, false); unlock: -mutex_unlock (&tcon->ses->server->srv_mutex); +cifs_server_unlock (tcon->ses->server);return ret; }
fs/cifs/cifsencrypt.c +4 -4
@@ -236,9 +236,9 @@ int cifs_verify_signature(struct smb_rqst *rqst,cpu_to_le32 (expected_sequence_number); cifs_pdu->Signature.Sequence.Reserved =0 ; -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); rc =cifs_calc_signature (rqst, server, what_we_think_sig_should_be); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);if (rc)return rc;
@@ -626,7 +626,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)memcpy (ses->auth_key.response + baselen, tiblob, tilen); -mutex_lock (&ses->server->srv_mutex); +cifs_server_lock (ses->server); rc = cifs_alloc_hash("hmac(md5)", &ses->server->secmech.hmacmd5,
@@ -678,7 +678,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)cifs_dbg (VFS ,"%s: Could not generate md5 hash\n" , __func__); unlock: -mutex_unlock (&ses->server->srv_mutex); +cifs_server_unlock (ses->server); setup_ntlmv2_rsp_ret:kfree (tiblob);
fs/cifs/cifsglob.h +19 -1
@@ -16,6 +16,7 @@#include <linux/mempool.h> #include <linux/workqueue.h> #include <linux/utsname.h> +#include <linux/sched/mm.h> #include <linux/netfs.h> #include "cifs_fs_sb.h" #include "cifsacl.h"
@@ -621,7 +622,8 @@ struct TCP_Server_Info {unsigned int in_flight;/* number of requests on the wire to server */ unsigned int max_in_flight;/* max number of requests that were on wire */ spinlock_t req_lock;/* protect the two values above */ -struct mutex srv_mutex; +struct mutex _srv_mutex; +unsigned int nofs_flag;struct task_struct *tsk;char server_GUID[16 ];__u16 sec_mode;
@@ -736,6 +738,22 @@ struct TCP_Server_Info {#endif }; +static inline void cifs_server_lock (struct TCP_Server_Info *server) +{ +unsigned int nofs_flag =memalloc_nofs_save (); + +mutex_lock (&server->_srv_mutex); + server->nofs_flag = nofs_flag; +} + +static inline void cifs_server_unlock (struct TCP_Server_Info *server) +{ +unsigned int nofs_flag = server->nofs_flag; + +mutex_unlock (&server->_srv_mutex); +memalloc_nofs_restore (nofs_flag); +} +struct cifs_credits {unsigned int value;unsigned int instance;
fs/cifs/connect.c +13 -13
@@ -148,7 +148,7 @@ static void cifs_resolve_server(struct work_struct *work)struct TCP_Server_Info *server =container_of (work, struct TCP_Server_Info, resolve.work); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);/* * Resolve the hostname again to make sure that IP address is up-to-date.
@@ -159,7 +159,7 @@ static void cifs_resolve_server(struct work_struct *work) __func__, rc); } -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server); }/*
@@ -267,7 +267,7 @@ cifs_abort_connection(struct TCP_Server_Info *server)/* do not want to be sending data on a socket we are freeing */ cifs_dbg (FYI ,"%s: tearing down socket\n" , __func__); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);if (server->ssocket) {cifs_dbg (FYI ,"State: 0x%x Flags: 0x%lx\n" , server->ssocket->state, server->ssocket->flags);
@@ -296,7 +296,7 @@ cifs_abort_connection(struct TCP_Server_Info *server) mid->mid_flags |=MID_DELETED ; }spin_unlock (&GlobalMid_Lock); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);cifs_dbg (FYI ,"%s: issuing mid callbacks\n" , __func__);list_for_each_entry_safe (mid, nmid, &retry_list, qhead) {
@@ -306,9 +306,9 @@ cifs_abort_connection(struct TCP_Server_Info *server) }if (cifs_rdma_enabled (server)) { -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);smbd_destroy (server); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server); } }
@@ -359,7 +359,7 @@ static int __cifs_reconnect(struct TCP_Server_Info *server, do { try_to_freeze(); - mutex_lock(&server->srv_mutex); + cifs_server_lock(server); if (!cifs_swn_set_server_dstaddr(server)) { /* resolve the hostname again to make sure that IP address is up-to-date */
@@ -372,7 +372,7 @@ static int __cifs_reconnect(struct TCP_Server_Info *server,else rc =generic_ip_connect (server);if (rc) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);cifs_dbg (FYI ,"%s: reconnect error %d\n" , __func__, rc);msleep (3000 ); }else {
@@ -383,7 +383,7 @@ static int __cifs_reconnect(struct TCP_Server_Info *server, server->tcpStatus = CifsNeedNegotiate;spin_unlock (&cifs_tcp_ses_lock);cifs_swn_reset_server_dstaddr (server); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);mod_delayed_work (cifsiod_wq, &server->reconnect,0 ); } }while (server->tcpStatus == CifsNeedReconnect);
@@ -488,12 +488,12 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server) do { try_to_freeze(); - mutex_lock(&server->srv_mutex); + cifs_server_lock(server); rc = reconnect_target_unlocked(server, &tl, &target_hint); if (rc) { /* Failed to reconnect socket */ - mutex_unlock(&server->srv_mutex); + cifs_server_unlock(server); cifs_dbg(FYI, "%s: reconnect error %d\n", __func__, rc); msleep(3000); continue;
@@ -510,7 +510,7 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server) server->tcpStatus = CifsNeedNegotiate;spin_unlock (&cifs_tcp_ses_lock);cifs_swn_reset_server_dstaddr (server); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);mod_delayed_work (cifsiod_wq, &server->reconnect,0 ); }while (server->tcpStatus == CifsNeedReconnect);
@@ -1565,7 +1565,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,init_waitqueue_head (&tcp_ses->response_q);init_waitqueue_head (&tcp_ses->request_q);INIT_LIST_HEAD (&tcp_ses->pending_mid_q); -mutex_init (&tcp_ses->srv_mutex); +mutex_init (&tcp_ses->_srv_mutex);memcpy (tcp_ses->workstation_RFC1001_name, ctx->source_rfc1001_name,RFC1001_NAME_LEN_WITH_NULL ); memcpy(tcp_ses->server_RFC1001_name,
fs/cifs/dfs_cache.c +2 -2
@@ -1327,9 +1327,9 @@ static bool target_share_equal(struct TCP_Server_Info *server, const char *s1, ccifs_dbg (VFS ,"%s: failed to convert address \'%s\'. skip address matching.\n" , __func__, ip); }else { -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); match =cifs_match_ipaddr ((struct sockaddr *)&server->dstaddr, &sa); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server); }kfree (ip);
fs/cifs/sess.c +3 -3
@@ -1093,14 +1093,14 @@ sess_establish_session(struct sess_data *sess_data)struct cifs_ses *ses = sess_data->ses;struct TCP_Server_Info *server = sess_data->server; -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);if (!server->session_estab) {if (server->sign) { server->session_key.response =kmemdup (ses->auth_key.response, ses->auth_key.len,GFP_KERNEL );if (!server->session_key.response) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);return -ENOMEM ; } server->session_key.len =
@@ -1109,7 +1109,7 @@ sess_establish_session(struct sess_data *sess_data) server->sequence_number =0x2 ; server->session_estab = true; } -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);cifs_dbg (FYI ,"CIFS session established successfully\n" );return 0 ;
fs/cifs/smb1ops.c +3 -3
@@ -38,10 +38,10 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst, in_buf->WordCount =0 ;put_bcc (0 , in_buf); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); rc =cifs_sign_smb (in_buf, server, &mid->sequence_number);if (rc) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);return rc; }
@@ -55,7 +55,7 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst,if (rc <0 ) server->sequence_number--; -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);cifs_dbg (FYI ,"issued NT_CANCEL for mid %u, rc = %d\n" ,get_mid (in_buf), rc);
fs/cifs/smb2pdu.c +3 -3
@@ -1369,13 +1369,13 @@ SMB2_sess_establish_session(struct SMB2_sess_data *sess_data)struct cifs_ses *ses = sess_data->ses;struct TCP_Server_Info *server = sess_data->server; -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);if (server->ops->generate_signingkey) { rc = server->ops->generate_signingkey (ses, server);if (rc) {cifs_dbg (FYI ,"SMB3 session key generation failed\n" ); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);return rc; } }
@@ -1383,7 +1383,7 @@ SMB2_sess_establish_session(struct SMB2_sess_data *sess_data) server->sequence_number =0x2 ; server->session_estab = true; } -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);cifs_dbg (FYI ,"SMB2/3 session established successfully\n" );return rc;
fs/cifs/smbdirect.c +2 -2
@@ -1382,9 +1382,9 @@ void smbd_destroy(struct TCP_Server_Info *server)log_rdma_event (INFO ,"freeing mr list\n" );wake_up_interruptible_all (&info->wait_mr);while (atomic_read (&info->mr_used_count)) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);msleep (1000 ); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); }destroy_mr_list (info);
fs/cifs/transport.c +20 -20
@@ -822,7 +822,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, }else instance = exist_credits->instance; -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);/* * We can't use credits obtained from the previous session to send this
@@ -830,14 +830,14 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,* return -EAGAIN in such cases to let callers handle it. */ if (instance != server->reconnect_instance) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);add_credits_and_wake_if (server, &credits, optype);return -EAGAIN ; } mid = server->ops->setup_async_request (server, rqst);if (IS_ERR (mid)) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);add_credits_and_wake_if (server, &credits, optype);return PTR_ERR (mid); }
@@ -868,7 +868,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,cifs_delete_mid (mid); } -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);if (rc ==0 )return 0 ;
@@ -1109,7 +1109,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,* of smb data. */ -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);/* * All the parts of the compound chain belong obtained credits from the
@@ -1119,7 +1119,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,* handle it. */ if (instance != server->reconnect_instance) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);for (j =0 ; j < num_rqst; j++)add_credits (server, &credits[j], optype);return -EAGAIN ;
@@ -1131,7 +1131,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,revert_current_mid (server, i);for (j =0 ; j < i; j++)cifs_delete_mid (midQ[j]); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);/* Update # of requests on wire to server */ for (j =0 ; j < num_rqst; j++)
@@ -1163,7 +1163,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, server->sequence_number -=2 ; } -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);/* * If sending failed for some reason or it is an oplock break that we
@@ -1190,9 +1190,9 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,if ((ses->status == CifsNew) || (optype &CIFS_NEG_OP ) || (optype &CIFS_SESS_OP )) {spin_unlock (&cifs_tcp_ses_lock); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);smb311_update_preauth_hash (ses, server, rqst[0 ].rq_iov, rqst[0 ].rq_nvec); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);spin_lock (&cifs_tcp_ses_lock); }
@@ -1266,9 +1266,9 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, .iov_len = resp_iov[0].iov_len };spin_unlock (&cifs_tcp_ses_lock); -mutex_lock (&server->srv_mutex); +cifs_server_lock (server);smb311_update_preauth_hash (ses, server, &iov,1 ); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);spin_lock (&cifs_tcp_ses_lock); }spin_unlock (&cifs_tcp_ses_lock);
@@ -1385,11 +1385,11 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,and avoid races inside tcp sendmsg code that could cause corruption of smb data */ -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); rc =allocate_mid (ses, in_buf, &midQ);if (rc) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);/* Update # of requests on wire to server */ add_credits (server, &credits,0 );return rc;
@@ -1397,7 +1397,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, rc =cifs_sign_smb (in_buf, server, &midQ->sequence_number);if (rc) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server); goto out; }
@@ -1411,7 +1411,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,if (rc <0 ) server->sequence_number -=2 ; -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);if (rc <0 ) goto out;
@@ -1530,18 +1530,18 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,and avoid races inside tcp sendmsg code that could cause corruption of smb data */ -mutex_lock (&server->srv_mutex); +cifs_server_lock (server); rc =allocate_mid (ses, in_buf, &midQ);if (rc) { -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);return rc; } rc =cifs_sign_smb (in_buf, server, &midQ->sequence_number);if (rc) {cifs_delete_mid (midQ); -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);return rc; }
@@ -1554,7 +1554,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,if (rc <0 ) server->sequence_number -=2 ; -mutex_unlock (&server->srv_mutex); +cifs_server_unlock (server);if (rc <0 ) {cifs_delete_mid (midQ);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 304/339 scsi: lpfc: Address NULL pointer dereference after starget_to_rport()
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 6f808bd78e8296b4ded813b7182988d57e1f6176 upstream.
Calls to starget_to_rport() may return NULL. Add check for NULL rport before dereference.
--- drivers/scsi/lpfc/lpfc_scsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/scsi/lpfc/lpfc_scsi.c +6 -0
@@ -6316,6 +6316,9 @@ lpfc_device_reset_handler(struct scsi_cmint status;u32 logit =LOG_FCP ; +if (!rport) +return FAILED ; + rdata = rport->dd_data;if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
@@ -6394,6 +6397,9 @@ lpfc_target_reset_handler(struct scsi_cmunsigned long flags;DECLARE_WAIT_QUEUE_HEAD_ONSTACK (waitq); +if (!rport) +return FAILED ; + rdata = rport->dd_data;if (!rdata || !rdata->pnode) { lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
Greg Kroah-Hartman
maintainerPATCH 313/339 mmc: block: Fix CQE recovery reset success
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit a051246b786af7e4a9d9219cc7038a6e8a411531 upstream.
The intention of the use of mmc_blk_reset_success() in mmc_blk_cqe_recovery() was to prevent repeated resets when retrying and getting the same error. However, that may not be the case - any amount of time and I/O may pass before another recovery is needed, in which case there would be no reason to deny it the opportunity to recover via a reset if necessary. CQE recovery is expected seldom and failure to recover (if the clear tasks command fails), even more seldom, so it is better to allow the reset always, which can be done by calling mmc_blk_reset_success() always.
--- drivers/mmc/core/block.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/core/block.c +1 -2
@@ -1482,8 +1482,7 @@ void mmc_blk_cqe_recovery(struct mmc_que err =mmc_cqe_recovery (host);if (err)mmc_blk_reset (mq->blkdata, host,MMC_BLK_CQE_RECOVERY ); -else -mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY ); +mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY );pr_debug ("%s: CQE recovery done\n" ,mmc_hostname (host)); }
Greg Kroah-Hartman
maintainerPATCH 314/339 net: phy: dp83867: retrigger SGMII AN when link change
In reply to Greg Kroah-HartmanFrom: Tan Tee Min <[email protected]>
commit c76acfb7e19dcc3a0964e0563770b1d11b8d4540 upstream.
There is a limitation in TI DP83867 PHY device where SGMII AN is only triggered once after the device is booted up. Even after the PHY TPI is down and up again, SGMII AN is not triggered and hence no new in-band message from PHY to MAC side SGMII.
This could cause an issue during power up, when PHY is up prior to MAC. At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t receive new in-band message from TI PHY with correct link status, speed and duplex info.
As suggested by TI, implemented a SW solution here to retrigger SGMII Auto-Neg whenever there is a link change.
v2: Add Fixes tag in commit message.
--- drivers/net/phy/dp83867.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/net/phy/dp83867.c +29 -0
@@ -137,6 +137,7 @@#define DP83867_DOWNSHIFT_2_COUNT 2#define DP83867_DOWNSHIFT_4_COUNT 4#define DP83867_DOWNSHIFT_8_COUNT 8 +#define DP83867_SGMII_AUTONEG_EN BIT(7)/* CFG3 bits */ #define DP83867_CFG3_INT_OE BIT(7)
@@ -855,6 +856,32 @@ static int dp83867_phy_reset(struct phy_ DP83867_PHYCR_FORCE_LINK_GOOD, 0); } +static void dp83867_link_change_notify (struct phy_device *phydev) +{ +/* There is a limitation in DP83867 PHY device where SGMII AN is +* only triggered once after the device is booted up. Even after the +* PHY TPI is down and up again, SGMII AN is not triggered and +* hence no new in-band message from PHY to MAC side SGMII. +* This could cause an issue during power up, when PHY is up prior +* to MAC. At this condition, once MAC side SGMII is up, MAC side +* SGMII wouldn`t receive new in-band message from TI PHY with +* correct link status, speed and duplex info. +* Thus, implemented a SW solution here to retrigger SGMII Auto-Neg +* whenever there is a link change. +*/ +if (phydev->interface ==PHY_INTERFACE_MODE_SGMII ) { +int val =0 ; + + val =phy_clear_bits (phydev,DP83867_CFG2 , +DP83867_SGMII_AUTONEG_EN ); +if (val <0 ) +return ; + +phy_set_bits (phydev,DP83867_CFG2 , +DP83867_SGMII_AUTONEG_EN ); + } +} +static struct phy_driver dp83867_driver[] = { { .phy_id =DP83867_PHY_ID ,
@@ -879,6 +906,8 @@ static struct phy_driver dp83867_driver[ .suspend = genphy_suspend, .resume = genphy_resume, + + .link_change_notify = dp83867_link_change_notify, }, };module_phy_driver (dp83867_driver);
Greg Kroah-Hartman
maintainerPATCH 300/339 cifs: populate empty hostnames for extra channels
In reply to Greg Kroah-HartmanFrom: Shyam Prasad N <[email protected]>
commit 4c14d7043fede258957d7b01da0cad2d9fe3a205 upstream.
Currently, the secondary channels of a multichannel session also get hostname populated based on the info in primary channel. However, this will end up with a wrong resolution of hostname to IP address during reconnect.
This change fixes this by not populating hostname info for all secondary channels.
--- fs/cifs/connect.c | 4 ++++ fs/cifs/sess.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-)
fs/cifs/connect.c +4 -0
@@ -97,6 +97,10 @@ static int reconn_set_ipaddr_from_hostnaif (!server->hostname)return -EINVAL ; +/* if server hostname isn't populated, there's nothing to do here */ +if (server->hostname[0 ] =='\0' ) +return 0 ; + len =strlen (server->hostname) +3 ; unc =kmalloc (len,GFP_KERNEL );
fs/cifs/sess.c +4 -1
@@ -274,7 +274,10 @@ cifs_ses_add_channel(struct cifs_sb_info/* Auth */ ctx.domainauto = ses->domainAuto; ctx.domainname = ses->domainName; - ctx.server_hostname = ses->server->hostname; + +/* no hostname for extra channels */ + ctx.server_hostname ="" ; + ctx.username = ses->user_name; ctx.password = ses->password; ctx.sectype = ses->sectype;
Greg Kroah-Hartman
maintainerPATCH 301/339 scsi: sd: Fix interpretation of VPD B9h length
In reply to Greg Kroah-HartmanFrom: Tyler Erickson <[email protected]>
commit f92de9d110429e39929a49240d823251c2fe903e upstream.
Fixing the interpretation of the length of the B9h VPD page (Concurrent Positioning Ranges). Adding 4 is necessary as the first 4 bytes of the page is the header with page number and length information. Adding 3 was likely a misinterpretation of the SBC-5 specification which sets all offsets starting at zero.
This fixes the error in dmesg:
[ 9.014456] sd 1:0:0:0: [sda] Invalid Concurrent Positioning Ranges VPD page
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -3067,7 +3067,7 @@ static void sd_read_cpr(struct scsi_disk goto out;/* We must have at least a 64B header and one 32B range descriptor */ - vpd_len =get_unaligned_be16 (&buffer[2 ]) +3 ; + vpd_len =get_unaligned_be16 (&buffer[2 ]) +4 ;if (vpd_len > buf_len || vpd_len <64 +32 || (vpd_len &31 )) {sd_printk (KERN_ERR , sdkp,"Invalid Concurrent Positioning Ranges VPD page\n" );
Greg Kroah-Hartman
maintainerPATCH 284/339 cifs: version operations for smb20 unneeded when legacy support disabled
In reply to Greg Kroah-HartmanFrom: Steve French <[email protected]>
[ Upstream commit 7ef93ffccd55fb0ba000ed16ef6a81cd7dee07b5 ]
We should not be including unused smb20 specific code when legacy support is disabled (CONFIG_CIFS_ALLOW_INSECURE_LEGACY turned off). For example smb2_operations and smb2_values aren't used in that case. Over time we can move more and more SMB1/CIFS and SMB2.0 code into the insecure legacy ifdefs
--- fs/cifs/cifsglob.h | 4 +++- fs/cifs/smb2ops.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
fs/cifs/cifsglob.h +3 -1
@@ -1929,11 +1929,13 @@ extern mempool_t *cifs_mid_poolp;/* Operations for different SMB versions */ #define SMB1_VERSION_STRING "1.0" +#define SMB20_VERSION_STRING "2.0" +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY extern struct smb_version_operations smb1_operations;extern struct smb_version_values smb1_values; -#define SMB20_VERSION_STRING "2.0"extern struct smb_version_operations smb20_operations;extern struct smb_version_values smb20_values; +#endif /* CIFS_ALLOW_INSECURE_LEGACY */ #define SMB21_VERSION_STRING "2.1"extern struct smb_version_operations smb21_operations;extern struct smb_version_values smb21_values;
fs/cifs/smb2ops.c +6 -1
@@ -4326,11 +4326,13 @@ smb3_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock, } } +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY static bool smb2_is_read_op (__u32 oplock) {return oplock ==SMB2_OPLOCK_LEVEL_II ; } +#endif /* CIFS_ALLOW_INSECURE_LEGACY */ static bool smb21_is_read_op (__u32 oplock)
@@ -5429,7 +5431,7 @@ smb2_make_node(unsigned int xid, struct inode *inode,return rc; } - +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY struct smb_version_operations smb20_operations = { .compare_fids = smb2_compare_fids, .setup_request = smb2_setup_request,
@@ -5528,6 +5530,7 @@ struct smb_version_operations smb20_operations = { .is_status_io_timeout = smb2_is_status_io_timeout, .is_network_name_deleted = smb2_is_network_name_deleted, }; +#endif /* CIFS_ALLOW_INSECURE_LEGACY */ struct smb_version_operations smb21_operations = { .compare_fids = smb2_compare_fids,
@@ -5859,6 +5862,7 @@ struct smb_version_operations smb311_operations = { .is_network_name_deleted = smb2_is_network_name_deleted, }; +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY struct smb_version_values smb20_values = { .version_string =SMB20_VERSION_STRING , .protocol_id = SMB20_PROT_ID,
@@ -5879,6 +5883,7 @@ struct smb_version_values smb20_values = { .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED, .create_lease_size = sizeof(struct create_lease), }; +#endif /* ALLOW_INSECURE_LEGACY */ struct smb_version_values smb21_values = { .version_string =SMB21_VERSION_STRING ,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 285/339 drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate
In reply to Greg Kroah-HartmanFrom: Yury Norov <[email protected]>
[ Upstream commit 525d6515604eb1373ce5e6372a6b6640953b2d6a ]
The smu_v1X_0_set_allowed_mask() uses bitmap_copy() to convert bitmap to 32-bit array. This may be wrong due to endiannes issues. Fix it by switching to bitmap_{from,to}_arr32.
--- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
@@ -781,7 +781,7 @@ int smu_v11_0_set_allowed_mask(struct smu_context *smu) goto failed; } -bitmap_copy ((unsigned long *)feature_mask, feature->allowed,64 ); +bitmap_to_arr32 (feature_mask, feature->allowed,64 ); ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetAllowedFeaturesMaskHigh, feature_mask[1 ],NULL );
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -1
@@ -730,7 +730,7 @@ int smu_v13_0_set_allowed_mask(struct smu_context *smu) feature->feature_num < 64)return -EINVAL ; -bitmap_copy ((unsigned long *)feature_mask, feature->allowed,64 ); +bitmap_to_arr32 (feature_mask, feature->allowed,64 ); ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetAllowedFeaturesMaskHigh, feature_mask[1 ],NULL );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 302/339 scsi: lpfc: Resolve some cleanup issues following abort path refactoring
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit 24e1f056677eefe834d5dcf61905cce857ca4b19 upstream.
Refactoring and consolidation of abort paths:
- lpfc_sli4_abort_fcp_cmpl() and lpfc_sli_abort_fcp_cmpl() are combined into a single generic lpfc_sli_abort_fcp_cmpl() routine. Thus, remove extraneous lpfc_sli4_abort_fcp_cmpl() prototype declaration.
- lpfc_nvme_abort_fcreq_cmpl() abort completion routine is called with a mismatched argument type. This may result in misleading log message content. Update to the correct argument type of lpfc_iocbq instead of lpfc_wcqe_complete. The lpfc_wcqe_complete should be derived from the lpfc_iocbq structure.
--- drivers/scsi/lpfc/lpfc_crtn.h | 4 +--- drivers/scsi/lpfc/lpfc_nvme.c | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/scsi/lpfc/lpfc_crtn.h +1 -3
@@ -418,8 +418,6 @@ int lpfc_sli_issue_iocb_wait(struct lpfc uint32_t);void lpfc_sli_abort_fcp_cmpl (struct lpfc_hba *,struct lpfc_iocbq *,struct lpfc_iocbq *); -void lpfc_sli4_abort_fcp_cmpl (struct lpfc_hba *h,struct lpfc_iocbq *i, -struct lpfc_wcqe_complete *w);void lpfc_sli_free_hbq (struct lpfc_hba *,struct hbq_dmabuf *);
@@ -627,7 +625,7 @@ void lpfc_nvmet_invalidate_host(struct l struct lpfc_nodelist *ndlp);void lpfc_nvme_abort_fcreq_cmpl (struct lpfc_hba *phba,struct lpfc_iocbq *cmdiocb, -struct lpfc_wcqe_complete *abts_cmpl); +struct lpfc_iocbq *rspiocb);void lpfc_create_multixri_pools (struct lpfc_hba *phba);void lpfc_create_destroy_pools (struct lpfc_hba *phba);void lpfc_move_xri_pvt_to_pbl (struct lpfc_hba *phba,u32 hwqid);
drivers/scsi/lpfc/lpfc_nvme.c +4 -2
@@ -1741,7 +1741,7 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_l* lpfc_nvme_abort_fcreq_cmpl - Complete an NVME FCP abort request. * @phba: Pointer to HBA context object * @cmdiocb: Pointer to command iocb object. -* @abts_cmpl: Pointer to wcqe complete object. +* @rspiocb: Pointer to response iocb object. * * This is the callback function for any NVME FCP IO that was aborted. *
@@ -1750,8 +1750,10 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_l**/ void lpfc_nvme_abort_fcreq_cmpl (struct lpfc_hba *phba,struct lpfc_iocbq *cmdiocb, -struct lpfc_wcqe_complete *abts_cmpl) +struct lpfc_iocbq *rspiocb) { +struct lpfc_wcqe_complete *abts_cmpl = &rspiocb->wcqe_cmpl; +lpfc_printf_log (phba,KERN_INFO ,LOG_NVME ,"6145 ABORT_XRI_CN completing on rpi x%x " "original iotag x%x, abort cmd iotag x%x "
Greg Kroah-Hartman
maintainerPATCH 288/339 vringh: Fix loop descriptors check in the indirect cases
In reply to Greg Kroah-HartmanFrom: Xie Yongji <[email protected]>
[ Upstream commit dbd29e0752286af74243cf891accf472b2f3edd8 ]
We should use size of descriptor chain to test loop condition in the indirect case. And another statistical count is also introduced for indirect descriptors to avoid conflict with the statistical count of direct descriptors.
Message-Id: <[email protected]>
--- drivers/vhost/vringh.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/vhost/vringh.c +8 -2
@@ -292,7 +292,7 @@ __vringh_iov(struct vringh *vrh, u16 i,int (*copy)(const struct vringh *vrh, void *dst, const void *src, size_t len)) { -int err, count =0 , up_next, desc_max; +int err, count =0 , indirect_count =0 , up_next, desc_max;struct vring_desc desc, *descs;struct vringh_range range = {-1ULL ,0 }, slowrange;bool slow = false;
@@ -349,7 +349,12 @@ __vringh_iov(struct vringh *vrh, u16 i,continue ; } -if (count++ == vrh->vring.num) { +if (up_next ==-1 ) + count++; +else + indirect_count++; + +if (count > vrh->vring.num || indirect_count > desc_max) {vringh_bad ("Descriptor loop in %p" , descs); err = -ELOOP ; goto fail;
@@ -411,6 +416,7 @@ __vringh_iov(struct vringh *vrh, u16 i, i =return_from_indirect (vrh, &up_next, &descs, &desc_max); slow = false; + indirect_count =0 ; }else break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 289/339 platform/x86: barco-p50-gpio: Add check for platform_driver_register
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 011881b80ebe773914b59905bce0f5e0ef93e7ba ]
As platform_driver_register() could fail, it should be better to deal with the return value in order to maintain the code consisitency.
--- drivers/platform/x86/barco-p50-gpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/platform/x86/barco-p50-gpio.c +4 -1
@@ -405,11 +405,14 @@ MODULE_DEVICE_TABLE(dmi, dmi_ids);static int __init p50_module_init (void ) {struct resource res =DEFINE_RES_IO (P50_GPIO_IO_PORT_BASE ,P50_PORT_CMD +1 ); +int ret;if (!dmi_first_match (dmi_ids))return -ENODEV ; -platform_driver_register (&p50_gpio_driver); + ret =platform_driver_register (&p50_gpio_driver); +if (ret) +return ret; gpio_pdev =platform_device_register_simple (DRIVER_NAME ,PLATFORM_DEVID_NONE , &res,1 );if (IS_ERR (gpio_pdev)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 290/339 scripts/gdb: change kernel config dumping method
In reply to Greg Kroah-HartmanFrom: Kuan-Ying Lee <[email protected]>
[ Upstream commit 1f7a6cf6b07c74a17343c2559cd5f5018a245961 ]
MAGIC_START("IKCFG_ST") and MAGIC_END("IKCFG_ED") are moved out from the kernel_config_data variable.
Thus, we parse kernel_config_data directly instead of considering offset of MAGIC_START and MAGIC_END.
--- scripts/gdb/linux/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/gdb/linux/config.py +3 -3
@@ -24,9 +24,9 @@ class LxConfigDump(gdb.Command): filename = arg try: - py_config_ptr = gdb.parse_and_eval("kernel_config_data + 8") - py_config_size = gdb.parse_and_eval( - "sizeof(kernel_config_data) - 1 - 8 * 2") + py_config_ptr = gdb.parse_and_eval("&kernel_config_data") + py_config_ptr_end = gdb.parse_and_eval("&kernel_config_data_end") + py_config_size = py_config_ptr_end - py_config_ptr except gdb.error as e: raise gdb.GdbError("Can't find config, enable CONFIG_IKCONFIG?")
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 291/339 platform/x86: hp-wmi: Resolve WMI query failures on some devices
In reply to Greg Kroah-HartmanFrom: Jorge Lopez <[email protected]>
[ Upstream commit dc6a6ab58379f25bf991d8e4a13b001ed806e881 ]
WMI queries fail on some devices where the ACPI method HWMC unconditionally attempts to create Fields beyond the buffer if the buffer is too small, this breaks essential features such as power profiles:
CreateByteField (Arg1, 0x10, D008)
CreateByteField (Arg1, 0x11, D009)
CreateByteField (Arg1, 0x12, D010)
CreateDWordField (Arg1, 0x10, D032)
CreateField (Arg1, 0x80, 0x0400, D128)In cases where args->data had zero length, ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D008] at bit offset/length 128/8 exceeds size of target Buffer (128 bits) (20211217/dsopcode-198) was obtained.
ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D009] at bit offset/length 136/8 exceeds size of target Buffer (136bits) (20211217/dsopcode-198)
The original code created a buffer size of 128 bytes regardless if the WMI call required a smaller buffer or not. This particular behavior occurs in older BIOS and reproduced in OMEN laptops. Newer BIOS handles buffer sizes properly and meets the latest specification requirements. This is the reason why testing with a dynamically allocated buffer did not uncover any failures with the test systems at hand.
This patch was tested on several OMEN, Elite, and Zbooks. It was confirmed the patch resolves HPWMI_FAN GET/SET calls in an OMEN Laptop 15-ek0xxx. No problems were reported when testing on several Elite and Zbooks notebooks.
--- drivers/platform/x86/hp-wmi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/platform/x86/hp-wmi.c +4 -2
@@ -290,14 +290,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,struct bios_return *bios_return;union acpi_object *obj =NULL ;struct bios_args *args =NULL ; -int mid, actual_outsize, ret; +int mid, actual_insize, actual_outsize;size_t bios_args_size; +int ret; mid =encode_outsize_for_pvsz (outsize);if (WARN_ON (mid <0 ))return mid; - bios_args_size =struct_size (args, data, insize); + actual_insize =max (insize,128 ); + bios_args_size =struct_size (args, data, actual_insize); args =kmalloc (bios_args_size,GFP_KERNEL );if (!args)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 315/339 net: openvswitch: fix misuse of the cached connection on tuple changes
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
commit 2061ecfdf2350994e5b61c43e50e98a7a70e95ee upstream.
If packet headers changed, the cached nfct is no longer relevant for the packet and attempt to re-use it leads to the incorrect packet classification.
This issue is causing broken connectivity in OpenStack deployments with OVS/OVN due to hairpin traffic being unexpectedly dropped.
The setup has datapath flows with several conntrack actions and tuple changes between them:
actions:ct(commit,zone=8,mark=0/0x1,nat(src)),
set(eth(src=00:00:00:00:00:01,dst=00:00:00:00:00:06)),
set(ipv4(src=172.18.2.10,dst=192.168.100.6,ttl=62)),
ct(zone=8),recirc(0x4)After the first ct() action the packet headers are almost fully re-written. The next ct() tries to re-use the existing nfct entry and marks the packet as invalid, so it gets dropped later in the pipeline.
Clearing the cached conntrack entry whenever packet tuple is changed to avoid the issue.
The flow key should not be cleared though, because we should still be able to match on the ct_state if the recirculation happens after the tuple change but before the next ct() action.
--- net/openvswitch/actions.c | 6 ++++++ net/openvswitch/conntrack.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
net/openvswitch/actions.c +6 -0
@@ -373,6 +373,7 @@ static void set_ip_addr(struct sk_buff *update_ip_l4_checksum (skb, nh, *addr, new_addr);csum_replace4 (&nh->check, *addr, new_addr);skb_clear_hash (skb); +ovs_ct_clear (skb,NULL ); *addr = new_addr; }
@@ -420,6 +421,7 @@ static void set_ipv6_addr(struct sk_buffupdate_ipv6_checksum (skb, l4_proto, addr, new_addr);skb_clear_hash (skb); +ovs_ct_clear (skb,NULL );memcpy (addr, new_addr,sizeof (__be32[4 ])); }
@@ -660,6 +662,7 @@ static int set_nsh(struct sk_buff *skb,static void set_tp_port (struct sk_buff *skb,__be16 *port,__be16 new_port,__sum16 *check) { +ovs_ct_clear (skb,NULL );inet_proto_csum_replace2 (check, skb, *port, new_port, false); *port = new_port; }
@@ -699,6 +702,7 @@ static int set_udp(struct sk_buff *skb, uh->dest = dst; flow_key->tp.src = src; flow_key->tp.dst = dst; +ovs_ct_clear (skb,NULL ); }skb_clear_hash (skb);
@@ -761,6 +765,8 @@ static int set_sctp(struct sk_buff *skb, sh->checksum = old_csum ^ old_correct_csum ^ new_csum;skb_clear_hash (skb); +ovs_ct_clear (skb,NULL ); + flow_key->tp.src = sh->source; flow_key->tp.dst = sh->dest;
net/openvswitch/conntrack.c +3 -1
@@ -1342,7 +1342,9 @@ int ovs_ct_clear(struct sk_buff *skb, stnf_ct_put (ct);nf_ct_set (skb,NULL ,IP_CT_UNTRACKED ); -ovs_ct_fill_key (skb, key, false); + +if (key) +ovs_ct_fill_key (skb, key, false);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 316/339 writeback: Fix inode->i_io_list not be protected by inode->i_lock error
In reply to Greg Kroah-HartmanFrom: Jchao Sun <[email protected]>
commit 10e14073107dd0b6d97d9516a02845a8e501c2c9 upstream.
Commit b35250c0816c ("writeback: Protect inode->i_io_list with inode->i_lock") made inode->i_io_list not only protected by wb->list_lock but also inode->i_lock, but inode_io_list_move_locked() was missed. Add lock there and also update comment describing things protected by inode->i_lock. This also fixes a race where __mark_inode_dirty() could move inode under flush worker's hands and thus sync(2) could miss writing some inodes.
--- fs/fs-writeback.c | 37 ++++++++++++++++++++++++++++--------- fs/inode.c | 2 +- 2 files changed, 29 insertions(+), 10 deletions(-)
fs/fs-writeback.c +28 -9
@@ -120,6 +120,7 @@ static bool inode_io_list_move_locked(st struct list_head *head) {assert_spin_locked (&wb->list_lock); +assert_spin_locked (&inode->i_lock);list_move (&inode->i_io_list, head);
@@ -1365,9 +1366,9 @@ static int move_expired_inodes(struct li inode =wb_inode (delaying_queue->prev);if (inode_dirtied_after (inode, dirtied_before))break ; +spin_lock (&inode->i_lock);list_move (&inode->i_io_list, &tmp); moved++; -spin_lock (&inode->i_lock); inode->i_state |=I_SYNC_QUEUED ;spin_unlock (&inode->i_lock);if (sb_is_blkdev_sb (inode->i_sb))
@@ -1383,7 +1384,12 @@ static int move_expired_inodes(struct li goto out; } -/* Move inodes from one superblock together */ +/* +* Although inode's i_io_list is moved from 'tmp' to 'dispatch_queue', +* we don't take inode->i_lock here because it is just a pointless overhead. +* Inode is already marked as I_SYNC_QUEUED so writeback list handling is +* fully under our control. +*/ while (!list_empty (&tmp)) { sb =wb_inode (tmp.prev)->i_sb;list_for_each_prev_safe (pos, node, &tmp) {
@@ -1826,8 +1832,8 @@ static long writeback_sb_inodes(struct s* We'll have another go at writing back this inode * when we completed a full scan of b_io. */ -spin_unlock (&inode->i_lock);requeue_io (inode, wb); +spin_unlock (&inode->i_lock);trace_writeback_sb_inodes_requeue (inode);continue ; }
@@ -2358,6 +2364,7 @@ void __mark_inode_dirty(struct inode *in {struct super_block *sb = inode->i_sb;int dirtytime =0 ; +struct bdi_writeback *wb =NULL ;trace_writeback_mark_inode_dirty (inode, flags);
@@ -2410,13 +2417,24 @@ void __mark_inode_dirty(struct inode *in inode->i_state |= flags;/* +* Grab inode's wb early because it requires dropping i_lock and we +* need to make sure following checks happen atomically with dirty +* list handling so that we don't move inodes under flush worker's +* hands. +*/ +if (!was_dirty) { + wb =locked_inode_to_wb_and_lock_list (inode); +spin_lock (&inode->i_lock); + } + +/* * If the inode is queued for writeback by flush worker, just * update its dirty state. Once the flush worker is done with * the inode it will place it on the appropriate superblock * list, based upon its state. */ if (inode->i_state &I_SYNC_QUEUED ) - goto out_unlock_inode; + goto out_unlock;/* * Only add valid (hashed) inodes to the superblock's
@@ -2424,22 +2442,19 @@ void __mark_inode_dirty(struct inode *in*/ if (!S_ISBLK (inode->i_mode)) {if (inode_unhashed (inode)) - goto out_unlock_inode; + goto out_unlock; }if (inode->i_state &I_FREEING ) - goto out_unlock_inode; + goto out_unlock;/* * If the inode was already on b_dirty/b_io/b_more_io, don't * reposition it (that would break b_dirty time-ordering). */ if (!was_dirty) { -struct bdi_writeback *wb;struct list_head *dirty_list;bool wakeup_bdi = false; - wb =locked_inode_to_wb_and_lock_list (inode); - inode->dirtied_when = jiffies;if (dirtytime) inode->dirtied_time_when = jiffies;
@@ -2453,6 +2468,7 @@ void __mark_inode_dirty(struct inode *in dirty_list);spin_unlock (&wb->list_lock); +spin_unlock (&inode->i_lock);trace_writeback_dirty_inode_enqueue (inode);/*
@@ -2467,6 +2483,9 @@ void __mark_inode_dirty(struct inode *inreturn ; } } +out_unlock: +if (wb) +spin_unlock (&wb->list_lock); out_unlock_inode:spin_unlock (&inode->i_lock); }
fs/inode.c +1 -1
@@ -27,7 +27,7 @@* Inode locking rules: * * inode->i_lock protects: -* inode->i_state, inode->i_hash, __iget() +* inode->i_state, inode->i_hash, __iget(), inode->i_io_list * Inode LRU list locks protect: * inode->i_sb->s_inode_lru, inode->i_lru * inode->i_sb->s_inode_list_lock protects:
Greg Kroah-Hartman
maintainerPATCH 317/339 nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
In reply to Greg Kroah-HartmanFrom: Martin Faltesek <[email protected]>
commit 77e5fe8f176a525523ae091d6fd0fbb8834c156d upstream.
The first validation check for EVT_TRANSACTION has two different checks tied together with logical AND. One is a check for minimum packet length, and the other is for a valid aid_tag. If either condition is true (fails), then an error should be triggered. The fix is to change && to ||.
--- drivers/nfc/st21nfca/se.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/st21nfca/se.c +1 -1
@@ -315,7 +315,7 @@ int st21nfca_connectivity_event_received* AID 81 5 to 16 * PARAMETERS 82 0 to 255 */ -if (skb->len <NFC_MIN_AID_LENGTH +2 && +if (skb->len <NFC_MIN_AID_LENGTH +2 || skb->data[0 ] !=NFC_EVT_TRANSACTION_AID_TAG )return -EPROTO ;
Greg Kroah-Hartman
maintainerPATCH 318/339 nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
In reply to Greg Kroah-HartmanFrom: Martin Faltesek <[email protected]>
commit 996419e0594abb311fb958553809f24f38e7abbe upstream.
Error paths do not free previously allocated memory. Add devm_kfree() to those failure paths.
--- drivers/nfc/st21nfca/se.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/nfc/st21nfca/se.c +10 -3
@@ -326,22 +326,29 @@ int st21nfca_connectivity_event_received transaction->aid_len = skb->data[1 ];/* Checking if the length of the AID is valid */ -if (transaction->aid_len >sizeof (transaction->aid)) +if (transaction->aid_len >sizeof (transaction->aid)) { +devm_kfree (dev, transaction);return -EINVAL ; + }memcpy (transaction->aid, &skb->data[2 ], transaction->aid_len);/* Check next byte is PARAMETERS tag (82) */ if (skb->data[transaction->aid_len +2 ] != -NFC_EVT_TRANSACTION_PARAMS_TAG ) +NFC_EVT_TRANSACTION_PARAMS_TAG ) { +devm_kfree (dev, transaction);return -EPROTO ; + } transaction->params_len = skb->data[transaction->aid_len +3 ];/* Total size is allocated (skb->len - 2) minus fixed array members */ -if (transaction->params_len > ((skb->len -2 ) -sizeof (struct nfc_evt_transaction ))) +if (transaction->params_len > ((skb->len -2 ) - +sizeof (struct nfc_evt_transaction ))) { +devm_kfree (dev, transaction);return -EINVAL ; + }memcpy (transaction->params, skb->data + transaction->aid_len +4 , transaction->params_len);
Greg Kroah-Hartman
maintainerPATCH 320/339 ixgbe: fix bcast packets Rx on VF after promisc removal
In reply to Greg Kroah-HartmanFrom: Olivier Matz <[email protected]>
commit 803e9895ea2b0fe80bc85980ae2d7a7e44037914 upstream.
After a VF requested to remove the promiscuous flag on an interface, the broadcast packets are not received anymore. This breaks some protocols like ARP.
In ixgbe_update_vf_xcast_mode(), we should keep the IXGBE_VMOLR_BAM bit (Broadcast Accept) on promiscuous removal.
This flag is already set by default in ixgbe_set_vmolr() on VF reset.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +2 -2
@@ -1184,9 +1184,9 @@ static int ixgbe_update_vf_xcast_mode(stswitch (xcast_mode) {case IXGBEVF_XCAST_MODE_NONE : - disable =IXGBE_VMOLR_BAM |IXGBE_VMOLR_ROMPE | + disable =IXGBE_VMOLR_ROMPE |IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ; - enable =0 ; + enable =IXGBE_VMOLR_BAM ;break ;case IXGBEVF_XCAST_MODE_MULTI : disable =IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ;
Greg Kroah-Hartman
maintainerPATCH 319/339 nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION
In reply to Greg Kroah-HartmanFrom: Martin Faltesek <[email protected]>
commit f2e19b36593caed4c977c2f55aeba7408aeb2132 upstream.
The transaction buffer is allocated by using the size of the packet buf, and subtracting two which seem intended to remove the two tags which are not present in the target structure. This calculation leads to under counting memory because of differences between the packet contents and the target structure. The aid_len field is a u8 in the packet, but a u32 in the structure, resulting in at least 3 bytes always being under counted. Further, the aid data is a variable length field in the packet, but fixed in the structure, so if this field is less than the max, the difference is added to the under counting.
The last validation check for transaction->params_len is also incorrect since it employs the same accounting error.
To fix, perform validation checks progressively to safely reach the next field, to determine the size of both buffers and verify both tags. Once all validation checks pass, allocate the buffer and copy the data. This eliminates freeing memory on the error path, as those checks are moved ahead of memory allocation.
--- drivers/nfc/st21nfca/se.c | 62 +++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
drivers/nfc/st21nfca/se.c +31 -31
@@ -300,6 +300,8 @@ int st21nfca_connectivity_event_receivedint r =0 ;struct device *dev = &hdev->ndev->dev;struct nfc_evt_transaction *transaction; +u32 aid_len; +u8 params_len;pr_debug ("connectivity gate event: %x\n" , event);
@@ -308,50 +310,48 @@ int st21nfca_connectivity_event_received r =nfc_se_connectivity (hdev->ndev, host);break ;case ST21NFCA_EVT_TRANSACTION : -/* -* According to specification etsi 102 622 +/* According to specification etsi 102 622 * 11.2.2.4 EVT_TRANSACTION Table 52 * Description Tag Length * AID 81 5 to 16 * PARAMETERS 82 0 to 255 +* +* The key differences are aid storage length is variably sized +* in the packet, but fixed in nfc_evt_transaction, and that the aid_len +* is u8 in the packet, but u32 in the structure, and the tags in +* the packet are not included in nfc_evt_transaction. +* +* size in bytes: 1 1 5-16 1 1 0-255 +* offset: 0 1 2 aid_len + 2 aid_len + 3 aid_len + 4 +* member name: aid_tag(M) aid_len aid params_tag(M) params_len params +* example: 0x81 5-16 X 0x82 0-255 X */ -if (skb->len <NFC_MIN_AID_LENGTH +2 || - skb->data[0 ] !=NFC_EVT_TRANSACTION_AID_TAG ) +if (skb->len <2 || skb->data[0 ] !=NFC_EVT_TRANSACTION_AID_TAG )return -EPROTO ; - transaction =devm_kzalloc (dev, skb->len -2 ,GFP_KERNEL ); -if (!transaction) -return -ENOMEM ; + aid_len = skb->data[1 ]; + +if (skb->len < aid_len +4 || aid_len >sizeof (transaction->aid)) +return -EPROTO ; - transaction->aid_len = skb->data[1 ]; + params_len = skb->data[aid_len +3 ]; -/* Checking if the length of the AID is valid */ -if (transaction->aid_len >sizeof (transaction->aid)) { -devm_kfree (dev, transaction); -return -EINVAL ; - } - -memcpy (transaction->aid, &skb->data[2 ], - transaction->aid_len); - -/* Check next byte is PARAMETERS tag (82) */ -if (skb->data[transaction->aid_len +2 ] != -NFC_EVT_TRANSACTION_PARAMS_TAG ) { -devm_kfree (dev, transaction); +/* Verify PARAMETERS tag is (82), and final check that there is enough +* space in the packet to read everything. +*/ +if ((skb->data[aid_len +2 ] !=NFC_EVT_TRANSACTION_PARAMS_TAG ) || + (skb->len < aid_len +4 + params_len))return -EPROTO ; - } - transaction->params_len = skb->data[transaction->aid_len +3 ]; + transaction =devm_kzalloc (dev,sizeof (*transaction) + params_len,GFP_KERNEL ); +if (!transaction) +return -ENOMEM ; -/* Total size is allocated (skb->len - 2) minus fixed array members */ -if (transaction->params_len > ((skb->len -2 ) - -sizeof (struct nfc_evt_transaction ))) { -devm_kfree (dev, transaction); -return -EINVAL ; - } + transaction->aid_len = aid_len; + transaction->params_len = params_len; -memcpy (transaction->params, skb->data + - transaction->aid_len +4 , transaction->params_len); +memcpy (transaction->aid, &skb->data[2 ], aid_len); +memcpy (transaction->params, &skb->data[aid_len +4 ], params_len); r =nfc_se_transaction (hdev->ndev, host, transaction);break ;
Greg Kroah-Hartman
maintainerPATCH 324/339 cpuidle,intel_idle: Fix CPUIDLE_FLAG_IRQ_ENABLE
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 32d4fd5751eadbe1823a37eb38df85ec5c8e6207 upstream.
Commit c227233ad64c ("intel_idle: enable interrupts before C1 on Xeons") wrecked intel_idle in two ways:
- must not have tracing in idle functions
- must return with IRQs disabled
Additionally, it added a branch for no good reason.
--- drivers/idle/intel_idle.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/idle/intel_idle.c +25 -7
@@ -115,6 +115,18 @@ static unsigned int mwait_substates __in#define flg2MWAIT (flags) (((flags) >> 24) & 0xFF)#define MWAIT2flg (eax) ((eax & 0xFF) << 24) +static __always_inline int __intel_idle(struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) +{ +struct cpuidle_state *state = &drv->states[index]; +unsigned long eax =flg2MWAIT (state->flags); +unsigned long ecx =1 ;/* break on interrupt flag */ + +mwait_idle_with_hints (eax, ecx); + +return index; +} +/** * intel_idle - Ask the processor to enter the given idle state. * @dev: cpuidle device of the target CPU.
@@ -132,16 +144,19 @@ static unsigned int mwait_substates __in static __cpuidle int intel_idle(struct cpuidle_device *dev,struct cpuidle_driver *drv,int index) { -struct cpuidle_state *state = &drv->states[index]; -unsigned long eax =flg2MWAIT (state->flags); -unsigned long ecx =1 ;/* break on interrupt flag */ +return __intel_idle (dev, drv, index); +} -if (state->flags &CPUIDLE_FLAG_IRQ_ENABLE ) -local_irq_enable (); +static __cpuidle int intel_idle_irq(struct cpuidle_device *dev, +struct cpuidle_driver *drv,int index) +{ +int ret; -mwait_idle_with_hints (eax, ecx); +raw_local_irq_enable (); + ret =__intel_idle (dev, drv, index); +raw_local_irq_disable (); -return index; +return ret; }/**
@@ -1668,6 +1683,9 @@ static void __init intel_idle_init_cstat/* Structure copy. */ drv->states[drv->state_count] = cpuidle_state_table[cstate]; +if (cpuidle_state_table[cstate].flags &CPUIDLE_FLAG_IRQ_ENABLE ) + drv->states[drv->state_count].enter = intel_idle_irq; + if ((disabled_states_mask & BIT(drv->state_count)) || ((icpu->use_acpi || force_use_acpi) && intel_idle_off_by_default(mwait_hint) &&
Greg Kroah-Hartman
maintainerPATCH 329/339 drm/atomic: Force bridge self-refresh-exit on CRTC switch
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit e54a4424925a27ed94dff046db3ce5caf4b1e748 upstream.
It's possible to change which CRTC is in use for a given connector/encoder/bridge while we're in self-refresh without fully disabling the connector/encoder/bridge along the way. This can confuse the bridge encoder/bridge, because
(a) it needs to track the SR state (trying to perform "active" operations while the panel is still in SR can be Bad(TM)); and
(b) it tracks the SR state via the CRTC state (and after the switch, the previous SR state is lost).
Thus, we need to either somehow carry the self-refresh state over to the new CRTC, or else force an encoder/bridge self-refresh transition during such a switch.
I choose the latter, so we disable the encoder (and exit PSR) before attaching it to the new CRTC (where we can continue to assume a clean (non-self-refresh) state).
This fixes PSR issues seen on Rockchip RK3399 systems with drivers/gpu/drm/bridge/analogix/analogix_dp_core.c.
Change in v2:
- Drop "->enable" condition; this could possibly be "->active" to reflect the intended hardware state, but it also is a little over-specific. We want to make a transition through "disabled" any time we're exiting PSR at the same time as a CRTC switch. (Thanks Liu Ying)
--- drivers/gpu/drm/drm_atomic_helper.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic_helper.c +13 -3
@@ -1011,9 +1011,19 @@ crtc_needs_disable(struct drm_crtc_statereturn drm_atomic_crtc_effectively_active (old_state);/* -* We need to run through the crtc_funcs->disable() function if the CRTC -* is currently on, if it's transitioning to self refresh mode, or if -* it's in self refresh mode and needs to be fully disabled. +* We need to disable bridge(s) and CRTC if we're transitioning out of +* self-refresh and changing CRTCs at the same time, because the +* bridge tracks self-refresh status via CRTC state. +*/ +if (old_state->self_refresh_active && + old_state->crtc != new_state->crtc) +return true; + +/* +* We also need to run through the crtc_funcs->disable() function if +* the CRTC is currently on, if it's transitioning to self refresh +* mode, or if it's in self refresh mode and needs to be fully +* disabled. */ return old_state->active || (old_state->self_refresh_active && !new_state->active) ||
Greg Kroah-Hartman
maintainerPATCH 331/339 drm/amd/display: remove stale config guards
In reply to Greg Kroah-HartmanFrom: Aurabindo Pillai <[email protected]>
commit fd843d03418ead2bba369159bb19b60e9d4b7b1e upstream.
This code should be executed.
--- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_clk_mgr.c | 2 -- drivers/gpu/drm/amd/display/dc/dml/dml_wrapper.c | 2 -- 2 files changed, 4 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_clk_mgr.c +0 -2
@@ -41,9 +41,7 @@#include "dc_dmub_srv.h" -#if defined (CONFIG_DRM_AMD_DC_DP2_0 )#include "dc_link_dp.h" -#endif #define TO_CLK_MGR_DCN315 (clk_mgr)\ container_of(clk_mgr, struct clk_mgr_dcn315, base)
drivers/gpu/drm/amd/display/dc/dml/dml_wrapper.c +0 -2
@@ -1284,10 +1284,8 @@ static bool is_dtbclk_required(struct dcfor (i =0 ; i < dc->res_pool->pipe_count; i++) {if (!context->res_ctx.pipe_ctx[i].stream)continue ; -#if defined (CONFIG_DRM_AMD_DC_DP2_0 )if (is_dp_128b_132b_signal (&context->res_ctx.pipe_ctx[i]))return true; -#endif }return false; }
Greg Kroah-Hartman
maintainerPATCH 337/339 random: account for arch randomness in bits
In reply to Greg Kroah-HartmanFrom: "Jason A. Donenfeld" <[email protected]>
commit 77fc95f8c0dc9e1f8e620ec14d2fb65028fb7adc upstream.
Rather than accounting in bytes and multiplying (shifting), we can just account in bits and avoid the shift. The main motivation for this is there are other patches in flux that expand this code a bit, and avoiding the duplication of "* 8" everywhere makes things a bit clearer.
--- drivers/char/random.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/char/random.c +4 -4
@@ -817,7 +817,7 @@ early_param("random.trust_bootloader", pint __init random_init (const char *command_line) {ktime_t now =ktime_get_real (); -unsigned int i, arch_bytes; +unsigned int i, arch_bits;unsigned long entropy;#if defined(LATENT_ENTROPY_PLUGIN )
@@ -825,12 +825,12 @@ int __init random_init(const char *comma_mix_pool_bytes (compiletime_seed,sizeof (compiletime_seed));#endif -for (i =0 , arch_bytes =BLAKE2S_BLOCK_SIZE ; +for (i =0 , arch_bits =BLAKE2S_BLOCK_SIZE *8 ; i <BLAKE2S_BLOCK_SIZE ; i +=sizeof (entropy)) {if (!arch_get_random_seed_long_early (&entropy) && !arch_get_random_long_early (&entropy)) { entropy =random_get_entropy (); - arch_bytes -=sizeof (entropy); + arch_bits -=sizeof (entropy) *8 ; }_mix_pool_bytes (&entropy,sizeof (entropy)); }
@@ -842,7 +842,7 @@ int __init random_init(const char *commaif (crng_ready ())crng_reseed ();else if (trust_cpu) -_credit_init_bits (arch_bytes *8 ); +_credit_init_bits (arch_bits);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 326/339 powerpc: Dont select HAVE_IRQ_EXIT_ON_IRQ_STACK
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 1346d00e1bdfd4067f92bc14e8a6131a01de4190 upstream.
The HAVE_IRQ_EXIT_ON_IRQ_STACK option tells generic code that irq_exit() is called while still running on the hard irq stack (hardirq_ctx[] in the powerpc code).
Selecting the option means the generic code will *not* switch to the softirq stack before running softirqs, because the code is already running on the (mostly empty) hard irq stack.
But since commit 1b1b6a6f4cc0 ("powerpc: handle irq_enter/irq_exit in interrupt handler wrappers"), irq_exit() is now called on the regular task stack, not the hard irq stack.
That's because previously irq_exit() was called in __do_irq() which is run on the hard irq stack, but now it is called in interrupt_async_exit_prepare() which is called from do_irq() constructed by the wrapper macro, which is after the switch back to the task stack.
So drop HAVE_IRQ_EXIT_ON_IRQ_STACK from the Kconfig. This will mean an extra stack switch when processing some interrupts, but should significantly reduce the likelihood of stack overflow.
It also means the softirq stack will be used for running softirqs from other interrupts that don't use the hard irq stack, eg. timer interrupts.
--- arch/powerpc/Kconfig | 1 - 1 file changed, 1 deletion(-)
arch/powerpc/Kconfig +0 -1
@@ -218,7 +218,6 @@ config PPC select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_IOREMAP_PROT - select HAVE_IRQ_EXIT_ON_IRQ_STACK select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KERNEL_GZIP select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE
Greg Kroah-Hartman
maintainerPATCH 306/339 KVM: SVM: fix tsc scaling cache logic
In reply to Greg Kroah-HartmanFrom: Maxim Levitsky <[email protected]>
commit 11d39e8cc43e1c6737af19ca9372e590061b5ad2 upstream.
SVM uses a per-cpu variable to cache the current value of the tsc scaling multiplier msr on each cpu.
Commit 1ab9287add5e2
("KVM: X86: Add vendor callbacks for writing the TSC multiplier") broke this caching logic.
Refactor the code so that all TSC scaling multiplier writes go through a single function which checks and updates the cache.
This fixes the following scenario:
1. A CPU runs a guest with some tsc scaling ratio.
2. New guest with different tsc scaling ratio starts on this CPU and terminates almost immediately.
This ensures that the short running guest had set the tsc scaling ratio just once when it was set via KVM_SET_TSC_KHZ. Due to the bug,
the per-cpu cache is not updated.
3. The original guest continues to run, it doesn't restore the msr value back to its own value, because the cache matches, and thus continues to run with a wrong tsc scaling ratio.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/nested.c | 4 ++-- arch/x86/kvm/svm/svm.c | 32 ++++++++++++++++++++------------ arch/x86/kvm/svm/svm.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-)
arch/x86/kvm/svm/nested.c +2 -2
@@ -896,7 +896,7 @@ int nested_svm_vmexit(struct vcpu_svm *sif (svm->tsc_ratio_msr != kvm_default_tsc_scaling_ratio) {WARN_ON (!svm->tsc_scaling_enabled); vcpu->arch.tsc_scaling_ratio = vcpu->arch.l1_tsc_scaling_ratio; -svm_write_tsc_multiplier (vcpu, vcpu->arch.tsc_scaling_ratio); +__svm_write_tsc_multiplier (vcpu->arch.tsc_scaling_ratio); } svm->nested.ctl.nested_cr3 =0 ;
@@ -1293,7 +1293,7 @@ void nested_svm_update_tsc_ratio_msr(str vcpu->arch.tsc_scaling_ratio =kvm_calc_nested_tsc_multiplier (vcpu->arch.l1_tsc_scaling_ratio, svm->tsc_ratio_msr); -svm_write_tsc_multiplier (vcpu, vcpu->arch.tsc_scaling_ratio); +__svm_write_tsc_multiplier (vcpu->arch.tsc_scaling_ratio); }/* Inverse operation of nested_copy_vmcb_control_to_cache(). asid is copied too. */
arch/x86/kvm/svm/svm.c +20 -12
@@ -463,11 +463,24 @@ static int has_svm(void)return 1 ; } +void __svm_write_tsc_multiplier (u64 multiplier) +{ +preempt_disable (); + +if (multiplier ==__this_cpu_read (current_tsc_ratio)) + goto out; + +wrmsrl (MSR_AMD64_TSC_RATIO , multiplier); +__this_cpu_write (current_tsc_ratio, multiplier); +out: +preempt_enable (); +} +static void svm_hardware_disable (void ) {/* Make sure we clean up behind us */ if (tsc_scaling) -wrmsrl (MSR_AMD64_TSC_RATIO ,SVM_TSC_RATIO_DEFAULT ); +__svm_write_tsc_multiplier (SVM_TSC_RATIO_DEFAULT );cpu_svm_disable ();
@@ -513,8 +526,7 @@ static int svm_hardware_enable(void)* Set the default value, even if we don't use TSC scaling * to avoid having stale value in the msr */ -wrmsrl (MSR_AMD64_TSC_RATIO ,SVM_TSC_RATIO_DEFAULT ); -__this_cpu_write (current_tsc_ratio,SVM_TSC_RATIO_DEFAULT ); +__svm_write_tsc_multiplier (SVM_TSC_RATIO_DEFAULT ); }
@@ -915,11 +927,12 @@ static void svm_write_tsc_offset(structvmcb_mark_dirty (svm->vmcb,VMCB_INTERCEPTS ); } -void svm_write_tsc_multiplier (struct kvm_vcpu *vcpu,u64 multiplier) +static void svm_write_tsc_multiplier (struct kvm_vcpu *vcpu,u64 multiplier) { -wrmsrl (MSR_AMD64_TSC_RATIO , multiplier); +__svm_write_tsc_multiplier (multiplier); } +/* Evaluate instruction intercepts that depend on guest CPUID features. */ static void svm_recalc_instruction_intercepts (struct kvm_vcpu *vcpu,struct vcpu_svm *svm)
@@ -1276,13 +1289,8 @@ static void svm_prepare_switch_to_guest(sev_es_prepare_switch_to_guest (hostsa); } -if (tsc_scaling) { -u64 tsc_ratio = vcpu->arch.tsc_scaling_ratio; -if (tsc_ratio !=__this_cpu_read (current_tsc_ratio)) { -__this_cpu_write (current_tsc_ratio, tsc_ratio); -wrmsrl (MSR_AMD64_TSC_RATIO , tsc_ratio); - } - } +if (tsc_scaling) +__svm_write_tsc_multiplier (vcpu->arch.tsc_scaling_ratio);if (likely (tsc_aux_uret_slot >=0 ))kvm_set_user_return_msr (tsc_aux_uret_slot, svm->tsc_aux,-1ull );
arch/x86/kvm/svm/svm.h +1 -1
@@ -558,7 +558,7 @@ int nested_svm_check_exception(struct vc bool has_error_code, u32 error_code);int nested_svm_exit_special (struct vcpu_svm *svm);void nested_svm_update_tsc_ratio_msr (struct kvm_vcpu *vcpu); -void svm_write_tsc_multiplier (struct kvm_vcpu *vcpu,u64 multiplier); +void __svm_write_tsc_multiplier (u64 multiplier);void nested_copy_vmcb_control_to_cache (struct vcpu_svm *svm,struct vmcb_control_area *control); void nested_copy_vmcb_save_to_cache(struct vcpu_svm *svm,
Greg Kroah-Hartman
maintainerPATCH 333/339 virtio-rng: make device ready before making request
In reply to Greg Kroah-HartmanFrom: Jason Wang <[email protected]>
commit 228432551bd8783211e494ab35f42a4344580502 upstream.
Current virtio-rng does a entropy request before DRIVER_OK, this violates the spec:
virtio spec requires that all drivers set DRIVER_OK before using devices.
Further, kernel will ignore the interrupt after commit 8b4ec69d7e09 ("virtio: harden vring IRQ").
Fixing this by making device ready before the request.
Message-Id: <[email protected]>
--- drivers/char/hw_random/virtio-rng.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/hw_random/virtio-rng.c +2 -0
@@ -159,6 +159,8 @@ static int probe_common(struct virtio_de goto err_find; } +virtio_device_ready (vdev); +/* we always have a pending entropy request */ request_entropy (vi);
Greg Kroah-Hartman
maintainerPATCH 312/339 mmc: sdhci-pci-gli: Fix GL9763E runtime PM when the system resumes from suspend
In reply to Greg Kroah-HartmanFrom: Ben Chuang <[email protected]>
commit 291e7d52d19f114cad6cbf802f3f19ef12a011f8 upstream.
When the system resumes from suspend (S3 or S4), the power mode is MMC_POWER_OFF. In this status, gl9763e_runtime_resume() should not enable PLL. Add a condition to this function to enable PLL only when the power mode is MMC_POWER_ON.
--- drivers/mmc/host/sdhci-pci-gli.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mmc/host/sdhci-pci-gli.c +3 -0
@@ -972,6 +972,9 @@ static int gl9763e_runtime_resume(structstruct sdhci_host *host = slot->host;u16 clock; +if (host->mmc->ios.power_mode !=MMC_POWER_ON ) +return 0 ; + clock =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); clock |=SDHCI_CLOCK_PLL_EN ;
Greg Kroah-Hartman
maintainerPATCH 323/339 vduse: Fix NULL pointer dereference on sysfs access
In reply to Greg Kroah-HartmanFrom: Xie Yongji <[email protected]>
commit b27ee76c74dc831d6e092eaebc2dfc9c0beed1c9 upstream.
The control device has no drvdata. So we will get a NULL pointer dereference when accessing control device's msg_timeout attribute via sysfs:
[ 132.841881][ T3644] BUG: kernel NULL pointer dereference, address: 00000000000000f8 [ 132.850619][ T3644] RIP: 0010:msg_timeout_show (drivers/vdpa/vdpa_user/vduse_dev.c:1271) [ 132.869447][ T3644] dev_attr_show (drivers/base/core.c:2094) [ 132.870215][ T3644] sysfs_kf_seq_show (fs/sysfs/file.c:59) [ 132.871164][ T3644] ? device_remove_bin_file (drivers/base/core.c:2088) [ 132.872082][ T3644] kernfs_seq_show (fs/kernfs/file.c:164) [ 132.872838][ T3644] seq_read_iter (fs/seq_file.c:230) [ 132.873578][ T3644] ? __vmalloc_area_node (mm/vmalloc.c:3041) [ 132.874532][ T3644] kernfs_fop_read_iter (fs/kernfs/file.c:238) [ 132.875513][ T3644] __kernel_read (fs/read_write.c:440 (discriminator 1)) [ 132.876319][ T3644] kernel_read (fs/read_write.c:459) [ 132.877129][ T3644] kernel_read_file (fs/kernel_read_file.c:94) [ 132.877978][ T3644] kernel_read_file_from_fd (include/linux/file.h:45 fs/kernel_read_file.c:186) [ 132.879019][ T3644] __do_sys_finit_module (kernel/module.c:4207) [ 132.879930][ T3644] __ia32_sys_finit_module (kernel/module.c:4189) [ 132.880930][ T3644] do_int80_syscall_32 (arch/x86/entry/common.c:112 arch/x86/entry/common.c:132) [ 132.881847][ T3644] entry_INT80_compat (arch/x86/entry/entry_64_compat.S:419)
To fix it, don't create the unneeded attribute for control device anymore.
Message-Id: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +3 -4
@@ -1344,9 +1344,9 @@ static int vduse_create_dev(struct vduse dev->minor = ret; dev->msg_timeout =VDUSE_MSG_DEFAULT_TIMEOUT ; - dev->dev =device_create (vduse_class,NULL , -MKDEV (MAJOR (vduse_major), dev->minor), - dev,"%s" , config->name); + dev->dev =device_create_with_groups (vduse_class,NULL , +MKDEV (MAJOR (vduse_major), dev->minor), + dev, vduse_dev_groups,"%s" , config->name);if (IS_ERR (dev->dev)) { ret =PTR_ERR (dev->dev); goto err_dev;
@@ -1595,7 +1595,6 @@ static int vduse_init(void)return PTR_ERR (vduse_class); vduse_class->devnode = vduse_devnode; - vduse_class->dev_groups = vduse_dev_groups; ret =alloc_chrdev_region (&vduse_major,0 ,VDUSE_DEV_MAX ,"vduse" );if (ret)
Greg Kroah-Hartman
maintainerPATCH 325/339 mm/huge_memory: Fix xarray node memory leak
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit 69a37a8ba1b408a1c7616494aa7018e4b3844cbe upstream.
If xas_split_alloc() fails to allocate the necessary nodes to complete the xarray entry split, it sets the xa_state to -ENOMEM, which xas_nomem() then interprets as "Please allocate more memory", not as "Please free any unnecessary memory" (which was the intended outcome). It's confusing to use xas_nomem() to free memory in this context, so call xas_destroy() instead.
--- include/linux/xarray.h | 1 + lib/xarray.c | 5 +++-- mm/huge_memory.c | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-)
include/linux/xarray.h +1 -0
@@ -1508,6 +1508,7 @@ void *xas_find_marked(struct xa_state *,void xas_init_marks (const struct xa_state *);bool xas_nomem (struct xa_state *,gfp_t ); +void xas_destroy (struct xa_state *);void xas_pause (struct xa_state *);void xas_create_range (struct xa_state *);
lib/xarray.c +3 -2
@@ -264,9 +264,10 @@ static void xa_node_free(struct xa_node* xas_destroy() - Free any resources allocated during the XArray operation. * @xas: XArray operation state. * -* This function is now internal-only. +* Most users will not need to call this function; it is called for you +* by xas_nomem(). */ -static void xas_destroy (struct xa_state *xas) +void xas_destroy (struct xa_state *xas) {struct xa_node *next, *node = xas->xa_alloc;
mm/huge_memory.c +1 -2
@@ -2622,8 +2622,7 @@ out_unlock:if (mapping)i_mmap_unlock_read (mapping); out: -/* Free any memory we didn't use */ -xas_nomem (&xas,0 ); +xas_destroy (&xas);count_vm_event (!ret ?THP_SPLIT_PAGE :THP_SPLIT_PAGE_FAILED );return ret; }
Greg Kroah-Hartman
maintainerPATCH 330/339 drm/amdgpu/jpeg2: Add jpeg vmid update under IB submit
In reply to Greg Kroah-HartmanFrom: Mohammad Zafar Ziya <[email protected]>
commit 578eb31776df57c81307fb3f96ef0781332c3c7c upstream.
Add jpeg vmid update under IB submit
--- drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c | 6 +++++- drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.c +5 -1
@@ -535,6 +535,10 @@ void jpeg_v2_0_dec_ring_emit_ib(struct a {unsigned vmid =AMDGPU_JOB_GET_VMID (job); +amdgpu_ring_write (ring,PACKETJ (mmUVD_JPEG_IH_CTRL_INTERNAL_OFFSET, +0 ,0 ,PACKETJ_TYPE0 )); +amdgpu_ring_write (ring, (vmid <<JPEG_IH_CTRL__IH_VMID__SHIFT )); +amdgpu_ring_write (ring,PACKETJ (mmUVD_LMI_JRBC_IB_VMID_INTERNAL_OFFSET,0 ,0 ,PACKETJ_TYPE0 ));amdgpu_ring_write (ring, (vmid | (vmid <<4 )));
@@ -768,7 +772,7 @@ static const struct amdgpu_ring_funcs jp8 +/* jpeg_v2_0_dec_ring_emit_vm_flush */ 18 +18 +/* jpeg_v2_0_dec_ring_emit_fence x2 vm fence */ 8 + 16, - .emit_ib_size = 22, /* jpeg_v2_0_dec_ring_emit_ib */ + .emit_ib_size = 24, /* jpeg_v2_0_dec_ring_emit_ib */ .emit_ib = jpeg_v2_0_dec_ring_emit_ib, .emit_fence = jpeg_v2_0_dec_ring_emit_fence, .emit_vm_flush = jpeg_v2_0_dec_ring_emit_vm_flush,
drivers/gpu/drm/amd/amdgpu/jpeg_v2_0.h +1 -0
@@ -41,6 +41,7 @@#define mmUVD_JRBC_RB_REF_DATA_INTERNAL_OFFSET 0x4084#define mmUVD_JRBC_STATUS_INTERNAL_OFFSET 0x4089#define mmUVD_JPEG_PITCH_INTERNAL_OFFSET 0x401f +#define mmUVD_JPEG_IH_CTRL_INTERNAL_OFFSET 0x4149#define JRBC_DEC_EXTERNAL_REG_WRITE_ADDR 0x18000
Greg Kroah-Hartman
maintainerPATCH 336/339 random: mark bootloader randomness code as __init
In reply to Greg Kroah-HartmanFrom: "Jason A. Donenfeld" <[email protected]>
commit 39e0f991a62ed5efabd20711a7b6e7da92603170 upstream.
add_bootloader_randomness() and the variables it touches are only used during __init and not after, so mark these as __init. At the same time, unexport this, since it's only called by other __init code that's built-in.
--- drivers/char/random.c | 7 +++---- include/linux/random.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/char/random.c +3 -4
@@ -793,8 +793,8 @@ static void __cold _credit_init_bits(siz* **********************************************************************/ -static bool trust_cpu__ro_after_init =IS_ENABLED (CONFIG_RANDOM_TRUST_CPU ); -static bool trust_bootloader__ro_after_init =IS_ENABLED (CONFIG_RANDOM_TRUST_BOOTLOADER ); +static bool trust_cpu__initdata =IS_ENABLED (CONFIG_RANDOM_TRUST_CPU ); +static bool trust_bootloader__initdata =IS_ENABLED (CONFIG_RANDOM_TRUST_BOOTLOADER );static int __init parse_trust_cpu (char *arg) {return kstrtobool (arg, &trust_cpu);
@@ -890,13 +890,12 @@ EXPORT_SYMBOL_GPL(add_hwgenerator_random* Handle random seed passed by bootloader, and credit it if * CONFIG_RANDOM_TRUST_BOOTLOADER is set. */ -void __cold add_bootloader_randomness (const void *buf,size_t len) +void __init add_bootloader_randomness (const void *buf,size_t len) {mix_pool_bytes (buf, len);if (trust_bootloader)credit_init_bits (len *8 ); } -EXPORT_SYMBOL_GPL (add_bootloader_randomness);#if IS_ENABLED (CONFIG_VMGENID )static BLOCKING_NOTIFIER_HEAD (vmfork_chain);
include/linux/random.h +1 -1
@@ -13,7 +13,7 @@struct notifier_block ;void add_device_randomness (const void *buf,size_t len); -void add_bootloader_randomness (const void *buf,size_t len); +void __init add_bootloader_randomness (const void *buf,size_t len); void add_input_randomness(unsigned int type, unsigned int code, unsigned int value) __latent_entropy; void add_interrupt_randomness(int irq) __latent_entropy;
Greg Kroah-Hartman
maintainerPATCH 321/339 ixgbe: fix unexpected VLAN Rx in promisc mode on VF
In reply to Greg Kroah-HartmanFrom: Olivier Matz <[email protected]>
commit 7bb0fb7c63df95d6027dc50d6af3bc3bbbc25483 upstream.
When the promiscuous mode is enabled on a VF, the IXGBE_VMOLR_VPE bit (VLAN Promiscuous Enable) is set. This means that the VF will receive packets whose VLAN is not the same than the VLAN of the VF.
For instance, in this situation:
┌────────┐ ┌────────┐ ┌────────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ VF0├────┤VF1 VF2├────┤VF3 │ │ │ │ │ │ │ └────────┘ └────────┘ └────────┘ VM1 VM2 VM3
vf 0: vlan 1000 vf 1: vlan 1000 vf 2: vlan 1001 vf 3: vlan 1001
If we tcpdump on VF3, we see all the packets, even those transmitted on vlan 1000.
This behavior prevents to bridge VF1 and VF2 in VM2, because it will create a loop: packets transmitted on VF1 will be received by VF2 and vice-versa, and bridged again through the software bridge.
This patch remove the activation of VLAN Promiscuous when a VF enables the promiscuous mode. However, the IXGBE_VMOLR_UPE bit (Unicast Promiscuous) is kept, so that a VF receives all packets that has the same VLAN, whatever the destination MAC address.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +2 -2
@@ -1208,9 +1208,9 @@ static int ixgbe_update_vf_xcast_mode(streturn -EPERM ; } - disable =0 ; + disable =IXGBE_VMOLR_VPE ; enable =IXGBE_VMOLR_BAM |IXGBE_VMOLR_ROMPE | -IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE |IXGBE_VMOLR_VPE ; +IXGBE_VMOLR_MPE |IXGBE_VMOLR_UPE ;break ;default :return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 328/339 drm/bridge: analogix_dp: Support PSR-exit to disable transition
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit ca871659ec1606d33b1e76de8d4cf924cf627e34 upstream.
Most eDP panel functions only work correctly when the panel is not in self-refresh. In particular, analogix_dp_bridge_disable() tends to hit AUX channel errors if the panel is in self-refresh.
Given the above, it appears that so far, this driver assumes that we are never in self-refresh when it comes time to fully disable the bridge. Prior to commit 846c7dfc1193 ("drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb, v2."), this tended to be true, because we would automatically disable the pipe when framebuffers were removed, and so we'd typically disable the bridge shortly after the last display activity.
However, that is not guaranteed: an idle (self-refresh) display pipe may be disabled, e.g., when switching CRTCs. We need to exit PSR first.
Stable notes: this is definitely a bugfix, and the bug has likely existed in some form for quite a while. It may predate the "PSR helpers" refactor, but the code looked very different before that, and it's probably not worth rewriting the fix.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 42 +++++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +38 -4
@@ -1269,6 +1269,25 @@ static int analogix_dp_bridge_attach(str }static +struct drm_crtc *analogix_dp_get_old_crtc (struct analogix_dp_device *dp, +struct drm_atomic_state *state) +{ +struct drm_encoder *encoder = dp->encoder; +struct drm_connector *connector; +struct drm_connector_state *conn_state; + + connector =drm_atomic_get_old_connector_for_encoder (state, encoder); +if (!connector) +return NULL ; + + conn_state =drm_atomic_get_old_connector_state (state, connector); +if (!conn_state) +return NULL ; + +return conn_state->crtc; +} + +static struct drm_crtc *analogix_dp_get_new_crtc (struct analogix_dp_device *dp,struct drm_atomic_state *state) {
@@ -1448,14 +1467,16 @@ analogix_dp_bridge_atomic_disable(struct {struct drm_atomic_state *old_state = old_bridge_state->base.state;struct analogix_dp_device *dp = bridge->driver_private; -struct drm_crtc *crtc; +struct drm_crtc *old_crtc, *new_crtc; +struct drm_crtc_state *old_crtc_state =NULL ;struct drm_crtc_state *new_crtc_state =NULL ; +int ret; - crtc =analogix_dp_get_new_crtc (dp, old_state); -if (!crtc) + new_crtc =analogix_dp_get_new_crtc (dp, old_state); +if (!new_crtc) goto out; - new_crtc_state =drm_atomic_get_new_crtc_state (old_state, crtc); + new_crtc_state =drm_atomic_get_new_crtc_state (old_state, new_crtc);if (!new_crtc_state) goto out;
@@ -1464,6 +1485,19 @@ analogix_dp_bridge_atomic_disable(structreturn ; out: + old_crtc =analogix_dp_get_old_crtc (dp, old_state); +if (old_crtc) { + old_crtc_state =drm_atomic_get_old_crtc_state (old_state, + old_crtc); + +/* When moving from PSR to fully disabled, exit PSR first. */ +if (old_crtc_state && old_crtc_state->self_refresh_active) { + ret =analogix_dp_disable_psr (dp); +if (ret) +DRM_ERROR ("Failed to disable psr (%d)\n" , ret); + } + } +analogix_dp_bridge_disable (bridge); }
Greg Kroah-Hartman
maintainerPATCH 339/339 zonefs: fix handling of explicit_open option on mount
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit a2a513be7139b279f1b5b2cee59c6c4950c34346 upstream.
Ignoring the explicit_open mount option on mount for devices that do not have a limit on the number of open zones must be done after the mount options are parsed and set in s_mount_opts. Move the check to ignore the explicit_open option after the call to zonefs_parse_options() in zonefs_fill_super().
--- fs/zonefs/super.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/zonefs/super.c +6 -5
@@ -1690,11 +1690,6 @@ static int zonefs_fill_super(struct supe sbi->s_mount_opts =ZONEFS_MNTOPT_ERRORS_RO ; sbi->s_max_open_zones =bdev_max_open_zones (sb->s_bdev);atomic_set (&sbi->s_open_zones,0 ); -if (!sbi->s_max_open_zones && - sbi->s_mount_opts &ZONEFS_MNTOPT_EXPLICIT_OPEN ) { -zonefs_info (sb,"No open zones limit. Ignoring explicit_open mount option\n" ); - sbi->s_mount_opts &= ~ZONEFS_MNTOPT_EXPLICIT_OPEN ; - } ret =zonefs_read_super (sb);if (ret)
@@ -1713,6 +1708,12 @@ static int zonefs_fill_super(struct supezonefs_info (sb,"Mounting %u zones" ,blkdev_nr_zones (sb->s_bdev->bd_disk)); +if (!sbi->s_max_open_zones && + sbi->s_mount_opts &ZONEFS_MNTOPT_EXPLICIT_OPEN ) { +zonefs_info (sb,"No open zones limit. Ignoring explicit_open mount option\n" ); + sbi->s_mount_opts &= ~ZONEFS_MNTOPT_EXPLICIT_OPEN ; + } +/* Create root directory inode */ ret = -ENOMEM ; inode =new_inode (sb);
Greg Kroah-Hartman
maintainerPATCH 338/339 md/raid0: Ignore RAID0 layout if the second zone has only one device
In reply to Greg Kroah-HartmanFrom: Pascal Hambourg <[email protected]>
commit ea23994edc4169bd90d7a9b5908c6ccefd82fa40 upstream.
The RAID0 layout is irrelevant if all members have the same size so the array has only one zone. It is *also* irrelevant if the array has two zones and the second zone has only one device, for example if the array has two members of different sizes.
So in that case it makes sense to allow assembly even when the layout is undefined, like what is done when the array has only one zone.
--- drivers/md/raid0.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/md/raid0.c +16 -15
@@ -128,21 +128,6 @@ static int create_strip_zones(struct mddpr_debug ("md/raid0:%s: FINAL %d zones\n" ,mdname (mddev), conf->nr_strip_zones); -if (conf->nr_strip_zones ==1 ) { - conf->layout =RAID0_ORIG_LAYOUT ; - }else if (mddev->layout ==RAID0_ORIG_LAYOUT || - mddev->layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { - conf->layout = mddev->layout; - }else if (default_layout ==RAID0_ORIG_LAYOUT || - default_layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { - conf->layout = default_layout; - }else { -pr_err ("md/raid0:%s: cannot assemble multi-zone RAID0 with default_layout setting\n" , -mdname (mddev)); -pr_err ("md/raid0: please set raid0.default_layout to 1 or 2\n" ); - err = -ENOTSUPP ; - goto abort; - }/* * now since we have the hard sector sizes, we can make sure * chunk size is a multiple of that sector size
@@ -273,6 +258,22 @@ static int create_strip_zones(struct mdd (unsigned long long)smallest->sectors); } +if (conf->nr_strip_zones ==1 || conf->strip_zone[1 ].nb_dev ==1 ) { + conf->layout =RAID0_ORIG_LAYOUT ; + }else if (mddev->layout ==RAID0_ORIG_LAYOUT || + mddev->layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { + conf->layout = mddev->layout; + }else if (default_layout ==RAID0_ORIG_LAYOUT || + default_layout ==RAID0_ALT_MULTIZONE_LAYOUT ) { + conf->layout = default_layout; + }else { +pr_err ("md/raid0:%s: cannot assemble multi-zone RAID0 with default_layout setting\n" , +mdname (mddev)); +pr_err ("md/raid0: please set raid0.default_layout to 1 or 2\n" ); + err = -EOPNOTSUPP ; + goto abort; + } +pr_debug ("md/raid0:%s: done.\n" ,mdname (mddev)); *private_conf = conf;
Greg Kroah-Hartman
maintainerPATCH 322/339 Input: bcm5974 - set missing URB_NO_TRANSFER_DMA_MAP urb flag
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
commit c42e65664390be7c1ef3838cd84956d3a2739d60 upstream.
The bcm5974 driver does the allocation and dma mapping of the usb urb data buffer, but driver does not set the URB_NO_TRANSFER_DMA_MAP flag to let usb core know the buffer is already mapped.
usb core tries to map the already mapped buffer, causing a warning:
"xhci_hcd 0000:00:14.0: rejecting DMA map of vmalloc memory"
Fix this by setting the URB_NO_TRANSFER_DMA_MAP, letting usb core know buffer is already mapped by bcm5974 driver
--- drivers/input/mouse/bcm5974.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/input/mouse/bcm5974.c +6 -1
@@ -942,17 +942,22 @@ static int bcm5974_probe(struct usb_inteif (!dev->tp_data) goto err_free_bt_buffer; -if (dev->bt_urb) +if (dev->bt_urb) {usb_fill_int_urb (dev->bt_urb, udev,usb_rcvintpipe (udev, cfg->bt_ep), dev->bt_data, dev->cfg.bt_datalen, bcm5974_irq_button, dev,1 ); + dev->bt_urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; + } +usb_fill_int_urb (dev->tp_urb, udev,usb_rcvintpipe (udev, cfg->tp_ep), dev->tp_data, dev->cfg.tp_datalen, bcm5974_irq_trackpad, dev,1 ); + dev->tp_urb->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; +/* create bcm5974 device */ usb_make_path (udev, dev->phys,sizeof (dev->phys));strlcat (dev->phys,"/input0" ,sizeof (dev->phys));
Greg Kroah-Hartman
maintainerPATCH 310/339 libata: fix translation of concurrent positioning ranges
In reply to Greg Kroah-HartmanFrom: Tyler Erickson <[email protected]>
commit 6d11acd452fd885ef6ace184c9c70bc863a8c72f upstream.
Fixing the page length in the SCSI translation for the concurrent positioning ranges VPD page. It was writing starting in offset 3 rather than offset 2 where the MSB is supposed to start for the VPD page length.
--- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/libata-scsi.c +1 -1
@@ -2101,7 +2101,7 @@ static unsigned int ata_scsiop_inq_b9(st/* SCSI Concurrent Positioning Ranges VPD page: SBC-5 rev 1 or later */ rbuf[1 ] =0xb9 ; -put_unaligned_be16 (64 + (int )cpr_log->nr_cpr *32 -4 , &rbuf[3 ]); +put_unaligned_be16 (64 + (int )cpr_log->nr_cpr *32 -4 , &rbuf[2 ]);for (i =0 ; i < cpr_log->nr_cpr; i++, desc +=32 ) { desc[0 ] = cpr_log->cpr[i].num;
Greg Kroah-Hartman
maintainerPATCH 308/339 KEYS: trusted: tpm2: Fix migratable logic
In reply to Greg Kroah-HartmanFrom: David Safford <[email protected]>
commit dda5384313a40ecbaafd8a9a80f47483255e4c4d upstream.
When creating (sealing) a new trusted key, migratable trusted keys have the FIXED_TPM and FIXED_PARENT attributes set, and non-migratable keys don't. This is backwards, and also causes creation to fail when creating a migratable key under a migratable parent. (The TPM thinks you are trying to seal a non-migratable blob under a migratable parent.)
The following simple patch fixes the logic, and has been tested for all four combinations of migratable and non-migratable trusted keys and parent storage keys. With this logic, you will get a proper failure if you try to create a non-migratable trusted key under a migratable parent storage key, and all other combinations work correctly.
--- security/keys/trusted-keys/trusted_tpm2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_tpm2.c +2 -2
@@ -283,8 +283,8 @@ int tpm2_seal_trusted(struct tpm_chip *c/* key properties */ flags =0 ; flags |= options->policydigest_len ?0 :TPM2_OA_USER_WITH_AUTH ; - flags |= payload->migratable ? (TPM2_OA_FIXED_TPM | -TPM2_OA_FIXED_PARENT ) :0 ; + flags |= payload->migratable ?0 : (TPM2_OA_FIXED_TPM | +TPM2_OA_FIXED_PARENT );tpm_buf_append_u32 (&buf, flags);/* policy */
Greg Kroah-Hartman
maintainerPATCH 305/339 KVM: x86/mmu: Check every prev_roots in __kvm_mmu_free_obsolete_roots()
In reply to Greg Kroah-HartmanFrom: Shaoqin Huang <[email protected]>
commit cf4a8693d97a51dccf5a1557248d12d6d8be4b9e upstream.
When freeing obsolete previous roots, check prev_roots as intended, not the current root.
Message-Id: <[email protected]>
--- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/mmu.c +1 -1
@@ -5168,7 +5168,7 @@ static void __kvm_mmu_free_obsolete_root roots_to_free |=KVM_MMU_ROOT_CURRENT ;for (i =0 ; i <KVM_MMU_NUM_PREV_ROOTS ; i++) { -if (is_obsolete_root (kvm, mmu->root.hpa)) +if (is_obsolete_root (kvm, mmu->prev_roots[i].hpa)) roots_to_free |=KVM_MMU_ROOT_PREVIOUS (i); }
Greg Kroah-Hartman
maintainerPATCH 307/339 filemap: Cache the value of vm_flags
In reply to Greg Kroah-HartmanFrom: Matthew Wilcox (Oracle) <[email protected]>
commit dcfa24ba68991ab69a48254a18377b45180ae664 upstream.
After we have unlocked the mmap_lock for I/O, the file is pinned, but the VMA is not. Checking this flag after that can be a use-after-free. It's not a terribly interesting use-after-free as it can only read one bit, and it's used to decide whether to read 2MB or 4MB. But it upsets the automated tools and it's generally bad practice anyway, so let's fix it.
--- mm/filemap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
mm/filemap.c +5 -4
@@ -2991,11 +2991,12 @@ static struct file *do_sync_mmap_readahestruct address_space *mapping = file->f_mapping;DEFINE_READAHEAD (ractl, file, ra, mapping, vmf->pgoff);struct file *fpin =NULL ; +unsigned long vm_flags = vmf->vma->vm_flags;unsigned int mmap_miss;#ifdef CONFIG_TRANSPARENT_HUGEPAGE /* Use the readahead code, even if readahead is disabled */ -if (vmf->vma->vm_flags &VM_HUGEPAGE ) { +if (vm_flags &VM_HUGEPAGE ) { fpin =maybe_unlock_mmap_for_io (vmf, fpin); ractl._index &= ~((unsigned long )HPAGE_PMD_NR -1 ); ra->size =HPAGE_PMD_NR ;
@@ -3003,7 +3004,7 @@ static struct file *do_sync_mmap_readahe* Fetch two PMD folios, so we get the chance to actually * readahead, unless we've been told not to. */ -if (!(vmf->vma->vm_flags &VM_RAND_READ )) +if (!(vm_flags &VM_RAND_READ )) ra->size *=2 ; ra->async_size =HPAGE_PMD_NR ;page_cache_ra_order (&ractl, ra,HPAGE_PMD_ORDER );
@@ -3012,12 +3013,12 @@ static struct file *do_sync_mmap_readahe#endif /* If we don't want any read-ahead, don't bother */ -if (vmf->vma->vm_flags &VM_RAND_READ ) +if (vm_flags &VM_RAND_READ )return fpin;if (!ra->ra_pages)return fpin; -if (vmf->vma->vm_flags &VM_SEQ_READ ) { +if (vm_flags &VM_SEQ_READ ) { fpin =maybe_unlock_mmap_for_io (vmf, fpin);page_cache_sync_ra (&ractl, ra->ra_pages);return fpin;
Greg Kroah-Hartman
maintainerPATCH 334/339 powerpc/32: Fix overread/overwrite of thread_struct via ptrace
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 8e1278444446fc97778a5e5c99bca1ce0bbc5ec9 upstream.
The ptrace PEEKUSR/POKEUSR (aka PEEKUSER/POKEUSER) API allows a process to read/write registers of another process.
To get/set a register, the API takes an index into an imaginary address space called the "USER area", where the registers of the process are laid out in some fashion.
The kernel then maps that index to a particular register in its own data structures and gets/sets the value.
The API only allows a single machine-word to be read/written at a time. So 4 bytes on 32-bit kernels and 8 bytes on 64-bit kernels.
The way floating point registers (FPRs) are addressed is somewhat complicated, because double precision float values are 64-bit even on 32-bit CPUs. That means on 32-bit kernels each FPR occupies two word-sized locations in the USER area. On 64-bit kernels each FPR occupies one word-sized location in the USER area.
Internally the kernel stores the FPRs in an array of u64s, or if VSX is enabled, an array of pairs of u64s where one half of each pair stores the FPR. Which half of the pair stores the FPR depends on the kernel's endianness.
To handle the different layouts of the FPRs depending on VSX/no-VSX and big/little endian, the TS_FPR() macro was introduced.
Unfortunately the TS_FPR() macro does not take into account the fact that the addressing of each FPR differs between 32-bit and 64-bit kernels. It just takes the index into the "USER area" passed from userspace and indexes into the fp_state.fpr array.
On 32-bit there are 64 indexes that address FPRs, but only 32 entries in the fp_state.fpr array, meaning the user can read/write 256 bytes past the end of the array. Because the fp_state sits in the middle of the thread_struct there are various fields than can be overwritten, including some pointers. As such it may be exploitable.
It has also been observed to cause systems to hang or otherwise misbehave when using gdbserver, and is probably the root cause of this report which could not be easily reproduced:
https://lore.kernel.org/linuxppc-dev/[email protected]/
Rather than trying to make the TS_FPR() macro even more complicated to fix the bug, or add more macros, instead add a special-case for 32-bit kernels. This is more obvious and hopefully avoids a similar bug happening again in future.
Note that because 32-bit kernels never have VSX enabled the code doesn't need to consider TS_FPRWIDTH/OFFSET at all. Add a BUILD_BUG_ON() to ensure that 32-bit && VSX is never enabled.
--- arch/powerpc/kernel/ptrace/ptrace-fpu.c | 20 ++++++++++++++------ arch/powerpc/kernel/ptrace/ptrace.c | 3 +++ 2 files changed, 17 insertions(+), 6 deletions(-)
arch/powerpc/kernel/ptrace/ptrace-fpu.c +14 -6
@@ -17,9 +17,13 @@ int ptrace_get_fpr(struct task_struct *c#ifdef CONFIG_PPC_FPU_REGS flush_fp_to_thread (child); -if (fpidx < (PT_FPSCR -PT_FPR0 )) -memcpy (data, &child->thread.TS_FPR (fpidx),sizeof (long )); -else +if (fpidx < (PT_FPSCR -PT_FPR0 )) { +if (IS_ENABLED (CONFIG_PPC32 )) +// On 32-bit the index we are passed refers to 32-bit words + *data = ((u32 *)child->thread.fp_state.fpr)[fpidx]; +else +memcpy (data, &child->thread.TS_FPR (fpidx),sizeof (long )); + }else *data = child->thread.fp_state.fpscr;#else *data =0 ;
@@ -39,9 +43,13 @@ int ptrace_put_fpr(struct task_struct *c#ifdef CONFIG_PPC_FPU_REGS flush_fp_to_thread (child); -if (fpidx < (PT_FPSCR -PT_FPR0 )) -memcpy (&child->thread.TS_FPR (fpidx), &data,sizeof (long )); -else +if (fpidx < (PT_FPSCR -PT_FPR0 )) { +if (IS_ENABLED (CONFIG_PPC32 )) +// On 32-bit the index we are passed refers to 32-bit words + ((u32 *)child->thread.fp_state.fpr)[fpidx] = data; +else +memcpy (&child->thread.TS_FPR (fpidx), &data,sizeof (long )); + }else child->thread.fp_state.fpscr = data;#endif
arch/powerpc/kernel/ptrace/ptrace.c +3 -0
@@ -450,4 +450,7 @@ void __init pt_regs_check(void)#else BUILD_BUG_ON (IS_ENABLED (CONFIG_HAVE_FUNCTION_DESCRIPTORS ));#endif + +// ptrace_get/put_fpr() rely on PPC32 and VSX being incompatible +BUILD_BUG_ON (IS_ENABLED (CONFIG_PPC32 ) &&IS_ENABLED (CONFIG_VSX )); }
Greg Kroah-Hartman
maintainerPATCH 303/339 scsi: lpfc: Resolve some cleanup issues following SLI path refactoring
In reply to Greg Kroah-HartmanFrom: James Smart <[email protected]>
commit e27f05147bff21408c1b8410ad8e90cd286e7952 upstream.
Following refactoring and consolidation in SLI processing, fix up some minor issues related to SLI path:
- Correct the setting of LPFC_EXCHANGE_BUSY flag in response IOCB.
- Fix some typographical errors.
- Fix duplicate log messages.
--- drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/lpfc/lpfc_sli.c | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -1
@@ -12063,7 +12063,7 @@ lpfc_sli_enable_msi(struct lpfc_hba *phb rc =pci_enable_msi (phba->pcidev);if (!rc)lpfc_printf_log (phba,KERN_INFO ,LOG_INIT , -"0462 PCI enable MSI mode success.\n" ); +"0012 PCI enable MSI mode success.\n" );else {lpfc_printf_log (phba,KERN_INFO ,LOG_INIT ,"0471 PCI enable MSI mode failed (%d)\n" , rc);
drivers/scsi/lpfc/lpfc_sli.c +12 -13
@@ -1930,7 +1930,7 @@ lpfc_issue_cmf_sync_wqe(struct lpfc_hba sync_buf =__lpfc_sli_get_iocbq (phba);if (!sync_buf) {lpfc_printf_log (phba,KERN_ERR ,LOG_CGN_MGMT , -"6213 No available WQEs for CMF_SYNC_WQE\n" ); +"6244 No available WQEs for CMF_SYNC_WQE\n" ); ret_val =ENOMEM ; goto out_unlock; }
@@ -3816,7 +3816,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hbset_job_ulpword4 (cmdiocbp,IOERR_ABORT_REQUESTED );/* -* For SLI4, irsiocb contains +* For SLI4, irspiocb contains * NO_XRI in sli_xritag, it * shall not affect releasing * sgl (xri) process.
@@ -3834,7 +3834,7 @@ lpfc_sli_process_sol_iocb(struct lpfc_hb } } } - (cmdiocbp->cmd_cmpl) (phba, cmdiocbp, saveq); + cmdiocbp->cmd_cmpl (phba, cmdiocbp, saveq); }else lpfc_sli_release_iocbq (phba, cmdiocbp); }else {
@@ -4074,8 +4074,7 @@ lpfc_sli_handle_fast_ring_event(struct l cmdiocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED ;if (cmdiocbq->cmd_cmpl) {spin_unlock_irqrestore (&phba->hbalock, iflag); - (cmdiocbq->cmd_cmpl)(phba, cmdiocbq, - &rspiocbq); + cmdiocbq->cmd_cmpl (phba, cmdiocbq, &rspiocbq);spin_lock_irqsave (&phba->hbalock, iflag); }break ;
@@ -10304,7 +10303,7 @@ __lpfc_sli_issue_iocb_s3(struct lpfc_hba* @flag: Flag indicating if this command can be put into txq. * * __lpfc_sli_issue_fcp_io_s3 is wrapper function to invoke lockless func to -* send an iocb command to an HBA with SLI-4 interface spec. +* send an iocb command to an HBA with SLI-3 interface spec. * * This function takes the hbalock before invoking the lockless version. * The function will return success after it successfully submit the wqe to
@@ -12741,7 +12740,7 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba cmdiocbq->cmd_cmpl = cmdiocbq->wait_cmd_cmpl; cmdiocbq->wait_cmd_cmpl =NULL ;if (cmdiocbq->cmd_cmpl) - (cmdiocbq->cmd_cmpl)(phba, cmdiocbq,NULL ); + cmdiocbq->cmd_cmpl (phba, cmdiocbq,NULL );else lpfc_sli_release_iocbq (phba, cmdiocbq);return ;
@@ -12755,9 +12754,9 @@ lpfc_sli_wake_iocb_wait(struct lpfc_hba/* Set the exchange busy flag for task management commands */ if ((cmdiocbq->cmd_flag &LPFC_IO_FCP ) && - !(cmdiocbq->cmd_flag &LPFC_IO_LIBDFC )) { + !(cmdiocbq->cmd_flag &LPFC_IO_LIBDFC )) { lpfc_cmd = container_of(cmdiocbq, struct lpfc_io_buf, - cur_iocbq); + cur_iocbq);if (rspiocbq && (rspiocbq->cmd_flag &LPFC_EXCHANGE_BUSY )) lpfc_cmd->flags |=LPFC_SBUF_XBUSY ;else
@@ -13897,7 +13896,7 @@ void lpfc_sli4_els_xri_abort_event_proc(* @irspiocbq: Pointer to work-queue completion queue entry. * * This routine handles an ELS work-queue completion event and construct -* a pseudo response ELS IODBQ from the SLI4 ELS WCQE for the common +* a pseudo response ELS IOCBQ from the SLI4 ELS WCQE for the common * discovery engine to handle. * * Return: Pointer to the receive IOCBQ, NULL otherwise.
@@ -13941,7 +13940,7 @@ lpfc_sli4_els_preprocess_rspiocbq(structif (bf_get (lpfc_wcqe_c_xb, wcqe)) {spin_lock_irqsave (&phba->hbalock, iflags); - cmdiocbq->cmd_flag |=LPFC_EXCHANGE_BUSY ; + irspiocbq->cmd_flag |=LPFC_EXCHANGE_BUSY ;spin_unlock_irqrestore (&phba->hbalock, iflags); }
@@ -14800,7 +14799,7 @@ lpfc_sli4_fp_handle_fcp_wcqe(struct lpfc/* Pass the cmd_iocb and the wcqe to the upper layer */ memcpy (&cmdiocbq->wcqe_cmpl, wcqe,sizeof (struct lpfc_wcqe_complete )); - (cmdiocbq->cmd_cmpl)(phba, cmdiocbq, cmdiocbq); + cmdiocbq->cmd_cmpl (phba, cmdiocbq, cmdiocbq); }else {lpfc_printf_log (phba,KERN_WARNING ,LOG_SLI , "0375 FCP cmdiocb not callback function "
@@ -18963,7 +18962,7 @@ lpfc_sli4_send_seq_to_ulp(struct lpfc_vp/* Free iocb created in lpfc_prep_seq */ list_for_each_entry_safe (curr_iocb, next_iocb, - &iocbq->list, list) { + &iocbq->list, list) {list_del_init (&curr_iocb->list);lpfc_sli_release_iocbq (phba, curr_iocb); }
Greg Kroah-Hartman
maintainerPATCH 311/339 ata: libata-transport: fix {dma|pio|xfer}_mode sysfs files
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
commit 72aad489f992871e908ff6d9055b26c6366fb864 upstream.
The {dma|pio}_mode sysfs files are incorrectly documented as having a list of the supported DMA/PIO transfer modes, while the corresponding fields of the *struct* ata_device hold the transfer mode IDs, not masks.
To match these docs, the {dma|pio}_mode (and even xfer_mode!) sysfs files are handled by the ata_bitfield_name_match() macro which leads to reading such kind of nonsense from them:
$ cat /sys/class/ata_device/dev3.0/pio_mode XFER_UDMA_7, XFER_UDMA_6, XFER_UDMA_5, XFER_UDMA_4, XFER_MW_DMA_4, XFER_PIO_6, XFER_PIO_5, XFER_PIO_4, XFER_PIO_3, XFER_PIO_2, XFER_PIO_1, XFER_PIO_0
Using the correct ata_bitfield_name_search() macro fixes that:
$ cat /sys/class/ata_device/dev3.0/pio_mode XFER_PIO_4
While fixing the file documentation, somewhat reword the {dma|pio}_mode file doc and add a note about being mostly useful for PATA devices to the xfer_mode file doc...
--- Documentation/ABI/testing/sysfs-ata | 11 ++++++----- drivers/ata/libata-transport.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-)
Documentation/ABI/testing/sysfs-ata +6 -5
@@ -107,13 +107,14 @@ Description: described in ATA8 7.16 and 7.17. Only valid if the device is not a PM. - pio_mode: (RO) Transfer modes supported by the device when - in PIO mode. Mostly used by PATA device. + pio_mode: (RO) PIO transfer mode used by the device. + Mostly used by PATA devices. - xfer_mode: (RO) Current transfer mode + xfer_mode: (RO) Current transfer mode. Mostly used by + PATA devices. - dma_mode: (RO) Transfer modes supported by the device when - in DMA mode. Mostly used by PATA device. + dma_mode: (RO) DMA transfer mode used by the device. + Mostly used by PATA devices. class: (RO) Device class. Can be "ata" for disk, "atapi" for packet device, "pmp" for PM, or
drivers/ata/libata-transport.c +1 -1
@@ -196,7 +196,7 @@ static struct { { XFER_PIO_0, "XFER_PIO_0" }, { XFER_PIO_SLOW, "XFER_PIO_SLOW" } }; -ata_bitfield_name_match (xfer,ata_xfer_names) +ata_bitfield_name_search (xfer, ata_xfer_names)/* * ATA Port attributes
Greg Kroah-Hartman
maintainerPATCH 332/339 drm/amdgpu: update VCN codec support for Yellow Carp
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 97e50305542f384741a5b45699aba349fe9fca73 upstream.
Supports AV1. Mesa already has support for this and doesn't rely on the kernel caps for yellow carp, so this was already working from an application perspective.
--- drivers/gpu/drm/amd/amdgpu/nv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/nv.c +1 -0
@@ -170,6 +170,7 @@ static const struct amdgpu_video_codec_i {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_HEVC, 8192, 4352, 186)}, {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_VP9, 8192, 4352, 0)}, {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_JPEG, 4096, 4096, 0)}, + {codec_info_build(AMDGPU_INFO_VIDEO_CAPS_CODEC_IDX_AV1, 8192, 4352, 0)}, }; static const struct amdgpu_video_codecs yc_video_codecs_decode = {
Greg Kroah-Hartman
maintainerPATCH 309/339 libata: fix reading concurrent positioning ranges log
In reply to Greg Kroah-HartmanFrom: Tyler Erickson <[email protected]>
commit c745dfc541e78428ba3986f1d17fe1dfdaca8184 upstream.
The concurrent positioning ranges log is not a fixed size and may depend on how many ranges are supported by the device. This patch uses the size reported in the GPL directory to determine the number of pages supported by the device before attempting to read this log page.
This resolves this error from the dmesg output:
ata6.00: Read log 0x47 page 0x00 failed, Emask 0x1
--- drivers/ata/libata-core.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/ata/libata-core.c +13 -8
@@ -2003,16 +2003,16 @@ retry:return err_mask; } -static bool ata_log_supported (struct ata_device *dev,u8 log) +static int ata_log_supported (struct ata_device *dev,u8 log) {struct ata_port *ap = dev->link->ap;if (dev->horkage &ATA_HORKAGE_NO_LOG_DIR ) -return false; +return 0 ;if (ata_read_log_page (dev,ATA_LOG_DIRECTORY ,0 , ap->sector_buf,1 )) -return false; -return get_unaligned_le16 (&ap->sector_buf[log *2 ]) ? true : false; +return 0 ; +return get_unaligned_le16 (&ap->sector_buf[log *2 ]); }static bool ata_identify_page_supported (struct ata_device *dev,u8 page)
@@ -2448,15 +2448,20 @@ static void ata_dev_config_cpr(struct atstruct ata_cpr_log *cpr_log =NULL ;u8 *desc, *buf =NULL ; -if (ata_id_major_version (dev->id) <11 || - !ata_log_supported (dev,ATA_LOG_CONCURRENT_POSITIONING_RANGES )) +if (ata_id_major_version (dev->id) <11 ) + goto out; + + buf_len =ata_log_supported (dev,ATA_LOG_CONCURRENT_POSITIONING_RANGES ); +if (buf_len ==0 ) goto out;/* * Read the concurrent positioning ranges log (0x47). We can have at -* most 255 32B range descriptors plus a 64B header. +* most 255 32B range descriptors plus a 64B header. This log varies in +* size, so use the size reported in the GPL directory. Reading beyond +* the supported length will result in an error. */ - buf_len = (64 +255 *32 +511 ) & ~511 ; + buf_len <<=9 ; buf =kzalloc (buf_len,GFP_KERNEL );if (!buf) goto out;
Greg Kroah-Hartman
maintainerPATCH 335/339 random: avoid checking crng_ready() twice in random_init()
In reply to Greg Kroah-HartmanFrom: "Jason A. Donenfeld" <[email protected]>
commit 9b29b6b20376ab64e1b043df6301d8a92378e631 upstream.
The current flow expands to:
if (crng_ready())
...
else if (...)
if (!crng_ready())
...The second crng_ready() call is redundant, but can't so easily be optimized out by the compiler.
This commit simplifies that to:
if (crng_ready()
...
else if (...)
...--- drivers/char/random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/random.c +1 -1
@@ -842,7 +842,7 @@ int __init random_init(const char *commaif (crng_ready ())crng_reseed ();else if (trust_cpu) -credit_init_bits (arch_bytes *8 ); +_credit_init_bits (arch_bytes *8 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 327/339 drm/amdkfd:Fix fw version for 10.3.6
In reply to Greg Kroah-HartmanFrom: Jesse Zhang <[email protected]>
commit a956a11ee669d069047525c8ec897b4c21a9cda1 upstream.
fix fw error when loading fw for 10.3.6
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +3 -1
@@ -156,7 +156,9 @@ static void kfd_device_info_init(structif (gc_version <IP_VERSION (11 ,0 ,0 )) {/* Navi2x+, Navi1x+ */ -if (gc_version >=IP_VERSION (10 ,3 ,0 )) +if (gc_version ==IP_VERSION (10 ,3 ,6 )) + kfd->device_info.no_atomic_fw_version =14 ; +else if (gc_version >=IP_VERSION (10 ,3 ,0 )) kfd->device_info.no_atomic_fw_version =92 ;else if (gc_version >=IP_VERSION (10 ,1 ,1 )) kfd->device_info.no_atomic_fw_version =145 ;
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.18.4 release. There are 339 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Wed, 15 Jun 2022 09:47:08 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.18.4-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.18.y
and the diffstat can be found below.thanks,
greg k-h
Hi Greg,
Compiled and booted on my test system Lenovo P50s: Intel Core i7 No emergency and critical messages in the dmesg
./perf bench sched all
# Running sched/messaging benchmark...
# 20 sender and receiver processes per group
# 10 groups == 400 processes run
Total time: 0.444 [sec]
# Running sched/pipe benchmark...
# Executed 1000000 pipe operations between two processes
Total time: 7.007 [sec]
7.007223 usecs/op
142709 ops/secThanks
-Zan
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.18.4 release. There are 339 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Successfully cross-compiled for arm (multi_v7_defconfig, GCC 12.1.0, ARMv7 with neon FPU) and arm64 (bcm2711_defconfig, GCC 12.1.0).
Signature · 1 line
An old man doll... just what I always wanted! - Clara