[RFC][CFT][PATCHSET v1] uaccess unification
We have several primitives for bulk kernel<->userland copying. That stuff lives in various asm/uaccess.h, with serious code duplication _and_ seriously inconsistent semantics. That code has grown a lot of cruft and more than a few bugs. Some got caught and fixed last year, but some fairly unpleasant ones still remain. A large part of problem was that a lot of code used to include directly, so we had no single place to work with. That got finally fixed in 4.10-rc1, when everything had been forcibly switched to including . At that point it became possible to start getting rid of boilerplate; I hoped to deal with that by 4.11-rc1, but the things didn't work out and that work has slipped to this cycle. The patchset currently in vfs.git#work.uaccess is the result; there's more work to do, but it takes care of a large part of the problems. About 2.8KLoc removed, a lot of cruft is gone and semantics is hopefully in sync now. All but two architectures (ia64 and metag) had been switched to new mechanism; for these two I'm afraid that I'll need serious help from maintainers. Currently we have 8 primitives - 6 on every architecture and 2 more on biarch ones. All of them have the same calling conventions: arguments are the same as for memcpy() (void *to, const void *from, unsigned long size) and the same rules for return value. If all loads and stores succeed, everything is obvious - the 'size' bytes starting at 'to' become equal to 'size' bytes starting at 'from' and zero is returned. If some loads or stores fail, non-zero value should be returned. If any of those primitives returns a positive value N, * N should be no greater than size * the values fetched out of from[0..size-N-1] should be stored into the corresponding bytes of to[0..size-N-1] * N should not be equal to size unless not a single byte could have been fetched or stored. As long as that restriction is satisfied, these primitives are not required to squeeze every possible byte in case some loads or stores fail. 1) copy_from_user() - 'to' points to kernel memory, 'from' is normally a userland pointer. This is used for copying structures from userland in all kinds of ioctls, etc. No faults on access to destination are allowed, faults on access to source lead to zero-padding the rest of destination. Note that for architectures with the same address space split between the kernel and userland (i.e. the ones that have non-trivial access_ok()) passing a kernel address instead of a userland one should be treated as 'every access would fail'. In such cases the entire destination should be zeroed (failure to do so was a fairly common bug). Note that all these functions, including copy_from_user(), are affected by set_fs() - when called under set_fs(KERNEL_DS), they expect kernel pointers where normally a userland one would be given. 2) copy_to_user() - 'from' points to kernel memory, 'to' is a userland pointer (subject to set_fs() effects, as usual). Again. this is used by all kinds of code in all kinds of drivers, syscalls, etc. No faults on access to source, fault on access to destination terminates copying. No zero-padding, of course - the faults are going to be on store here. Does not assume that access_ok() had been checked by caller; given 'to'/'size' that fails access_ok() returns "nothing copied". 3) copy_in_user() - both 'from' and 'to' are in userland. Used only by compat code that needs to repack 32bit data structures into native 64bit counterparts. As the result, provided only by biarch architectures. Subject to set_fs(), but really should not be (and AFAICS isn't) used that way. Some architectures tried to zero-pad, but did it inconsistently and it's pointless anyway - destination is in userland memory, so no infoleaks would happen. 4) __copy_from_user_inatomic() - similar to copy_from_user(), except that * the caller is presumed to have verified that the source range passes access_ok() [note that this is does not guarantee the lack of faults] * most importantly, zero-padding SHOULD NOT happen on short copy. If implementation fails to guarantee that, it's a bug and potentially bad one[1]. * it may be called with pagefaults disabled (of course, in that case any pagefault results in a short copy). That's what 'inatomic' in the name refers to. Note that actually disabling pagefaults is up to the caller; blindly calling it e.g. from under a spinlock will just get you a deadlock. Even more precautions are needed to call it from something like an interrupt handler - you must do that under set_fs(), etc. It's not "this variant is safe to call from atomic contexts", it's "I know what I'm doing, don't worry if you see it in an atomic context". 5) __copy_to_user_inatomic(). A counterpart of __copy_from_user_inatomic(), except for the direction of copying. 6) __copy_from_user().
[RFC][CFT][PATCHSET v1] uaccess unification
We have several primitives for bulk kernel<->userland copying. That stuff lives in various asm/uaccess.h, with serious code duplication _and_ seriously inconsistent semantics. That code has grown a lot of cruft and more than a few bugs. Some got caught and fixed last year, but some fairly unpleasant ones still remain. A large part of problem was that a lot of code used to include directly, so we had no single place to work with. That got finally fixed in 4.10-rc1, when everything had been forcibly switched to including . At that point it became possible to start getting rid of boilerplate; I hoped to deal with that by 4.11-rc1, but the things didn't work out and that work has slipped to this cycle. The patchset currently in vfs.git#work.uaccess is the result; there's more work to do, but it takes care of a large part of the problems. About 2.8KLoc removed, a lot of cruft is gone and semantics is hopefully in sync now. All but two architectures (ia64 and metag) had been switched to new mechanism; for these two I'm afraid that I'll need serious help from maintainers. Currently we have 8 primitives - 6 on every architecture and 2 more on biarch ones. All of them have the same calling conventions: arguments are the same as for memcpy() (void *to, const void *from, unsigned long size) and the same rules for return value. If all loads and stores succeed, everything is obvious - the 'size' bytes starting at 'to' become equal to 'size' bytes starting at 'from' and zero is returned. If some loads or stores fail, non-zero value should be returned. If any of those primitives returns a positive value N, * N should be no greater than size * the values fetched out of from[0..size-N-1] should be stored into the corresponding bytes of to[0..size-N-1] * N should not be equal to size unless not a single byte could have been fetched or stored. As long as that restriction is satisfied, these primitives are not required to squeeze every possible byte in case some loads or stores fail. 1) copy_from_user() - 'to' points to kernel memory, 'from' is normally a userland pointer. This is used for copying structures from userland in all kinds of ioctls, etc. No faults on access to destination are allowed, faults on access to source lead to zero-padding the rest of destination. Note that for architectures with the same address space split between the kernel and userland (i.e. the ones that have non-trivial access_ok()) passing a kernel address instead of a userland one should be treated as 'every access would fail'. In such cases the entire destination should be zeroed (failure to do so was a fairly common bug). Note that all these functions, including copy_from_user(), are affected by set_fs() - when called under set_fs(KERNEL_DS), they expect kernel pointers where normally a userland one would be given. 2) copy_to_user() - 'from' points to kernel memory, 'to' is a userland pointer (subject to set_fs() effects, as usual). Again. this is used by all kinds of code in all kinds of drivers, syscalls, etc. No faults on access to source, fault on access to destination terminates copying. No zero-padding, of course - the faults are going to be on store here. Does not assume that access_ok() had been checked by caller; given 'to'/'size' that fails access_ok() returns "nothing copied". 3) copy_in_user() - both 'from' and 'to' are in userland. Used only by compat code that needs to repack 32bit data structures into native 64bit counterparts. As the result, provided only by biarch architectures. Subject to set_fs(), but really should not be (and AFAICS isn't) used that way. Some architectures tried to zero-pad, but did it inconsistently and it's pointless anyway - destination is in userland memory, so no infoleaks would happen. 4) __copy_from_user_inatomic() - similar to copy_from_user(), except that * the caller is presumed to have verified that the source range passes access_ok() [note that this is does not guarantee the lack of faults] * most importantly, zero-padding SHOULD NOT happen on short copy. If implementation fails to guarantee that, it's a bug and potentially bad one[1]. * it may be called with pagefaults disabled (of course, in that case any pagefault results in a short copy). That's what 'inatomic' in the name refers to. Note that actually disabling pagefaults is up to the caller; blindly calling it e.g. from under a spinlock will just get you a deadlock. Even more precautions are needed to call it from something like an interrupt handler - you must do that under set_fs(), etc. It's not "this variant is safe to call from atomic contexts", it's "I know what I'm doing, don't worry if you see it in an atomic context". 5) __copy_to_user_inatomic(). A counterpart of __copy_from_user_inatomic(), except for the direction of copying. 6) __copy_from_user().
Re: [PATCH v7 0/3] Broadcom FlexRM ring manager support
On Wed, Mar 29, 2017 at 11:05 AM, Jassi Brarwrote: > On Wed, Mar 29, 2017 at 11:00 AM, Anup Patel wrote: >> The Broadcom FlexRM ring manager provides producer-consumer style >> ring interface for offload engines on Broadcom iProc SoCs. We can >> have one or more instances of Broadcom FlexRM ring manager in a SoC. >> >> This patchset adds a mailbox driver for Broadcom FlexRM ring manager >> which can be used by offload engine drivers as mailbox clients. >> >> The Broadcom FlexRM mailbox driver is feature complete for RAID and >> Crypto offload engines. We will have incremental patches in-future >> for ring-level statistics using debugfs and minor optimizations. >> >> This patchset is based on Linux-4.11-rc4 and it is also available >> at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git >> >> Changes since v6: >> - Rebased patches for Linux-4.11-rc4 >> - Added a patch to remove depends on COMPILE_TEST for kconfig >>option BCM_FLEXRM_MBOX >> > You only needed to send the fix to compilation failure reports, not > the whole series. My bad for the noise. > I believe only the patch-3 is new in the series and I need not even > look at patch-1,2 ? Yes, only patch-3 is required to fix compilation failure. Regards, Anup
Re: [PATCH v7 0/3] Broadcom FlexRM ring manager support
On Wed, Mar 29, 2017 at 11:05 AM, Jassi Brar wrote: > On Wed, Mar 29, 2017 at 11:00 AM, Anup Patel wrote: >> The Broadcom FlexRM ring manager provides producer-consumer style >> ring interface for offload engines on Broadcom iProc SoCs. We can >> have one or more instances of Broadcom FlexRM ring manager in a SoC. >> >> This patchset adds a mailbox driver for Broadcom FlexRM ring manager >> which can be used by offload engine drivers as mailbox clients. >> >> The Broadcom FlexRM mailbox driver is feature complete for RAID and >> Crypto offload engines. We will have incremental patches in-future >> for ring-level statistics using debugfs and minor optimizations. >> >> This patchset is based on Linux-4.11-rc4 and it is also available >> at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git >> >> Changes since v6: >> - Rebased patches for Linux-4.11-rc4 >> - Added a patch to remove depends on COMPILE_TEST for kconfig >>option BCM_FLEXRM_MBOX >> > You only needed to send the fix to compilation failure reports, not > the whole series. My bad for the noise. > I believe only the patch-3 is new in the series and I need not even > look at patch-1,2 ? Yes, only patch-3 is required to fix compilation failure. Regards, Anup
[PATCH] net: ipv6: netfilter: replace explicit NULL comparison with ! operator
Replace explicit NULL comparison with ! operator to simplify code. Signed-off-by: Arushi Singhal--- net/ipv6/netfilter/ip6_tables.c| 4 ++-- net/ipv6/netfilter/ip6t_SYNPROXY.c | 16 net/ipv6/netfilter/ip6t_ah.c | 2 +- net/ipv6/netfilter/ip6t_frag.c | 2 +- net/ipv6/netfilter/ip6t_hbh.c | 6 +++--- net/ipv6/netfilter/ip6t_mh.c | 2 +- net/ipv6/netfilter/ip6t_rt.c | 2 +- net/ipv6/netfilter/ip6table_filter.c | 2 +- net/ipv6/netfilter/ip6table_mangle.c | 2 +- net/ipv6/netfilter/ip6table_nat.c | 2 +- net/ipv6/netfilter/ip6table_raw.c | 2 +- net/ipv6/netfilter/ip6table_security.c | 2 +- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 2 +- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 4 ++-- net/ipv6/netfilter/nf_conntrack_reasm.c| 8 net/ipv6/netfilter/nf_dup_ipv6.c | 2 +- net/ipv6/netfilter/nf_log_ipv6.c | 12 ++-- net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 2 +- net/ipv6/netfilter/nf_reject_ipv6.c| 2 +- net/ipv6/netfilter/nf_socket_ipv6.c| 8 net/ipv6/netfilter/nf_tables_ipv6.c| 2 +- net/ipv6/netfilter/nft_dup_ipv6.c | 2 +- 22 files changed, 44 insertions(+), 44 deletions(-) diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 754e911bdafd..b8cb61c27aa1 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -830,7 +830,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) countersize = sizeof(struct xt_counters) * private->number; counters = vzalloc(countersize); - if (counters == NULL) + if (!counters) return ERR_PTR(-ENOMEM); get_counters(private, counters); @@ -1846,7 +1846,7 @@ icmp6_match(const struct sk_buff *skb, struct xt_action_param *par) return false; ic = skb_header_pointer(skb, par->thoff, sizeof(_icmph), &_icmph); - if (ic == NULL) { + if (!ic) { /* We've been asked to examine this packet, and we * can't. Hence, no choice but to drop. */ diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c index 4ef1ddd4bbbd..e0fa78085ad7 100644 --- a/net/ipv6/netfilter/ip6t_SYNPROXY.c +++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c @@ -98,7 +98,7 @@ synproxy_send_client_synack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -140,7 +140,7 @@ synproxy_send_server_syn(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -185,7 +185,7 @@ synproxy_send_server_ack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -223,7 +223,7 @@ synproxy_send_client_ack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -285,7 +285,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par) return NF_DROP; th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th); - if (th == NULL) + if (!th) return NF_DROP; if (!synproxy_parse_options(skb, par->thoff, th, )) @@ -335,11 +335,11 @@ static unsigned int ipv6_synproxy_hook(void *priv, int thoff; ct = nf_ct_get(skb, ); - if (ct == NULL) + if (!ct) return NF_ACCEPT; synproxy = nfct_synproxy(ct); - if (synproxy == NULL) + if (!synproxy) return NF_ACCEPT; if (nf_is_loopback_packet(skb)) @@ -352,7 +352,7 @@ static unsigned int ipv6_synproxy_hook(void *priv, return NF_ACCEPT; th = skb_header_pointer(skb, thoff, sizeof(_th), &_th); - if (th == NULL) + if (!th) return NF_DROP; state = >proto.tcp; diff --git
Re: linux-next: manual merge of the tty tree with the tty.current tree
On Mon, Mar 20, 2017 at 10:26:43AM +0100, Dmitry Vyukov wrote: > On Mon, Mar 20, 2017 at 10:21 AM, Dmitry Vyukovwrote: > > On Mon, Mar 20, 2017 at 3:28 AM, Stephen Rothwell > > wrote: > >> Hi Greg, > >> > >> Today's linux-next merge of the tty tree got a conflict in: > >> > >> drivers/tty/tty_ldisc.c > >> > >> between commit: > >> > >> 5362544bebe8 ("tty: don't panic on OOM in tty_set_ldisc()") > >> > >> from the tty.current tree and commit: > >> > >> 71472fa9c52b ("tty: Fix ldisc crash on reopened tty") > >> > >> from the tty tree. > >> > >> I fixed it up (see below) and can carry the fix as necessary. This > >> is now fixed as far as linux-next is concerned, but any non trivial > >> conflicts should be mentioned to your upstream maintainer when your tree > >> is submitted for merging. You may also want to consider cooperating > >> with the maintainer of the conflicting tree to minimise any particularly > >> complex conflicts. > >> > >> -- > >> Cheers, > >> Stephen Rothwell > >> > >> diff --cc drivers/tty/tty_ldisc.c > >> index b0500a0a87b8,4ee7742dced3.. > >> --- a/drivers/tty/tty_ldisc.c > >> +++ b/drivers/tty/tty_ldisc.c > >> @@@ -621,14 -669,17 +621,15 @@@ int tty_ldisc_reinit(struct tty_struct > >> tty_ldisc_put(tty->ldisc); > >> } > >> > >> - /* switch the line discipline */ > >> - tty->ldisc = ld; > >> tty_set_termios_ldisc(tty, disc); > >> - retval = tty_ldisc_open(tty, tty->ldisc); > >> + retval = tty_ldisc_open(tty, ld); > >> if (retval) { > >> - tty_ldisc_put(tty->ldisc); > >> - tty->ldisc = NULL; > >> - if (!WARN_ON(disc == N_TTY)) { > >> - tty_ldisc_put(ld); > >> - ld = NULL; > >> - } > >> ++ tty_ldisc_put(ld); > >> ++ ld = NULL; > >> } > >> + > >> + /* switch the line discipline */ > >> + smp_store_release(>ldisc, ld); > >> return retval; > >> } > >> > > > > > > Peter, > > > > Looking at your patch "tty: Fix ldisc crash on reopened tty", I think > > there is a missed barrier in tty_ldisc_ref. A single barrier does not > > have any effect, they always need to be in pairs. So I think we also > > need at least: > > > > @@ -295,7 +295,8 @@ struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) > > struct tty_ldisc *ld = NULL; > > > > if (ldsem_down_read_trylock(>ldisc_sem)) { > > - ld = tty->ldisc; > > + ld = READ_ONCE(tty->ldisc); > > + read_barrier_depends(); > > if (!ld) > > ldsem_up_read(>ldisc_sem); > > } > > > > > > Or simply: > > > > @@ -295,7 +295,8 @@ struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) > > struct tty_ldisc *ld = NULL; > > > > if (ldsem_down_read_trylock(>ldisc_sem)) { > > - ld = tty->ldisc; > > + /* pairs with smp_store_release in tty_ldisc_reinit */ > > + ld = smp_load_acquire(>ldisc); > > if (!ld) > > ldsem_up_read(>ldisc_sem); > > } > > > > > I am also surprised that callers of tty_ldisc_reinit don't hold > ldisc_sem. I thought that ldisc_sem is what's supposed to protect > changes to ldisc. That would also auto fix the crash without any > tricky barriers as flush_to_ldisc uses tty_ldisc_ref. Ok, I'm reverting this patch. Michael and Peter, please rework it and resubmit. thanks, greg k-h
Re: linux-next: manual merge of the tty tree with the tty.current tree
On Mon, Mar 20, 2017 at 10:26:43AM +0100, Dmitry Vyukov wrote: > On Mon, Mar 20, 2017 at 10:21 AM, Dmitry Vyukov wrote: > > On Mon, Mar 20, 2017 at 3:28 AM, Stephen Rothwell > > wrote: > >> Hi Greg, > >> > >> Today's linux-next merge of the tty tree got a conflict in: > >> > >> drivers/tty/tty_ldisc.c > >> > >> between commit: > >> > >> 5362544bebe8 ("tty: don't panic on OOM in tty_set_ldisc()") > >> > >> from the tty.current tree and commit: > >> > >> 71472fa9c52b ("tty: Fix ldisc crash on reopened tty") > >> > >> from the tty tree. > >> > >> I fixed it up (see below) and can carry the fix as necessary. This > >> is now fixed as far as linux-next is concerned, but any non trivial > >> conflicts should be mentioned to your upstream maintainer when your tree > >> is submitted for merging. You may also want to consider cooperating > >> with the maintainer of the conflicting tree to minimise any particularly > >> complex conflicts. > >> > >> -- > >> Cheers, > >> Stephen Rothwell > >> > >> diff --cc drivers/tty/tty_ldisc.c > >> index b0500a0a87b8,4ee7742dced3.. > >> --- a/drivers/tty/tty_ldisc.c > >> +++ b/drivers/tty/tty_ldisc.c > >> @@@ -621,14 -669,17 +621,15 @@@ int tty_ldisc_reinit(struct tty_struct > >> tty_ldisc_put(tty->ldisc); > >> } > >> > >> - /* switch the line discipline */ > >> - tty->ldisc = ld; > >> tty_set_termios_ldisc(tty, disc); > >> - retval = tty_ldisc_open(tty, tty->ldisc); > >> + retval = tty_ldisc_open(tty, ld); > >> if (retval) { > >> - tty_ldisc_put(tty->ldisc); > >> - tty->ldisc = NULL; > >> - if (!WARN_ON(disc == N_TTY)) { > >> - tty_ldisc_put(ld); > >> - ld = NULL; > >> - } > >> ++ tty_ldisc_put(ld); > >> ++ ld = NULL; > >> } > >> + > >> + /* switch the line discipline */ > >> + smp_store_release(>ldisc, ld); > >> return retval; > >> } > >> > > > > > > Peter, > > > > Looking at your patch "tty: Fix ldisc crash on reopened tty", I think > > there is a missed barrier in tty_ldisc_ref. A single barrier does not > > have any effect, they always need to be in pairs. So I think we also > > need at least: > > > > @@ -295,7 +295,8 @@ struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) > > struct tty_ldisc *ld = NULL; > > > > if (ldsem_down_read_trylock(>ldisc_sem)) { > > - ld = tty->ldisc; > > + ld = READ_ONCE(tty->ldisc); > > + read_barrier_depends(); > > if (!ld) > > ldsem_up_read(>ldisc_sem); > > } > > > > > > Or simply: > > > > @@ -295,7 +295,8 @@ struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) > > struct tty_ldisc *ld = NULL; > > > > if (ldsem_down_read_trylock(>ldisc_sem)) { > > - ld = tty->ldisc; > > + /* pairs with smp_store_release in tty_ldisc_reinit */ > > + ld = smp_load_acquire(>ldisc); > > if (!ld) > > ldsem_up_read(>ldisc_sem); > > } > > > > > I am also surprised that callers of tty_ldisc_reinit don't hold > ldisc_sem. I thought that ldisc_sem is what's supposed to protect > changes to ldisc. That would also auto fix the crash without any > tricky barriers as flush_to_ldisc uses tty_ldisc_ref. Ok, I'm reverting this patch. Michael and Peter, please rework it and resubmit. thanks, greg k-h
[PATCH] net: ipv6: netfilter: replace explicit NULL comparison with ! operator
Replace explicit NULL comparison with ! operator to simplify code. Signed-off-by: Arushi Singhal --- net/ipv6/netfilter/ip6_tables.c| 4 ++-- net/ipv6/netfilter/ip6t_SYNPROXY.c | 16 net/ipv6/netfilter/ip6t_ah.c | 2 +- net/ipv6/netfilter/ip6t_frag.c | 2 +- net/ipv6/netfilter/ip6t_hbh.c | 6 +++--- net/ipv6/netfilter/ip6t_mh.c | 2 +- net/ipv6/netfilter/ip6t_rt.c | 2 +- net/ipv6/netfilter/ip6table_filter.c | 2 +- net/ipv6/netfilter/ip6table_mangle.c | 2 +- net/ipv6/netfilter/ip6table_nat.c | 2 +- net/ipv6/netfilter/ip6table_raw.c | 2 +- net/ipv6/netfilter/ip6table_security.c | 2 +- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 2 +- net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 4 ++-- net/ipv6/netfilter/nf_conntrack_reasm.c| 8 net/ipv6/netfilter/nf_dup_ipv6.c | 2 +- net/ipv6/netfilter/nf_log_ipv6.c | 12 ++-- net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 2 +- net/ipv6/netfilter/nf_reject_ipv6.c| 2 +- net/ipv6/netfilter/nf_socket_ipv6.c| 8 net/ipv6/netfilter/nf_tables_ipv6.c| 2 +- net/ipv6/netfilter/nft_dup_ipv6.c | 2 +- 22 files changed, 44 insertions(+), 44 deletions(-) diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 754e911bdafd..b8cb61c27aa1 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -830,7 +830,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) countersize = sizeof(struct xt_counters) * private->number; counters = vzalloc(countersize); - if (counters == NULL) + if (!counters) return ERR_PTR(-ENOMEM); get_counters(private, counters); @@ -1846,7 +1846,7 @@ icmp6_match(const struct sk_buff *skb, struct xt_action_param *par) return false; ic = skb_header_pointer(skb, par->thoff, sizeof(_icmph), &_icmph); - if (ic == NULL) { + if (!ic) { /* We've been asked to examine this packet, and we * can't. Hence, no choice but to drop. */ diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c index 4ef1ddd4bbbd..e0fa78085ad7 100644 --- a/net/ipv6/netfilter/ip6t_SYNPROXY.c +++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c @@ -98,7 +98,7 @@ synproxy_send_client_synack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -140,7 +140,7 @@ synproxy_send_server_syn(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -185,7 +185,7 @@ synproxy_send_server_ack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -223,7 +223,7 @@ synproxy_send_client_ack(struct net *net, tcp_hdr_size = sizeof(*nth) + synproxy_options_size(opts); nskb = alloc_skb(sizeof(*niph) + tcp_hdr_size + MAX_TCP_HEADER, GFP_ATOMIC); - if (nskb == NULL) + if (!nskb) return; skb_reserve(nskb, MAX_TCP_HEADER); @@ -285,7 +285,7 @@ synproxy_tg6(struct sk_buff *skb, const struct xt_action_param *par) return NF_DROP; th = skb_header_pointer(skb, par->thoff, sizeof(_th), &_th); - if (th == NULL) + if (!th) return NF_DROP; if (!synproxy_parse_options(skb, par->thoff, th, )) @@ -335,11 +335,11 @@ static unsigned int ipv6_synproxy_hook(void *priv, int thoff; ct = nf_ct_get(skb, ); - if (ct == NULL) + if (!ct) return NF_ACCEPT; synproxy = nfct_synproxy(ct); - if (synproxy == NULL) + if (!synproxy) return NF_ACCEPT; if (nf_is_loopback_packet(skb)) @@ -352,7 +352,7 @@ static unsigned int ipv6_synproxy_hook(void *priv, return NF_ACCEPT; th = skb_header_pointer(skb, thoff, sizeof(_th), &_th); - if (th == NULL) + if (!th) return NF_DROP; state = >proto.tcp; diff --git a/net/ipv6/netfilter/ip6t_ah.c
Re: [PATCH 4.9 00/88] 4.9.19-stable review
On Tue, Mar 28, 2017 at 12:32:16PM -0700, Kevin Hilman wrote: > kernelci.org botwrites: > > > stable-rc/linux-4.9.y boot: 186 boots: 12 failed, 153 passed with 21 > > offline (v4.9.18-89-g4c510f546717) > > This can be ignored. > > These emails were supposed to be disabled while we are working on some > infrastructure updates. Oops. Not a problem, good luck with your update. greg k-h
Re: [PATCH 4.9 00/88] 4.9.19-stable review
On Tue, Mar 28, 2017 at 12:32:16PM -0700, Kevin Hilman wrote: > kernelci.org bot writes: > > > stable-rc/linux-4.9.y boot: 186 boots: 12 failed, 153 passed with 21 > > offline (v4.9.18-89-g4c510f546717) > > This can be ignored. > > These emails were supposed to be disabled while we are working on some > infrastructure updates. Oops. Not a problem, good luck with your update. greg k-h
Re: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function
On Tue, 28 Mar 2017, kan.li...@intel.com wrote: > From: Kan Liang> > There is no exported kernel interfaces which can flip a MSR bit. It has > to do read-modify-write operation on the MSR through rd/wrmsr* > interfaces. But the method is not atomic. > > There is already __flip_bit support. Just rename and expose it. This function is not atomic either. Protection has to be provided by the caller. > -static inline int __flip_bit(u32 msr, u8 bit, bool set) > +int msr_flip_bit(u32 msr, u8 bit, bool set) > { > struct msr m, m1; > int err = -EINVAL; > @@ -85,6 +85,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set) > > return 1; > } > +EXPORT_SYMBOL_GPL(msr_flip_bit); That export is not required. The call site is always built in. Thanks, tglx
Re: [PATCH 4.10 000/111] 4.10.7-stable review
On Tue, Mar 28, 2017 at 07:59:36PM -0700, Guenter Roeck wrote: > On 03/28/2017 05:29 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.10.7 release. > > There are 111 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Thu Mar 30 12:28:57 UTC 2017. > > Anything received after that time might be too late. > > > > > Build results: > total: 149 pass: 149 fail: 0 > Qemu test results: > total: 122 pass: 122 fail: 0 > > Details are available at http://kerneltests.org/builders. Thanks for testing all of these and letting me know. greg k-h
Re: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function
On Tue, 28 Mar 2017, kan.li...@intel.com wrote: > From: Kan Liang > > There is no exported kernel interfaces which can flip a MSR bit. It has > to do read-modify-write operation on the MSR through rd/wrmsr* > interfaces. But the method is not atomic. > > There is already __flip_bit support. Just rename and expose it. This function is not atomic either. Protection has to be provided by the caller. > -static inline int __flip_bit(u32 msr, u8 bit, bool set) > +int msr_flip_bit(u32 msr, u8 bit, bool set) > { > struct msr m, m1; > int err = -EINVAL; > @@ -85,6 +85,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set) > > return 1; > } > +EXPORT_SYMBOL_GPL(msr_flip_bit); That export is not required. The call site is always built in. Thanks, tglx
Re: [PATCH 4.10 000/111] 4.10.7-stable review
On Tue, Mar 28, 2017 at 07:59:36PM -0700, Guenter Roeck wrote: > On 03/28/2017 05:29 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.10.7 release. > > There are 111 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Thu Mar 30 12:28:57 UTC 2017. > > Anything received after that time might be too late. > > > > > Build results: > total: 149 pass: 149 fail: 0 > Qemu test results: > total: 122 pass: 122 fail: 0 > > Details are available at http://kerneltests.org/builders. Thanks for testing all of these and letting me know. greg k-h
Re: [PATCH 4.10 000/111] 4.10.7-stable review
On Tue, Mar 28, 2017 at 01:37:16PM -0600, Shuah Khan wrote: > On 03/28/2017 06:29 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.10.7 release. > > There are 111 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Thu Mar 30 12:28:57 UTC 2017. > > Anything received after that time might be too late. > > > > The whole patch series can be found in one patch at: > > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.10.7-rc1.gz > > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > > linux-4.10.y > > and the diffstat can be found below. > > > > thanks, > > > > greg k-h > > > > Compiled and booted on my test system. No dmesg regressions. Thanks for testing all of these and letting me know. greg k-h
Re: [PATCH 4.10 000/111] 4.10.7-stable review
On Tue, Mar 28, 2017 at 01:37:16PM -0600, Shuah Khan wrote: > On 03/28/2017 06:29 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 4.10.7 release. > > There are 111 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Thu Mar 30 12:28:57 UTC 2017. > > Anything received after that time might be too late. > > > > The whole patch series can be found in one patch at: > > kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.10.7-rc1.gz > > or in the git tree and branch at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git > > linux-4.10.y > > and the diffstat can be found below. > > > > thanks, > > > > greg k-h > > > > Compiled and booted on my test system. No dmesg regressions. Thanks for testing all of these and letting me know. greg k-h
[PATCH] net: netfilter: Use list_{next/prev}_entry instead of list_entry
This patch replace list_entry with list_prev_entry as it makes the code more clear to read. Signed-off-by: simran singhal--- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index b7645d7..a341eaf 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1895,7 +1895,7 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net, goto nla_put_failure; if ((event != NFT_MSG_DELRULE) && (rule->list.prev != >rules)) { - prule = list_entry(rule->list.prev, struct nft_rule, list); + prule = list_prev_entry(rule, list); if (nla_put_be64(skb, NFTA_RULE_POSITION, cpu_to_be64(prule->handle), NFTA_RULE_PAD)) -- 2.7.4
[PATCH] net: netfilter: Use list_{next/prev}_entry instead of list_entry
This patch replace list_entry with list_prev_entry as it makes the code more clear to read. Signed-off-by: simran singhal --- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index b7645d7..a341eaf 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -1895,7 +1895,7 @@ static int nf_tables_fill_rule_info(struct sk_buff *skb, struct net *net, goto nla_put_failure; if ((event != NFT_MSG_DELRULE) && (rule->list.prev != >rules)) { - prule = list_entry(rule->list.prev, struct nft_rule, list); + prule = list_prev_entry(rule, list); if (nla_put_be64(skb, NFTA_RULE_POSITION, cpu_to_be64(prule->handle), NFTA_RULE_PAD)) -- 2.7.4
Re: linux-next: manual merge of the akpm-current tree with the sparc tree
From: Stephen RothwellDate: Wed, 29 Mar 2017 16:37:46 +1100 > 3f506bf2a354 ("sparc64: NG4 memset 32 bits overflow") Andrew, this change still needs discussion and review and I intended to push it via my tree once everything was sorted out. Thank you.
Re: linux-next: manual merge of the akpm-current tree with the sparc tree
From: Stephen Rothwell Date: Wed, 29 Mar 2017 16:37:46 +1100 > 3f506bf2a354 ("sparc64: NG4 memset 32 bits overflow") Andrew, this change still needs discussion and review and I intended to push it via my tree once everything was sorted out. Thank you.
[PATCH] Staging: nvec: Remove FSF's mailing address
Removed Free Software Foundation's address from the copyright notice and replaced it with a link to http://www.gnu.org/licenses Signed-off-by: Riku Salminen--- drivers/staging/nvec/nvec-keytable.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec-keytable.h b/drivers/staging/nvec/nvec-keytable.h index 1dc22cb8812a..7008c96bdbbe 100644 --- a/drivers/staging/nvec/nvec-keytable.h +++ b/drivers/staging/nvec/nvec-keytable.h @@ -17,8 +17,7 @@ * more details. * * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * with this program; if not, see http://www.gnu.org/licenses */ static unsigned short code_tab_102us[] = { -- 2.11.0
[PATCH] Staging: nvec: Remove FSF's mailing address
Removed Free Software Foundation's address from the copyright notice and replaced it with a link to http://www.gnu.org/licenses Signed-off-by: Riku Salminen --- drivers/staging/nvec/nvec-keytable.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/nvec/nvec-keytable.h b/drivers/staging/nvec/nvec-keytable.h index 1dc22cb8812a..7008c96bdbbe 100644 --- a/drivers/staging/nvec/nvec-keytable.h +++ b/drivers/staging/nvec/nvec-keytable.h @@ -17,8 +17,7 @@ * more details. * * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * with this program; if not, see http://www.gnu.org/licenses */ static unsigned short code_tab_102us[] = { -- 2.11.0
linux-next: manual merge of the akpm-current tree with the sparc tree
Hi Andrew, Today's linux-next merge of the akpm-current tree got a conflict in: arch/sparc/lib/NG4memset.S between commit: 0ae2d26ffe70 ("arch/sparc: Avoid DCTI Couples") from the sparc tree and commit: 3f506bf2a354 ("sparc64: NG4 memset 32 bits overflow") from the akpm-current tree. I fixed it up (I think - see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc arch/sparc/lib/NG4memset.S index 7c0c81f18837,e7c2e70df263.. --- a/arch/sparc/lib/NG4memset.S +++ b/arch/sparc/lib/NG4memset.S @@@ -99,8 -99,7 +99,8 @@@ NG4bzero stxa%o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P stxa%o4, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P stxa%o4, [%o0 + %o5] ASI_BLK_INIT_QUAD_LDD_P - bne,pt %icc, 1b + bne,pt %xcc, 1b add%o0, 0x30, %o0 - ba,a,pt %icc, .Lpostloop + ba,a,pt %xcc, .Lpostloop + nop .size NG4bzero,.-NG4bzero
linux-next: manual merge of the akpm-current tree with the sparc tree
Hi Andrew, Today's linux-next merge of the akpm-current tree got a conflict in: arch/sparc/lib/NG4memset.S between commit: 0ae2d26ffe70 ("arch/sparc: Avoid DCTI Couples") from the sparc tree and commit: 3f506bf2a354 ("sparc64: NG4 memset 32 bits overflow") from the akpm-current tree. I fixed it up (I think - see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc arch/sparc/lib/NG4memset.S index 7c0c81f18837,e7c2e70df263.. --- a/arch/sparc/lib/NG4memset.S +++ b/arch/sparc/lib/NG4memset.S @@@ -99,8 -99,7 +99,8 @@@ NG4bzero stxa%o4, [%o0 + %g2] ASI_BLK_INIT_QUAD_LDD_P stxa%o4, [%o0 + %g3] ASI_BLK_INIT_QUAD_LDD_P stxa%o4, [%o0 + %o5] ASI_BLK_INIT_QUAD_LDD_P - bne,pt %icc, 1b + bne,pt %xcc, 1b add%o0, 0x30, %o0 - ba,a,pt %icc, .Lpostloop + ba,a,pt %xcc, .Lpostloop + nop .size NG4bzero,.-NG4bzero
Re: [PATCH v7 0/3] Broadcom FlexRM ring manager support
On Wed, Mar 29, 2017 at 11:00 AM, Anup Patelwrote: > The Broadcom FlexRM ring manager provides producer-consumer style > ring interface for offload engines on Broadcom iProc SoCs. We can > have one or more instances of Broadcom FlexRM ring manager in a SoC. > > This patchset adds a mailbox driver for Broadcom FlexRM ring manager > which can be used by offload engine drivers as mailbox clients. > > The Broadcom FlexRM mailbox driver is feature complete for RAID and > Crypto offload engines. We will have incremental patches in-future > for ring-level statistics using debugfs and minor optimizations. > > This patchset is based on Linux-4.11-rc4 and it is also available > at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git > > Changes since v6: > - Rebased patches for Linux-4.11-rc4 > - Added a patch to remove depends on COMPILE_TEST for kconfig >option BCM_FLEXRM_MBOX > You only needed to send the fix to compilation failure reports, not the whole series. I believe only the patch-3 is new in the series and I need not even look at patch-1,2 ?
Re: [PATCH v7 0/3] Broadcom FlexRM ring manager support
On Wed, Mar 29, 2017 at 11:00 AM, Anup Patel wrote: > The Broadcom FlexRM ring manager provides producer-consumer style > ring interface for offload engines on Broadcom iProc SoCs. We can > have one or more instances of Broadcom FlexRM ring manager in a SoC. > > This patchset adds a mailbox driver for Broadcom FlexRM ring manager > which can be used by offload engine drivers as mailbox clients. > > The Broadcom FlexRM mailbox driver is feature complete for RAID and > Crypto offload engines. We will have incremental patches in-future > for ring-level statistics using debugfs and minor optimizations. > > This patchset is based on Linux-4.11-rc4 and it is also available > at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git > > Changes since v6: > - Rebased patches for Linux-4.11-rc4 > - Added a patch to remove depends on COMPILE_TEST for kconfig >option BCM_FLEXRM_MBOX > You only needed to send the fix to compilation failure reports, not the whole series. I believe only the patch-3 is new in the series and I need not even look at patch-1,2 ?
[PATCH v7 3/3] mailbox: Remove depends on COMPILE_TEST for BCM_FLEXRM_MBOX
The Broadcom FlexRM mailbox driver uses platform MSI support but not all ARCHs provide asm/msi.h. Due to this, we get compilation error in Broadcom FlexRM mailbox driver via linux/msi.h on ARCHs which lack asm/msi.h. This patch removes "depends on COMPILE_TEST" for Kconfig option BCM_FLEXRM_MBOX so that Broadcom FlexRM mailbox driver is only compiled for ARM64. Signed-off-by: Anup Patel--- drivers/mailbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 305018c..9c19b9f 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -155,7 +155,7 @@ config BCM_PDC_MBOX config BCM_FLEXRM_MBOX tristate "Broadcom FlexRM Mailbox" - depends on ARM64 || COMPILE_TEST + depends on ARM64 depends on HAS_DMA select GENERIC_MSI_IRQ_DOMAIN default ARCH_BCM_IPROC -- 2.7.4
[PATCH v7 3/3] mailbox: Remove depends on COMPILE_TEST for BCM_FLEXRM_MBOX
The Broadcom FlexRM mailbox driver uses platform MSI support but not all ARCHs provide asm/msi.h. Due to this, we get compilation error in Broadcom FlexRM mailbox driver via linux/msi.h on ARCHs which lack asm/msi.h. This patch removes "depends on COMPILE_TEST" for Kconfig option BCM_FLEXRM_MBOX so that Broadcom FlexRM mailbox driver is only compiled for ARM64. Signed-off-by: Anup Patel --- drivers/mailbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 305018c..9c19b9f 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -155,7 +155,7 @@ config BCM_PDC_MBOX config BCM_FLEXRM_MBOX tristate "Broadcom FlexRM Mailbox" - depends on ARM64 || COMPILE_TEST + depends on ARM64 depends on HAS_DMA select GENERIC_MSI_IRQ_DOMAIN default ARCH_BCM_IPROC -- 2.7.4
[PATCH v7 2/3] dt-bindings: Add DT bindings info for FlexRM ring manager
This patch adds device tree bindings document for the FlexRM ring manager found on Broadcom iProc SoCs. Acked-by: Rob HerringReviewed-by: Ray Jui Reviewed-by: Scott Branden Signed-off-by: Anup Patel --- .../bindings/mailbox/brcm,iproc-flexrm-mbox.txt| 59 ++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt diff --git a/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt b/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt new file mode 100644 index 000..752ae6b --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt @@ -0,0 +1,59 @@ +Broadcom FlexRM Ring Manager + +The Broadcom FlexRM ring manager provides a set of rings which can be +used to submit work to offload engines. An SoC may have multiple FlexRM +hardware blocks. There is one device tree entry per FlexRM block. The +FlexRM driver will create a mailbox-controller instance for given FlexRM +hardware block where each mailbox channel is a separate FlexRM ring. + +Required properties: + +- compatible: Should be "brcm,iproc-flexrm-mbox" +- reg: Specifies base physical address and size of the FlexRM + ring registers +- msi-parent: Phandles (and potential Device IDs) to MSI controllers + The FlexRM engine will send MSIs (instead of wired + interrupts) to CPU. There is one MSI for each FlexRM ring. + Refer devicetree/bindings/interrupt-controller/msi.txt +- #mbox-cells: Specifies the number of cells needed to encode a mailbox + channel. This should be 3. + + The 1st cell is the mailbox channel number. + + The 2nd cell contains MSI completion threshold. This is the + number of completion messages for which FlexRM will inject + one MSI interrupt to CPU. + + The 3nd cell contains MSI timer value representing time for + which FlexRM will wait to accumulate N completion messages + where N is the value specified by 2nd cell above. If FlexRM + does not get required number of completion messages in time + specified by this cell then it will inject one MSI interrupt + to CPU provided atleast one completion message is available. + +Optional properties: + +- dma-coherent:Present if DMA operations made by the FlexRM engine (such + as DMA descriptor access, access to buffers pointed by DMA + descriptors and read/write pointer updates to DDR) are + cache coherent with the CPU. + +Example: + +crypto_mbox: mbox@6700 { + compatible = "brcm,iproc-flexrm-mbox"; + reg = <0x6700 0x20>; + msi-parent = <_its 0x7f00>; + #mbox-cells = <3>; +}; + +crypto@672c { + compatible = "brcm,spu2-v2-crypto"; + reg = <0x672c 0x1000>; + mboxes = <_mbox 0 0x1 0x>, +<_mbox 1 0x1 0x>, +<_mbox 16 0x1 0x>, +<_mbox 17 0x1 0x>, +<_mbox 30 0x1 0x>, +<_mbox 31 0x1 0x>; +}; -- 2.7.4
[PATCH v7 1/3] mailbox: Add driver for Broadcom FlexRM ring manager
Some of the Broadcom iProc SoCs have FlexRM ring manager which provides a ring-based programming interface to various offload engines (e.g. RAID, Crypto, etc). This patch adds a common mailbox driver for Broadcom FlexRM ring manager which can be shared by various offload engine drivers (implemented as mailbox clients). Reviewed-by: Ray JuiReviewed-by: Scott Branden Reviewed-by: Pramod KUMAR Signed-off-by: Anup Patel --- drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile |2 + drivers/mailbox/bcm-flexrm-mailbox.c | 1595 ++ include/linux/mailbox/brcm-message.h | 14 +- 4 files changed, 1618 insertions(+), 4 deletions(-) create mode 100644 drivers/mailbox/bcm-flexrm-mailbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ceff415..305018c 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -152,4 +152,15 @@ config BCM_PDC_MBOX Mailbox implementation for the Broadcom PDC ring manager, which provides access to various offload engines on Broadcom SoCs. Say Y here if you want to use the Broadcom PDC. + +config BCM_FLEXRM_MBOX + tristate "Broadcom FlexRM Mailbox" + depends on ARM64 || COMPILE_TEST + depends on HAS_DMA + select GENERIC_MSI_IRQ_DOMAIN + default ARCH_BCM_IPROC + help + Mailbox implementation of the Broadcom FlexRM ring manager, + which provides access to various offload engines on Broadcom + SoCs. Say Y here if you want to use the Broadcom FlexRM. endif diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 7dde4f6..e2bcb03 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -30,4 +30,6 @@ obj-$(CONFIG_HI6220_MBOX) += hi6220-mailbox.o obj-$(CONFIG_BCM_PDC_MBOX) += bcm-pdc-mailbox.o +obj-$(CONFIG_BCM_FLEXRM_MBOX) += bcm-flexrm-mailbox.o + obj-$(CONFIG_TEGRA_HSP_MBOX) += tegra-hsp.o diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c new file mode 100644 index 000..da67882 --- /dev/null +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -0,0 +1,1595 @@ +/* Broadcom FlexRM Mailbox Driver + * + * Copyright (C) 2017 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Each Broadcom FlexSparx4 offload engine is implemented as an + * extension to Broadcom FlexRM ring manager. The FlexRM ring + * manager provides a set of rings which can be used to submit + * work to a FlexSparx4 offload engine. + * + * This driver creates a mailbox controller using a set of FlexRM + * rings where each mailbox channel represents a separate FlexRM ring. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* == FlexRM register defines = */ + +/* FlexRM configuration */ +#define RING_REGS_SIZE 0x1 +#define RING_DESC_SIZE 8 +#define RING_DESC_INDEX(offset)\ + ((offset) / RING_DESC_SIZE) +#define RING_DESC_OFFSET(index)\ + ((index) * RING_DESC_SIZE) +#define RING_MAX_REQ_COUNT 1024 +#define RING_BD_ALIGN_ORDER12 +#define RING_BD_ALIGN_CHECK(addr) \ + (!((addr) & ((0x1 << RING_BD_ALIGN_ORDER) - 1))) +#define RING_BD_TOGGLE_INVALID(offset) \ + (((offset) >> RING_BD_ALIGN_ORDER) & 0x1) +#define RING_BD_TOGGLE_VALID(offset) \ + (!RING_BD_TOGGLE_INVALID(offset)) +#define RING_BD_DESC_PER_REQ 32 +#define RING_BD_DESC_COUNT \ + (RING_MAX_REQ_COUNT * RING_BD_DESC_PER_REQ) +#define RING_BD_SIZE \ + (RING_BD_DESC_COUNT * RING_DESC_SIZE) +#define RING_CMPL_ALIGN_ORDER 13 +#define RING_CMPL_DESC_COUNT RING_MAX_REQ_COUNT +#define RING_CMPL_SIZE \ + (RING_CMPL_DESC_COUNT * RING_DESC_SIZE) +#define RING_VER_MAGIC 0x76303031 + +/* Per-Ring register offsets */ +#define RING_VER 0x000 +#define RING_BD_START_ADDR 0x004 +#define RING_BD_READ_PTR 0x008 +#define RING_BD_WRITE_PTR 0x00c +#define
[PATCH v7 2/3] dt-bindings: Add DT bindings info for FlexRM ring manager
This patch adds device tree bindings document for the FlexRM ring manager found on Broadcom iProc SoCs. Acked-by: Rob Herring Reviewed-by: Ray Jui Reviewed-by: Scott Branden Signed-off-by: Anup Patel --- .../bindings/mailbox/brcm,iproc-flexrm-mbox.txt| 59 ++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt diff --git a/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt b/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt new file mode 100644 index 000..752ae6b --- /dev/null +++ b/Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt @@ -0,0 +1,59 @@ +Broadcom FlexRM Ring Manager + +The Broadcom FlexRM ring manager provides a set of rings which can be +used to submit work to offload engines. An SoC may have multiple FlexRM +hardware blocks. There is one device tree entry per FlexRM block. The +FlexRM driver will create a mailbox-controller instance for given FlexRM +hardware block where each mailbox channel is a separate FlexRM ring. + +Required properties: + +- compatible: Should be "brcm,iproc-flexrm-mbox" +- reg: Specifies base physical address and size of the FlexRM + ring registers +- msi-parent: Phandles (and potential Device IDs) to MSI controllers + The FlexRM engine will send MSIs (instead of wired + interrupts) to CPU. There is one MSI for each FlexRM ring. + Refer devicetree/bindings/interrupt-controller/msi.txt +- #mbox-cells: Specifies the number of cells needed to encode a mailbox + channel. This should be 3. + + The 1st cell is the mailbox channel number. + + The 2nd cell contains MSI completion threshold. This is the + number of completion messages for which FlexRM will inject + one MSI interrupt to CPU. + + The 3nd cell contains MSI timer value representing time for + which FlexRM will wait to accumulate N completion messages + where N is the value specified by 2nd cell above. If FlexRM + does not get required number of completion messages in time + specified by this cell then it will inject one MSI interrupt + to CPU provided atleast one completion message is available. + +Optional properties: + +- dma-coherent:Present if DMA operations made by the FlexRM engine (such + as DMA descriptor access, access to buffers pointed by DMA + descriptors and read/write pointer updates to DDR) are + cache coherent with the CPU. + +Example: + +crypto_mbox: mbox@6700 { + compatible = "brcm,iproc-flexrm-mbox"; + reg = <0x6700 0x20>; + msi-parent = <_its 0x7f00>; + #mbox-cells = <3>; +}; + +crypto@672c { + compatible = "brcm,spu2-v2-crypto"; + reg = <0x672c 0x1000>; + mboxes = <_mbox 0 0x1 0x>, +<_mbox 1 0x1 0x>, +<_mbox 16 0x1 0x>, +<_mbox 17 0x1 0x>, +<_mbox 30 0x1 0x>, +<_mbox 31 0x1 0x>; +}; -- 2.7.4
[PATCH v7 1/3] mailbox: Add driver for Broadcom FlexRM ring manager
Some of the Broadcom iProc SoCs have FlexRM ring manager which provides a ring-based programming interface to various offload engines (e.g. RAID, Crypto, etc). This patch adds a common mailbox driver for Broadcom FlexRM ring manager which can be shared by various offload engine drivers (implemented as mailbox clients). Reviewed-by: Ray Jui Reviewed-by: Scott Branden Reviewed-by: Pramod KUMAR Signed-off-by: Anup Patel --- drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile |2 + drivers/mailbox/bcm-flexrm-mailbox.c | 1595 ++ include/linux/mailbox/brcm-message.h | 14 +- 4 files changed, 1618 insertions(+), 4 deletions(-) create mode 100644 drivers/mailbox/bcm-flexrm-mailbox.c diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index ceff415..305018c 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -152,4 +152,15 @@ config BCM_PDC_MBOX Mailbox implementation for the Broadcom PDC ring manager, which provides access to various offload engines on Broadcom SoCs. Say Y here if you want to use the Broadcom PDC. + +config BCM_FLEXRM_MBOX + tristate "Broadcom FlexRM Mailbox" + depends on ARM64 || COMPILE_TEST + depends on HAS_DMA + select GENERIC_MSI_IRQ_DOMAIN + default ARCH_BCM_IPROC + help + Mailbox implementation of the Broadcom FlexRM ring manager, + which provides access to various offload engines on Broadcom + SoCs. Say Y here if you want to use the Broadcom FlexRM. endif diff --git a/drivers/mailbox/Makefile b/drivers/mailbox/Makefile index 7dde4f6..e2bcb03 100644 --- a/drivers/mailbox/Makefile +++ b/drivers/mailbox/Makefile @@ -30,4 +30,6 @@ obj-$(CONFIG_HI6220_MBOX) += hi6220-mailbox.o obj-$(CONFIG_BCM_PDC_MBOX) += bcm-pdc-mailbox.o +obj-$(CONFIG_BCM_FLEXRM_MBOX) += bcm-flexrm-mailbox.o + obj-$(CONFIG_TEGRA_HSP_MBOX) += tegra-hsp.o diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c new file mode 100644 index 000..da67882 --- /dev/null +++ b/drivers/mailbox/bcm-flexrm-mailbox.c @@ -0,0 +1,1595 @@ +/* Broadcom FlexRM Mailbox Driver + * + * Copyright (C) 2017 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Each Broadcom FlexSparx4 offload engine is implemented as an + * extension to Broadcom FlexRM ring manager. The FlexRM ring + * manager provides a set of rings which can be used to submit + * work to a FlexSparx4 offload engine. + * + * This driver creates a mailbox controller using a set of FlexRM + * rings where each mailbox channel represents a separate FlexRM ring. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* == FlexRM register defines = */ + +/* FlexRM configuration */ +#define RING_REGS_SIZE 0x1 +#define RING_DESC_SIZE 8 +#define RING_DESC_INDEX(offset)\ + ((offset) / RING_DESC_SIZE) +#define RING_DESC_OFFSET(index)\ + ((index) * RING_DESC_SIZE) +#define RING_MAX_REQ_COUNT 1024 +#define RING_BD_ALIGN_ORDER12 +#define RING_BD_ALIGN_CHECK(addr) \ + (!((addr) & ((0x1 << RING_BD_ALIGN_ORDER) - 1))) +#define RING_BD_TOGGLE_INVALID(offset) \ + (((offset) >> RING_BD_ALIGN_ORDER) & 0x1) +#define RING_BD_TOGGLE_VALID(offset) \ + (!RING_BD_TOGGLE_INVALID(offset)) +#define RING_BD_DESC_PER_REQ 32 +#define RING_BD_DESC_COUNT \ + (RING_MAX_REQ_COUNT * RING_BD_DESC_PER_REQ) +#define RING_BD_SIZE \ + (RING_BD_DESC_COUNT * RING_DESC_SIZE) +#define RING_CMPL_ALIGN_ORDER 13 +#define RING_CMPL_DESC_COUNT RING_MAX_REQ_COUNT +#define RING_CMPL_SIZE \ + (RING_CMPL_DESC_COUNT * RING_DESC_SIZE) +#define RING_VER_MAGIC 0x76303031 + +/* Per-Ring register offsets */ +#define RING_VER 0x000 +#define RING_BD_START_ADDR 0x004 +#define RING_BD_READ_PTR 0x008 +#define RING_BD_WRITE_PTR 0x00c +#define RING_BD_READ_PTR_DDR_LS0x010 +#define RING_BD_READ_PTR_DDR_MS
[PATCH v7 0/3] Broadcom FlexRM ring manager support
The Broadcom FlexRM ring manager provides producer-consumer style ring interface for offload engines on Broadcom iProc SoCs. We can have one or more instances of Broadcom FlexRM ring manager in a SoC. This patchset adds a mailbox driver for Broadcom FlexRM ring manager which can be used by offload engine drivers as mailbox clients. The Broadcom FlexRM mailbox driver is feature complete for RAID and Crypto offload engines. We will have incremental patches in-future for ring-level statistics using debugfs and minor optimizations. This patchset is based on Linux-4.11-rc4 and it is also available at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git Changes since v6: - Rebased patches for Linux-4.11-rc4 - Added a patch to remove depends on COMPILE_TEST for kconfig option BCM_FLEXRM_MBOX Changes since v5: - Rebased patches for Linux-4.11-rc2 - Merged all source files into one source file and removed driver directory Changes since v4: - Rebased patches for Linux-4.11-rc1 Changes since v3: - Fixed mailbox client example DT node in DT bindings document Changes since v2: - Rebased patches for Linux-4.10-rc2 Changes since v1: - Use compatile string as brcm,iproc-flexrm-mbox - Rephrase commit message and text in DT bindings patch Anup Patel (3): mailbox: Add driver for Broadcom FlexRM ring manager dt-bindings: Add DT bindings info for FlexRM ring manager mailbox: Remove depends on COMPILE_TEST for BCM_FLEXRM_MBOX .../bindings/mailbox/brcm,iproc-flexrm-mbox.txt| 59 + drivers/mailbox/Kconfig| 11 + drivers/mailbox/Makefile |2 + drivers/mailbox/bcm-flexrm-mailbox.c | 1595 include/linux/mailbox/brcm-message.h | 14 +- 5 files changed, 1677 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt create mode 100644 drivers/mailbox/bcm-flexrm-mailbox.c -- 2.7.4
[PATCH v7 0/3] Broadcom FlexRM ring manager support
The Broadcom FlexRM ring manager provides producer-consumer style ring interface for offload engines on Broadcom iProc SoCs. We can have one or more instances of Broadcom FlexRM ring manager in a SoC. This patchset adds a mailbox driver for Broadcom FlexRM ring manager which can be used by offload engine drivers as mailbox clients. The Broadcom FlexRM mailbox driver is feature complete for RAID and Crypto offload engines. We will have incremental patches in-future for ring-level statistics using debugfs and minor optimizations. This patchset is based on Linux-4.11-rc4 and it is also available at flexrm-v7 branch of https://github.com/Broadcom/arm64-linux.git Changes since v6: - Rebased patches for Linux-4.11-rc4 - Added a patch to remove depends on COMPILE_TEST for kconfig option BCM_FLEXRM_MBOX Changes since v5: - Rebased patches for Linux-4.11-rc2 - Merged all source files into one source file and removed driver directory Changes since v4: - Rebased patches for Linux-4.11-rc1 Changes since v3: - Fixed mailbox client example DT node in DT bindings document Changes since v2: - Rebased patches for Linux-4.10-rc2 Changes since v1: - Use compatile string as brcm,iproc-flexrm-mbox - Rephrase commit message and text in DT bindings patch Anup Patel (3): mailbox: Add driver for Broadcom FlexRM ring manager dt-bindings: Add DT bindings info for FlexRM ring manager mailbox: Remove depends on COMPILE_TEST for BCM_FLEXRM_MBOX .../bindings/mailbox/brcm,iproc-flexrm-mbox.txt| 59 + drivers/mailbox/Kconfig| 11 + drivers/mailbox/Makefile |2 + drivers/mailbox/bcm-flexrm-mailbox.c | 1595 include/linux/mailbox/brcm-message.h | 14 +- 5 files changed, 1677 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/mailbox/brcm,iproc-flexrm-mbox.txt create mode 100644 drivers/mailbox/bcm-flexrm-mailbox.c -- 2.7.4
Re: [PATCH v3 2/3] irqchip: mtk-cirq: Add mediatek mtk-cirq implement
On Fri, 2017-03-24 at 16:22 +, Marc Zyngier wrote: > On 14/02/17 02:56, Youlin Pei wrote: > > In Mediatek SOCs, the CIRQ is a low power interrupt controller > > designed to works outside MCUSYS which comprises with Cortex-Ax > > cores,CCI and GIC. > > > > The CIRQ controller is integrated in between MCUSYS( include > > Cortex-Ax, CCI and GIC ) and interrupt sources as the second > > level interrupt controller. The external interrupts which outside > > MCUSYS will feed through CIRQ then bypass to GIC. CIRQ can monitors > > all edge trigger interupts. When an edge interrupt is triggered, > > CIRQ can record the status and generate a pulse signal to GIC when > > flush command executed. > > > > When system enters sleep mode, MCUSYS will be turned off to improve > > power consumption, also GIC is power down. The edge trigger interrupts > > will be lost in this scenario without CIRQ. > > > > This commit provides the CIRQ irqchip implement. > > > > Signed-off-by: Youlin Pei> > --- > > drivers/irqchip/Makefile |2 +- > > drivers/irqchip/irq-mtk-cirq.c | 288 > > > > 2 files changed, 289 insertions(+), 1 deletion(-) > > create mode 100644 drivers/irqchip/irq-mtk-cirq.c > > > > diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile > > index 0e55d94..db9acd1 100644 > > --- a/drivers/irqchip/Makefile > > +++ b/drivers/irqchip/Makefile > > @@ -61,7 +61,7 @@ obj-$(CONFIG_BCM7120_L2_IRQ) += > > irq-bcm7120-l2.o > > obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o > > obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o > > obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o > > -obj-$(CONFIG_ARCH_MEDIATEK)+= irq-mtk-sysirq.o > > +obj-$(CONFIG_ARCH_MEDIATEK)+= irq-mtk-sysirq.o > > irq-mtk-cirq.o > > obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o > > obj-$(CONFIG_RENESAS_H8300H_INTC) += irq-renesas-h8300h.o > > obj-$(CONFIG_RENESAS_H8S_INTC) += irq-renesas-h8s.o > > diff --git a/drivers/irqchip/irq-mtk-cirq.c b/drivers/irqchip/irq-mtk-cirq.c > > new file mode 100644 > > index 000..b5cf506 > > --- /dev/null > > +++ b/drivers/irqchip/irq-mtk-cirq.c > > @@ -0,0 +1,288 @@ > > +/* > > + * Copyright (c) 2016 MediaTek Inc. > > + * Author: Youlin.Pei > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define CIRQ_ACK 0x40 > > +#define CIRQ_MASK_SET 0xc0 > > +#define CIRQ_MASK_CLR 0x100 > > +#define CIRQ_SENS_SET 0x180 > > +#define CIRQ_SENS_CLR 0x1c0 > > +#define CIRQ_POL_SET 0x240 > > +#define CIRQ_POL_CLR 0x280 > > +#define CIRQ_CONTROL 0x300 > > + > > +#define CIRQ_EN0x1 > > +#define CIRQ_EDGE 0x2 > > +#define CIRQ_FLUSH 0x4 > > + > > +struct mtk_cirq_chip_data { > > + void __iomem *base; > > + unsigned int ext_irq_start; > > + unsigned int ext_irq_end; > > + struct irq_domain *domain; > > +}; > > + > > +static struct mtk_cirq_chip_data *cirq_data; > > Question in relation to the sysirq patches that have been queued for > 4.12: Are we going to see something similar with this driver, where > you're going to have to support multiple non-contiguous register sets? > I'd rather have this kind of thing from day one, instead of adding that > at a later time... > > Specially given that the platform that is using this driver does also > have a sysirq controller. Hi Marc, Thanks for your review. All of the cirq's registers are in continuous space, So no need to support multiple non-continuous register sets. > > > + > > +static void mtk_cirq_write_mask(struct irq_data *data, unsigned int offset) > > +{ > > + struct mtk_cirq_chip_data *chip_data = data->chip_data; > > + unsigned int cirq_num = data->hwirq; > > + u32 mask = 1 << (cirq_num % 32); > > + > > + writel_relaxed(mask, chip_data->base + offset + (cirq_num / 32) * 4); > > +} > > + > > +static void mtk_cirq_mask(struct irq_data *data) > > +{ > > + mtk_cirq_write_mask(data, CIRQ_MASK_SET); > > + irq_chip_mask_parent(data); > > +} > > + > > +static void mtk_cirq_unmask(struct irq_data *data) > > +{ > > + mtk_cirq_write_mask(data, CIRQ_MASK_CLR); > > + irq_chip_unmask_parent(data); > > +} > > + > > +static int mtk_cirq_set_type(struct irq_data *data, unsigned int type) > > +{ > > +
Re: [PATCH v3 2/3] irqchip: mtk-cirq: Add mediatek mtk-cirq implement
On Fri, 2017-03-24 at 16:22 +, Marc Zyngier wrote: > On 14/02/17 02:56, Youlin Pei wrote: > > In Mediatek SOCs, the CIRQ is a low power interrupt controller > > designed to works outside MCUSYS which comprises with Cortex-Ax > > cores,CCI and GIC. > > > > The CIRQ controller is integrated in between MCUSYS( include > > Cortex-Ax, CCI and GIC ) and interrupt sources as the second > > level interrupt controller. The external interrupts which outside > > MCUSYS will feed through CIRQ then bypass to GIC. CIRQ can monitors > > all edge trigger interupts. When an edge interrupt is triggered, > > CIRQ can record the status and generate a pulse signal to GIC when > > flush command executed. > > > > When system enters sleep mode, MCUSYS will be turned off to improve > > power consumption, also GIC is power down. The edge trigger interrupts > > will be lost in this scenario without CIRQ. > > > > This commit provides the CIRQ irqchip implement. > > > > Signed-off-by: Youlin Pei > > --- > > drivers/irqchip/Makefile |2 +- > > drivers/irqchip/irq-mtk-cirq.c | 288 > > > > 2 files changed, 289 insertions(+), 1 deletion(-) > > create mode 100644 drivers/irqchip/irq-mtk-cirq.c > > > > diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile > > index 0e55d94..db9acd1 100644 > > --- a/drivers/irqchip/Makefile > > +++ b/drivers/irqchip/Makefile > > @@ -61,7 +61,7 @@ obj-$(CONFIG_BCM7120_L2_IRQ) += > > irq-bcm7120-l2.o > > obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o > > obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o > > obj-$(CONFIG_MIPS_GIC) += irq-mips-gic.o > > -obj-$(CONFIG_ARCH_MEDIATEK)+= irq-mtk-sysirq.o > > +obj-$(CONFIG_ARCH_MEDIATEK)+= irq-mtk-sysirq.o > > irq-mtk-cirq.o > > obj-$(CONFIG_ARCH_DIGICOLOR) += irq-digicolor.o > > obj-$(CONFIG_RENESAS_H8300H_INTC) += irq-renesas-h8300h.o > > obj-$(CONFIG_RENESAS_H8S_INTC) += irq-renesas-h8s.o > > diff --git a/drivers/irqchip/irq-mtk-cirq.c b/drivers/irqchip/irq-mtk-cirq.c > > new file mode 100644 > > index 000..b5cf506 > > --- /dev/null > > +++ b/drivers/irqchip/irq-mtk-cirq.c > > @@ -0,0 +1,288 @@ > > +/* > > + * Copyright (c) 2016 MediaTek Inc. > > + * Author: Youlin.Pei > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 as > > + * published by the Free Software Foundation. > > + * > > + * This program is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > > + * GNU General Public License for more details. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define CIRQ_ACK 0x40 > > +#define CIRQ_MASK_SET 0xc0 > > +#define CIRQ_MASK_CLR 0x100 > > +#define CIRQ_SENS_SET 0x180 > > +#define CIRQ_SENS_CLR 0x1c0 > > +#define CIRQ_POL_SET 0x240 > > +#define CIRQ_POL_CLR 0x280 > > +#define CIRQ_CONTROL 0x300 > > + > > +#define CIRQ_EN0x1 > > +#define CIRQ_EDGE 0x2 > > +#define CIRQ_FLUSH 0x4 > > + > > +struct mtk_cirq_chip_data { > > + void __iomem *base; > > + unsigned int ext_irq_start; > > + unsigned int ext_irq_end; > > + struct irq_domain *domain; > > +}; > > + > > +static struct mtk_cirq_chip_data *cirq_data; > > Question in relation to the sysirq patches that have been queued for > 4.12: Are we going to see something similar with this driver, where > you're going to have to support multiple non-contiguous register sets? > I'd rather have this kind of thing from day one, instead of adding that > at a later time... > > Specially given that the platform that is using this driver does also > have a sysirq controller. Hi Marc, Thanks for your review. All of the cirq's registers are in continuous space, So no need to support multiple non-continuous register sets. > > > + > > +static void mtk_cirq_write_mask(struct irq_data *data, unsigned int offset) > > +{ > > + struct mtk_cirq_chip_data *chip_data = data->chip_data; > > + unsigned int cirq_num = data->hwirq; > > + u32 mask = 1 << (cirq_num % 32); > > + > > + writel_relaxed(mask, chip_data->base + offset + (cirq_num / 32) * 4); > > +} > > + > > +static void mtk_cirq_mask(struct irq_data *data) > > +{ > > + mtk_cirq_write_mask(data, CIRQ_MASK_SET); > > + irq_chip_mask_parent(data); > > +} > > + > > +static void mtk_cirq_unmask(struct irq_data *data) > > +{ > > + mtk_cirq_write_mask(data, CIRQ_MASK_CLR); > > + irq_chip_unmask_parent(data); > > +} > > + > > +static int mtk_cirq_set_type(struct irq_data *data, unsigned int type) > > +{ > > + int ret; > > + > > + switch (type &
[RFC PATCH tip/master 3/3] kprobes: Limit kretprobe maximum instances
Limit kretprobe maximum instance up to MAXACTIVE_ALLOC. Without this limit, kretprobe user can specify huge number (e.g. forget to zero-fill struct kretprobe) to maxactive and may cause out-of-memory. Signed-off-by: Masami Hiramatsu--- kernel/kprobes.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 75c5390..f1bebcf 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1942,6 +1942,9 @@ int register_kretprobe(struct kretprobe *rp) rp->kp.break_handler = NULL; /* Pre-allocate memory for max kretprobe instances */ + if (rp->maxactive > KRETPROBE_MAXACTIVE_ALLOC) + return -E2BIG; + if (rp->maxactive <= 0) { #ifdef CONFIG_PREEMPT rp->maxactive = max_t(unsigned int, 10, 2*num_possible_cpus());
[RFC PATCH tip/master 3/3] kprobes: Limit kretprobe maximum instances
Limit kretprobe maximum instance up to MAXACTIVE_ALLOC. Without this limit, kretprobe user can specify huge number (e.g. forget to zero-fill struct kretprobe) to maxactive and may cause out-of-memory. Signed-off-by: Masami Hiramatsu --- kernel/kprobes.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 75c5390..f1bebcf 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1942,6 +1942,9 @@ int register_kretprobe(struct kretprobe *rp) rp->kp.break_handler = NULL; /* Pre-allocate memory for max kretprobe instances */ + if (rp->maxactive > KRETPROBE_MAXACTIVE_ALLOC) + return -E2BIG; + if (rp->maxactive <= 0) { #ifdef CONFIG_PREEMPT rp->maxactive = max_t(unsigned int, 10, 2*num_possible_cpus());
[RFC PATCH tip/master 2/3] kprobes: Allocate kretprobe instance if its free list is empty
Try to allocate kretprobe instance by GFP_ATOMIC if kretprobe's free list is empty. This can prevent kretprobe miss-hit on the function which can be heavily invoked and slept inside (like locking syscall entries.) NOTE: This may easily cause nested kprobe call which will be just skipped (but nmissed count is incremented), if someone probe functions on the memory allocation path. Signed-off-by: Masami Hiramatsu--- Documentation/kprobes.txt | 25 +++-- include/linux/kprobes.h |2 ++ kernel/kprobes.c | 41 + 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt index 1f6d45a..2de6533 100644 --- a/Documentation/kprobes.txt +++ b/Documentation/kprobes.txt @@ -131,11 +131,13 @@ kretprobe, then sets the saved instruction pointer to the saved return address, and that's where execution resumes upon return from the trap. While the probed function is executing, its return address is -stored in an object of type kretprobe_instance. Before calling -register_kretprobe(), the user sets the maxactive field of the -kretprobe struct to specify how many instances of the specified -function can be probed simultaneously. register_kretprobe() -pre-allocates the indicated number of kretprobe_instance objects. +stored in an object of type kretprobe_instance. Usually, this +kretprobe_instance will be allocated dynamically. +Since the dynamic allocation can cause mis-hit of other probes +on memory allocation path, user can set maxactive field for pooling +pre-allocated instances before calling register_kretprobe(). +This maxactive indicates how many instances of the specified +function can be probed simultaneously. For example, if the function is non-recursive and is called with a spinlock held, maxactive = 1 should be enough. If the function is @@ -144,11 +146,14 @@ or preemption), NR_CPUS should be enough. If maxactive <= 0, it is set to a default value. If CONFIG_PREEMPT is enabled, the default is max(10, 2*NR_CPUS). Otherwise, the default is NR_CPUS. -It's not a disaster if you set maxactive too low; you'll just miss -some probes. In the kretprobe struct, the nmissed field is set to -zero when the return probe is registered, and is incremented every -time the probed function is entered but there is no kretprobe_instance -object available for establishing the return probe. +It's not a disaster if you set maxactive too low; you'll just see +some probes on memory allocation path missed if it exists. + +In the kretprobe struct, the nmissed field is set to zero when the +return probe is registered, and is incremented every time the probed +function is entered but there is no kretprobe_instance object available +and it fails to allocate new one, or hit the upper limit of maxactive +(KRETPROBE_MAXACTIVE_ALLOC, currently it is 4096.) 1.3.2 Kretprobe entry-handler diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 47e4da5..8064e14 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -192,6 +192,8 @@ struct kretprobe { struct hlist_head free_instances; raw_spinlock_t lock; }; +/* Upper limit of maxactive for dynamic allocation */ +#define KRETPROBE_MAXACTIVE_ALLOC 4096 struct kretprobe_instance { struct hlist_node hlist; diff --git a/kernel/kprobes.c b/kernel/kprobes.c index d733479..75c5390 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -57,7 +57,6 @@ #define KPROBE_HASH_BITS 6 #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) - /* * Some oddball architectures like 64bit powerpc have function descriptors * so this must be overridable. @@ -1824,6 +1823,30 @@ void unregister_jprobes(struct jprobe **jps, int num) EXPORT_SYMBOL_GPL(unregister_jprobes); #ifdef CONFIG_KRETPROBES + +/* Try to use free instance first, if failed, try to allocate new instance */ +struct kretprobe_instance *kretprobe_alloc_instance(struct kretprobe *rp) +{ + struct kretprobe_instance *ri = NULL; + unsigned long flags = 0; + + raw_spin_lock_irqsave(>lock, flags); + if (!hlist_empty(>free_instances)) { + ri = hlist_entry(rp->free_instances.first, + struct kretprobe_instance, hlist); + hlist_del(>hlist); + } + raw_spin_unlock_irqrestore(>lock, flags); + + /* Populate max active instance if possible */ + if (!ri && rp->maxactive < KRETPROBE_MAXACTIVE_ALLOC) { + ri = kmalloc(sizeof(*ri) + rp->data_size, GFP_ATOMIC); + if (ri) + rp->maxactive++; + } + + return ri; +} /* * This kprobe pre_handler is registered with every kretprobe. When probe * hits it will set up the return probe. @@ -1846,14 +1869,8 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) } /* TODO: consider to only
[RFC PATCH tip/master 2/3] kprobes: Allocate kretprobe instance if its free list is empty
Try to allocate kretprobe instance by GFP_ATOMIC if kretprobe's free list is empty. This can prevent kretprobe miss-hit on the function which can be heavily invoked and slept inside (like locking syscall entries.) NOTE: This may easily cause nested kprobe call which will be just skipped (but nmissed count is incremented), if someone probe functions on the memory allocation path. Signed-off-by: Masami Hiramatsu --- Documentation/kprobes.txt | 25 +++-- include/linux/kprobes.h |2 ++ kernel/kprobes.c | 41 + 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/Documentation/kprobes.txt b/Documentation/kprobes.txt index 1f6d45a..2de6533 100644 --- a/Documentation/kprobes.txt +++ b/Documentation/kprobes.txt @@ -131,11 +131,13 @@ kretprobe, then sets the saved instruction pointer to the saved return address, and that's where execution resumes upon return from the trap. While the probed function is executing, its return address is -stored in an object of type kretprobe_instance. Before calling -register_kretprobe(), the user sets the maxactive field of the -kretprobe struct to specify how many instances of the specified -function can be probed simultaneously. register_kretprobe() -pre-allocates the indicated number of kretprobe_instance objects. +stored in an object of type kretprobe_instance. Usually, this +kretprobe_instance will be allocated dynamically. +Since the dynamic allocation can cause mis-hit of other probes +on memory allocation path, user can set maxactive field for pooling +pre-allocated instances before calling register_kretprobe(). +This maxactive indicates how many instances of the specified +function can be probed simultaneously. For example, if the function is non-recursive and is called with a spinlock held, maxactive = 1 should be enough. If the function is @@ -144,11 +146,14 @@ or preemption), NR_CPUS should be enough. If maxactive <= 0, it is set to a default value. If CONFIG_PREEMPT is enabled, the default is max(10, 2*NR_CPUS). Otherwise, the default is NR_CPUS. -It's not a disaster if you set maxactive too low; you'll just miss -some probes. In the kretprobe struct, the nmissed field is set to -zero when the return probe is registered, and is incremented every -time the probed function is entered but there is no kretprobe_instance -object available for establishing the return probe. +It's not a disaster if you set maxactive too low; you'll just see +some probes on memory allocation path missed if it exists. + +In the kretprobe struct, the nmissed field is set to zero when the +return probe is registered, and is incremented every time the probed +function is entered but there is no kretprobe_instance object available +and it fails to allocate new one, or hit the upper limit of maxactive +(KRETPROBE_MAXACTIVE_ALLOC, currently it is 4096.) 1.3.2 Kretprobe entry-handler diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 47e4da5..8064e14 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -192,6 +192,8 @@ struct kretprobe { struct hlist_head free_instances; raw_spinlock_t lock; }; +/* Upper limit of maxactive for dynamic allocation */ +#define KRETPROBE_MAXACTIVE_ALLOC 4096 struct kretprobe_instance { struct hlist_node hlist; diff --git a/kernel/kprobes.c b/kernel/kprobes.c index d733479..75c5390 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -57,7 +57,6 @@ #define KPROBE_HASH_BITS 6 #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) - /* * Some oddball architectures like 64bit powerpc have function descriptors * so this must be overridable. @@ -1824,6 +1823,30 @@ void unregister_jprobes(struct jprobe **jps, int num) EXPORT_SYMBOL_GPL(unregister_jprobes); #ifdef CONFIG_KRETPROBES + +/* Try to use free instance first, if failed, try to allocate new instance */ +struct kretprobe_instance *kretprobe_alloc_instance(struct kretprobe *rp) +{ + struct kretprobe_instance *ri = NULL; + unsigned long flags = 0; + + raw_spin_lock_irqsave(>lock, flags); + if (!hlist_empty(>free_instances)) { + ri = hlist_entry(rp->free_instances.first, + struct kretprobe_instance, hlist); + hlist_del(>hlist); + } + raw_spin_unlock_irqrestore(>lock, flags); + + /* Populate max active instance if possible */ + if (!ri && rp->maxactive < KRETPROBE_MAXACTIVE_ALLOC) { + ri = kmalloc(sizeof(*ri) + rp->data_size, GFP_ATOMIC); + if (ri) + rp->maxactive++; + } + + return ri; +} /* * This kprobe pre_handler is registered with every kretprobe. When probe * hits it will set up the return probe. @@ -1846,14 +1869,8 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) } /* TODO: consider to only swap the RA after the
[RFC PATCH tip/master 1/3] trace: kprobes: Show sum of probe/retprobe nmissed count
Show sum of probe and retprobe nmissed count in kprobe_profile, since retprobe can be missed even if the kprobe itself succeeeded. This explains user why their return probe didn't hit sometimes. Signed-off-by: Masami Hiramatsu--- kernel/trace/trace_kprobe.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 013f4e7..bbdc3de 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -896,7 +896,7 @@ static int probes_profile_seq_show(struct seq_file *m, void *v) seq_printf(m, " %-44s %15lu %15lu\n", trace_event_name(>tp.call), trace_kprobe_nhit(tk), - tk->rp.kp.nmissed); + tk->rp.kp.nmissed + tk->rp.nmissed); return 0; }
[RFC PATCH tip/master 1/3] trace: kprobes: Show sum of probe/retprobe nmissed count
Show sum of probe and retprobe nmissed count in kprobe_profile, since retprobe can be missed even if the kprobe itself succeeeded. This explains user why their return probe didn't hit sometimes. Signed-off-by: Masami Hiramatsu --- kernel/trace/trace_kprobe.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 013f4e7..bbdc3de 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -896,7 +896,7 @@ static int probes_profile_seq_show(struct seq_file *m, void *v) seq_printf(m, " %-44s %15lu %15lu\n", trace_event_name(>tp.call), trace_kprobe_nhit(tk), - tk->rp.kp.nmissed); + tk->rp.kp.nmissed + tk->rp.nmissed); return 0; }
[RFC PATCH tip/master 0/3] kprobes: tracing: kretprobe_instance dynamic allocation
Here is a correction of patches to introduce kretprobe_instance dynamic allocation for avoiding kretprobe silently miss-hits. Original issue was reported by Lukasz on linux-trace ml. https://www.spinics.net/lists/linux-trace/msg00448.html Also Alban is working on kprobe-tracer side because of iovisor's issue. https://www.spinics.net/lists/netdev/msg427149.html (Note that this series is independently applicable, no conflict) This series is a kind of complementary patches for Alban's patch. So I think both of them are needed. [1/3]: Add kretprobe's miss-hit counter to miss-hit column on kprobe_profile. This helps user to see what happened. [2/3]: Introduce kretprobe_instance dynamic allocation. This will help user not to miss the ret probes even it has low number of maxactive. [3/3]: Set maximum limitation for pre-allocated maxactive. This can avoid miss configuration of struct kretprobe. The downside of this patch is, dynamic allocation will involve memory allocation, which sometimes traced by kprobes. In that case those nested kprobes are missed. To avoid this kind of miss-hit, user may need to make maxactive enough large when registering kretprobes. However, in other case, this can reduce the possibility of miss-hit of kretprobes. Since the maxactive increased automatically, user will not need to retry tracing with larger maxactive. Alban, you can reuse KRETPROBE_MAXACTIVE_ALLOC for checking upper limiation in trace_kprobe.c too. Thank you, --- Masami Hiramatsu (3): trace: kprobes: Show sum of probe/retprobe nmissed count kprobes: Allocate kretprobe instance if its free list is empty kprobes: Limit kretprobe maximum instances Documentation/kprobes.txt | 25 +++- include/linux/kprobes.h |2 ++ kernel/kprobes.c| 44 +++ kernel/trace/trace_kprobe.c |2 +- 4 files changed, 50 insertions(+), 23 deletions(-) -- Masami Hiramatsu (Linaro)
[RFC PATCH tip/master 0/3] kprobes: tracing: kretprobe_instance dynamic allocation
Here is a correction of patches to introduce kretprobe_instance dynamic allocation for avoiding kretprobe silently miss-hits. Original issue was reported by Lukasz on linux-trace ml. https://www.spinics.net/lists/linux-trace/msg00448.html Also Alban is working on kprobe-tracer side because of iovisor's issue. https://www.spinics.net/lists/netdev/msg427149.html (Note that this series is independently applicable, no conflict) This series is a kind of complementary patches for Alban's patch. So I think both of them are needed. [1/3]: Add kretprobe's miss-hit counter to miss-hit column on kprobe_profile. This helps user to see what happened. [2/3]: Introduce kretprobe_instance dynamic allocation. This will help user not to miss the ret probes even it has low number of maxactive. [3/3]: Set maximum limitation for pre-allocated maxactive. This can avoid miss configuration of struct kretprobe. The downside of this patch is, dynamic allocation will involve memory allocation, which sometimes traced by kprobes. In that case those nested kprobes are missed. To avoid this kind of miss-hit, user may need to make maxactive enough large when registering kretprobes. However, in other case, this can reduce the possibility of miss-hit of kretprobes. Since the maxactive increased automatically, user will not need to retry tracing with larger maxactive. Alban, you can reuse KRETPROBE_MAXACTIVE_ALLOC for checking upper limiation in trace_kprobe.c too. Thank you, --- Masami Hiramatsu (3): trace: kprobes: Show sum of probe/retprobe nmissed count kprobes: Allocate kretprobe instance if its free list is empty kprobes: Limit kretprobe maximum instances Documentation/kprobes.txt | 25 +++- include/linux/kprobes.h |2 ++ kernel/kprobes.c| 44 +++ kernel/trace/trace_kprobe.c |2 +- 4 files changed, 50 insertions(+), 23 deletions(-) -- Masami Hiramatsu (Linaro)
linux-next: build failure after merge of the mailbox tree
Hi Jassi, After merging the mailbox tree, today's linux-next build (powerpc allyesconfig) failed like this: In file included from /home/sfr/next/next/include/linux/kvm_host.h:20:0, from /home/sfr/next/next/arch/powerpc/kernel/asm-offsets.c:54: /home/sfr/next/next/include/linux/msi.h:195:21: fatal error: asm/msi.h: No such file or directory Caused by commit dbc049eee730 ("mailbox: Add driver for Broadcom FlexRM ring manager") Not all architectures have the above include file. I have added the following patch for today: From: Stephen RothwellDate: Wed, 29 Mar 2017 16:11:14 +1100 Subject: [PATCH] mailbox: do not compile test the Broadcom FlexRM Mailbox driver Signed-off-by: Stephen Rothwell --- drivers/mailbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 0b6f25e26c7c..ee1a3d9147ef 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -154,7 +154,7 @@ config BCM_PDC_MBOX config BCM_FLEXRM_MBOX tristate "Broadcom FlexRM Mailbox" - depends on ARM64 || COMPILE_TEST + depends on ARM64 depends on HAS_DMA select GENERIC_MSI_IRQ_DOMAIN default ARCH_BCM_IPROC -- 2.11.0 -- Cheers, Stephen Rothwell
linux-next: build failure after merge of the mailbox tree
Hi Jassi, After merging the mailbox tree, today's linux-next build (powerpc allyesconfig) failed like this: In file included from /home/sfr/next/next/include/linux/kvm_host.h:20:0, from /home/sfr/next/next/arch/powerpc/kernel/asm-offsets.c:54: /home/sfr/next/next/include/linux/msi.h:195:21: fatal error: asm/msi.h: No such file or directory Caused by commit dbc049eee730 ("mailbox: Add driver for Broadcom FlexRM ring manager") Not all architectures have the above include file. I have added the following patch for today: From: Stephen Rothwell Date: Wed, 29 Mar 2017 16:11:14 +1100 Subject: [PATCH] mailbox: do not compile test the Broadcom FlexRM Mailbox driver Signed-off-by: Stephen Rothwell --- drivers/mailbox/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig index 0b6f25e26c7c..ee1a3d9147ef 100644 --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -154,7 +154,7 @@ config BCM_PDC_MBOX config BCM_FLEXRM_MBOX tristate "Broadcom FlexRM Mailbox" - depends on ARM64 || COMPILE_TEST + depends on ARM64 depends on HAS_DMA select GENERIC_MSI_IRQ_DOMAIN default ARCH_BCM_IPROC -- 2.11.0 -- Cheers, Stephen Rothwell
Re: [PATCH v22 02/11] clocksource: arm_arch_timer: separate out device-tree code and remove arch_timer_detect_rate
Hi Daniel, On 29 March 2017 at 11:41, Fu Weiwrote: > Hi Daniel, > > Great thanks for your review, allow me to answer your question below: > > On 28 March 2017 at 22:58, Daniel Lezcano wrote: >> On Wed, Mar 22, 2017 at 12:31:13AM +0800, fu@linaro.org wrote: >>> From: Fu Wei >>> >>> Currently, the counter frequency detection call(arch_timer_detect_rate) >>> includes getting the frequency from the device-tree property, the per-cpu >>> arch-timer and the memory-mapped (MMIO) timer interfaces. >>> But reading device-tree property will be needed only when system boot with >>> device-tree, and reading from the per-cpu arch-timer and the memory-mapped >>> (MMIO) timer interfaces will be needed only when the system initializes >>> the relevant timer. >>> >>> This patch separates out device-tree code, keep them in device-tree init >>> function, and removes arch_timer_detect_rate founction, then uses the >>> arch_timer_get_cntfrq and arch_timer_mem_get_cntfrq directly. >>> >>> Signed-off-by: Fu Wei >>> --- >>> drivers/clocksource/arm_arch_timer.c | 58 >>> +++- >>> 1 file changed, 30 insertions(+), 28 deletions(-) >>> >>> diff --git a/drivers/clocksource/arm_arch_timer.c >>> b/drivers/clocksource/arm_arch_timer.c >>> index 843f923..29ca7d6 100644 >>> --- a/drivers/clocksource/arm_arch_timer.c >>> +++ b/drivers/clocksource/arm_arch_timer.c >>> @@ -560,30 +560,6 @@ static u32 arch_timer_mem_get_cntfrq(void __iomem >>> *cntbase) >>> return readl_relaxed(cntbase + CNTFRQ); >>> } >>> >>> -static void >>> -arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) >>> -{ >>> - /* Who has more than one independent system counter? */ >>> - if (arch_timer_rate) >>> - return; >>> - >>> - /* >>> - * Try to determine the frequency from the device tree or CNTFRQ, >>> - * if ACPI is enabled, get the frequency from CNTFRQ ONLY. >>> - */ >>> - if (!acpi_disabled || >>> - of_property_read_u32(np, "clock-frequency", _timer_rate)) { >>> - if (cntbase) >>> - arch_timer_rate = arch_timer_mem_get_cntfrq(cntbase); >>> - else >>> - arch_timer_rate = arch_timer_get_cntfrq(); >>> - } >>> - >>> - /* Check the timer frequency. */ >>> - if (arch_timer_rate == 0) >>> - pr_warn("frequency not available\n"); >>> -} >>> - >>> static void arch_timer_banner(unsigned type) >>> { >>> pr_info("%s%s%s timer(s) running at %lu.%02luMHz (%s%s%s).\n", >>> @@ -958,7 +934,17 @@ static int __init arch_timer_of_init(struct >>> device_node *np) >>> for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; >>> i++) >>> arch_timer_ppi[i] = irq_of_parse_and_map(np, i); >>> >>> - arch_timer_detect_rate(NULL, np); >>> + /* >>> + * Try to determine the frequency from the device tree, >>> + * if fail, get the frequency from the sysreg CNTFRQ. >>> + */ >>> + if (!arch_timer_rate && >> >> This variable is set only if "arm,armv7-timer" and "arm,armv7-timer-mem" are >> declared together in the DT, right ? >> >> Two declarations for a single variable ? Ignore the !arch_timer_rate. > > In this function, we try to initialize per-CPU arm arch_timer by DT. > this "!arch_timer_rate" is for testing that if we have got system > counter frequency from the memory-mapped timer. If so, we just skip > getting the frequency from DT or sysreg cntfrq again. > This variable is set only if "arm,armv7-timer-mem" is initialized > earlier than "arm,armv7-timer", in another word, maybe the node of > "arm,armv7-timer-mem" is declared earlier than "arm,armv7-timer-mem" > one in DT. > > we do this check is for keeping the same init logic as before in the > DT, try to avoid any possibility of breaking devices which boot by > DT. > >> >>> + of_property_read_u32(np, "clock-frequency", _timer_rate)) >>> + arch_timer_rate = arch_timer_get_cntfrq(); >>> + if (!arch_timer_rate) { >>> + pr_err(FW_BUG "frequency not available.\n"); >>> + return -EINVAL; >>> + } >> >> Please, clarify this block, the conditions are unclear. > > this "!arch_timer_rate" is for verifying that if the system counter > frequency we just got from DT or sysreg cntfrq is valid(non-zero). > > So here, you can see I check arch_timer_rate twice, but they are for > different cases. I think about this several times, For this block, it is a little unclear, so I think this will be better: + /* + * Try to determine the frequency: + * If we have got it in arch_timer_mem_of_init, we don't need to get it again, skip. + * Otherwise, try to get the frequency from the device tree, + * if fail, try to get it from the sysreg CNTFRQ. + * Last, verify the arch_timer_rate before leaving this block. + */ + if (!arch_timer_rate) { + if
Re: [PATCH v22 02/11] clocksource: arm_arch_timer: separate out device-tree code and remove arch_timer_detect_rate
Hi Daniel, On 29 March 2017 at 11:41, Fu Wei wrote: > Hi Daniel, > > Great thanks for your review, allow me to answer your question below: > > On 28 March 2017 at 22:58, Daniel Lezcano wrote: >> On Wed, Mar 22, 2017 at 12:31:13AM +0800, fu@linaro.org wrote: >>> From: Fu Wei >>> >>> Currently, the counter frequency detection call(arch_timer_detect_rate) >>> includes getting the frequency from the device-tree property, the per-cpu >>> arch-timer and the memory-mapped (MMIO) timer interfaces. >>> But reading device-tree property will be needed only when system boot with >>> device-tree, and reading from the per-cpu arch-timer and the memory-mapped >>> (MMIO) timer interfaces will be needed only when the system initializes >>> the relevant timer. >>> >>> This patch separates out device-tree code, keep them in device-tree init >>> function, and removes arch_timer_detect_rate founction, then uses the >>> arch_timer_get_cntfrq and arch_timer_mem_get_cntfrq directly. >>> >>> Signed-off-by: Fu Wei >>> --- >>> drivers/clocksource/arm_arch_timer.c | 58 >>> +++- >>> 1 file changed, 30 insertions(+), 28 deletions(-) >>> >>> diff --git a/drivers/clocksource/arm_arch_timer.c >>> b/drivers/clocksource/arm_arch_timer.c >>> index 843f923..29ca7d6 100644 >>> --- a/drivers/clocksource/arm_arch_timer.c >>> +++ b/drivers/clocksource/arm_arch_timer.c >>> @@ -560,30 +560,6 @@ static u32 arch_timer_mem_get_cntfrq(void __iomem >>> *cntbase) >>> return readl_relaxed(cntbase + CNTFRQ); >>> } >>> >>> -static void >>> -arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) >>> -{ >>> - /* Who has more than one independent system counter? */ >>> - if (arch_timer_rate) >>> - return; >>> - >>> - /* >>> - * Try to determine the frequency from the device tree or CNTFRQ, >>> - * if ACPI is enabled, get the frequency from CNTFRQ ONLY. >>> - */ >>> - if (!acpi_disabled || >>> - of_property_read_u32(np, "clock-frequency", _timer_rate)) { >>> - if (cntbase) >>> - arch_timer_rate = arch_timer_mem_get_cntfrq(cntbase); >>> - else >>> - arch_timer_rate = arch_timer_get_cntfrq(); >>> - } >>> - >>> - /* Check the timer frequency. */ >>> - if (arch_timer_rate == 0) >>> - pr_warn("frequency not available\n"); >>> -} >>> - >>> static void arch_timer_banner(unsigned type) >>> { >>> pr_info("%s%s%s timer(s) running at %lu.%02luMHz (%s%s%s).\n", >>> @@ -958,7 +934,17 @@ static int __init arch_timer_of_init(struct >>> device_node *np) >>> for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; >>> i++) >>> arch_timer_ppi[i] = irq_of_parse_and_map(np, i); >>> >>> - arch_timer_detect_rate(NULL, np); >>> + /* >>> + * Try to determine the frequency from the device tree, >>> + * if fail, get the frequency from the sysreg CNTFRQ. >>> + */ >>> + if (!arch_timer_rate && >> >> This variable is set only if "arm,armv7-timer" and "arm,armv7-timer-mem" are >> declared together in the DT, right ? >> >> Two declarations for a single variable ? Ignore the !arch_timer_rate. > > In this function, we try to initialize per-CPU arm arch_timer by DT. > this "!arch_timer_rate" is for testing that if we have got system > counter frequency from the memory-mapped timer. If so, we just skip > getting the frequency from DT or sysreg cntfrq again. > This variable is set only if "arm,armv7-timer-mem" is initialized > earlier than "arm,armv7-timer", in another word, maybe the node of > "arm,armv7-timer-mem" is declared earlier than "arm,armv7-timer-mem" > one in DT. > > we do this check is for keeping the same init logic as before in the > DT, try to avoid any possibility of breaking devices which boot by > DT. > >> >>> + of_property_read_u32(np, "clock-frequency", _timer_rate)) >>> + arch_timer_rate = arch_timer_get_cntfrq(); >>> + if (!arch_timer_rate) { >>> + pr_err(FW_BUG "frequency not available.\n"); >>> + return -EINVAL; >>> + } >> >> Please, clarify this block, the conditions are unclear. > > this "!arch_timer_rate" is for verifying that if the system counter > frequency we just got from DT or sysreg cntfrq is valid(non-zero). > > So here, you can see I check arch_timer_rate twice, but they are for > different cases. I think about this several times, For this block, it is a little unclear, so I think this will be better: + /* + * Try to determine the frequency: + * If we have got it in arch_timer_mem_of_init, we don't need to get it again, skip. + * Otherwise, try to get the frequency from the device tree, + * if fail, try to get it from the sysreg CNTFRQ. + * Last, verify the arch_timer_rate before leaving this block. + */ + if (!arch_timer_rate) { + if (of_property_read_u32(np, "clock-frequency", _timer_rate)) + arch_timer_rate =
Re: [PATCH] Revert "net: stmmac: enable multiple buffers"
Did you even test all 3 of Thierry's patches? I want you to do that before we revert.
Re: [PATCH] Revert "net: stmmac: enable multiple buffers"
Did you even test all 3 of Thierry's patches? I want you to do that before we revert.
[PATCH] staging: iio: Use devm functions
Use managed resource functions devm_request_irq instead of request_irq. Remove corresponding calls to free_irq in the probe. Signed-off-by: Arushi Singhal--- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 4e0b4eedb53d..42473d095911 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -211,8 +211,9 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) if (ret) goto out; - ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr, - 0, st->trig->name, st); + ret = devm_request_irq(>dev, + st->irq, iio_bfin_tmr_trigger_isr, + 0, st->trig->name, st); if (ret) { dev_err(>dev, "request IRQ-%d failed", st->irq); @@ -256,7 +257,6 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) return 0; out_free_irq: - free_irq(st->irq, st); out1: iio_trigger_unregister(st->trig); out: @@ -271,7 +271,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev) disable_gptimers(st->t->bit); if (st->output_enable) peripheral_free(st->t->pin); - free_irq(st->irq, st); iio_trigger_unregister(st->trig); iio_trigger_free(st->trig); -- 2.11.0
[PATCH] staging: iio: Use devm functions
Use managed resource functions devm_request_irq instead of request_irq. Remove corresponding calls to free_irq in the probe. Signed-off-by: Arushi Singhal --- drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 4e0b4eedb53d..42473d095911 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -211,8 +211,9 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) if (ret) goto out; - ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr, - 0, st->trig->name, st); + ret = devm_request_irq(>dev, + st->irq, iio_bfin_tmr_trigger_isr, + 0, st->trig->name, st); if (ret) { dev_err(>dev, "request IRQ-%d failed", st->irq); @@ -256,7 +257,6 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) return 0; out_free_irq: - free_irq(st->irq, st); out1: iio_trigger_unregister(st->trig); out: @@ -271,7 +271,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev) disable_gptimers(st->t->bit); if (st->output_enable) peripheral_free(st->t->pin); - free_irq(st->irq, st); iio_trigger_unregister(st->trig); iio_trigger_free(st->trig); -- 2.11.0
[PATCH] Revert "net: stmmac: enable multiple buffers"
The commit aff3d9eff843 ("net: stmmac: enable multiple buffers") breaks numerous boards. while some patch exists for fixing some of it, dwmac-sunxi is still broken with it. Since this patch is very huge, it will be better to split it in smaller part. Signed-off-by: Corentin Labbe--- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 45 +- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 46 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 49 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1306 +++-- 4 files changed, 473 insertions(+), 973 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 37881f8..01a8c02 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -26,15 +26,12 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) { - struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p; + struct stmmac_priv *priv = (struct stmmac_priv *)p; + unsigned int entry = priv->cur_tx; + struct dma_desc *desc = priv->dma_tx + entry; unsigned int nopaged_len = skb_headlen(skb); - struct stmmac_priv *priv = tx_q->priv_data; - unsigned int entry = tx_q->cur_tx; unsigned int bmax, des2; unsigned int i = 1, len; - struct dma_desc *desc; - - desc = tx_q->dma_tx + entry; if (priv->plat->enh_desc) bmax = BUF_SIZE_8KiB; @@ -48,16 +45,16 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = bmax; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = bmax; /* do not close the descriptor and do not set own bit */ priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE, 0, false); while (len != 0) { - tx_q->tx_skbuff[entry] = NULL; + priv->tx_skbuff[entry] = NULL; entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); - desc = tx_q->dma_tx + entry; + desc = priv->dma_tx + entry; if (len > bmax) { des2 = dma_map_single(priv->device, @@ -66,8 +63,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = bmax; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, STMMAC_CHAIN_MODE, 1, false); @@ -80,8 +77,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = len; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = len; /* last descriptor can be set now */ priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, STMMAC_CHAIN_MODE, 1, @@ -90,7 +87,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) } } - tx_q->cur_tx = entry; + priv->cur_tx = entry; return entry; } @@ -139,34 +136,32 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr, static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p) { - struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr; - struct stmmac_priv *priv = rx_q->priv_data; + struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; if (priv->hwts_rx_en && !priv->extend_desc) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy + - (((rx_q->dirty_rx) + 1) % + p->des3 =
[PATCH] Revert "net: stmmac: enable multiple buffers"
The commit aff3d9eff843 ("net: stmmac: enable multiple buffers") breaks numerous boards. while some patch exists for fixing some of it, dwmac-sunxi is still broken with it. Since this patch is very huge, it will be better to split it in smaller part. Signed-off-by: Corentin Labbe --- drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 45 +- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 46 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 49 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1306 +++-- 4 files changed, 473 insertions(+), 973 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 37881f8..01a8c02 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -26,15 +26,12 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) { - struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p; + struct stmmac_priv *priv = (struct stmmac_priv *)p; + unsigned int entry = priv->cur_tx; + struct dma_desc *desc = priv->dma_tx + entry; unsigned int nopaged_len = skb_headlen(skb); - struct stmmac_priv *priv = tx_q->priv_data; - unsigned int entry = tx_q->cur_tx; unsigned int bmax, des2; unsigned int i = 1, len; - struct dma_desc *desc; - - desc = tx_q->dma_tx + entry; if (priv->plat->enh_desc) bmax = BUF_SIZE_8KiB; @@ -48,16 +45,16 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = bmax; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = bmax; /* do not close the descriptor and do not set own bit */ priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE, 0, false); while (len != 0) { - tx_q->tx_skbuff[entry] = NULL; + priv->tx_skbuff[entry] = NULL; entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); - desc = tx_q->dma_tx + entry; + desc = priv->dma_tx + entry; if (len > bmax) { des2 = dma_map_single(priv->device, @@ -66,8 +63,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = bmax; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, STMMAC_CHAIN_MODE, 1, false); @@ -80,8 +77,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - tx_q->tx_skbuff_dma[entry].buf = des2; - tx_q->tx_skbuff_dma[entry].len = len; + priv->tx_skbuff_dma[entry].buf = des2; + priv->tx_skbuff_dma[entry].len = len; /* last descriptor can be set now */ priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, STMMAC_CHAIN_MODE, 1, @@ -90,7 +87,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) } } - tx_q->cur_tx = entry; + priv->cur_tx = entry; return entry; } @@ -139,34 +136,32 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr, static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p) { - struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr; - struct stmmac_priv *priv = rx_q->priv_data; + struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; if (priv->hwts_rx_en && !priv->extend_desc) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy + - (((rx_q->dirty_rx) + 1) % + p->des3 = cpu_to_le32((unsigned int)(priv->dma_rx_phy
RE: [PATCH v2 07/11] ARM: at91: pm: Tie the memory controller type to the ramc id
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 07/11] ARM: at91: pm: Tie the memory controller type to the > ramc id > > Instead of relying on the SoC type to select the memory controller type, use > the > device tree ids as they are parsed anyway. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 30 -- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 488549bc2bed..ddf62a006635 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -329,11 +329,23 @@ static void at91sam9_sdram_standby(void) > at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1); } > > +struct ramc_info { > + void (*idle)(void); > + unsigned int memctrl; > +}; > + > +static const struct ramc_info ramc_infos[] __initconst = { > + { .idle = at91rm9200_standby, .memctrl = AT91_MEMCTRL_MC}, > + { .idle = at91sam9_sdram_standby, .memctrl = > AT91_MEMCTRL_SDRAMC}, > + { .idle = at91_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR}, > + { .idle = sama5d3_ddr_standby, .memctrl = > AT91_MEMCTRL_DDRSDR}, }; > + > static const struct of_device_id const ramc_ids[] __initconst = { > - { .compatible = "atmel,at91rm9200-sdramc", .data = > at91rm9200_standby }, > - { .compatible = "atmel,at91sam9260-sdramc", .data = > at91sam9_sdram_standby }, > - { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby }, > - { .compatible = "atmel,sama5d3-ddramc", .data = sama5d3_ddr_standby }, > + { .compatible = "atmel,at91rm9200-sdramc", .data = _infos[0] }, > + { .compatible = "atmel,at91sam9260-sdramc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9g45-ddramc", .data = _infos[2] }, > + { .compatible = "atmel,sama5d3-ddramc", .data = _infos[3] }, > { /*sentinel*/ } > }; > > @@ -343,14 +355,17 @@ static __init void at91_dt_ramc(void) > const struct of_device_id *of_id; > int idx = 0; > const void *standby = NULL; > + const struct ramc_info *ramc; > > for_each_matching_node_and_match(np, ramc_ids, _id) { > pm_data.ramc[idx] = of_iomap(np, 0); > if (!pm_data.ramc[idx]) > panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), > idx); > > + ramc = of_id->data; > if (!standby) > - standby = of_id->data; > + standby = ramc->idle; > + pm_data.memctrl = ramc->memctrl; > > idx++; > } > @@ -473,7 +488,6 @@ void __init at91rm9200_pm_init(void) > at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0); > > pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_MC; > > at91_pm_init(at91rm9200_idle); > } > @@ -481,7 +495,6 @@ void __init at91rm9200_pm_init(void) void __init > at91sam9260_pm_init(void) { > at91_dt_ramc(); > - pm_data.memctrl = AT91_MEMCTRL_SDRAMC; > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > @@ -490,7 +503,6 @@ void __init at91sam9g45_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(at91sam9_idle); > } > > @@ -498,7 +510,6 @@ void __init at91sam9x5_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(at91sam9_idle); > } > > @@ -506,6 +517,5 @@ void __init sama5_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(NULL); > } > -- > 2.11.0 Best Regards, Wenyou Yang
RE: [PATCH v2 07/11] ARM: at91: pm: Tie the memory controller type to the ramc id
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 07/11] ARM: at91: pm: Tie the memory controller type to the > ramc id > > Instead of relying on the SoC type to select the memory controller type, use > the > device tree ids as they are parsed anyway. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 30 -- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 488549bc2bed..ddf62a006635 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -329,11 +329,23 @@ static void at91sam9_sdram_standby(void) > at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1); } > > +struct ramc_info { > + void (*idle)(void); > + unsigned int memctrl; > +}; > + > +static const struct ramc_info ramc_infos[] __initconst = { > + { .idle = at91rm9200_standby, .memctrl = AT91_MEMCTRL_MC}, > + { .idle = at91sam9_sdram_standby, .memctrl = > AT91_MEMCTRL_SDRAMC}, > + { .idle = at91_ddr_standby, .memctrl = AT91_MEMCTRL_DDRSDR}, > + { .idle = sama5d3_ddr_standby, .memctrl = > AT91_MEMCTRL_DDRSDR}, }; > + > static const struct of_device_id const ramc_ids[] __initconst = { > - { .compatible = "atmel,at91rm9200-sdramc", .data = > at91rm9200_standby }, > - { .compatible = "atmel,at91sam9260-sdramc", .data = > at91sam9_sdram_standby }, > - { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby }, > - { .compatible = "atmel,sama5d3-ddramc", .data = sama5d3_ddr_standby }, > + { .compatible = "atmel,at91rm9200-sdramc", .data = _infos[0] }, > + { .compatible = "atmel,at91sam9260-sdramc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9g45-ddramc", .data = _infos[2] }, > + { .compatible = "atmel,sama5d3-ddramc", .data = _infos[3] }, > { /*sentinel*/ } > }; > > @@ -343,14 +355,17 @@ static __init void at91_dt_ramc(void) > const struct of_device_id *of_id; > int idx = 0; > const void *standby = NULL; > + const struct ramc_info *ramc; > > for_each_matching_node_and_match(np, ramc_ids, _id) { > pm_data.ramc[idx] = of_iomap(np, 0); > if (!pm_data.ramc[idx]) > panic(pr_fmt("unable to map ramc[%d] cpu registers\n"), > idx); > > + ramc = of_id->data; > if (!standby) > - standby = of_id->data; > + standby = ramc->idle; > + pm_data.memctrl = ramc->memctrl; > > idx++; > } > @@ -473,7 +488,6 @@ void __init at91rm9200_pm_init(void) > at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0); > > pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_MC; > > at91_pm_init(at91rm9200_idle); > } > @@ -481,7 +495,6 @@ void __init at91rm9200_pm_init(void) void __init > at91sam9260_pm_init(void) { > at91_dt_ramc(); > - pm_data.memctrl = AT91_MEMCTRL_SDRAMC; > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > @@ -490,7 +503,6 @@ void __init at91sam9g45_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(at91sam9_idle); > } > > @@ -498,7 +510,6 @@ void __init at91sam9x5_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(at91sam9_idle); > } > > @@ -506,6 +517,5 @@ void __init sama5_pm_init(void) { > at91_dt_ramc(); > pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > - pm_data.memctrl = AT91_MEMCTRL_DDRSDR; > at91_pm_init(NULL); > } > -- > 2.11.0 Best Regards, Wenyou Yang
[RFC PATCH tip/master V3 8/8] kprobes/x86: Consolidate insn decoder users for copying code
Consolidate x86 instruction decoder users on the path of copying original code for kprobes. Kprobes decodes same instruction 3 times in maximum when preparing instruction buffer. The first time for getting the length of instruction, the 2nd for adjusting displacement, and the 3rd for checking whether the instruction is boostable or not. For each time, actually decoding target address is slightly different (1st is original address or recovered instruction buffer, 2nd and 3rd are copied buffer), but basically those must have same instruction. Thus, this patch also changes the target address to copied buffer at first and reuses the decoded "insn" for displacement adjusting and checking boostable. Signed-off-by: Masami Hiramatsu--- Changes in v2: - Fix several build errors. --- arch/x86/kernel/kprobes/common.h |4 +- arch/x86/kernel/kprobes/core.c | 66 ++ arch/x86/kernel/kprobes/opt.c|5 ++- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h index d688826..db2182d 100644 --- a/arch/x86/kernel/kprobes/common.h +++ b/arch/x86/kernel/kprobes/common.h @@ -67,7 +67,7 @@ #endif /* Ensure if the instruction can be boostable */ -extern int can_boost(kprobe_opcode_t *instruction, void *addr); +extern int can_boost(struct insn *insn, void *orig_addr); /* Recover instruction if given address is probed */ extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr); @@ -75,7 +75,7 @@ extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf, * Copy an instruction and adjust the displacement if the instruction * uses the %rip-relative addressing mode. */ -extern int __copy_instruction(u8 *dest, u8 *src); +extern int __copy_instruction(u8 *dest, u8 *src, struct insn *insn); /* Generate a relative-jump/call instruction */ extern void synthesize_reljump(void *from, void *to); diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 722f544..19e1f2a 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -164,33 +164,29 @@ static kprobe_opcode_t *skip_prefixes(kprobe_opcode_t *insn) NOKPROBE_SYMBOL(skip_prefixes); /* - * Returns non-zero if opcode is boostable. + * Returns non-zero if INSN is boostable. * RIP relative instructions are adjusted at copying time in 64 bits mode */ -int can_boost(kprobe_opcode_t *opcodes, void *addr) +int can_boost(struct insn *insn, void *addr) { - struct insn insn; kprobe_opcode_t opcode; if (search_exception_tables((unsigned long)addr)) return 0; /* Page fault may occur on this address. */ - kernel_insn_init(, (void *)opcodes, MAX_INSN_SIZE); - insn_get_opcode(); - /* 2nd-byte opcode */ - if (insn.opcode.nbytes == 2) - return test_bit(insn.opcode.bytes[1], + if (insn->opcode.nbytes == 2) + return test_bit(insn->opcode.bytes[1], (unsigned long *)twobyte_is_boostable); - if (insn.opcode.nbytes != 1) + if (insn->opcode.nbytes != 1) return 0; /* Can't boost Address-size override prefix */ - if (unlikely(inat_is_address_size_prefix(insn.attr))) + if (unlikely(inat_is_address_size_prefix(insn->attr))) return 0; - opcode = insn.opcode.bytes[0]; + opcode = insn->opcode.bytes[0]; switch (opcode & 0xf0) { case 0x60: @@ -351,35 +347,31 @@ static int is_IF_modifier(kprobe_opcode_t *insn) * addressing mode. * This returns the length of copied instruction, or 0 if it has an error. */ -int __copy_instruction(u8 *dest, u8 *src) +int __copy_instruction(u8 *dest, u8 *src, struct insn *insn) { - struct insn insn; kprobe_opcode_t buf[MAX_INSN_SIZE]; - int length; unsigned long recovered_insn = recover_probed_instruction(buf, (unsigned long)src); - if (!recovered_insn) + if (!recovered_insn || !insn) return 0; - kernel_insn_init(, (void *)recovered_insn, MAX_INSN_SIZE); - insn_get_length(); - length = insn.length; - /* Another subsystem puts a breakpoint, failed to recover */ - if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) + /* This can access kernel text if given address is not recovered */ + if (probe_kernel_read(dest, (void *)recovered_insn, MAX_INSN_SIZE)) return 0; - /* This can access kernel text if given address is not recovered */ - if (kernel_probe_read(dest, insn.kaddr, length)) + kernel_insn_init(insn, dest, MAX_INSN_SIZE); + insn_get_length(insn); + + /* Another subsystem puts a breakpoint, failed to recover */ + if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
[RFC PATCH tip/master V3 8/8] kprobes/x86: Consolidate insn decoder users for copying code
Consolidate x86 instruction decoder users on the path of copying original code for kprobes. Kprobes decodes same instruction 3 times in maximum when preparing instruction buffer. The first time for getting the length of instruction, the 2nd for adjusting displacement, and the 3rd for checking whether the instruction is boostable or not. For each time, actually decoding target address is slightly different (1st is original address or recovered instruction buffer, 2nd and 3rd are copied buffer), but basically those must have same instruction. Thus, this patch also changes the target address to copied buffer at first and reuses the decoded "insn" for displacement adjusting and checking boostable. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix several build errors. --- arch/x86/kernel/kprobes/common.h |4 +- arch/x86/kernel/kprobes/core.c | 66 ++ arch/x86/kernel/kprobes/opt.c|5 ++- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/arch/x86/kernel/kprobes/common.h b/arch/x86/kernel/kprobes/common.h index d688826..db2182d 100644 --- a/arch/x86/kernel/kprobes/common.h +++ b/arch/x86/kernel/kprobes/common.h @@ -67,7 +67,7 @@ #endif /* Ensure if the instruction can be boostable */ -extern int can_boost(kprobe_opcode_t *instruction, void *addr); +extern int can_boost(struct insn *insn, void *orig_addr); /* Recover instruction if given address is probed */ extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr); @@ -75,7 +75,7 @@ extern unsigned long recover_probed_instruction(kprobe_opcode_t *buf, * Copy an instruction and adjust the displacement if the instruction * uses the %rip-relative addressing mode. */ -extern int __copy_instruction(u8 *dest, u8 *src); +extern int __copy_instruction(u8 *dest, u8 *src, struct insn *insn); /* Generate a relative-jump/call instruction */ extern void synthesize_reljump(void *from, void *to); diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 722f544..19e1f2a 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -164,33 +164,29 @@ static kprobe_opcode_t *skip_prefixes(kprobe_opcode_t *insn) NOKPROBE_SYMBOL(skip_prefixes); /* - * Returns non-zero if opcode is boostable. + * Returns non-zero if INSN is boostable. * RIP relative instructions are adjusted at copying time in 64 bits mode */ -int can_boost(kprobe_opcode_t *opcodes, void *addr) +int can_boost(struct insn *insn, void *addr) { - struct insn insn; kprobe_opcode_t opcode; if (search_exception_tables((unsigned long)addr)) return 0; /* Page fault may occur on this address. */ - kernel_insn_init(, (void *)opcodes, MAX_INSN_SIZE); - insn_get_opcode(); - /* 2nd-byte opcode */ - if (insn.opcode.nbytes == 2) - return test_bit(insn.opcode.bytes[1], + if (insn->opcode.nbytes == 2) + return test_bit(insn->opcode.bytes[1], (unsigned long *)twobyte_is_boostable); - if (insn.opcode.nbytes != 1) + if (insn->opcode.nbytes != 1) return 0; /* Can't boost Address-size override prefix */ - if (unlikely(inat_is_address_size_prefix(insn.attr))) + if (unlikely(inat_is_address_size_prefix(insn->attr))) return 0; - opcode = insn.opcode.bytes[0]; + opcode = insn->opcode.bytes[0]; switch (opcode & 0xf0) { case 0x60: @@ -351,35 +347,31 @@ static int is_IF_modifier(kprobe_opcode_t *insn) * addressing mode. * This returns the length of copied instruction, or 0 if it has an error. */ -int __copy_instruction(u8 *dest, u8 *src) +int __copy_instruction(u8 *dest, u8 *src, struct insn *insn) { - struct insn insn; kprobe_opcode_t buf[MAX_INSN_SIZE]; - int length; unsigned long recovered_insn = recover_probed_instruction(buf, (unsigned long)src); - if (!recovered_insn) + if (!recovered_insn || !insn) return 0; - kernel_insn_init(, (void *)recovered_insn, MAX_INSN_SIZE); - insn_get_length(); - length = insn.length; - /* Another subsystem puts a breakpoint, failed to recover */ - if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) + /* This can access kernel text if given address is not recovered */ + if (probe_kernel_read(dest, (void *)recovered_insn, MAX_INSN_SIZE)) return 0; - /* This can access kernel text if given address is not recovered */ - if (kernel_probe_read(dest, insn.kaddr, length)) + kernel_insn_init(insn, dest, MAX_INSN_SIZE); + insn_get_length(insn); + + /* Another subsystem puts a breakpoint, failed to recover */ + if (insn->opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
Re: [PATCH net-next] net: dsa: fix copyright holder
From: Vivien DidelotDate: Tue, 28 Mar 2017 15:10:36 -0400 > I do not hold the copyright of the DSA core and drivers source files, > since these changes have been written as an initiative of my day job. > Fix this. > > Signed-off-by: Vivien Didelot Applied.
Re: [PATCH net-next] net: dsa: fix copyright holder
From: Vivien Didelot Date: Tue, 28 Mar 2017 15:10:36 -0400 > I do not hold the copyright of the DSA core and drivers source files, > since these changes have been written as an initiative of my day job. > Fix this. > > Signed-off-by: Vivien Didelot Applied.
Re: [PATCH net-next] net: dsa: mv88e6xxx: unconditionally set ATU trunk
From: Vivien DidelotDate: Tue, 28 Mar 2017 15:09:43 -0400 > Set the trunk member of the mv88e6xxx_atu_entry structure regardless its > value, so that uninitialized structures gets the correct boolean value. > > Note that no mainline code is affected by the current behavior. > > Signed-off-by: Vivien Didelot Applied.
[RFC PATCH tip/master V3 7/8] kprobes/x86: Use probe_kernel_read instead of memcpy
Use probe_kernel_read() for avoiding unexpected faults while copying kernel text in __recover_probed_insn(), __recover_optprobed_insn() and __copy_instruction(). Signed-off-by: Masami Hiramatsu--- Note that this is just an update patch which I had been sent to LKML last month ( https://lkml.org/lkml/2017/2/27/294 ) --- arch/x86/kernel/kprobes/core.c | 12 +--- arch/x86/kernel/kprobes/opt.c |5 - 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 0dc24e6..722f544 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -259,7 +259,10 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) * Fortunately, we know that the original code is the ideal 5-byte * long NOP. */ - memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); + if (probe_kernel_read(buf, (void *)addr, + MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) + return 0UL; + if (faddr) memcpy(buf, ideal_nops[NOP_ATOMIC5], 5); else @@ -271,7 +274,7 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) * Recover the probed instruction at addr for further analysis. * Caller must lock kprobes by kprobe_mutex, or disable preemption * for preventing to release referencing kprobes. - * Returns zero if the instruction can not get recovered. + * Returns zero if the instruction can not get recovered (or access failed). */ unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr) { @@ -365,7 +368,10 @@ int __copy_instruction(u8 *dest, u8 *src) /* Another subsystem puts a breakpoint, failed to recover */ if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; - memcpy(dest, insn.kaddr, length); + + /* This can access kernel text if given address is not recovered */ + if (kernel_probe_read(dest, insn.kaddr, length)) + return 0; #ifdef CONFIG_X86_64 /* Only x86_64 has RIP relative instructions */ diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index b121037..5b52334 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -65,7 +65,10 @@ unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr) * overwritten by jump destination address. In this case, original * bytes must be recovered from op->optinsn.copied_insn buffer. */ - memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); + if (probe_kernel_read(buf, (void *)addr, + MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) + return 0UL; + if (addr == (unsigned long)kp->addr) { buf[0] = kp->opcode; memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
Re: [PATCH net-next] net: dsa: mv88e6xxx: unconditionally set ATU trunk
From: Vivien Didelot Date: Tue, 28 Mar 2017 15:09:43 -0400 > Set the trunk member of the mv88e6xxx_atu_entry structure regardless its > value, so that uninitialized structures gets the correct boolean value. > > Note that no mainline code is affected by the current behavior. > > Signed-off-by: Vivien Didelot Applied.
[RFC PATCH tip/master V3 7/8] kprobes/x86: Use probe_kernel_read instead of memcpy
Use probe_kernel_read() for avoiding unexpected faults while copying kernel text in __recover_probed_insn(), __recover_optprobed_insn() and __copy_instruction(). Signed-off-by: Masami Hiramatsu --- Note that this is just an update patch which I had been sent to LKML last month ( https://lkml.org/lkml/2017/2/27/294 ) --- arch/x86/kernel/kprobes/core.c | 12 +--- arch/x86/kernel/kprobes/opt.c |5 - 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 0dc24e6..722f544 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -259,7 +259,10 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) * Fortunately, we know that the original code is the ideal 5-byte * long NOP. */ - memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); + if (probe_kernel_read(buf, (void *)addr, + MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) + return 0UL; + if (faddr) memcpy(buf, ideal_nops[NOP_ATOMIC5], 5); else @@ -271,7 +274,7 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) * Recover the probed instruction at addr for further analysis. * Caller must lock kprobes by kprobe_mutex, or disable preemption * for preventing to release referencing kprobes. - * Returns zero if the instruction can not get recovered. + * Returns zero if the instruction can not get recovered (or access failed). */ unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr) { @@ -365,7 +368,10 @@ int __copy_instruction(u8 *dest, u8 *src) /* Another subsystem puts a breakpoint, failed to recover */ if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION) return 0; - memcpy(dest, insn.kaddr, length); + + /* This can access kernel text if given address is not recovered */ + if (kernel_probe_read(dest, insn.kaddr, length)) + return 0; #ifdef CONFIG_X86_64 /* Only x86_64 has RIP relative instructions */ diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index b121037..5b52334 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -65,7 +65,10 @@ unsigned long __recover_optprobed_insn(kprobe_opcode_t *buf, unsigned long addr) * overwritten by jump destination address. In this case, original * bytes must be recovered from op->optinsn.copied_insn buffer. */ - memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); + if (probe_kernel_read(buf, (void *)addr, + MAX_INSN_SIZE * sizeof(kprobe_opcode_t))) + return 0UL; + if (addr == (unsigned long)kp->addr) { buf[0] = kp->opcode; memcpy(buf + 1, op->optinsn.copied_insn, RELATIVE_ADDR_SIZE);
[RFC PATCH tip/master V3 6/8] kprobes/x86: Set kprobes pages readonly
Set the pages which is used for kprobes' singlestep buffer and optprobe's trampoline instruction buffer to readonly. This can prevent unexpected (or unintended) instruction modification. This also passes rodata_test as below. Without this patch, rodata_test shows a warning: [ 10.041310] [ cut here ] [ 10.041717] WARNING: CPU: 0 PID: 1 at arch/x86/mm/dump_pagetables.c:235 note_page+0x7a9/0xa20 [ 10.042469] x86/mm: Found insecure W+X mapping at address a000/0xa000 [ 10.043073] Modules linked in: [ 10.043317] CPU: 0 PID: 1 Comm: swapper/0 Tainted: GB 4.11.0-rc1-00282-gc4bf2f7 #6 [ 10.043935] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014 [ 10.044721] Call Trace: [ 10.044898] dump_stack+0x63/0x8d [ 10.045131] __warn+0x107/0x130 [ 10.045352] warn_slowpath_fmt+0x92/0xb0 [ 10.045623] ? __warn+0x130/0x130 [ 10.045856] ? 0xa000 [ 10.046104] ? 0xa000 [ 10.046337] note_page+0x7a9/0xa20 [ 10.046577] ptdump_walk_pgd_level_core+0x511/0x540 [ 10.046914] ? note_page+0xa20/0xa20 [ 10.047163] ? do_raw_spin_unlock+0x92/0x120 [ 10.047458] ? 0xa000 [ 10.047691] ? 0x8100 [ 10.047924] ptdump_walk_pgd_level_checkwx+0x12/0x20 [ 10.048266] mark_rodata_ro+0x10e/0x120 [ 10.048533] ? rest_init+0xe0/0xe0 [ 10.048771] kernel_init+0x2a/0x120 [ 10.049016] ? rest_init+0xe0/0xe0 [ 10.049254] ret_from_fork+0x2c/0x40 [ 10.049503] ---[ end trace 1e4cda1ee3314caa ]--- [ 10.049861] x86/mm: Checked W+X mappings: FAILED, 2 W+X pages found. [ 10.050349] rodata_test: all tests were successful With this fix, no W+X pages found: [ 10.130919] x86/mm: Checked W+X mappings: passed, no W+X pages found. [ 10.131624] rodata_test: all tests were successful Signed-off-by: Masami HiramatsuReported-by: Andrey Ryabinin --- arch/x86/kernel/kprobes/core.c |4 arch/x86/kernel/kprobes/opt.c |3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 3f084a0..0dc24e6 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -419,6 +419,8 @@ static int arch_copy_kprobe(struct kprobe *p) { int len; + set_memory_rw((unsigned long)p->ainsn.insn & PAGE_MASK, 1); + /* Copy an instruction with recovering if other optprobe modifies it.*/ len = __copy_instruction(p->ainsn.insn, p->addr); if (!len) @@ -430,6 +432,8 @@ static int arch_copy_kprobe(struct kprobe *p) */ prepare_boost(p, len); + set_memory_ro((unsigned long)p->ainsn.insn & PAGE_MASK, 1); + /* Check whether the instruction modifies Interrupt Flag or not */ p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn); diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 3e7c6e5..b121037 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -350,6 +350,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, } buf = (u8 *)op->optinsn.insn; + set_memory_rw((unsigned long)buf & PAGE_MASK, 1); /* Copy instructions into the out-of-line buffer */ ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr); @@ -372,6 +373,8 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size, (u8 *)op->kp.addr + op->optinsn.size); + set_memory_ro((unsigned long)buf & PAGE_MASK, 1); + flush_icache_range((unsigned long) buf, (unsigned long) buf + TMPL_END_IDX + op->optinsn.size + RELATIVEJUMP_SIZE);
[RFC PATCH tip/master V3 6/8] kprobes/x86: Set kprobes pages readonly
Set the pages which is used for kprobes' singlestep buffer and optprobe's trampoline instruction buffer to readonly. This can prevent unexpected (or unintended) instruction modification. This also passes rodata_test as below. Without this patch, rodata_test shows a warning: [ 10.041310] [ cut here ] [ 10.041717] WARNING: CPU: 0 PID: 1 at arch/x86/mm/dump_pagetables.c:235 note_page+0x7a9/0xa20 [ 10.042469] x86/mm: Found insecure W+X mapping at address a000/0xa000 [ 10.043073] Modules linked in: [ 10.043317] CPU: 0 PID: 1 Comm: swapper/0 Tainted: GB 4.11.0-rc1-00282-gc4bf2f7 #6 [ 10.043935] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.1-0-g8891697-prebuilt.qemu-project.org 04/01/2014 [ 10.044721] Call Trace: [ 10.044898] dump_stack+0x63/0x8d [ 10.045131] __warn+0x107/0x130 [ 10.045352] warn_slowpath_fmt+0x92/0xb0 [ 10.045623] ? __warn+0x130/0x130 [ 10.045856] ? 0xa000 [ 10.046104] ? 0xa000 [ 10.046337] note_page+0x7a9/0xa20 [ 10.046577] ptdump_walk_pgd_level_core+0x511/0x540 [ 10.046914] ? note_page+0xa20/0xa20 [ 10.047163] ? do_raw_spin_unlock+0x92/0x120 [ 10.047458] ? 0xa000 [ 10.047691] ? 0x8100 [ 10.047924] ptdump_walk_pgd_level_checkwx+0x12/0x20 [ 10.048266] mark_rodata_ro+0x10e/0x120 [ 10.048533] ? rest_init+0xe0/0xe0 [ 10.048771] kernel_init+0x2a/0x120 [ 10.049016] ? rest_init+0xe0/0xe0 [ 10.049254] ret_from_fork+0x2c/0x40 [ 10.049503] ---[ end trace 1e4cda1ee3314caa ]--- [ 10.049861] x86/mm: Checked W+X mappings: FAILED, 2 W+X pages found. [ 10.050349] rodata_test: all tests were successful With this fix, no W+X pages found: [ 10.130919] x86/mm: Checked W+X mappings: passed, no W+X pages found. [ 10.131624] rodata_test: all tests were successful Signed-off-by: Masami Hiramatsu Reported-by: Andrey Ryabinin --- arch/x86/kernel/kprobes/core.c |4 arch/x86/kernel/kprobes/opt.c |3 +++ 2 files changed, 7 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 3f084a0..0dc24e6 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -419,6 +419,8 @@ static int arch_copy_kprobe(struct kprobe *p) { int len; + set_memory_rw((unsigned long)p->ainsn.insn & PAGE_MASK, 1); + /* Copy an instruction with recovering if other optprobe modifies it.*/ len = __copy_instruction(p->ainsn.insn, p->addr); if (!len) @@ -430,6 +432,8 @@ static int arch_copy_kprobe(struct kprobe *p) */ prepare_boost(p, len); + set_memory_ro((unsigned long)p->ainsn.insn & PAGE_MASK, 1); + /* Check whether the instruction modifies Interrupt Flag or not */ p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn); diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 3e7c6e5..b121037 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c @@ -350,6 +350,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, } buf = (u8 *)op->optinsn.insn; + set_memory_rw((unsigned long)buf & PAGE_MASK, 1); /* Copy instructions into the out-of-line buffer */ ret = copy_optimized_instructions(buf + TMPL_END_IDX, op->kp.addr); @@ -372,6 +373,8 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size, (u8 *)op->kp.addr + op->optinsn.size); + set_memory_ro((unsigned long)buf & PAGE_MASK, 1); + flush_icache_range((unsigned long) buf, (unsigned long) buf + TMPL_END_IDX + op->optinsn.size + RELATIVEJUMP_SIZE);
RE: [PATCH v2 06/11] ARM: at91: pm: Workaround DDRSDRC self-refresh bug with LPDDR1 memories.
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 06/11] ARM: at91: pm: Workaround DDRSDRC self-refresh > bug with LPDDR1 memories. > > As already explained for pm_suspend.S, the DDRSDR controller fails to put > LPDDR1 memories in self-refresh. Force the controller to think it has DDR2 > memories during the self-refresh period, as the DDR2 self-refresh spec is > equivalent to LPDDR1, and is correctly implemented in the controller. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 20 +++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 3d68d93c11c7..488549bc2bed 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -241,12 +241,27 @@ static void at91_ddr_standby(void) > /* Those two values allow us to delay self-refresh activation >* to the maximum. */ > u32 lpr0, lpr1 = 0; > + u32 mdr, saved_mdr0, saved_mdr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > + /* LPDDR1 --> force DDR2 mode during self-refresh */ > + saved_mdr0 = at91_ramc_read(0, AT91_DDRSDRC_MDR); > + if ((saved_mdr0 & AT91_DDRSDRC_MD) == > AT91_DDRSDRC_MD_LOW_POWER_DDR) { > + mdr = saved_mdr0 & ~AT91_DDRSDRC_MD; > + mdr |= AT91_DDRSDRC_MD_DDR2; > + at91_ramc_write(0, AT91_DDRSDRC_MDR, mdr); > + } > + > if (pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); > lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; > lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; > + saved_mdr1 = at91_ramc_read(1, AT91_DDRSDRC_MDR); > + if ((saved_mdr1 & AT91_DDRSDRC_MD) == > AT91_DDRSDRC_MD_LOW_POWER_DDR) { > + mdr = saved_mdr1 & ~AT91_DDRSDRC_MD; > + mdr |= AT91_DDRSDRC_MD_DDR2; > + at91_ramc_write(1, AT91_DDRSDRC_MDR, mdr); > + } > } > > saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR); @@ -260,9 > +275,12 @@ static void at91_ddr_standby(void) > > cpu_do_idle(); > > + at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr0); > at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); > - if (pm_data.ramc[1]) > + if (pm_data.ramc[1]) { > + at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr1); > at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); > + } > } > > static void sama5d3_ddr_standby(void) > -- > 2.11.0
RE: [PATCH v2 06/11] ARM: at91: pm: Workaround DDRSDRC self-refresh bug with LPDDR1 memories.
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 06/11] ARM: at91: pm: Workaround DDRSDRC self-refresh > bug with LPDDR1 memories. > > As already explained for pm_suspend.S, the DDRSDR controller fails to put > LPDDR1 memories in self-refresh. Force the controller to think it has DDR2 > memories during the self-refresh period, as the DDR2 self-refresh spec is > equivalent to LPDDR1, and is correctly implemented in the controller. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 20 +++- > 1 file changed, 19 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 3d68d93c11c7..488549bc2bed 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -241,12 +241,27 @@ static void at91_ddr_standby(void) > /* Those two values allow us to delay self-refresh activation >* to the maximum. */ > u32 lpr0, lpr1 = 0; > + u32 mdr, saved_mdr0, saved_mdr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > + /* LPDDR1 --> force DDR2 mode during self-refresh */ > + saved_mdr0 = at91_ramc_read(0, AT91_DDRSDRC_MDR); > + if ((saved_mdr0 & AT91_DDRSDRC_MD) == > AT91_DDRSDRC_MD_LOW_POWER_DDR) { > + mdr = saved_mdr0 & ~AT91_DDRSDRC_MD; > + mdr |= AT91_DDRSDRC_MD_DDR2; > + at91_ramc_write(0, AT91_DDRSDRC_MDR, mdr); > + } > + > if (pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); > lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; > lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; > + saved_mdr1 = at91_ramc_read(1, AT91_DDRSDRC_MDR); > + if ((saved_mdr1 & AT91_DDRSDRC_MD) == > AT91_DDRSDRC_MD_LOW_POWER_DDR) { > + mdr = saved_mdr1 & ~AT91_DDRSDRC_MD; > + mdr |= AT91_DDRSDRC_MD_DDR2; > + at91_ramc_write(1, AT91_DDRSDRC_MDR, mdr); > + } > } > > saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR); @@ -260,9 > +275,12 @@ static void at91_ddr_standby(void) > > cpu_do_idle(); > > + at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr0); > at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); > - if (pm_data.ramc[1]) > + if (pm_data.ramc[1]) { > + at91_ramc_write(0, AT91_DDRSDRC_MDR, saved_mdr1); > at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); > + } > } > > static void sama5d3_ddr_standby(void) > -- > 2.11.0
[RFC PATCH tip/master V3 5/8] kprobes/x86: Make boostable flag boolean
Make arch_specific_insn.boostable to boolean, since it has only 2 states, boostable or not. So it is better to use boolean from the viewpoint of code readability. Signed-off-by: Masami Hiramatsu--- arch/x86/include/asm/kprobes.h |7 +++ arch/x86/kernel/kprobes/core.c | 12 ++-- arch/x86/kernel/kprobes/ftrace.c |2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h index 2005816..34b984c 100644 --- a/arch/x86/include/asm/kprobes.h +++ b/arch/x86/include/asm/kprobes.h @@ -72,14 +72,13 @@ struct arch_specific_insn { /* copy of the original instruction */ kprobe_opcode_t *insn; /* -* boostable = -1: This instruction type is not boostable. -* boostable = 0: This instruction type is boostable. -* boostable = 1: This instruction has been boosted: we have +* boostable = false: This instruction type is not boostable. +* boostable = true: This instruction has been boosted: we have * added a relative jump after the instruction copy in insn, * so no single-step and fixup are needed (unless there's * a post_handler or break_handler). */ - int boostable; + bool boostable; bool if_modifier; }; diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index a654054..3f084a0 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -409,9 +409,9 @@ static void prepare_boost(struct kprobe *p, int length) * jumps back to correct address. */ synthesize_reljump(p->ainsn.insn + length, p->addr + length); - p->ainsn.boostable = 1; + p->ainsn.boostable = true; } else { - p->ainsn.boostable = -1; + p->ainsn.boostable = false; } } @@ -467,7 +467,7 @@ void arch_disarm_kprobe(struct kprobe *p) void arch_remove_kprobe(struct kprobe *p) { if (p->ainsn.insn) { - free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1)); + free_insn_slot(p->ainsn.insn, p->ainsn.boostable); p->ainsn.insn = NULL; } } @@ -539,7 +539,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs, return; #if !defined(CONFIG_PREEMPT) - if (p->ainsn.boostable == 1 && !p->post_handler) { + if (p->ainsn.boostable && !p->post_handler) { /* Boost up -- we can execute copied instructions directly */ if (!reenter) reset_current_kprobe(); @@ -859,7 +859,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, case 0xcf: case 0xea: /* jmp absolute -- ip is correct */ /* ip is already adjusted, no more changes required */ - p->ainsn.boostable = 1; + p->ainsn.boostable = true; goto no_change; case 0xe8: /* call relative - Fix return addr */ *tos = orig_ip + (*tos - copy_ip); @@ -884,7 +884,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, * jmp near and far, absolute indirect * ip is correct. And this is boostable */ - p->ainsn.boostable = 1; + p->ainsn.boostable = true; goto no_change; } default: diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c index 5f8f0b3..041f7b6 100644 --- a/arch/x86/kernel/kprobes/ftrace.c +++ b/arch/x86/kernel/kprobes/ftrace.c @@ -94,6 +94,6 @@ NOKPROBE_SYMBOL(kprobe_ftrace_handler); int arch_prepare_kprobe_ftrace(struct kprobe *p) { p->ainsn.insn = NULL; - p->ainsn.boostable = -1; + p->ainsn.boostable = false; return 0; }
RE: [PATCH v2 04/11] ARM: at91: pm: Use struct at91_pm_data in pm_suspend.S
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 04/11] ARM: at91: pm: Use struct at91_pm_data in > pm_suspend.S > > The number of register we can safely pass to at91_pm_suspend_in_sram is > limited. Instead, pass the address to the at91_pm_data structure. > > The offsets are automatically generated to avoid hardcoding them. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/Makefile | 33 +++ > arch/arm/mach-at91/pm.c | 78 > +++- > arch/arm/mach-at91/pm.h | 16 +--- > arch/arm/mach-at91/pm_data-offsets.c | 13 ++ > arch/arm/mach-at91/pm_suspend.S | 29 ++ > 5 files changed, 102 insertions(+), 67 deletions(-) create mode 100644 > arch/arm/mach-at91/pm_data-offsets.c > > diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index > c5bbf8bb8c0f..858ef14f961c 100644 > --- a/arch/arm/mach-at91/Makefile > +++ b/arch/arm/mach-at91/Makefile > @@ -18,3 +18,36 @@ endif > ifeq ($(CONFIG_PM_DEBUG),y) > CFLAGS_pm.o += -DDEBUG > endif > + > +# Default sed regexp - multiline due to syntax constraints define sed-y > + "/^->/{s:->#\(.*\):/* \1 */:; \ > + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ > + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ > + s:->::; p;}" > +endef > + > +# Use filechk to avoid rebuilds when a header changes, but the > +resulting file # does not define filechk_offsets > + (set -e; \ > + echo "#ifndef $2"; \ > + echo "#define $2"; \ > + echo "/*"; \ > + echo " * DO NOT MODIFY."; \ > + echo " *"; \ > + echo " * This file was generated by Kbuild"; \ > + echo " */"; \ > + echo ""; \ > + sed -ne $(sed-y); \ > + echo ""; \ > + echo "#endif" ) > +endef > + > +arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c > + $(call if_changed_dep,cc_s_c) > + > +include/generated/at91_pm_data-offsets.h: arch/arm/mach-at91/pm_data- > offsets.s FORCE > + $(call filechk,offsets,__PM_DATA_OFFSETS_H__) > + > +arch/arm/mach-at91/pm_suspend.o: > +include/generated/at91_pm_data-offsets.h > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > c780dda3b604..a35b1541b328 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -37,18 +37,13 @@ extern void at91_pinctrl_gpio_suspend(void); extern void > at91_pinctrl_gpio_resume(void); #endif > > -static struct { > - void __iomem *pmc; > - void __iomem *ramc[2]; > - unsigned long uhp_udp_mask; > - int memctrl; > -} at91_pm_data; > +static struct at91_pm_data pm_data; > > #define at91_ramc_read(id, field) \ > - __raw_readl(at91_pm_data.ramc[id] + field) > + __raw_readl(pm_data.ramc[id] + field) > > #define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_pm_data.ramc[id] + field) > + __raw_writel(value, pm_data.ramc[id] + field) > > static int at91_pm_valid_state(suspend_state_t state) { @@ -84,10 +79,10 @@ > static int at91_pm_verify_clocks(void) > unsigned long scsr; > int i; > > - scsr = readl(at91_pm_data.pmc + AT91_PMC_SCSR); > + scsr = readl(pm_data.pmc + AT91_PMC_SCSR); > > /* USB must not be using PLLB */ > - if ((scsr & at91_pm_data.uhp_udp_mask) != 0) { > + if ((scsr & pm_data.uhp_udp_mask) != 0) { > pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); > return 0; > } > @@ -98,7 +93,7 @@ static int at91_pm_verify_clocks(void) > > if ((scsr & (AT91_PMC_PCK0 << i)) == 0) > continue; > - css = readl(at91_pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > + css = readl(pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > if (css != AT91_PMC_CSS_SLOW) { > pr_err("AT91: PM - Suspend-to-RAM with PCK%d > src %d\n", i, css); > return 0; > @@ -124,25 +119,18 @@ int at91_suspend_entering_slow_clock(void) > } > EXPORT_SYMBOL(at91_suspend_entering_slow_clock); > > -static void (*at91_suspend_sram_fn)(void __iomem *pmc, void __iomem *ramc0, > - void __iomem *ramc1, int memctrl); > - > -extern void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem > *ramc0, > - void __iomem *ramc1, int memctrl); > +static void (*at91_suspend_sram_fn)(struct at91_pm_data *); extern void >
[RFC PATCH tip/master V3 5/8] kprobes/x86: Make boostable flag boolean
Make arch_specific_insn.boostable to boolean, since it has only 2 states, boostable or not. So it is better to use boolean from the viewpoint of code readability. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/kprobes.h |7 +++ arch/x86/kernel/kprobes/core.c | 12 ++-- arch/x86/kernel/kprobes/ftrace.c |2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h index 2005816..34b984c 100644 --- a/arch/x86/include/asm/kprobes.h +++ b/arch/x86/include/asm/kprobes.h @@ -72,14 +72,13 @@ struct arch_specific_insn { /* copy of the original instruction */ kprobe_opcode_t *insn; /* -* boostable = -1: This instruction type is not boostable. -* boostable = 0: This instruction type is boostable. -* boostable = 1: This instruction has been boosted: we have +* boostable = false: This instruction type is not boostable. +* boostable = true: This instruction has been boosted: we have * added a relative jump after the instruction copy in insn, * so no single-step and fixup are needed (unless there's * a post_handler or break_handler). */ - int boostable; + bool boostable; bool if_modifier; }; diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index a654054..3f084a0 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -409,9 +409,9 @@ static void prepare_boost(struct kprobe *p, int length) * jumps back to correct address. */ synthesize_reljump(p->ainsn.insn + length, p->addr + length); - p->ainsn.boostable = 1; + p->ainsn.boostable = true; } else { - p->ainsn.boostable = -1; + p->ainsn.boostable = false; } } @@ -467,7 +467,7 @@ void arch_disarm_kprobe(struct kprobe *p) void arch_remove_kprobe(struct kprobe *p) { if (p->ainsn.insn) { - free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1)); + free_insn_slot(p->ainsn.insn, p->ainsn.boostable); p->ainsn.insn = NULL; } } @@ -539,7 +539,7 @@ static void setup_singlestep(struct kprobe *p, struct pt_regs *regs, return; #if !defined(CONFIG_PREEMPT) - if (p->ainsn.boostable == 1 && !p->post_handler) { + if (p->ainsn.boostable && !p->post_handler) { /* Boost up -- we can execute copied instructions directly */ if (!reenter) reset_current_kprobe(); @@ -859,7 +859,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, case 0xcf: case 0xea: /* jmp absolute -- ip is correct */ /* ip is already adjusted, no more changes required */ - p->ainsn.boostable = 1; + p->ainsn.boostable = true; goto no_change; case 0xe8: /* call relative - Fix return addr */ *tos = orig_ip + (*tos - copy_ip); @@ -884,7 +884,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, * jmp near and far, absolute indirect * ip is correct. And this is boostable */ - p->ainsn.boostable = 1; + p->ainsn.boostable = true; goto no_change; } default: diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c index 5f8f0b3..041f7b6 100644 --- a/arch/x86/kernel/kprobes/ftrace.c +++ b/arch/x86/kernel/kprobes/ftrace.c @@ -94,6 +94,6 @@ NOKPROBE_SYMBOL(kprobe_ftrace_handler); int arch_prepare_kprobe_ftrace(struct kprobe *p) { p->ainsn.insn = NULL; - p->ainsn.boostable = -1; + p->ainsn.boostable = false; return 0; }
RE: [PATCH v2 04/11] ARM: at91: pm: Use struct at91_pm_data in pm_suspend.S
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 04/11] ARM: at91: pm: Use struct at91_pm_data in > pm_suspend.S > > The number of register we can safely pass to at91_pm_suspend_in_sram is > limited. Instead, pass the address to the at91_pm_data structure. > > The offsets are automatically generated to avoid hardcoding them. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/Makefile | 33 +++ > arch/arm/mach-at91/pm.c | 78 > +++- > arch/arm/mach-at91/pm.h | 16 +--- > arch/arm/mach-at91/pm_data-offsets.c | 13 ++ > arch/arm/mach-at91/pm_suspend.S | 29 ++ > 5 files changed, 102 insertions(+), 67 deletions(-) create mode 100644 > arch/arm/mach-at91/pm_data-offsets.c > > diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile index > c5bbf8bb8c0f..858ef14f961c 100644 > --- a/arch/arm/mach-at91/Makefile > +++ b/arch/arm/mach-at91/Makefile > @@ -18,3 +18,36 @@ endif > ifeq ($(CONFIG_PM_DEBUG),y) > CFLAGS_pm.o += -DDEBUG > endif > + > +# Default sed regexp - multiline due to syntax constraints define sed-y > + "/^->/{s:->#\(.*\):/* \1 */:; \ > + s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ > + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ > + s:->::; p;}" > +endef > + > +# Use filechk to avoid rebuilds when a header changes, but the > +resulting file # does not define filechk_offsets > + (set -e; \ > + echo "#ifndef $2"; \ > + echo "#define $2"; \ > + echo "/*"; \ > + echo " * DO NOT MODIFY."; \ > + echo " *"; \ > + echo " * This file was generated by Kbuild"; \ > + echo " */"; \ > + echo ""; \ > + sed -ne $(sed-y); \ > + echo ""; \ > + echo "#endif" ) > +endef > + > +arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c > + $(call if_changed_dep,cc_s_c) > + > +include/generated/at91_pm_data-offsets.h: arch/arm/mach-at91/pm_data- > offsets.s FORCE > + $(call filechk,offsets,__PM_DATA_OFFSETS_H__) > + > +arch/arm/mach-at91/pm_suspend.o: > +include/generated/at91_pm_data-offsets.h > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > c780dda3b604..a35b1541b328 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -37,18 +37,13 @@ extern void at91_pinctrl_gpio_suspend(void); extern void > at91_pinctrl_gpio_resume(void); #endif > > -static struct { > - void __iomem *pmc; > - void __iomem *ramc[2]; > - unsigned long uhp_udp_mask; > - int memctrl; > -} at91_pm_data; > +static struct at91_pm_data pm_data; > > #define at91_ramc_read(id, field) \ > - __raw_readl(at91_pm_data.ramc[id] + field) > + __raw_readl(pm_data.ramc[id] + field) > > #define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_pm_data.ramc[id] + field) > + __raw_writel(value, pm_data.ramc[id] + field) > > static int at91_pm_valid_state(suspend_state_t state) { @@ -84,10 +79,10 @@ > static int at91_pm_verify_clocks(void) > unsigned long scsr; > int i; > > - scsr = readl(at91_pm_data.pmc + AT91_PMC_SCSR); > + scsr = readl(pm_data.pmc + AT91_PMC_SCSR); > > /* USB must not be using PLLB */ > - if ((scsr & at91_pm_data.uhp_udp_mask) != 0) { > + if ((scsr & pm_data.uhp_udp_mask) != 0) { > pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); > return 0; > } > @@ -98,7 +93,7 @@ static int at91_pm_verify_clocks(void) > > if ((scsr & (AT91_PMC_PCK0 << i)) == 0) > continue; > - css = readl(at91_pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > + css = readl(pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > if (css != AT91_PMC_CSS_SLOW) { > pr_err("AT91: PM - Suspend-to-RAM with PCK%d > src %d\n", i, css); > return 0; > @@ -124,25 +119,18 @@ int at91_suspend_entering_slow_clock(void) > } > EXPORT_SYMBOL(at91_suspend_entering_slow_clock); > > -static void (*at91_suspend_sram_fn)(void __iomem *pmc, void __iomem *ramc0, > - void __iomem *ramc1, int memctrl); > - > -extern void at91_pm_suspend_in_sram(void __iomem *pmc, void __iomem > *ramc0, > - void __iomem *ramc1, int memctrl); > +static void (*at91_suspend_sram_fn)(struct at91_pm_data *); extern void > +at91_pm_suspend_in_sram(struct at91_pm_data *pm_data); > extern u32 at91_pm_suspend_in_sram_sz; > > static void at91_pm_suspend(suspend_state_t state) { > - unsigned int
[RFC PATCH tip/master V3 4/8] kprobes/x86: Do not modify singlestep buffer while resuming
Do not modify singlestep execution buffer (kprobe.ainsn.insn) while resuming from single-stepping, instead, modifies the buffer to add a jump back instruction at preparing buffer. Signed-off-by: Masami Hiramatsu--- Changes in v3: - Fix imbalance curly braces. - Remove unneeded (void *) casting. --- arch/x86/kernel/kprobes/core.c | 42 +++- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 6327f95..a654054 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -399,23 +399,36 @@ int __copy_instruction(u8 *dest, u8 *src) return length; } +/* Prepare reljump right after instruction to boost */ +static void prepare_boost(struct kprobe *p, int length) +{ + if (can_boost(p->ainsn.insn, p->addr) && + MAX_INSN_SIZE - length >= RELATIVEJUMP_SIZE) { + /* +* These instructions can be executed directly if it +* jumps back to correct address. +*/ + synthesize_reljump(p->ainsn.insn + length, p->addr + length); + p->ainsn.boostable = 1; + } else { + p->ainsn.boostable = -1; + } +} + static int arch_copy_kprobe(struct kprobe *p) { - int ret; + int len; /* Copy an instruction with recovering if other optprobe modifies it.*/ - ret = __copy_instruction(p->ainsn.insn, p->addr); - if (!ret) + len = __copy_instruction(p->ainsn.insn, p->addr); + if (!len) return -EINVAL; /* * __copy_instruction can modify the displacement of the instruction, * but it doesn't affect boostable check. */ - if (can_boost(p->ainsn.insn, p->addr)) - p->ainsn.boostable = 0; - else - p->ainsn.boostable = -1; + prepare_boost(p, len); /* Check whether the instruction modifies Interrupt Flag or not */ p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn); @@ -878,21 +891,6 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, break; } - if (p->ainsn.boostable == 0) { - if ((regs->ip > copy_ip) && - (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) { - /* -* These instructions can be executed directly if it -* jumps back to correct address. -*/ - synthesize_reljump((void *)regs->ip, - (void *)orig_ip + (regs->ip - copy_ip)); - p->ainsn.boostable = 1; - } else { - p->ainsn.boostable = -1; - } - } - regs->ip += orig_ip - copy_ip; no_change:
[RFC PATCH tip/master V3 4/8] kprobes/x86: Do not modify singlestep buffer while resuming
Do not modify singlestep execution buffer (kprobe.ainsn.insn) while resuming from single-stepping, instead, modifies the buffer to add a jump back instruction at preparing buffer. Signed-off-by: Masami Hiramatsu --- Changes in v3: - Fix imbalance curly braces. - Remove unneeded (void *) casting. --- arch/x86/kernel/kprobes/core.c | 42 +++- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 6327f95..a654054 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -399,23 +399,36 @@ int __copy_instruction(u8 *dest, u8 *src) return length; } +/* Prepare reljump right after instruction to boost */ +static void prepare_boost(struct kprobe *p, int length) +{ + if (can_boost(p->ainsn.insn, p->addr) && + MAX_INSN_SIZE - length >= RELATIVEJUMP_SIZE) { + /* +* These instructions can be executed directly if it +* jumps back to correct address. +*/ + synthesize_reljump(p->ainsn.insn + length, p->addr + length); + p->ainsn.boostable = 1; + } else { + p->ainsn.boostable = -1; + } +} + static int arch_copy_kprobe(struct kprobe *p) { - int ret; + int len; /* Copy an instruction with recovering if other optprobe modifies it.*/ - ret = __copy_instruction(p->ainsn.insn, p->addr); - if (!ret) + len = __copy_instruction(p->ainsn.insn, p->addr); + if (!len) return -EINVAL; /* * __copy_instruction can modify the displacement of the instruction, * but it doesn't affect boostable check. */ - if (can_boost(p->ainsn.insn, p->addr)) - p->ainsn.boostable = 0; - else - p->ainsn.boostable = -1; + prepare_boost(p, len); /* Check whether the instruction modifies Interrupt Flag or not */ p->ainsn.if_modifier = is_IF_modifier(p->ainsn.insn); @@ -878,21 +891,6 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, break; } - if (p->ainsn.boostable == 0) { - if ((regs->ip > copy_ip) && - (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) { - /* -* These instructions can be executed directly if it -* jumps back to correct address. -*/ - synthesize_reljump((void *)regs->ip, - (void *)orig_ip + (regs->ip - copy_ip)); - p->ainsn.boostable = 1; - } else { - p->ainsn.boostable = -1; - } - } - regs->ip += orig_ip - copy_ip; no_change:
[RFC PATCH tip/master V3 3/8] kprobes/x86: Use instruction decoder for booster
Use x86 instruction decoder for checking whether the probed instruction is able to boost or not, instead of hand-written code. Signed-off-by: Masami Hiramatsu--- arch/x86/kernel/kprobes/core.c | 39 --- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 81d4dc7..6327f95 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -169,35 +169,33 @@ NOKPROBE_SYMBOL(skip_prefixes); */ int can_boost(kprobe_opcode_t *opcodes, void *addr) { + struct insn insn; kprobe_opcode_t opcode; - kprobe_opcode_t *orig_opcodes = opcodes; if (search_exception_tables((unsigned long)addr)) return 0; /* Page fault may occur on this address. */ -retry: - if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) - return 0; - opcode = *(opcodes++); + kernel_insn_init(, (void *)opcodes, MAX_INSN_SIZE); + insn_get_opcode(); /* 2nd-byte opcode */ - if (opcode == 0x0f) { - if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) - return 0; - return test_bit(*opcodes, + if (insn.opcode.nbytes == 2) + return test_bit(insn.opcode.bytes[1], (unsigned long *)twobyte_is_boostable); - } + + if (insn.opcode.nbytes != 1) + return 0; + + /* Can't boost Address-size override prefix */ + if (unlikely(inat_is_address_size_prefix(insn.attr))) + return 0; + + opcode = insn.opcode.bytes[0]; switch (opcode & 0xf0) { -#ifdef CONFIG_X86_64 - case 0x40: - goto retry; /* REX prefix is boostable */ -#endif case 0x60: - if (0x63 < opcode && opcode < 0x67) - goto retry; /* prefixes */ - /* can't boost Address-size override and bound */ - return (opcode != 0x62 && opcode != 0x67); + /* can't boost "bound" */ + return (opcode != 0x62); case 0x70: return 0; /* can't boost conditional jump */ case 0x90: @@ -212,14 +210,9 @@ int can_boost(kprobe_opcode_t *opcodes, void *addr) /* can boost in/out and absolute jmps */ return ((opcode & 0x04) || opcode == 0xea); case 0xf0: - if ((opcode & 0x0c) == 0 && opcode != 0xf1) - goto retry; /* lock/rep(ne) prefix */ /* clear and set flags are boostable */ return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe)); default: - /* segment override prefixes are boostable */ - if (opcode == 0x26 || opcode == 0x36 || opcode == 0x3e) - goto retry; /* prefixes */ /* CS override prefix and call are not boostable */ return (opcode != 0x2e && opcode != 0x9a); }
[RFC PATCH tip/master V3 3/8] kprobes/x86: Use instruction decoder for booster
Use x86 instruction decoder for checking whether the probed instruction is able to boost or not, instead of hand-written code. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/kprobes/core.c | 39 --- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 81d4dc7..6327f95 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -169,35 +169,33 @@ NOKPROBE_SYMBOL(skip_prefixes); */ int can_boost(kprobe_opcode_t *opcodes, void *addr) { + struct insn insn; kprobe_opcode_t opcode; - kprobe_opcode_t *orig_opcodes = opcodes; if (search_exception_tables((unsigned long)addr)) return 0; /* Page fault may occur on this address. */ -retry: - if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) - return 0; - opcode = *(opcodes++); + kernel_insn_init(, (void *)opcodes, MAX_INSN_SIZE); + insn_get_opcode(); /* 2nd-byte opcode */ - if (opcode == 0x0f) { - if (opcodes - orig_opcodes > MAX_INSN_SIZE - 1) - return 0; - return test_bit(*opcodes, + if (insn.opcode.nbytes == 2) + return test_bit(insn.opcode.bytes[1], (unsigned long *)twobyte_is_boostable); - } + + if (insn.opcode.nbytes != 1) + return 0; + + /* Can't boost Address-size override prefix */ + if (unlikely(inat_is_address_size_prefix(insn.attr))) + return 0; + + opcode = insn.opcode.bytes[0]; switch (opcode & 0xf0) { -#ifdef CONFIG_X86_64 - case 0x40: - goto retry; /* REX prefix is boostable */ -#endif case 0x60: - if (0x63 < opcode && opcode < 0x67) - goto retry; /* prefixes */ - /* can't boost Address-size override and bound */ - return (opcode != 0x62 && opcode != 0x67); + /* can't boost "bound" */ + return (opcode != 0x62); case 0x70: return 0; /* can't boost conditional jump */ case 0x90: @@ -212,14 +210,9 @@ int can_boost(kprobe_opcode_t *opcodes, void *addr) /* can boost in/out and absolute jmps */ return ((opcode & 0x04) || opcode == 0xea); case 0xf0: - if ((opcode & 0x0c) == 0 && opcode != 0xf1) - goto retry; /* lock/rep(ne) prefix */ /* clear and set flags are boostable */ return (opcode == 0xf5 || (0xf7 < opcode && opcode < 0xfe)); default: - /* segment override prefixes are boostable */ - if (opcode == 0x26 || opcode == 0x36 || opcode == 0x3e) - goto retry; /* prefixes */ /* CS override prefix and call are not boostable */ return (opcode != 0x2e && opcode != 0x9a); }
[RFC PATCH tip/master V3 2/8] kprobes/x86: Fix the description of __copy_instruction()
Fix the description comment of __copy_instruction() function since it has already been changed to return the length of copied instruction. Signed-off-by: Masami Hiramatsu--- arch/x86/kernel/kprobes/core.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 9eae5a6..81d4dc7 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -350,11 +350,10 @@ static int is_IF_modifier(kprobe_opcode_t *insn) } /* - * Copy an instruction and adjust the displacement if the instruction - * uses the %rip-relative addressing mode. - * If it does, Return the address of the 32-bit displacement word. - * If not, return null. - * Only applicable to 64-bit x86. + * Copy an instruction with recovering modified instruction by kprobes + * and adjust the displacement if the instruction uses the %rip-relative + * addressing mode. + * This returns the length of copied instruction, or 0 if it has an error. */ int __copy_instruction(u8 *dest, u8 *src) { @@ -376,6 +375,7 @@ int __copy_instruction(u8 *dest, u8 *src) memcpy(dest, insn.kaddr, length); #ifdef CONFIG_X86_64 + /* Only x86_64 has RIP relative instructions */ if (insn_rip_relative()) { s64 newdisp; u8 *disp;
[RFC PATCH tip/master V3 2/8] kprobes/x86: Fix the description of __copy_instruction()
Fix the description comment of __copy_instruction() function since it has already been changed to return the length of copied instruction. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/kprobes/core.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 9eae5a6..81d4dc7 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -350,11 +350,10 @@ static int is_IF_modifier(kprobe_opcode_t *insn) } /* - * Copy an instruction and adjust the displacement if the instruction - * uses the %rip-relative addressing mode. - * If it does, Return the address of the 32-bit displacement word. - * If not, return null. - * Only applicable to 64-bit x86. + * Copy an instruction with recovering modified instruction by kprobes + * and adjust the displacement if the instruction uses the %rip-relative + * addressing mode. + * This returns the length of copied instruction, or 0 if it has an error. */ int __copy_instruction(u8 *dest, u8 *src) { @@ -376,6 +375,7 @@ int __copy_instruction(u8 *dest, u8 *src) memcpy(dest, insn.kaddr, length); #ifdef CONFIG_X86_64 + /* Only x86_64 has RIP relative instructions */ if (insn_rip_relative()) { s64 newdisp; u8 *disp;
RE: [PATCH v2 09/11] ARM: at91: pm: Merge all at91sam9*_pm_init
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 09/11] ARM: at91: pm: Merge all at91sam9*_pm_init > > The PM initialization is now identical for all at91sam9. Merge the functions. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/at91sam9.c | 45 > +++ > arch/arm/mach-at91/generic.h | 8 ++-- > arch/arm/mach-at91/pm.c | 14 +- > 3 files changed, 6 insertions(+), 61 deletions(-) > > diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c > index ba28e9cc584d..c089bfd0dc2f 100644 > --- a/arch/arm/mach-at91/at91sam9.c > +++ b/arch/arm/mach-at91/at91sam9.c > @@ -52,7 +52,7 @@ static const struct at91_soc at91sam9_socs[] = { > { /* sentinel */ }, > }; > > -static void __init at91sam9_common_init(void) > +static void __init at91sam9_init(void) > { > struct soc_device *soc; > struct device *soc_dev = NULL; > @@ -62,12 +62,8 @@ static void __init at91sam9_common_init(void) > soc_dev = soc_device_to_device(soc); > > of_platform_default_populate(NULL, NULL, soc_dev); -} > > -static void __init at91sam9_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9260_pm_init(); > + at91sam9_pm_init(); > } > > static const char *const at91_dt_board_compat[] __initconst = { @@ -77,41 > +73,6 @@ static const char *const at91_dt_board_compat[] __initconst = { > > DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM9") > /* Maintainer: Atmel */ > - .init_machine = at91sam9_dt_device_init, > + .init_machine = at91sam9_init, > .dt_compat = at91_dt_board_compat, > MACHINE_END > - > -static void __init at91sam9g45_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9g45_pm_init(); > -} > - > -static const char *const at91sam9g45_board_compat[] __initconst = { > - "atmel,at91sam9g45", > - NULL > -}; > - > -DT_MACHINE_START(at91sam9g45_dt, "Atmel AT91SAM9G45") > - /* Maintainer: Atmel */ > - .init_machine = at91sam9g45_dt_device_init, > - .dt_compat = at91sam9g45_board_compat, > -MACHINE_END > - > -static void __init at91sam9x5_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9x5_pm_init(); > -} > - > -static const char *const at91sam9x5_board_compat[] __initconst = { > - "atmel,at91sam9x5", > - "atmel,at91sam9n12", > - NULL > -}; > - > -DT_MACHINE_START(at91sam9x5_dt, "Atmel AT91SAM9") > - /* Maintainer: Atmel */ > - .init_machine = at91sam9x5_dt_device_init, > - .dt_compat = at91sam9x5_board_compat, > -MACHINE_END > diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index > 28ca57a2060f..f1ead0f13c19 100644 > --- a/arch/arm/mach-at91/generic.h > +++ b/arch/arm/mach-at91/generic.h > @@ -13,15 +13,11 @@ > > #ifdef CONFIG_PM > extern void __init at91rm9200_pm_init(void); -extern void __init > at91sam9260_pm_init(void); -extern void __init at91sam9g45_pm_init(void); - > extern void __init at91sam9x5_pm_init(void); > +extern void __init at91sam9_pm_init(void); > extern void __init sama5_pm_init(void); #else static inline void __init > at91rm9200_pm_init(void) { } -static inline void __init > at91sam9260_pm_init(void) > { } -static inline void __init at91sam9g45_pm_init(void) { } -static inline > void __init > at91sam9x5_pm_init(void) { } > +static inline void __init at91sam9_pm_init(void) { } > static inline void __init sama5_pm_init(void) { } #endif > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > a7c047f0d21f..dedfe9038336 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -505,19 +505,7 @@ void __init at91rm9200_pm_init(void) > at91_pm_init(at91rm9200_idle); > } > > -void __init at91sam9260_pm_init(void) > -{ > - at91_dt_ramc(); > - at91_pm_init(at91sam9_idle); > -} > - > -void __init at91sam9g45_pm_init(void) > -{ > - at91_dt_ramc(); > - at91_pm_init(at91sam9_idle); > -} > - > -void __init at91sam9x5_pm_init(void) > +void __init at91sam9_pm_init(void) > { > at91_dt_ramc(); > at91_pm_init(at91sam9_idle); > -- > 2.11.0 Best Regards, Wenyou Yang
RE: [PATCH v2 09/11] ARM: at91: pm: Merge all at91sam9*_pm_init
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 09/11] ARM: at91: pm: Merge all at91sam9*_pm_init > > The PM initialization is now identical for all at91sam9. Merge the functions. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/at91sam9.c | 45 > +++ > arch/arm/mach-at91/generic.h | 8 ++-- > arch/arm/mach-at91/pm.c | 14 +- > 3 files changed, 6 insertions(+), 61 deletions(-) > > diff --git a/arch/arm/mach-at91/at91sam9.c b/arch/arm/mach-at91/at91sam9.c > index ba28e9cc584d..c089bfd0dc2f 100644 > --- a/arch/arm/mach-at91/at91sam9.c > +++ b/arch/arm/mach-at91/at91sam9.c > @@ -52,7 +52,7 @@ static const struct at91_soc at91sam9_socs[] = { > { /* sentinel */ }, > }; > > -static void __init at91sam9_common_init(void) > +static void __init at91sam9_init(void) > { > struct soc_device *soc; > struct device *soc_dev = NULL; > @@ -62,12 +62,8 @@ static void __init at91sam9_common_init(void) > soc_dev = soc_device_to_device(soc); > > of_platform_default_populate(NULL, NULL, soc_dev); -} > > -static void __init at91sam9_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9260_pm_init(); > + at91sam9_pm_init(); > } > > static const char *const at91_dt_board_compat[] __initconst = { @@ -77,41 > +73,6 @@ static const char *const at91_dt_board_compat[] __initconst = { > > DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM9") > /* Maintainer: Atmel */ > - .init_machine = at91sam9_dt_device_init, > + .init_machine = at91sam9_init, > .dt_compat = at91_dt_board_compat, > MACHINE_END > - > -static void __init at91sam9g45_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9g45_pm_init(); > -} > - > -static const char *const at91sam9g45_board_compat[] __initconst = { > - "atmel,at91sam9g45", > - NULL > -}; > - > -DT_MACHINE_START(at91sam9g45_dt, "Atmel AT91SAM9G45") > - /* Maintainer: Atmel */ > - .init_machine = at91sam9g45_dt_device_init, > - .dt_compat = at91sam9g45_board_compat, > -MACHINE_END > - > -static void __init at91sam9x5_dt_device_init(void) -{ > - at91sam9_common_init(); > - at91sam9x5_pm_init(); > -} > - > -static const char *const at91sam9x5_board_compat[] __initconst = { > - "atmel,at91sam9x5", > - "atmel,at91sam9n12", > - NULL > -}; > - > -DT_MACHINE_START(at91sam9x5_dt, "Atmel AT91SAM9") > - /* Maintainer: Atmel */ > - .init_machine = at91sam9x5_dt_device_init, > - .dt_compat = at91sam9x5_board_compat, > -MACHINE_END > diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index > 28ca57a2060f..f1ead0f13c19 100644 > --- a/arch/arm/mach-at91/generic.h > +++ b/arch/arm/mach-at91/generic.h > @@ -13,15 +13,11 @@ > > #ifdef CONFIG_PM > extern void __init at91rm9200_pm_init(void); -extern void __init > at91sam9260_pm_init(void); -extern void __init at91sam9g45_pm_init(void); - > extern void __init at91sam9x5_pm_init(void); > +extern void __init at91sam9_pm_init(void); > extern void __init sama5_pm_init(void); #else static inline void __init > at91rm9200_pm_init(void) { } -static inline void __init > at91sam9260_pm_init(void) > { } -static inline void __init at91sam9g45_pm_init(void) { } -static inline > void __init > at91sam9x5_pm_init(void) { } > +static inline void __init at91sam9_pm_init(void) { } > static inline void __init sama5_pm_init(void) { } #endif > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > a7c047f0d21f..dedfe9038336 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -505,19 +505,7 @@ void __init at91rm9200_pm_init(void) > at91_pm_init(at91rm9200_idle); > } > > -void __init at91sam9260_pm_init(void) > -{ > - at91_dt_ramc(); > - at91_pm_init(at91sam9_idle); > -} > - > -void __init at91sam9g45_pm_init(void) > -{ > - at91_dt_ramc(); > - at91_pm_init(at91sam9_idle); > -} > - > -void __init at91sam9x5_pm_init(void) > +void __init at91sam9_pm_init(void) > { > at91_dt_ramc(); > at91_pm_init(at91sam9_idle); > -- > 2.11.0 Best Regards, Wenyou Yang
[RFC PATCH tip/master V3 1/8] kprobes/x86: Fix not to boost call far instruction
Fix kprobe-booster not to boost call far instruction, because call may store the address in singlestep execution buffer to the stack, which should be modified after single stepping. Currently, this instruction will be filtered as not boostable in resume_execution(), so this is not a critical issue. Signed-off-by: Masami Hiramatsu--- arch/x86/kernel/kprobes/core.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 993fa4f..9eae5a6 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -200,6 +200,8 @@ int can_boost(kprobe_opcode_t *opcodes, void *addr) return (opcode != 0x62 && opcode != 0x67); case 0x70: return 0; /* can't boost conditional jump */ + case 0x90: + return opcode != 0x9a; /* can't boost call far */ case 0xc0: /* can't boost software-interruptions */ return (0xc1 < opcode && opcode < 0xcc) || opcode == 0xcf;
[RFC PATCH tip/master V3 1/8] kprobes/x86: Fix not to boost call far instruction
Fix kprobe-booster not to boost call far instruction, because call may store the address in singlestep execution buffer to the stack, which should be modified after single stepping. Currently, this instruction will be filtered as not boostable in resume_execution(), so this is not a critical issue. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/kprobes/core.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 993fa4f..9eae5a6 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c @@ -200,6 +200,8 @@ int can_boost(kprobe_opcode_t *opcodes, void *addr) return (opcode != 0x62 && opcode != 0x67); case 0x70: return 0; /* can't boost conditional jump */ + case 0x90: + return opcode != 0x9a; /* can't boost call far */ case 0xc0: /* can't boost software-interruptions */ return (0xc1 < opcode && opcode < 0xcc) || opcode == 0xcf;
RE: [PATCH v2 08/11] ARM: at91: pm: Tie the USB clock mask to the pmc
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 08/11] ARM: at91: pm: Tie the USB clock mask to the pmc > > The USB clocks mask (uhp_udp_mask) depends on the pmc. Tie it to the pmc id > instead of the SoC. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 37 +++-- > 1 file changed, 23 insertions(+), 14 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > ddf62a006635..a7c047f0d21f 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -442,31 +442,46 @@ static void __init at91_pm_sram_init(void) > _pm_suspend_in_sram, > at91_pm_suspend_in_sram_sz); } > > +struct pmc_info { > + unsigned long uhp_udp_mask; > +}; > + > +static const struct pmc_info pmc_infos[] __initconst = { > + { .uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP }, > + { .uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP }, > + { .uhp_udp_mask = AT91SAM926x_PMC_UHP }, }; > + > static const struct of_device_id atmel_pmc_ids[] __initconst = { > - { .compatible = "atmel,at91rm9200-pmc" }, > - { .compatible = "atmel,at91sam9260-pmc" }, > - { .compatible = "atmel,at91sam9g45-pmc" }, > - { .compatible = "atmel,at91sam9n12-pmc" }, > - { .compatible = "atmel,at91sam9x5-pmc" }, > - { .compatible = "atmel,sama5d3-pmc" }, > - { .compatible = "atmel,sama5d2-pmc" }, > + { .compatible = "atmel,at91rm9200-pmc", .data = _infos[0] }, > + { .compatible = "atmel,at91sam9260-pmc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9g45-pmc", .data = _infos[2] }, > + { .compatible = "atmel,at91sam9n12-pmc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9x5-pmc", .data = _infos[1] }, > + { .compatible = "atmel,sama5d3-pmc", .data = _infos[1] }, > + { .compatible = "atmel,sama5d2-pmc", .data = _infos[1] }, > { /* sentinel */ }, > }; > > static void __init at91_pm_init(void (*pm_idle)(void)) { > struct device_node *pmc_np; > + const struct of_device_id *of_id; > + const struct pmc_info *pmc; > > if (at91_cpuidle_device.dev.platform_data) > platform_device_register(_cpuidle_device); > > - pmc_np = of_find_matching_node(NULL, atmel_pmc_ids); > + pmc_np = of_find_matching_node_and_match(NULL, atmel_pmc_ids, > _id); > pm_data.pmc = of_iomap(pmc_np, 0); > if (!pm_data.pmc) { > pr_err("AT91: PM not supported, PMC not found\n"); > return; > } > > + pmc = of_id->data; > + pm_data.uhp_udp_mask = pmc->uhp_udp_mask; > + > if (pm_idle) > arm_pm_idle = pm_idle; > > @@ -487,35 +502,29 @@ void __init at91rm9200_pm_init(void) >*/ > at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0); > > - pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP; > - > at91_pm_init(at91rm9200_idle); > } > > void __init at91sam9260_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > > void __init at91sam9g45_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; > at91_pm_init(at91sam9_idle); > } > > void __init at91sam9x5_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > > void __init sama5_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(NULL); > } > -- > 2.11.0 Best Regards, Wenyou Yang
RE: [PATCH v2 08/11] ARM: at91: pm: Tie the USB clock mask to the pmc
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 08/11] ARM: at91: pm: Tie the USB clock mask to the pmc > > The USB clocks mask (uhp_udp_mask) depends on the pmc. Tie it to the pmc id > instead of the SoC. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 37 +++-- > 1 file changed, 23 insertions(+), 14 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > ddf62a006635..a7c047f0d21f 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -442,31 +442,46 @@ static void __init at91_pm_sram_init(void) > _pm_suspend_in_sram, > at91_pm_suspend_in_sram_sz); } > > +struct pmc_info { > + unsigned long uhp_udp_mask; > +}; > + > +static const struct pmc_info pmc_infos[] __initconst = { > + { .uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP }, > + { .uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP }, > + { .uhp_udp_mask = AT91SAM926x_PMC_UHP }, }; > + > static const struct of_device_id atmel_pmc_ids[] __initconst = { > - { .compatible = "atmel,at91rm9200-pmc" }, > - { .compatible = "atmel,at91sam9260-pmc" }, > - { .compatible = "atmel,at91sam9g45-pmc" }, > - { .compatible = "atmel,at91sam9n12-pmc" }, > - { .compatible = "atmel,at91sam9x5-pmc" }, > - { .compatible = "atmel,sama5d3-pmc" }, > - { .compatible = "atmel,sama5d2-pmc" }, > + { .compatible = "atmel,at91rm9200-pmc", .data = _infos[0] }, > + { .compatible = "atmel,at91sam9260-pmc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9g45-pmc", .data = _infos[2] }, > + { .compatible = "atmel,at91sam9n12-pmc", .data = _infos[1] }, > + { .compatible = "atmel,at91sam9x5-pmc", .data = _infos[1] }, > + { .compatible = "atmel,sama5d3-pmc", .data = _infos[1] }, > + { .compatible = "atmel,sama5d2-pmc", .data = _infos[1] }, > { /* sentinel */ }, > }; > > static void __init at91_pm_init(void (*pm_idle)(void)) { > struct device_node *pmc_np; > + const struct of_device_id *of_id; > + const struct pmc_info *pmc; > > if (at91_cpuidle_device.dev.platform_data) > platform_device_register(_cpuidle_device); > > - pmc_np = of_find_matching_node(NULL, atmel_pmc_ids); > + pmc_np = of_find_matching_node_and_match(NULL, atmel_pmc_ids, > _id); > pm_data.pmc = of_iomap(pmc_np, 0); > if (!pm_data.pmc) { > pr_err("AT91: PM not supported, PMC not found\n"); > return; > } > > + pmc = of_id->data; > + pm_data.uhp_udp_mask = pmc->uhp_udp_mask; > + > if (pm_idle) > arm_pm_idle = pm_idle; > > @@ -487,35 +502,29 @@ void __init at91rm9200_pm_init(void) >*/ > at91_ramc_write(0, AT91_MC_SDRAMC_LPR, 0); > > - pm_data.uhp_udp_mask = AT91RM9200_PMC_UHP | > AT91RM9200_PMC_UDP; > - > at91_pm_init(at91rm9200_idle); > } > > void __init at91sam9260_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > > void __init at91sam9g45_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP; > at91_pm_init(at91sam9_idle); > } > > void __init at91sam9x5_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(at91sam9_idle); > } > > void __init sama5_pm_init(void) > { > at91_dt_ramc(); > - pm_data.uhp_udp_mask = AT91SAM926x_PMC_UHP | > AT91SAM926x_PMC_UDP; > at91_pm_init(NULL); > } > -- > 2.11.0 Best Regards, Wenyou Yang
[RFC PATCH tip/master V3 0/8] kprobes/x86: Make kprobes instruction buffers read-only
Hi, This is the 3rd version of the series. I just updated 4/8 according to Ingo's comment. This series tries to make kprobes instruction buffers read-only pages. Since those buffers are used for trampoline code, those are a part of "text area" and it should be marked as ro for avoiding unexpected modification. And this actually fix a warning rodata sanity check reported by lkp-robot. https://lkml.org/lkml/2017/2/27/161 This change requires changing the kprobe-booster at first because it can modify the instruction buffer to add a jump while resuming from single-stepping. Of course after we make the buffer readonly, we may not be able to modify it while probing. So, at first this series checks the current bootable instructions and fixes a missed instruction (call far), modifies can_boost to use x86 instruction decoder, and inserts "booster" jump while preparing instruction buffer instead of resuming from single-stepping. At last, it makes the buffers for kprobes and optprobe readonly. This series also has some cleanup patches related to above changes. Changes from V2: - [4/8]: Fix imbalanced curly braces and remove unneeded (void *) cast. --- Masami Hiramatsu (8): kprobes/x86: Fix not to boost call far instruction kprobes/x86: Fix the description of __copy_instruction() kprobes/x86: Use instruction decoder for booster kprobes/x86: Do not modify singlestep buffer while resuming kprobes/x86: Make boostable flag boolean kprobes/x86: Set kprobes pages readonly kprobes/x86: Use probe_kernel_read instead of memcpy kprobes/x86: Consolidate insn decoder users for copying code arch/x86/include/asm/kprobes.h |7 +- arch/x86/kernel/kprobes/common.h |4 + arch/x86/kernel/kprobes/core.c | 149 +++--- arch/x86/kernel/kprobes/ftrace.c |2 - arch/x86/kernel/kprobes/opt.c| 13 +++ 5 files changed, 90 insertions(+), 85 deletions(-) -- Masami Hiramatsu (Linaro)
[RFC PATCH tip/master V3 0/8] kprobes/x86: Make kprobes instruction buffers read-only
Hi, This is the 3rd version of the series. I just updated 4/8 according to Ingo's comment. This series tries to make kprobes instruction buffers read-only pages. Since those buffers are used for trampoline code, those are a part of "text area" and it should be marked as ro for avoiding unexpected modification. And this actually fix a warning rodata sanity check reported by lkp-robot. https://lkml.org/lkml/2017/2/27/161 This change requires changing the kprobe-booster at first because it can modify the instruction buffer to add a jump while resuming from single-stepping. Of course after we make the buffer readonly, we may not be able to modify it while probing. So, at first this series checks the current bootable instructions and fixes a missed instruction (call far), modifies can_boost to use x86 instruction decoder, and inserts "booster" jump while preparing instruction buffer instead of resuming from single-stepping. At last, it makes the buffers for kprobes and optprobe readonly. This series also has some cleanup patches related to above changes. Changes from V2: - [4/8]: Fix imbalanced curly braces and remove unneeded (void *) cast. --- Masami Hiramatsu (8): kprobes/x86: Fix not to boost call far instruction kprobes/x86: Fix the description of __copy_instruction() kprobes/x86: Use instruction decoder for booster kprobes/x86: Do not modify singlestep buffer while resuming kprobes/x86: Make boostable flag boolean kprobes/x86: Set kprobes pages readonly kprobes/x86: Use probe_kernel_read instead of memcpy kprobes/x86: Consolidate insn decoder users for copying code arch/x86/include/asm/kprobes.h |7 +- arch/x86/kernel/kprobes/common.h |4 + arch/x86/kernel/kprobes/core.c | 149 +++--- arch/x86/kernel/kprobes/ftrace.c |2 - arch/x86/kernel/kprobes/opt.c| 13 +++ 5 files changed, 90 insertions(+), 85 deletions(-) -- Masami Hiramatsu (Linaro)
Re: [PATCH net-next] net: dsa: mv88e6xxx: debug ATU Age Time
From: Vivien DidelotDate: Tue, 28 Mar 2017 14:13:53 -0400 > Hi David, > > Vivien Didelot writes: > >> The ATU ageing time value programmed in the switch is rounded up to the >> nearest multiple of its coefficient (variable depending on the model.) >> >> Add a debug message to inform the user about the exact programmed value. >> >> On 6352, "brctl setageing br0 18" gives "AgeTime set to 0x01 (15000 ms)" >> while on 6390 we get "AgeTime set to 0x05 (18750 ms)". >> >> Signed-off-by: Vivien Didelot > > Can you pick this patch? If it's not in a pending state in patchwork, there must be a reason. And that reason will tell you why I didn't apply it, and what needs to be resolved in order to change that. In any event, you have to at a minimum resubmit the patch.
Re: [PATCH net-next] net: dsa: mv88e6xxx: debug ATU Age Time
From: Vivien Didelot Date: Tue, 28 Mar 2017 14:13:53 -0400 > Hi David, > > Vivien Didelot writes: > >> The ATU ageing time value programmed in the switch is rounded up to the >> nearest multiple of its coefficient (variable depending on the model.) >> >> Add a debug message to inform the user about the exact programmed value. >> >> On 6352, "brctl setageing br0 18" gives "AgeTime set to 0x01 (15000 ms)" >> while on 6390 we get "AgeTime set to 0x05 (18750 ms)". >> >> Signed-off-by: Vivien Didelot > > Can you pick this patch? If it's not in a pending state in patchwork, there must be a reason. And that reason will tell you why I didn't apply it, and what needs to be resolved in order to change that. In any event, you have to at a minimum resubmit the patch.
Re: [PATCH net-next 0/4] net: dsa: fix chip definitions
From: Vivien DidelotDate: Tue, 28 Mar 2017 13:50:31 -0400 > The definitions of some of the mv88e6xxx_ops and mv88e6xxx_info > structures are misordered and erroneous for 88E6191 and 88E6391. > > This patch series cleans that up. Series applied.
Re: [PATCH net-next 0/4] net: dsa: fix chip definitions
From: Vivien Didelot Date: Tue, 28 Mar 2017 13:50:31 -0400 > The definitions of some of the mv88e6xxx_ops and mv88e6xxx_info > structures are misordered and erroneous for 88E6191 and 88E6391. > > This patch series cleans that up. Series applied.
RE: [PATCH v2 10/11] ARM: at91: pm: Remove at91_pm_set_standby
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 10/11] ARM: at91: pm: Remove at91_pm_set_standby > > Merge at91_pm_set_standby() in at91_dt_ramc as this is the only callsite. > That moves it to the init section. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 10 ++ > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > dedfe9038336..2cd27c830ab6 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -205,12 +205,6 @@ static struct platform_device at91_cpuidle_device = { > .name = "cpuidle-at91", > }; > > -static void at91_pm_set_standby(void (*at91_standby)(void)) -{ > - if (at91_standby) > - at91_cpuidle_device.dev.platform_data = at91_standby; > -} > - > /* > * The AT91RM9200 goes into self-refresh mode with this command, and will > * terminate self-refresh automatically on the next SDRAM access. > @@ -354,7 +348,7 @@ static __init void at91_dt_ramc(void) > struct device_node *np; > const struct of_device_id *of_id; > int idx = 0; > - const void *standby = NULL; > + void *standby = NULL; > const struct ramc_info *ramc; > > for_each_matching_node_and_match(np, ramc_ids, _id) { @@ -378,7 > +372,7 @@ static __init void at91_dt_ramc(void) > return; > } > > - at91_pm_set_standby(standby); > + at91_cpuidle_device.dev.platform_data = standby; > } > > static void at91rm9200_idle(void) > -- > 2.11.0 Best Regards, Wenyou Yang
RE: [PATCH v2 10/11] ARM: at91: pm: Remove at91_pm_set_standby
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 10/11] ARM: at91: pm: Remove at91_pm_set_standby > > Merge at91_pm_set_standby() in at91_dt_ramc as this is the only callsite. > That moves it to the init section. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 10 ++ > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > dedfe9038336..2cd27c830ab6 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -205,12 +205,6 @@ static struct platform_device at91_cpuidle_device = { > .name = "cpuidle-at91", > }; > > -static void at91_pm_set_standby(void (*at91_standby)(void)) -{ > - if (at91_standby) > - at91_cpuidle_device.dev.platform_data = at91_standby; > -} > - > /* > * The AT91RM9200 goes into self-refresh mode with this command, and will > * terminate self-refresh automatically on the next SDRAM access. > @@ -354,7 +348,7 @@ static __init void at91_dt_ramc(void) > struct device_node *np; > const struct of_device_id *of_id; > int idx = 0; > - const void *standby = NULL; > + void *standby = NULL; > const struct ramc_info *ramc; > > for_each_matching_node_and_match(np, ramc_ids, _id) { @@ -378,7 > +372,7 @@ static __init void at91_dt_ramc(void) > return; > } > > - at91_pm_set_standby(standby); > + at91_cpuidle_device.dev.platform_data = standby; > } > > static void at91rm9200_idle(void) > -- > 2.11.0 Best Regards, Wenyou Yang
RE: [PATCH v2 03/11] ARM: at91: pm: Move global variables into at91_pm_data
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 03/11] ARM: at91: pm: Move global variables into > at91_pm_data > > Instead of having separate global variables to hold IP addresses, move them to > struct at91_pm_data. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 44 +--- > 1 file changed, 21 insertions(+), 23 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 41789aa4df86..c780dda3b604 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -26,8 +26,6 @@ > #include "generic.h" > #include "pm.h" > > -static void __iomem *pmc; > - > /* > * FIXME: this is needed to communicate between the pinctrl driver and > * the PM implementation in the machine. Possibly part of the PM @@ -40,17 > +38,17 @@ extern void at91_pinctrl_gpio_resume(void); #endif > > static struct { > + void __iomem *pmc; > + void __iomem *ramc[2]; > unsigned long uhp_udp_mask; > int memctrl; > } at91_pm_data; > > -static void __iomem *at91_ramc_base[2]; #define at91_ramc_read(id, field) \ > - __raw_readl(at91_ramc_base[id] + field) > + __raw_readl(at91_pm_data.ramc[id] + field) > > #define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_ramc_base[id] + field) > - > + __raw_writel(value, at91_pm_data.ramc[id] + field) > > static int at91_pm_valid_state(suspend_state_t state) { @@ -86,7 +84,7 @@ > static int at91_pm_verify_clocks(void) > unsigned long scsr; > int i; > > - scsr = readl(pmc + AT91_PMC_SCSR); > + scsr = readl(at91_pm_data.pmc + AT91_PMC_SCSR); > > /* USB must not be using PLLB */ > if ((scsr & at91_pm_data.uhp_udp_mask) != 0) { @@ -100,7 +98,7 @@ > static int at91_pm_verify_clocks(void) > > if ((scsr & (AT91_PMC_PCK0 << i)) == 0) > continue; > - css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS; > + css = readl(at91_pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > if (css != AT91_PMC_CSS_SLOW) { > pr_err("AT91: PM - Suspend-to-RAM with PCK%d > src %d\n", i, css); > return 0; > @@ -143,8 +141,8 @@ static void at91_pm_suspend(suspend_state_t state) > flush_cache_all(); > outer_disable(); > > - at91_suspend_sram_fn(pmc, at91_ramc_base[0], > - at91_ramc_base[1], pm_data); > + at91_suspend_sram_fn(at91_pm_data.pmc, at91_pm_data.ramc[0], > + at91_pm_data.ramc[1], pm_data); > > outer_resume(); > } > @@ -247,7 +245,7 @@ static void at91rm9200_standby(void) > "mcrp15, 0, %0, c7, c0, 4\n\t" > "str%5, [%1, %2]" > : > - : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91_MC_SDRAMC_LPR), > + : "r" (0), "r" (at91_pm_data.ramc[0]), "r" > (AT91_MC_SDRAMC_LPR), > "r" (1), "r" (AT91_MC_SDRAMC_SRR), > "r" (lpr)); > } > @@ -262,7 +260,7 @@ static void at91_ddr_standby(void) > u32 lpr0, lpr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > - if (at91_ramc_base[1]) { > + if (at91_pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); > lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; > lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; @@ -274,13 > +272,13 @@ static void at91_ddr_standby(void) > > /* self-refresh mode now */ > at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); > - if (at91_ramc_base[1]) > + if (at91_pm_data.ramc[1]) > at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); > > cpu_do_idle(); > > at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); > - if (at91_ramc_base[1]) > + if (at91_pm_data.ramc[1]) > at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); } > > @@ -308,7 +306,7 @@ static void at91sam9_sdram_standby(void) > u32 lpr0, lpr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > - if (at91_ramc_base[1]) { > + if (at91_pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR); > lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB; > lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH; @@ -320,13 > +318,13 @@ static void at91sam9_sdram_standby(void) > > /* self-refresh mode now */ > at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0); > - if (at91_ramc_base[1]) > +
RE: [PATCH v2 03/11] ARM: at91: pm: Move global variables into at91_pm_data
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:20 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 03/11] ARM: at91: pm: Move global variables into > at91_pm_data > > Instead of having separate global variables to hold IP addresses, move them to > struct at91_pm_data. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 44 +--- > 1 file changed, 21 insertions(+), 23 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 41789aa4df86..c780dda3b604 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -26,8 +26,6 @@ > #include "generic.h" > #include "pm.h" > > -static void __iomem *pmc; > - > /* > * FIXME: this is needed to communicate between the pinctrl driver and > * the PM implementation in the machine. Possibly part of the PM @@ -40,17 > +38,17 @@ extern void at91_pinctrl_gpio_resume(void); #endif > > static struct { > + void __iomem *pmc; > + void __iomem *ramc[2]; > unsigned long uhp_udp_mask; > int memctrl; > } at91_pm_data; > > -static void __iomem *at91_ramc_base[2]; #define at91_ramc_read(id, field) \ > - __raw_readl(at91_ramc_base[id] + field) > + __raw_readl(at91_pm_data.ramc[id] + field) > > #define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_ramc_base[id] + field) > - > + __raw_writel(value, at91_pm_data.ramc[id] + field) > > static int at91_pm_valid_state(suspend_state_t state) { @@ -86,7 +84,7 @@ > static int at91_pm_verify_clocks(void) > unsigned long scsr; > int i; > > - scsr = readl(pmc + AT91_PMC_SCSR); > + scsr = readl(at91_pm_data.pmc + AT91_PMC_SCSR); > > /* USB must not be using PLLB */ > if ((scsr & at91_pm_data.uhp_udp_mask) != 0) { @@ -100,7 +98,7 @@ > static int at91_pm_verify_clocks(void) > > if ((scsr & (AT91_PMC_PCK0 << i)) == 0) > continue; > - css = readl(pmc + AT91_PMC_PCKR(i)) & AT91_PMC_CSS; > + css = readl(at91_pm_data.pmc + AT91_PMC_PCKR(i)) & > AT91_PMC_CSS; > if (css != AT91_PMC_CSS_SLOW) { > pr_err("AT91: PM - Suspend-to-RAM with PCK%d > src %d\n", i, css); > return 0; > @@ -143,8 +141,8 @@ static void at91_pm_suspend(suspend_state_t state) > flush_cache_all(); > outer_disable(); > > - at91_suspend_sram_fn(pmc, at91_ramc_base[0], > - at91_ramc_base[1], pm_data); > + at91_suspend_sram_fn(at91_pm_data.pmc, at91_pm_data.ramc[0], > + at91_pm_data.ramc[1], pm_data); > > outer_resume(); > } > @@ -247,7 +245,7 @@ static void at91rm9200_standby(void) > "mcrp15, 0, %0, c7, c0, 4\n\t" > "str%5, [%1, %2]" > : > - : "r" (0), "r" (at91_ramc_base[0]), "r" (AT91_MC_SDRAMC_LPR), > + : "r" (0), "r" (at91_pm_data.ramc[0]), "r" > (AT91_MC_SDRAMC_LPR), > "r" (1), "r" (AT91_MC_SDRAMC_SRR), > "r" (lpr)); > } > @@ -262,7 +260,7 @@ static void at91_ddr_standby(void) > u32 lpr0, lpr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > - if (at91_ramc_base[1]) { > + if (at91_pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); > lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; > lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH; @@ -274,13 > +272,13 @@ static void at91_ddr_standby(void) > > /* self-refresh mode now */ > at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); > - if (at91_ramc_base[1]) > + if (at91_pm_data.ramc[1]) > at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); > > cpu_do_idle(); > > at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); > - if (at91_ramc_base[1]) > + if (at91_pm_data.ramc[1]) > at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); } > > @@ -308,7 +306,7 @@ static void at91sam9_sdram_standby(void) > u32 lpr0, lpr1 = 0; > u32 saved_lpr0, saved_lpr1 = 0; > > - if (at91_ramc_base[1]) { > + if (at91_pm_data.ramc[1]) { > saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR); > lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB; > lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH; @@ -320,13 > +318,13 @@ static void at91sam9_sdram_standby(void) > > /* self-refresh mode now */ > at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0); > - if (at91_ramc_base[1]) > + if (at91_pm_data.ramc[1]) > at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1); > > cpu_do_idle(); > > at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0); > -
RE: [PATCH v2 02/11] ARM: at91: pm: Move at91_ramc_read/write to pm.c
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:19 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 02/11] ARM: at91: pm: Move at91_ramc_read/write to pm.c > > Those macros are only used in pm.c, move them there so we can remove the test > on __ASSEMBLY__. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 6 ++ > arch/arm/mach-at91/pm.h | 8 > 2 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 9e2b5c1e503e..41789aa4df86 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -45,6 +45,12 @@ static struct { > } at91_pm_data; > > static void __iomem *at91_ramc_base[2]; > +#define at91_ramc_read(id, field) \ > + __raw_readl(at91_ramc_base[id] + field) > + > +#define at91_ramc_write(id, field, value) \ > + __raw_writel(value, at91_ramc_base[id] + field) > + > > static int at91_pm_valid_state(suspend_state_t state) { diff --git > a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h index > bf980c6ef294..8eed156ef19a 100644 > --- a/arch/arm/mach-at91/pm.h > +++ b/arch/arm/mach-at91/pm.h > @@ -17,14 +17,6 @@ > #include > #include > > -#ifndef __ASSEMBLY__ > -#define at91_ramc_read(id, field) \ > - __raw_readl(at91_ramc_base[id] + field) > - > -#define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_ramc_base[id] + field) > -#endif > - > #define AT91_MEMCTRL_MC 0 > #define AT91_MEMCTRL_SDRAMC 1 > #define AT91_MEMCTRL_DDRSDR 2 > -- > 2.11.0
RE: [PATCH v2 02/11] ARM: at91: pm: Move at91_ramc_read/write to pm.c
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:19 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 02/11] ARM: at91: pm: Move at91_ramc_read/write to pm.c > > Those macros are only used in pm.c, move them there so we can remove the test > on __ASSEMBLY__. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 6 ++ > arch/arm/mach-at91/pm.h | 8 > 2 files changed, 6 insertions(+), 8 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > 9e2b5c1e503e..41789aa4df86 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -45,6 +45,12 @@ static struct { > } at91_pm_data; > > static void __iomem *at91_ramc_base[2]; > +#define at91_ramc_read(id, field) \ > + __raw_readl(at91_ramc_base[id] + field) > + > +#define at91_ramc_write(id, field, value) \ > + __raw_writel(value, at91_ramc_base[id] + field) > + > > static int at91_pm_valid_state(suspend_state_t state) { diff --git > a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h index > bf980c6ef294..8eed156ef19a 100644 > --- a/arch/arm/mach-at91/pm.h > +++ b/arch/arm/mach-at91/pm.h > @@ -17,14 +17,6 @@ > #include > #include > > -#ifndef __ASSEMBLY__ > -#define at91_ramc_read(id, field) \ > - __raw_readl(at91_ramc_base[id] + field) > - > -#define at91_ramc_write(id, field, value) \ > - __raw_writel(value, at91_ramc_base[id] + field) > -#endif > - > #define AT91_MEMCTRL_MC 0 > #define AT91_MEMCTRL_SDRAMC 1 > #define AT91_MEMCTRL_DDRSDR 2 > -- > 2.11.0
Re: [PATCH] VSOCK: remove unnecessary ternary operator on return value
From: Colin KingDate: Tue, 28 Mar 2017 16:54:24 +0100 > From: Colin Ian King > > Rather than assign the positive errno values to ret and then > checking if it is positive and flip the sign, just set ret to > be the -ve errno value. > > Detected by CoverityScan, CID#986649 ("Logically Dead Code") > > Signed-off-by: Colin Ian King Just return the error directly instead of having this variable. Thanks.
Re: [PATCH] VSOCK: remove unnecessary ternary operator on return value
From: Colin King Date: Tue, 28 Mar 2017 16:54:24 +0100 > From: Colin Ian King > > Rather than assign the positive errno values to ret and then > checking if it is positive and flip the sign, just set ret to > be the -ve errno value. > > Detected by CoverityScan, CID#986649 ("Logically Dead Code") > > Signed-off-by: Colin Ian King Just return the error directly instead of having this variable. Thanks.
RE: [PATCH v2 01/11] ARM: at91: pm: Cleanup headers
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:19 > To: Nicolas Ferre - M43238> Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 01/11] ARM: at91: pm: Cleanup headers > > Remove unnecessary header inclusions and reorder the remaining ones. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 21 + > 1 file changed, 5 insertions(+), 16 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > a277981f414d..9e2b5c1e503e 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -10,28 +10,17 @@ > * (at your option) any later version. > */ > > -#include > -#include > -#include > -#include > #include > -#include > -#include > -#include > +#include > +#include > #include > #include > -#include > -#include > -#include > -#include > +#include > + > #include > > -#include > -#include > -#include > -#include > -#include > #include > +#include > #include > > #include "generic.h" > -- > 2.11.0
RE: [PATCH v2 01/11] ARM: at91: pm: Cleanup headers
> -Original Message- > From: Alexandre Belloni [mailto:alexandre.bell...@free-electrons.com] > Sent: 2017年3月28日 19:19 > To: Nicolas Ferre - M43238 > Cc: linux-kernel@vger.kernel.org; linux-arm-ker...@lists.infradead.org; Boris > Brezillon ; Wenyou Yang - A41535 > ; Alexandre Belloni electrons.com> > Subject: [PATCH v2 01/11] ARM: at91: pm: Cleanup headers > > Remove unnecessary header inclusions and reorder the remaining ones. > > Signed-off-by: Alexandre Belloni Acked-by: Wenyou Yang > --- > arch/arm/mach-at91/pm.c | 21 + > 1 file changed, 5 insertions(+), 16 deletions(-) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index > a277981f414d..9e2b5c1e503e 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -10,28 +10,17 @@ > * (at your option) any later version. > */ > > -#include > -#include > -#include > -#include > #include > -#include > -#include > -#include > +#include > +#include > #include > #include > -#include > -#include > -#include > -#include > +#include > + > #include > > -#include > -#include > -#include > -#include > -#include > #include > +#include > #include > > #include "generic.h" > -- > 2.11.0