5.5.3-stable review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 15/367 cls_rsvp: fix rsvp_policy
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit cb3c0e6bdf64d0d124e94ce43cbe4ccbb9b37f51 ]
NLA_BINARY can be confusing, since .len value represents the max size of the blob.
cls_rsvp really wants user space to provide long enough data for TCA_RSVP_DST and TCA_RSVP_SRC attributes.
BUG: KMSAN: uninit-value in rsvp_get net/sched/cls_rsvp.h:258 [inline] BUG: KMSAN: uninit-value in gen_handle net/sched/cls_rsvp.h:402 [inline] BUG: KMSAN: uninit-value in rsvp_change+0x1ae9/0x4220 net/sched/cls_rsvp.h:572 CPU: 1 PID: 13228 Comm: syz-executor.1 Not tainted 5.5.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1c9/0x220 lib/dump_stack.c:118 kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118 __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215 rsvp_get net/sched/cls_rsvp.h:258 [inline] gen_handle net/sched/cls_rsvp.h:402 [inline] rsvp_change+0x1ae9/0x4220 net/sched/cls_rsvp.h:572 tc_new_tfilter+0x31fe/0x5010 net/sched/cls_api.c:2104 rtnetlink_rcv_msg+0xcb7/0x1570 net/core/rtnetlink.c:5415 netlink_rcv_skb+0x451/0x650 net/netlink/af_netlink.c:2477 rtnetlink_rcv+0x50/0x60 net/core/rtnetlink.c:5442 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0xf9e/0x1100 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x1248/0x14d0 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:639 [inline] sock_sendmsg net/socket.c:659 [inline] ____sys_sendmsg+0x12b6/0x1350 net/socket.c:2330 ___sys_sendmsg net/socket.c:2384 [inline] __sys_sendmsg+0x451/0x5f0 net/socket.c:2417 __do_sys_sendmsg net/socket.c:2426 [inline] __se_sys_sendmsg+0x97/0xb0 net/socket.c:2424 __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2424 do_syscall_64+0xb8/0x160 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x45b349 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f269d43dc78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f269d43e6d4 RCX: 000000000045b349 RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003 RBP: 000000000075bfc8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000009c2 R14: 00000000004cb338 R15: 000000000075bfd4
Uninit was created at:
kmsan_save_stack_with_flags mm/kmsan/kmsan.c:144 [inline] kmsan_internal_poison_shadow+0x66/0xd0 mm/kmsan/kmsan.c:127 kmsan_slab_alloc+0x8a/0xe0 mm/kmsan/kmsan_hooks.c:82 slab_alloc_node mm/slub.c:2774 [inline] __kmalloc_node_track_caller+0xb40/0x1200 mm/slub.c:4382 __kmalloc_reserve net/core/skbuff.c:141 [inline] __alloc_skb+0x2fd/0xac0 net/core/skbuff.c:209 alloc_skb include/linux/skbuff.h:1049 [inline] netlink_alloc_large_skb net/netlink/af_netlink.c:1174 [inline] netlink_sendmsg+0x7d3/0x14d0 net/netlink/af_netlink.c:1892 sock_sendmsg_nosec net/socket.c:639 [inline] sock_sendmsg net/socket.c:659 [inline] ____sys_sendmsg+0x12b6/0x1350 net/socket.c:2330 ___sys_sendmsg net/socket.c:2384 [inline] __sys_sendmsg+0x451/0x5f0 net/socket.c:2417 __do_sys_sendmsg net/socket.c:2426 [inline] __se_sys_sendmsg+0x97/0xb0 net/socket.c:2424 __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2424 do_syscall_64+0xb8/0x160 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- net/sched/cls_rsvp.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/sched/cls_rsvp.h +2 -4
@@ -463,10 +463,8 @@ static u32 gen_tunnel(struct rsvp_head *static const struct nla_policy rsvp_policy[TCA_RSVP_MAX +1 ] = { [TCA_RSVP_CLASSID ] = { .type =NLA_U32 }, - [TCA_RSVP_DST ] = { .type =NLA_BINARY , - .len =RSVP_DST_LEN *sizeof (u32) }, - [TCA_RSVP_SRC ] = { .type =NLA_BINARY , - .len =RSVP_DST_LEN *sizeof (u32) }, + [TCA_RSVP_DST ] = { .len =RSVP_DST_LEN *sizeof (u32) }, + [TCA_RSVP_SRC ] = { .len =RSVP_DST_LEN *sizeof (u32) }, [TCA_RSVP_PINFO ] = { .len =sizeof (struct tc_rsvp_pinfo ) }, };
Greg Kroah-Hartman
maintainerPATCH 18/367 rxrpc: Fix missing active use pinning of rxrpc_local object
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 04d36d748fac349b068ef621611f454010054c58 ]
The introduction of a split between the reference count on rxrpc_local objects and the usage count didn't quite go far enough. A number of kernel work items need to make use of the socket to perform transmission. These also need to get an active count on the local object to prevent the socket from being closed.
Fix this by getting the active count in those places.
Also split out the raw active count get/put functions as these places tend to hold refs on the rxrpc_local object already, so getting and putting an extra object ref is just a waste of time.
The problem can lead to symptoms like:
BUG: kernel NULL pointer dereference, address: 0000000000000018
..
CPU: 2 PID: 818 Comm: kworker/u9:0 Not tainted 5.5.0-fscache+ #51
...
RIP: 0010:selinux_socket_sendmsg+0x5/0x13
...
Call Trace:
security_socket_sendmsg+0x2c/0x3e
sock_sendmsg+0x1a/0x46
rxrpc_send_keepalive+0x131/0x1ae
rxrpc_peer_keepalive_worker+0x219/0x34b
process_one_work+0x18e/0x271
worker_thread+0x1a3/0x247
kthread+0xe6/0xeb
ret_from_fork+0x1f/0x30--- net/rxrpc/af_rxrpc.c | 2 ++ net/rxrpc/ar-internal.h | 10 ++++++++++ net/rxrpc/conn_event.c | 30 ++++++++++++++++++++---------- net/rxrpc/local_object.c | 18 +++++++----------- net/rxrpc/peer_event.c | 40 ++++++++++++++++++++++------------------ 5 files changed, 61 insertions(+), 39 deletions(-)
net/rxrpc/af_rxrpc.c +2 -0
@@ -194,6 +194,7 @@ static int rxrpc_bind(struct socket *soc service_in_use:write_unlock (&local->services_lock);rxrpc_unuse_local (local); +rxrpc_put_local (local); ret = -EADDRINUSE ; error_unlock:release_sock (&rx->sk);
@@ -899,6 +900,7 @@ static int rxrpc_release_sock(struct socrxrpc_purge_queue (&sk->sk_receive_queue);rxrpc_unuse_local (rx->local); +rxrpc_put_local (rx->local); rx->local =NULL ;key_put (rx->key); rx->key =NULL ;
net/rxrpc/ar-internal.h +10 -0
@@ -1021,6 +1021,16 @@ void rxrpc_unuse_local(struct rxrpc_locavoid rxrpc_queue_local (struct rxrpc_local *);void rxrpc_destroy_all_locals (struct rxrpc_net *); +static inline bool __rxrpc_unuse_local (struct rxrpc_local *local) +{ +return atomic_dec_return (&local->active_users) ==0 ; +} + +static inline bool __rxrpc_use_local (struct rxrpc_local *local) +{ +return atomic_fetch_add_unless (&local->active_users,1 ,0 ) !=0 ; +} +/* * misc.c */
net/rxrpc/conn_event.c +20 -10
@@ -438,16 +438,12 @@ again:/* * connection-level event processor */ -void rxrpc_process_connection (struct work_struct *work) +static void rxrpc_do_process_connection (struct rxrpc_connection *conn) { -struct rxrpc_connection *conn = - container_of(work, struct rxrpc_connection, processor);struct sk_buff *skb;u32 abort_code =RX_PROTOCOL_ERROR ;int ret; -rxrpc_see_connection (conn); -if (test_and_clear_bit (RXRPC_CONN_EV_CHALLENGE , &conn->events))rxrpc_secure_connection (conn);
@@ -475,18 +471,32 @@ void rxrpc_process_connection(struct wor } } -out: -rxrpc_put_connection (conn); -_leave ("" );return ; requeue_and_leave:skb_queue_head (&conn->rx_queue, skb); - goto out; +return ; protocol_error:if (rxrpc_abort_connection (conn, ret, abort_code) <0 ) goto requeue_and_leave;rxrpc_free_skb (skb, rxrpc_skb_freed); - goto out; +return ; +} + +void rxrpc_process_connection (struct work_struct *work) +{ +struct rxrpc_connection *conn = + container_of(work, struct rxrpc_connection, processor); + +rxrpc_see_connection (conn); + +if (__rxrpc_use_local (conn->params.local)) { +rxrpc_do_process_connection (conn); +rxrpc_unuse_local (conn->params.local); + } + +rxrpc_put_connection (conn); +_leave ("" ); +return ; }
net/rxrpc/local_object.c +7 -11
@@ -383,14 +383,11 @@ void rxrpc_put_local(struct rxrpc_local*/ struct rxrpc_local *rxrpc_use_local (struct rxrpc_local *local) { -unsigned int au; - local =rxrpc_get_local_maybe (local);if (!local)return NULL ; - au =atomic_fetch_add_unless (&local->active_users,1 ,0 ); -if (au ==0 ) { +if (!__rxrpc_use_local (local)) {rxrpc_put_local (local);return NULL ; }
@@ -404,14 +401,11 @@ struct rxrpc_local *rxrpc_use_local(stru*/ void rxrpc_unuse_local (struct rxrpc_local *local) { -unsigned int au; -if (local) { - au =atomic_dec_return (&local->active_users); -if (au ==0 ) +if (__rxrpc_unuse_local (local)) { +rxrpc_get_local (local);rxrpc_queue_local (local); -else -rxrpc_put_local (local); + } } }
@@ -468,7 +462,7 @@ static void rxrpc_local_processor(struct do { again = false; - if (atomic_read(&local->active_users) == 0) { + if (!__rxrpc_use_local(local)) { rxrpc_local_destroyer(local); break; }
@@ -482,6 +476,8 @@ static void rxrpc_local_processor(structrxrpc_process_local_events (local); again = true; } + +__rxrpc_unuse_local (local); }while (again);rxrpc_put_local (local);
net/rxrpc/peer_event.c +22 -18
@@ -364,27 +364,31 @@ static void rxrpc_peer_keepalive_dispatcif (!rxrpc_get_peer_maybe (peer))continue ; -spin_unlock_bh (&rxnet->peer_hash_lock); +if (__rxrpc_use_local (peer->local)) { +spin_unlock_bh (&rxnet->peer_hash_lock); - keepalive_at = peer->last_tx_at +RXRPC_KEEPALIVE_TIME ; - slot = keepalive_at - base; -_debug ("%02x peer %u t=%d {%pISp}" , - cursor, peer->debug_id, slot, &peer->srx.transport); + keepalive_at = peer->last_tx_at +RXRPC_KEEPALIVE_TIME ; + slot = keepalive_at - base; +_debug ("%02x peer %u t=%d {%pISp}" , + cursor, peer->debug_id, slot, &peer->srx.transport); -if (keepalive_at <= base || - keepalive_at > base +RXRPC_KEEPALIVE_TIME ) { -rxrpc_send_keepalive (peer); - slot =RXRPC_KEEPALIVE_TIME ; - } +if (keepalive_at <= base || + keepalive_at > base +RXRPC_KEEPALIVE_TIME ) { +rxrpc_send_keepalive (peer); + slot =RXRPC_KEEPALIVE_TIME ; + } -/* A transmission to this peer occurred since last we examined -* it so put it into the appropriate future bucket. -*/ - slot += cursor; - slot &= mask; -spin_lock_bh (&rxnet->peer_hash_lock); -list_add_tail (&peer->keepalive_link, - &rxnet->peer_keepalive[slot & mask]); +/* A transmission to this peer occurred since last we +* examined it so put it into the appropriate future +* bucket. +*/ + slot += cursor; + slot &= mask; +spin_lock_bh (&rxnet->peer_hash_lock); +list_add_tail (&peer->keepalive_link, + &rxnet->peer_keepalive[slot & mask]); +rxrpc_unuse_local (peer->local); + }rxrpc_put_peer_locked (peer); }
Greg Kroah-Hartman
maintainerPATCH 21/367 net: phy: at803x: disable vddio regulator
In reply to Greg Kroah-HartmanFrom: Michael Walle <[email protected]>
[ Upstream commit 2318ca8aef3877da2b16b92edce47a497370a86e ]
The probe() might enable a VDDIO regulator, which needs to be disabled again before calling regulator_put(). Add a remove() function.
--- drivers/net/phy/at803x.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/phy/at803x.c +11 -0
@@ -489,6 +489,14 @@ static int at803x_probe(struct phy_devicreturn at803x_parse_dt (phydev); } +static void at803x_remove (struct phy_device *phydev) +{ +struct at803x_priv *priv = phydev->priv; + +if (priv->vddio) +regulator_disable (priv->vddio); +} +static int at803x_clk_out_config (struct phy_device *phydev) {struct at803x_priv *priv = phydev->priv;
@@ -711,6 +719,7 @@ static struct phy_driver at803x_driver[] .name = "Qualcomm Atheros AR8035", .phy_id_mask = AT803X_PHY_ID_MASK, .probe = at803x_probe, + .remove = at803x_remove, .config_init = at803x_config_init, .set_wol = at803x_set_wol, .get_wol = at803x_get_wol,
@@ -726,6 +735,7 @@ static struct phy_driver at803x_driver[] .name = "Qualcomm Atheros AR8030", .phy_id_mask = AT803X_PHY_ID_MASK, .probe = at803x_probe, + .remove = at803x_remove, .config_init = at803x_config_init, .link_change_notify = at803x_link_change_notify, .set_wol = at803x_set_wol,
@@ -741,6 +751,7 @@ static struct phy_driver at803x_driver[] .name = "Qualcomm Atheros AR8031/AR8033", .phy_id_mask = AT803X_PHY_ID_MASK, .probe = at803x_probe, + .remove = at803x_remove, .config_init = at803x_config_init, .set_wol = at803x_set_wol, .get_wol = at803x_get_wol,
Greg Kroah-Hartman
maintainerPATCH 23/367 ionic: fix rxq comp packet type mask
In reply to Greg Kroah-HartmanFrom: Shannon Nelson <[email protected]>
[ Upstream commit b5ce31b5e11b768b7d685b2bab7db09ad5549493 ]
Be sure to include all the packet type bits in the mask.
--- drivers/net/ethernet/pensando/ionic/ionic_if.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/pensando/ionic/ionic_if.h +1 -1
@@ -862,7 +862,7 @@ struct ionic_rxq_comp {#define IONIC_RXQ_COMP_CSUM_F_VLAN 0x40#define IONIC_RXQ_COMP_CSUM_F_CALC 0x80u8 pkt_type_color; -#define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x0f +#define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x7f };enum ionic_pkt_type {
Greg Kroah-Hartman
maintainerPATCH 5/367 net: hsr: fix possible NULL deref in hsr_handle_frame()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 2b5b8251bc9fe2f9118411f037862ee17cf81e97 ]
hsr_port_get_rcu() can return NULL, so we need to be careful.
general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] CPU: 1 PID: 10249 Comm: syz-executor.5 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:__read_once_size include/linux/compiler.h:199 [inline] RIP: 0010:hsr_addr_is_self+0x86/0x330 net/hsr/hsr_framereg.c:44 Code: 04 00 f3 f3 f3 65 48 8b 04 25 28 00 00 00 48 89 45 d0 31 c0 e8 6b ff 94 f9 4c 89 f2 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 75 02 00 00 48 8b 43 30 49 39 c6 49 89 47 c0 0f RSP: 0018:ffffc90000da8a90 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff87e0cc33 RDX: 0000000000000006 RSI: ffffffff87e035d5 RDI: 0000000000000000 RBP: ffffc90000da8b20 R08: ffff88808e7de040 R09: ffffed1015d2707c R10: ffffed1015d2707b R11: ffff8880ae9383db R12: ffff8880a689bc5e R13: 1ffff920001b5153 R14: 0000000000000030 R15: ffffc90000da8af8 FS: 00007fd7a42be700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b32338000 CR3: 00000000a928c000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <IRQ> hsr_handle_frame+0x1c5/0x630 net/hsr/hsr_slave.c:31 __netif_receive_skb_core+0xfbc/0x30b0 net/core/dev.c:5099 __netif_receive_skb_one_core+0xa8/0x1a0 net/core/dev.c:5196 __netif_receive_skb+0x2c/0x1d0 net/core/dev.c:5312 process_backlog+0x206/0x750 net/core/dev.c:6144 napi_poll net/core/dev.c:6582 [inline] net_rx_action+0x508/0x1120 net/core/dev.c:6650 __do_softirq+0x262/0x98c kernel/softirq.c:292 do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1082 </IRQ>
--- net/hsr/hsr_slave.c | 2 ++ 1 file changed, 2 insertions(+)
net/hsr/hsr_slave.c +2 -0
@@ -27,6 +27,8 @@ static rx_handler_result_t hsr_handle_frrcu_read_lock ();/* hsr->node_db, hsr->ports */ port =hsr_port_get_rcu (skb->dev); +if (!port) + goto finish_pass;if (hsr_addr_is_self (port->hsr,eth_hdr (skb)->h_source)) {/* Directly kill frames sent by ourselves */
Greg Kroah-Hartman
maintainerPATCH 34/367 rcu: Use *_ONCE() to protect lockless ->expmask accesses
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
commit 15c7c972cd26d89a26788e609c53b5a465324a6c upstream.
The rcu_node structure's ->expmask field is accessed locklessly when starting a new expedited grace period and when reporting an expedited RCU CPU stall warning. This commit therefore handles the former by taking a snapshot of ->expmask while the lock is held and the latter by applying READ_ONCE() to lockless reads and WRITE_ONCE() to the corresponding updates.
--- kernel/rcu/tree_exp.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
kernel/rcu/tree_exp.h +9 -10
@@ -134,7 +134,7 @@ static void __maybe_unused sync_exp_resercu_for_each_node_breadth_first (rnp) {raw_spin_lock_irqsave_rcu_node (rnp, flags);WARN_ON_ONCE (rnp->expmask); - rnp->expmask = rnp->expmaskinit; +WRITE_ONCE (rnp->expmask, rnp->expmaskinit);raw_spin_unlock_irqrestore_rcu_node (rnp, flags); } }
@@ -211,7 +211,7 @@ static void __rcu_report_exp_rnp(struct rnp = rnp->parent;raw_spin_lock_rcu_node (rnp);/* irqs already disabled */ WARN_ON_ONCE (!(rnp->expmask & mask)); - rnp->expmask &= ~mask; +WRITE_ONCE (rnp->expmask, rnp->expmask & ~mask); } }
@@ -241,7 +241,7 @@ static void rcu_report_exp_cpu_mult(struraw_spin_unlock_irqrestore_rcu_node (rnp, flags);return ; } - rnp->expmask &= ~mask; +WRITE_ONCE (rnp->expmask, rnp->expmask & ~mask);__rcu_report_exp_rnp (rnp, wake, flags);/* Releases rnp->lock. */ }
@@ -372,12 +372,10 @@ static void sync_rcu_exp_select_node_cpuraw_spin_unlock_irqrestore_rcu_node (rnp, flags);/* IPI the remaining CPUs for expedited quiescent state. */ -for_each_leaf_node_cpu_mask (rnp, cpu, rnp->expmask) { +for_each_leaf_node_cpu_mask (rnp, cpu, mask_ofl_ipi) {unsigned long mask =leaf_node_cpu_bit (rnp, cpu);struct rcu_data *rdp =per_cpu_ptr (&rcu_data, cpu); -if (!(mask_ofl_ipi & mask)) -continue ; retry_ipi:if (rcu_dynticks_in_eqs_since (rdp, rdp->exp_dynticks_snap)) { mask_ofl_test |= mask;
@@ -491,7 +489,7 @@ static void synchronize_sched_expedited_struct rcu_data *rdp; mask =leaf_node_cpu_bit (rnp, cpu); -if (!(rnp->expmask & mask)) +if (!(READ_ONCE (rnp->expmask) & mask))continue ; ndetected++; rdp =per_cpu_ptr (&rcu_data, cpu);
@@ -503,7 +501,8 @@ static void synchronize_sched_expedited_ }pr_cont (" } %lu jiffies s: %lu root: %#lx/%c\n" , jiffies - jiffies_start, rcu_state.expedited_sequence, - rnp_root->expmask,".T" [!!rnp_root->exp_tasks]); +READ_ONCE (rnp_root->expmask), +".T" [!!rnp_root->exp_tasks]);if (ndetected) {pr_err ("blocking rcu_node structures:" );rcu_for_each_node_breadth_first (rnp) {
@@ -513,7 +512,7 @@ static void synchronize_sched_expedited_continue ;pr_cont (" l=%u:%d-%d:%#lx/%c" , rnp->level, rnp->grplo, rnp->grphi, - rnp->expmask, +READ_ONCE (rnp->expmask),".T" [!!rnp->exp_tasks]); }pr_cont ("\n" );
@@ -521,7 +520,7 @@ static void synchronize_sched_expedited_rcu_for_each_leaf_node (rnp) {for_each_leaf_node_possible_cpu (rnp, cpu) { mask =leaf_node_cpu_bit (rnp, cpu); -if (!(rnp->expmask & mask)) +if (!(READ_ONCE (rnp->expmask) & mask))continue ;dump_cpu_task (cpu); }
Greg Kroah-Hartman
maintainerPATCH 44/367 usb: dwc3: gadget: Delay starting transfer
In reply to Greg Kroah-HartmanFrom: Thinh Nguyen <[email protected]>
commit da10bcdd6f70dc9977f2cf18f4783cf78520623a upstream.
If the END_TRANSFER command hasn't completed yet, then don't send the START_TRANSFER command. The controller may not be able to start if that's the case. Some controller revisions depend on this. See commit 76a638f8ac0d ("usb: dwc3: gadget: wait for End Transfer to complete"). Let's only send START_TRANSFER command after the END_TRANSFER command had completed.
--- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/gadget.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
drivers/usb/dwc3/core.h +1 -0
@@ -690,6 +690,7 @@ struct dwc3_ep {#define DWC3_EP_TRANSFER_STARTED BIT(3)#define DWC3_EP_END_TRANSFER_PENDING BIT(4)#define DWC3_EP_PENDING_REQUEST BIT(5) +#define DWC3_EP_DELAY_START BIT(6)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
drivers/usb/dwc3/gadget.c +11 -0
@@ -1447,6 +1447,12 @@ static int __dwc3_gadget_ep_queue(structlist_add_tail (&req->list, &dep->pending_list); req->status =DWC3_REQUEST_STATUS_QUEUED ; +/* Start the transfer only after the END_TRANSFER is completed */ +if (dep->flags &DWC3_EP_END_TRANSFER_PENDING ) { + dep->flags |=DWC3_EP_DELAY_START ; +return 0 ; + } +/* * NOTICE: Isochronous endpoints should NEVER be prestarted. We must * wait for a XferNotReady event so we will know what's the current
@@ -2628,6 +2634,11 @@ static void dwc3_endpoint_interrupt(stru dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING ; dep->flags &= ~DWC3_EP_TRANSFER_STARTED ;dwc3_gadget_ep_cleanup_cancelled_requests (dep); +if ((dep->flags &DWC3_EP_DELAY_START ) && + !usb_endpoint_xfer_isoc (dep->endpoint.desc)) +__dwc3_gadget_kick_transfer (dep); + + dep->flags &= ~DWC3_EP_DELAY_START ; }break ;case DWC3_DEPEVT_STREAMEVT :
Greg Kroah-Hartman
maintainerPATCH 50/367 usb: gadget: f_ecm: Use atomic_t to track in-flight request
In reply to Greg Kroah-HartmanFrom: Bryan O'Donoghue <[email protected]>
commit d710562e01c48d59be3f60d58b7a85958b39aeda upstream.
Currently ecm->notify_req is used to flag when a request is in-flight. ecm->notify_req is set to NULL and when a request completes it is subsequently reset.
This is fundamentally buggy in that the unbind logic of the ECM driver will unconditionally free ecm->notify_req leading to a NULL pointer dereference.
--- drivers/usb/gadget/function/f_ecm.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/f_ecm.c +12 -4
@@ -52,6 +52,7 @@ struct f_ecm {struct usb_ep *notify;struct usb_request *notify_req;u8 notify_state; +atomic_t notify_count;bool is_open;/* FIXME is_open needs some irq-ish locking
@@ -380,7 +381,7 @@ static void ecm_do_notify(struct f_ecm *int status;/* notification already in flight? */ -if (!req) +if (atomic_read (&ecm->notify_count))return ; event = req->buf;
@@ -420,10 +421,10 @@ static void ecm_do_notify(struct f_ecm * event->bmRequestType =0xA1 ; event->wIndex =cpu_to_le16 (ecm->ctrl_id); - ecm->notify_req =NULL ; +atomic_inc (&ecm->notify_count); status =usb_ep_queue (ecm->notify, req,GFP_ATOMIC );if (status <0 ) { - ecm->notify_req = req; +atomic_dec (&ecm->notify_count);DBG (cdev,"notify --> %d\n" , status); } }
@@ -448,17 +449,19 @@ static void ecm_notify_complete(struct uswitch (req->status) {case 0 :/* no fault */ +atomic_dec (&ecm->notify_count);break ;case -ECONNRESET :case -ESHUTDOWN : +atomic_set (&ecm->notify_count,0 ); ecm->notify_state =ECM_NOTIFY_NONE ;break ;default :DBG (cdev,"event %02x --> %d\n" , event->bNotificationType, req->status); +atomic_dec (&ecm->notify_count);break ; } - ecm->notify_req = req;ecm_do_notify (ecm); }
@@ -907,6 +910,11 @@ static void ecm_unbind(struct usb_configusb_free_all_descriptors (f); +if (atomic_read (&ecm->notify_count)) { +usb_ep_dequeue (ecm->notify, ecm->notify_req); +atomic_set (&ecm->notify_count,0 ); + } +kfree (ecm->notify_req->buf);usb_ep_free_request (ecm->notify, ecm->notify_req); }
Greg Kroah-Hartman
maintainerPATCH 28/367 mfd: dln2: More sanity checking for endpoints
In reply to Greg Kroah-HartmanFrom: Oliver Neukum <[email protected]>
commit 2b8bd606b1e60ca28c765f69c1eedd7d2a2e9dca upstream.
It is not enough to check for the number of endpoints. The types must also be correct.
--- drivers/mfd/dln2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/mfd/dln2.c +11 -2
@@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interfa const struct usb_device_id *usb_id) {struct usb_host_interface *hostif = interface->cur_altsetting; +struct usb_endpoint_descriptor *epin; +struct usb_endpoint_descriptor *epout;struct device *dev = &interface->dev;struct dln2_dev *dln2;int ret;
@@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interfa hostif->desc.bNumEndpoints < 2)return -ENODEV ; + epin = &hostif->endpoint[0 ].desc; + epout = &hostif->endpoint[1 ].desc; +if (!usb_endpoint_is_bulk_out (epout)) +return -ENODEV ; +if (!usb_endpoint_is_bulk_in (epin)) +return -ENODEV ; + dln2 =kzalloc (sizeof (*dln2),GFP_KERNEL );if (!dln2)return -ENOMEM ; - dln2->ep_out = hostif->endpoint[0 ].desc.bEndpointAddress; - dln2->ep_in = hostif->endpoint[1 ].desc.bEndpointAddress; + dln2->ep_out = epout->bEndpointAddress; + dln2->ep_in = epin->bEndpointAddress; dln2->usb_dev =usb_get_dev (interface_to_usbdev (interface)); dln2->interface = interface;usb_set_intfdata (interface, dln2);
Greg Kroah-Hartman
maintainerPATCH 62/367 media: v4l2-core: compat: ignore native command codes
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 4a873f3fa5d6ca52e446d306dd7194dd86a09422 upstream.
The do_video_ioctl() compat handler converts the compat command codes into the native ones before processing further, but this causes problems for 32-bit user applications that pass a command code that matches a 64-bit native number, which will then be handled the same way.
Specifically, this breaks VIDIOC_DQEVENT_TIME from user space applications with 64-bit time_t, as the structure layout is the same as the native 64-bit layout on many architectures (x86 being the notable exception).
Change the handler to use the converted command code only for passing into the native ioctl handler, not for deciding on the conversion, in order to make the compat behavior match the native behavior.
Actual support for the 64-bit time_t version of VIDIOC_DQEVENT_TIME and other commands still needs to be added in a separate patch.
--- drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 148 +++++++++++++------------- 1 file changed, 75 insertions(+), 73 deletions(-)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +75 -73
@@ -1183,36 +1183,38 @@ static long do_video_ioctl(struct file *u32 aux_space;int compatible_arg =1 ;long err =0 ; +unsigned int ncmd;/* * 1. When struct size is different, converts the command. */ switch (cmd) { -case VIDIOC_G_FMT32 : cmd =VIDIOC_G_FMT ;break ; -case VIDIOC_S_FMT32 : cmd =VIDIOC_S_FMT ;break ; -case VIDIOC_QUERYBUF32 : cmd =VIDIOC_QUERYBUF ;break ; -case VIDIOC_G_FBUF32 : cmd =VIDIOC_G_FBUF ;break ; -case VIDIOC_S_FBUF32 : cmd =VIDIOC_S_FBUF ;break ; -case VIDIOC_QBUF32 : cmd =VIDIOC_QBUF ;break ; -case VIDIOC_DQBUF32 : cmd =VIDIOC_DQBUF ;break ; -case VIDIOC_ENUMSTD32 : cmd =VIDIOC_ENUMSTD ;break ; -case VIDIOC_ENUMINPUT32 : cmd =VIDIOC_ENUMINPUT ;break ; -case VIDIOC_TRY_FMT32 : cmd =VIDIOC_TRY_FMT ;break ; -case VIDIOC_G_EXT_CTRLS32 : cmd =VIDIOC_G_EXT_CTRLS ;break ; -case VIDIOC_S_EXT_CTRLS32 : cmd =VIDIOC_S_EXT_CTRLS ;break ; -case VIDIOC_TRY_EXT_CTRLS32 : cmd =VIDIOC_TRY_EXT_CTRLS ;break ; -case VIDIOC_DQEVENT32 : cmd =VIDIOC_DQEVENT ;break ; -case VIDIOC_OVERLAY32 : cmd =VIDIOC_OVERLAY ;break ; -case VIDIOC_STREAMON32 : cmd =VIDIOC_STREAMON ;break ; -case VIDIOC_STREAMOFF32 : cmd =VIDIOC_STREAMOFF ;break ; -case VIDIOC_G_INPUT32 : cmd =VIDIOC_G_INPUT ;break ; -case VIDIOC_S_INPUT32 : cmd =VIDIOC_S_INPUT ;break ; -case VIDIOC_G_OUTPUT32 : cmd =VIDIOC_G_OUTPUT ;break ; -case VIDIOC_S_OUTPUT32 : cmd =VIDIOC_S_OUTPUT ;break ; -case VIDIOC_CREATE_BUFS32 : cmd =VIDIOC_CREATE_BUFS ;break ; -case VIDIOC_PREPARE_BUF32 : cmd =VIDIOC_PREPARE_BUF ;break ; -case VIDIOC_G_EDID32 : cmd =VIDIOC_G_EDID ;break ; -case VIDIOC_S_EDID32 : cmd =VIDIOC_S_EDID ;break ; +case VIDIOC_G_FMT32 : ncmd =VIDIOC_G_FMT ;break ; +case VIDIOC_S_FMT32 : ncmd =VIDIOC_S_FMT ;break ; +case VIDIOC_QUERYBUF32 : ncmd =VIDIOC_QUERYBUF ;break ; +case VIDIOC_G_FBUF32 : ncmd =VIDIOC_G_FBUF ;break ; +case VIDIOC_S_FBUF32 : ncmd =VIDIOC_S_FBUF ;break ; +case VIDIOC_QBUF32 : ncmd =VIDIOC_QBUF ;break ; +case VIDIOC_DQBUF32 : ncmd =VIDIOC_DQBUF ;break ; +case VIDIOC_ENUMSTD32 : ncmd =VIDIOC_ENUMSTD ;break ; +case VIDIOC_ENUMINPUT32 : ncmd =VIDIOC_ENUMINPUT ;break ; +case VIDIOC_TRY_FMT32 : ncmd =VIDIOC_TRY_FMT ;break ; +case VIDIOC_G_EXT_CTRLS32 : ncmd =VIDIOC_G_EXT_CTRLS ;break ; +case VIDIOC_S_EXT_CTRLS32 : ncmd =VIDIOC_S_EXT_CTRLS ;break ; +case VIDIOC_TRY_EXT_CTRLS32 : ncmd =VIDIOC_TRY_EXT_CTRLS ;break ; +case VIDIOC_DQEVENT32 : ncmd =VIDIOC_DQEVENT ;break ; +case VIDIOC_OVERLAY32 : ncmd =VIDIOC_OVERLAY ;break ; +case VIDIOC_STREAMON32 : ncmd =VIDIOC_STREAMON ;break ; +case VIDIOC_STREAMOFF32 : ncmd =VIDIOC_STREAMOFF ;break ; +case VIDIOC_G_INPUT32 : ncmd =VIDIOC_G_INPUT ;break ; +case VIDIOC_S_INPUT32 : ncmd =VIDIOC_S_INPUT ;break ; +case VIDIOC_G_OUTPUT32 : ncmd =VIDIOC_G_OUTPUT ;break ; +case VIDIOC_S_OUTPUT32 : ncmd =VIDIOC_S_OUTPUT ;break ; +case VIDIOC_CREATE_BUFS32 : ncmd =VIDIOC_CREATE_BUFS ;break ; +case VIDIOC_PREPARE_BUF32 : ncmd =VIDIOC_PREPARE_BUF ;break ; +case VIDIOC_G_EDID32 : ncmd =VIDIOC_G_EDID ;break ; +case VIDIOC_S_EDID32 : ncmd =VIDIOC_S_EDID ;break ; +default : ncmd = cmd;break ; }/*
@@ -1221,11 +1223,11 @@ static long do_video_ioctl(struct file ** argument into it. */ switch (cmd) { -case VIDIOC_OVERLAY : -case VIDIOC_STREAMON : -case VIDIOC_STREAMOFF : -case VIDIOC_S_INPUT : -case VIDIOC_S_OUTPUT : +case VIDIOC_OVERLAY32 : +case VIDIOC_STREAMON32 : +case VIDIOC_STREAMOFF32 : +case VIDIOC_S_INPUT32 : +case VIDIOC_S_OUTPUT32 : err =alloc_userspace (sizeof (unsigned int ),0 , &new_p64);if (!err &&assign_in_user ((unsigned int __user *)new_p64, (compat_uint_t __user *)p32))
@@ -1233,23 +1235,23 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_G_INPUT : -case VIDIOC_G_OUTPUT : +case VIDIOC_G_INPUT32 : +case VIDIOC_G_OUTPUT32 : err =alloc_userspace (sizeof (unsigned int ),0 , &new_p64); compatible_arg =0 ;break ; -case VIDIOC_G_EDID : -case VIDIOC_S_EDID : +case VIDIOC_G_EDID32 : +case VIDIOC_S_EDID32 : err =alloc_userspace (sizeof (struct v4l2_edid ),0 , &new_p64);if (!err) err =get_v4l2_edid32 (new_p64, p32); compatible_arg =0 ;break ; -case VIDIOC_G_FMT : -case VIDIOC_S_FMT : -case VIDIOC_TRY_FMT : +case VIDIOC_G_FMT32 : +case VIDIOC_S_FMT32 : +case VIDIOC_TRY_FMT32 : err =bufsize_v4l2_format (p32, &aux_space);if (!err) err = alloc_userspace(sizeof(struct v4l2_format),
@@ -1262,7 +1264,7 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_CREATE_BUFS : +case VIDIOC_CREATE_BUFS32 : err =bufsize_v4l2_create (p32, &aux_space);if (!err) err = alloc_userspace(sizeof(struct v4l2_create_buffers),
@@ -1275,10 +1277,10 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_PREPARE_BUF : -case VIDIOC_QUERYBUF : -case VIDIOC_QBUF : -case VIDIOC_DQBUF : +case VIDIOC_PREPARE_BUF32 : +case VIDIOC_QUERYBUF32 : +case VIDIOC_QBUF32 : +case VIDIOC_DQBUF32 : err =bufsize_v4l2_buffer (p32, &aux_space);if (!err) err = alloc_userspace(sizeof(struct v4l2_buffer),
@@ -1291,7 +1293,7 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_S_FBUF : +case VIDIOC_S_FBUF32 : err =alloc_userspace (sizeof (struct v4l2_framebuffer ),0 , &new_p64);if (!err)
@@ -1299,13 +1301,13 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_G_FBUF : +case VIDIOC_G_FBUF32 : err =alloc_userspace (sizeof (struct v4l2_framebuffer ),0 , &new_p64); compatible_arg =0 ;break ; -case VIDIOC_ENUMSTD : +case VIDIOC_ENUMSTD32 : err =alloc_userspace (sizeof (struct v4l2_standard ),0 , &new_p64);if (!err)
@@ -1313,16 +1315,16 @@ static long do_video_ioctl(struct file * compatible_arg =0 ;break ; -case VIDIOC_ENUMINPUT : +case VIDIOC_ENUMINPUT32 : err =alloc_userspace (sizeof (struct v4l2_input ),0 , &new_p64);if (!err) err =get_v4l2_input32 (new_p64, p32); compatible_arg =0 ;break ; -case VIDIOC_G_EXT_CTRLS : -case VIDIOC_S_EXT_CTRLS : -case VIDIOC_TRY_EXT_CTRLS : +case VIDIOC_G_EXT_CTRLS32 : +case VIDIOC_S_EXT_CTRLS32 : +case VIDIOC_TRY_EXT_CTRLS32 : err =bufsize_v4l2_ext_controls (p32, &aux_space);if (!err) err = alloc_userspace(sizeof(struct v4l2_ext_controls),
@@ -1334,7 +1336,7 @@ static long do_video_ioctl(struct file * } compatible_arg =0 ;break ; -case VIDIOC_DQEVENT : +case VIDIOC_DQEVENT32 : err =alloc_userspace (sizeof (struct v4l2_event ),0 , &new_p64); compatible_arg =0 ;break ;
@@ -1352,9 +1354,9 @@ static long do_video_ioctl(struct file ** Otherwise, it will pass the newly allocated @new_p64 argument. */ if (compatible_arg) - err =native_ioctl (file, cmd, (unsigned long )p32); + err =native_ioctl (file, ncmd, (unsigned long )p32);else - err =native_ioctl (file, cmd, (unsigned long )new_p64); + err =native_ioctl (file, ncmd, (unsigned long )new_p64);if (err == -ENOTTY )return err;
@@ -1370,13 +1372,13 @@ static long do_video_ioctl(struct file ** the blocks to maximum allowed value. */ switch (cmd) { -case VIDIOC_G_EXT_CTRLS : -case VIDIOC_S_EXT_CTRLS : -case VIDIOC_TRY_EXT_CTRLS : +case VIDIOC_G_EXT_CTRLS32 : +case VIDIOC_S_EXT_CTRLS32 : +case VIDIOC_TRY_EXT_CTRLS32 :if (put_v4l2_ext_controls32 (file, new_p64, p32)) err = -EFAULT ;break ; -case VIDIOC_S_EDID : +case VIDIOC_S_EDID32 :if (put_v4l2_edid32 (new_p64, p32)) err = -EFAULT ;break ;
@@ -1389,49 +1391,49 @@ static long do_video_ioctl(struct file ** the original 32 bits structure. */ switch (cmd) { -case VIDIOC_S_INPUT : -case VIDIOC_S_OUTPUT : -case VIDIOC_G_INPUT : -case VIDIOC_G_OUTPUT : +case VIDIOC_S_INPUT32 : +case VIDIOC_S_OUTPUT32 : +case VIDIOC_G_INPUT32 : +case VIDIOC_G_OUTPUT32 :if (assign_in_user ((compat_uint_t __user *)p32, ((unsigned int __user *)new_p64))) err = -EFAULT ;break ; -case VIDIOC_G_FBUF : +case VIDIOC_G_FBUF32 : err =put_v4l2_framebuffer32 (new_p64, p32);break ; -case VIDIOC_DQEVENT : +case VIDIOC_DQEVENT32 : err =put_v4l2_event32 (new_p64, p32);break ; -case VIDIOC_G_EDID : +case VIDIOC_G_EDID32 : err =put_v4l2_edid32 (new_p64, p32);break ; -case VIDIOC_G_FMT : -case VIDIOC_S_FMT : -case VIDIOC_TRY_FMT : +case VIDIOC_G_FMT32 : +case VIDIOC_S_FMT32 : +case VIDIOC_TRY_FMT32 : err =put_v4l2_format32 (new_p64, p32);break ; -case VIDIOC_CREATE_BUFS : +case VIDIOC_CREATE_BUFS32 : err =put_v4l2_create32 (new_p64, p32);break ; -case VIDIOC_PREPARE_BUF : -case VIDIOC_QUERYBUF : -case VIDIOC_QBUF : -case VIDIOC_DQBUF : +case VIDIOC_PREPARE_BUF32 : +case VIDIOC_QUERYBUF32 : +case VIDIOC_QBUF32 : +case VIDIOC_DQBUF32 : err =put_v4l2_buffer32 (new_p64, p32);break ; -case VIDIOC_ENUMSTD : +case VIDIOC_ENUMSTD32 : err =put_v4l2_standard32 (new_p64, p32);break ; -case VIDIOC_ENUMINPUT : +case VIDIOC_ENUMINPUT32 : err =put_v4l2_input32 (new_p64, p32);break ; }
Greg Kroah-Hartman
maintainerPATCH 63/367 media: v4l2-rect.h: fix v4l2_rect_map_inside() top/left adjustments
In reply to Greg Kroah-HartmanFrom: Helen Koike <[email protected]>
commit f51e50db4c20d46930b33be3f208851265694f3e upstream.
boundary->width and boundary->height are sizes relative to boundary->left and boundary->top coordinates, but they were not being taken into consideration to adjust r->left and r->top, leading to the following error:
Consider the follow as initial values for boundary and r:
struct v4l2_rect boundary = {
.left = 100,
.top = 100,
.width = 800,
.height = 600,
}struct v4l2_rect r = {
.left = 0,
.top = 0,
.width = 1920,
.height = 960,
}calling v4l2_rect_map_inside(&r, &boundary) was modifying r to:
r = {
.left = 0,
.top = 0,
.width = 800,
.height = 600,
}Which is wrongly outside the boundary rectangle, because:
v4l2_rect_set_max_size(r, boundary); // r->width = 800, r->height = 600 ... if (r->left + r->width > boundary->width) // true r->left = boundary->width - r->width; // r->left = 800 - 800 if (r->top + r->height > boundary->height) // true r->top = boundary->height - r->height; // r->height = 600 - 600
Fix this by considering top/left coordinates from boundary.
--- include/media/v4l2-rect.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
include/media/v4l2-rect.h +4 -4
@@ -63,10 +63,10 @@ static inline void v4l2_rect_map_inside( r->left = boundary->left;if (r->top < boundary->top) r->top = boundary->top; -if (r->left + r->width > boundary->width) - r->left = boundary->width - r->width; -if (r->top + r->height > boundary->height) - r->top = boundary->height - r->height; +if (r->left + r->width > boundary->left + boundary->width) + r->left = boundary->left + boundary->width - r->width; +if (r->top + r->height > boundary->top + boundary->height) + r->top = boundary->top + boundary->height - r->height; }/**
Greg Kroah-Hartman
maintainerPATCH 66/367 x86/cpu: Update cached HLE state on write to TSX_CTRL_CPUID_CLEAR
In reply to Greg Kroah-HartmanFrom: Pawan Gupta <[email protected]>
commit 5efc6fa9044c3356d6046c6e1da6d02572dbed6b upstream.
/proc/cpuinfo currently reports Hardware Lock Elision (HLE) feature to be present on boot cpu even if it was disabled during the bootup. This is because cpuinfo_x86->x86_capability HLE bit is not updated after TSX state is changed via the new MSR IA32_TSX_CTRL.
Update the cached HLE bit also since it is expected to change after an update to CPUID_CLEAR bit in MSR IA32_TSX_CTRL.
--- arch/x86/kernel/cpu/tsx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/tsx.c +7 -6
@@ -115,11 +115,12 @@ void __init tsx_init(void)tsx_disable ();/* -* tsx_disable() will change the state of the -* RTM CPUID bit. Clear it here since it is now -* expected to be not set. +* tsx_disable() will change the state of the RTM and HLE CPUID +* bits. Clear them here since they are now expected to be not +* set. */ setup_clear_cpu_cap (X86_FEATURE_RTM ); +setup_clear_cpu_cap (X86_FEATURE_HLE ); }else if (tsx_ctrl_state ==TSX_CTRL_ENABLE ) {/*
@@ -131,10 +132,10 @@ void __init tsx_init(void)tsx_enable ();/* -* tsx_enable() will change the state of the -* RTM CPUID bit. Force it here since it is now -* expected to be set. +* tsx_enable() will change the state of the RTM and HLE CPUID +* bits. Force them here since they are now expected to be set. */ setup_force_cpu_cap (X86_FEATURE_RTM ); +setup_force_cpu_cap (X86_FEATURE_HLE ); } }
Greg Kroah-Hartman
maintainerPATCH 68/367 ALSA: hda: Apply aligned MMIO access only conditionally
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 4d024fe8f806e20e577cc934204c5784c7063293 upstream.
It turned out that the recent simplification of HD-audio bus access helpers caused a regression on the virtual HD-audio device on QEMU with ARM platforms. The driver got a CORB/RIRB timeout and couldn't probe any codecs.
The essential difference that caused a problem was the enforced aligned MMIO accesses by simplification. Since snd-hda-tegra driver is enabled on ARM, it enables CONFIG_SND_HDA_ALIGNED_MMIO, which makes the all HD-audio drivers using the aligned MMIO accesses. While this is mandatory for snd-hda-tegra, it seems that snd-hda-intel on ARM gets broken by this access pattern.
For addressing the regression, this patch introduces a new flag, aligned_mmio, to hdac_bus object, and applies the aligned MMIO only when this flag is set. This change affects only platforms with CONFIG_SND_HDA_ALIGNED_MMIO set, i.e. mostly only for ARM platforms.
Unfortunately the patch became a big bigger than it should be, just because the former calls didn't take hdac_bus object in the argument, hence we had to extend the call patterns.
--- include/sound/hdaudio.h | 77 +++++++++++++++++++++++++++++++--------------- sound/pci/hda/hda_tegra.c | 1 2 files changed, 54 insertions(+), 24 deletions(-)
include/sound/hdaudio.h +53 -24
@@ -8,6 +8,7 @@#include <linux/device.h> #include <linux/interrupt.h> +#include <linux/io.h> #include <linux/pm_runtime.h> #include <linux/timecounter.h> #include <sound/core.h>
@@ -330,6 +331,7 @@ struct hdac_bus { bool chip_init:1; /* h/w initialized *//* behavior flags */ + bool aligned_mmio:1; /* aligned MMIO access */ bool sync_write:1; /* sync after verb write */ bool use_posbuf:1; /* use position buffer */ bool snoop:1; /* enable snooping */
@@ -405,34 +407,61 @@ void snd_hdac_bus_free_stream_pages(struunsigned int snd_hdac_aligned_read (void __iomem *addr,unsigned int mask);void snd_hdac_aligned_write (unsigned int val,void __iomem *addr,unsigned int mask); -#define snd_hdac_reg_writeb (v, addr) snd_hdac_aligned_write(v, addr, 0xff) -#define snd_hdac_reg_writew (v, addr) snd_hdac_aligned_write(v, addr, 0xffff) -#define snd_hdac_reg_readb (addr) snd_hdac_aligned_read(addr, 0xff) -#define snd_hdac_reg_readw (addr) snd_hdac_aligned_read(addr, 0xffff) -#else /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writeb (val, addr) writeb(val, addr) -#define snd_hdac_reg_writew (val, addr) writew(val, addr) -#define snd_hdac_reg_readb (addr) readb(addr) -#define snd_hdac_reg_readw (addr) readw(addr) -#endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ -#define snd_hdac_reg_writel (val, addr) writel(val, addr) -#define snd_hdac_reg_readl (addr) readl(addr) +#define snd_hdac_aligned_mmio (bus) (bus)->aligned_mmio +#else +#define snd_hdac_aligned_mmio (bus) false +#define snd_hdac_aligned_read (addr, mask) 0 +#define snd_hdac_aligned_write (val, addr, mask) do {} while (0) +#endif + +static inline void snd_hdac_reg_writeb (struct hdac_bus *bus,void __iomem *addr, +u8 val) +{ +if (snd_hdac_aligned_mmio (bus)) +snd_hdac_aligned_write (val, addr,0xff ); +else +writeb (val, addr); +} + +static inline void snd_hdac_reg_writew (struct hdac_bus *bus,void __iomem *addr, +u16 val) +{ +if (snd_hdac_aligned_mmio (bus)) +snd_hdac_aligned_write (val, addr,0xffff ); +else +writew (val, addr); +} + +static inline u8 snd_hdac_reg_readb (struct hdac_bus *bus,void __iomem *addr) +{ +return snd_hdac_aligned_mmio (bus) ? +snd_hdac_aligned_read (addr,0xff ) :readb (addr); +} + +static inline u16 snd_hdac_reg_readw (struct hdac_bus *bus,void __iomem *addr) +{ +return snd_hdac_aligned_mmio (bus) ? +snd_hdac_aligned_read (addr,0xffff ) :readw (addr); +} + +#define snd_hdac_reg_writel (bus, addr, val) writel(val, addr) +#define snd_hdac_reg_readl (bus, addr) readl(addr)/* * macros for easy use */ #define _snd_hdac_chip_writeb (chip, reg, value) \ - snd_hdac_reg_writeb(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writeb(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readb (chip, reg) \ - snd_hdac_reg_readb((chip)->remap_addr + (reg)) + snd_hdac_reg_readb(chip, (chip)->remap_addr + (reg))#define _snd_hdac_chip_writew (chip, reg, value) \ - snd_hdac_reg_writew(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writew(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readw (chip, reg) \ - snd_hdac_reg_readw((chip)->remap_addr + (reg)) + snd_hdac_reg_readw(chip, (chip)->remap_addr + (reg))#define _snd_hdac_chip_writel (chip, reg, value) \ - snd_hdac_reg_writel(value, (chip)->remap_addr + (reg)) + snd_hdac_reg_writel(chip, (chip)->remap_addr + (reg), value)#define _snd_hdac_chip_readl (chip, reg) \ - snd_hdac_reg_readl((chip)->remap_addr + (reg)) + snd_hdac_reg_readl(chip, (chip)->remap_addr + (reg))/* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_chip_writel (chip, reg, value) \
@@ -540,17 +569,17 @@ int snd_hdac_get_stream_stripe_ctl(struc*/ /* read/write a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_writel (dev, reg, value) \ - snd_hdac_reg_writel(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writel((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_writew (dev, reg, value) \ - snd_hdac_reg_writew(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writew((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_writeb (dev, reg, value) \ - snd_hdac_reg_writeb(value, (dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_writeb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value)#define snd_hdac_stream_readl (dev, reg) \ - snd_hdac_reg_readl((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readl((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)#define snd_hdac_stream_readw (dev, reg) \ - snd_hdac_reg_readw((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readw((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)#define snd_hdac_stream_readb (dev, reg) \ - snd_hdac_reg_readb((dev)->sd_addr + AZX_REG_ ## reg) + snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg)/* update a register, pass without AZX_REG_ prefix */ #define snd_hdac_stream_updatel (dev, reg, mask, val) \
sound/pci/hda/hda_tegra.c +1 -0
@@ -398,6 +398,7 @@ static int hda_tegra_create(struct snd_creturn err; chip->bus.needs_damn_long_delay =1 ; + chip->bus.core.aligned_mmio =1 ; err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops);if (err <0 ) {
Greg Kroah-Hartman
maintainerPATCH 30/367 ALSA: pcm: Fix memory leak at closing a stream without hw_free
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 66f2d19f8116e16898f8d82e28573a384ddc430d upstream.
ALSA PCM core recently introduced a new managed PCM buffer allocation mode that does allocate / free automatically at hw_params and hw_free. However, it overlooked the code path directly calling hw_free PCM ops at releasing the PCM substream, and it may result in a memory leak as spotted by syzkaller when no buffer preallocation is used (e.g. vmalloc buffer).
This patch papers over it with a slight refactoring. The hw_free ops call and relevant tasks are unified in a new helper function, and call it from both places.
--- sound/core/pcm_native.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
sound/core/pcm_native.c +15 -9
@@ -785,10 +785,22 @@ end:return err; } +static int do_hw_free (struct snd_pcm_substream *substream) +{ +int result =0 ; + +snd_pcm_sync_stop (substream); +if (substream->ops->hw_free) + result = substream->ops->hw_free (substream); +if (substream->managed_buffer_alloc) +snd_pcm_lib_free_pages (substream); +return result; +} +static int snd_pcm_hw_free (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime; -int result =0 ; +int result;if (PCM_RUNTIME_CHECK (substream))return -ENXIO ;
@@ -805,11 +817,7 @@ static int snd_pcm_hw_free(struct snd_pcsnd_pcm_stream_unlock_irq (substream);if (atomic_read (&substream->mmap_count))return -EBADFD ; -snd_pcm_sync_stop (substream); -if (substream->ops->hw_free) - result = substream->ops->hw_free (substream); -if (substream->managed_buffer_alloc) -snd_pcm_lib_free_pages (substream); + result =do_hw_free (substream);snd_pcm_set_state (substream,SNDRV_PCM_STATE_OPEN );pm_qos_remove_request (&substream->latency_pm_qos_req);return result;
@@ -2466,9 +2474,7 @@ void snd_pcm_release_substream(struct snsnd_pcm_drop (substream);if (substream->hw_opened) { -if (substream->ops->hw_free && - substream->runtime->status->state !=SNDRV_PCM_STATE_OPEN ) - substream->ops->hw_free (substream); +do_hw_free (substream); substream->ops->close (substream); substream->hw_opened =0 ; }
Greg Kroah-Hartman
maintainerPATCH 94/367 mmc: spi: Toggle SPI polarity, do not hardcode it
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
commit af3ed119329cf9690598c5a562d95dfd128e91d6 upstream.
The code in mmc_spi_initsequence() tries to send a burst with high chipselect and for this reason hardcodes the device into SPI_CS_HIGH.
This is not good because the SPI_CS_HIGH flag indicates logical "asserted" CS not always the physical level. In some cases the signal is inverted in the GPIO library and in that case SPI_CS_HIGH is already set, and enforcing SPI_CS_HIGH again will actually drive it low.
Instead of hard-coding this, toggle the polarity so if the default is LOW it goes high to assert chipselect but if it is already high then toggle it low instead.
--- drivers/mmc/host/mmc_spi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/mmc_spi.c +8 -3
@@ -1134,17 +1134,22 @@ static void mmc_spi_initsequence(struct* SPI protocol. Another is that when chipselect is released while * the card returns BUSY status, the clock must issue several cycles * with chipselect high before the card will stop driving its output. +* +* SPI_CS_HIGH means "asserted" here. In some cases like when using +* GPIOs for chip select, SPI_CS_HIGH is set but this will be logically +* inverted by gpiolib, so if we want to ascertain to drive it high +* we should toggle the default with an XOR as we do here. */ - host->spi->mode |=SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ;if (spi_setup (host->spi) !=0 ) {/* Just warn; most cards work without it. */ dev_warn (&host->spi->dev,"can't change chip-select polarity\n" ); - host->spi->mode &= ~SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ; }else {mmc_spi_readbytes (host,18 ); - host->spi->mode &= ~SPI_CS_HIGH ; + host->spi->mode ^=SPI_CS_HIGH ;if (spi_setup (host->spi) !=0 ) {/* Wot, we can't get the same setup we had before? */ dev_err(&host->spi->dev,
Greg Kroah-Hartman
maintainerPATCH 102/367 ubifs: dont trigger assertion on invalid no-key filename
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit f0d07a98a070bb5e443df19c3aa55693cbca9341 upstream.
If userspace provides an invalid fscrypt no-key filename which encodes a hash value with any of the UBIFS node type bits set (i.e. the high 3 bits), gracefully report ENOENT rather than triggering ubifs_assert().
Test case with kvm-xfstests shell:
. fs/ubifs/config
. ~/xfstests/common/encrypt dev=$(__blkdev_to_ubi_volume /dev/vdc) ubiupdatevol $dev -t
mount $dev /mnt -t ubifs
mkdir /mnt/edir
xfs_io -c set_encpolicy /mnt/edir
rm /mnt/edir/_,,,,,DAAAAAAAAAAAAAAAAAAAAAAAAAA
With the bug, the following assertion fails on the 'rm' command:
[ 19.066048] UBIFS error (ubi0:0 pid 379): ubifs_assert_failed: UBIFS assert failed: !(hash & ~UBIFS_S_KEY_HASH_MASK), in fs/ubifs/key.h:170
--- fs/ubifs/dir.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/dir.c +2 -0
@@ -228,6 +228,8 @@ static struct dentry *ubifs_lookup(strucif (nm.hash) {ubifs_assert (c,fname_len (&nm) ==0 );ubifs_assert (c,fname_name (&nm) ==NULL ); +if (nm.hash & ~UBIFS_S_KEY_HASH_MASK ) + goto done;/* ENOENT */ dent_key_init_hash (c, &key, dir->i_ino, nm.hash); err =ubifs_tnc_lookup_dh (c, &key, dent, nm.minor_hash); }else {
Greg Kroah-Hartman
maintainerPATCH 104/367 ubifs: Fix FS_IOC_SETFLAGS unexpectedly clearing encrypt flag
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 2b57067a7778484c10892fa191997bfda29fea13 upstream.
UBIFS's implementation of FS_IOC_SETFLAGS fails to preserve existing inode flags that aren't settable by FS_IOC_SETFLAGS, namely the encrypt flag. This causes the encrypt flag to be unexpectedly cleared.
Fix it by preserving existing unsettable flags, like ext4 and f2fs do.
Test case with kvm-xfstests shell:
FSTYP=ubifs KEYCTL_PROG=keyctl
. fs/ubifs/config
. ~/xfstests/common/encrypt
dev=$(__blkdev_to_ubi_volume /dev/vdc)
ubiupdatevol -t $dev
mount $dev /mnt -t ubifs
k=$(_generate_session_encryption_key)
mkdir /mnt/edir
xfs_io -c "set_encpolicy $k" /mnt/edir
echo contents > /mnt/edir/file
chattr +i /mnt/edir/file
chattr -i /mnt/edir/file
With the bug, the following errors occur on the last command:
[ 18.081559] fscrypt (ubifs, inode 67): Inconsistent encryption context (parent directory: 65)
chattr: Operation not permitted while reading flags on /mnt/edir/file--- fs/ubifs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ubifs/ioctl.c +2 -1
@@ -113,7 +113,8 @@ static int setflags(struct inode *inode,if (err) goto out_unlock; - ui->flags =ioctl2ubifs (flags); + ui->flags &= ~ioctl2ubifs (UBIFS_SUPPORTED_IOCTL_FLAGS ); + ui->flags |=ioctl2ubifs (flags);ubifs_set_inode_flags (inode); inode->i_ctime =current_time (inode); release = ui->dirty;
Greg Kroah-Hartman
maintainerPATCH 103/367 ubifs: Fix wrong memory allocation
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
commit edec51374bce779f37fc209a228139c55d90ec8d upstream.
In create_default_filesystem() when we allocate the idx node we must use the idx_node_size we calculated just one line before, not tmp, which contains completely other data.
--- fs/ubifs/sb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ubifs/sb.c +1 -1
@@ -161,7 +161,7 @@ static int create_default_filesystem(str sup =kzalloc (ALIGN (UBIFS_SB_NODE_SZ , c->min_io_size),GFP_KERNEL ); mst =kzalloc (c->mst_node_alsz,GFP_KERNEL ); idx_node_size =ubifs_idx_node_sz (c,1 ); - idx =kzalloc (ALIGN (tmp, c->min_io_size),GFP_KERNEL ); + idx =kzalloc (ALIGN (idx_node_size, c->min_io_size),GFP_KERNEL ); ino =kzalloc (ALIGN (UBIFS_INO_NODE_SZ , c->min_io_size),GFP_KERNEL ); cs =kzalloc (ALIGN (UBIFS_CS_NODE_SZ , c->min_io_size),GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 108/367 ASoC: topology: fix soc_tplg_fe_link_create() - link->dobj initialization order
In reply to Greg Kroah-HartmanFrom: Jaroslav Kysela <[email protected]>
commit 8ce1cbd6ce0b1bda0c980c64fee4c1e1378355f1 upstream.
The code which checks the return value for snd_soc_add_dai_link() call in soc_tplg_fe_link_create() moved the snd_soc_add_dai_link() call before link->dobj members initialization.
While it does not affect the latest kernels, the old soc-core.c code in the stable kernels is affected. The snd_soc_add_dai_link() function uses the link->dobj.type member to check, if the link structure is valid.
Reorder the link->dobj initialization to make things work again. It's harmless for the recent code (and the structure should be properly initialized before other calls anyway).
The problem is in stable linux-5.4.y since version 5.4.11 when the upstream commit 76d270364932 was applied.
--- sound/soc/soc-topology.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
sound/soc/soc-topology.c +4 -3
@@ -1906,6 +1906,10 @@ static int soc_tplg_fe_link_create(struc link->num_codecs =1 ; link->num_platforms =1 ; + link->dobj.index = tplg->index; + link->dobj.ops = tplg->ops; + link->dobj.type =SND_SOC_DOBJ_DAI_LINK ; +if (strlen (pcm->pcm_name)) { link->name =kstrdup (pcm->pcm_name,GFP_KERNEL ); link->stream_name =kstrdup (pcm->pcm_name,GFP_KERNEL );
@@ -1942,9 +1946,6 @@ static int soc_tplg_fe_link_create(struc goto err; } - link->dobj.index = tplg->index; - link->dobj.ops = tplg->ops; - link->dobj.type =SND_SOC_DOBJ_DAI_LINK ;list_add (&link->dobj.list, &tplg->comp->dobj_list);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 112/367 nvmem: imx: scu: fix write SIP
In reply to Greg Kroah-HartmanFrom: Peng Fan <[email protected]>
commit 40bb95dbb8acca35f8d52a833393ddbb01cfa2db upstream.
SIP number 0xC200000A is for reading, 0xC200000B is for writing. And the following two args for write are word index, data to write.
--- drivers/nvmem/imx-ocotp-scu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/nvmem/imx-ocotp-scu.c +2 -4
@@ -15,8 +15,7 @@#include <linux/platform_device.h> #include <linux/slab.h> -#define IMX_SIP_OTP 0xC200000A -#define IMX_SIP_OTP_WRITE 0x2 +#define IMX_SIP_OTP_WRITE 0xc200000Benum ocotp_devtype {IMX8QXP ,
@@ -212,8 +211,7 @@ static int imx_scu_ocotp_write(void *conmutex_lock (&scu_ocotp_mutex); -arm_smccc_smc (IMX_SIP_OTP ,IMX_SIP_OTP_WRITE , index, *buf, -0 ,0 ,0 ,0 , &res); +arm_smccc_smc (IMX_SIP_OTP_WRITE , index, *buf,0 ,0 ,0 ,0 ,0 , &res);mutex_unlock (&scu_ocotp_mutex);
Greg Kroah-Hartman
maintainerPATCH 111/367 mfd: axp20x: Mark AXP20X_VBUS_IPSOUT_MGMT as volatile
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit dc91c3b6fe66a13ac76f6cb3b2100c0779cd3350 upstream.
On AXP288 and newer PMICs, bit 7 of AXP20X_VBUS_IPSOUT_MGMT can be set to prevent using the VBUS input. However, when the VBUS unplugged and plugged back in, the bit automatically resets to zero.
We need to set the register as volatile to prevent regmap from caching that bit. Otherwise, regcache will think the bit is already set and not write the register.
--- drivers/mfd/axp20x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/axp20x.c +1 -1
@@ -126,7 +126,7 @@ static const struct regmap_range axp288_static const struct regmap_range axp288_volatile_ranges[] = {regmap_reg_range (AXP20X_PWR_INPUT_STATUS ,AXP288_POWER_REASON ),regmap_reg_range (AXP288_BC_GLOBAL ,AXP288_BC_GLOBAL ), -regmap_reg_range (AXP288_BC_DET_STAT ,AXP288_BC_DET_STAT ), +regmap_reg_range (AXP288_BC_DET_STAT ,AXP20X_VBUS_IPSOUT_MGMT ),regmap_reg_range (AXP20X_CHRG_BAK_CTRL ,AXP20X_CHRG_BAK_CTRL ),regmap_reg_range (AXP20X_IRQ1_EN ,AXP20X_IPSOUT_V_HIGH_L ),regmap_reg_range (AXP20X_TIMER_CTRL ,AXP20X_TIMER_CTRL ),
Greg Kroah-Hartman
maintainerPATCH 78/367 MIPS: fix indentation of the RELOCS message
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
commit a53998802e178451701d59d38e36f551422977ba upstream.
quiet_cmd_relocs lacks a whitespace which results in:
LD vmlinux SORTEX vmlinux SYSMAP System.map
RELOCS vmlinux
Building modules, stage 2.
MODPOST 64 modules
After this patch:
LD vmlinux SORTEX vmlinux SYSMAP System.map RELOCS vmlinux
Building modules, stage 2.
MODPOST 64 modules
Typo is present in kernel tree since the introduction of relocatable kernel support in commit e818fac595ab ("MIPS: Generate relocation table when CONFIG_RELOCATABLE"), but the relocation scripts were moved to Makefile.postlink later with commit 44079d3509ae ("MIPS: Use Makefile.postlink to insert relocations into vmlinux").
--- arch/mips/Makefile.postlink | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Makefile.postlink +1 -1
@@ -17,7 +17,7 @@ quiet_cmd_ls3_llsc = LLSCCHK $@ cmd_ls3_llsc = $(CMD_LS3_LLSC) $@ CMD_RELOCS = arch/mips/boot/tools/relocs -quiet_cmd_relocs = RELOCS $@ +quiet_cmd_relocs = RELOCS $@ cmd_relocs = $(CMD_RELOCS) $@ # `@true` prevents complaint when there is nothing to be done
Greg Kroah-Hartman
maintainerPATCH 130/367 ovl: fix wrong WARN_ON() in ovl_cache_update_ino()
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
commit 4c37e71b713ecffe81f8e6273c6835e54306d412 upstream.
The WARN_ON() that child entry is always on overlay st_dev became wrong when we allowed this function to update d_ino in non-samefs setup with xino enabled.
It is not true in case of xino bits overflow on a non-dir inode. Leave the WARN_ON() only for directories, where assertion is still true.
--- fs/overlayfs/readdir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/overlayfs/readdir.c +7 -1
@@ -504,7 +504,13 @@ get:if (err) goto fail; -WARN_ON_ONCE (dir->d_sb->s_dev != stat.dev); +/* +* Directory inode is always on overlay st_dev. +* Non-dir with ovl_same_dev() could be on pseudo st_dev in case +* of xino bits overflow. +*/ +WARN_ON_ONCE (S_ISDIR (stat.mode) && + dir->d_sb->s_dev != stat.dev); ino = stat.ino; }else if (xinobits && !OVL_TYPE_UPPER (type)) { ino = ovl_remap_lower_ino(ino, xinobits,
Greg Kroah-Hartman
maintainerPATCH 133/367 f2fs: code cleanup for f2fs_statfs_project()
In reply to Greg Kroah-HartmanFrom: Chengguang Xu <[email protected]>
commit bf2cbd3c57159c2b639ee8797b52ab5af180bf83 upstream.
Calling min_not_zero() to simplify complicated prjquota limit comparison in f2fs_statfs_project().
--- fs/f2fs/super.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
fs/f2fs/super.c +4 -12
@@ -1213,12 +1213,8 @@ static int f2fs_statfs_project(struct sureturn PTR_ERR (dquot);spin_lock (&dquot->dq_dqb_lock); - limit =0 ; -if (dquot->dq_dqb.dqb_bsoftlimit) - limit = dquot->dq_dqb.dqb_bsoftlimit; -if (dquot->dq_dqb.dqb_bhardlimit && - (!limit || dquot->dq_dqb.dqb_bhardlimit < limit)) - limit = dquot->dq_dqb.dqb_bhardlimit; + limit =min_not_zero (dquot->dq_dqb.dqb_bsoftlimit, + dquot->dq_dqb.dqb_bhardlimit);if (limit) limit >>= sb->s_blocksize_bits;
@@ -1230,12 +1226,8 @@ static int f2fs_statfs_project(struct su (buf->f_blocks - curblock) : 0; } - limit =0 ; -if (dquot->dq_dqb.dqb_isoftlimit) - limit = dquot->dq_dqb.dqb_isoftlimit; -if (dquot->dq_dqb.dqb_ihardlimit && - (!limit || dquot->dq_dqb.dqb_ihardlimit < limit)) - limit = dquot->dq_dqb.dqb_ihardlimit; + limit =min_not_zero (dquot->dq_dqb.dqb_isoftlimit, + dquot->dq_dqb.dqb_ihardlimit);if (limit && buf->f_files > limit) { buf->f_files = limit;
Greg Kroah-Hartman
maintainerPATCH 136/367 PM: core: Fix handling of devices deleted during system-wide resume
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 0552e05fdfea191a2cf3a0abd33574b5ef9ca818 upstream.
If a device is deleted by one of its system-wide resume callbacks (for example, because it does not appear to be present or accessible any more) along with its children, the resume of the children may continue leading to use-after-free errors and other issues (potentially).
Namely, if the device's children are resumed asynchronously, their resume may have been scheduled already before the device's callback runs and so the device may be deleted while dpm_wait_for_superior() is being executed for them. The memory taken up by the parent device object may be freed then while dpm_wait() is waiting for the parent's resume callback to complete, which leads to a use-after-free. Moreover, the resume of the children is really not expected to continue after they have been unregistered, so it must be terminated right away in that case.
To address this problem, modify dpm_wait_for_superior() to check if the target device is still there in the system-wide PM list of devices and if so, to increment its parent's reference counter, both under dpm_list_mtx which prevents device_del() running for the child from dropping the parent's reference counter prematurely.
If the device is not present in the system-wide PM list of devices any more, the resume of it cannot continue, so check that again after dpm_wait() returns, which means that the parent's callback has been completed, and pass the result of that check to the caller of dpm_wait_for_superior() to allow it to abort the device's resume if it is not there any more.
--- drivers/base/power/main.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
drivers/base/power/main.c +37 -5
@@ -273,10 +273,38 @@ static void dpm_wait_for_suppliers(strucdevice_links_read_unlock (idx); } -static void dpm_wait_for_superior (struct device *dev,bool async) +static bool dpm_wait_for_superior (struct device *dev,bool async) { -dpm_wait (dev->parent, async); +struct device *parent; + +/* +* If the device is resumed asynchronously and the parent's callback +* deletes both the device and the parent itself, the parent object may +* be freed while this function is running, so avoid that by reference +* counting the parent once more unless the device has been deleted +* already (in which case return right away). +*/ +mutex_lock (&dpm_list_mtx); + +if (!device_pm_initialized (dev)) { +mutex_unlock (&dpm_list_mtx); +return false; + } + + parent =get_device (dev->parent); + +mutex_unlock (&dpm_list_mtx); + +dpm_wait (parent, async); +put_device (parent); +dpm_wait_for_suppliers (dev, async); + +/* +* If the parent's callback has deleted the device, attempting to resume +* it would be invalid, so avoid doing that then. +*/ +return device_pm_initialized (dev); }static void dpm_wait_for_consumers (struct device *dev,bool async)
@@ -621,7 +649,8 @@ static int device_resume_noirq(struct deif (!dev->power.is_noirq_suspended) goto Out; -dpm_wait_for_superior (dev, async); +if (!dpm_wait_for_superior (dev, async)) + goto Out; skip_resume =dev_pm_may_skip_resume (dev);
@@ -829,7 +858,8 @@ static int device_resume_early(struct deif (!dev->power.is_late_suspended) goto Out; -dpm_wait_for_superior (dev, async); +if (!dpm_wait_for_superior (dev, async)) + goto Out; callback =dpm_subsys_resume_early_cb (dev, state, &info);
@@ -944,7 +974,9 @@ static int device_resume(struct device * goto Complete; } -dpm_wait_for_superior (dev, async); +if (!dpm_wait_for_superior (dev, async)) + goto Complete; +dpm_watchdog_set (&wd, dev);device_lock (dev);
Greg Kroah-Hartman
maintainerPATCH 137/367 cpufreq: Avoid creating excessively large stack frames
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 1e4f63aecb53e48468661e922fc2fa3b83e55722 upstream.
In the process of modifying a cpufreq policy, the cpufreq core makes a copy of it including all of the internals which is stored on the CPU stack. Because struct cpufreq_policy is relatively large, this may cause the size of the stack frame to exceed the 2 KB limit and so the GCC complains when -Wframe-larger-than= is used.
In fact, it is not necessary to copy the entire policy structure in order to modify it, however.
First, because cpufreq_set_policy() obtains the min and max policy limits from frequency QoS now, it is not necessary to pass the limits to it from the callers. The only things that need to be passed to it from there are the new governor pointer or (if there is a built-in governor in the driver) the "policy" value representing the governor choice. They both can be passed as individual arguments, though, so make cpufreq_set_policy() take them this way and rework its callers accordingly. This avoids making copies of cpufreq policies in the callers of cpufreq_set_policy().
Second, cpufreq_set_policy() still needs to pass the new policy data to the ->verify() callback of the cpufreq driver whose task is to sanitize the min and max policy limits. It still does not need to make a full copy of struct cpufreq_policy for this purpose, but it needs to pass a few items from it to the driver in case they are needed (different drivers have different needs in that respect and all of them have to be covered). For this reason, introduce struct cpufreq_policy_data to hold copies of the members of struct cpufreq_policy used by the existing ->verify() driver callbacks and pass a pointer to a temporary structure of that type to ->verify() (instead of passing a pointer to full struct cpufreq_policy to it).
While at it, notice that intel_pstate and longrun don't really need to verify the "policy" value in struct cpufreq_policy, so drop those check from them to avoid copying "policy" into struct cpufreq_policy_data (which allows it to be slightly smaller).
Also while at it fix up white space in a couple of places and make cpufreq_set_policy() static (as it can be so).
--- drivers/cpufreq/cppc_cpufreq.c | 2 drivers/cpufreq/cpufreq-nforce2.c | 2 drivers/cpufreq/cpufreq.c | 147 +++++++++++++++++-------------------- drivers/cpufreq/freq_table.c | 4 - drivers/cpufreq/gx-suspmod.c | 2 drivers/cpufreq/intel_pstate.c | 38 ++++----- drivers/cpufreq/longrun.c | 6 - drivers/cpufreq/pcc-cpufreq.c | 2 drivers/cpufreq/sh-cpufreq.c | 2 drivers/cpufreq/unicore2-cpufreq.c | 2 include/linux/cpufreq.h | 32 +++++--- 11 files changed, 119 insertions(+), 120 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +1 -1
@@ -217,7 +217,7 @@ static int cppc_cpufreq_set_target(strucreturn ret; } -static int cppc_verify_policy (struct cpufreq_policy *policy) +static int cppc_verify_policy (struct cpufreq_policy_data *policy) {cpufreq_verify_within_cpu_limits (policy);return 0 ;
drivers/cpufreq/cpufreq-nforce2.c +1 -1
@@ -291,7 +291,7 @@ static int nforce2_target(struct cpufreq* nforce2_verify - verifies a new CPUFreq policy * @policy: new policy */ -static int nforce2_verify (struct cpufreq_policy *policy) +static int nforce2_verify (struct cpufreq_policy_data *policy) {unsigned int fsb_pol_max;
drivers/cpufreq/cpufreq.c +70 -77
266 lines not on this page · raw message
drivers/cpufreq/freq_table.c +2 -2
@@ -60,7 +60,7 @@ int cpufreq_frequency_table_cpuinfo(strureturn 0 ; } -int cpufreq_frequency_table_verify (struct cpufreq_policy *policy, +int cpufreq_frequency_table_verify (struct cpufreq_policy_data *policy,struct cpufreq_frequency_table *table) {struct cpufreq_frequency_table *pos;
@@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_tabl* Generic routine to verify policy & frequency table, requires driver to set * policy->freq_table prior to it. */ -int cpufreq_generic_frequency_table_verify (struct cpufreq_policy *policy) +int cpufreq_generic_frequency_table_verify (struct cpufreq_policy_data *policy) {if (!policy->freq_table)return -ENODEV ;
drivers/cpufreq/gx-suspmod.c +1 -1
@@ -328,7 +328,7 @@ static void gx_set_cpuspeed(struct cpufr* for the hardware supported by the driver. */ -static int cpufreq_gx_verify (struct cpufreq_policy *policy) +static int cpufreq_gx_verify (struct cpufreq_policy_data *policy) {unsigned int tmp_freq =0 ;u8 tmp1, tmp2;
drivers/cpufreq/intel_pstate.c +17 -21
@@ -2036,8 +2036,9 @@ static int intel_pstate_get_max_freq(str cpu->pstate.max_freq : cpu->pstate.turbo_freq; } -static void intel_pstate_update_perf_limits (struct cpufreq_policy *policy, -struct cpudata *cpu) +static void intel_pstate_update_perf_limits (struct cpudata *cpu, +unsigned int policy_min, +unsigned int policy_max) {int max_freq =intel_pstate_get_max_freq (cpu);int32_t max_policy_perf, min_policy_perf;
@@ -2056,18 +2057,17 @@ static void intel_pstate_update_perf_lim turbo_max = cpu->pstate.turbo_pstate; } - max_policy_perf = max_state * policy->max / max_freq; -if (policy->max == policy->min) { + max_policy_perf = max_state * policy_max / max_freq; +if (policy_max == policy_min) { min_policy_perf = max_policy_perf; }else { - min_policy_perf = max_state * policy->min / max_freq; + min_policy_perf = max_state * policy_min / max_freq; min_policy_perf =clamp_t (int32_t, min_policy_perf,0 , max_policy_perf); }pr_debug ("cpu:%d max_state %d min_policy_perf:%d max_policy_perf:%d\n" , - policy->cpu, max_state, - min_policy_perf, max_policy_perf); + cpu->cpu, max_state, min_policy_perf, max_policy_perf);/* Normalize user input to [min_perf, max_perf] */ if (per_cpu_limits) {
@@ -2081,7 +2081,7 @@ static void intel_pstate_update_perf_lim global_min =DIV_ROUND_UP (turbo_max * global.min_perf_pct,100 ); global_min =clamp_t (int32_t, global_min,0 , global_max); -pr_debug ("cpu:%d global_min:%d global_max:%d\n" , policy->cpu, +pr_debug ("cpu:%d global_min:%d global_max:%d\n" , cpu->cpu, global_min, global_max); cpu->min_perf_ratio =max (min_policy_perf, global_min);
@@ -2094,7 +2094,7 @@ static void intel_pstate_update_perf_lim cpu->max_perf_ratio); } -pr_debug ("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n" , policy->cpu, +pr_debug ("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n" , cpu->cpu, cpu->max_perf_ratio, cpu->min_perf_ratio); }
@@ -2114,7 +2114,7 @@ static int intel_pstate_set_policy(strucmutex_lock (&intel_pstate_limits_lock); -intel_pstate_update_perf_limits (policy, cpu); +intel_pstate_update_perf_limits (cpu, policy->min, policy->max);if (cpu->policy ==CPUFREQ_POLICY_PERFORMANCE ) {/*
@@ -2143,8 +2143,8 @@ static int intel_pstate_set_policy(strucreturn 0 ; } -static void intel_pstate_adjust_policy_max (struct cpufreq_policy *policy, -struct cpudata *cpu) +static void intel_pstate_adjust_policy_max (struct cpudata *cpu, +struct cpufreq_policy_data *policy) { if (!hwp_active && cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate &&
@@ -2155,7 +2155,7 @@ static void intel_pstate_adjust_policy_m } } -static int intel_pstate_verify_policy (struct cpufreq_policy *policy) +static int intel_pstate_verify_policy (struct cpufreq_policy_data *policy) {struct cpudata *cpu = all_cpu_data[policy->cpu];
@@ -2163,11 +2163,7 @@ static int intel_pstate_verify_policy(stcpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq,intel_pstate_get_max_freq (cpu)); -if (policy->policy !=CPUFREQ_POLICY_POWERSAVE && - policy->policy !=CPUFREQ_POLICY_PERFORMANCE ) -return -EINVAL ; - -intel_pstate_adjust_policy_max (policy, cpu); +intel_pstate_adjust_policy_max (cpu, policy);return 0 ; }
@@ -2268,7 +2264,7 @@ static struct cpufreq_driver intel_pstat .name = "intel_pstate", }; -static int intel_cpufreq_verify_policy (struct cpufreq_policy *policy) +static int intel_cpufreq_verify_policy (struct cpufreq_policy_data *policy) {struct cpudata *cpu = all_cpu_data[policy->cpu];
@@ -2276,9 +2272,9 @@ static int intel_cpufreq_verify_policy(scpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq,intel_pstate_get_max_freq (cpu)); -intel_pstate_adjust_policy_max (policy, cpu); +intel_pstate_adjust_policy_max (cpu, policy); -intel_pstate_update_perf_limits (policy, cpu); +intel_pstate_update_perf_limits (cpu, policy->min, policy->max);return 0 ; }
drivers/cpufreq/longrun.c +1 -5
@@ -122,7 +122,7 @@ static int longrun_set_policy(struct cpu* Validates a new CPUFreq policy. This function has to be called with * cpufreq_driver locked. */ -static int longrun_verify_policy (struct cpufreq_policy *policy) +static int longrun_verify_policy (struct cpufreq_policy_data *policy) {if (!policy)return -EINVAL ;
@@ -130,10 +130,6 @@ static int longrun_verify_policy(struct policy->cpu =0 ;cpufreq_verify_within_cpu_limits (policy); -if ((policy->policy !=CPUFREQ_POLICY_POWERSAVE ) && - (policy->policy !=CPUFREQ_POLICY_PERFORMANCE )) -return -EINVAL ; -return 0 ; }
drivers/cpufreq/pcc-cpufreq.c +1 -1
@@ -109,7 +109,7 @@ struct pcc_cpu {static struct pcc_cpu __percpu *pcc_cpu_info; -static int pcc_cpufreq_verify (struct cpufreq_policy *policy) +static int pcc_cpufreq_verify (struct cpufreq_policy_data *policy) {cpufreq_verify_within_cpu_limits (policy);return 0 ;
drivers/cpufreq/sh-cpufreq.c +1 -1
@@ -87,7 +87,7 @@ static int sh_cpufreq_target(struct cpufreturn work_on_cpu (policy->cpu, __sh_cpufreq_target, &data); } -static int sh_cpufreq_verify (struct cpufreq_policy *policy) +static int sh_cpufreq_verify (struct cpufreq_policy_data *policy) {struct clk *cpuclk = &per_cpu (sh_cpuclk, policy->cpu);struct cpufreq_frequency_table *freq_table;
drivers/cpufreq/unicore2-cpufreq.c +1 -1
@@ -22,7 +22,7 @@ static struct cpufreq_driver ucv2_driver/* make sure that only the "userspace" governor is run * -- anything else wouldn't make sense on this platform, anyway. */ -static int ucv2_verify_speed (struct cpufreq_policy *policy) +static int ucv2_verify_speed (struct cpufreq_policy_data *policy) {if (policy->cpu)return -EINVAL ;
include/linux/cpufreq.h +23 -9
@@ -148,6 +148,20 @@ struct cpufreq_policy {struct notifier_block nb_max; }; +/* +* Used for passing new cpufreq policy data to the cpufreq driver's ->verify() +* callback for sanitization. That callback is only expected to modify the min +* and max values, if necessary, and specifically it must not update the +* frequency table. +*/ +struct cpufreq_policy_data { +struct cpufreq_cpuinfo cpuinfo; +struct cpufreq_frequency_table *freq_table; +unsigned int cpu; +unsigned int min;/* in kHz */ +unsigned int max;/* in kHz */ +}; +struct cpufreq_freqs {struct cpufreq_policy *policy;unsigned int old;
@@ -201,8 +215,6 @@ u64 get_cpu_idle_time(unsigned int cpu,struct cpufreq_policy *cpufreq_cpu_acquire (unsigned int cpu);void cpufreq_cpu_release (struct cpufreq_policy *policy);int cpufreq_get_policy (struct cpufreq_policy *policy,unsigned int cpu); -int cpufreq_set_policy (struct cpufreq_policy *policy, -struct cpufreq_policy *new_policy);void refresh_frequency_limits (struct cpufreq_policy *policy);void cpufreq_update_policy (unsigned int cpu);void cpufreq_update_limits (unsigned int cpu);
@@ -284,7 +296,7 @@ struct cpufreq_driver {/* needed by all drivers */ int (*init)(struct cpufreq_policy *policy); -int (*verify)(struct cpufreq_policy *policy); +int (*verify)(struct cpufreq_policy_data *policy);/* define one out of two */ int (*setpolicy)(struct cpufreq_policy *policy);
@@ -415,8 +427,9 @@ static inline int cpufreq_thermal_contro (drv->flags &CPUFREQ_IS_COOLING_DEV ); } -static inline void cpufreq_verify_within_limits (struct cpufreq_policy *policy, -unsigned int min,unsigned int max) +static inline void cpufreq_verify_within_limits (struct cpufreq_policy_data *policy, +unsigned int min, +unsigned int max) {if (policy->min < min) policy->min = min;
@@ -432,10 +445,10 @@ static inline void cpufreq_verify_within }static inline void -cpufreq_verify_within_cpu_limits (struct cpufreq_policy *policy) +cpufreq_verify_within_cpu_limits (struct cpufreq_policy_data *policy) {cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); + policy->cpuinfo.max_freq); }#ifdef CONFIG_CPU_FREQ
@@ -513,6 +526,7 @@ static inline unsigned long cpufreq_scal* CPUFREQ GOVERNORS * *********************************************************************/ +#define CPUFREQ_POLICY_UNKNOWN (0)/* * If (cpufreq_driver->target) exists, the ->governor decides what frequency * within the limits is used. If (cpufreq_driver->setpolicy> exists, these
@@ -684,9 +698,9 @@ static inline void dev_pm_opp_free_cpufrint cpufreq_frequency_table_cpuinfo (struct cpufreq_policy *policy,struct cpufreq_frequency_table *table); -int cpufreq_frequency_table_verify (struct cpufreq_policy *policy, +int cpufreq_frequency_table_verify (struct cpufreq_policy_data *policy,struct cpufreq_frequency_table *table); -int cpufreq_generic_frequency_table_verify (struct cpufreq_policy *policy); +int cpufreq_generic_frequency_table_verify (struct cpufreq_policy_data *policy); int cpufreq_table_index_unsorted(struct cpufreq_policy *policy, unsigned int target_freq,
Greg Kroah-Hartman
maintainerPATCH 141/367 dm space map common: fix to ensure new block isnt already in use
In reply to Greg Kroah-HartmanFrom: Joe Thornber <[email protected]>
commit 4feaef830de7ffdd8352e1fe14ad3bf13c9688f8 upstream.
The space-maps track the reference counts for disk blocks allocated by both the thin-provisioning and cache targets. There are variants for tracking metadata blocks and data blocks.
Transactionality is implemented by never touching blocks from the previous transaction, so we can rollback in the event of a crash.
When allocating a new block we need to ensure the block is free (has reference count of 0) in both the current and previous transaction. Prior to this fix we were doing this by searching for a free block in the previous transaction, and relying on a 'begin' counter to track where the last allocation in the current transaction was. This 'begin' field was not being updated in all code paths (eg, increment of a data block reference count due to breaking sharing of a neighbour block in the same btree leaf).
This fix keeps the 'begin' field, but now it's just a hint to speed up the search. Instead the current transaction is searched for a free block, and then the old transaction is double checked to ensure it's free. Much simpler.
This fixes reports of sm_disk_new_block()'s BUG_ON() triggering when DM thin-provisioning's snapshots are heavily used.
--- drivers/md/persistent-data/dm-space-map-common.c | 27 +++++++++++++++++++++ drivers/md/persistent-data/dm-space-map-common.h | 2 + drivers/md/persistent-data/dm-space-map-disk.c | 6 +++- drivers/md/persistent-data/dm-space-map-metadata.c | 5 +++ 4 files changed, 37 insertions(+), 3 deletions(-)
drivers/md/persistent-data/dm-space-map-common.c +27 -0
@@ -380,6 +380,33 @@ int sm_ll_find_free_block(struct ll_diskreturn -ENOSPC ; } +int sm_ll_find_common_free_block (struct ll_disk *old_ll,struct ll_disk *new_ll, +dm_block_t begin,dm_block_t end,dm_block_t *b) +{ +int r; +uint32_t count; + +do { + r =sm_ll_find_free_block (new_ll, begin, new_ll->nr_blocks, b); +if (r) +break ; + +/* double check this block wasn't used in the old transaction */ +if (*b >= old_ll->nr_blocks) + count =0 ; +else { + r =sm_ll_lookup (old_ll, *b, &count); +if (r) +break ; + +if (count) + begin = *b +1 ; + } + }while (count); + +return r; +} +static int sm_ll_mutate (struct ll_disk *ll,dm_block_t b,int (*mutator)(void *context,uint32_t old,uint32_t *new),void *context,enum allocation_event *ev)
drivers/md/persistent-data/dm-space-map-common.h +2 -0
@@ -109,6 +109,8 @@ int sm_ll_lookup_bitmap(struct ll_disk *int sm_ll_lookup (struct ll_disk *ll,dm_block_t b,uint32_t *result);int sm_ll_find_free_block (struct ll_disk *ll,dm_block_t begin,dm_block_t end,dm_block_t *result); +int sm_ll_find_common_free_block (struct ll_disk *old_ll,struct ll_disk *new_ll, +dm_block_t begin,dm_block_t end,dm_block_t *result);int sm_ll_insert (struct ll_disk *ll,dm_block_t b,uint32_t ref_count,enum allocation_event *ev);int sm_ll_inc (struct ll_disk *ll,dm_block_t b,enum allocation_event *ev);int sm_ll_dec (struct ll_disk *ll,dm_block_t b,enum allocation_event *ev);
drivers/md/persistent-data/dm-space-map-disk.c +4 -2
@@ -167,8 +167,10 @@ static int sm_disk_new_block(struct dm_senum allocation_event ev; struct sm_disk *smd = container_of(sm, struct sm_disk, sm); -/* FIXME: we should loop round a couple of times */ - r =sm_ll_find_free_block (&smd->old_ll, smd->begin, smd->old_ll.nr_blocks, b); +/* +* Any block we allocate has to be free in both the old and current ll. +*/ + r =sm_ll_find_common_free_block (&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b);if (r)return r;
drivers/md/persistent-data/dm-space-map-metadata.c +4 -1
@@ -448,7 +448,10 @@ static int sm_metadata_new_block_(structenum allocation_event ev; struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); - r =sm_ll_find_free_block (&smm->old_ll, smm->begin, smm->old_ll.nr_blocks, b); +/* +* Any block we allocate has to be free in both the old and current ll. +*/ + r =sm_ll_find_common_free_block (&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);if (r)return r;
Greg Kroah-Hartman
maintainerPATCH 152/367 ftrace: Add comment to why rcu_dereference_sched() is open coded
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit 16052dd5bdfa16dbe18d8c1d4cde2ddab9d23177 ]
Because the function graph tracer can execute in sections where RCU is not "watching", the rcu_dereference_sched() for the has needs to be open coded. This is fine because the RCU "flavor" of the ftrace hash is protected by its own RCU handling (it does its own little synchronization on every CPU and does not rely on RCU sched).
--- kernel/trace/trace.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/trace/trace.h +10 -0
@@ -961,6 +961,11 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)preempt_disable_notrace (); +/* +* Have to open code "rcu_dereference_sched()" because the +* function graph tracer can be called when RCU is not +* "watching". +*/ hash =rcu_dereference_protected (ftrace_graph_hash, !preemptible ());if (ftrace_hash_empty (hash)) {
@@ -1008,6 +1013,11 @@ static inline int ftrace_graph_notrace_addr(unsigned long addr)preempt_disable_notrace (); +/* +* Have to open code "rcu_dereference_sched()" because the +* function graph tracer can be called when RCU is not +* "watching". +*/ notrace_hash =rcu_dereference_protected (ftrace_graph_notrace_hash, !preemptible ());
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 120/367 padata: Remove broken queue flushing
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 07928d9bfc81640bab36f5190e8725894d93b659 upstream.
The function padata_flush_queues is fundamentally broken because it cannot force padata users to complete the request that is underway. IOW padata has to passively wait for the completion of any outstanding work.
As it stands flushing is used in two places. Its use in padata_stop is simply unnecessary because nothing depends on the queues to be flushed afterwards.
The other use in padata_replace is more substantial as we depend on it to free the old pd structure. This patch instead uses the pd->refcnt to dynamically free the pd structure once all requests are complete.
--- kernel/padata.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-)
kernel/padata.c +12 -31
@@ -35,6 +35,8 @@#define MAX_OBJ_NUM 1000 +static void padata_free_pd (struct parallel_data *pd); +static int padata_index_to_cpu (struct parallel_data *pd,int cpu_index) {int cpu, target_cpu;
@@ -283,6 +285,7 @@ static void padata_serial_worker(structstruct padata_serial_queue *squeue;struct parallel_data *pd;LIST_HEAD (local_list); +int cnt;local_bh_disable (); squeue = container_of(serial_work, struct padata_serial_queue, work);
@@ -292,6 +295,8 @@ static void padata_serial_worker(structlist_replace_init (&squeue->serial.list, &local_list);spin_unlock (&squeue->serial.lock); + cnt =0 ; +while (!list_empty (&local_list)) {struct padata_priv *padata;
@@ -301,9 +306,12 @@ static void padata_serial_worker(structlist_del_init (&padata->list); padata->serial (padata); -atomic_dec (&pd->refcnt); + cnt++; }local_bh_enable (); + +if (atomic_sub_and_test (cnt, &pd->refcnt)) +padata_free_pd (pd); }/**
@@ -440,7 +448,7 @@ static struct parallel_data *padata_allopadata_init_squeues (pd);atomic_set (&pd->seq_nr,-1 );atomic_set (&pd->reorder_objects,0 ); -atomic_set (&pd->refcnt,0 ); +atomic_set (&pd->refcnt,1 );spin_lock_init (&pd->lock); pd->cpu =cpumask_first (pd->cpumask.pcpu);INIT_WORK (&pd->reorder_work, invoke_padata_reorder);
@@ -466,29 +474,6 @@ static void padata_free_pd(struct parallkfree (pd); } -/* Flush all objects out of the padata queues. */ -static void padata_flush_queues (struct parallel_data *pd) -{ -int cpu; -struct padata_parallel_queue *pqueue; -struct padata_serial_queue *squeue; - -for_each_cpu (cpu, pd->cpumask.pcpu) { - pqueue =per_cpu_ptr (pd->pqueue, cpu); -flush_work (&pqueue->work); - } - -if (atomic_read (&pd->reorder_objects)) -padata_reorder (pd); - -for_each_cpu (cpu, pd->cpumask.cbcpu) { - squeue =per_cpu_ptr (pd->squeue, cpu); -flush_work (&squeue->work); - } - -BUG_ON (atomic_read (&pd->refcnt) !=0 ); -} -static void __padata_start (struct padata_instance *pinst) { pinst->flags |=PADATA_INIT ;
@@ -502,10 +487,6 @@ static void __padata_stop(struct padata_ pinst->flags &= ~PADATA_INIT ;synchronize_rcu (); - -get_online_cpus (); -padata_flush_queues (pinst->pd); -put_online_cpus (); }/* Replace the internal control structure with a new one. */
@@ -526,8 +507,8 @@ static void padata_replace(struct padataif (!cpumask_equal (pd_old->cpumask.cbcpu, pd_new->cpumask.cbcpu)) notification_mask |=PADATA_CPU_SERIAL ; -padata_flush_queues (pd_old); -padata_free_pd (pd_old); +if (atomic_dec_and_test (&pd_old->refcnt)) +padata_free_pd (pd_old);if (notification_mask) blocking_notifier_call_chain(&pinst->cpumask_change_notifier,
Greg Kroah-Hartman
maintainerPATCH 119/367 crypto: ccree - fix PM race condition
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit 15fd2566bf54ee4d4781d8f170acfc9472a1541f upstream.
The PM code was racy, possibly causing the driver to submit requests to a powered down device. Fix the race and while at it simplify the PM code.
--- drivers/crypto/ccree/cc_driver.h | 1 drivers/crypto/ccree/cc_pm.c | 28 ++++--------------- drivers/crypto/ccree/cc_request_mgr.c | 50 ---------------------------------- drivers/crypto/ccree/cc_request_mgr.h | 8 ----- 4 files changed, 7 insertions(+), 80 deletions(-)
drivers/crypto/ccree/cc_driver.h +1 -0
@@ -161,6 +161,7 @@ struct cc_drvdata {int std_bodies;bool sec_disabled;u32 comp_mask; +bool pm_on; };struct cc_crypto_alg {
drivers/crypto/ccree/cc_pm.c +6 -22
@@ -22,14 +22,8 @@ const struct dev_pm_ops ccree_pm = {int cc_pm_suspend (struct device *dev) {struct cc_drvdata *drvdata =dev_get_drvdata (dev); -int rc;dev_dbg (dev,"set HOST_POWER_DOWN_EN\n" ); - rc =cc_suspend_req_queue (drvdata); -if (rc) { -dev_err (dev,"cc_suspend_req_queue (%x)\n" , rc); -return rc; - }fini_cc_regs (drvdata);cc_iowrite (drvdata,CC_REG (HOST_POWER_DOWN_EN ),POWER_DOWN_ENABLE );cc_clk_off (drvdata);
@@ -63,13 +57,6 @@ int cc_pm_resume(struct device *dev)/* check if tee fips error occurred during power down */ cc_tee_handle_fips_error (drvdata); - rc =cc_resume_req_queue (drvdata); -if (rc) { -dev_err (dev,"cc_resume_req_queue (%x)\n" , rc); -return rc; - } - -/* must be after the queue resuming as it uses the HW queue*/ cc_init_hash_sram (drvdata);return 0 ;
@@ -80,10 +67,8 @@ int cc_pm_get(struct device *dev)int rc =0 ;struct cc_drvdata *drvdata =dev_get_drvdata (dev); -if (cc_req_queue_suspended (drvdata)) +if (drvdata->pm_on) rc =pm_runtime_get_sync (dev); -else -pm_runtime_get_noresume (dev);return (rc ==1 ?0 : rc); }
@@ -93,14 +78,11 @@ int cc_pm_put_suspend(struct device *devint rc =0 ;struct cc_drvdata *drvdata =dev_get_drvdata (dev); -if (!cc_req_queue_suspended (drvdata)) { +if (drvdata->pm_on) {pm_runtime_mark_last_busy (dev); rc =pm_runtime_put_autosuspend (dev); - }else { -/* Something wrong happens*/ -dev_err (dev,"request to suspend already suspended queue" ); - rc = -EBUSY ; } +return rc; }
@@ -117,7 +99,7 @@ int cc_pm_init(struct cc_drvdata *drvdat/* must be before the enabling to avoid resdundent suspending */ pm_runtime_set_autosuspend_delay (dev,CC_SUSPEND_TIMEOUT );pm_runtime_use_autosuspend (dev); -/* activate the PM module */ +/* set us as active - note we won't do PM ops until cc_pm_go()! */ return pm_runtime_set_active (dev); }
@@ -125,9 +107,11 @@ int cc_pm_init(struct cc_drvdata *drvdatvoid cc_pm_go (struct cc_drvdata *drvdata) {pm_runtime_enable (drvdata_to_dev (drvdata)); + drvdata->pm_on = true; }void cc_pm_fini (struct cc_drvdata *drvdata) {pm_runtime_disable (drvdata_to_dev (drvdata)); + drvdata->pm_on = false; }
drivers/crypto/ccree/cc_request_mgr.c +0 -50
59 lines not on this page · raw message
drivers/crypto/ccree/cc_request_mgr.h +0 -8
@@ -40,12 +40,4 @@ void complete_request(struct cc_drvdatavoid cc_req_mgr_fini (struct cc_drvdata *drvdata); -#if defined(CONFIG_PM ) -int cc_resume_req_queue (struct cc_drvdata *drvdata); - -int cc_suspend_req_queue (struct cc_drvdata *drvdata); - -bool cc_req_queue_suspended (struct cc_drvdata *drvdata); -#endif -#endif /*__REQUEST_MGR_H__*/
Greg Kroah-Hartman
maintainerPATCH 121/367 fs: allow deduplication of eof block into the end of the destination file
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit a5e6ea18e3d132be4716eb5fdd520c2c234e3003 upstream.
We always round down, to a multiple of the filesystem's block size, the length to deduplicate at generic_remap_check_len(). However this is only needed if an attempt to deduplicate the last block into the middle of the destination file is requested, since that leads into a corruption if the length of the source file is not block size aligned. When an attempt to deduplicate the last block into the end of the destination file is requested, we should allow it because it is safe to do it - there's no stale data exposure and we are prepared to compare the data ranges for a length not aligned to the block (or page) size - in fact we even do the data compare before adjusting the deduplication length.
After btrfs was updated to use the generic helpers from VFS (by commit 34a28e3d77535e ("Btrfs: use generic_remap_file_range_prep() for cloning and deduplication")) we started to have user reports of deduplication not reflinking the last block anymore, and whence users getting lower deduplication scores. The main use case is deduplication of entire files that have a size not aligned to the block size of the filesystem.
We already allow cloning the last block to the end (and beyond) of the destination file, so allow for deduplication as well.
--- fs/read_write.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/read_write.c +4 -6
@@ -1777,10 +1777,9 @@ static int remap_verify_area(struct file* else. Assume that the offsets have already been checked for block * alignment. * -* For deduplication we always scale down to the previous block because we -* can't meaningfully compare post-EOF contents. -* -* For clone we only link a partial EOF block above the destination file's EOF. +* For clone we only link a partial EOF block above or at the destination file's +* EOF. For deduplication we accept a partial EOF block only if it ends at the +* destination file's EOF (can not link it into the middle of a file). * * Shorten the request if possible. */
@@ -1796,8 +1795,7 @@ static int generic_remap_check_len(strucif ((*len & blkmask) ==0 )return 0 ; -if ((remap_flags &REMAP_FILE_DEDUP ) || - pos_out + *len <i_size_read (inode_out)) +if (pos_out + *len <i_size_read (inode_out)) new_len &= ~blkmask;if (new_len == *len)
Greg Kroah-Hartman
maintainerPATCH 159/367 libbpf: Fix printf compilation warnings on ppc64le arch
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
commit 679152d3a32e305c213f83160c328c37566ae8bc upstream.
On ppc64le __u64 and __s64 are defined as long int and unsigned long int, respectively. This causes compiler to emit warning when %lld/%llu are used to printf 64-bit numbers. Fix this by casting to size_t/ssize_t with %zu and %zd format specifiers, respectively.
v1->v2:
- use size_t/ssize_t instead of custom typedefs (Martin).
--- tools/lib/bpf/libbpf.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-)
tools/lib/bpf/libbpf.c +19 -18
@@ -1242,15 +1242,15 @@ static int bpf_object__init_user_btf_map } sz =btf__resolve_size (obj->btf, t->type);if (sz <0 ) { -pr_warn ("map '%s': can't determine key size for type [%u]: %lld.\n" , - map_name, t->type, sz); +pr_warn ("map '%s': can't determine key size for type [%u]: %zd.\n" , + map_name, t->type, (ssize_t )sz);return sz; } -pr_debug ("map '%s': found key [%u], sz = %lld.\n" , - map_name, t->type, sz); +pr_debug ("map '%s': found key [%u], sz = %zd.\n" , + map_name, t->type, (ssize_t )sz);if (map->def.key_size && map->def.key_size != sz) { -pr_warn ("map '%s': conflicting key size %u != %lld.\n" , - map_name, map->def.key_size, sz); +pr_warn ("map '%s': conflicting key size %u != %zd.\n" , + map_name, map->def.key_size, (ssize_t )sz);return -EINVAL ; } map->def.key_size = sz;
@@ -1285,15 +1285,15 @@ static int bpf_object__init_user_btf_map } sz =btf__resolve_size (obj->btf, t->type);if (sz <0 ) { -pr_warn ("map '%s': can't determine value size for type [%u]: %lld.\n" , - map_name, t->type, sz); +pr_warn ("map '%s': can't determine value size for type [%u]: %zd.\n" , + map_name, t->type, (ssize_t )sz);return sz; } -pr_debug ("map '%s': found value [%u], sz = %lld.\n" , - map_name, t->type, sz); +pr_debug ("map '%s': found value [%u], sz = %zd.\n" , + map_name, t->type, (ssize_t )sz);if (map->def.value_size && map->def.value_size != sz) { -pr_warn ("map '%s': conflicting value size %u != %lld.\n" , - map_name, map->def.value_size, sz); +pr_warn ("map '%s': conflicting value size %u != %zd.\n" , + map_name, map->def.value_size, (ssize_t )sz);return -EINVAL ; } map->def.value_size = sz;
@@ -1817,7 +1817,8 @@ static int bpf_program__record_reloc(strreturn -LIBBPF_ERRNO__RELOC ; }if (sym->st_value %8 ) { -pr_warn ("bad call relo offset: %llu\n" , (__u64 )sym->st_value); +pr_warn ("bad call relo offset: %zu\n" , + (size_t )sym->st_value);return -LIBBPF_ERRNO__RELOC ; } reloc_desc->type =RELO_CALL ;
@@ -1859,8 +1860,8 @@ static int bpf_program__record_reloc(strbreak ; }if (map_idx >= nr_maps) { -pr_warn ("map relo failed to find map for sec %u, off %llu\n" , - shdr_idx, (__u64 )sym->st_value); +pr_warn ("map relo failed to find map for sec %u, off %zu\n" , + shdr_idx, (size_t )sym->st_value);return -LIBBPF_ERRNO__RELOC ; } reloc_desc->type =RELO_LD64 ;
@@ -1941,9 +1942,9 @@ bpf_program__collect_reloc(struct bpf_pr name =elf_strptr (obj->efile.elf, obj->efile.strtabidx, sym.st_name) ? :"<?>" ; -pr_debug ("relo for shdr %u, symb %llu, value %llu, type %d, bind %d, name %d (\'%s\'), insn %u\n" , - (__u32 )sym.st_shndx, (__u64 )GELF_R_SYM (rel.r_info), - (__u64 )sym.st_value,GELF_ST_TYPE (sym.st_info), +pr_debug ("relo for shdr %u, symb %zu, value %zu, type %d, bind %d, name %d (\'%s\'), insn %u\n" , + (__u32 )sym.st_shndx, (size_t )GELF_R_SYM (rel.r_info), + (size_t )sym.st_value,GELF_ST_TYPE (sym.st_info),GELF_ST_BIND (sym.st_info), sym.st_name, name, insn_idx);
Greg Kroah-Hartman
maintainerPATCH 171/367 selftests/bpf: Skip perf hw events test if the setup disabled it
In reply to Greg Kroah-HartmanFrom: Hangbin Liu <[email protected]>
commit f1c3656c6d9c147d07d16614455aceb34932bdeb upstream.
The same with commit 4e59afbbed96 ("selftests/bpf: skip nmi test when perf hw events are disabled"), it would make more sense to skip the test_stacktrace_build_id_nmi test if the setup (e.g. virtual machines) has disabled hardware perf events.
--- tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c +6 -2
@@ -49,8 +49,12 @@ retry: pmu_fd =syscall (__NR_perf_event_open, &attr,-1 /* pid */ ,0 /* cpu 0 */ ,-1 /* group id */ ,0 /* flags */ ); -if (CHECK (pmu_fd <0 ,"perf_event_open" , -"err %d errno %d. Does the test host support PERF_COUNT_HW_CPU_CYCLES?\n" , +if (pmu_fd <0 && errno ==ENOENT ) { +printf ("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n" , __func__); +test__skip (); + goto cleanup; + } +if (CHECK (pmu_fd <0 ,"perf_event_open" ,"err %d errno %d\n" , pmu_fd, errno)) goto close_prog;
Greg Kroah-Hartman
maintainerPATCH 178/367 crypto: hisilicon - Fix issue with wrong number of sg elements after dma map
In reply to Greg Kroah-HartmanFrom: Jonathan Cameron <[email protected]>
commit 8debacd60c69beab80736d4af4feca47c2e2bd9e upstream.
We fill the hardware scatter gather list assuming it will need the same number of elements at the original scatterlist. If an IOMMU is involved, then it may well need fewer. The return value of dma_map_sg tells us how many.
Probably never caused visible problems as the hardware won't get to the elements that are incorrect before it finds enough space.
--- drivers/crypto/hisilicon/sgl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/crypto/hisilicon/sgl.c +8 -5
@@ -202,18 +202,21 @@ hisi_acc_sg_buf_map_to_hw_sgl(struct devdma_addr_t curr_sgl_dma =0 ;struct acc_hw_sge *curr_hw_sge;struct scatterlist *sg; -int i, ret, sg_n; +int i, sg_n, sg_n_mapped;if (!dev || !sgl || !pool || !hw_sgl_dma)return ERR_PTR (-EINVAL ); sg_n =sg_nents (sgl); -if (sg_n > pool->sge_nr) + + sg_n_mapped =dma_map_sg (dev, sgl, sg_n,DMA_BIDIRECTIONAL ); +if (!sg_n_mapped)return ERR_PTR (-EINVAL ); - ret =dma_map_sg (dev, sgl, sg_n,DMA_BIDIRECTIONAL ); -if (!ret) +if (sg_n_mapped > pool->sge_nr) { +dma_unmap_sg (dev, sgl, sg_n,DMA_BIDIRECTIONAL );return ERR_PTR (-EINVAL ); + } curr_hw_sgl =acc_get_sgl (pool, index, &curr_sgl_dma);if (IS_ERR (curr_hw_sgl)) {
@@ -224,7 +227,7 @@ hisi_acc_sg_buf_map_to_hw_sgl(struct dev curr_hw_sgl->entry_length_in_sgl =cpu_to_le16 (pool->sge_nr); curr_hw_sge = curr_hw_sgl->sge_entries; -for_each_sg (sgl, sg, sg_n, i) { +for_each_sg (sgl, sg, sg_n_mapped, i) {sg_map_to_hw_sg (sg, curr_hw_sge);inc_hw_sgl_sge (curr_hw_sgl); curr_hw_sge++;
Greg Kroah-Hartman
maintainerPATCH 184/367 crypto: atmel-aes - Fix counter overflow in CTR mode
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit 781a08d9740afa73357f1a60d45d7c93d7cca2dd upstream.
32 bit counter is not supported by neither of our AES IPs, all implement a 16 bit block counter. Drop the 32 bit block counter logic.
--- drivers/crypto/atmel-aes.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-)
drivers/crypto/atmel-aes.c +12 -25
@@ -89,7 +89,6 @@struct atmel_aes_caps {bool has_dualbuff;bool has_cfb64; -bool has_ctr32;bool has_gcm;bool has_xts;bool has_authenc;
@@ -1015,8 +1014,9 @@ static int atmel_aes_ctr_transfer(structstruct atmel_aes_ctr_ctx *ctx =atmel_aes_ctr_ctx_cast (dd->ctx);struct skcipher_request *req =skcipher_request_cast (dd->areq);struct scatterlist *src, *dst; -u32 ctr, blocks;size_t datalen; +u32 ctr; +u16 blocks, start, end;bool use_dma, fragmented = false;/* Check for transfer completion. */
@@ -1028,27 +1028,17 @@ static int atmel_aes_ctr_transfer(struct datalen = req->cryptlen - ctx->offset; blocks =DIV_ROUND_UP (datalen,AES_BLOCK_SIZE ); ctr =be32_to_cpu (ctx->iv[3 ]); -if (dd->caps.has_ctr32) { -/* Check 32bit counter overflow. */ -u32 start = ctr; -u32 end = start + blocks -1 ; - -if (end < start) { - ctr |=0xffffffff ; - datalen =AES_BLOCK_SIZE * -start; - fragmented = true; - } - }else { -/* Check 16bit counter overflow. */ -u16 start = ctr &0xffff ; -u16 end = start + (u16 )blocks -1 ; - -if (blocks >>16 || end < start) { - ctr |=0xffff ; - datalen =AES_BLOCK_SIZE * (0x10000 -start); - fragmented = true; - } + +/* Check 16bit counter overflow. */ + start = ctr &0xffff ; + end = start + blocks -1 ; + +if (blocks >>16 || end < start) { + ctr |=0xffff ; + datalen =AES_BLOCK_SIZE * (0x10000 - start); + fragmented = true; } + use_dma = (datalen >=ATMEL_AES_DMA_THRESHOLD );/* Jump to offset. */
@@ -2533,7 +2523,6 @@ static void atmel_aes_get_cap(struct atm { dd->caps.has_dualbuff =0 ; dd->caps.has_cfb64 =0 ; - dd->caps.has_ctr32 =0 ; dd->caps.has_gcm =0 ; dd->caps.has_xts =0 ; dd->caps.has_authenc =0 ;
@@ -2544,7 +2533,6 @@ static void atmel_aes_get_cap(struct atmcase 0x500 : dd->caps.has_dualbuff =1 ; dd->caps.has_cfb64 =1 ; - dd->caps.has_ctr32 =1 ; dd->caps.has_gcm =1 ; dd->caps.has_xts =1 ; dd->caps.has_authenc =1 ;
@@ -2553,7 +2541,6 @@ static void atmel_aes_get_cap(struct atmcase 0x200 : dd->caps.has_dualbuff =1 ; dd->caps.has_cfb64 =1 ; - dd->caps.has_ctr32 =1 ; dd->caps.has_gcm =1 ; dd->caps.max_burst_size =4 ;break ;
Greg Kroah-Hartman
maintainerPATCH 186/367 crypto: picoxcell - adjust the position of tasklet_init and fix missed tasklet_kill
In reply to Greg Kroah-HartmanFrom: Chuhong Yuan <[email protected]>
commit 7f8c36fe9be46862c4f3c5302f769378028a34fa upstream.
Since tasklet is needed to be initialized before registering IRQ handler, adjust the position of tasklet_init to fix the wrong order.
Besides, to fix the missed tasklet_kill, this patch adds a helper function and uses devm_add_action to kill the tasklet automatically.
--- drivers/crypto/picoxcell_crypto.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/crypto/picoxcell_crypto.c +13 -2
@@ -1595,6 +1595,11 @@ static const struct of_device_id spacc_oMODULE_DEVICE_TABLE (of, spacc_of_id_table);#endif /* CONFIG_OF */ +static void spacc_tasklet_kill (void *data) +{ +tasklet_kill (data); +} +static int spacc_probe (struct platform_device *pdev) {int i, err, ret;
@@ -1637,6 +1642,14 @@ static int spacc_probe(struct platform_dreturn -ENXIO ; } +tasklet_init (&engine->complete, spacc_spacc_complete, + (unsigned long )engine); + + ret =devm_add_action (&pdev->dev, spacc_tasklet_kill, + &engine->complete); +if (ret) +return ret; +if (devm_request_irq (&pdev->dev, irq->start, spacc_spacc_irq,0 , engine->name, engine)) {dev_err (engine->dev,"failed to request IRQ\n" );
@@ -1694,8 +1707,6 @@ static int spacc_probe(struct platform_dINIT_LIST_HEAD (&engine->completed);INIT_LIST_HEAD (&engine->in_progress); engine->in_flight =0 ; -tasklet_init (&engine->complete, spacc_spacc_complete, - (unsigned long )engine);platform_set_drvdata (pdev, engine);
Greg Kroah-Hartman
maintainerPATCH 166/367 tc-testing: fix eBPF tests failure on linux fresh clones
In reply to Greg Kroah-HartmanFrom: Davide Caratti <[email protected]>
commit 7145fcfffef1fad4266aaf5ca96727696916edb7 upstream.
when the following command is done on a fresh clone of the kernel tree,
[root@f31 tc-testing]# ./tdc.py -c bpf
test cases that need to build the eBPF sample program fail systematically, because 'buildebpfPlugin' is unable to install the kernel headers (i.e, the 'khdr' target fails). Pass the correct environment to 'make', in place of ENVIR, to allow running these tests.
--- tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py +1 -1
@@ -54,7 +54,7 @@ class SubPlugin(TdcPlugin): shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=ENVIR) + env=os.environ.copy()) (rawout, serr) = proc.communicate() if proc.returncode != 0 and len(serr) > 0:
Greg Kroah-Hartman
maintainerPATCH 167/367 samples/bpf: Dont try to remove users homedir on clean
In reply to Greg Kroah-HartmanFrom: Toke Høiland-Jørgensen <[email protected]>
commit b2e5e93ae8af6a34bca536cdc4b453ab1e707b8b upstream.
The 'clean' rule in the samples/bpf Makefile tries to remove backup files (ending in ~). However, if no such files exist, it will instead try to remove the user's home directory. While the attempt is mostly harmless, it does lead to a somewhat scary warning like this:
rm: cannot remove '~': Is a directory
Fix this by using find instead of shell expansion to locate any actual backup files that need to be removed.
--- samples/bpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/bpf/Makefile +1 -1
@@ -251,7 +251,7 @@ all: clean: $(MAKE) -C ../../ M=$(CURDIR) clean - @rm -f *~ + @find $(CURDIR) -type f -name '*~' -delete $(LIBBPF): FORCE # Fix up variables inherited from Kbuild that tools/ build system won't like
Greg Kroah-Hartman
maintainerPATCH 214/367 drm: atmel-hlcdc: prefer a lower pixel-clock than requested
In reply to Greg Kroah-HartmanFrom: Peter Rosin <[email protected]>
commit 51a19d150b520f6cb42143f3bdffacd3c33d7ac5 upstream.
The intention was to only select a higher pixel-clock rate than the requested, if a slight overclocking would result in a rate significantly closer to the requested rate than if the conservative lower pixel-clock rate is selected. The fixed patch has the logic the other way around and actually prefers the higher frequency. Fix that.
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +2 -2
@@ -121,8 +121,8 @@ static void atmel_hlcdc_crtc_mode_set_noint div_low = prate / mode_rate;if (div_low >=2 && - ((prate / div_low - mode_rate) < -10 * (mode_rate - prate / div))) + (10 * (prate / div_low - mode_rate) < + (mode_rate - prate / div)))/* * At least 10 times better when using a higher * frequency than requested, instead of a lower.
Greg Kroah-Hartman
maintainerPATCH 217/367 media: rc: ensure lirc is initialized before registering input device
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 080d89f522e2baddb4fbbd1af4b67b5f92537ef8 upstream.
Once rc_open is called on the input device, lirc events can be delivered. Ensure lirc is ready to do so else we might get this:
Registered IR keymap rc-hauppauge
rc rc0: Hauppauge WinTV PVR-350 as /devices/pci0000:00/0000:00:1e.0/0000:04:00.0/i2c-0/0-0018/rc/rc0
input: Hauppauge WinTV PVR-350 as /devices/pci0000:00/0000:00:1e.0/0000:04:00.0/i2c-0/0-0018/rc/rc0/input9
BUG: kernel NULL pointer dereference, address: 0000000000000038 PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.3.11-300.fc31.x86_64 #1 Hardware name: /DG43NB, BIOS NBG4310H.86A.0096.2009.0903.1845 09/03/2009 Workqueue: events ir_work [ir_kbd_i2c] RIP: 0010:ir_lirc_scancode_event+0x3d/0xb0 Code: a6 b4 07 00 00 49 81 c6 b8 07 00 00 55 53 e8 ba a7 9d ff 4c 89 e7 49 89 45 00 e8 5e 7a 25 00 49 8b 1e 48 89 c5 4c 39 f3 74 58 <8b> 43 38 8b 53 40 89 c1 2b 4b 3c 39 ca 72 41 21 d0 49 8b 7d 00 49 RSP: 0018:ffffaae2000b3d88 EFLAGS: 00010017 RAX: 0000000000000002 RBX: 0000000000000000 RCX: 0000000000000019 RDX: 0000000000000001 RSI: 006e801b1f26ce6a RDI: ffff9e39797c37b4 RBP: 0000000000000002 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000001 R12: ffff9e39797c37b4 R13: ffffaae2000b3db8 R14: ffff9e39797c37b8 R15: ffff9e39797c33d8 FS: 0000000000000000(0000) GS:ffff9e397b680000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000038 CR3: 0000000035844000 CR4: 00000000000006e0 Call Trace: ir_do_keydown+0x8e/0x2b0 rc_keydown+0x52/0xc0 ir_work+0xb8/0x130 [ir_kbd_i2c] process_one_work+0x19d/0x340 worker_thread+0x50/0x3b0 kthread+0xfb/0x130 ? process_one_work+0x340/0x340 ? kthread_park+0x80/0x80 ret_from_fork+0x35/0x40 Modules linked in: rc_hauppauge tuner msp3400 saa7127 saa7115 ivtv(+)
tveeprom cx2341x v4l2_common videodev mc i2c_algo_bit ir_kbd_i2c ip_tables firewire_ohci e1000e serio_raw firewire_core ata_generic crc_itu_t pata_acpi pata_jmicron fuse
CR2: 0000000000000038
---[ end trace c67c2697a99fa74b ]--- RIP: 0010:ir_lirc_scancode_event+0x3d/0xb0 Code: a6 b4 07 00 00 49 81 c6 b8 07 00 00 55 53 e8 ba a7 9d ff 4c 89 e7 49 89 45 00 e8 5e 7a 25 00 49 8b 1e 48 89 c5 4c 39 f3 74 58 <8b> 43 38 8b 53 40 89 c1 2b 4b 3c 39 ca 72 41 21 d0 49 8b 7d 00 49 RSP: 0018:ffffaae2000b3d88 EFLAGS: 00010017 RAX: 0000000000000002 RBX: 0000000000000000 RCX: 0000000000000019 RDX: 0000000000000001 RSI: 006e801b1f26ce6a RDI: ffff9e39797c37b4 RBP: 0000000000000002 R08: 0000000000000001 R09: 0000000000000001 R10: 0000000000000001 R11: 0000000000000001 R12: ffff9e39797c37b4 R13: ffffaae2000b3db8 R14: ffff9e39797c37b8 R15: ffff9e39797c33d8 FS: 0000000000000000(0000) GS:ffff9e397b680000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000038 CR3: 0000000035844000 CR4: 00000000000006e0 rc rc0: lirc_dev: driver ir_kbd_i2c registered at minor = 0, scancode
receiver, no transmitter
tuner-simple 0-0061: creating new instance
tuner-simple 0-0061: type set to 2 (Philips NTSC (FI1236,FM1236 and compatibles))
ivtv0: Registered device video0 for encoder MPG (4096 kB)
ivtv0: Registered device video32 for encoder YUV (2048 kB)
ivtv0: Registered device vbi0 for encoder VBI (1024 kB)
ivtv0: Registered device video24 for encoder PCM (320 kB)
ivtv0: Registered device radio0 for encoder radio
ivtv0: Registered device video16 for decoder MPG (1024 kB)
ivtv0: Registered device vbi8 for decoder VBI (64 kB)
ivtv0: Registered device vbi16 for decoder VOUT
ivtv0: Registered device video48 for decoder YUV (1024 kB)
--- drivers/media/rc/rc-main.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/media/rc/rc-main.c +16 -11
@@ -1891,23 +1891,28 @@ int rc_register_device(struct rc_dev *de dev->registered = true; -if (dev->driver_type !=RC_DRIVER_IR_RAW_TX ) { - rc =rc_setup_rx_device (dev); -if (rc) - goto out_dev; - } - -/* Ensure that the lirc kfifo is setup before we start the thread */ +/* +* once the the input device is registered in rc_setup_rx_device, +* userspace can open the input device and rc_open() will be called +* as a result. This results in driver code being allowed to submit +* keycodes with rc_keydown, so lirc must be registered first. +*/ if (dev->allowed_protocols !=RC_PROTO_BIT_CEC ) { rc =ir_lirc_register (dev);if (rc <0 ) - goto out_rx; + goto out_dev; + } + +if (dev->driver_type !=RC_DRIVER_IR_RAW_TX ) { + rc =rc_setup_rx_device (dev); +if (rc) + goto out_lirc; }if (dev->driver_type ==RC_DRIVER_IR_RAW ) { rc =ir_raw_event_register (dev);if (rc <0 ) - goto out_lirc; + goto out_rx; } dev_dbg(&dev->dev, "Registered rc%u (driver: %s)\n", dev->minor,
@@ -1915,11 +1920,11 @@ int rc_register_device(struct rc_dev *dereturn 0 ; +out_rx: +rc_free_rx_device (dev); out_lirc:if (dev->allowed_protocols !=RC_PROTO_BIT_CEC )ir_lirc_unregister (dev); -out_rx: -rc_free_rx_device (dev); out_dev:device_del (&dev->dev); out_rx_free:
Greg Kroah-Hartman
maintainerPATCH 221/367 watchdog: fix UAF in reboot notifier handling in watchdog core code
In reply to Greg Kroah-HartmanFrom: Vladis Dronov <[email protected]>
commit 69503e585192fdd84b240f18a0873d20e18a2e0a upstream.
After the commit 44ea39420fc9 ("drivers/watchdog: make use of devm_register_reboot_notifier()") the struct notifier_block reboot_nb in the struct watchdog_device is removed from the reboot notifiers chain at the time watchdog's chardev is closed. But at least in i6300esb.c case reboot_nb is embedded in the struct esb_dev which can be freed on its device removal and before the chardev is closed, thus UAF at reboot:
[ 7.728581] esb_probe: esb_dev.watchdog_device ffff91316f91ab28
ts# uname -r note the address ^^^
5.5.0-rc5-ae6088-wdog
ts# ./openwdog0 &
[1] 696
ts# opened /dev/watchdog0, sleeping 10s...
ts# echo 1 > /sys/devices/pci0000\:00/0000\:00\:09.0/remove
[ 178.086079] devres:rel_nodes: dev ffff91317668a0b0 data ffff91316f91ab28
esb_dev.watchdog_device.reboot_nb memory is freed here ^^^
ts# ...woken up
[ 181.459010] devres:rel_nodes: dev ffff913171781000 data ffff913174a1dae8
[ 181.460195] devm_unreg_reboot_notifier: res ffff913174a1dae8 nb ffff91316f91ab78
attempt to use memory already freed ^^^
[ 181.461063] devm_unreg_reboot_notifier: nb->call 6b6b6b6b6b6b6b6b
[ 181.461243] devm_unreg_reboot_notifier: nb->next 6b6b6b6b6b6b6b6b
freed memory is filled with a slub poison ^^^
[1]+ Done ./openwdog0
ts# reboot
[ 229.921862] systemd-shutdown[1]: Rebooting.
[ 229.939265] notifier_call_chain: nb ffffffff9c6c2f20 nb->next ffffffff9c6d50c0
[ 229.943080] notifier_call_chain: nb ffffffff9c6d50c0 nb->next 6b6b6b6b6b6b6b6b
[ 229.946054] notifier_call_chain: nb 6b6b6b6b6b6b6b6b INVAL
[ 229.957584] general protection fault: 0000 [#1] SMP
[ 229.958770] CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 5.5.0-rc5-ae6088-wdog
[ 229.960224] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), ...
[ 229.963288] RIP: 0010:notifier_call_chain+0x66/0xd0
[ 229.969082] RSP: 0018:ffffb20dc0013d88 EFLAGS: 00010246
[ 229.970812] RAX: 000000000000002e RBX: 6b6b6b6b6b6b6b6b RCX: 00000000000008b3
[ 229.972929] RDX: 0000000000000000 RSI: 0000000000000096 RDI: ffffffff9ccc46ac
[ 229.975028] RBP: 0000000000000001 R08: 0000000000000000 R09: 00000000000008b3
[ 229.977039] R10: 0000000000000001 R11: ffffffff9c26c740 R12: 0000000000000000
[ 229.979155] R13: 6b6b6b6b6b6b6b6b R14: 0000000000000000 R15: 00000000fffffffa
... slub_debug=FZP poison ^^^
[ 229.989089] Call Trace:
[ 229.990157] blocking_notifier_call_chain+0x43/0x59
[ 229.991401] kernel_restart_prepare+0x14/0x30
[ 229.992607] kernel_restart+0x9/0x30
[ 229.993800] __do_sys_reboot+0x1d2/0x210
[ 230.000149] do_syscall_64+0x3d/0x130
[ 230.001277] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 230.002639] RIP: 0033:0x7f5461bdd177
[ 230.016402] Modules linked in: i6300esb
[ 230.050261] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000bFix the crash by reverting 44ea39420fc9 so unregister_reboot_notifier() is called when watchdog device is removed. This also makes handling of the reboot notifier unified with the handling of the restart handler, which is freed with unregister_restart_handler() in the same place.
--- drivers/watchdog/watchdog_core.c | 35 +++++++++++++++++++++++++++++++++++ drivers/watchdog/watchdog_dev.c | 36 +----------------------------------- 2 files changed, 36 insertions(+), 35 deletions(-)
drivers/watchdog/watchdog_core.c +35 -0
@@ -147,6 +147,25 @@ int watchdog_init_timeout(struct watchdo }EXPORT_SYMBOL_GPL (watchdog_init_timeout); +static int watchdog_reboot_notifier (struct notifier_block *nb, +unsigned long code,void *data) +{ +struct watchdog_device *wdd; + + wdd = container_of(nb, struct watchdog_device, reboot_nb); +if (code ==SYS_DOWN || code ==SYS_HALT ) { +if (watchdog_active (wdd)) { +int ret; + + ret = wdd->ops->stop (wdd); +if (ret) +return NOTIFY_BAD ; + } + } + +return NOTIFY_DONE ; +} +static int watchdog_restart_notifier (struct notifier_block *nb,unsigned long action,void *data) {
@@ -235,6 +254,19 @@ static int __watchdog_register_device(st } } +if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) { + wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; + + ret =register_reboot_notifier (&wdd->reboot_nb); +if (ret) { +pr_err ("watchdog%d: Cannot register reboot notifier (%d)\n" , + wdd->id, ret); +watchdog_dev_unregister (wdd); +ida_simple_remove (&watchdog_ida, id); +return ret; + } + } +if (wdd->ops->restart) { wdd->restart_nb.notifier_call = watchdog_restart_notifier;
@@ -289,6 +321,9 @@ static void __watchdog_unregister_deviceif (wdd->ops->restart)unregister_restart_handler (&wdd->restart_nb); +if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) +unregister_reboot_notifier (&wdd->reboot_nb); +watchdog_dev_unregister (wdd);ida_simple_remove (&watchdog_ida, wdd->id); }
drivers/watchdog/watchdog_dev.c +1 -35
@@ -38,7 +38,6 @@#include <linux/miscdevice.h> /* For handling misc devices */ #include <linux/module.h> /* For module stuff/... */ #include <linux/mutex.h> /* For mutexes */ -#include <linux/reboot.h> /* For reboot notifier */ #include <linux/slab.h> /* For memory functions */ #include <linux/types.h> /* For standard types (like size_t) */ #include <linux/watchdog.h> /* For watchdog specific items */
@@ -1097,25 +1096,6 @@ static void watchdog_cdev_unregister(strput_device (&wd_data->dev); } -static int watchdog_reboot_notifier (struct notifier_block *nb, -unsigned long code,void *data) -{ -struct watchdog_device *wdd; - - wdd = container_of(nb, struct watchdog_device, reboot_nb); -if (code ==SYS_DOWN || code ==SYS_HALT ) { -if (watchdog_active (wdd)) { -int ret; - - ret = wdd->ops->stop (wdd); -if (ret) -return NOTIFY_BAD ; - } - } - -return NOTIFY_DONE ; -} -/* * watchdog_dev_register: register a watchdog device * @wdd: watchdog device
@@ -1134,22 +1114,8 @@ int watchdog_dev_register(struct watchdoreturn ret; ret =watchdog_register_pretimeout (wdd); -if (ret) { +if (ret)watchdog_cdev_unregister (wdd); -return ret; - } - -if (test_bit (WDOG_STOP_ON_REBOOT , &wdd->status)) { - wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; - - ret =devm_register_reboot_notifier (&wdd->wd_data->dev, - &wdd->reboot_nb); -if (ret) { -pr_err ("watchdog%d: Cannot register reboot notifier (%d)\n" , - wdd->id, ret); -watchdog_dev_unregister (wdd); - } - }return ret; }
Greg Kroah-Hartman
maintainerPATCH 225/367 eventfd: track eventfd_signal() recursion depth
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit b5e683d5cab8cd433b06ae178621f083cabd4f63 upstream.
eventfd use cases from aio and io_uring can deadlock due to circular or resursive calling, when eventfd_signal() tries to grab the waitqueue lock. On top of that, it's also possible to construct notification chains that are deep enough that we could blow the stack.
Add a percpu counter that tracks the percpu recursion depth, warn if we exceed it. The counter is also exposed so that users of eventfd_signal() can do the right thing if it's non-zero in the context where it is called.
--- fs/eventfd.c | 15 +++++++++++++++ include/linux/eventfd.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+)
fs/eventfd.c +15 -0
@@ -24,6 +24,8 @@#include <linux/seq_file.h> #include <linux/idr.h> +DEFINE_PER_CPU (int, eventfd_wake_count); +static DEFINE_IDA (eventfd_ida);struct eventfd_ctx {
@@ -60,12 +62,25 @@ __u64 eventfd_signal(struct eventfd_ctx {unsigned long flags; +/* +* Deadlock or stack overflow issues can happen if we recurse here +* through waitqueue wakeup handlers. If the caller users potentially +* nested waitqueues with custom wakeup handlers, then it should +* check eventfd_signal_count() before calling this function. If +* it returns true, the eventfd_signal() call should be deferred to a +* safe context. +*/ +if (WARN_ON_ONCE (this_cpu_read (eventfd_wake_count))) +return 0 ; +spin_lock_irqsave (&ctx->wqh.lock, flags); +this_cpu_inc (eventfd_wake_count);if (ULLONG_MAX - ctx->count < n) n =ULLONG_MAX - ctx->count; ctx->count += n;if (waitqueue_active (&ctx->wqh))wake_up_locked_poll (&ctx->wqh,EPOLLIN ); +this_cpu_dec (eventfd_wake_count);spin_unlock_irqrestore (&ctx->wqh.lock, flags);return n;
include/linux/eventfd.h +14 -0
@@ -12,6 +12,8 @@#include <linux/fcntl.h> #include <linux/wait.h> #include <linux/err.h> +#include <linux/percpu-defs.h> +#include <linux/percpu.h> /* * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining
@@ -40,6 +42,13 @@ __u64 eventfd_signal(struct eventfd_ctxint eventfd_ctx_remove_wait_queue (struct eventfd_ctx *ctx,wait_queue_entry_t *wait,__u64 *cnt); +DECLARE_PER_CPU (int, eventfd_wake_count); + +static inline bool eventfd_signal_count (void ) +{ +return this_cpu_read (eventfd_wake_count); +} +#else /* CONFIG_EVENTFD */ /*
@@ -68,6 +77,11 @@ static inline int eventfd_ctx_remove_waireturn -ENOSYS ; } +static inline bool eventfd_signal_count (void ) +{ +return false; +} +#endif #endif /* _LINUX_EVENTFD_H */
Greg Kroah-Hartman
maintainerPATCH 226/367 aio: prevent potential eventfd recursion on poll
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 01d7a356872eec22ef34a33a5f9cfa917d145468 upstream.
If we have nested or circular eventfd wakeups, then we can deadlock if we run them inline from our poll waitqueue wakeup handler. It's also possible to have very long chains of notifications, to the extent where we could risk blowing the stack.
Check the eventfd recursion count before calling eventfd_signal(). If it's non-zero, then punt the signaling to async context. This is always safe, as it takes us out-of-line in terms of stack and locking context.
--- fs/aio.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
fs/aio.c +18 -2
@@ -1610,6 +1610,14 @@ static int aio_fsync(struct fsync_iocb *return 0 ; } +static void aio_poll_put_work (struct work_struct *work) +{ + struct poll_iocb *req = container_of(work, struct poll_iocb, work); + struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); + +iocb_put (iocb); +} +static void aio_poll_complete_work (struct work_struct *work) { struct poll_iocb *req = container_of(work, struct poll_iocb, work);
@@ -1674,6 +1682,8 @@ static int aio_poll_wake(struct wait_quelist_del_init (&req->wait.entry);if (mask &&spin_trylock_irqsave (&iocb->ki_ctx->ctx_lock, flags)) { +struct kioctx *ctx = iocb->ki_ctx; +/* * Try to complete the iocb inline if we can. Use * irqsave/irqrestore because not all filesystems (e.g. fuse)
@@ -1683,8 +1693,14 @@ static int aio_poll_wake(struct wait_quelist_del (&iocb->ki_list); iocb->ki_res.res =mangle_poll (mask); req->done = true; -spin_unlock_irqrestore (&iocb->ki_ctx->ctx_lock, flags); -iocb_put (iocb); +if (iocb->ki_eventfd &&eventfd_signal_count ()) { + iocb =NULL ; +INIT_WORK (&req->work, aio_poll_put_work); +schedule_work (&req->work); + } +spin_unlock_irqrestore (&ctx->ctx_lock, flags); +if (iocb) +iocb_put (iocb); }else {schedule_work (&req->work); }
Greg Kroah-Hartman
maintainerPATCH 228/367 KVM: x86: Refactor prefix decoding to prevent Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 125ffc5e0a56a3eded608dc51e09d5ebf72cf652 upstream.
This fixes Spectre-v1/L1TF vulnerabilities in vmx_read_guest_seg_selector(), vmx_read_guest_seg_base(), vmx_read_guest_seg_limit() and vmx_read_guest_seg_ar(). When invoked from emulation, these functions contain index computations based on the (attacker-influenced) segment value. Using constants prevents the attack.
--- arch/x86/kvm/emulate.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
arch/x86/kvm/emulate.c +14 -2
@@ -5210,16 +5210,28 @@ int x86_decode_insn(struct x86_emulate_c ctxt->ad_bytes = def_ad_bytes ^6 ;break ;case 0x26 :/* ES override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_ES ; +break ;case 0x2e :/* CS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_CS ; +break ;case 0x36 :/* SS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_SS ; +break ;case 0x3e :/* DS override */ has_seg_override = true; - ctxt->seg_override = (ctxt->b >>3 ) &3 ; + ctxt->seg_override =VCPU_SREG_DS ;break ;case 0x64 :/* FS override */ + has_seg_override = true; + ctxt->seg_override =VCPU_SREG_FS ; +break ;case 0x65 :/* GS override */ has_seg_override = true; - ctxt->seg_override = ctxt->b &7 ; + ctxt->seg_override =VCPU_SREG_GS ;break ; case 0x40 ... 0x4f: /* REX */if (mode !=X86EMUL_MODE_PROT64 )
Greg Kroah-Hartman
maintainerPATCH 205/367 ARM: tegra: Enable PLLP bypass during Tegra124 LP1
In reply to Greg Kroah-HartmanFrom: Stephen Warren <[email protected]>
commit 1a3388d506bf5b45bb283e6a4c4706cfb4897333 upstream.
For a little over a year, U-Boot has configured the flow controller to perform automatic RAM re-repair on off->on power transitions of the CPU rail[1]. This is mandatory for correct operation of Tegra124. However, RAM re-repair relies on certain clocks, which the kernel must enable and leave running. PLLP is one of those clocks. This clock is shut down during LP1 in order to save power. Enable bypass (which I believe routes osc_div_clk, essentially the crystal clock, to the PLL output) so that this clock signal toggles even though the PLL is not active. This is required so that LP1 power mode (system suspend) operates correctly.
The bypass configuration must then be undone when resuming from LP1, so that all peripheral clocks run at the expected rate. Without this, many peripherals won't work correctly; for example, the UART baud rate would be incorrect.
NVIDIA's downstream kernel code only does this if not compiled for Tegra30, so the added code is made conditional upon the chip ID. NVIDIA's downstream code makes this change conditional upon the active CPU cluster. The upstream kernel currently doesn't support cluster switching, so this patch doesn't test the active CPU cluster ID.
[1] 3cc7942a4ae5 ARM: tegra: implement RAM repair
--- arch/arm/mach-tegra/sleep-tegra30.S | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm/mach-tegra/sleep-tegra30.S +11 -0
@@ -370,6 +370,14 @@ _pll_m_c_x_done: pll_locked r1, r0, CLK_RESET_PLLC_BASE pll_locked r1, r0, CLK_RESET_PLLX_BASE + tegra_get_soc_id TEGRA_APB_MISC_BASE, r1 + cmp r1, #TEGRA30 + beq 1f + ldr r1, [r0, #CLK_RESET_PLLP_BASE] + bic r1, r1, #(1<<31) @ disable PllP bypass + str r1, [r0, #CLK_RESET_PLLP_BASE] +1: + mov32 r7, TEGRA_TMRUS_BASE ldr r1, [r7] add r1, r1, #LOCK_DELAY
@@ -630,7 +638,10 @@ tegra30_switch_cpu_to_clk32k: str r0, [r4, #PMC_PLLP_WB0_OVERRIDE] /* disable PLLP, PLLA, PLLC and PLLX */ + tegra_get_soc_id TEGRA_APB_MISC_BASE, r1 + cmp r1, #TEGRA30 ldr r0, [r5, #CLK_RESET_PLLP_BASE] + orrne r0, r0, #(1 << 31) @ enable PllP bypass on fast cluster bic r0, r0, #(1 << 30) str r0, [r5, #CLK_RESET_PLLP_BASE] ldr r0, [r5, #CLK_RESET_PLLA_BASE]
Greg Kroah-Hartman
maintainerPATCH 230/367 KVM: x86: Protect DR-based index computations from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit ea740059ecb37807ba47b84b33d1447435a8d868 upstream.
This fixes a Spectre-v1/L1TF vulnerability in __kvm_set_dr() and kvm_get_dr().
Both kvm_get_dr() and kvm_set_dr() (a wrapper of __kvm_set_dr()) are exported symbols so KVM should tream them conservatively from a security perspective.
--- arch/x86/kvm/x86.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +6 -2
@@ -1047,9 +1047,11 @@ static u64 kvm_dr6_fixed(struct kvm_vcpustatic int __kvm_set_dr (struct kvm_vcpu *vcpu,int dr,unsigned long val) { +size_t size =ARRAY_SIZE (vcpu->arch.db); +switch (dr) { case 0 ... 3: - vcpu->arch.db[dr] = val; + vcpu->arch.db[array_index_nospec (dr, size)] = val;if (!(vcpu->guest_debug &KVM_GUESTDBG_USE_HW_BP )) vcpu->arch.eff_db[dr] = val;break ;
@@ -1086,9 +1088,11 @@ EXPORT_SYMBOL_GPL(kvm_set_dr);int kvm_get_dr (struct kvm_vcpu *vcpu,int dr,unsigned long *val) { +size_t size =ARRAY_SIZE (vcpu->arch.db); +switch (dr) { case 0 ... 3: - *val = vcpu->arch.db[dr]; + *val = vcpu->arch.db[array_index_nospec (dr, size)];break ;case 4 :/* fall through */
Greg Kroah-Hartman
maintainerPATCH 231/367 KVM: x86: Protect kvm_lapic_reg_write() from Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 4bf79cb089f6b1c6c632492c0271054ce52ad766 upstream.
This fixes a Spectre-v1/L1TF vulnerability in kvm_lapic_reg_write(). This function contains index computations based on the (attacker-controlled) MSR number.
--- arch/x86/kvm/lapic.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/x86/kvm/lapic.c +9 -4
@@ -1963,15 +1963,20 @@ int kvm_lapic_reg_write(struct kvm_lapiccase APIC_LVTTHMR :case APIC_LVTPC :case APIC_LVT1 : -case APIC_LVTERR : +case APIC_LVTERR : {/* TODO: Check vector */ +size_t size; +u32 index; +if (!kvm_apic_sw_enabled (apic)) val |=APIC_LVT_MASKED ; - - val &= apic_lvt_mask[(reg -APIC_LVTT ) >>4 ]; + size =ARRAY_SIZE (apic_lvt_mask); + index =array_index_nospec ( + (reg -APIC_LVTT ) >>4 , size); + val &= apic_lvt_mask[index];kvm_lapic_set_reg (apic, reg, val); -break ; + }case APIC_LVTT :if (!kvm_apic_sw_enabled (apic))
Greg Kroah-Hartman
maintainerPATCH 244/367 x86/kvm: Be careful not to clear KVM_VCPU_FLUSH_TLB bit
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 8c6de56a42e0c657955e12b882a81ef07d1d073e upstream.
kvm_steal_time_set_preempted() may accidentally clear KVM_VCPU_FLUSH_TLB bit if it is called more than once while VCPU is preempted.
This is part of CVE-2019-3016.
(This bug was also independently discovered by Jim Mattson <[email protected]>)
--- arch/x86/kvm/x86.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/x86.c +3 -0
@@ -3514,6 +3514,9 @@ static void kvm_steal_time_set_preemptedif (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; +if (vcpu->arch.st.steal.preempted) +return ; + vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime,
Greg Kroah-Hartman
maintainerPATCH 208/367 sunrpc: expiry_time should be seconds not timeval
In reply to Greg Kroah-HartmanFrom: Roberto Bergantinos Corpas <[email protected]>
commit 3d96208c30f84d6edf9ab4fac813306ac0d20c10 upstream.
When upcalling gssproxy, cache_head.expiry_time is set as a timeval, not seconds since boot. As such, RPC cache expiry logic will not clean expired objects created under auth.rpcsec.context cache.
This has proven to cause kernel memory leaks on field. Using 64 bit variants of getboottime/timespec
Expiration times have worked this way since 2010's c5b29f885afe "sunrpc:
use seconds since boot in expiry cache". The gssproxy code introduced in 2012 added gss_proxy_save_rsc and introduced the bug. That's a while for this to lurk, but it required a bit of an extreme case to make it obvious.
--- net/sunrpc/auth_gss/svcauth_gss.c | 4 ++++ 1 file changed, 4 insertions(+)
net/sunrpc/auth_gss/svcauth_gss.c +4 -0
@@ -1248,6 +1248,7 @@ static int gss_proxy_save_rsc(struct cacdprintk ("RPC: No creds found!\n" ); goto out; }else { +struct timespec64 boot;/* steal creds */ rsci.cred = ud->creds;
@@ -1268,6 +1269,9 @@ static int gss_proxy_save_rsc(struct cac &expiry, GFP_KERNEL);if (status) goto out; + +getboottime64 (&boot); + expiry -= boot.tv_sec; } rsci.h.expiry_time = expiry;
Greg Kroah-Hartman
maintainerPATCH 261/367 ocfs2: fix oops when writing cloned file
In reply to Greg Kroah-HartmanFrom: Gang He <[email protected]>
commit 2d797e9ff95ecbcf0a83d657928ed20579444857 upstream.
Writing a cloned file triggers a kernel oops and the user-space command process is also killed by the system. The bug can be reproduced stably via:
1) create a file under ocfs2 file system directory.
journalctl -b > aa.txt
2) create a cloned file for this file.
reflink aa.txt bb.txt
3) write the cloned file with dd command.
dd if=/dev/zero of=bb.txt bs=512 count=1 conv=notrunc
The dd command is killed by the kernel, then you can see the oops message via dmesg command.
[ 463.875404] BUG: kernel NULL pointer dereference, address: 0000000000000028 [ 463.875413] #PF: supervisor read access in kernel mode [ 463.875416] #PF: error_code(0x0000) - not-present page [ 463.875418] PGD 0 P4D 0 [ 463.875425] Oops: 0000 [#1] SMP PTI [ 463.875431] CPU: 1 PID: 2291 Comm: dd Tainted: G OE 5.3.16-2-default [ 463.875433] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 [ 463.875500] RIP: 0010:ocfs2_refcount_cow+0xa4/0x5d0 [ocfs2] [ 463.875505] Code: 06 89 6c 24 38 89 eb f6 44 24 3c 02 74 be 49 8b 47 28 [ 463.875508] RSP: 0018:ffffa2cb409dfce8 EFLAGS: 00010202 [ 463.875512] RAX: ffff8b1ebdca8000 RBX: 0000000000000001 RCX: ffff8b1eb73a9df0 [ 463.875515] RDX: 0000000000056a01 RSI: 0000000000000000 RDI: 0000000000000000 [ 463.875517] RBP: 0000000000000001 R08: ffff8b1eb73a9de0 R09: 0000000000000000 [ 463.875520] R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000 [ 463.875522] R13: ffff8b1eb922f048 R14: 0000000000000000 R15: ffff8b1eb922f048 [ 463.875526] FS: 00007f8f44d15540(0000) GS:ffff8b1ebeb00000(0000) knlGS:0000000000000000 [ 463.875529] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 463.875532] CR2: 0000000000000028 CR3: 000000003c17a000 CR4: 00000000000006e0 [ 463.875546] Call Trace: [ 463.875596] ? ocfs2_inode_lock_full_nested+0x18b/0x960 [ocfs2] [ 463.875648] ocfs2_file_write_iter+0xaf8/0xc70 [ocfs2] [ 463.875672] new_sync_write+0x12d/0x1d0 [ 463.875688] vfs_write+0xad/0x1a0 [ 463.875697] ksys_write+0xa1/0xe0 [ 463.875710] do_syscall_64+0x60/0x1f0 [ 463.875743] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 463.875758] RIP: 0033:0x7f8f4482ed44 [ 463.875762] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 80 00 00 00 [ 463.875765] RSP: 002b:00007fff300a79d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 463.875769] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f8f4482ed44 [ 463.875771] RDX: 0000000000000200 RSI: 000055f771b5c000 RDI: 0000000000000001 [ 463.875774] RBP: 0000000000000200 R08: 00007f8f44af9c78 R09: 0000000000000003 [ 463.875776] R10: 000000000000089f R11: 0000000000000246 R12: 000055f771b5c000 [ 463.875779] R13: 0000000000000200 R14: 0000000000000000 R15: 000055f771b5c000
This regression problem was introduced by commit e74540b28556 ("ocfs2:
protect extent tree in ocfs2_prepare_inode_for_write()").
--- fs/ocfs2/file.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/ocfs2/file.c +6 -8
@@ -2101,17 +2101,15 @@ static int ocfs2_is_io_unaligned(structstatic int ocfs2_inode_lock_for_extent_tree (struct inode *inode,struct buffer_head **di_bh,int meta_level, -int overwrite_io,int write_sem,int wait) {int ret =0 ;if (wait) - ret =ocfs2_inode_lock (inode,NULL , meta_level); + ret =ocfs2_inode_lock (inode, di_bh, meta_level);else - ret =ocfs2_try_inode_lock (inode, - overwrite_io ?NULL : di_bh, meta_level); + ret =ocfs2_try_inode_lock (inode, di_bh, meta_level);if (ret <0 ) goto out;
@@ -2136,6 +2134,7 @@ static int ocfs2_inode_lock_for_extent_t out_unlock:brelse (*di_bh); + *di_bh =NULL ;ocfs2_inode_unlock (inode, meta_level); out:return ret;
@@ -2177,7 +2176,6 @@ static int ocfs2_prepare_inode_for_write ret =ocfs2_inode_lock_for_extent_tree (inode, &di_bh, meta_level, - overwrite_io, write_sem, wait);if (ret <0 ) {
@@ -2233,13 +2231,13 @@ static int ocfs2_prepare_inode_for_write &di_bh, meta_level, write_sem); + meta_level =1 ; + write_sem =1 ; ret =ocfs2_inode_lock_for_extent_tree (inode, &di_bh, meta_level, - overwrite_io, -1 , + write_sem, wait); - write_sem =1 ;if (ret <0 ) {if (ret != -EAGAIN )mlog_errno (ret);
Greg Kroah-Hartman
maintainerPATCH 267/367 drm/tegra: Relax IOMMU usage criteria on old Tegra
In reply to Greg Kroah-HartmanFrom: Thierry Reding <[email protected]>
commit 2d9384ff91770a71bd1ff24c25952ef1187a0e9c upstream.
Older Tegra devices only allow addressing 32 bits of memory, so whether or not the host1x is attached to an IOMMU doesn't matter. host1x IOMMU attachment is only needed on devices that can address memory beyond the 32-bit boundary and where the host1x doesn't support the wide GATHER opcode that allows it to access buffers at higher addresses.
--- drivers/gpu/drm/tegra/drm.c | 49 ++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 17 deletions(-)
drivers/gpu/drm/tegra/drm.c +32 -17
@@ -1037,23 +1037,9 @@ void tegra_drm_free(struct tegra_drm *tefree_pages ((unsigned long )virt,get_order (size)); } -static int host1x_drm_probe (struct host1x_device *dev) +static bool host1x_drm_wants_iommu (struct host1x_device *dev) { -struct drm_driver *driver = &tegra_drm_driver;struct iommu_domain *domain; -struct tegra_drm *tegra; -struct drm_device *drm; -int err; - - drm =drm_dev_alloc (driver, &dev->dev); -if (IS_ERR (drm)) -return PTR_ERR (drm); - - tegra =kzalloc (sizeof (*tegra),GFP_KERNEL ); -if (!tegra) { - err = -ENOMEM ; - goto put; - }/* * If the Tegra DRM clients are backed by an IOMMU, push buffers are
@@ -1082,9 +1068,38 @@ static int host1x_drm_probe(struct host1* up the device tree appropriately. This is considered an problem * of integration, so care must be taken for the DT to be consistent. */ - domain =iommu_get_domain_for_dev (drm->dev->parent); + domain =iommu_get_domain_for_dev (dev->dev.parent); + +/* +* Tegra20 and Tegra30 don't support addressing memory beyond the +* 32-bit boundary, so the regular GATHER opcodes will always be +* sufficient and whether or not the host1x is attached to an IOMMU +* doesn't matter. +*/ +if (!domain &&dma_get_mask (dev->dev.parent) <=DMA_BIT_MASK (32 )) +return true; + +return domain !=NULL ; +} + +static int host1x_drm_probe (struct host1x_device *dev) +{ +struct drm_driver *driver = &tegra_drm_driver; +struct tegra_drm *tegra; +struct drm_device *drm; +int err; + + drm =drm_dev_alloc (driver, &dev->dev); +if (IS_ERR (drm)) +return PTR_ERR (drm); + + tegra =kzalloc (sizeof (*tegra),GFP_KERNEL ); +if (!tegra) { + err = -ENOMEM ; + goto put; + } -if (domain &&iommu_present (&platform_bus_type)) { +if (host1x_drm_wants_iommu (dev) &&iommu_present (&platform_bus_type)) { tegra->domain =iommu_domain_alloc (&platform_bus_type);if (!tegra->domain) { err = -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 268/367 drm/tegra: Reuse IOVA mapping where possible
In reply to Greg Kroah-HartmanFrom: Thierry Reding <[email protected]>
commit 273da5a046965ccf0ec79eb63f2d5173467e20fa upstream.
This partially reverts the DMA API support that was recently merged because it was causing performance regressions on older Tegra devices. Unfortunately, the cache maintenance performed by dma_map_sg() and dma_unmap_sg() causes performance to drop by a factor of 10.
The right solution for this would be to cache mappings for buffers per consumer device, but that's a bit involved. Instead, we simply revert to the old behaviour of sharing IOVA mappings when we know that devices can do so (i.e. they share the same IOMMU domain).
--- drivers/gpu/drm/tegra/gem.c | 10 ++++++++- drivers/gpu/drm/tegra/plane.c | 46 +++++++++++++++++++++++------------------- drivers/gpu/host1x/job.c | 32 ++++++++++++++++++++++++++--- 3 files changed, 64 insertions(+), 24 deletions(-)
drivers/gpu/drm/tegra/gem.c +9 -1
@@ -60,8 +60,16 @@ static struct sg_table *tegra_bo_pin(str/* * If we've manually mapped the buffer object through the IOMMU, make * sure to return the IOVA address of our mapping. +* +* Similarly, for buffers that have been allocated by the DMA API the +* physical address can be used for devices that are not attached to +* an IOMMU. For these devices, callers must pass a valid pointer via +* the @phys argument. +* +* Imported buffers were also already mapped at import time, so the +* existing mapping can be reused. */ -if (phys && obj->mm) { +if (phys) { *phys = obj->iova;return NULL ; }
drivers/gpu/drm/tegra/plane.c +26 -20
86 lines not on this page · raw message
drivers/gpu/host1x/job.c +29 -3
@@ -8,6 +8,7 @@#include <linux/dma-mapping.h> #include <linux/err.h> #include <linux/host1x.h> +#include <linux/iommu.h> #include <linux/kref.h> #include <linux/module.h> #include <linux/scatterlist.h>
@@ -101,9 +102,11 @@ static unsigned int pin_job(struct host1 {struct host1x_client *client = job->client;struct device *dev = client->dev; +struct iommu_domain *domain;unsigned int i;int err; + domain =iommu_get_domain_for_dev (dev); job->num_unpins =0 ;for (i =0 ; i < job->num_relocs; i++) {
@@ -117,7 +120,19 @@ static unsigned int pin_job(struct host1 goto unpin; } -if (client->group) +/* +* If the client device is not attached to an IOMMU, the +* physical address of the buffer object can be used. +* +* Similarly, when an IOMMU domain is shared between all +* host1x clients, the IOVA is already available, so no +* need to map the buffer object again. +* +* XXX Note that this isn't always safe to do because it +* relies on an assumption that no cache maintenance is +* needed on the buffer objects. +*/ +if (!domain || client->group) phys = &phys_addr;else phys =NULL ;
@@ -176,6 +191,7 @@ static unsigned int pin_job(struct host1dma_addr_t phys_addr;unsigned long shift;struct iova *alloc; +dma_addr_t *phys;unsigned int j; g->bo =host1x_bo_get (g->bo);
@@ -184,7 +200,17 @@ static unsigned int pin_job(struct host1 goto unpin; } - sgt =host1x_bo_pin (host->dev, g->bo,NULL ); +/** +* If the host1x is not attached to an IOMMU, there is no need +* to map the buffer object for the host1x, since the physical +* address can simply be used. +*/ +if (!iommu_get_domain_for_dev (host->dev)) + phys = &phys_addr; +else + phys =NULL ; + + sgt =host1x_bo_pin (host->dev, g->bo, phys);if (IS_ERR (sgt)) { err =PTR_ERR (sgt); goto unpin;
@@ -214,7 +240,7 @@ static unsigned int pin_job(struct host1 job->unpins[job->num_unpins].size = gather_size; phys_addr =iova_dma_addr (&host->iova, alloc); - }else { + }else if (sgt) { err =dma_map_sg (host->dev, sgt->sgl, sgt->nents,DMA_TO_DEVICE );if (!err) {
Greg Kroah-Hartman
maintainerPATCH 272/367 drm/amdgpu/navi10: add OD_RANGE for navi overclocking
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit ee23a518fdc2c1dd1aaaf3a2c7ffdd6c83b396ec upstream.
So users can see the range of valid values.
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +59 -0
@@ -710,6 +710,15 @@ static inline bool navi10_od_feature_is_return od_table->cap[feature]; } +static void navi10_od_setting_get_range (struct smu_11_0_overdrive_table *od_table, +enum SMU_11_0_ODSETTING_ID setting, +uint32_t *min,uint32_t *max) +{ +if (min) + *min = od_table->min[setting]; +if (max) + *max = od_table->max[setting]; +}static int navi10_print_clk_levels (struct smu_context *smu,enum smu_clk_type clk_type,char *buf)
@@ -728,6 +737,7 @@ static int navi10_print_clk_levels(strucOverDriveTable_t *od_table = (OverDriveTable_t *)table_context->overdrive_table;struct smu_11_0_overdrive_table *od_settings = smu->od_settings; +uint32_t min_value, max_value;switch (clk_type) {case SMU_GFXCLK :
@@ -841,6 +851,55 @@ static int navi10_print_clk_levels(struc size +=sprintf (buf + size,"%d: %uMHz @ %umV\n" , i, curve_settings[0 ], curve_settings[1 ] /NAVI10_VOLTAGE_SCALE ); }break ; +case SMU_OD_RANGE : +if (!smu->od_enabled || !od_table || !od_settings) +break ; + size =sprintf (buf,"%s:\n" ,"OD_RANGE" ); + +if (navi10_od_feature_is_supported (od_settings,SMU_11_0_ODFEATURE_GFXCLK_LIMITS )) { +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_GFXCLKFMIN , + &min_value,NULL ); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_GFXCLKFMAX , +NULL , &max_value); + size +=sprintf (buf + size,"SCLK: %7uMhz %10uMhz\n" , + min_value, max_value); + } + +if (navi10_od_feature_is_supported (od_settings,SMU_11_0_ODFEATURE_UCLK_MAX )) { +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_UCLKFMAX , + &min_value, &max_value); + size +=sprintf (buf + size,"MCLK: %7uMhz %10uMhz\n" , + min_value, max_value); + } + +if (navi10_od_feature_is_supported (od_settings,SMU_11_0_ODFEATURE_GFXCLK_CURVE )) { +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n" , + min_value, max_value); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P1 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n" , + min_value, max_value); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P2 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n" , + min_value, max_value); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P2 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n" , + min_value, max_value); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P3 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n" , + min_value, max_value); +navi10_od_setting_get_range (od_settings,SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P3 , + &min_value, &max_value); + size +=sprintf (buf + size,"VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n" , + min_value, max_value); + } + +break ;default :break ; }
Greg Kroah-Hartman
maintainerPATCH 248/367 x86/kvm: Cache gfn to pfn translation
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit 917248144db5d7320655dbb41d3af0b8a0f3d589 upstream.
__kvm_map_gfn()'s call to gfn_to_pfn_memslot() is
* relatively expensive
* in certain cases (such as when done from atomic context) cannot be called
Stashing gfn-to-pfn mapping should help with both cases.
This is part of CVE-2019-3016.
--- arch/x86/include/asm/kvm_host.h | 1 arch/x86/kvm/x86.c | 10 ++++ include/linux/kvm_host.h | 7 ++ include/linux/kvm_types.h | 9 +++ virt/kvm/kvm_main.c | 98 ++++++++++++++++++++++++++++++++-------- 5 files changed, 103 insertions(+), 22 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -0
@@ -689,6 +689,7 @@ struct kvm_vcpu_arch {u64 last_steal;struct gfn_to_hva_cache stime;struct kvm_steal_time steal; +struct gfn_to_pfn_cache cache; } st;u64 tsc_offset;
arch/x86/kvm/x86.c +10 -0
@@ -9111,6 +9111,9 @@ static void fx_init(struct kvm_vcpu *vcpvoid kvm_arch_vcpu_free (struct kvm_vcpu *vcpu) {void *wbinvd_dirty_mask = vcpu->arch.wbinvd_dirty_mask; +struct gfn_to_pfn_cache *cache = &vcpu->arch.st.cache; + +kvm_release_pfn (cache->pfn, cache->dirty, cache);kvmclock_reset (vcpu);
@@ -9784,11 +9787,18 @@ out_free:void kvm_arch_memslots_updated (struct kvm *kvm,u64 gen) { +struct kvm_vcpu *vcpu; +int i; +/* * memslots->generation has been incremented. * mmio generation may have reached its maximum value. */ kvm_mmu_invalidate_mmio_sptes (kvm, gen); + +/* Force re-initialization of steal_time cache */ +kvm_for_each_vcpu (i, vcpu, kvm) +kvm_vcpu_kick (vcpu); } int kvm_arch_prepare_memory_region(struct kvm *kvm,
include/linux/kvm_host.h +5 -2
@@ -723,6 +723,7 @@ void kvm_set_pfn_dirty(kvm_pfn_t pfn);void kvm_set_pfn_accessed (kvm_pfn_t pfn);void kvm_get_pfn (kvm_pfn_t pfn); +void kvm_release_pfn (kvm_pfn_t pfn,bool dirty,struct gfn_to_pfn_cache *cache);int kvm_read_guest_page (struct kvm *kvm,gfn_t gfn,void *data,int offset,int len); int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
@@ -775,10 +776,12 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic (struct kvm_vcpu *vcpu,gfn_t gfn);kvm_pfn_t kvm_vcpu_gfn_to_pfn (struct kvm_vcpu *vcpu,gfn_t gfn);int kvm_vcpu_map (struct kvm_vcpu *vcpu,gpa_t gpa,struct kvm_host_map *map); -int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map); +int kvm_map_gfn (struct kvm_vcpu *vcpu,gfn_t gfn,struct kvm_host_map *map, +struct gfn_to_pfn_cache *cache,bool atomic);struct page *kvm_vcpu_gfn_to_page (struct kvm_vcpu *vcpu,gfn_t gfn);void kvm_vcpu_unmap (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty); -int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map,bool dirty); +int kvm_unmap_gfn (struct kvm_vcpu *vcpu,struct kvm_host_map *map, +struct gfn_to_pfn_cache *cache,bool dirty,bool atomic);unsigned long kvm_vcpu_gfn_to_hva (struct kvm_vcpu *vcpu,gfn_t gfn);unsigned long kvm_vcpu_gfn_to_hva_prot (struct kvm_vcpu *vcpu,gfn_t gfn,bool *writable); int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset,
include/linux/kvm_types.h +8 -1
@@ -18,7 +18,7 @@ struct kvm_memslots;enum kvm_mr_change ; -#include <asm/types.h> +#include <linux/types.h> /* * Address types:
@@ -51,4 +51,11 @@ struct gfn_to_hva_cache { struct kvm_memory_slot *memslot; }; +struct gfn_to_pfn_cache { +u64 generation; +gfn_t gfn; +kvm_pfn_t pfn; +bool dirty; +}; +#endif /* __KVM_TYPES_H__ */
virt/kvm/kvm_main.c +79 -19
160 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 250/367 KVM: x86: Use gpa_t for cr2/gpa to fix TDP support on 32-bit KVM
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 736c291c9f36b07f8889c61764c28edce20e715d upstream.
Convert a plethora of parameters and variables in the MMU and page fault flows from type gva_t to gpa_t to properly handle TDP on 32-bit KVM.
Thanks to PSE and PAE paging, 32-bit kernels can access 64-bit physical addresses. When TDP is enabled, the fault address is a guest physical address and thus can be a 64-bit value, even when both KVM and its guest are using 32-bit virtual addressing, e.g. VMX's VMCS.GUEST_PHYSICAL is a 64-bit field, not a natural width field.
Using a gva_t for the fault address means KVM will incorrectly drop the upper 32-bits of the GPA. Ditto for gva_to_gpa() when it is used to translate L2 GPAs to L1 GPAs.
Opportunistically rename variables and parameters to better reflect the dual address modes, e.g. use "cr2_or_gpa" for fault addresses and plain "addr" instead of "vaddr" when the address may be either a GVA or an L2 GPA. Similarly, use "gpa" in the nonpaging_page_fault() flows to avoid a confusing "gpa_t gva" declaration; this also sets the stage for a future patch to combing nonpaging_page_fault() and tdp_page_fault() with minimal churn.
Sprinkle in a few comments to document flows where an address is known to be a GVA and thus can be safely truncated to a 32-bit value. Add WARNs in kvm_handle_page_fault() and FNAME(gva_to_gpa_nested)() to help document such cases and detect bugs.
--- arch/x86/include/asm/kvm_host.h | 8 ++-- arch/x86/kvm/mmu/mmu.c | 69 +++++++++++++++++++++++----------------- arch/x86/kvm/mmu/paging_tmpl.h | 25 +++++++++----- arch/x86/kvm/mmutrace.h | 12 +++--- arch/x86/kvm/x86.c | 40 +++++++++++------------ arch/x86/kvm/x86.h | 2 - include/linux/kvm_host.h | 6 +-- virt/kvm/async_pf.c | 10 ++--- 8 files changed, 94 insertions(+), 78 deletions(-)
arch/x86/include/asm/kvm_host.h +4 -4
@@ -378,12 +378,12 @@ struct kvm_mmu {void (*set_cr3)(struct kvm_vcpu *vcpu,unsigned long root);unsigned long (*get_cr3)(struct kvm_vcpu *vcpu);u64 (*get_pdptr)(struct kvm_vcpu *vcpu,int index); -int (*page_fault)(struct kvm_vcpu *vcpu,gva_t gva,u32 err, +int (*page_fault)(struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,u32 err,bool prefault);void (*inject_page_fault)(struct kvm_vcpu *vcpu,struct x86_exception *fault); -gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu,gva_t gva,u32 access, -struct x86_exception *exception); +gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu,gpa_t gva_or_gpa, +u32 access,struct x86_exception *exception);gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu,gpa_t gpa,u32 access,struct x86_exception *exception); int (*sync_page)(struct kvm_vcpu *vcpu,
@@ -1469,7 +1469,7 @@ void kvm_vcpu_deactivate_apicv(struct kvint kvm_emulate_hypercall (struct kvm_vcpu *vcpu); -int kvm_mmu_page_fault (struct kvm_vcpu *vcpu,gva_t gva,u64 error_code, +int kvm_mmu_page_fault (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,u64 error_code,void *insn,int insn_len);void kvm_mmu_invlpg (struct kvm_vcpu *vcpu,gva_t gva);void kvm_mmu_invpcid_gva (struct kvm_vcpu *vcpu,gva_t gva,unsigned long pcid);
arch/x86/kvm/mmu/mmu.c +40 -29
214 lines not on this page · raw message
arch/x86/kvm/mmu/paging_tmpl.h +16 -9
@@ -291,11 +291,11 @@ static inline unsigned FNAME(gpte_pkeys) }/* -* Fetch a guest pte for a guest virtual address +* Fetch a guest pte for a guest virtual address, or for an L2's GPA. */ static int FNAME (walk_addr_generic )(struct guest_walker *walker,struct kvm_vcpu *vcpu,struct kvm_mmu *mmu, -gva_t addr,u32 access) +gpa_t addr,u32 access) {int ret;pt_element_t pte;
@@ -496,7 +496,7 @@ error: }static int FNAME (walk_addr )(struct guest_walker *walker, -struct kvm_vcpu *vcpu,gva_t addr,u32 access) +struct kvm_vcpu *vcpu,gpa_t addr,u32 access) {return FNAME (walk_addr_generic)(walker, vcpu, vcpu->arch.mmu, addr, access);
@@ -611,7 +611,7 @@ static void FNAME(pte_prefetch)(struct k* If the guest tries to write a write-protected page, we need to * emulate this operation, return 1 to indicate this case. */ -static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, +static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, struct guest_walker *gw, int write_fault, int hlevel, kvm_pfn_t pfn, bool map_writable, bool prefault,
@@ -765,7 +765,7 @@ FNAME(is_self_change_mapping)(struct kvm* Returns: 1 if we need to emulate the instruction, 0 otherwise, or * a negative value on error. */ -static int FNAME (page_fault )(struct kvm_vcpu *vcpu,gva_t addr,u32 error_code, +static int FNAME (page_fault )(struct kvm_vcpu *vcpu,gpa_t addr,u32 error_code,bool prefault) {int write_fault = error_code &PFERR_WRITE_MASK ;
@@ -945,18 +945,19 @@ static void FNAME(invlpg)(struct kvm_vcpspin_unlock (&vcpu->kvm->mmu_lock); } -static gpa_t FNAME (gva_to_gpa )(struct kvm_vcpu *vcpu,gva_t vaddr,u32 access, +/* Note, @addr is a GPA when gva_to_gpa() translates an L2 GPA to an L1 GPA. */ +static gpa_t FNAME (gva_to_gpa )(struct kvm_vcpu *vcpu,gpa_t addr,u32 access,struct x86_exception *exception) {struct guest_walker walker;gpa_t gpa =UNMAPPED_GVA ;int r; - r =FNAME (walk_addr)(&walker, vcpu, vaddr, access); + r =FNAME (walk_addr)(&walker, vcpu, addr, access);if (r) { gpa =gfn_to_gpa (walker.gfn); - gpa |= vaddr & ~PAGE_MASK ; + gpa |= addr & ~PAGE_MASK ; }else if (exception) *exception = walker.fault;
@@ -964,7 +965,8 @@ static gpa_t FNAME(gva_to_gpa)(struct kv }#if PTTYPE !=PTTYPE_EPT -static gpa_t FNAME (gva_to_gpa_nested )(struct kvm_vcpu *vcpu,gva_t vaddr, +/* Note, gva_to_gpa_nested() is only used to translate L2 GVAs. */ +static gpa_t FNAME (gva_to_gpa_nested )(struct kvm_vcpu *vcpu,gpa_t vaddr,u32 access,struct x86_exception *exception) {
@@ -972,6 +974,11 @@ static gpa_t FNAME(gva_to_gpa_nested)(stgpa_t gpa =UNMAPPED_GVA ;int r; +#ifndef CONFIG_X86_64 +/* A 64-bit GVA should be impossible on 32-bit KVM. */ +WARN_ON_ONCE (vaddr >>32 ); +#endif + r =FNAME (walk_addr_nested)(&walker, vcpu, vaddr, access);if (r) {
arch/x86/kvm/mmutrace.h +6 -6
@@ -249,13 +249,13 @@ TRACE_EVENT( TRACE_EVENT( fast_page_fault, - TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, + TP_PROTO(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 error_code, u64 *sptep, u64 old_spte, bool retry), - TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry), + TP_ARGS(vcpu, cr2_or_gpa, error_code, sptep, old_spte, retry), TP_STRUCT__entry( __field(int, vcpu_id) - __field(gva_t, gva) + __field(gpa_t, cr2_or_gpa) __field(u32, error_code) __field(u64 *, sptep) __field(u64, old_spte)
@@ -265,7 +265,7 @@ TRACE_EVENT(TP_fast_assign ( __entry->vcpu_id = vcpu->vcpu_id; - __entry->gva = gva; + __entry->cr2_or_gpa = cr2_or_gpa; __entry->error_code = error_code; __entry->sptep = sptep; __entry->old_spte = old_spte;
@@ -273,9 +273,9 @@ TRACE_EVENT( __entry->retry = retry; ), -TP_printk ("vcpu %d gva %lx error_code %s sptep %p old %#llx" +TP_printk ("vcpu %d gva %llx error_code %s sptep %p old %#llx" " new %llx spurious %d fixed %d" , __entry->vcpu_id, - __entry->gva,__print_flags (__entry->error_code,"|" , + __entry->cr2_or_gpa,__print_flags (__entry->error_code,"|" , kvm_mmu_trace_pferr_flags), __entry->sptep, __entry->old_spte, __entry->new_spte, __spte_satisfied(old_spte), __spte_satisfied(new_spte)
arch/x86/kvm/x86.c +19 -21
@@ -6396,11 +6396,11 @@ static int handle_emulation_failure(strureturn 1 ; } -static bool reexecute_instruction (struct kvm_vcpu *vcpu,gva_t cr2, +static bool reexecute_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,bool write_fault_to_shadow_pgtable,int emulation_type) { -gpa_t gpa = cr2; +gpa_t gpa = cr2_or_gpa;kvm_pfn_t pfn;if (!(emulation_type &EMULTYPE_ALLOW_RETRY ))
@@ -6414,7 +6414,7 @@ static bool reexecute_instruction(struct* Write permission should be allowed since only * write access need to be emulated. */ - gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2,NULL ); + gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2_or_gpa,NULL );/* * If the mapping is invalid in guest, let cpu retry
@@ -6471,10 +6471,10 @@ static bool reexecute_instruction(struct }static bool retry_instruction (struct x86_emulate_ctxt *ctxt, -unsigned long cr2,int emulation_type) +gpa_t cr2_or_gpa,int emulation_type) {struct kvm_vcpu *vcpu =emul_to_vcpu (ctxt); -unsigned long last_retry_eip, last_retry_addr, gpa = cr2; +unsigned long last_retry_eip, last_retry_addr, gpa = cr2_or_gpa; last_retry_eip = vcpu->arch.last_retry_eip; last_retry_addr = vcpu->arch.last_retry_addr;
@@ -6503,14 +6503,14 @@ static bool retry_instruction(struct x86if (x86_page_table_writing_insn (ctxt))return false; -if (ctxt->eip == last_retry_eip && last_retry_addr == cr2) +if (ctxt->eip == last_retry_eip && last_retry_addr == cr2_or_gpa)return false; vcpu->arch.last_retry_eip = ctxt->eip; - vcpu->arch.last_retry_addr = cr2; + vcpu->arch.last_retry_addr = cr2_or_gpa;if (!vcpu->arch.mmu->direct_map) - gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2,NULL ); + gpa =kvm_mmu_gva_to_gpa_write (vcpu, cr2_or_gpa,NULL );kvm_mmu_unprotect_page (vcpu->kvm,gpa_to_gfn (gpa));
@@ -6656,11 +6656,8 @@ static bool is_vmware_backdoor_opcode(streturn false; } -int x86_emulate_instruction (struct kvm_vcpu *vcpu, -unsigned long cr2, -int emulation_type, -void *insn, -int insn_len) +int x86_emulate_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +int emulation_type,void *insn,int insn_len) {int r;struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
@@ -6706,8 +6703,9 @@ int x86_emulate_instruction(struct kvm_vkvm_queue_exception (vcpu,UD_VECTOR );return 1 ; } -if (reexecute_instruction (vcpu, cr2, write_fault_to_spt, - emulation_type)) +if (reexecute_instruction (vcpu, cr2_or_gpa, + write_fault_to_spt, + emulation_type))return 1 ;if (ctxt->have_exception) {/*
@@ -6741,7 +6739,7 @@ int x86_emulate_instruction(struct kvm_vreturn 1 ; } -if (retry_instruction (ctxt, cr2, emulation_type)) +if (retry_instruction (ctxt, cr2_or_gpa, emulation_type))return 1 ;/* this is needed for vmware backdoor interface to work since it
@@ -6753,7 +6751,7 @@ int x86_emulate_instruction(struct kvm_v restart:/* Save the faulting GPA (cr2) in the address field */ - ctxt->exception.address = cr2; + ctxt->exception.address = cr2_or_gpa; r =x86_emulate_insn (ctxt);
@@ -6761,7 +6759,7 @@ restart:return 1 ;if (r ==EMULATION_FAILED ) { -if (reexecute_instruction (vcpu, cr2, write_fault_to_spt, +if (reexecute_instruction (vcpu, cr2_or_gpa, write_fault_to_spt, emulation_type))return 1 ;
@@ -10045,7 +10043,7 @@ void kvm_arch_async_page_ready(struct kv work->arch.cr3 != vcpu->arch.mmu->get_cr3(vcpu)) return; - vcpu->arch.mmu->page_fault (vcpu, work->gva,0 , true); + vcpu->arch.mmu->page_fault (vcpu, work->cr2_or_gpa,0 , true); }static inline u32 kvm_async_pf_hash_fn (gfn_t gfn)
@@ -10158,7 +10156,7 @@ void kvm_arch_async_page_not_present(str {struct x86_exception fault; -trace_kvm_async_pf_not_present (work->arch.token, work->gva); +trace_kvm_async_pf_not_present (work->arch.token, work->cr2_or_gpa);kvm_add_async_pf_gfn (vcpu, work->arch.gfn); if (kvm_can_deliver_async_pf(vcpu) &&
@@ -10193,7 +10191,7 @@ void kvm_arch_async_page_present(struct work->arch.token = ~0 ;/* broadcast wakeup */ else kvm_del_async_pf_gfn(vcpu, work->arch.gfn); -trace_kvm_async_pf_ready (work->arch.token, work->gva); +trace_kvm_async_pf_ready (work->arch.token, work->cr2_or_gpa);if (vcpu->arch.apf.msr_val &KVM_ASYNC_PF_ENABLED && !apf_get_user (vcpu, &val)) {
arch/x86/kvm/x86.h +1 -1
@@ -289,7 +289,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcbool kvm_mtrr_check_gfn_range_consistency (struct kvm_vcpu *vcpu,gfn_t gfn,int page_num);bool kvm_vector_hashing_enabled (void ); -int x86_emulate_instruction (struct kvm_vcpu *vcpu,unsigned long cr2, +int x86_emulate_instruction (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa,int emulation_type,void *insn,int insn_len);#define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \
include/linux/kvm_host.h +3 -3
@@ -204,7 +204,7 @@ struct kvm_async_pf {struct list_head queue;struct kvm_vcpu *vcpu;struct mm_struct *mm; -gva_t gva; +gpa_t cr2_or_gpa;unsigned long addr;struct kvm_arch_async_pf arch;bool wakeup_all;
@@ -212,8 +212,8 @@ struct kvm_async_pf {void kvm_clear_async_pf_completion_queue (struct kvm_vcpu *vcpu);void kvm_check_async_pf_completion (struct kvm_vcpu *vcpu); -int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gva_t gva,unsigned long hva, -struct kvm_arch_async_pf *arch); +int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +unsigned long hva,struct kvm_arch_async_pf *arch);int kvm_async_pf_wakeup_all (struct kvm_vcpu *vcpu);#endif
virt/kvm/async_pf.c +5 -5
@@ -64,7 +64,7 @@ static void async_pf_execute(struct workstruct mm_struct *mm = apf->mm;struct kvm_vcpu *vcpu = apf->vcpu;unsigned long addr = apf->addr; -gva_t gva = apf->gva; +gpa_t cr2_or_gpa = apf->cr2_or_gpa;int locked =1 ;might_sleep ();
@@ -92,7 +92,7 @@ static void async_pf_execute(struct work* this point */ -trace_kvm_async_pf_completed (addr, gva); +trace_kvm_async_pf_completed (addr, cr2_or_gpa);if (swq_has_sleeper (&vcpu->wq))swake_up_one (&vcpu->wq);
@@ -165,8 +165,8 @@ void kvm_check_async_pf_completion(struc } } -int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gva_t gva,unsigned long hva, -struct kvm_arch_async_pf *arch) +int kvm_setup_async_pf (struct kvm_vcpu *vcpu,gpa_t cr2_or_gpa, +unsigned long hva,struct kvm_arch_async_pf *arch) {struct kvm_async_pf *work;
@@ -185,7 +185,7 @@ int kvm_setup_async_pf(struct kvm_vcpu * work->wakeup_all = false; work->vcpu = vcpu; - work->gva = gva; + work->cr2_or_gpa = cr2_or_gpa; work->addr = hva; work->arch = *arch; work->mm = current->mm;
Greg Kroah-Hartman
maintainerPATCH 254/367 KVM: x86: fix overlap between SPTE_MMIO_MASK and generation
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit 56871d444bc4d7ea66708775e62e2e0926384dbc upstream.
The SPTE_MMIO_MASK overlaps with the bits used to track MMIO generation number. A high enough generation number would overwrite the SPTE_SPECIAL_MASK region and cause the MMIO SPTE to be misinterpreted.
Likewise, setting bits 52 and 53 would also cause an incorrect generation number to be read from the PTE, though this was partially mitigated by the (useless if it weren't for the bug) removal of SPTE_SPECIAL_MASK from the spte in get_mmio_spte_generation. Drop that removal, and replace it with a compile-time assertion.
--- arch/x86/kvm/mmu/mmu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kvm/mmu/mmu.c +5 -5
@@ -418,22 +418,24 @@ static inline bool is_access_track_spte(* requires a full MMU zap). The flag is instead explicitly queried when * checking for MMIO spte cache hits. */ -#define MMIO_SPTE_GEN_MASK GENMASK_ULL(18, 0) +#define MMIO_SPTE_GEN_MASK GENMASK_ULL(17, 0)#define MMIO_SPTE_GEN_LOW_START 3#define MMIO_SPTE_GEN_LOW_END 11#define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \ MMIO_SPTE_GEN_LOW_START) -#define MMIO_SPTE_GEN_HIGH_START 52 -#define MMIO_SPTE_GEN_HIGH_END 61 +#define MMIO_SPTE_GEN_HIGH_START PT64_SECOND_AVAIL_BITS_SHIFT +#define MMIO_SPTE_GEN_HIGH_END 62#define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \ MMIO_SPTE_GEN_HIGH_START) +static u64 generation_mmio_spte_mask (u64 gen) {u64 mask;WARN_ON (gen & ~MMIO_SPTE_GEN_MASK ); +BUILD_BUG_ON ((MMIO_SPTE_GEN_HIGH_MASK |MMIO_SPTE_GEN_LOW_MASK ) &SPTE_SPECIAL_MASK ); mask = (gen <<MMIO_SPTE_GEN_LOW_START ) &MMIO_SPTE_GEN_LOW_MASK ; mask |= (gen <<MMIO_SPTE_GEN_HIGH_START ) &MMIO_SPTE_GEN_HIGH_MASK ;
@@ -444,8 +446,6 @@ static u64 get_mmio_spte_generation(u64 {u64 gen; - spte &= ~shadow_mmio_mask; - gen = (spte &MMIO_SPTE_GEN_LOW_MASK ) >>MMIO_SPTE_GEN_LOW_START ; gen |= (spte &MMIO_SPTE_GEN_HIGH_MASK ) >>MMIO_SPTE_GEN_HIGH_START ;return gen;
Greg Kroah-Hartman
maintainerPATCH 316/367 bonding/alb: properly access headers in bond_alb_xmit()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 38f88c45404293bbc027b956def6c10cbd45c616 ]
syzbot managed to send an IPX packet through bond_alb_xmit() and af_packet and triggered a use-after-free.
First, bond_alb_xmit() was using ipx_hdr() helper to reach the IPX header, but ipx_hdr() was using the transport offset instead of the network offset. In the particular syzbot report transport offset was 0xFFFF
This patch removes ipx_hdr() since it was only (mis)used from bonding.
Then we need to make sure IPv4/IPv6/IPX headers are pulled in skb->head before dereferencing anything.
BUG: KASAN: use-after-free in bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452 Read of size 2 at addr ffff8801ce56dfff by task syz-executor.2/18108 (if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) ...) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: [<ffffffff8441fc42>] __dump_stack lib/dump_stack.c:17 [inline] [<ffffffff8441fc42>] dump_stack+0x14d/0x20b lib/dump_stack.c:53 [<ffffffff81a7dec4>] print_address_description+0x6f/0x20b mm/kasan/report.c:282 [<ffffffff81a7e0ec>] kasan_report_error mm/kasan/report.c:380 [inline] [<ffffffff81a7e0ec>] kasan_report mm/kasan/report.c:438 [inline] [<ffffffff81a7e0ec>] kasan_report.cold+0x8c/0x2a0 mm/kasan/report.c:422 [<ffffffff81a7dc4f>] __asan_report_load_n_noabort+0xf/0x20 mm/kasan/report.c:469 [<ffffffff82c8c00a>] bond_alb_xmit+0x153a/0x1590 drivers/net/bonding/bond_alb.c:1452 [<ffffffff82c60c74>] __bond_start_xmit drivers/net/bonding/bond_main.c:4199 [inline] [<ffffffff82c60c74>] bond_start_xmit+0x4f4/0x1570 drivers/net/bonding/bond_main.c:4224 [<ffffffff83baa558>] __netdev_start_xmit include/linux/netdevice.h:4525 [inline] [<ffffffff83baa558>] netdev_start_xmit include/linux/netdevice.h:4539 [inline] [<ffffffff83baa558>] xmit_one net/core/dev.c:3611 [inline] [<ffffffff83baa558>] dev_hard_start_xmit+0x168/0x910 net/core/dev.c:3627 [<ffffffff83bacf35>] __dev_queue_xmit+0x1f55/0x33b0 net/core/dev.c:4238 [<ffffffff83bae3a8>] dev_queue_xmit+0x18/0x20 net/core/dev.c:4278 [<ffffffff84339189>] packet_snd net/packet/af_packet.c:3226 [inline] [<ffffffff84339189>] packet_sendmsg+0x4919/0x70b0 net/packet/af_packet.c:3252 [<ffffffff83b1ac0c>] sock_sendmsg_nosec net/socket.c:673 [inline] [<ffffffff83b1ac0c>] sock_sendmsg+0x12c/0x160 net/socket.c:684 [<ffffffff83b1f5a2>] __sys_sendto+0x262/0x380 net/socket.c:1996 [<ffffffff83b1f700>] SYSC_sendto net/socket.c:2008 [inline] [<ffffffff83b1f700>] SyS_sendto+0x40/0x60 net/socket.c:2004
--- drivers/net/bonding/bond_alb.c | 44 +++++++++++++++++++++++++++++------------ include/net/ipx.h | 5 ---- 2 files changed, 32 insertions(+), 17 deletions(-)
drivers/net/bonding/bond_alb.c +32 -12
@@ -1383,26 +1383,31 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbool do_tx_balance = true;u32 hash_index =0 ;const u8 *hash_start =NULL ; -struct ipv6hdr *ip6hdr;skb_reset_mac_header (skb); eth_data =eth_hdr (skb);switch (ntohs (skb->protocol)) {case ETH_P_IP : { -const struct iphdr *iph =ip_hdr (skb); +const struct iphdr *iph;if (is_broadcast_ether_addr (eth_data->h_dest) || - iph->daddr == ip_bcast || - iph->protocol ==IPPROTO_IGMP ) { + !pskb_network_may_pull (skb,sizeof (*iph))) { + do_tx_balance = false; +break ; + } + iph =ip_hdr (skb); +if (iph->daddr == ip_bcast || iph->protocol ==IPPROTO_IGMP ) { do_tx_balance = false;break ; } hash_start = (char *)&(iph->daddr); hash_size =sizeof (iph->daddr); - }break ; -case ETH_P_IPV6 : + } +case ETH_P_IPV6 : { +const struct ipv6hdr *ip6hdr; +/* IPv6 doesn't really use broadcast mac address, but leave * that here just in case. */
@@ -1419,7 +1424,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } -/* Additianally, DAD probes should not be tx-balanced as that +if (!pskb_network_may_pull (skb,sizeof (*ip6hdr))) { + do_tx_balance = false; +break ; + } +/* Additionally, DAD probes should not be tx-balanced as that * will lead to false positives for duplicate addresses and * prevent address configuration from working. */
@@ -1429,17 +1438,26 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } - hash_start = (char *)&(ipv6_hdr (skb)->daddr); - hash_size =sizeof (ipv6_hdr (skb)->daddr); + hash_start = (char *)&ip6hdr->daddr; + hash_size =sizeof (ip6hdr->daddr);break ; -case ETH_P_IPX : -if (ipx_hdr (skb)->ipx_checksum !=IPX_NO_CHECKSUM ) { + } +case ETH_P_IPX : { +const struct ipxhdr *ipxhdr; + +if (pskb_network_may_pull (skb,sizeof (*ipxhdr))) { + do_tx_balance = false; +break ; + } + ipxhdr = (struct ipxhdr *)skb_network_header (skb); + +if (ipxhdr->ipx_checksum !=IPX_NO_CHECKSUM ) {/* something is wrong with this packet */ do_tx_balance = false;break ; } -if (ipx_hdr (skb)->ipx_type !=IPX_TYPE_NCP ) { +if (ipxhdr->ipx_type !=IPX_TYPE_NCP ) {/* The only protocol worth balancing in * this family since it has an "ARP" like * mechanism
@@ -1448,9 +1466,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buffbreak ; } + eth_data =eth_hdr (skb); hash_start = (char *)eth_data->h_dest; hash_size =ETH_ALEN ;break ; + }case ETH_P_ARP : do_tx_balance = false;if (bond_info->rlb_enabled)
include/net/ipx.h +0 -5
@@ -47,11 +47,6 @@ struct ipxhdr {/* From af_ipx.c */ extern int sysctl_ipx_pprop_broadcasting; -static __inline__struct ipxhdr *ipx_hdr (struct sk_buff *skb) -{ -return (struct ipxhdr *)skb_transport_header (skb); -} -struct ipx_interface {/* IPX address */ __be32 if_netnum;
Greg Kroah-Hartman
maintainerPATCH 319/367 net: dsa: b53: Always use dev->vlan_enabled in b53_configure_vlan()
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit df373702bc0f8f2d83980ea441e71639fc1efcf8 ]
b53_configure_vlan() is called by the bcm_sf2 driver upon setup and indirectly through resume as well. During the initial setup, we are guaranteed that dev->vlan_enabled is false, so there is no change in behavior, however during suspend, we may have enabled VLANs before, so we do want to restore that setting.
--- drivers/net/dsa/b53/b53_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/b53/b53_common.c +1 -1
@@ -680,7 +680,7 @@ int b53_configure_vlan(struct dsa_switchb53_do_vlan_op (dev,VTA_CMD_CLEAR ); } -b53_enable_vlan (dev, false, ds->vlan_filtering); +b53_enable_vlan (dev, dev->vlan_enabled, ds->vlan_filtering);b53_for_each_port (dev, i) b53_write16(dev, B53_VLAN_PAGE,
Greg Kroah-Hartman
maintainerPATCH 326/367 net/mlx5: IPsec, Fix esp modify function attribute
In reply to Greg Kroah-HartmanFrom: Raed Salem <[email protected]>
[ Upstream commit 0dc2c534f17c05bed0622b37a744bc38b48ca88a ]
The function mlx5_fpga_esp_validate_xfrm_attrs is wrongly used with negative negation as zero value indicates success but it used as failure return value instead.
Fix by remove the unary not negation operator.
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +1 -1
@@ -1478,7 +1478,7 @@ int mlx5_fpga_esp_modify_xfrm(struct mlxif (!memcmp (&xfrm->attrs, attrs,sizeof (xfrm->attrs)))return 0 ; -if (!mlx5_fpga_esp_validate_xfrm_attrs (mdev, attrs)) { +if (mlx5_fpga_esp_validate_xfrm_attrs (mdev, attrs)) {mlx5_core_warn (mdev,"Tried to create an esp with unsupported attrs\n" );return -EOPNOTSUPP ; }
Greg Kroah-Hartman
maintainerPATCH 348/367 cifs: fix mode bits from dir listing when mounted with modefromsid
In reply to Greg Kroah-HartmanFrom: Aurelien Aptel <[email protected]>
commit e3e056c35108661e418c803adfc054bf683426e7 upstream.
When mounting with -o modefromsid, the mode bits are stored in an ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir which does not include ACEs in its response. The mode bits in this case are silently set to a default value of 755 instead.
This patch marks the dentry created during the directory enumeration as needing re-evaluation (i.e. additional Query Info with ACEs) so that the mode bits can be properly extracted.
Quick repro:
$ mount.cifs //win19.test/data /mnt -o ...,modefromsid $ touch /mnt/foo && chmod 751 /mnt/foo $ stat /mnt/foo # reports 751 (OK) $ sleep 2 # dentry older than 1s by default get invalidated $ ls -l /mnt # since dentry invalid, ls does a Query Dir # and reports foo as 755 (WRONG)
--- fs/cifs/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/readdir.c +2 -1
@@ -196,7 +196,8 @@ cifs_fill_common_info(struct cifs_fattr* may look wrong since the inodes may not have timed out by the time * "ls" does a stat() call on them. */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) +if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) || + (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID )) fattr->cf_flags |=CIFS_FATTR_NEED_REVAL ; if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&
Greg Kroah-Hartman
maintainerPATCH 351/367 perf/core: Fix mlock accounting in perf_mmap()
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
commit 003461559ef7a9bd0239bae35a22ad8924d6e9ad upstream.
Decreasing sysctl_perf_event_mlock between two consecutive perf_mmap()s of a perf ring buffer may lead to an integer underflow in locked memory accounting. This may lead to the undesired behaviors, such as failures in BPF map creation.
Address this by adjusting the accounting logic to take into account the possibility that the amount of already locked memory may exceed the current limit.
--- kernel/events/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/events/core.c +9 -1
@@ -5916,7 +5916,15 @@ accounting:*/ user_lock_limit *=num_online_cpus (); - user_locked =atomic_long_read (&user->locked_vm) + user_extra; + user_locked =atomic_long_read (&user->locked_vm); + +/* +* sysctl_perf_event_mlock may have changed, so that +* user->locked_vm > user_lock_limit +*/ +if (user_locked > user_lock_limit) + user_locked = user_lock_limit; + user_locked += user_extra;if (user_locked > user_lock_limit) {/*
Greg Kroah-Hartman
maintainerPATCH 352/367 perf/cgroups: Install cgroup events to correct cpuctx
In reply to Greg Kroah-HartmanFrom: Song Liu <[email protected]>
commit 07c5972951f088094776038006a0592a46d14bbc upstream.
cgroup events are always installed in the cpuctx. However, when it is not installed via IPI, list_update_cgroup_event() adds it to cpuctx of current CPU, which triggers list corruption:
[] list_add double add: new=ffff888ff7cf0db0, prev=ffff888ff7ce82f0, next=ffff888ff7cf0db0.
To reproduce this, we can simply run:
# perf stat -e cs -a & # perf stat -e cs -G anycgroup
Fix this by installing it to cpuctx that contains event->ctx, and the proper cgrp_cpuctx_list.
--- kernel/events/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/events/core.c +4 -3
@@ -951,9 +951,9 @@ list_update_cgroup_event(struct perf_eve/* * Because cgroup events are always per-cpu events, -* this will always be called from the right CPU. +* @ctx == &cpuctx->ctx. */ - cpuctx =__get_cpu_context (ctx); + cpuctx = container_of(ctx, struct perf_cpu_context, ctx);/* * Since setting cpuctx->cgrp is conditional on the current @cgrp
@@ -979,7 +979,8 @@ list_update_cgroup_event(struct perf_eve cpuctx_entry = &cpuctx->cgrp_cpuctx_entry;if (add) -list_add (cpuctx_entry,this_cpu_ptr (&cgrp_cpuctx_list)); +list_add (cpuctx_entry, +per_cpu_ptr (&cgrp_cpuctx_list, event->cpu));else list_del (cpuctx_entry); }
Greg Kroah-Hartman
maintainerPATCH 356/367 KVM: x86: Protect exit_reason from being used in Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
[ Upstream commit c926f2f7230b1a29e31914b51db680f8cbf3103f ]
This fixes a Spectre-v1/L1TF vulnerability in vmx_handle_exit(). While exit_reason is set by the hardware and therefore should not be attacker-influenced, an unknown exit_reason could potentially be used to perform such an attack.
--- arch/x86/kvm/vmx/vmx.c | 55 +++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-)
arch/x86/kvm/vmx/vmx.c +30 -25
@@ -5904,34 +5904,39 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu) } } -if (exit_reason < kvm_vmx_max_exit_handlers - && kvm_vmx_exit_handlers[exit_reason]) { +if (exit_reason >= kvm_vmx_max_exit_handlers) + goto unexpected_vmexit;#ifdef CONFIG_RETPOLINE -if (exit_reason ==EXIT_REASON_MSR_WRITE ) -return kvm_emulate_wrmsr (vcpu); -else if (exit_reason ==EXIT_REASON_PREEMPTION_TIMER ) -return handle_preemption_timer (vcpu); -else if (exit_reason ==EXIT_REASON_PENDING_INTERRUPT ) -return handle_interrupt_window (vcpu); -else if (exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT ) -return handle_external_interrupt (vcpu); -else if (exit_reason ==EXIT_REASON_HLT ) -return kvm_emulate_halt (vcpu); -else if (exit_reason ==EXIT_REASON_EPT_MISCONFIG ) -return handle_ept_misconfig (vcpu); +if (exit_reason ==EXIT_REASON_MSR_WRITE ) +return kvm_emulate_wrmsr (vcpu); +else if (exit_reason ==EXIT_REASON_PREEMPTION_TIMER ) +return handle_preemption_timer (vcpu); +else if (exit_reason ==EXIT_REASON_PENDING_INTERRUPT ) +return handle_interrupt_window (vcpu); +else if (exit_reason ==EXIT_REASON_EXTERNAL_INTERRUPT ) +return handle_external_interrupt (vcpu); +else if (exit_reason ==EXIT_REASON_HLT ) +return kvm_emulate_halt (vcpu); +else if (exit_reason ==EXIT_REASON_EPT_MISCONFIG ) +return handle_ept_misconfig (vcpu);#endif -return kvm_vmx_exit_handlers[exit_reason](vcpu); - }else { -vcpu_unimpl (vcpu,"vmx: unexpected exit reason 0x%x\n" , - exit_reason); -dump_vmcs (); - vcpu->run->exit_reason =KVM_EXIT_INTERNAL_ERROR ; - vcpu->run->internal.suberror = + + exit_reason =array_index_nospec (exit_reason, + kvm_vmx_max_exit_handlers); +if (!kvm_vmx_exit_handlers[exit_reason]) + goto unexpected_vmexit; + +return kvm_vmx_exit_handlers[exit_reason](vcpu); + +unexpected_vmexit: +vcpu_unimpl (vcpu,"vmx: unexpected exit reason 0x%x\n" , exit_reason); +dump_vmcs (); + vcpu->run->exit_reason =KVM_EXIT_INTERNAL_ERROR ; + vcpu->run->internal.suberror =KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON ; - vcpu->run->internal.ndata =1 ; - vcpu->run->internal.data[0 ] = exit_reason; -return 0 ; - } + vcpu->run->internal.ndata =1 ; + vcpu->run->internal.data[0 ] = exit_reason; +return 0 ; }/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 358/367 KVM: Use vcpu-specific gva->hva translation when querying host page size
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit f9b84e19221efc5f493156ee0329df3142085f28 ]
Use kvm_vcpu_gfn_to_hva() when retrieving the host page size so that the correct set of memslots is used when handling x86 page faults in SMM.
--- arch/powerpc/kvm/book3s_xive_native.c | 2 +- arch/x86/kvm/mmu/mmu.c | 6 +++--- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/kvm/book3s_xive_native.c +1 -1
@@ -631,7 +631,7 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive, srcu_idx =srcu_read_lock (&kvm->srcu); gfn =gpa_to_gfn (kvm_eq.qaddr); - page_size =kvm_host_page_size (kvm, gfn); + page_size =kvm_host_page_size (vcpu, gfn);if (1ull << kvm_eq.qshift > page_size) {srcu_read_unlock (&kvm->srcu, srcu_idx);pr_warn ("Incompatible host page size %lx!\n" , page_size);
arch/x86/kvm/mmu/mmu.c +3 -3
@@ -1286,12 +1286,12 @@ static bool mmu_gfn_lpage_is_disallowed(struct kvm_vcpu *vcpu, gfn_t gfn,return __mmu_gfn_lpage_is_disallowed (gfn, level, slot); } -static int host_mapping_level (struct kvm *kvm,gfn_t gfn) +static int host_mapping_level (struct kvm_vcpu *vcpu,gfn_t gfn) {unsigned long page_size;int i, ret =0 ; - page_size =kvm_host_page_size (kvm, gfn); + page_size =kvm_host_page_size (vcpu, gfn);for (i =PT_PAGE_TABLE_LEVEL ; i <=PT_MAX_HUGEPAGE_LEVEL ; ++i) {if (page_size >=KVM_HPAGE_SIZE (i))
@@ -1341,7 +1341,7 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn,if (unlikely (*force_pt_level))return PT_PAGE_TABLE_LEVEL ; - host_level =host_mapping_level (vcpu->kvm, large_gfn); + host_level =host_mapping_level (vcpu, large_gfn);if (host_level ==PT_PAGE_TABLE_LEVEL )return host_level;
include/linux/kvm_host.h +1 -1
@@ -768,7 +768,7 @@ int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);int kvm_clear_guest (struct kvm *kvm,gpa_t gpa,unsigned long len);struct kvm_memory_slot *gfn_to_memslot (struct kvm *kvm,gfn_t gfn);bool kvm_is_visible_gfn (struct kvm *kvm,gfn_t gfn); -unsigned long kvm_host_page_size (struct kvm *kvm,gfn_t gfn); +unsigned long kvm_host_page_size (struct kvm_vcpu *vcpu,gfn_t gfn);void mark_page_dirty (struct kvm *kvm,gfn_t gfn);struct kvm_memslots *kvm_vcpu_memslots (struct kvm_vcpu *vcpu);
virt/kvm/kvm_main.c +2 -2
@@ -1406,14 +1406,14 @@ bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn) }EXPORT_SYMBOL_GPL (kvm_is_visible_gfn); -unsigned long kvm_host_page_size (struct kvm *kvm,gfn_t gfn) +unsigned long kvm_host_page_size (struct kvm_vcpu *vcpu,gfn_t gfn) {struct vm_area_struct *vma;unsigned long addr, size; size =PAGE_SIZE ; - addr =gfn_to_hva (kvm, gfn); + addr =kvm_vcpu_gfn_to_hva (vcpu, gfn);if (kvm_is_error_hva (addr))return PAGE_SIZE ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 366/367 regulator fix for "regulator: core: Add regulator_is_equal() helper"
In reply to Greg Kroah-HartmanFrom: Stephen Rothwell <[email protected]>
[ Upstream commit 0468e667a5bead9c1b7ded92861b5a98d8d78745 ]
--- include/linux/regulator/consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/regulator/consumer.h +1 -1
@@ -596,7 +596,7 @@ regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, }static inline bool -regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +regulator_is_equal (struct regulator *reg1,struct regulator *reg2) {return false; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 367/367 powerpc/kuap: Fix set direction in allow/prevent_user_access()
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit 1d8f739b07bd538f272f60bf53f10e7e6248d295 ]
__builtin_constant_p() always return 0 for pointers, so on RADIX we always end up opening both direction (by writing 0 in SPR29):
0000000000000170 <._copy_to_user>:
...
1b0: 4c 00 01 2c isync
1b4: 39 20 00 00 li r9,0
1b8: 7d 3d 03 a6 mtspr 29,r9
1bc: 4c 00 01 2c isync
1c0: 48 00 00 01 bl 1c0 <._copy_to_user+0x50>
1c0: R_PPC64_REL24 .__copy_tofrom_user
...
0000000000000220 <._copy_from_user>:
...
2ac: 4c 00 01 2c isync
2b0: 39 20 00 00 li r9,0
2b4: 7d 3d 03 a6 mtspr 29,r9
2b8: 4c 00 01 2c isync
2bc: 7f c5 f3 78 mr r5,r30 2c0: 7f 83 e3 78 mr r3,r28 2c4: 48 00 00 01 bl 2c4 <._copy_from_user+0xa4>
2c4: R_PPC64_REL24 .__copy_tofrom_user
...
Use an explicit parameter for direction selection, so that GCC is able to see it is a constant:
00000000000001b0 <._copy_to_user>:
...
1f0: 4c 00 01 2c isync
1f4: 3d 20 40 00 lis r9,16384 1f8: 79 29 07 c6 rldicr r9,r9,32,31 1fc: 7d 3d 03 a6 mtspr 29,r9 200: 4c 00 01 2c isync 204: 48 00 00 01 bl 204 <._copy_to_user+0x54> 204: R_PPC64_REL24 .__copy_tofrom_user ... 0000000000000260 <._copy_from_user>: ... 2ec: 4c 00 01 2c isync 2f0: 39 20 ff ff li r9,-1 2f4: 79 29 00 04 rldicr r9,r9,0,0 2f8: 7d 3d 03 a6 mtspr 29,r9 2fc: 4c 00 01 2c isync 300: 7f c5 f3 78 mr r5,r30 304: 7f 83 e3 78 mr r3,r28 308: 48 00 00 01 bl 308 <._copy_from_user+0xa8>
308: R_PPC64_REL24 .__copy_tofrom_user
...
--- arch/powerpc/include/asm/book3s/32/kup.h | 13 ++++++-- .../powerpc/include/asm/book3s/64/kup-radix.h | 11 +++---- arch/powerpc/include/asm/kup.h | 30 ++++++++++++++----- arch/powerpc/include/asm/nohash/32/kup-8xx.h | 4 +-- arch/powerpc/include/asm/uaccess.h | 4 +-- 5 files changed, 43 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/book3s/32/kup.h +10 -3
@@ -102,11 +102,13 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end)isync ();/* Context sync required after mtsrin() */ } -static inline void allow_user_access (void __user *to,const void __user *from,u32 size) +static __always_inline void allow_user_access(void __user *to, const void __user *from, +u32 size,unsigned long dir) {u32 addr, end; -if (__builtin_constant_p (to) && to ==NULL ) +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (!(dir &KUAP_WRITE ))return ; addr = (__force u32 )to;
@@ -119,11 +121,16 @@ static inline void allow_user_access(void __user *to, const void __user *from, ukuap_update_sr (mfsrin (addr) & ~SR_KS , addr, end);/* Clear Ks */ } -static inline void prevent_user_access (void __user *to,const void __user *from,u32 size) +static __always_inline void prevent_user_access(void __user *to, const void __user *from, +u32 size,unsigned long dir) {u32 addr = (__force u32 )to;u32 end =min (addr + size,TASK_SIZE ); +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (!(dir &KUAP_WRITE )) +return ; +if (!addr || addr >=TASK_SIZE || !size)return ;
arch/powerpc/include/asm/book3s/64/kup-radix.h +6 -5
@@ -77,20 +77,21 @@ static inline void set_kuap(unsigned long value)isync (); } -static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) +static __always_inline void allow_user_access(void __user *to, const void __user *from, +unsigned long size,unsigned long dir) {// This is written so we can resolve to a single case at build time -if (__builtin_constant_p (to) && to ==NULL ) +BUILD_BUG_ON (!__builtin_constant_p (dir)); +if (dir ==KUAP_READ )set_kuap (AMR_KUAP_BLOCK_WRITE ); -else if (__builtin_constant_p (from) && from ==NULL ) +else if (dir ==KUAP_WRITE )set_kuap (AMR_KUAP_BLOCK_READ );else set_kuap (0 ); }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {set_kuap (AMR_KUAP_BLOCKED ); }
arch/powerpc/include/asm/kup.h +23 -7
@@ -2,6 +2,10 @@#ifndef _ASM_POWERPC_KUP_H_#define _ASM_POWERPC_KUP_H_ +#define KUAP_READ 1 +#define KUAP_WRITE 2 +#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE) +#ifdef CONFIG_PPC64 #include <asm/book3s/64/kup-radix.h> #endif
@@ -42,9 +46,9 @@ void setup_kuap(bool disabled);#else static inline void setup_kuap (bool disabled) { }static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) { } +unsigned long size,unsigned long dir) { }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) { } +unsigned long size,unsigned long dir) { }static inline bool bad_kuap_fault (struct pt_regs *regs,unsigned long address,bool is_write) {
@@ -54,24 +58,36 @@ bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)static inline void allow_read_from_user (const void __user *from,unsigned long size) { -allow_user_access (NULL , from, size); +allow_user_access (NULL , from, size,KUAP_READ ); }static inline void allow_write_to_user (void __user *to,unsigned long size) { -allow_user_access (to,NULL , size); +allow_user_access (to,NULL , size,KUAP_WRITE ); +} + +static inline void allow_read_write_user (void __user *to,const void __user *from, +unsigned long size) +{ +allow_user_access (to, from, size,KUAP_READ_WRITE ); }static inline void prevent_read_from_user (const void __user *from,unsigned long size) { -prevent_user_access (NULL , from, size); +prevent_user_access (NULL , from, size,KUAP_READ ); }static inline void prevent_write_to_user (void __user *to,unsigned long size) { -prevent_user_access (to,NULL , size); +prevent_user_access (to,NULL , size,KUAP_WRITE ); +} + +static inline void prevent_read_write_user (void __user *to,const void __user *from, +unsigned long size) +{ +prevent_user_access (to, from, size,KUAP_READ_WRITE ); }#endif /* !__ASSEMBLY__ */ -#endif /* _ASM_POWERPC_KUP_H_ */ +#endif /* _ASM_POWERPC_KUAP_H_ */
arch/powerpc/include/asm/nohash/32/kup-8xx.h +2 -2
@@ -35,13 +35,13 @@#include <asm/reg.h> static inline void allow_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {mtspr (SPRN_MD_AP ,MD_APG_INIT ); }static inline void prevent_user_access (void __user *to,const void __user *from, -unsigned long size) +unsigned long size,unsigned long dir) {mtspr (SPRN_MD_AP ,MD_APG_KUAP ); }
arch/powerpc/include/asm/uaccess.h +2 -2
@@ -313,9 +313,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n)unsigned long ret;barrier_nospec (); -allow_user_access (to, from, n); +allow_read_write_user (to, from, n); ret =__copy_tofrom_user (to, from, n); -prevent_user_access (to, from, n); +prevent_read_write_user (to, from, n); return ret; }#endif /* __powerpc64__ */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 13/367 tcp: clear tp->data_segs{in|out} in tcp_disconnect()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit db7ffee6f3eb3683cdcaeddecc0a630a14546fe3 ]
tp->data_segs_in and tp->data_segs_out need to be cleared in tcp_disconnect().
tcp_disconnect() is rarely used, but it is worth fixing it.
--- net/ipv4/tcp.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/tcp.c +2 -0
@@ -2642,6 +2642,8 @@ int tcp_disconnect(struct sock *sk, int tp->bytes_acked =0 ; tp->bytes_received =0 ; tp->bytes_retrans =0 ; + tp->data_segs_in =0 ; + tp->data_segs_out =0 ; tp->duplicate_sack[0 ].start_seq =0 ; tp->duplicate_sack[0 ].end_seq =0 ; tp->dsack_dups =0 ;
Greg Kroah-Hartman
maintainerPATCH 22/367 bnxt_en: Fix RDMA driver failure with SRIOV after firmware reset.
In reply to Greg Kroah-HartmanFrom: Michael Chan <[email protected]>
[ Upstream commit 12de2eadf87825c3990c1aa68b5e93101ca2f043 ]
bnxt_ulp_start() needs to be called before SRIOV is re-enabled after firmware reset. Re-enabling SRIOV may consume all the resources and may cause the RDMA driver to fail to get MSIX and other resources. Fix it by calling bnxt_ulp_start() first before calling bnxt_reenable_sriov().
We re-arrange the logic so that we call bnxt_ulp_start() and bnxt_reenable_sriov() in proper sequence in bnxt_fw_reset_task() and bnxt_open(). The former is the normal coordinated firmware reset sequence and the latter is firmware reset while the function is down. This new logic is now more straight forward and will now fix both scenarios.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +5 -2
@@ -9269,9 +9269,10 @@ static int bnxt_open(struct net_device *bnxt_hwrm_if_change (bp, false); }else {if (test_and_clear_bit (BNXT_STATE_FW_RESET_DET , &bp->state)) { -bnxt_reenable_sriov (bp); -if (!test_bit (BNXT_STATE_IN_FW_RESET , &bp->state)) +if (!test_bit (BNXT_STATE_IN_FW_RESET , &bp->state)) {bnxt_ulp_start (bp,0 ); +bnxt_reenable_sriov (bp); + } }bnxt_hwmon_open (bp); }
@@ -10827,6 +10828,8 @@ static void bnxt_fw_reset_task(struct wosmp_mb__before_atomic ();clear_bit (BNXT_STATE_IN_FW_RESET , &bp->state);bnxt_ulp_start (bp, rc); +if (!rc) +bnxt_reenable_sriov (bp);bnxt_dl_health_status_update (bp, true);rtnl_unlock ();break ;
Greg Kroah-Hartman
maintainerPATCH 25/367 netdevsim: fix stack-out-of-bounds in nsim_dev_debugfs_init()
In reply to Greg Kroah-HartmanFrom: Taehee Yoo <[email protected]>
[ Upstream commit 6fb8852b1298200da39bd85788bc5755d1d56f32 ]
When netdevsim dev is being created, a debugfs directory is created. The variable "dev_ddir_name" is 16bytes device name pointer and device name is "netdevsim<dev id>".
The maximum dev id length is 10.
So, 16bytes for device name isn't enough.
Test commands:
modprobe netdevsim
echo "1000000000 0" > /sys/bus/netdevsim/new_deviceSplat looks like:
[ 249.622710][ T900] BUG: KASAN: stack-out-of-bounds in number+0x824/0x880 [ 249.623658][ T900] Write of size 1 at addr ffff88804c527988 by task bash/900 [ 249.624521][ T900] [ 249.624830][ T900] CPU: 1 PID: 900 Comm: bash Not tainted 5.5.0+ #322 [ 249.625691][ T900] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [ 249.626712][ T900] Call Trace: [ 249.627103][ T900] dump_stack+0x96/0xdb [ 249.627639][ T900] ? number+0x824/0x880 [ 249.628173][ T900] print_address_description.constprop.5+0x1be/0x360 [ 249.629022][ T900] ? number+0x824/0x880 [ 249.629569][ T900] ? number+0x824/0x880 [ 249.630105][ T900] __kasan_report+0x12a/0x170 [ 249.630717][ T900] ? number+0x824/0x880 [ 249.631201][ T900] kasan_report+0xe/0x20 [ 249.631723][ T900] number+0x824/0x880 [ 249.632235][ T900] ? put_dec+0xa0/0xa0 [ 249.632716][ T900] ? rcu_read_lock_sched_held+0x90/0xc0 [ 249.633392][ T900] vsnprintf+0x63c/0x10b0 [ 249.633983][ T900] ? pointer+0x5b0/0x5b0 [ 249.634543][ T900] ? mark_lock+0x11d/0xc40 [ 249.635200][ T900] sprintf+0x9b/0xd0 [ 249.635750][ T900] ? scnprintf+0xe0/0xe0 [ 249.636370][ T900] nsim_dev_probe+0x63c/0xbf0 [netdevsim]
[ ... ]
--- drivers/net/netdevsim/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netdevsim/dev.c +1 -1
@@ -73,7 +73,7 @@ static const struct file_operations nsimstatic int nsim_dev_debugfs_init (struct nsim_dev *nsim_dev) { -char dev_ddir_name[16 ]; +char dev_ddir_name[sizeof (DRV_NAME ) +10 ];sprintf (dev_ddir_name,DRV_NAME "%u" , nsim_dev->nsim_bus_dev->dev.id); nsim_dev->ddir =debugfs_create_dir (dev_ddir_name, nsim_dev_ddir);
Greg Kroah-Hartman
maintainerPATCH 38/367 nvmet: Fix error print message at nvmet_install_queue function
In reply to Greg Kroah-HartmanFrom: Israel Rukshin <[email protected]>
commit 0b87a2b795d66be7b54779848ef0f3901c5e46fc upstream.
Place the arguments in the correct order.
--- drivers/nvme/target/fabrics-cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd.c +1 -1
@@ -136,7 +136,7 @@ static u16 nvmet_install_queue(struct nvif (ret) {pr_err ("failed to install queue %d cntlid %d ret %x\n" , - qid, ret, ctrl->cntlid); + qid, ctrl->cntlid, ret);return ret; } }
Greg Kroah-Hartman
maintainerPATCH 48/367 usb: gadget: legacy: set max_speed to super-speed
In reply to Greg Kroah-HartmanFrom: Roger Quadros <[email protected]>
commit 463f67aec2837f981b0a0ce8617721ff59685c00 upstream.
These interfaces do support super-speed so let's not limit maximum speed to high-speed.
--- drivers/usb/gadget/legacy/cdc2.c | 2 +- drivers/usb/gadget/legacy/g_ffs.c | 2 +- drivers/usb/gadget/legacy/multi.c | 2 +- drivers/usb/gadget/legacy/ncm.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/legacy/cdc2.c +1 -1
@@ -225,7 +225,7 @@ static struct usb_composite_driver cdc_d .name = "g_cdc", .dev = &device_desc, .strings = dev_strings, - .max_speed = USB_SPEED_HIGH, + .max_speed = USB_SPEED_SUPER, .bind = cdc_bind, .unbind = cdc_unbind, };
drivers/usb/gadget/legacy/g_ffs.c +1 -1
@@ -149,7 +149,7 @@ static struct usb_composite_driver gfs_d .name = DRIVER_NAME, .dev = &gfs_dev_desc, .strings = gfs_dev_strings, - .max_speed = USB_SPEED_HIGH, + .max_speed = USB_SPEED_SUPER, .bind = gfs_bind, .unbind = gfs_unbind, };
drivers/usb/gadget/legacy/multi.c +1 -1
@@ -482,7 +482,7 @@ static struct usb_composite_driver multi .name = "g_multi", .dev = &device_desc, .strings = dev_strings, - .max_speed = USB_SPEED_HIGH, + .max_speed = USB_SPEED_SUPER, .bind = multi_bind, .unbind = multi_unbind, .needs_serial = 1,
drivers/usb/gadget/legacy/ncm.c +1 -1
@@ -197,7 +197,7 @@ static struct usb_composite_driver ncm_d .name = "g_ncm", .dev = &device_desc, .strings = dev_strings, - .max_speed = USB_SPEED_HIGH, + .max_speed = USB_SPEED_SUPER, .bind = gncm_bind, .unbind = gncm_unbind, };
Greg Kroah-Hartman
maintainerPATCH 53/367 ALSA: dummy: Fix PCM format loop in proc output
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 2acf25f13ebe8beb40e97a1bbe76f36277c64f1e upstream.
The loop termination for iterating over all formats should contain SNDRV_PCM_FORMAT_LAST, not less than it.
--- sound/drivers/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/dummy.c +1 -1
@@ -915,7 +915,7 @@ static void print_formats(struct snd_dum {int i; -for (i =0 ; i <SNDRV_PCM_FORMAT_LAST ; i++) { +for (i =0 ; i <=SNDRV_PCM_FORMAT_LAST ; i++) {if (dummy->pcm_hw.formats & (1ULL << i))snd_iprintf (buffer," %s" ,snd_pcm_format_name (i)); }
Greg Kroah-Hartman
maintainerPATCH 33/367 tracing: Fix sched switch start/stop refcount racy updates
In reply to Greg Kroah-HartmanFrom: Mathieu Desnoyers <[email protected]>
commit 64ae572bc7d0060429e40e1c8d803ce5eb31a0d6 upstream.
Reading the sched_cmdline_ref and sched_tgid_ref initial state within tracing_start_sched_switch without holding the sched_register_mutex is racy against concurrent updates, which can lead to tracepoint probes being registered more than once (and thus trigger warnings within tracepoint.c).
--- kernel/trace/trace_sched_switch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_sched_switch.c +3 -1
@@ -89,8 +89,10 @@ static void tracing_sched_unregister(voistatic void tracing_start_sched_switch (int ops) { -bool sched_register = (!sched_cmdline_ref && !sched_tgid_ref); +bool sched_register; +mutex_lock (&sched_register_mutex); + sched_register = (!sched_cmdline_ref && !sched_tgid_ref);switch (ops) {case RECORD_CMDLINE :
Greg Kroah-Hartman
maintainerPATCH 70/367 ALSA: hda: Add JasperLake PCI ID and codec vid
In reply to Greg Kroah-HartmanFrom: Yong Zhi <[email protected]>
commit 78be2228c15dd45865b102b29d72e721f0ace9b1 upstream.
Add HD Audio Device PCI ID and codec vendor_id for the Intel JasperLake REV2/A0 silicon.
--- sound/pci/hda/hda_intel.c | 2 ++ sound/pci/hda/patch_hdmi.c | 1 + 2 files changed, 3 insertions(+)
sound/pci/hda/hda_intel.c +2 -0
@@ -2449,6 +2449,8 @@ static const struct pci_device_id azx_id/* Jasperlake */ { PCI_DEVICE(0x8086, 0x38c8), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, + { PCI_DEVICE(0x8086, 0x4dc8), + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, /* Tigerlake */ { PCI_DEVICE(0x8086, 0xa0c8), .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE},
sound/pci/hda/patch_hdmi.c +1 -0
@@ -4250,6 +4250,7 @@ HDA_CODEC_ENTRY(0x8086280c, "CannonlakeHDA_CODEC_ENTRY (0x8086280d ,"Geminilake HDMI" , patch_i915_glk_hdmi),HDA_CODEC_ENTRY (0x8086280f ,"Icelake HDMI" , patch_i915_icl_hdmi),HDA_CODEC_ENTRY (0x80862812 ,"Tigerlake HDMI" , patch_i915_tgl_hdmi), +HDA_CODEC_ENTRY (0x8086281a ,"Jasperlake HDMI" , patch_i915_icl_hdmi),HDA_CODEC_ENTRY (0x80862880 ,"CedarTrail HDMI" , patch_generic_hdmi),HDA_CODEC_ENTRY (0x80862882 ,"Valleyview2 HDMI" , patch_i915_byt_hdmi), HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi),
Greg Kroah-Hartman
maintainerPATCH 80/367 MIPS: SGI-IP30: Check for valid pointer before using it
In reply to Greg Kroah-HartmanFrom: Thomas Bogendoerfer <[email protected]>
commit c0e79fd89749b0cda1c72049e2772dd2eeada86f upstream.
Fix issue detected by Smatch:
./arch/mips/sgi-ip30/ip30-irq.c:236 heart_domain_free()
warn: variable dereferenced before check 'irqd' (see line 235)
--- arch/mips/sgi-ip30/ip30-irq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/sgi-ip30/ip30-irq.c +3 -2
@@ -232,9 +232,10 @@ static void heart_domain_free(struct irqreturn ; irqd =irq_domain_get_irq_data (domain, virq); -clear_bit (irqd->hwirq, heart_irq_map); -if (irqd && irqd->chip_data) +if (irqd) { +clear_bit (irqd->hwirq, heart_irq_map);kfree (irqd->chip_data); + } }static const struct irq_domain_ops heart_domain_ops = {
Greg Kroah-Hartman
maintainerPATCH 83/367 powerpc/mmu_gather: enable RCU_TABLE_FREE even for !SMP case
In reply to Greg Kroah-HartmanFrom: Aneesh Kumar K.V <[email protected]>
commit 12e4d53f3f04e81f9e83d6fc10edc7314ab9f6b9 upstream.
Patch series "Fixup page directory freeing", v4.
This is a repost of patch series from Peter with the arch specific changes except ppc64 dropped. ppc64 changes are added here because we are redoing the patch series on top of ppc64 changes. This makes it easy to backport these changes. Only the first 2 patches need to be backported to stable.
The thing is, on anything SMP, freeing page directories should observe the exact same order as normal page freeing:
1) unhook page/directory
2) TLB invalidate
3) free page/directory
Without this, any concurrent page-table walk could end up with a Use-after-Free. This is esp. trivial for anything that has software page-table walkers (HAVE_FAST_GUP / software TLB fill) or the hardware caches partial page-walks (ie. caches page directories).
Even on UP this might give issues since mmu_gather is preemptible these days. An interrupt or preempted task accessing user pages might stumble into the free page if the hardware caches page directories.
This patch series fixes ppc64 and add generic MMU_GATHER changes to support the conversion of other architectures. I haven't added patches w.r.t other architecture because they are yet to be acked.
This patch (of 9):
A followup patch is going to make sure we correctly invalidate page walk cache before we free page table pages. In order to keep things simple enable RCU_TABLE_FREE even for !SMP so that we don't have to fixup the !SMP case differently in the followup patch
!SMP case is right now broken for radix translation w.r.t page walk cache flush. We can get interrupted in between page table free and that would imply we have page walk cache entries pointing to tables which got freed already. Michael said "both our platforms that run on Power9 force SMP on in Kconfig, so the !SMP case is unlikely to be a problem for anyone in practice, unless they've hacked their kernel to build it !SMP."
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/book3s/32/pgalloc.h | 8 -------- arch/powerpc/include/asm/book3s/64/pgalloc.h | 2 -- arch/powerpc/include/asm/nohash/pgalloc.h | 8 -------- arch/powerpc/mm/book3s64/pgtable.c | 7 ------- 5 files changed, 1 insertion(+), 26 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -222,7 +222,7 @@ config PPC select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_RCU_TABLE_FREE if SMP + select HAVE_RCU_TABLE_FREE select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_MMU_GATHER_PAGE_SIZE select HAVE_REGS_AND_STACK_ACCESS_API
arch/powerpc/include/asm/book3s/32/pgalloc.h +0 -8
@@ -49,7 +49,6 @@ static inline void pgtable_free(void *ta#define get_hugepd_cache_index (x) (x) -#ifdef CONFIG_SMP static inline void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift) {
@@ -66,13 +65,6 @@ static inline void __tlb_remove_table(vopgtable_free (table, shift); } -#else -static inline void pgtable_free_tlb (struct mmu_gather *tlb, -void *table,int shift) -{ -pgtable_free (table, shift); -} -#endif static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address)
arch/powerpc/include/asm/book3s/64/pgalloc.h +0 -2
@@ -19,9 +19,7 @@ extern struct vmemmap_backing *vmemmap_lextern pmd_t *pmd_fragment_alloc (struct mm_struct *,unsigned long );extern void pmd_fragment_free (unsigned long *);extern void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift); -#ifdef CONFIG_SMP extern void __tlb_remove_table (void *_table); -#endif void pte_frag_destroy (void *pte_frag);static inline pgd_t *radix__pgd_alloc (struct mm_struct *mm)
arch/powerpc/include/asm/nohash/pgalloc.h +0 -8
@@ -46,7 +46,6 @@ static inline void pgtable_free(void *ta#define get_hugepd_cache_index (x) (x) -#ifdef CONFIG_SMP static inline void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift) {unsigned long pgf = (unsigned long )table;
@@ -64,13 +63,6 @@ static inline void __tlb_remove_table(vopgtable_free (table, shift); } -#else -static inline void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int shift) -{ -pgtable_free (table, shift); -} -#endif -static inline void __pte_free_tlb (struct mmu_gather *tlb,pgtable_t table,unsigned long address) {
arch/powerpc/mm/book3s64/pgtable.c +0 -7
@@ -378,7 +378,6 @@ static inline void pgtable_free(void *ta } } -#ifdef CONFIG_SMP void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int index) {unsigned long pgf = (unsigned long )table;
@@ -395,12 +394,6 @@ void __tlb_remove_table(void *_table)return pgtable_free (table, index); } -#else -void pgtable_free_tlb (struct mmu_gather *tlb,void *table,int index) -{ -return pgtable_free (table, index); -} -#endif #ifdef CONFIG_PROC_FS atomic_long_t direct_pages_count[MMU_PAGE_COUNT ];
Greg Kroah-Hartman
maintainerPATCH 89/367 PCI/ATS: Use PF PASID for VFs
In reply to Greg Kroah-HartmanFrom: Kuppuswamy Sathyanarayanan <[email protected]>
commit 2e34673be0bd6bb0c6c496a861cbc3f7431e7ce3 upstream.
Per PCIe r5.0, sec 9.3.7.14, if a PF implements the PASID Capability, the PF PASID configuration is shared by its VFs, and VFs must not implement their own PASID Capability. But commit 751035b8dc06 ("PCI/ATS: Cache PASID Capability offset") changed pci_max_pasids() and pci_pasid_features() to use the PASID Capability of the VF device instead of the associated PF device. This leads to IOMMU bind failures when pci_max_pasids() and pci_pasid_features() are called for VFs.
In pci_max_pasids() and pci_pasid_features(), always use the PF PASID Capability.
--- drivers/pci/ats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/ats.c +4 -2
@@ -424,11 +424,12 @@ void pci_restore_pasid_state(struct pci_int pci_pasid_features (struct pci_dev *pdev) {u16 supported; -int pasid = pdev->pasid_cap; +int pasid;if (pdev->is_virtfn) pdev =pci_physfn (pdev); + pasid = pdev->pasid_cap;if (!pasid)return -EINVAL ;
@@ -451,11 +452,12 @@ int pci_pasid_features(struct pci_dev *pint pci_max_pasids (struct pci_dev *pdev) {u16 supported; -int pasid = pdev->pasid_cap; +int pasid;if (pdev->is_virtfn) pdev =pci_physfn (pdev); + pasid = pdev->pasid_cap;if (!pasid)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 106/367 mmc: sdhci-of-at91: fix memleak on clk_get failure
In reply to Greg Kroah-HartmanFrom: Michał Mirosław <[email protected]>
[ Upstream commit a04184ce777b46e92c2b3c93c6dcb2754cb005e1 ]
sdhci_alloc_host() does its work not using managed infrastructure, so needs explicit free on error path. Add it where needed.
--- drivers/mmc/host/sdhci-of-at91.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-of-at91.c +6 -3
@@ -335,19 +335,22 @@ static int sdhci_at91_probe(struct platform_device *pdev) priv->mainck =devm_clk_get (&pdev->dev,"baseclk" );if (IS_ERR (priv->mainck)) {dev_err (&pdev->dev,"failed to get baseclk\n" ); -return PTR_ERR (priv->mainck); + ret =PTR_ERR (priv->mainck); + goto sdhci_pltfm_free; } priv->hclock =devm_clk_get (&pdev->dev,"hclock" );if (IS_ERR (priv->hclock)) {dev_err (&pdev->dev,"failed to get hclock\n" ); -return PTR_ERR (priv->hclock); + ret =PTR_ERR (priv->hclock); + goto sdhci_pltfm_free; } priv->gck =devm_clk_get (&pdev->dev,"multclk" );if (IS_ERR (priv->gck)) {dev_err (&pdev->dev,"failed to get multclk\n" ); -return PTR_ERR (priv->gck); + ret =PTR_ERR (priv->gck); + goto sdhci_pltfm_free; } ret =sdhci_at91_set_clks_presets (&pdev->dev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 109/367 ASoC: SOF: core: free trace on errors
In reply to Greg Kroah-HartmanFrom: Pierre-Louis Bossart <[email protected]>
commit 37e97e6faeabda405d0c4319f8419dcc3da14b2b upstream.
free_trace() is not called on probe errors, fix
--- sound/soc/sof/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/sof/core.c +5 -2
@@ -394,7 +394,7 @@ static int sof_probe_continue(struct sndif (ret <0 ) {dev_err (sdev->dev,"error: failed to register DSP DAI driver %d\n" , ret); - goto fw_run_err; + goto fw_trace_err; } drv_name = plat_data->machine->drv_name;
@@ -408,7 +408,7 @@ static int sof_probe_continue(struct sndif (IS_ERR (plat_data->pdev_mach)) { ret =PTR_ERR (plat_data->pdev_mach); - goto fw_run_err; + goto fw_trace_err; } dev_dbg(sdev->dev, "created machine %s\n",
@@ -420,6 +420,8 @@ static int sof_probe_continue(struct sndreturn 0 ;#if !IS_ENABLED (CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE ) +fw_trace_err: +snd_sof_free_trace (sdev); fw_run_err:snd_sof_fw_unload (sdev); fw_load_err:
@@ -437,6 +439,7 @@ dbg_err:* snd_sof_device_remove() when the PCI/ACPI device is removed */ +fw_trace_err: fw_run_err: fw_load_err: ipc_err:
Greg Kroah-Hartman
maintainerPATCH 74/367 KVM: arm/arm64: Correct CPSR on exception entry
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
commit 3c2483f15499b877ccb53250d88addb8c91da147 upstream.
When KVM injects an exception into a guest, it generates the CPSR value from scratch, configuring CPSR.{M,A,I,T,E}, and setting all other bits to zero.
This isn't correct, as the architecture specifies that some CPSR bits are (conditionally) cleared or set upon an exception, and others are unchanged from the original context.
This patch adds logic to match the architectural behaviour. To make this simple to follow/audit/extend, documentation references are provided, and bits are configured in order of their layout in SPSR_EL2. This layout can be seen in the diagram on ARM DDI 0487E.a page C5-426.
Note that this code is used by both arm and arm64, and is intended to fuction with the SPSR_EL2 and SPSR_HYP layouts.
--- arch/arm/include/asm/kvm_emulate.h | 12 ++++ arch/arm64/include/asm/ptrace.h | 1 virt/kvm/arm/aarch32.c | 111 +++++++++++++++++++++++++++++++++---- 3 files changed, 114 insertions(+), 10 deletions(-)
arch/arm/include/asm/kvm_emulate.h +12 -0
@@ -14,13 +14,25 @@#include <asm/cputype.h> /* arm64 compatibility macros */ +#define PSR_AA32_MODE_FIQ FIQ_MODE +#define PSR_AA32_MODE_SVC SVC_MODE#define PSR_AA32_MODE_ABT ABT_MODE#define PSR_AA32_MODE_UND UND_MODE#define PSR_AA32_T_BIT PSR_T_BIT +#define PSR_AA32_F_BIT PSR_F_BIT#define PSR_AA32_I_BIT PSR_I_BIT#define PSR_AA32_A_BIT PSR_A_BIT#define PSR_AA32_E_BIT PSR_E_BIT#define PSR_AA32_IT_MASK PSR_IT_MASK +#define PSR_AA32_GE_MASK 0x000f0000 +#define PSR_AA32_DIT_BIT 0x00200000 +#define PSR_AA32_PAN_BIT 0x00400000 +#define PSR_AA32_SSBS_BIT 0x00800000 +#define PSR_AA32_Q_BIT PSR_Q_BIT +#define PSR_AA32_V_BIT PSR_V_BIT +#define PSR_AA32_C_BIT PSR_C_BIT +#define PSR_AA32_Z_BIT PSR_Z_BIT +#define PSR_AA32_N_BIT PSR_N_BITunsigned long *vcpu_reg (struct kvm_vcpu *vcpu,u8 reg_num);
arch/arm64/include/asm/ptrace.h +1 -0
@@ -62,6 +62,7 @@#define PSR_AA32_I_BIT 0x00000080#define PSR_AA32_A_BIT 0x00000100#define PSR_AA32_E_BIT 0x00000200 +#define PSR_AA32_PAN_BIT 0x00400000#define PSR_AA32_SSBS_BIT 0x00800000#define PSR_AA32_DIT_BIT 0x01000000#define PSR_AA32_Q_BIT 0x08000000
virt/kvm/arm/aarch32.c +101 -10
136 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 128/367 power: supply: axp20x_ac_power: Fix reporting online status
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit 1c51aad8475d670ad58ae60adc9d32342381df8d upstream.
AXP803/AXP813 have a flag that enables/disables the AC power supply input. This flag does not affect the status bits in PWR_INPUT_STATUS. Its effect can be verified by checking the battery charge/discharge state (bit 2 of PWR_INPUT_STATUS), or by examining the current draw on the AC input.
Take this flag into account when getting the ONLINE property of the AC input, on PMICs where this flag is present.
--- drivers/power/supply/axp20x_ac_power.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-)
drivers/power/supply/axp20x_ac_power.c +25 -6
@@ -23,6 +23,8 @@#define AXP20X_PWR_STATUS_ACIN_PRESENT BIT(7)#define AXP20X_PWR_STATUS_ACIN_AVAIL BIT(6) +#define AXP813_ACIN_PATH_SEL BIT(7) +#define AXP813_VHOLD_MASK GENMASK(5, 3)#define AXP813_VHOLD_UV_TO_BIT (x) ((((x) / 100000) - 40) << 3)#define AXP813_VHOLD_REG_TO_UV (x) \
@@ -40,6 +42,7 @@ struct axp20x_ac_power {struct power_supply *supply;struct iio_channel *acin_v;struct iio_channel *acin_i; +bool has_acin_path_sel; };static irqreturn_t axp20x_ac_power_irq (int irq,void *devid)
@@ -86,6 +89,17 @@ static int axp20x_ac_power_get_property(return ret; val->intval = !!(reg &AXP20X_PWR_STATUS_ACIN_AVAIL ); + +/* ACIN_PATH_SEL disables ACIN even if ACIN_AVAIL is set. */ +if (val->intval && power->has_acin_path_sel) { + ret =regmap_read (power->regmap,AXP813_ACIN_PATH_CTRL , + ®); +if (ret) +return ret; + + val->intval = !!(reg &AXP813_ACIN_PATH_SEL ); + } +return 0 ;case POWER_SUPPLY_PROP_VOLTAGE_NOW :
@@ -224,21 +238,25 @@ static const struct power_supply_desc axstruct axp_data {const struct power_supply_desc *power_desc;bool acin_adc; +bool acin_path_sel; };static const struct axp_data axp20x_data = { - .power_desc = &axp20x_ac_power_desc, - .acin_adc = true, + .power_desc = &axp20x_ac_power_desc, + .acin_adc = true, + .acin_path_sel = false, };static const struct axp_data axp22x_data = { - .power_desc = &axp22x_ac_power_desc, - .acin_adc = false, + .power_desc = &axp22x_ac_power_desc, + .acin_adc = false, + .acin_path_sel = false, };static const struct axp_data axp813_data = { - .power_desc = &axp813_ac_power_desc, - .acin_adc = false, + .power_desc = &axp813_ac_power_desc, + .acin_adc = false, + .acin_path_sel = true, };static int axp20x_ac_power_probe (struct platform_device *pdev)
@@ -282,6 +300,7 @@ static int axp20x_ac_power_probe(struct } power->regmap =dev_get_regmap (pdev->dev.parent,NULL ); + power->has_acin_path_sel = axp_data->acin_path_sel;platform_set_drvdata (pdev, power);
Greg Kroah-Hartman
maintainerPATCH 116/367 crypto: ccree - fix AEAD decrypt auth fail
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
commit 2a6bc713f1cef32e39e3c4e6f2e1a9849da6379c upstream.
On AEAD decryption authentication failure we are suppose to zero out the output plaintext buffer. However, we've missed skipping the optional associated data that may prefix the ciphertext. This commit fixes this issue.
--- drivers/crypto/ccree/cc_aead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccree/cc_aead.c +1 -1
@@ -237,7 +237,7 @@ static void cc_aead_complete(struct devi* revealed the decrypted message --> zero its memory. */ sg_zero_buffer (areq->dst,sg_nents (areq->dst), - areq->cryptlen,0 ); + areq->cryptlen, areq->assoclen); err = -EBADMSG ; }/*ENCRYPT*/
Greg Kroah-Hartman
maintainerPATCH 169/367 samples/bpf: Reintroduce missed build targets
In reply to Greg Kroah-HartmanFrom: Prashant Bhole <[email protected]>
commit 5984dc6cb5aa6cce342a44f01f984fde09ed05b1 upstream.
Add xdp_redirect and per_socket_stats_example in build targets. They got removed from build targets in Makefile reorganization.
--- samples/bpf/Makefile | 2 ++ 1 file changed, 2 insertions(+)
samples/bpf/Makefile +2 -0
@@ -38,6 +38,8 @@ tprogs-y += tc_l2_redirect tprogs-y += lwt_len_hist tprogs-y += xdp_tx_iptunnel tprogs-y += test_map_in_map +tprogs-y += per_socket_stats_example +tprogs-y += xdp_redirect tprogs-y += xdp_redirect_map tprogs-y += xdp_redirect_cpu tprogs-y += xdp_monitor
Greg Kroah-Hartman
maintainerPATCH 173/367 selftests: bpf: Ignore FIN packets for reuseport tests
In reply to Greg Kroah-HartmanFrom: Lorenz Bauer <[email protected]>
commit 8bec4f665e0baecb5f1b683379fc10b3745eb612 upstream.
The reuseport tests currently suffer from a race condition: FIN packets count towards DROP_ERR_SKB_DATA, since they don't contain a valid struct cmd. Tests will spuriously fail depending on whether check_results is called before or after the FIN is processed.
Exit the BPF program early if FIN is set.
--- tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c +6 -0
@@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reusep data_check.skb_ports[0 ] = th->source; data_check.skb_ports[1 ] = th->dest; +if (th->fin) +/* The connection is being torn down at the end of a +* test. It can't contain a cmd, so return early. +*/ +return SK_PASS ; +if ((th->doff <<2 ) +sizeof (*cmd) > data_check.len)GOTO_DONE (DROP_ERR_SKB_DATA ); if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy,
Greg Kroah-Hartman
maintainerPATCH 183/367 crypto: hisilicon - select CRYPTO_SKCIPHER, not CRYPTO_BLKCIPHER
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 8e8c778d9ed4fdc5a9af108c7023bfb640a673f2 upstream.
Another instance of CRYPTO_BLKCIPHER made it in just after it was renamed to CRYPTO_SKCIPHER. Fix it.
--- drivers/crypto/hisilicon/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/hisilicon/Kconfig +1 -1
@@ -16,7 +16,7 @@ config CRYPTO_DEV_HISI_SEC config CRYPTO_DEV_HISI_SEC2 tristate "Support for HiSilicon SEC2 crypto block cipher accelerator" - select CRYPTO_BLKCIPHER + select CRYPTO_SKCIPHER select CRYPTO_ALGAPI select CRYPTO_LIB_DES select CRYPTO_DEV_HISI_QM
Greg Kroah-Hartman
maintainerPATCH 161/367 selftests/bpf: Fix perf_buffer test on systems w/ offline CPUs
In reply to Greg Kroah-HartmanFrom: Andrii Nakryiko <[email protected]>
commit 91cbdf740a476cf2c744169bf407de2e3ac1f3cf upstream.
Fix up perf_buffer.c selftest to take into account offline/missing CPUs.
--- tools/testing/selftests/bpf/prog_tests/perf_buffer.c | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-)
tools/testing/selftests/bpf/prog_tests/perf_buffer.c +24 -5
@@ -4,6 +4,7 @@#include <sched.h> #include <sys/socket.h> #include <test_progs.h> +#include "libbpf_internal.h" static void on_sample (void *ctx,int cpu,void *data,__u32 size) {
@@ -19,7 +20,7 @@ static void on_sample(void *ctx, int cpuvoid test_perf_buffer (void ) { -int err, prog_fd, nr_cpus, i, duration =0 ; +int err, prog_fd, on_len, nr_on_cpus =0 , nr_cpus, i, duration =0 ;const char *prog_name ="kprobe/sys_nanosleep" ;const char *file ="./test_perf_buffer.o" ;struct perf_buffer_opts pb_opts = {};
@@ -29,15 +30,27 @@ void test_perf_buffer(void)struct bpf_object *obj;struct perf_buffer *pb;struct bpf_link *link; +bool *online; nr_cpus =libbpf_num_possible_cpus ();if (CHECK (nr_cpus <0 ,"nr_cpus" ,"err %d\n" , nr_cpus))return ; + err =parse_cpu_mask_file ("/sys/devices/system/cpu/online" , + &online, &on_len); +if (CHECK (err,"nr_on_cpus" ,"err %d\n" , err)) +return ; + +for (i =0 ; i < on_len; i++) +if (online[i]) + nr_on_cpus++; +/* load program */ err =bpf_prog_load (file,BPF_PROG_TYPE_KPROBE , &obj, &prog_fd); -if (CHECK (err,"obj_load" ,"err %d errno %d\n" , err, errno)) -return ; +if (CHECK (err,"obj_load" ,"err %d errno %d\n" , err, errno)) { + obj =NULL ; + goto out_close; + } prog =bpf_object__find_program_by_title (obj, prog_name);if (CHECK (!prog,"find_probe" ,"prog '%s' not found\n" , prog_name))
@@ -64,6 +77,11 @@ void test_perf_buffer(void)/* trigger kprobe on every CPU */ CPU_ZERO (&cpu_seen);for (i =0 ; i < nr_cpus; i++) { +if (i >= on_len || !online[i]) { +printf ("skipping offline CPU #%d\n" , i); +continue ; + } +CPU_ZERO (&cpu_set);CPU_SET (i, &cpu_set);
@@ -81,8 +99,8 @@ void test_perf_buffer(void)if (CHECK (err <0 ,"perf_buffer__poll" ,"err %d\n" , err)) goto out_free_pb; -if (CHECK (CPU_COUNT (&cpu_seen) != nr_cpus,"seen_cpu_cnt" , -"expect %d, seen %d\n" , nr_cpus,CPU_COUNT (&cpu_seen))) +if (CHECK (CPU_COUNT (&cpu_seen) != nr_on_cpus,"seen_cpu_cnt" , +"expect %d, seen %d\n" , nr_on_cpus,CPU_COUNT (&cpu_seen))) goto out_free_pb; out_free_pb:
@@ -91,4 +109,5 @@ out_detach:bpf_link__destroy (link); out_close:bpf_object__close (obj); +free (online); }
Greg Kroah-Hartman
maintainerPATCH 187/367 powerpc/futex: Fix incorrect user access blocking
In reply to Greg Kroah-HartmanFrom: Michael Ellerman <[email protected]>
commit 9dc086f1e9ef39dd823bd27954b884b2062f9e70 upstream.
The early versions of our kernel user access prevention (KUAP) were written by Russell and Christophe, and didn't have separate read/write access.
At some point I picked up the series and added the read/write access, but I failed to update the usages in futex.h to correctly allow read and write.
However we didn't notice because of another bug which was causing the low-level code to always enable read and write. That bug was fixed recently in commit 1d8f739b07bd ("powerpc/kuap: Fix set direction in allow/prevent_user_access()").
futex_atomic_cmpxchg_inatomic() is passed the user address as %3 and does:
1: lwarx %1, 0, %3
cmpw 0, %1, %4
bne- 3f
2: stwcx. %5, 0, %3Which clearly loads and stores from/to %3. The logic in arch_futex_atomic_op_inuser() is similar, so fix both of them to use allow_read_write_user().
Without this fix, and with PPC_KUAP_DEBUG=y, we see eg:
Bug: Read fault blocked by AMR!
WARNING: CPU: 94 PID: 149215 at arch/powerpc/include/asm/book3s/64/kup-radix.h:126 __do_page_fault+0x600/0xf30
CPU: 94 PID: 149215 Comm: futex_requeue_p Tainted: G W 5.5.0-rc7-gcc9x-g4c25df5640ae #1
...
NIP [c000000000070680] __do_page_fault+0x600/0xf30
LR [c00000000007067c] __do_page_fault+0x5fc/0xf30
Call Trace:
[c00020138e5637e0] [c00000000007067c] __do_page_fault+0x5fc/0xf30 (unreliable)
[c00020138e5638c0] [c00000000000ada8] handle_page_fault+0x10/0x30
--- interrupt: 301 at cmpxchg_futex_value_locked+0x68/0xd0
LR = futex_lock_pi_atomic+0xe0/0x1f0
[c00020138e563bc0] [c000000000217b50] futex_lock_pi_atomic+0x80/0x1f0 (unreliable)
[c00020138e563c30] [c00000000021b668] futex_requeue+0x438/0xb60
[c00020138e563d60] [c00000000021c6cc] do_futex+0x1ec/0x2b0
[c00020138e563d90] [c00000000021c8b8] sys_futex+0x128/0x200
[c00020138e563e20] [c00000000000b7ac] system_call+0x5c/0x68--- arch/powerpc/include/asm/futex.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/powerpc/include/asm/futex.h +6 -4
@@ -35,7 +35,7 @@ static inline int arch_futex_atomic_op_i {int oldval =0 , ret; -allow_write_to_user (uaddr,sizeof (*uaddr)); +allow_read_write_user (uaddr, uaddr,sizeof (*uaddr));pagefault_disable ();switch (op) {
@@ -62,7 +62,7 @@ static inline int arch_futex_atomic_op_i *oval = oldval; -prevent_write_to_user (uaddr,sizeof (*uaddr)); +prevent_read_write_user (uaddr, uaddr,sizeof (*uaddr));return ret; }
@@ -76,7 +76,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval,if (!access_ok (uaddr,sizeof (u32)))return -EFAULT ; -allow_write_to_user (uaddr,sizeof (*uaddr)); +allow_read_write_user (uaddr, uaddr,sizeof (*uaddr)); + __asm__ __volatile__ ( PPC_ATOMIC_ENTRY_BARRIER "1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\
@@ -97,7 +98,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, : "cc", "memory"); *uval = prev; -prevent_write_to_user (uaddr,sizeof (*uaddr)); +prevent_read_write_user (uaddr, uaddr,sizeof (*uaddr)); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 188/367 scsi: qla2xxx: Fix unbound NVME response length
In reply to Greg Kroah-HartmanFrom: Arun Easi <[email protected]>
commit 00fe717ee1ea3c2979db4f94b1533c57aed8dea9 upstream.
On certain cases when response length is less than 32, NVME response data is supplied inline in IOCB. This is indicated by some combination of state flags. There was an instance when a high, and incorrect, response length was indicated causing driver to overrun buffers. Fix this by checking and limiting the response payload length.
--- drivers/scsi/qla2xxx/qla_dbg.c | 6 ------ drivers/scsi/qla2xxx/qla_dbg.h | 6 ++++++ drivers/scsi/qla2xxx/qla_isr.c | 12 ++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_dbg.c +0 -6
@@ -2519,12 +2519,6 @@ qla83xx_fw_dump_failed:/* Driver Debug Functions. */ /****************************************************************************/ -static inline int -ql_mask_match (uint level) -{ -return (level & ql2xextended_error_logging) == level; -} -/* * This function is for formatting and logging debug information. * It is to be used when vha is available. It formats the message
drivers/scsi/qla2xxx/qla_dbg.h +6 -0
@@ -374,3 +374,9 @@ extern int qla24xx_dump_ram(struct qla_hextern void qla24xx_pause_risc (struct device_reg_24xx __iomem *,struct qla_hw_data *);extern int qla24xx_soft_reset (struct qla_hw_data *); + +static inline int +ql_mask_match (uint level) +{ +return (level & ql2xextended_error_logging) == level; +}
drivers/scsi/qla2xxx/qla_isr.c +12 -0
@@ -1918,6 +1918,18 @@ static void qla24xx_nvme_iocb_entry(scsi inbuf = (uint32_t *)&sts->nvme_ersp_data; outbuf = (uint32_t *)fd->rspaddr; iocb->u.nvme.rsp_pyld_len =le16_to_cpu (sts->nvme_rsp_pyld_len); +if (unlikely (iocb->u.nvme.rsp_pyld_len > +sizeof (struct nvme_fc_ersp_iu ))) { +if (ql_mask_match (ql_dbg_io)) { +WARN_ONCE (1 ,"Unexpected response payload length %u.\n" , + iocb->u.nvme.rsp_pyld_len); +ql_log (ql_log_warn, fcport->vha,0x5100 , +"Unexpected response payload length %u.\n" , + iocb->u.nvme.rsp_pyld_len); + } + iocb->u.nvme.rsp_pyld_len = +sizeof (struct nvme_fc_ersp_iu ); + } iter = iocb->u.nvme.rsp_pyld_len >>2 ;for (; iter; iter--) *outbuf++ =swab32 (*inbuf++);
Greg Kroah-Hartman
maintainerPATCH 192/367 jbd2_seq_info_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
commit 1a8e9cf40c9a6a2e40b1e924b13ed303aeea4418 upstream.
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
Script below generates endless output
$ q=;while read -r r;do echo "$((++q)) $r";done </proc/fs/jbd2/DEV/info
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- fs/jbd2/journal.c | 1 + 1 file changed, 1 insertion(+)
fs/jbd2/journal.c +1 -0
@@ -982,6 +982,7 @@ static void *jbd2_seq_info_start(structstatic void *jbd2_seq_info_next (struct seq_file *seq,void *v,loff_t *pos) { + (*pos)++;return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 193/367 ext4: fix deadlock allocating crypto bounce page from mempool
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 547c556f4db7c09447ecf5f833ab6aaae0c5ab58 upstream.
ext4_writepages() on an encrypted file has to encrypt the data, but it can't modify the pagecache pages in-place, so it encrypts the data into bounce pages and writes those instead. All bounce pages are allocated from a mempool using GFP_NOFS.
This is not correct use of a mempool, and it can deadlock. This is because GFP_NOFS includes __GFP_DIRECT_RECLAIM, which enables the "never fail" mode for mempool_alloc() where a failed allocation will fall back to waiting for one of the preallocated elements in the pool.
But since this mode is used for all a bio's pages and not just the first, it can deadlock waiting for pages already in the bio to be freed.
This deadlock can be reproduced by patching mempool_alloc() to pretend that pool->alloc() always fails (so that it always falls back to the preallocations), and then creating an encrypted file of size > 128 KiB.
Fix it by only using GFP_NOFS for the first page in the bio. For subsequent pages just use GFP_NOWAIT, and if any of those fail, just submit the bio and start a new one.
This will need to be fixed in f2fs too, but that's less straightforward.
--- fs/ext4/page-io.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
fs/ext4/page-io.c +14 -5
@@ -512,17 +512,26 @@ int ext4_bio_write_page(struct ext4_io_sgfp_t gfp_flags =GFP_NOFS ;unsigned int enc_bytes =round_up (len,i_blocksize (inode)); +/* +* Since bounce page allocation uses a mempool, we can only use +* a waiting mask (i.e. request guaranteed allocation) on the +* first page of the bio. Otherwise it can deadlock. +*/ +if (io->io_bio) + gfp_flags =GFP_NOWAIT | __GFP_NOWARN; retry_encrypt: bounce_page =fscrypt_encrypt_pagecache_blocks (page, enc_bytes,0 , gfp_flags);if (IS_ERR (bounce_page)) { ret =PTR_ERR (bounce_page); -if (ret == -ENOMEM && wbc->sync_mode ==WB_SYNC_ALL ) { -if (io->io_bio) { +if (ret == -ENOMEM && + (io->io_bio || wbc->sync_mode ==WB_SYNC_ALL )) { + gfp_flags =GFP_NOFS ; +if (io->io_bio)ext4_io_submit (io); -congestion_wait (BLK_RW_ASYNC ,HZ /50 ); - } - gfp_flags |= __GFP_NOFAIL; +else + gfp_flags |= __GFP_NOFAIL; +congestion_wait (BLK_RW_ASYNC ,HZ /50 ); goto retry_encrypt; }
Greg Kroah-Hartman
maintainerPATCH 198/367 btrfs: set trans->drity in btrfs_commit_transaction
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit d62b23c94952e78211a383b7d90ef0afbd9a3717 upstream.
If we abort a transaction we have the following sequence
if (!trans->dirty && list_empty(&trans->new_bgs))
return;
WRITE_ONCE(trans->transaction->aborted, err);
The idea being if we didn't modify anything with our trans handle then we don't really need to abort the whole transaction, maybe the other trans handles are fine and we can carry on.
However in the case of create_snapshot we add a pending_snapshot object to our transaction and then commit the transaction. We don't actually modify anything. sync() behaves the same way, attach to an existing transaction and commit it. This means that if we have an IO error in the right places we could abort the committing transaction with our trans->dirty being not set and thus not set transaction->aborted.
This is a problem because in the create_snapshot() case we depend on pending->error being set to something, or btrfs_commit_transaction returning an error.
If we are not the trans handle that gets to commit the transaction, and we're waiting on the commit to happen we get our return value from cur_trans->aborted. If this was not set to anything because sync() hit an error in the transaction commit before it could modify anything then cur_trans->aborted would be 0. Thus we'd return 0 from btrfs_commit_transaction() in create_snapshot.
This is a problem because we then try to do things with pending_snapshot->snap, which will be NULL because we didn't create the snapshot, and then we'll get a NULL pointer dereference like the following
"BUG: kernel NULL pointer dereference, address: 00000000000001f0"
RIP: 0010:btrfs_orphan_cleanup+0x2d/0x330 Call Trace: ? btrfs_mksubvol.isra.31+0x3f2/0x510 btrfs_mksubvol.isra.31+0x4bc/0x510 ? __sb_start_write+0xfa/0x200 ? mnt_want_write_file+0x24/0x50 btrfs_ioctl_snap_create_transid+0x16c/0x1a0 btrfs_ioctl_snap_create_v2+0x11e/0x1a0 btrfs_ioctl+0x1534/0x2c10 ? free_debug_processing+0x262/0x2a3 do_vfs_ioctl+0xa6/0x6b0 ? do_sys_open+0x188/0x220 ? syscall_trace_enter+0x1f8/0x330 ksys_ioctl+0x60/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x4a/0x1b0
In order to fix this we need to make sure anybody who calls commit_transaction has trans->dirty set so that they properly set the trans->transaction->aborted value properly so any waiters know bad things happened.
This was found while I was running generic/475 with my modified fsstress, it reproduced within a few runs. I ran with this patch all night and didn't see the problem again.
--- fs/btrfs/transaction.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/transaction.c +8 -0
@@ -2013,6 +2013,14 @@ int btrfs_commit_transaction(struct btrfASSERT (refcount_read (&trans->use_count) ==1 ); +/* +* Some places just start a transaction to commit it. We need to make +* sure that if this commit fails that the abort code actually marks the +* transaction as failed, so set trans->dirty to make the abort code do +* the right thing. +*/ + trans->dirty = true; +/* Stop the commit early if ->aborted is set */ if (unlikely (READ_ONCE (cur_trans->aborted))) { ret = cur_trans->aborted;
Greg Kroah-Hartman
maintainerPATCH 200/367 btrfs: free block groups after freeing fs trees
In reply to Greg Kroah-HartmanFrom: Josef Bacik <[email protected]>
commit 4e19443da1941050b346f8fc4c368aa68413bc88 upstream.
Sometimes when running generic/475 we would trip the WARN_ON(cache->reserved) check when free'ing the block groups on umount. This is because sometimes we don't commit the transaction because of IO errors and thus do not cleanup the tree logs until at umount time.
These blocks are still reserved until they are cleaned up, but they aren't cleaned up until _after_ we do the free block groups work. Fix this by moving the free after free'ing the fs roots, that way all of the tree logs are cleaned up and we have a properly cleaned fs. A bunch of loops of generic/475 confirmed this fixes the problem.
--- fs/btrfs/disk-io.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/disk-io.c +9 -2
@@ -4026,11 +4026,18 @@ void __cold close_ctree(struct btrfs_fs_invalidate_inode_pages2 (fs_info->btree_inode->i_mapping);btrfs_stop_all_workers (fs_info); -btrfs_free_block_groups (fs_info); -clear_bit (BTRFS_FS_OPEN , &fs_info->flags);free_root_pointers (fs_info, true); +/* +* We must free the block groups after dropping the fs_roots as we could +* have had an IO error and have left over tree log blocks that aren't +* cleaned up until the fs roots are freed. This makes the block group +* accounting appear to be wrong because there's pending reserved bytes, +* so make sure we do the block group cleanup afterwards. +*/ +btrfs_free_block_groups (fs_info); +iput (fs_info->btree_inode);#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
Greg Kroah-Hartman
maintainerPATCH 213/367 drm: atmel-hlcdc: enable clock before configuring timing engine
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
commit 2c1fb9d86f6820abbfaa38a6836157c76ccb4e7b upstream.
Changing pixel clock source without having this clock source enabled will block the timing engine and the next operations after (in this case setting ATMEL_HLCDC_CFG(5) settings in atmel_hlcdc_crtc_mode_set_nofb() will fail). It is recomended (although in datasheet this is not present) to actually enabled pixel clock source before doing any changes on timing enginge (only SAM9X60 datasheet specifies that the peripheral clock and pixel clock must be enabled before using LCD controller).
--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +7 -1
@@ -73,7 +73,11 @@ static void atmel_hlcdc_crtc_mode_set_nounsigned long prate;unsigned int mask =ATMEL_HLCDC_CLKDIV_MASK |ATMEL_HLCDC_CLKPOL ;unsigned int cfg =0 ; -int div; +int div, ret; + + ret =clk_prepare_enable (crtc->dc->hlcdc->sys_clk); +if (ret) +return ; vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay; vm.vback_porch = adj->crtc_vtotal - adj->crtc_vsync_end;
@@ -147,6 +151,8 @@ static void atmel_hlcdc_crtc_mode_set_noATMEL_HLCDC_VSPSU |ATMEL_HLCDC_VSPHO |ATMEL_HLCDC_GUARDTIME_MASK |ATMEL_HLCDC_MODE_MASK , cfg); + +clk_disable_unprepare (crtc->dc->hlcdc->sys_clk); } static enum drm_mode_status
Greg Kroah-Hartman
maintainerPATCH 218/367 tools/kvm_stat: Fix kvm_exit filter name
In reply to Greg Kroah-HartmanFrom: Gavin Shan <[email protected]>
commit 5fcf3a55a62afb0760ccb6f391d62f20bce4a42f upstream.
The filter name is fixed to "exit_reason" for some kvm_exit events, no matter what architect we have. Actually, the filter name ("exit_reason") is only applicable to x86, meaning it's broken on other architects including aarch64.
This fixes the issue by providing various kvm_exit filter names, depending on architect we're on. Afterwards, the variable filter name is picked and applied through ioctl(fd, SET_FILTER).
--- tools/kvm/kvm_stat/kvm_stat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/kvm/kvm_stat/kvm_stat +6 -2
@@ -270,6 +270,7 @@ class ArchX86(Arch): def __init__(self, exit_reasons): self.sc_perf_evt_open = 298 self.ioctl_numbers = IOCTL_NUMBERS + self.exit_reason_field = 'exit_reason' self.exit_reasons = exit_reasons def debugfs_is_child(self, field):
@@ -289,6 +290,7 @@ class ArchPPC(Arch): # numbers depend on the wordsize. char_ptr_size = ctypes.sizeof(ctypes.c_char_p) self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 + self.exit_reason_field = 'exit_nr' self.exit_reasons = {} def debugfs_is_child(self, field):
@@ -300,6 +302,7 @@ class ArchA64(Arch): def __init__(self): self.sc_perf_evt_open = 241 self.ioctl_numbers = IOCTL_NUMBERS + self.exit_reason_field = 'esr_ec' self.exit_reasons = AARCH64_EXIT_REASONS def debugfs_is_child(self, field):
@@ -311,6 +314,7 @@ class ArchS390(Arch): def __init__(self): self.sc_perf_evt_open = 331 self.ioctl_numbers = IOCTL_NUMBERS + self.exit_reason_field = None self.exit_reasons = None def debugfs_is_child(self, field):
@@ -541,8 +545,8 @@ class TracepointProvider(Provider): """ filters = {} filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS) - if ARCH.exit_reasons: - filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) + if ARCH.exit_reason_field and ARCH.exit_reasons: + filters['kvm_exit'] = (ARCH.exit_reason_field, ARCH.exit_reasons) return filters def _get_available_fields(self):
Greg Kroah-Hartman
maintainerPATCH 204/367 Btrfs: send, fix emission of invalid clone operations within the same file
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 9722b10148504c4153a74a9c89725af271e490fc upstream.
When doing an incremental send and a file has extents shared with itself at different file offsets, it's possible for send to emit clone operations that will fail at the destination because the source range goes beyond the file's current size. This happens when the file size has increased in the send snapshot, there is a hole between the shared extents and both shared extents are at file offsets which are greater the file's size in the parent snapshot.
Example:
$ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt/sdb
$ xfs_io -f -c "pwrite -S 0xf1 0 64K" /mnt/sdb/foobar $ btrfs subvolume snapshot -r /mnt/sdb /mnt/sdb/base $ btrfs send -f /tmp/1.snap /mnt/sdb/base
# Create a 320K extent at file offset 512K.
$ xfs_io -c "pwrite -S 0xab 512K 64K" /mnt/sdb/foobar $ xfs_io -c "pwrite -S 0xcd 576K 64K" /mnt/sdb/foobar $ xfs_io -c "pwrite -S 0xef 640K 64K" /mnt/sdb/foobar $ xfs_io -c "pwrite -S 0x64 704K 64K" /mnt/sdb/foobar $ xfs_io -c "pwrite -S 0x73 768K 64K" /mnt/sdb/foobar
# Clone part of that 320K extent into a lower file offset (192K). # This file offset is greater than the file's size in the parent
# snapshot (64K). Also the clone range is a bit behind the offset of # the 320K extent so that we leave a hole between the shared extents. $ xfs_io -c "reflink /mnt/sdb/foobar 448K 192K 192K" /mnt/sdb/foobar
$ btrfs subvolume snapshot -r /mnt/sdb /mnt/sdb/incr $ btrfs send -p /mnt/sdb/base -f /tmp/2.snap /mnt/sdb/incr
$ mkfs.btrfs -f /dev/sdc $ mount /dev/sdc /mnt/sdc
$ btrfs receive -f /tmp/1.snap /mnt/sdc $ btrfs receive -f /tmp/2.snap /mnt/sdc ERROR: failed to clone extents to foobar: Invalid argument
The problem is that after processing the extent at file offset 256K, which refers to the first 128K of the 320K extent created by the buffered write operations, we have 'cur_inode_next_write_offset' set to 384K, which corresponds to the end offset of the partially shared extent (256K + 128K) and to the current file size in the receiver. Then when we process the extent at offset 512K, we do extent backreference iteration to figure out if we can clone the extent from some other inode or from the same inode, and we consider the extent at offset 256K of the same inode as a valid source for a clone operation, which is not correct because at that point the current file size in the receiver is 384K, which corresponds to the end of last processed extent (at file offset 256K), so using a clone source range from 256K to 256K + 320K is invalid because that goes past the current size of the file (384K) - this makes the receiver get an -EINVAL error when attempting the clone operation.
So fix this by excluding clone sources that have a range that goes beyond the current file size in the receiver when iterating extent backreferences.
A test case for fstests follows soon.
--- fs/btrfs/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/send.c +2 -1
@@ -1269,7 +1269,8 @@ static int __iterate_backrefs(u64 ino, u* destination of the stream. */ if (ino == bctx->cur_objectid && - offset >= bctx->sctx->cur_inode_next_write_offset) + offset + bctx->extent_len > + bctx->sctx->cur_inode_next_write_offset)return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 241/367 KVM: PPC: Book3S PR: Free shared page if mmu initialization fails
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit cb10bf9194f4d2c5d830eddca861f7ca0fecdbb4 upstream.
Explicitly free the shared page if kvmppc_mmu_init() fails during kvmppc_core_vcpu_create(), as the page is freed only in kvmppc_core_vcpu_free(), which is not reached via kvm_vcpu_uninit().
--- arch/powerpc/kvm/book3s_pr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kvm/book3s_pr.c +3 -1
@@ -1806,10 +1806,12 @@ static struct kvm_vcpu *kvmppc_core_vcpu err =kvmppc_mmu_init (vcpu);if (err <0 ) - goto uninit_vcpu; + goto free_shared_page;return vcpu; +free_shared_page: +free_page ((unsigned long )vcpu->arch.shared); uninit_vcpu:kvm_vcpu_uninit (vcpu); free_shadow_vcpu:
Greg Kroah-Hartman
maintainerPATCH 207/367 mwifiex: fix unbalanced locking in mwifiex_process_country_ie()
In reply to Greg Kroah-HartmanFrom: Brian Norris <[email protected]>
commit 65b1aae0d9d5962faccc06bdb8e91a2a0b09451c upstream.
We called rcu_read_lock(), so we need to call rcu_read_unlock() before we return.
--- drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +1 -0
@@ -232,6 +232,7 @@ static int mwifiex_process_country_ie(stif (country_ie_len > (IEEE80211_COUNTRY_STRING_LEN +MWIFIEX_MAX_TRIPLET_802_11D )) { +rcu_read_unlock ();mwifiex_dbg (priv->adapter,ERROR ,"11D: country_ie_len overflow!, deauth AP\n" );return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 255/367 KVM: x86: Handle TIF_NEED_FPU_LOAD in kvm_{load,put}_guest_fpu()
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit c9aef3b85f425d1f6635382ec210ee5a7ef55d7d upstream.
Handle TIF_NEED_FPU_LOAD similar to how fpu__copy() handles the flag when duplicating FPU state to a new task struct. TIF_NEED_FPU_LOAD can be set any time control is transferred out of KVM, be it voluntarily, e.g. if I/O is triggered during a KVM call to get_user_pages, or involuntarily, e.g. if softirq runs after an IRQ occurs. Therefore, KVM must account for TIF_NEED_FPU_LOAD whenever it is (potentially) accessing CPU FPU state.
--- arch/x86/kvm/x86.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
arch/x86/kvm/x86.c +17 -2
@@ -8517,12 +8517,26 @@ static int complete_emulated_mmio(structreturn 0 ; } +static void kvm_save_current_fpu (struct fpu *fpu) +{ +/* +* If the target FPU state is not resident in the CPU registers, just +* memcpy() from current, else save CPU state directly to the target. +*/ +if (test_thread_flag (TIF_NEED_FPU_LOAD )) +memcpy (&fpu->state, ¤t->thread.fpu.state, + fpu_kernel_xstate_size); +else +copy_fpregs_to_fpstate (fpu); +} +/* Swap (qemu) user FPU context for the guest FPU context. */ static void kvm_load_guest_fpu (struct kvm_vcpu *vcpu) {fpregs_lock (); -copy_fpregs_to_fpstate (vcpu->arch.user_fpu); +kvm_save_current_fpu (vcpu->arch.user_fpu); +/* PKRU is separately restored in kvm_x86_ops->run. */ __copy_kernel_to_fpregs (&vcpu->arch.guest_fpu->state, ~XFEATURE_MASK_PKRU );
@@ -8538,7 +8552,8 @@ static void kvm_put_guest_fpu(struct kvm {fpregs_lock (); -copy_fpregs_to_fpstate (vcpu->arch.guest_fpu); +kvm_save_current_fpu (vcpu->arch.guest_fpu); +copy_kernel_to_fpregs (&vcpu->arch.user_fpu->state);fpregs_mark_activate ();
Greg Kroah-Hartman
maintainerPATCH 266/367 drm/amdgpu/navi: fix index for OD MCLK
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 45826e9c4e9e952db43053f4fbed58ec602a410f upstream.
You can only adjust the max mclk, not the min.
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +1 -1
@@ -812,7 +812,7 @@ static int navi10_print_clk_levels(strucif (!navi10_od_feature_is_supported (od_settings,SMU_11_0_ODFEATURE_UCLK_MAX ))break ; size +=sprintf (buf + size,"OD_MCLK:\n" ); - size +=sprintf (buf + size,"0: %uMHz\n" , od_table->UclkFmax); + size +=sprintf (buf + size,"1: %uMHz\n" , od_table->UclkFmax);break ;case SMU_OD_VDDC_CURVE :if (!smu->od_enabled || !od_table || !od_settings)
Greg Kroah-Hartman
maintainerPATCH 281/367 scsi: csiostor: Adjust indentation in csio_device_reset
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit a808a04c861782e31fc30e342a619c144aaee14a upstream.
Clang warns:
../drivers/scsi/csiostor/csio_scsi.c:1386:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
csio_lnodes_exit(hw, 1);
^
../drivers/scsi/csiostor/csio_scsi.c:1382:2: note: previous statement is
here
if (*buf != '1')
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/scsi/csiostor/csio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/csiostor/csio_scsi.c +1 -1
@@ -1383,7 +1383,7 @@ csio_device_reset(struct device *dev,return -EINVAL ;/* Delete NPIV lnodes */ -csio_lnodes_exit (hw,1 ); +csio_lnodes_exit (hw,1 );/* Block upper IOs */ csio_lnodes_block_request (hw);
Greg Kroah-Hartman
maintainerPATCH 249/367 x86/KVM: Clean up hosts steal time structure
In reply to Greg Kroah-HartmanFrom: Boris Ostrovsky <[email protected]>
commit a6bd811f1209fe1c64c9f6fd578101d6436c6b6e upstream.
Now that we are mapping kvm_steal_time from the guest directly we don't need keep a copy of it in kvm_vcpu_arch.st. The same is true for the stime field.
This is part of CVE-2019-3016.
--- arch/x86/include/asm/kvm_host.h | 3 +-- arch/x86/kvm/x86.c | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -2
@@ -685,10 +685,9 @@ struct kvm_vcpu_arch {bool pvclock_set_guest_stopped_request;struct { +u8 preempted;u64 msr_val;u64 last_steal; -struct gfn_to_hva_cache stime; -struct kvm_steal_time steal;struct gfn_to_pfn_cache cache; } st;
arch/x86/kvm/x86.c +3 -8
@@ -2611,7 +2611,7 @@ static void record_steal_time(struct kvmif (xchg (&st->preempted,0 ) &KVM_VCPU_FLUSH_TLB )kvm_vcpu_flush_tlb (vcpu, false); - vcpu->arch.st.steal.preempted =0 ; + vcpu->arch.st.preempted =0 ;if (st->version &1 ) st->version +=1 ;/* first time write, random junk */
@@ -2795,11 +2795,6 @@ int kvm_set_msr_common(struct kvm_vcpu *if (data &KVM_STEAL_RESERVED_MASK )return 1 ; -if (kvm_gfn_to_hva_cache_init (vcpu->kvm, &vcpu->arch.st.stime, - data &KVM_STEAL_VALID_BITS , -sizeof (struct kvm_steal_time ))) -return 1 ; - vcpu->arch.st.msr_val = data;if (!(data &KVM_MSR_ENABLED ))
@@ -3519,7 +3514,7 @@ static void kvm_steal_time_set_preemptedif (!(vcpu->arch.st.msr_val &KVM_MSR_ENABLED ))return ; -if (vcpu->arch.st.steal.preempted) +if (vcpu->arch.st.preempted)return ; if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map,
@@ -3529,7 +3524,7 @@ static void kvm_steal_time_set_preempted st = map.hva +offset_in_page (vcpu->arch.st.msr_val &KVM_STEAL_VALID_BITS ); - st->preempted = vcpu->arch.st.steal.preempted =KVM_VCPU_PREEMPTED ; + st->preempted = vcpu->arch.st.preempted =KVM_VCPU_PREEMPTED ;kvm_unmap_gfn (vcpu, &map, &vcpu->arch.st.cache, true, true); }
Greg Kroah-Hartman
maintainerPATCH 288/367 powerpc/44x: Adjust indentation in ibm4xx_denali_fixup_memsize
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit c3aae14e5d468d18dbb5d7c0c8c7e2968cc14aad upstream.
Clang warns:
../arch/powerpc/boot/4xx.c:231:3: warning: misleading indentation; statement is not part of the previous 'else' [-Wmisleading-indentation]
val = SDRAM0_READ(DDR0_42);
^
../arch/powerpc/boot/4xx.c:227:2: note: previous statement is here
else
^This is because there is a space at the beginning of this line; remove it so that the indentation is consistent according to the Linux kernel coding style and clang no longer warns.
--- arch/powerpc/boot/4xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/boot/4xx.c +1 -1
@@ -228,7 +228,7 @@ void ibm4xx_denali_fixup_memsize(void) dpath =8 ;/* 64 bits */ /* get address pins (rows) */ - val =SDRAM0_READ (DDR0_42 ); + val =SDRAM0_READ (DDR0_42 ); row =DDR_GET_VAL (val,DDR_APIN ,DDR_APIN_SHIFT );if (row > max_row)
Greg Kroah-Hartman
maintainerPATCH 252/367 KVM: x86: Dont let userspace set host-reserved cr4 bits
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit b11306b53b2540c6ba068c4deddb6a17d9f8d95b upstream.
Calculate the host-reserved cr4 bits at runtime based on the system's capabilities (using logic similar to __do_cpuid_func()), and use the dynamically generated mask for the reserved bit check in kvm_set_cr4() instead using of the static CR4_RESERVED_BITS define. This prevents userspace from "enabling" features in cr4 that are not supported by the system, e.g. by ignoring KVM_GET_SUPPORTED_CPUID and specifying a bogus CPUID for the vCPU.
Allowing userspace to set unsupported bits in cr4 can lead to a variety of undesirable behavior, e.g. failed VM-Enter, and in general increases KVM's attack surface. A crafty userspace can even abuse CR4.LA57 to induce an unchecked #GP on a WRMSR.
On a platform without LA57 support:
KVM_SET_CPUID2 // CPUID_7_0_ECX.LA57 = 1
KVM_SET_SREGS // CR4.LA57 = 1
KVM_SET_MSRS // KERNEL_GS_BASE = 0x0004000000000000
KVM_RUN
leads to a #GP when writing KERNEL_GS_BASE into hardware:
unchecked MSR access error: WRMSR to 0xc0000102 (tried to write 0x0004000000000000) at rIP: 0xffffffffa00f239a (vmx_prepare_switch_to_guest+0x10a/0x1d0 [kvm_intel])
Call Trace: kvm_arch_vcpu_ioctl_run+0x671/0x1c70 [kvm] kvm_vcpu_ioctl+0x36b/0x5d0 [kvm] do_vfs_ioctl+0xa1/0x620 ksys_ioctl+0x66/0x70 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x4c/0x170 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7fc08133bf47
Note, the above sequence fails VM-Enter due to invalid guest state. Userspace can allow VM-Enter to succeed (after the WRMSR #GP) by adding a KVM_SET_SREGS w/ CR4.LA57=0 after KVM_SET_MSRS, in which case KVM will technically leak the host's KERNEL_GS_BASE into the guest. But, as KERNEL_GS_BASE is a userspace-defined value/address, the leak is largely benign as a malicious userspace would simply be exposing its own data to the guest, and attacking a benevolent userspace would require multiple bugs in the userspace VMM.
--- arch/x86/kvm/x86.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +34 -1
@@ -93,6 +93,8 @@ u64 __read_mostly efer_reserved_bits = ~static u64 __read_mostly efer_reserved_bits = ~((u64 )EFER_SCE );#endif +static u64 __read_mostly cr4_reserved_bits =CR4_RESERVED_BITS ; +#define VM_STAT (x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__#define VCPU_STAT (x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__
@@ -879,9 +881,38 @@ int kvm_set_xcr(struct kvm_vcpu *vcpu, u }EXPORT_SYMBOL_GPL (kvm_set_xcr); +static u64 kvm_host_cr4_reserved_bits (struct cpuinfo_x86 *c) +{ +u64 reserved_bits =CR4_RESERVED_BITS ; + +if (!cpu_has (c,X86_FEATURE_XSAVE )) + reserved_bits |=X86_CR4_OSXSAVE ; + +if (!cpu_has (c,X86_FEATURE_SMEP )) + reserved_bits |=X86_CR4_SMEP ; + +if (!cpu_has (c,X86_FEATURE_SMAP )) + reserved_bits |=X86_CR4_SMAP ; + +if (!cpu_has (c,X86_FEATURE_FSGSBASE )) + reserved_bits |=X86_CR4_FSGSBASE ; + +if (!cpu_has (c,X86_FEATURE_PKU )) + reserved_bits |=X86_CR4_PKE ; + +if (!cpu_has (c,X86_FEATURE_LA57 ) && + !(cpuid_ecx (0x7 ) &bit (X86_FEATURE_LA57 ))) + reserved_bits |=X86_CR4_LA57 ; + +if (!cpu_has (c,X86_FEATURE_UMIP ) && !kvm_x86_ops->umip_emulated ()) + reserved_bits |=X86_CR4_UMIP ; + +return reserved_bits; +} +static int kvm_valid_cr4 (struct kvm_vcpu *vcpu,unsigned long cr4) { -if (cr4 &CR4_RESERVED_BITS ) +if (cr4 & cr4_reserved_bits)return -EINVAL ;if (!guest_cpuid_has (vcpu,X86_FEATURE_XSAVE ) && (cr4 &X86_CR4_OSXSAVE ))
@@ -9369,6 +9400,8 @@ int kvm_arch_hardware_setup(void)if (r !=0 )return r; + cr4_reserved_bits =kvm_host_cr4_reserved_bits (&boot_cpu_data); +if (kvm_has_tsc_control) {/* * Make sure the user can only configure tsc_khz values that
Greg Kroah-Hartman
maintainerPATCH 306/367 regulator: core: Add regulator_is_equal() helper
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit b059b7e0ec3208ff1e17cff6387d75a9fbab4e02 upstream.
Add regulator_is_equal() helper to compare whether two regulators are the same. This is useful for checking whether two separate regulators in a driver are actually the same supply.
--- drivers/regulator/helpers.c | 14 ++++++++++++++ include/linux/regulator/consumer.h | 7 +++++++ 2 files changed, 21 insertions(+)
drivers/regulator/helpers.c +14 -0
@@ -13,6 +13,8 @@#include <linux/regulator/driver.h> #include <linux/module.h> +#include "internal.h" +/** * regulator_is_enabled_regmap - standard is_enabled() for regmap users *
@@ -881,3 +883,15 @@ void regulator_bulk_set_supply_names(str consumers[i].supply = supply_names[i]; }EXPORT_SYMBOL_GPL (regulator_bulk_set_supply_names); + +/** +* regulator_is_equal - test whether two regulators are the same +* +* @reg1: first regulator to operate on +* @reg2: second regulator to operate on +*/ +bool regulator_is_equal (struct regulator *reg1,struct regulator *reg2) +{ +return reg1->rdev == reg2->rdev; +} +EXPORT_SYMBOL_GPL (regulator_is_equal);
include/linux/regulator/consumer.h +7 -0
@@ -287,6 +287,8 @@ void regulator_bulk_set_supply_names(strconst char *const *supply_names, unsigned int num_supplies); +bool regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +#else /*
@@ -593,6 +595,11 @@ regulator_bulk_set_supply_names(struct r { } +static inline bool +regulator_is_equal (struct regulator *reg1,struct regulator *reg2); +{ +return false; +}#endif static inline int regulator_set_voltage_triplet(struct regulator *regulator,
Greg Kroah-Hartman
maintainerPATCH 315/367 x86/timer: Dont skip PIT setup when APIC is disabled or in legacy mode
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 979923871f69a4dc926658f9f9a1a4c1bde57552 upstream.
Tony reported a boot regression caused by the recent workaround for systems which have a disabled (clock gate off) PIT.
On his machine the kernel fails to initialize the PIT because apic_needs_pit() does not take into account whether the local APIC interrupt delivery mode will actually allow to setup and use the local APIC timer. This should be easy to reproduce with acpi=off on the command line which also disables HPET.
Due to the way the PIT/HPET and APIC setup ordering works (APIC setup can require working PIT/HPET) the information is not available at the point where apic_needs_pit() makes this decision.
To address this, split out the interrupt mode selection from apic_intr_mode_init(), invoke the selection before making the decision whether PIT is required or not, and add the missing checks into apic_needs_pit().
--- arch/x86/include/asm/apic.h | 2 ++ arch/x86/include/asm/x86_init.h | 2 ++ arch/x86/kernel/apic/apic.c | 23 ++++++++++++++++++----- arch/x86/kernel/time.c | 12 ++++++++++-- arch/x86/kernel/x86_init.c | 1 + arch/x86/xen/enlighten_pv.c | 1 + 6 files changed, 34 insertions(+), 7 deletions(-)
arch/x86/include/asm/apic.h +2 -0
@@ -140,6 +140,7 @@ extern void apic_soft_disable(void);extern void lapic_shutdown (void );extern void sync_Arb_IDs (void );extern void init_bsp_APIC (void ); +extern void apic_intr_mode_select (void );extern void apic_intr_mode_init (void );extern void init_apic_mappings (void );void register_lapic_address (unsigned long address);
@@ -188,6 +189,7 @@ static inline void disable_local_APIC(vo# define setup_secondary_APIC_clock x86_init_noopstatic inline void lapic_update_tsc_freq (void ) { }static inline void init_bsp_APIC (void ) { } +static inline void apic_intr_mode_select (void ) { }static inline void apic_intr_mode_init (void ) { }static inline void lapic_assign_system_vectors (void ) { }static inline void lapic_assign_legacy_vector (unsigned int i,bool r) { }
arch/x86/include/asm/x86_init.h +2 -0
@@ -51,12 +51,14 @@ struct x86_init_resources {* are set up. * @intr_init: interrupt init code * @trap_init: platform specific trap setup +* @intr_mode_select: interrupt delivery mode selection * @intr_mode_init: interrupt delivery mode setup */ struct x86_init_irqs {void (*pre_vector_init)(void );void (*intr_init)(void );void (*trap_init)(void ); +void (*intr_mode_select)(void );void (*intr_mode_init)(void ); };
arch/x86/kernel/apic/apic.c +18 -5
@@ -830,8 +830,17 @@ bool __init apic_needs_pit(void)if (!tsc_khz || !cpu_khz)return true; -/* Is there an APIC at all? */ -if (!boot_cpu_has (X86_FEATURE_APIC )) +/* Is there an APIC at all or is it disabled? */ +if (!boot_cpu_has (X86_FEATURE_APIC ) || disable_apic) +return true; + +/* +* If interrupt delivery mode is legacy PIC or virtual wire without +* configuration, the local APIC timer wont be set up. Make sure +* that the PIT is initialized. +*/ +if (apic_intr_mode ==APIC_PIC || + apic_intr_mode ==APIC_VIRTUAL_WIRE_NO_CONFIG )return true;/* Virt guests may lack ARAT, but still have DEADLINE */
@@ -1322,7 +1331,7 @@ void __init sync_Arb_IDs(void)enum apic_intr_mode_id apic_intr_mode__ro_after_init ; -static int __init apic_intr_mode_select (void ) +static int __init __apic_intr_mode_select (void ) {/* Check kernel option */ if (disable_apic) {
@@ -1384,6 +1393,12 @@ static int __init apic_intr_mode_select(return APIC_SYMMETRIC_IO ; } +/* Select the interrupt delivery mode for the BSP */ +void __init apic_intr_mode_select (void ) +{ + apic_intr_mode =__apic_intr_mode_select (); +} +/* * An initial setup of the virtual wire mode. */
@@ -1440,8 +1455,6 @@ void __init apic_intr_mode_init(void) {bool upmode =IS_ENABLED (CONFIG_UP_LATE_INIT ); - apic_intr_mode =apic_intr_mode_select (); -switch (apic_intr_mode) {case APIC_PIC :pr_info ("APIC: Keep in PIC mode(8259)\n" );
arch/x86/kernel/time.c +10 -2
@@ -91,10 +91,18 @@ void __init hpet_time_init(void)static __init void x86_late_time_init (void ) { +/* +* Before PIT/HPET init, select the interrupt mode. This is required +* to make the decision whether PIT should be initialized correct. +*/ + x86_init.irqs.intr_mode_select (); + +/* Setup the legacy timers */ x86_init.timers.timer_init (); +/* -* After PIT/HPET timers init, select and setup -* the final interrupt mode for delivering IRQs. +* After PIT/HPET timers init, set up the final interrupt mode for +* delivering IRQs. */ x86_init.irqs.intr_mode_init ();tsc_init ();
arch/x86/kernel/x86_init.c +1 -0
@@ -80,6 +80,7 @@ struct x86_init_ops x86_init __initdata .pre_vector_init = init_ISA_irqs, .intr_init = native_init_IRQ, .trap_init = x86_init_noop, + .intr_mode_select = apic_intr_mode_select, .intr_mode_init = apic_intr_mode_init },
arch/x86/xen/enlighten_pv.c +1 -0
@@ -1205,6 +1205,7 @@ asmlinkage __visible void __init xen_sta x86_platform.get_nmi_reason = xen_get_nmi_reason; x86_init.resources.memory_setup = xen_memory_setup; + x86_init.irqs.intr_mode_select = x86_init_noop; x86_init.irqs.intr_mode_init = x86_init_noop; x86_init.oem.arch_setup = xen_arch_setup; x86_init.oem.banner = xen_banner;
Greg Kroah-Hartman
maintainerPATCH 292/367 net: smc911x: Adjust indentation in smc911x_phy_configure
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 5c61e223004b3b5c3f1dd25718e979bc17a3b12d upstream.
Clang warns:
../drivers/net/ethernet/smsc/smc911x.c:939:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (!lp->ctl_rfduplx)
^
../drivers/net/ethernet/smsc/smc911x.c:936:2: note: previous statement
is here
if (lp->ctl_rspeed != 100)
^1 warning generated.
This warning occurs because there is a space after the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/ethernet/smsc/smc911x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/smsc/smc911x.c +1 -1
@@ -936,7 +936,7 @@ static void smc911x_phy_configure(structif (lp->ctl_rspeed !=100 ) my_ad_caps &= ~(ADVERTISE_100BASE4 |ADVERTISE_100FULL |ADVERTISE_100HALF ); -if (!lp->ctl_rfduplx) +if (!lp->ctl_rfduplx) my_ad_caps &= ~(ADVERTISE_100FULL |ADVERTISE_10FULL );/* Update our Auto-Neg Advertisement Register */
Greg Kroah-Hartman
maintainerPATCH 322/367 net: mvneta: move rx_dropped and rx_errors in per-cpu stats
In reply to Greg Kroah-HartmanFrom: Lorenzo Bianconi <[email protected]>
[ Upstream commit c35947b8ff8acca33134ee39c31708233765c31a ]
Move rx_dropped and rx_errors counters in mvneta_pcpu_stats in order to avoid possible races updating statistics
--- drivers/net/ethernet/marvell/mvneta.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
drivers/net/ethernet/marvell/mvneta.c +22 -9
@@ -401,6 +401,8 @@ struct mvneta_pcpu_stats {struct u64_stats_sync syncp;u64 rx_packets;u64 rx_bytes; +u64 rx_dropped; +u64 rx_errors;u64 tx_packets;u64 tx_bytes; };
@@ -738,6 +740,8 @@ mvneta_get_stats64(struct net_device *destruct mvneta_pcpu_stats *cpu_stats;u64 rx_packets;u64 rx_bytes; +u64 rx_dropped; +u64 rx_errors;u64 tx_packets;u64 tx_bytes;
@@ -746,19 +750,20 @@ mvneta_get_stats64(struct net_device *de start =u64_stats_fetch_begin_irq (&cpu_stats->syncp); rx_packets = cpu_stats->rx_packets; rx_bytes = cpu_stats->rx_bytes; + rx_dropped = cpu_stats->rx_dropped; + rx_errors = cpu_stats->rx_errors; tx_packets = cpu_stats->tx_packets; tx_bytes = cpu_stats->tx_bytes; }while (u64_stats_fetch_retry_irq (&cpu_stats->syncp, start)); stats->rx_packets += rx_packets; stats->rx_bytes += rx_bytes; + stats->rx_dropped += rx_dropped; + stats->rx_errors += rx_errors; stats->tx_packets += tx_packets; stats->tx_bytes += tx_bytes; } - stats->rx_errors = dev->stats.rx_errors; - stats->rx_dropped = dev->stats.rx_dropped; - stats->tx_dropped = dev->stats.tx_dropped; }
@@ -1736,8 +1741,14 @@ static u32 mvneta_txq_desc_csum(int l3_ostatic void mvneta_rx_error (struct mvneta_port *pp,struct mvneta_rx_desc *rx_desc) { +struct mvneta_pcpu_stats *stats =this_cpu_ptr (pp->stats);u32 status = rx_desc->status; +/* update per-cpu counter */ +u64_stats_update_begin (&stats->syncp); + stats->rx_errors++; +u64_stats_update_end (&stats->syncp); +switch (status &MVNETA_RXD_ERR_CODE_MASK ) {case MVNETA_RXD_ERR_CRC : netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n",
@@ -2179,11 +2190,15 @@ mvneta_swbm_rx_frame(struct mvneta_port rxq->skb =build_skb (xdp->data_hard_start,PAGE_SIZE );if (unlikely (!rxq->skb)) { -netdev_err (dev, -"Can't allocate skb on queue %d\n" , - rxq->id); - dev->stats.rx_dropped++; +struct mvneta_pcpu_stats *stats =this_cpu_ptr (pp->stats); + +netdev_err (dev,"Can't allocate skb on queue %d\n" , rxq->id); rxq->skb_alloc_err++; + +u64_stats_update_begin (&stats->syncp); + stats->rx_dropped++; +u64_stats_update_end (&stats->syncp); +return -ENOMEM ; }page_pool_release_page (rxq->page_pool, page);
@@ -2270,7 +2285,6 @@ static int mvneta_rx_swbm(struct napi_st/* Check errors only for FIRST descriptor */ if (rx_status &MVNETA_RXD_ERR_SUMMARY ) {mvneta_rx_error (pp, rx_desc); - dev->stats.rx_errors++;/* leave the descriptor untouched */ continue ; }
@@ -2372,7 +2386,6 @@ err_drop_frame_ret_pool:mvneta_bm_pool_put_bp (pp->bm_priv, bm_pool, rx_desc->buf_phys_addr); err_drop_frame: - dev->stats.rx_errors++;mvneta_rx_error (pp, rx_desc);/* leave the descriptor untouched */ continue ;
Greg Kroah-Hartman
maintainerPATCH 321/367 net: dsa: microchip: enable module autoprobe
In reply to Greg Kroah-HartmanFrom: Razvan Stefanescu <[email protected]>
[ Upstream commit f8c2afa66d5397b0b9293c4347dac6dabb327685 ]
This matches /sys/devices/.../spi1.0/modalias content.
--- drivers/net/dsa/microchip/ksz9477_spi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/dsa/microchip/ksz9477_spi.c +6 -0
@@ -101,6 +101,12 @@ static struct spi_driver ksz9477_spi_drimodule_spi_driver (ksz9477_spi_driver); +MODULE_ALIAS ("spi:ksz9477" ); +MODULE_ALIAS ("spi:ksz9897" ); +MODULE_ALIAS ("spi:ksz9893" ); +MODULE_ALIAS ("spi:ksz9563" ); +MODULE_ALIAS ("spi:ksz8563" ); +MODULE_ALIAS ("spi:ksz9567" );MODULE_AUTHOR ("Woojung Huh <[email protected]>" );MODULE_DESCRIPTION ("Microchip KSZ9477 Series Switch SPI access Driver" );MODULE_LICENSE ("GPL" );
Greg Kroah-Hartman
maintainerPATCH 323/367 net_sched: fix a resource leak in tcindex_set_parms()
In reply to Greg Kroah-HartmanFrom: Cong Wang <[email protected]>
[ Upstream commit 52b5ae501c045010aeeb1d5ac0373ff161a88291 ]
Jakub noticed there is a potential resource leak in tcindex_set_parms(): when tcindex_filter_result_init() fails and it jumps to 'errout1' which doesn't release the memory and resources allocated by tcindex_alloc_perfect_hash().
We should just jump to 'errout_alloc' which callstcindex_free_perfect_hash().
--- net/sched/cls_tcindex.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/sched/cls_tcindex.c +1 -2
@@ -365,7 +365,7 @@ tcindex_set_parms(struct net *net, struc err =tcindex_filter_result_init (&new_filter_result, net);if (err <0 ) - goto errout1; + goto errout_alloc;if (old_r) cr = r->res;
@@ -484,7 +484,6 @@ errout_alloc:tcindex_free_perfect_hash (cp); else if (balloc == 2) kfree(cp->h); -errout1:tcf_exts_destroy (&new_filter_result.exts); errout:kfree (cp);
Greg Kroah-Hartman
maintainerPATCH 327/367 net/mlx5: IPsec, fix memory leak at mlx5_fpga_ipsec_delete_sa_ctx
In reply to Greg Kroah-HartmanFrom: Raed Salem <[email protected]>
[ Upstream commit 08db2cf577487f5123aebcc2f913e0b8a2c14b43 ]
SA context is allocated at mlx5_fpga_ipsec_create_sa_ctx, however the counterpart mlx5_fpga_ipsec_delete_sa_ctx function nullifies sa_ctx pointer without freeing the memory allocated, hence the memory leak.
Fix by free SA context when the SA is released.
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +1 -0
@@ -850,6 +850,7 @@ void mlx5_fpga_ipsec_delete_sa_ctx(voidmutex_lock (&fpga_xfrm->lock);if (!--fpga_xfrm->num_rules) {mlx5_fpga_ipsec_release_sa_ctx (fpga_xfrm->sa_ctx); +kfree (fpga_xfrm->sa_ctx); fpga_xfrm->sa_ctx =NULL ; }mutex_unlock (&fpga_xfrm->lock);
Greg Kroah-Hartman
maintainerPATCH 293/367 net: tulip: Adjust indentation in {dmfe, uli526x}_init_module
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit fe06bf3d83ef0d92f35a24e03297172e92ce9ce3 upstream.
Clang warns:
../drivers/net/ethernet/dec/tulip/uli526x.c:1812:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
switch (mode) {
^
../drivers/net/ethernet/dec/tulip/uli526x.c:1809:2: note: previous
statement is here
if (cr6set)
^1 warning generated.
../drivers/net/ethernet/dec/tulip/dmfe.c:2217:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
switch(mode) {
^
../drivers/net/ethernet/dec/tulip/dmfe.c:2214:2: note: previous
statement is here
if (cr6set)
^1 warning generated.
This warning occurs because there is a space before the tab on these lines. Remove them so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
While we are here, adjust the default block in dmfe_init_module to have a proper break between the label and assignment and add a space between the switch and opening parentheses to avoid a checkpatch warning.
--- drivers/net/ethernet/dec/tulip/dmfe.c | 7 ++++--- drivers/net/ethernet/dec/tulip/uli526x.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/ethernet/dec/tulip/dmfe.c +4 -3
@@ -2214,15 +2214,16 @@ static int __init dmfe_init_module(void)if (cr6set) dmfe_cr6_user_set = cr6set; -switch (mode) { -case DMFE_10MHF : +switch (mode) { +case DMFE_10MHF :case DMFE_100MHF :case DMFE_10MFD :case DMFE_100MFD :case DMFE_1M_HPNA : dmfe_media_mode = mode;break ; -default :dmfe_media_mode =DMFE_AUTO ; +default : + dmfe_media_mode =DMFE_AUTO ;break ; }
drivers/net/ethernet/dec/tulip/uli526x.c +2 -2
@@ -1809,8 +1809,8 @@ static int __init uli526x_init_module(voif (cr6set) uli526x_cr6_user_set = cr6set; -switch (mode) { -case ULI526X_10MHF : +switch (mode) { +case ULI526X_10MHF :case ULI526X_100MHF :case ULI526X_10MFD :case ULI526X_100MFD :
Greg Kroah-Hartman
maintainerPATCH 295/367 IB/core: Fix ODP get user pages flow
In reply to Greg Kroah-HartmanFrom: Yishai Hadas <[email protected]>
commit d07de8bd1709a80a282963ad7b2535148678a9e4 upstream.
The nr_pages argument of get_user_pages_remote() should always be in terms of the system page size, not the MR page size. Use PAGE_SIZE instead of umem_odp->page_shift.
--- drivers/infiniband/core/umem_odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem_odp.c +1 -1
@@ -440,7 +440,7 @@ int ib_umem_odp_map_dma_pages(struct ib_while (bcnt >0 ) {const size_t gup_num_pages =min_t (size_t, - (bcnt +BIT (page_shift) -1 ) >> page_shift, +ALIGN (bcnt,PAGE_SIZE ) /PAGE_SIZE ,PAGE_SIZE /sizeof (struct page *));down_read (&owning_mm->mmap_sem);
Greg Kroah-Hartman
maintainerPATCH 365/367 crypto: atmel-tdes - Map driver data flags to Mode Register
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
[ Upstream commit 848572f817721499c05b66553afc7ce0c08b1723 ]
Simplifies the configuration of the TDES IP.
--- drivers/crypto/atmel-tdes.c | 144 ++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 73 deletions(-)
drivers/crypto/atmel-tdes.c +71 -73
@@ -41,20 +41,23 @@#include "atmel-tdes-regs.h" /* TDES flags */ -#define TDES_FLAGS_MODE_MASK 0x00ff -#define TDES_FLAGS_ENCRYPT BIT(0) -#define TDES_FLAGS_CBC BIT(1) -#define TDES_FLAGS_CFB BIT(2) -#define TDES_FLAGS_CFB8 BIT(3) -#define TDES_FLAGS_CFB16 BIT(4) -#define TDES_FLAGS_CFB32 BIT(5) -#define TDES_FLAGS_CFB64 BIT(6) -#define TDES_FLAGS_OFB BIT(7) - -#define TDES_FLAGS_INIT BIT(16) -#define TDES_FLAGS_FAST BIT(17) -#define TDES_FLAGS_BUSY BIT(18) -#define TDES_FLAGS_DMA BIT(19) +/* Reserve bits [17:16], [13:12], [2:0] for AES Mode Register */ +#define TDES_FLAGS_ENCRYPT TDES_MR_CYPHER_ENC +#define TDES_FLAGS_OPMODE_MASK (TDES_MR_OPMOD_MASK | TDES_MR_CFBS_MASK) +#define TDES_FLAGS_ECB TDES_MR_OPMOD_ECB +#define TDES_FLAGS_CBC TDES_MR_OPMOD_CBC +#define TDES_FLAGS_OFB TDES_MR_OPMOD_OFB +#define TDES_FLAGS_CFB64 (TDES_MR_OPMOD_CFB | TDES_MR_CFBS_64b) +#define TDES_FLAGS_CFB32 (TDES_MR_OPMOD_CFB | TDES_MR_CFBS_32b) +#define TDES_FLAGS_CFB16 (TDES_MR_OPMOD_CFB | TDES_MR_CFBS_16b) +#define TDES_FLAGS_CFB8 (TDES_MR_OPMOD_CFB | TDES_MR_CFBS_8b) + +#define TDES_FLAGS_MODE_MASK (TDES_FLAGS_OPMODE_MASK | TDES_FLAGS_ENCRYPT) + +#define TDES_FLAGS_INIT BIT(3) +#define TDES_FLAGS_FAST BIT(4) +#define TDES_FLAGS_BUSY BIT(5) +#define TDES_FLAGS_DMA BIT(6)#define ATMEL_TDES_QUEUE_LENGTH 50
@@ -282,25 +285,7 @@ static int atmel_tdes_write_ctrl(struct atmel_tdes_dev *dd) valmr |=TDES_MR_TDESMOD_DES ; } -if (dd->flags &TDES_FLAGS_CBC ) { - valmr |=TDES_MR_OPMOD_CBC ; - }else if (dd->flags &TDES_FLAGS_CFB ) { - valmr |=TDES_MR_OPMOD_CFB ; - -if (dd->flags &TDES_FLAGS_CFB8 ) - valmr |= TDES_MR_CFBS_8b; -else if (dd->flags &TDES_FLAGS_CFB16 ) - valmr |= TDES_MR_CFBS_16b; -else if (dd->flags &TDES_FLAGS_CFB32 ) - valmr |= TDES_MR_CFBS_32b; -else if (dd->flags &TDES_FLAGS_CFB64 ) - valmr |= TDES_MR_CFBS_64b; - }else if (dd->flags &TDES_FLAGS_OFB ) { - valmr |=TDES_MR_OPMOD_OFB ; - } - -if ((dd->flags &TDES_FLAGS_ENCRYPT ) || (dd->flags &TDES_FLAGS_OFB )) - valmr |=TDES_MR_CYPHER_ENC ; + valmr |= dd->flags &TDES_FLAGS_MODE_MASK ;atmel_tdes_write (dd,TDES_CR , valcr);atmel_tdes_write (dd,TDES_MR , valmr);
@@ -308,10 +293,8 @@ static int atmel_tdes_write_ctrl(struct atmel_tdes_dev *dd)atmel_tdes_write_n (dd,TDES_KEY1W1R , dd->ctx->key, dd->ctx->keylen >>2 ); -if (((dd->flags &TDES_FLAGS_CBC ) || (dd->flags &TDES_FLAGS_CFB ) || - (dd->flags &TDES_FLAGS_OFB )) && dd->req->iv) { +if (dd->req->iv && (valmr &TDES_MR_OPMOD_MASK ) !=TDES_MR_OPMOD_ECB )atmel_tdes_write_n (dd,TDES_IV1R , (void *)dd->req->iv,2 ); - }return 0 ; }
@@ -402,6 +385,7 @@ static int atmel_tdes_crypt_pdc(struct crypto_tfm *tfm, dma_addr_t dma_addr_in, {struct atmel_tdes_ctx *ctx =crypto_tfm_ctx (tfm);struct atmel_tdes_dev *dd = ctx->dd; +struct atmel_tdes_reqctx *rctx =skcipher_request_ctx (dd->req);int len32; dd->dma_size = length;
@@ -411,12 +395,19 @@ static int atmel_tdes_crypt_pdc(struct crypto_tfm *tfm, dma_addr_t dma_addr_in, DMA_TO_DEVICE); } -if ((dd->flags &TDES_FLAGS_CFB ) && (dd->flags &TDES_FLAGS_CFB8 )) +switch (rctx->mode &TDES_FLAGS_OPMODE_MASK ) { +case TDES_FLAGS_CFB8 : len32 =DIV_ROUND_UP (length,sizeof (u8)); -else if ((dd->flags &TDES_FLAGS_CFB ) && (dd->flags &TDES_FLAGS_CFB16 )) +break ; + +case TDES_FLAGS_CFB16 : len32 =DIV_ROUND_UP (length,sizeof (u16)); -else +break ; + +default : len32 =DIV_ROUND_UP (length,sizeof (u32)); +break ; + }atmel_tdes_write (dd,TDES_PTCR ,TDES_PTCR_TXTDIS |TDES_PTCR_RXTDIS );atmel_tdes_write (dd,TDES_TPR , dma_addr_in);
@@ -438,8 +429,10 @@ static int atmel_tdes_crypt_dma(struct crypto_tfm *tfm, dma_addr_t dma_addr_in, {struct atmel_tdes_ctx *ctx =crypto_tfm_ctx (tfm);struct atmel_tdes_dev *dd = ctx->dd; +struct atmel_tdes_reqctx *rctx =skcipher_request_ctx (dd->req);struct scatterlist sg[2 ];struct dma_async_tx_descriptor *in_desc, *out_desc; +enum dma_slave_buswidth addr_width; dd->dma_size = length;
@@ -448,23 +441,23 @@ static int atmel_tdes_crypt_dma(struct crypto_tfm *tfm, dma_addr_t dma_addr_in, DMA_TO_DEVICE); } -if (dd->flags &TDES_FLAGS_CFB8 ) { - dd->dma_lch_in.dma_conf.dst_addr_width = -DMA_SLAVE_BUSWIDTH_1_BYTE ; - dd->dma_lch_out.dma_conf.src_addr_width = -DMA_SLAVE_BUSWIDTH_1_BYTE ; - }else if (dd->flags &TDES_FLAGS_CFB16 ) { - dd->dma_lch_in.dma_conf.dst_addr_width = -DMA_SLAVE_BUSWIDTH_2_BYTES ; - dd->dma_lch_out.dma_conf.src_addr_width = -DMA_SLAVE_BUSWIDTH_2_BYTES ; - }else { - dd->dma_lch_in.dma_conf.dst_addr_width = -DMA_SLAVE_BUSWIDTH_4_BYTES ; - dd->dma_lch_out.dma_conf.src_addr_width = -DMA_SLAVE_BUSWIDTH_4_BYTES ; +switch (rctx->mode &TDES_FLAGS_OPMODE_MASK ) { +case TDES_FLAGS_CFB8 : + addr_width =DMA_SLAVE_BUSWIDTH_1_BYTE ; +break ; + +case TDES_FLAGS_CFB16 : + addr_width =DMA_SLAVE_BUSWIDTH_2_BYTES ; +break ; + +default : + addr_width =DMA_SLAVE_BUSWIDTH_4_BYTES ; +break ; } + dd->dma_lch_in.dma_conf.dst_addr_width = addr_width; + dd->dma_lch_out.dma_conf.src_addr_width = addr_width; +dmaengine_slave_config (dd->dma_lch_in.chan, &dd->dma_lch_in.dma_conf);dmaengine_slave_config (dd->dma_lch_out.chan, &dd->dma_lch_out.dma_conf);
@@ -701,30 +694,38 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode)struct atmel_tdes_ctx *ctx =crypto_skcipher_ctx (skcipher);struct atmel_tdes_reqctx *rctx =skcipher_request_ctx (req); -if (mode &TDES_FLAGS_CFB8 ) { +switch (mode &TDES_FLAGS_OPMODE_MASK ) { +case TDES_FLAGS_CFB8 :if (!IS_ALIGNED (req->cryptlen,CFB8_BLOCK_SIZE )) {pr_err ("request size is not exact amount of CFB8 blocks\n" );return -EINVAL ; } ctx->block_size =CFB8_BLOCK_SIZE ; - }else if (mode &TDES_FLAGS_CFB16 ) { +break ; + +case TDES_FLAGS_CFB16 :if (!IS_ALIGNED (req->cryptlen,CFB16_BLOCK_SIZE )) {pr_err ("request size is not exact amount of CFB16 blocks\n" );return -EINVAL ; } ctx->block_size =CFB16_BLOCK_SIZE ; - }else if (mode &TDES_FLAGS_CFB32 ) { +break ; + +case TDES_FLAGS_CFB32 :if (!IS_ALIGNED (req->cryptlen,CFB32_BLOCK_SIZE )) {pr_err ("request size is not exact amount of CFB32 blocks\n" );return -EINVAL ; } ctx->block_size =CFB32_BLOCK_SIZE ; - }else { +break ; + +default :if (!IS_ALIGNED (req->cryptlen,DES_BLOCK_SIZE )) {pr_err ("request size is not exact amount of DES blocks\n" );return -EINVAL ; } ctx->block_size =DES_BLOCK_SIZE ; +break ; } rctx->mode = mode;
@@ -844,17 +845,17 @@ static int atmel_tdes_setkey(struct crypto_skcipher *tfm, const u8 *key,static int atmel_tdes_ecb_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT ); +return atmel_tdes_crypt (req,TDES_FLAGS_ECB |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_ecb_decrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,0 ); +return atmel_tdes_crypt (req,TDES_FLAGS_ECB ); }static int atmel_tdes_cbc_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_CBC ); +return atmel_tdes_crypt (req,TDES_FLAGS_CBC |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_cbc_decrypt (struct skcipher_request *req)
@@ -863,50 +864,47 @@ static int atmel_tdes_cbc_decrypt(struct skcipher_request *req) }static int atmel_tdes_cfb_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_CFB ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB64 |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_cfb_decrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_CFB ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB64 ); }static int atmel_tdes_cfb8_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_CFB | -TDES_FLAGS_CFB8 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB8 |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_cfb8_decrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_CFB |TDES_FLAGS_CFB8 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB8 ); }static int atmel_tdes_cfb16_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_CFB | -TDES_FLAGS_CFB16 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB16 |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_cfb16_decrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_CFB |TDES_FLAGS_CFB16 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB16 ); }static int atmel_tdes_cfb32_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_CFB | -TDES_FLAGS_CFB32 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB32 |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_cfb32_decrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_CFB |TDES_FLAGS_CFB32 ); +return atmel_tdes_crypt (req,TDES_FLAGS_CFB32 ); }static int atmel_tdes_ofb_encrypt (struct skcipher_request *req) { -return atmel_tdes_crypt (req,TDES_FLAGS_ENCRYPT |TDES_FLAGS_OFB ); +return atmel_tdes_crypt (req,TDES_FLAGS_OFB |TDES_FLAGS_ENCRYPT ); }static int atmel_tdes_ofb_decrypt (struct skcipher_request *req)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 334/367 net: stmmac: update pci platform data to use phy_interface
In reply to Greg Kroah-HartmanFrom: Voon Weifeng <[email protected]>
[ Upstream commit 909c1dde67c433f1e4122f2619cbd8ac370fcf0a ]
The recent patch to support passive mode converter did not take care the phy interface configuration in PCI platform data. Hence, converting all the PCI platform data from plat->interface to plat->phy_interface as the default mode is meant for PHY.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +8 -6
@@ -96,7 +96,7 @@ static int stmmac_default_data(struct pc plat->bus_id =1 ; plat->phy_addr =0 ; - plat->interface =PHY_INTERFACE_MODE_GMII ; + plat->phy_interface =PHY_INTERFACE_MODE_GMII ; plat->dma_cfg->pbl =32 ; plat->dma_cfg->pblx8 = true;
@@ -220,7 +220,8 @@ static int ehl_sgmii_data(struct pci_dev { plat->bus_id =1 ; plat->phy_addr =0 ; - plat->interface =PHY_INTERFACE_MODE_SGMII ; + plat->phy_interface =PHY_INTERFACE_MODE_SGMII ; +return ehl_common_data (pdev, plat); }
@@ -233,7 +234,8 @@ static int ehl_rgmii_data(struct pci_dev { plat->bus_id =1 ; plat->phy_addr =0 ; - plat->interface =PHY_INTERFACE_MODE_RGMII ; + plat->phy_interface =PHY_INTERFACE_MODE_RGMII ; +return ehl_common_data (pdev, plat); }
@@ -261,7 +263,7 @@ static int tgl_sgmii_data(struct pci_dev { plat->bus_id =1 ; plat->phy_addr =0 ; - plat->interface =PHY_INTERFACE_MODE_SGMII ; + plat->phy_interface =PHY_INTERFACE_MODE_SGMII ;return tgl_common_data (pdev, plat); }
@@ -361,7 +363,7 @@ static int quark_default_data(struct pci plat->bus_id =pci_dev_id (pdev); plat->phy_addr = ret; - plat->interface =PHY_INTERFACE_MODE_RMII ; + plat->phy_interface =PHY_INTERFACE_MODE_RMII ; plat->dma_cfg->pbl =16 ; plat->dma_cfg->pblx8 = true;
@@ -418,7 +420,7 @@ static int snps_gmac5_default_data(struc plat->bus_id =1 ; plat->phy_addr =-1 ; - plat->interface =PHY_INTERFACE_MODE_GMII ; + plat->phy_interface =PHY_INTERFACE_MODE_GMII ; plat->dma_cfg->pbl =32 ; plat->dma_cfg->pblx8 = true;
Greg Kroah-Hartman
maintainerPATCH 340/367 ipv6/addrconf: fix potential NULL deref in inet6_set_link_af()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit db3fa271022dacb9f741b96ea4714461a8911bb9 ]
__in6_dev_get(dev) called from inet6_set_link_af() can return NULL.
The needed check has been recently removed, let's add it back.
While do_setlink() does call validate_linkmsg() :
...
err = validate_linkmsg(dev, tb); /* OK at this point */
...
It is possible that the following call happening before the ->set_link_af() removes IPv6 if MTU is less than 1280 :
if (tb[IFLA_MTU]) {
err = dev_set_mtu_ext(dev, nla_get_u32(tb[IFLA_MTU]), extack);
if (err < 0)
goto errout;
status |= DO_SETLINK_MODIFIED;
}...
if (tb[IFLA_AF_SPEC]) {
...
err = af_ops->set_link_af(dev, af);
->inet6_set_link_af() // CRASH because idev is NULLPlease note that IPv4 is immune to the bug since inet_set_link_af() does :
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (!in_dev)
return -EAFNOSUPPORT;
This problem has been mentioned in commit cf7afbfeb8ce ("rtnl: make link af-specific updates atomic") changelog :
This method is not fail proof, while it is currently sufficient to make set_link_af() inerrable and thus 100% atomic, the validation function method will not be able to detect all error scenarios in the future, there will likely always be errors depending on states which are f.e. not protected by rtnl_mutex and thus may change between validation and setting.
IPv6: ADDRCONF(NETDEV_CHANGE): lo: link becomes ready
general protection fault, probably for non-canonical address 0xdffffc0000000056: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000002b0-0x00000000000002b7] CPU: 0 PID: 9698 Comm: syz-executor712 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733 Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00 RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6 RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0 RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0 R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000 FS: 0000000000c46880(0000) GS:ffff8880ae800000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000055f0494ca0d0 CR3: 000000009e4ac000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: do_setlink+0x2a9f/0x3720 net/core/rtnetlink.c:2754 rtnl_group_changelink net/core/rtnetlink.c:3103 [inline] __rtnl_newlink+0xdd1/0x1790 net/core/rtnetlink.c:3257 rtnl_newlink+0x69/0xa0 net/core/rtnetlink.c:3377 rtnetlink_rcv_msg+0x45e/0xaf0 net/core/rtnetlink.c:5438 netlink_rcv_skb+0x177/0x450 net/netlink/af_netlink.c:2477 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:5456 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0x59e/0x7e0 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x91c/0xea0 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:652 [inline] sock_sendmsg+0xd7/0x130 net/socket.c:672 ____sys_sendmsg+0x753/0x880 net/socket.c:2343 ___sys_sendmsg+0x100/0x170 net/socket.c:2397 __sys_sendmsg+0x105/0x1d0 net/socket.c:2430 __do_sys_sendmsg net/socket.c:2439 [inline] __se_sys_sendmsg net/socket.c:2437 [inline] __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2437 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4402e9 Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007fffd62fbcf8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 00000000004402e9 RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000000000003 RBP: 00000000006ca018 R08: 0000000000000008 R09: 00000000004002c8 R10: 0000000000000005 R11: 0000000000000246 R12: 0000000000401b70 R13: 0000000000401c00 R14: 0000000000000000 R15: 0000000000000000 Modules linked in: ---[ end trace cfa7664b8fdcdff3 ]--- RIP: 0010:inet6_set_link_af+0x66e/0xae0 net/ipv6/addrconf.c:5733 Code: 38 d0 7f 08 84 c0 0f 85 20 03 00 00 48 8d bb b0 02 00 00 45 0f b6 64 24 04 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 1a 03 00 00 44 89 a3 b0 02 00 RSP: 0018:ffffc90005b06d40 EFLAGS: 00010206 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff86df39a6 RDX: 0000000000000056 RSI: ffffffff86df3e74 RDI: 00000000000002b0 RBP: ffffc90005b06e70 R08: ffff8880a2ac0380 R09: ffffc90005b06db0 R10: fffff52000b60dbe R11: ffffc90005b06df7 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8880a1fcc424 R15: dffffc0000000000 FS: 0000000000c46880(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020000004 CR3: 000000009e4ac000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- net/ipv6/addrconf.c | 3 +++ 1 file changed, 3 insertions(+)
net/ipv6/addrconf.c +3 -0
@@ -5718,6 +5718,9 @@ static int inet6_set_link_af(struct net_struct nlattr *tb[IFLA_INET6_MAX +1 ];int err; +if (!idev) +return -EAFNOSUPPORT ; +if (nla_parse_nested_deprecated (tb,IFLA_INET6_MAX , nla,NULL ,NULL ) <0 )BUG ();
Greg Kroah-Hartman
maintainerPATCH 362/367 crypto: atmel-{aes,tdes} - Do not save IV for ECB mode
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
[ Upstream commit c65d123742a7bf2a5bc9fa8398e1fd2376eb4c43 ]
ECB mode does not use IV.
--- drivers/crypto/atmel-aes.c | 9 +++++++-- drivers/crypto/atmel-tdes.c | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/crypto/atmel-aes.c +7 -2
@@ -515,6 +515,9 @@ static void atmel_aes_set_iv_as_last_ciphertext_block(struct atmel_aes_dev *dd)static inline int atmel_aes_complete (struct atmel_aes_dev *dd,int err) { +struct skcipher_request *req =skcipher_request_cast (dd->areq); +struct atmel_aes_reqctx *rctx =skcipher_request_ctx (req); +#if IS_ENABLED (CONFIG_CRYPTO_DEV_ATMEL_AUTHENC )if (dd->ctx->is_aead)atmel_aes_authenc_complete (dd, err);
@@ -523,7 +526,8 @@ static inline int atmel_aes_complete(struct atmel_aes_dev *dd, int err)clk_disable (dd->iclk); dd->flags &= ~AES_FLAGS_BUSY ; -if (!dd->ctx->is_aead) +if (!dd->ctx->is_aead && + (rctx->mode &AES_FLAGS_OPMODE_MASK ) !=AES_FLAGS_ECB )atmel_aes_set_iv_as_last_ciphertext_block (dd);if (dd->is_async)
@@ -1121,7 +1125,8 @@ static int atmel_aes_crypt(struct skcipher_request *req, unsigned long mode) rctx =skcipher_request_ctx (req); rctx->mode = mode; -if (!(mode &AES_FLAGS_ENCRYPT ) && (req->src == req->dst)) { +if ((mode &AES_FLAGS_OPMODE_MASK ) !=AES_FLAGS_ECB && + !(mode &AES_FLAGS_ENCRYPT ) && req->src == req->dst) {unsigned int ivsize =crypto_skcipher_ivsize (skcipher);if (req->cryptlen >= ivsize)
drivers/crypto/atmel-tdes.c +5 -2
@@ -600,12 +600,14 @@ atmel_tdes_set_iv_as_last_ciphertext_block(struct atmel_tdes_dev *dd)static void atmel_tdes_finish_req (struct atmel_tdes_dev *dd,int err) {struct skcipher_request *req = dd->req; +struct atmel_tdes_reqctx *rctx =skcipher_request_ctx (req);clk_disable_unprepare (dd->iclk); dd->flags &= ~TDES_FLAGS_BUSY ; -atmel_tdes_set_iv_as_last_ciphertext_block (dd); +if ((rctx->mode &TDES_FLAGS_OPMODE_MASK ) !=TDES_FLAGS_ECB ) +atmel_tdes_set_iv_as_last_ciphertext_block (dd); req->base.complete (&req->base, err); }
@@ -727,7 +729,8 @@ static int atmel_tdes_crypt(struct skcipher_request *req, unsigned long mode) rctx->mode = mode; -if (!(mode &TDES_FLAGS_ENCRYPT ) && req->src == req->dst) { +if ((mode &TDES_FLAGS_OPMODE_MASK ) !=TDES_FLAGS_ECB && + !(mode &TDES_FLAGS_ENCRYPT ) && req->src == req->dst) {unsigned int ivsize =crypto_skcipher_ivsize (skcipher);if (req->cryptlen >= ivsize)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 355/367 io_uring: prevent potential eventfd recursion on poll
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit f0b493e6b9a8959356983f57112229e69c2f7b8c ]
If we have nested or circular eventfd wakeups, then we can deadlock if we run them inline from our poll waitqueue wakeup handler. It's also possible to have very long chains of notifications, to the extent where we could risk blowing the stack.
Check the eventfd recursion count before calling eventfd_signal(). If it's non-zero, then punt the signaling to async context. This is always safe, as it takes us out-of-line in terms of stack and locking context.
--- fs/io_uring.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-)
fs/io_uring.c +29 -6
@@ -738,21 +738,28 @@ static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)static inline bool io_should_trigger_evfd (struct io_ring_ctx *ctx) { +if (!ctx->cq_ev_fd) +return false;if (!ctx->eventfd_async)return true;return io_wq_current_is_worker () ||in_interrupt (); } -static void io_cqring_ev_posted (struct io_ring_ctx *ctx) +static void __io_cqring_ev_posted (struct io_ring_ctx *ctx,bool trigger_ev) {if (waitqueue_active (&ctx->wait))wake_up (&ctx->wait);if (waitqueue_active (&ctx->sqo_wait))wake_up (&ctx->sqo_wait); -if (ctx->cq_ev_fd &&io_should_trigger_evfd (ctx)) +if (trigger_ev)eventfd_signal (ctx->cq_ev_fd,1 ); } +static void io_cqring_ev_posted (struct io_ring_ctx *ctx) +{ +__io_cqring_ev_posted (ctx,io_should_trigger_evfd (ctx)); +} +/* Returns true if there are no backlogged entries after the flush */ static bool io_cqring_overflow_flush (struct io_ring_ctx *ctx,bool force) {
@@ -2645,6 +2652,14 @@ static void io_poll_complete_work(struct io_wq_work **workptr)io_wq_assign_next (workptr, nxt); } +static void io_poll_trigger_evfd (struct io_wq_work **workptr) +{ + struct io_kiocb *req = container_of(*workptr, struct io_kiocb, work); + +eventfd_signal (req->ctx->cq_ev_fd,1 ); +io_put_req (req); +} +static int io_poll_wake (struct wait_queue_entry *wait,unsigned mode,int sync,void *key) {
@@ -2667,13 +2682,21 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,* for finalizing the request, mark us as having grabbed that already. */ if (mask &&spin_trylock_irqsave (&ctx->completion_lock, flags)) { +bool trigger_ev; +hash_del (&req->hash_node);io_poll_complete (req, mask,0 ); - req->flags |=REQ_F_COMP_LOCKED ; -io_put_req (req); + trigger_ev =io_should_trigger_evfd (ctx); +if (trigger_ev &&eventfd_signal_count ()) { + trigger_ev = false; + req->work.func = io_poll_trigger_evfd; + }else { + req->flags |=REQ_F_COMP_LOCKED ; +io_put_req (req); + req =NULL ; + }spin_unlock_irqrestore (&ctx->completion_lock, flags); - -io_cqring_ev_posted (ctx); +__io_cqring_ev_posted (ctx, trigger_ev); }else {io_queue_async_work (req); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 354/367 io_uring: enable option to only trigger eventfd for async completions
In reply to Greg Kroah-Hartman[ Upstream commit f2842ab5b72d7ee5f7f8385c2d4f32c133f5837b ]
If an application is using eventfd notifications with poll to know when new SQEs can be issued, it's expecting the following read/writes to complete inline. And with that, it knows that there are events available, and don't want spurious wakeups on the eventfd for those requests.
This adds IORING_REGISTER_EVENTFD_ASYNC, which works just like IORING_REGISTER_EVENTFD, except it only triggers notifications for events that happen from async completions (IRQ, or io-wq worker completions). Any completions inline from the submission itself will not trigger notifications.
--- fs/io_uring.c | 17 ++++++++++++++++- include/uapi/linux/io_uring.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-)
fs/io_uring.c +16 -1
@@ -188,6 +188,7 @@ struct io_ring_ctx {bool account_mem;bool cq_overflow_flushed;bool drain_next; +bool eventfd_async;/* * Ring buffer of indices into array of io_uring_sqe, which is
@@ -735,13 +736,20 @@ static struct io_uring_cqe *io_get_cqring(struct io_ring_ctx *ctx)return &rings->cqes[tail & ctx->cq_mask]; } +static inline bool io_should_trigger_evfd (struct io_ring_ctx *ctx) +{ +if (!ctx->eventfd_async) +return true; +return io_wq_current_is_worker () ||in_interrupt (); +} +static void io_cqring_ev_posted (struct io_ring_ctx *ctx) {if (waitqueue_active (&ctx->wait))wake_up (&ctx->wait);if (waitqueue_active (&ctx->sqo_wait))wake_up (&ctx->sqo_wait); -if (ctx->cq_ev_fd) +if (ctx->cq_ev_fd &&io_should_trigger_evfd (ctx))eventfd_signal (ctx->cq_ev_fd,1 ); }
@@ -5486,10 +5494,17 @@ static int __io_uring_register(struct io_ring_ctx *ctx, unsigned opcode, ret =io_sqe_files_update (ctx, arg, nr_args);break ;case IORING_REGISTER_EVENTFD : +case IORING_REGISTER_EVENTFD_ASYNC : ret = -EINVAL ;if (nr_args !=1 )break ; ret =io_eventfd_register (ctx, arg); +if (ret) +break ; +if (opcode ==IORING_REGISTER_EVENTFD_ASYNC ) + ctx->eventfd_async =1 ; +else + ctx->eventfd_async =0 ;break ;case IORING_UNREGISTER_EVENTFD : ret = -EINVAL ;
include/uapi/linux/io_uring.h +1 -0
@@ -175,6 +175,7 @@ struct io_uring_params {#define IORING_REGISTER_EVENTFD 4#define IORING_UNREGISTER_EVENTFD 5#define IORING_REGISTER_FILES_UPDATE 6 +#define IORING_REGISTER_EVENTFD_ASYNC 7struct io_uring_files_update {__u32 offset;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 345/367 r8169: fix performance regression related to PCIe max read request size
In reply to Greg Kroah-HartmanFrom: Heiner Kallweit <[email protected]>
[ Upstream commit 21b5f672fb2eb1366dedc4ac9d32431146b378d3 ]
It turned out that on low performance systems the original change can cause lower tx performance. On a N3450-based mini-PC tx performance in iperf3 was reduced from 950Mbps to ~900Mbps. Therefore effectively revert the original change, just use pcie_set_readrq() now instead of changing the PCIe capability register directly.
--- drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +6 -0
@@ -3865,15 +3865,18 @@ static void rtl_hw_jumbo_enable(struct rswitch (tp->mac_version) {case RTL_GIGA_MAC_VER_12 :case RTL_GIGA_MAC_VER_17 : +pcie_set_readrq (tp->pci_dev,512 );r8168b_1_hw_jumbo_enable (tp);break ; case RTL_GIGA_MAC_VER_18 ... RTL_GIGA_MAC_VER_26: +pcie_set_readrq (tp->pci_dev,512 );r8168c_hw_jumbo_enable (tp);break ; case RTL_GIGA_MAC_VER_27 ... RTL_GIGA_MAC_VER_28:r8168dp_hw_jumbo_enable (tp);break ; case RTL_GIGA_MAC_VER_31 ... RTL_GIGA_MAC_VER_33: +pcie_set_readrq (tp->pci_dev,512 );r8168e_hw_jumbo_enable (tp);break ;default :
@@ -3903,6 +3906,9 @@ static void rtl_hw_jumbo_disable(structbreak ; }rtl_lock_config_regs (tp); + +if (pci_is_pcie (tp->pci_dev) && tp->supports_gmii) +pcie_set_readrq (tp->pci_dev,4096 ); }static void rtl_jumbo_config (struct rtl8169_private *tp,int mtu)
Greg Kroah-Hartman
maintainerPATCH 329/367 net: macb: Limit maximum GEM TX length in TSO
In reply to Greg Kroah-HartmanFrom: Harini Katakam <[email protected]>
[ Upstream commit f822e9c4ffa511a5c681cf866287d9383a3b6f1b ]
GEM_MAX_TX_LEN currently resolves to 0x3FF8 for any IP version supporting TSO with full 14bits of length field in payload descriptor. But an IP errata causes false amba_error (bit 6 of ISR) when length in payload descriptors is specified above 16387. The error occurs because the DMA falsely concludes that there is not enough space in SRAM for incoming payload. These errors were observed continuously under stress of large packets using iperf on a version where SRAM was 16K for each queue. This errata will be documented shortly and affects all versions since TSO functionality was added. Hence limit the max length to 0x3FC0 (rounded).
--- drivers/net/ethernet/cadence/macb_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +5 -1
@@ -73,7 +73,11 @@ struct sifive_fu540_macb_mgmt {/* Max length of transmit frame must be a multiple of 8 bytes */ #define MACB_TX_LEN_ALIGN 8#define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) -#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) +/* Limit maximum TX length as per Cadence TSO errata. This is to avoid a +* false amba_error in TX path from the DMA assuming there is not enough +* space in the SRAM (16KB) even when there is. +*/ +#define GEM_MAX_TX_LEN (unsigned int)(0x3FC0)#define GEM_MTU_MIN_SIZE ETH_MIN_MTU#define MACB_NETIF_LSO NETIF_F_TSO
Greg Kroah-Hartman
maintainerPATCH 307/367 ASoC: sgtl5000: Fix VDDA and VDDIO comparison
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
commit e19ecbf105b236a6334fab64d8fd5437b12ee019 upstream.
Comparing the voltage of VDDA and VDDIO to determine whether or not to enable VDDC manual override is insufficient. This is a problem in case the VDDA is supplied from different regulator than VDDIO, while both report the same voltage to the regulator framework. In that case where VDDA and VDDIO is supplied by different regulators, the VDDC manual override must not be applied.
--- sound/soc/codecs/sgtl5000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/codecs/sgtl5000.c +2 -1
@@ -1344,7 +1344,8 @@ static int sgtl5000_set_power_regs(struc* if vddio == vdda the source of charge pump should be * assigned manually to VDDIO */ -if (vddio == vdda) { +if (regulator_is_equal (sgtl5000->supplies[VDDA ].consumer, + sgtl5000->supplies[VDDIO ].consumer)) { lreg_ctrl |=SGTL5000_VDDC_ASSN_OVRD ; lreg_ctrl |=SGTL5000_VDDC_MAN_ASSN_VDDIO <<SGTL5000_VDDC_MAN_ASSN_SHIFT ;
Greg Kroah-Hartman
maintainerPATCH 300/367 nfsd: Return the correct number of bytes written to the file
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 09a80f2aef06b7c86143f5c14efd3485e0d2c139 upstream.
We must allow for the fact that iov_iter_write() could have returned a short write (e.g. if there was an ENOSPC issue).
--- fs/nfsd/vfs.c | 1 + 1 file changed, 1 insertion(+)
fs/nfsd/vfs.c +1 -0
@@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s host_err =vfs_iter_write (file, &iter, &pos, flags);if (host_err <0 ) goto out_nfserr; + *cnt = host_err; nfsdstats.io_write += *cnt;fsnotify_modify (file);
Greg Kroah-Hartman
maintainerPATCH 299/367 nfsd: fix jiffies/time_t mixup in LRU list
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 9594497f2c78993cb66b696122f7c65528ace985 upstream.
The nfsd4_blocked_lock->nbl_time timestamp is recorded in jiffies, but then compared to a CLOCK_REALTIME timestamp later on, which makes no sense.
For consistency with the other timestamps, change this to use a time_t.
This is a change in behavior, which may cause regressions, but the current code is not sensible. On a system with CONFIG_HZ=1000, the 'time_after((unsigned long)nbl->nbl_time, (unsigned long)cutoff))' check is false for roughly the first 18 days of uptime and then true for the next 49 days.
--- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/state.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -1
@@ -6550,7 +6550,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struc }if (fl_flags &FL_SLEEP ) { - nbl->nbl_time = jiffies; + nbl->nbl_time =get_seconds ();spin_lock (&nn->blocked_locks_lock);list_add_tail (&nbl->nbl_list, &lock_sop->lo_blocked);list_add_tail (&nbl->nbl_lru, &nn->blocked_locks_lru);
fs/nfsd/state.h +1 -1
@@ -606,7 +606,7 @@ static inline bool nfsd4_stateid_generatstruct nfsd4_blocked_lock {struct list_head nbl_list;struct list_head nbl_lru; -unsigned long nbl_time; +time_t nbl_time;struct file_lock nbl_lock;struct knfsd_fh nbl_fh;struct nfsd4_callback nbl_cb;
Greg Kroah-Hartman
maintainerPATCH 284/367 compat: scsi: sg: fix v3 compat read/write interface
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit 78ed001d9e7106171e0ee761cd854137dd731302 upstream.
In the v5.4 merge window, a cleanup patch from Al Viro conflicted with my rework of the compat handling for sg.c read(). Linus Torvalds did a correct merge but pointed out that the resulting code is still unsatisfactory.
I later noticed that the sg_new_read() function still gets the compat mode wrong, when the 'count' argument is large enough to pass a compat_sg_io_hdr object, but not a nativ sg_io_hdr.
To address both of these, move the definition of compat_sg_io_hdr into a scsi/sg.h to make it visible to sg.c and rewrite the logic for reading req_pack_id as well as the size check to a simpler version that gets the expected results.
--- block/scsi_ioctl.c | 29 ------------ drivers/scsi/sg.c | 126 ++++++++++++++++++++++++----------------------------- include/scsi/sg.h | 30 ++++++++++++ 3 files changed, 90 insertions(+), 95 deletions(-)
block/scsi_ioctl.c +1 -28
@@ -20,6 +20,7 @@#include <scsi/scsi.h> #include <scsi/scsi_ioctl.h> #include <scsi/scsi_cmnd.h> +#include <scsi/sg.h> struct blk_cmd_filter {unsigned long read_ok[BLK_SCSI_CMD_PER_LONG ];
@@ -550,34 +551,6 @@ static inline int blk_send_start_stop(streturn __blk_send_generic (q, bd_disk,GPCMD_START_STOP_UNIT , data); } -#ifdef CONFIG_COMPAT -struct compat_sg_io_hdr { -compat_int_t interface_id;/* [i] 'S' for SCSI generic (required) */ -compat_int_t dxfer_direction;/* [i] data transfer direction */ -unsigned char cmd_len;/* [i] SCSI command length ( <= 16 bytes) */ -unsigned char mx_sb_len;/* [i] max length to write to sbp */ -unsigned short iovec_count;/* [i] 0 implies no scatter gather */ -compat_uint_t dxfer_len;/* [i] byte count of data transfer */ -compat_uint_t dxferp;/* [i], [*io] points to data transfer memory -or scatter gather list */ -compat_uptr_t cmdp;/* [i], [*i] points to command to perform */ -compat_uptr_t sbp;/* [i], [*o] points to sense_buffer memory */ -compat_uint_t timeout;/* [i] MAX_UINT->no timeout (unit: millisec) */ -compat_uint_t flags;/* [i] 0 -> default, see SG_FLAG... */ -compat_int_t pack_id;/* [i->o] unused internally (normally) */ -compat_uptr_t usr_ptr;/* [i->o] unused internally */ -unsigned char status;/* [o] scsi status */ -unsigned char masked_status;/* [o] shifted, masked scsi status */ -unsigned char msg_status;/* [o] messaging level data (optional) */ -unsigned char sb_len_wr;/* [o] byte count actually written to sbp */ -unsigned short host_status;/* [o] errors from host adapter */ -unsigned short driver_status;/* [o] errors from software driver */ -compat_int_t resid;/* [o] dxfer_len - actual_transferred */ -compat_uint_t duration;/* [o] time taken by cmd (unit: millisec) */ -compat_uint_t info;/* [o] auxiliary information */ -}; -#endif -int put_sg_io_hdr (const struct sg_io_hdr *hdr,void __user *argp) {#ifdef CONFIG_COMPAT
drivers/scsi/sg.c +59 -67
159 lines not on this page · raw message
include/scsi/sg.h +30 -0
@@ -68,6 +68,36 @@ typedef struct sg_io_hdrunsigned int info;/* [o] auxiliary information */ } sg_io_hdr_t;/* 64 bytes long (on i386) */ +#if defined(__KERNEL__) +#include <linux/compat.h> + +struct compat_sg_io_hdr { +compat_int_t interface_id;/* [i] 'S' for SCSI generic (required) */ +compat_int_t dxfer_direction;/* [i] data transfer direction */ +unsigned char cmd_len;/* [i] SCSI command length ( <= 16 bytes) */ +unsigned char mx_sb_len;/* [i] max length to write to sbp */ +unsigned short iovec_count;/* [i] 0 implies no scatter gather */ +compat_uint_t dxfer_len;/* [i] byte count of data transfer */ +compat_uint_t dxferp;/* [i], [*io] points to data transfer memory +or scatter gather list */ +compat_uptr_t cmdp;/* [i], [*i] points to command to perform */ +compat_uptr_t sbp;/* [i], [*o] points to sense_buffer memory */ +compat_uint_t timeout;/* [i] MAX_UINT->no timeout (unit: millisec) */ +compat_uint_t flags;/* [i] 0 -> default, see SG_FLAG... */ +compat_int_t pack_id;/* [i->o] unused internally (normally) */ +compat_uptr_t usr_ptr;/* [i->o] unused internally */ +unsigned char status;/* [o] scsi status */ +unsigned char masked_status;/* [o] shifted, masked scsi status */ +unsigned char msg_status;/* [o] messaging level data (optional) */ +unsigned char sb_len_wr;/* [o] byte count actually written to sbp */ +unsigned short host_status;/* [o] errors from host adapter */ +unsigned short driver_status;/* [o] errors from software driver */ +compat_int_t resid;/* [o] dxfer_len - actual_transferred */ +compat_uint_t duration;/* [o] time taken by cmd (unit: millisec) */ +compat_uint_t info;/* [o] auxiliary information */ +}; +#endif +#define SG_INTERFACE_ID_ORIG 'S'/* Use negative values to flag difference from original sg_header structure */
Greg Kroah-Hartman
maintainerPATCH 271/367 drm/amdgpu: fetch default VDDC curve voltages (v2)
In reply to Greg Kroah-HartmanFrom: Alex Deucher <[email protected]>
commit 0531aa6eb38bfa9514609e2727558a051da7365f upstream.
Ask the SMU for the default VDDC curve voltage values. This properly reports the VDDC values in the OD interface.
v2: only update if the original values are 0
--- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 50 ++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +49 -1
@@ -121,6 +121,8 @@ static struct smu_11_0_cmn2aisc_mappingMSG_MAP (ArmD3, PPSMC_MSG_ArmD3),MSG_MAP (DAL_DISABLE_DUMMY_PSTATE_CHANGE ,PPSMC_MSG_DALDisableDummyPstateChange),MSG_MAP (DAL_ENABLE_DUMMY_PSTATE_CHANGE , PPSMC_MSG_DALEnableDummyPstateChange), +MSG_MAP (GetVoltageByDpm, PPSMC_MSG_GetVoltageByDpm), + MSG_MAP(GetVoltageByDpmOverdrive, PPSMC_MSG_GetVoltageByDpmOverdrive), }; static struct smu_11_0_cmn2aisc_mapping navi10_clk_map[SMU_CLK_COUNT] = {
@@ -1782,6 +1784,28 @@ static int navi10_od_setting_check_rangereturn 0 ; } +static int navi10_overdrive_get_gfx_clk_base_voltage (struct smu_context *smu, +uint16_t *voltage, +uint32_t freq) +{ +uint32_t param = (freq &0xFFFF ) | (PPCLK_GFXCLK <<16 ); +uint32_t value =0 ; +int ret; + + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_GetVoltageByDpm, + param); +if (ret) { +pr_err ("[GetBaseVoltage] failed to get GFXCLK AVFS voltage from SMU!" ); +return ret; + } + +smu_read_smc_arg (smu, &value); + *voltage = (uint16_t )value; + +return 0 ; +} +static int navi10_setup_od_limits (struct smu_context *smu) {struct smu_11_0_overdrive_table *overdrive_table =NULL ;struct smu_11_0_powerplay_table *powerplay_table =NULL ;
@@ -1808,16 +1832,40 @@ static int navi10_set_default_od_settingif (ret)return ret; + od_table = (OverDriveTable_t *)smu->smu_table.overdrive_table;if (initialize) { ret =navi10_setup_od_limits (smu);if (ret) {pr_err ("Failed to retrieve board OD limits\n" );return ret; } +if (od_table) { +if (!od_table->GfxclkVolt1) { + ret =navi10_overdrive_get_gfx_clk_base_voltage (smu, + &od_table->GfxclkVolt1, + od_table->GfxclkFreq1); +if (ret) + od_table->GfxclkVolt1 =0 ; + } + +if (!od_table->GfxclkVolt2) { + ret =navi10_overdrive_get_gfx_clk_base_voltage (smu, + &od_table->GfxclkVolt2, + od_table->GfxclkFreq2); +if (ret) + od_table->GfxclkVolt2 =0 ; + } +if (!od_table->GfxclkVolt3) { + ret =navi10_overdrive_get_gfx_clk_base_voltage (smu, + &od_table->GfxclkVolt3, + od_table->GfxclkFreq3); +if (ret) + od_table->GfxclkVolt3 =0 ; + } + } } - od_table = (OverDriveTable_t *)smu->smu_table.overdrive_table;if (od_table) {navi10_dump_od_table (od_table); }
Greg Kroah-Hartman
maintainerPATCH 264/367 mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
commit 0ed1325967ab5f7a4549a2641c6ebe115f76e228 upstream.
Architectures for which we have hardware walkers of Linux page table should flush TLB on mmu gather batch allocation failures and batch flush. Some architectures like POWER supports multiple translation modes (hash and radix) and in the case of POWER only radix translation mode needs the above TLBI. This is because for hash translation mode kernel wants to avoid this extra flush since there are no hardware walkers of linux page table. With radix translation, the hardware also walks linux page table and with that, kernel needs to make sure to TLB invalidate page walk cache before page table pages are freed.
More details in commit d86564a2f085 ("mm/tlb, x86/mm: Support invalidating TLB caches for RCU_TABLE_FREE")
The changes to sparc are to make sure we keep the old behavior since we are now removing HAVE_RCU_TABLE_NO_INVALIDATE. The default value for tlb_needs_table_invalidate is to always force an invalidate and sparc can avoid the table invalidate. Hence we define tlb_needs_table_invalidate to false for sparc architecture.
--- arch/Kconfig | 3 --- arch/powerpc/Kconfig | 1 - arch/powerpc/include/asm/tlb.h | 11 +++++++++++ arch/sparc/Kconfig | 1 - arch/sparc/include/asm/tlb_64.h | 9 +++++++++ include/asm-generic/tlb.h | 22 +++++++++++++++------- mm/mmu_gather.c | 16 ++++++++-------- 7 files changed, 43 insertions(+), 20 deletions(-)
arch/Kconfig +0 -3
@@ -396,9 +396,6 @@ config HAVE_ARCH_JUMP_LABEL_RELATIVE config HAVE_RCU_TABLE_FREE bool -config HAVE_RCU_TABLE_NO_INVALIDATE - bool - config HAVE_MMU_GATHER_PAGE_SIZE bool
arch/powerpc/Kconfig +0 -1
@@ -223,7 +223,6 @@ config PPC select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP select HAVE_RCU_TABLE_FREE - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_MMU_GATHER_PAGE_SIZE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
arch/powerpc/include/asm/tlb.h +11 -0
@@ -26,6 +26,17 @@#define tlb_flush tlb_flushextern void tlb_flush (struct mmu_gather *tlb); +/* +* book3s: +* Hash does not use the linux page-tables, so we can avoid +* the TLB invalidate for page-table freeing, Radix otoh does use the +* page-tables and needs the TLBI. +* +* nohash: +* We still do TLB invalidate in the __pte_free_tlb routine before we +* add the page table pages to mmu gather table batch. +*/ +#define tlb_needs_table_invalidate () radix_enabled()/* Get the generic bits... */ #include <asm-generic/tlb.h>
arch/sparc/Kconfig +0 -1
@@ -65,7 +65,6 @@ config SPARC64 select HAVE_KRETPROBES select HAVE_KPROBES select HAVE_RCU_TABLE_FREE if SMP - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_MEMBLOCK_NODE_MAP select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_DYNAMIC_FTRACE
arch/sparc/include/asm/tlb_64.h +9 -0
@@ -28,6 +28,15 @@ void flush_tlb_pending(void);#define __tlb_remove_tlb_entry (tlb, ptep, address) do { } while (0)#define tlb_flush (tlb) flush_tlb_pending() +/* +* SPARC64's hardware TLB fill does not use the Linux page-tables +* and therefore we don't need a TLBI when freeing page-table pages. +*/ + +#ifdef CONFIG_HAVE_RCU_TABLE_FREE +#define tlb_needs_table_invalidate () (false) +#endif +#include <asm-generic/tlb.h> #endif /* _SPARC64_TLB_H */
include/asm-generic/tlb.h +15 -7
@@ -137,13 +137,6 @@* When used, an architecture is expected to provide __tlb_remove_table() * which does the actual freeing of these pages. * -* HAVE_RCU_TABLE_NO_INVALIDATE -* -* This makes HAVE_RCU_TABLE_FREE avoid calling tlb_flush_mmu_tlbonly() before -* freeing the page-table pages. This can be avoided if you use -* HAVE_RCU_TABLE_FREE and your architecture does _NOT_ use the Linux -* page-tables natively. -* * MMU_GATHER_NO_RANGE * * Use this if your architecture lacks an efficient flush_tlb_range().
@@ -189,8 +182,23 @@ struct mmu_table_batch {extern void tlb_remove_table (struct mmu_gather *tlb,void *table); +/* +* This allows an architecture that does not use the linux page-tables for +* hardware to skip the TLBI when freeing page tables. +*/ +#ifndef tlb_needs_table_invalidate +#define tlb_needs_table_invalidate () (true)#endif +#else + +#ifdef tlb_needs_table_invalidate +#error tlb_needs_table_invalidate() requires HAVE_RCU_TABLE_FREE +#endif + +#endif /* CONFIG_HAVE_RCU_TABLE_FREE */ + +#ifndef CONFIG_HAVE_MMU_GATHER_NO_GATHER /* * If we can't allocate a page to make a big batch of page pointers
mm/mmu_gather.c +8 -8
@@ -102,14 +102,14 @@ bool __tlb_remove_page_size(struct mmu_g*/ static inline void tlb_table_invalidate (struct mmu_gather *tlb) { -#ifndef CONFIG_HAVE_RCU_TABLE_NO_INVALIDATE -/* -* Invalidate page-table caches used by hardware walkers. Then we still -* need to RCU-sched wait while freeing the pages because software -* walkers can still be in-flight. -*/ -tlb_flush_mmu_tlbonly (tlb); -#endif +if (tlb_needs_table_invalidate ()) { +/* +* Invalidate page-table caches used by hardware walkers. Then +* we still need to RCU-sched wait while freeing the pages +* because software walkers can still be in-flight. +*/ +tlb_flush_mmu_tlbonly (tlb); + } }static void tlb_remove_table_smp_sync (void *arg)
Greg Kroah-Hartman
maintainerPATCH 227/367 KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks
In reply to Greg Kroah-HartmanFrom: Marios Pomonis <[email protected]>
commit 14e32321f3606e4b0970200b6e5e47ee6f1e6410 upstream.
This fixes a Spectre-v1/L1TF vulnerability in picdev_write(). It replaces index computations based on the (attacked-controlled) port number with constants through a minor refactoring.
--- arch/x86/kvm/i8259.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/kvm/i8259.c +5 -1
@@ -460,10 +460,14 @@ static int picdev_write(struct kvm_pic *switch (addr) {case 0x20 :case 0x21 : +pic_lock (s); +pic_ioport_write (&s->pics[0 ], addr, data); +pic_unlock (s); +break ;case 0xa0 :case 0xa1 :pic_lock (s); -pic_ioport_write (&s->pics[addr >>7 ], addr, data); +pic_ioport_write (&s->pics[1 ], addr, data);pic_unlock (s);break ;case 0x4d0 :
Greg Kroah-Hartman
maintainerPATCH 196/367 Btrfs: make deduplication with range including the last block work
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 831d2fa25ab8e27592b1b0268dae6f2dfaf7cc43 upstream.
Since btrfs was migrated to use the generic VFS helpers for clone and deduplication, it stopped allowing for the last block of a file to be deduplicated when the source file size is not sector size aligned (when eof is somewhere in the middle of the last block). There are two reasons for that:
1) The generic code always rounds down, to a multiple of the block size, the range's length for deduplications. This means we end up never deduplicating the last block when the eof is not block size aligned, even for the safe case where the destination range's end offset matches the destination file's size. That rounding down operation is done at generic_remap_check_len();
2) Because of that, the btrfs specific code does not expect anymore any non-aligned range length's for deduplication and therefore does not work if such nona-aligned length is given.
This patch addresses that second part, and it depends on a patch that fixes generic_remap_check_len(), in the VFS, which was submitted ealier and has the following subject:
"fs: allow deduplication of eof block into the end of the destination file"
These two patches address reports from users that started seeing lower deduplication rates due to the last block never being deduplicated when the file size is not aligned to the filesystem's block size.
--- fs/btrfs/ioctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/ioctl.c +2 -1
@@ -3243,6 +3243,7 @@ static void btrfs_double_extent_lock(strstatic int btrfs_extent_same_range (struct inode *src,u64 loff,u64 len,struct inode *dst,u64 dst_loff) { +const u64 bs =BTRFS_I (src)->root->fs_info->sb->s_blocksize;int ret;/*
@@ -3250,7 +3251,7 @@ static int btrfs_extent_same_range(struc* source range to serialize with relocation. */ btrfs_double_extent_lock (src, loff, dst, dst_loff, len); - ret =btrfs_clone (src, dst, loff, len, len, dst_loff,1 ); + ret =btrfs_clone (src, dst, loff, len,ALIGN (len, bs), dst_loff,1 );btrfs_double_extent_unlock (src, loff, dst, dst_loff, len);return ret;
Greg Kroah-Hartman
maintainerPATCH 190/367 NFS: Directory page cache pages need to be locked when read
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 114de38225d9b300f027e2aec9afbb6e0def154b upstream.
When a NFS directory page cache page is removed from the page cache, its contents are freed through a call to nfs_readdir_clear_array(). To prevent the removal of the page cache entry until after we've finished reading it, we must take the page lock.
--- fs/nfs/dir.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
fs/nfs/dir.c +19 -11
@@ -702,8 +702,6 @@ int nfs_readdir_filler(void *data, strucstatic void cache_page_release (nfs_readdir_descriptor_t *desc) { -if (!desc->page->mapping) -nfs_readdir_clear_array (desc->page);put_page (desc->page); desc->page =NULL ; }
@@ -717,19 +715,28 @@ struct page *get_cache_page(nfs_readdir_/* * Returns 0 if desc->dir_cookie was found on page desc->page_index +* and locks the page to prevent removal from the page cache. */ static -int find_cache_page (nfs_readdir_descriptor_t *desc) +int find_and_lock_cache_page (nfs_readdir_descriptor_t *desc) {int res; desc->page =get_cache_page (desc);if (IS_ERR (desc->page))return PTR_ERR (desc->page); - - res =nfs_readdir_search_array (desc); + res =lock_page_killable (desc->page);if (res !=0 ) -cache_page_release (desc); + goto error; + res = -EAGAIN ; +if (desc->page->mapping !=NULL ) { + res =nfs_readdir_search_array (desc); +if (res ==0 ) +return 0 ; + } +unlock_page (desc->page); +error: +cache_page_release (desc);return res; }
@@ -744,7 +751,7 @@ int readdir_search_pagecache(nfs_readdir desc->last_cookie =0 ; }do { - res =find_cache_page (desc); + res =find_and_lock_cache_page (desc); }while (res == -EAGAIN );return res; }
@@ -783,7 +790,6 @@ int nfs_do_filldir(nfs_readdir_descripto desc->eof = true;kunmap (desc->page); -cache_page_release (desc);dfprintk (DIRCACHE ,"NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n" , (unsigned long long )*desc->dir_cookie, res);return res;
@@ -829,13 +835,13 @@ int uncached_readdir(nfs_readdir_descrip status =nfs_do_filldir (desc); + out_release: +nfs_readdir_clear_array (desc->page); +cache_page_release (desc); out:dfprintk (DIRCACHE ,"NFS: %s: returns %d\n" , __func__, status);return status; - out_release: -cache_page_release (desc); - goto out; }/* The file offset position represents the dirent entry number. A
@@ -900,6 +906,8 @@ static int nfs_readdir(struct file *filebreak ; res =nfs_do_filldir (desc); +unlock_page (desc->page); +cache_page_release (desc);if (res <0 )break ; }while (!desc->eof);
Greg Kroah-Hartman
maintainerPATCH 191/367 nfsd: fix filecache lookup
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 28c7d86bb6172ffbb1a1237c6388e77f9fe5f181 upstream.
If the lookup keeps finding a nfsd_file with an unhashed open file, then retry once only.
--- fs/nfsd/filecache.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nfsd/filecache.c +6 -0
@@ -789,6 +789,7 @@ nfsd_file_acquire(struct svc_rqst *rqstpstruct nfsd_file *nf, *new;struct inode *inode;unsigned int hashval; +bool retry = true;/* FIXME: skip this if fh_dentry is already set? */ status = fh_verify(rqstp, fhp, S_IFREG,
@@ -824,6 +825,11 @@ wait_for_construction:/* Did construction of this file fail? */ if (!test_bit (NFSD_FILE_HASHED , &nf->nf_flags)) { +if (!retry) { + status = nfserr_jukebox; + goto out; + } + retry = false;nfsd_file_put_noref (nf); goto retry; }
Greg Kroah-Hartman
maintainerPATCH 189/367 NFS: Fix memory leaks and corruption in readdir
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 4b310319c6a8ce708f1033d57145e2aa027a883c upstream.
nfs_readdir_xdr_to_array() must not exit without having initialised the array, so that the page cache deletion routines can safely call nfs_readdir_clear_array().
Furthermore, we should ensure that if we exit nfs_readdir_filler() with an error, we free up any page contents to prevent a leak if we try to fill the page again.
--- fs/nfs/dir.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
fs/nfs/dir.c +15 -2
@@ -162,6 +162,17 @@ typedef struct {bool eof; } nfs_readdir_descriptor_t; +static +void nfs_readdir_init_array (struct page *page) +{ +struct nfs_cache_array *array; + + array =kmap_atomic (page); +memset (array,0 ,sizeof (struct nfs_cache_array )); + array->eof_index =-1 ; +kunmap_atomic (array); +} +/* * we are freeing strings created by nfs_add_to_readdir_array() */
@@ -174,6 +185,7 @@ void nfs_readdir_clear_array(struct page array =kmap_atomic (page);for (i =0 ; i < array->size; i++)kfree (array->array[i].string.name); + array->size =0 ;kunmap_atomic (array); }
@@ -610,6 +622,8 @@ int nfs_readdir_xdr_to_array(nfs_readdirint status = -ENOMEM ;unsigned int array_size =ARRAY_SIZE (pages); +nfs_readdir_init_array (page); + entry.prev_cookie =0 ; entry.cookie = desc->last_cookie; entry.eof =0 ;
@@ -626,8 +640,6 @@ int nfs_readdir_xdr_to_array(nfs_readdir } array =kmap (page); -memset (array,0 ,sizeof (struct nfs_cache_array )); - array->eof_index =-1 ; status =nfs_readdir_alloc_pages (pages, array_size);if (status <0 )
@@ -682,6 +694,7 @@ int nfs_readdir_filler(void *data, strucunlock_page (page);return 0 ; error: +nfs_readdir_clear_array (page);unlock_page (page);return ret; }
Greg Kroah-Hartman
maintainerPATCH 185/367 crypto: api - Fix race condition in crypto_spawn_alg
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 73669cc556462f4e50376538d77ee312142e8a8a upstream.
The function crypto_spawn_alg is racy because it drops the lock before shooting the dying algorithm. The algorithm could disappear altogether before we shoot it.
This patch fixes it by moving the shooting into the locked section.
--- crypto/algapi.c | 16 +++++----------- crypto/api.c | 3 +-- crypto/internal.h | 1 - 3 files changed, 6 insertions(+), 14 deletions(-)
crypto/algapi.c +5 -11
@@ -697,22 +697,16 @@ EXPORT_SYMBOL_GPL(crypto_drop_spawn);static struct crypto_alg *crypto_spawn_alg (struct crypto_spawn *spawn) {struct crypto_alg *alg; -struct crypto_alg *alg2;down_read (&crypto_alg_sem); alg = spawn->alg; - alg2 = alg; -if (alg2) - alg2 =crypto_mod_get (alg2); -up_read (&crypto_alg_sem); - -if (!alg2) { -if (alg) -crypto_shoot_alg (alg); -return ERR_PTR (-EAGAIN ); +if (alg && !crypto_mod_get (alg)) { + alg->cra_flags |=CRYPTO_ALG_DYING ; + alg =NULL ; } +up_read (&crypto_alg_sem); -return alg; +return alg ?:ERR_PTR (-EAGAIN ); } struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
crypto/api.c +1 -2
@@ -346,13 +346,12 @@ static unsigned int crypto_ctxsize(strucreturn len; } -void crypto_shoot_alg (struct crypto_alg *alg) +static void crypto_shoot_alg (struct crypto_alg *alg) {down_write (&crypto_alg_sem); alg->cra_flags |=CRYPTO_ALG_DYING ;up_write (&crypto_alg_sem); } -EXPORT_SYMBOL_GPL (crypto_shoot_alg);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask)
crypto/internal.h +0 -1
@@ -68,7 +68,6 @@ void crypto_alg_tested(const char *name,void crypto_remove_spawns (struct crypto_alg *alg,struct list_head *list,struct crypto_alg *nalg);void crypto_remove_final (struct list_head *list); -void crypto_shoot_alg (struct crypto_alg *alg);struct crypto_tfm *__crypto_alloc_tfm (struct crypto_alg *alg,u32 type,u32 mask); void *crypto_create_tfm(struct crypto_alg *alg,
Greg Kroah-Hartman
maintainerPATCH 175/367 crypto: amlogic - fix removal of module
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 24775ac2fe68132d3e0e7cd3a0521ccb1a5d7243 upstream.
Removing the driver cause an oops due to the fact we clean an extra channel.
Let's give the right index to the cleaning function.
--- drivers/crypto/amlogic/amlogic-gxl-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/amlogic/amlogic-gxl-core.c +2 -2
@@ -289,7 +289,7 @@ static int meson_crypto_probe(struct pla error_alg:meson_unregister_algs (mc); error_flow: -meson_free_chanlist (mc,MAXFLOW ); +meson_free_chanlist (mc,MAXFLOW -1 );clk_disable_unprepare (mc->busclk);return err; }
@@ -304,7 +304,7 @@ static int meson_crypto_remove(struct plmeson_unregister_algs (mc); -meson_free_chanlist (mc,MAXFLOW ); +meson_free_chanlist (mc,MAXFLOW -1 );clk_disable_unprepare (mc->busclk);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 174/367 crypto: sun8i-ss - fix removal of module
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
commit 7b3d853ead8187288bf99df38ed71ee02773a65f upstream.
Removing the driver cause an oops due to the fact we clean an extra channel.
Let's give the right index to the cleaning function.
--- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +2 -2
@@ -595,7 +595,7 @@ error_alg: error_irq:sun8i_ss_pm_exit (ss); error_pm: -sun8i_ss_free_flows (ss,MAXFLOW ); +sun8i_ss_free_flows (ss,MAXFLOW -1 );return err; }
@@ -609,7 +609,7 @@ static int sun8i_ss_remove(struct platfodebugfs_remove_recursive (ss->dbgfs_dir);#endif -sun8i_ss_free_flows (ss,MAXFLOW ); +sun8i_ss_free_flows (ss,MAXFLOW -1 );sun8i_ss_pm_exit (ss);
Greg Kroah-Hartman
maintainerPATCH 114/367 crypto: api - Check spawn->alg under lock in crypto_drop_spawn
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 7db3b61b6bba4310f454588c2ca6faf2958ad79f upstream.
We need to check whether spawn->alg is NULL under lock as otherwise the algorithm could be removed from under us after we have checked it and found it to be non-NULL. This could cause us to remove the spawn from a non-existent list.
--- crypto/algapi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
crypto/algapi.c +2 -4
@@ -669,11 +669,9 @@ EXPORT_SYMBOL_GPL(crypto_grab_spawn);void crypto_drop_spawn (struct crypto_spawn *spawn) { -if (!spawn->alg) -return ; -down_write (&crypto_alg_sem); -list_del (&spawn->list); +if (spawn->alg) +list_del (&spawn->list);up_write (&crypto_alg_sem); }EXPORT_SYMBOL_GPL (crypto_drop_spawn);
Greg Kroah-Hartman
maintainerPATCH 153/367 ftrace: Protect ftrace_graph_hash with ftrace_sync
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit 54a16ff6f2e50775145b210bcd94d62c3c2af117 ]
As function_graph tracer can run when RCU is not "watching", it can not be protected by synchronize_rcu() it requires running a task on each CPU before it can be freed. Calling schedule_on_each_cpu(ftrace_sync) needs to be used.
--- kernel/trace/ftrace.c | 11 +++++++++-- kernel/trace/trace.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-)
kernel/trace/ftrace.c +9 -2
@@ -5872,8 +5872,15 @@ ftrace_graph_release(struct inode *inode, struct file *file)mutex_unlock (&graph_lock); -/* Wait till all users are no longer using the old hash */ -synchronize_rcu (); +/* +* We need to do a hard force of sched synchronization. +* This is because we use preempt_disable() to do RCU, but +* the function tracers can be called where RCU is not watching +* (like before user_exit()). We can not rely on the RCU +* infrastructure to do the synchronization, thus we must do it +* ourselves. +*/ +schedule_on_each_cpu (ftrace_sync);free_ftrace_hash (old_hash); }
kernel/trace/trace.h +2 -0
@@ -965,6 +965,7 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)* Have to open code "rcu_dereference_sched()" because the * function graph tracer can be called when RCU is not * "watching". +* Protected with schedule_on_each_cpu(ftrace_sync) */ hash =rcu_dereference_protected (ftrace_graph_hash, !preemptible ());
@@ -1017,6 +1018,7 @@ static inline int ftrace_graph_notrace_addr(unsigned long addr)* Have to open code "rcu_dereference_sched()" because the * function graph tracer can be called when RCU is not * "watching". +* Protected with schedule_on_each_cpu(ftrace_sync) */ notrace_hash =rcu_dereference_protected (ftrace_graph_notrace_hash, !preemptible ());
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 333/367 net: stmmac: xgmac: fix missing IFF_MULTICAST checki in dwxgmac2_set_filter
In reply to Greg Kroah-HartmanFrom: "Tan, Tee Min" <[email protected]>
[ Upstream commit 2f633d5820e4ed870f408957322acb9263bce2f4 ]
Without checking for IFF_MULTICAST flag, it is wrong to assume multicast filtering is always enabled. By checking against IFF_MULTICAST, now the driver behaves correctly when the multicast support is toggled by below command:-
ip link set <devname> multicast off|on
--- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +1 -1
@@ -458,7 +458,7 @@ static void dwxgmac2_set_filter(struct mfor (i =0 ; i <XGMAC_MAX_HASH_TABLE ; i++)writel (~0x0 , ioaddr +XGMAC_HASH_TABLE (i)); - }else if (!netdev_mc_empty (dev)) { + }else if (!netdev_mc_empty (dev) && (dev->flags &IFF_MULTICAST )) {struct netdev_hw_addr *ha; value |=XGMAC_FILTER_HMC ;
Greg Kroah-Hartman
maintainerPATCH 151/367 tracing: Annotate ftrace_graph_notrace_hash pointer with __rcu
In reply to Greg Kroah-HartmanFrom: Amol Grover <[email protected]>
[ Upstream commit fd0e6852c407dd9aefc594f54ddcc21d84803d3b ]
Fix following instances of sparse error kernel/trace/ftrace.c:5667:29: error: incompatible types in comparison kernel/trace/ftrace.c:5813:21: error: incompatible types in comparison kernel/trace/ftrace.c:5868:36: error: incompatible types in comparison kernel/trace/ftrace.c:5870:25: error: incompatible types in comparison
Use rcu_dereference_protected to dereference the newly annotated pointer.
--- kernel/trace/ftrace.c | 2 +- kernel/trace/trace.h | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +1 -1
@@ -5597,7 +5597,7 @@ static const struct file_operations ftrace_notrace_fops = {static DEFINE_MUTEX (graph_lock);struct ftrace_hash __rcu *ftrace_graph_hash =EMPTY_HASH ; -struct ftrace_hash *ftrace_graph_notrace_hash =EMPTY_HASH ; +struct ftrace_hash __rcu *ftrace_graph_notrace_hash =EMPTY_HASH ;enum graph_filter_type {GRAPH_FILTER_NOTRACE =0 ,
kernel/trace/trace.h +6 -2
@@ -951,7 +951,7 @@ extern void __trace_graph_return(struct trace_array *tr,#ifdef CONFIG_DYNAMIC_FTRACE extern struct ftrace_hash __rcu *ftrace_graph_hash; -extern struct ftrace_hash *ftrace_graph_notrace_hash; +extern struct ftrace_hash __rcu *ftrace_graph_notrace_hash;static inline int ftrace_graph_addr (struct ftrace_graph_ent *trace) {
@@ -1004,10 +1004,14 @@ static inline void ftrace_graph_addr_finish(struct ftrace_graph_ret *trace)static inline int ftrace_graph_notrace_addr (unsigned long addr) {int ret =0 ; +struct ftrace_hash *notrace_hash;preempt_disable_notrace (); -if (ftrace_lookup_ip (ftrace_graph_notrace_hash, addr)) + notrace_hash =rcu_dereference_protected (ftrace_graph_notrace_hash, + !preemptible ()); + +if (ftrace_lookup_ip (notrace_hash, addr)) ret =1 ;preempt_enable_notrace ();
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 147/367 dm: fix potential for q->make_request_fn NULL pointer
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 47ace7e012b9f7ad71d43ac9063d335ea3d6820b upstream.
Move blk_queue_make_request() to dm.c:alloc_dev() so that q->make_request_fn is never NULL during the lifetime of a DM device (even one that is created without a DM table).
Otherwise generic_make_request() will crash simply by doing:
dmsetup create -n test
mount /dev/dm-N /mnt
While at it, move ->congested_data initialization out of dm.c:alloc_dev() and into the bio-based specific init method.
Depends-on: c12c9a3c3860c ("dm: various cleanups to md->queue initialization code")
--- drivers/md/dm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/md/dm.c +7 -2
@@ -1859,6 +1859,7 @@ static void dm_init_normal_md_queue(stru/* * Initialize aspects of queue that aren't relevant for blk-mq */ + md->queue->backing_dev_info->congested_data = md; md->queue->backing_dev_info->congested_fn = dm_any_congested; }
@@ -1949,7 +1950,12 @@ static struct mapped_device *alloc_dev(iif (!md->queue) goto bad; md->queue->queuedata = md; - md->queue->backing_dev_info->congested_data = md; +/* +* default to bio-based required ->make_request_fn until DM +* table is loaded and md->type established. If request-based +* table is loaded: blk-mq will override accordingly. +*/ +blk_queue_make_request (md->queue, dm_make_request); md->disk =alloc_disk_node (1 , md->numa_node_id);if (!md->disk)
@@ -2264,7 +2270,6 @@ int dm_setup_md_queue(struct mapped_devicase DM_TYPE_DAX_BIO_BASED :case DM_TYPE_NVME_BIO_BASED :dm_init_normal_md_queue (md); -blk_queue_make_request (md->queue, dm_make_request);break ;case DM_TYPE_NONE :WARN_ON_ONCE (true);