Re: [PATCH] percpu: improve percpu_alloc_percpu_fail event trace

2024-01-22 Thread George Guo
On Mon, 22 Jan 2024 10:57:00 -0500
Steven Rostedt  wrote:

> On Mon, 22 Jan 2024 15:36:29 +0800
> George Guo  wrote:
> 
> > From: George Guo 
> > 
> > Add do_warn, warn_limit fields to the output of the
> > percpu_alloc_percpu_fail ftrace event.
> > 
> > This is required to percpu_alloc failed with no warning showing.  
> 
> You mean to state;
> 
>   In order to know why percpu_alloc failed but produces no warnings,
> the do_warn and warn_limit should be traced to let the user know it
> was rate-limited.
> 
> Or something like that?
> 
> Honestly, I don't think that the trace event is the proper place to do
> that. The trace event just shows that it did fail. If you are
> confused to why it doesn't print to dmesg, then you can simply add a
> kprobe to see those values as well.
> 
> -- Steve
> 
> > 
> > Signed-off-by: George Guo 
> > --- 

There are two reasons of percpu_alloc failed without warnings: 

1. do_warn is false
2. do_warn is true and warn_limit is reached the limit.

Showing do_warn and warn_limit makes things simple, maybe dont need
kprobe again.



[PATCH] percpu: improve percpu_alloc_percpu_fail event trace

2024-01-21 Thread George Guo
From: George Guo 

Add do_warn, warn_limit fields to the output of the
percpu_alloc_percpu_fail ftrace event.

This is required to percpu_alloc failed with no warning showing.

Signed-off-by: George Guo 
---
 include/trace/events/percpu.h | 22 ++
 mm/percpu.c   |  2 +-
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/include/trace/events/percpu.h b/include/trace/events/percpu.h
index 5b8211ca8950..c5f412e84bb8 100644
--- a/include/trace/events/percpu.h
+++ b/include/trace/events/percpu.h
@@ -75,15 +75,18 @@ TRACE_EVENT(percpu_free_percpu,
 
 TRACE_EVENT(percpu_alloc_percpu_fail,
 
-   TP_PROTO(bool reserved, bool is_atomic, size_t size, size_t align),
+   TP_PROTO(bool reserved, bool is_atomic, size_t size, size_t align,
+bool do_warn, int warn_limit),
 
-   TP_ARGS(reserved, is_atomic, size, align),
+   TP_ARGS(reserved, is_atomic, size, align, do_warn, warn_limit),
 
TP_STRUCT__entry(
-   __field(bool,   reserved)
-   __field(bool,   is_atomic   )
-   __field(size_t, size)
-   __field(size_t, align   )
+   __field(bool,   reserved)
+   __field(bool,   is_atomic)
+   __field(size_t, size)
+   __field(size_t, align)
+   __field(bool,   do_warn)
+   __field(int,warn_limit)
),
 
TP_fast_assign(
@@ -91,11 +94,14 @@ TRACE_EVENT(percpu_alloc_percpu_fail,
__entry->is_atomic  = is_atomic;
__entry->size   = size;
__entry->align  = align;
+   __entry->do_warn= do_warn;
+   __entry->warn_limit = warn_limit;
),
 
-   TP_printk("reserved=%d is_atomic=%d size=%zu align=%zu",
+   TP_printk("reserved=%d is_atomic=%d size=%zu align=%zu do_warn=%d, 
warn_limit=%d",
  __entry->reserved, __entry->is_atomic,
- __entry->size, __entry->align)
+ __entry->size, __entry->align,
+ __entry->do_warn, __entry->warn_limit)
 );
 
 TRACE_EVENT(percpu_create_chunk,
diff --git a/mm/percpu.c b/mm/percpu.c
index 4e11fc1e6def..ac5b48268c99 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1886,7 +1886,7 @@ static void __percpu *pcpu_alloc(size_t size, size_t 
align, bool reserved,
 fail_unlock:
spin_unlock_irqrestore(_lock, flags);
 fail:
-   trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align);
+   trace_percpu_alloc_percpu_fail(reserved, is_atomic, size, align, 
do_warn, warn_limit);
 
if (do_warn && warn_limit) {
pr_warn("allocation failed, size=%zu align=%zu atomic=%d, %s\n",
-- 
2.34.1




Re: [PATCH] ACPI: x86: Call acpi_boot_table_init() after acpi_table_upgrade()

2021-04-13 Thread George Kennedy




On 4/13/2021 10:01 AM, Rafael J. Wysocki wrote:

From: Rafael J. Wysocki 

Commit 1a1c130ab757 ("ACPI: tables: x86: Reserve memory occupied by
ACPI tables") attempted to address an issue with reserving the memory
occupied by ACPI tables, but it broke the initrd-based table override
mechanism relied on by multiple users.

To restore the initrd-based ACPI table override functionality, move
the acpi_boot_table_init() invocation in setup_arch() on x86 after
the acpi_table_upgrade() one.

Fixes: 1a1c130ab757 ("ACPI: tables: x86: Reserve memory occupied by ACPI 
tables")
Reported-by: Hans de Goede 
Tested-by: Hans de Goede 
Signed-off-by: Rafael J. Wysocki 
---

George, can you please check if this reintroduces the issue addressed by
the above commit for you?


Will do.

George



---
  arch/x86/kernel/setup.c |5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

Index: linux-pm/arch/x86/kernel/setup.c
===
--- linux-pm.orig/arch/x86/kernel/setup.c
+++ linux-pm/arch/x86/kernel/setup.c
@@ -1045,9 +1045,6 @@ void __init setup_arch(char **cmdline_p)
  
  	cleanup_highmap();
  
-	/* Look for ACPI tables and reserve memory occupied by them. */

-   acpi_boot_table_init();
-
memblock_set_current_limit(ISA_END_ADDRESS);
e820__memblock_setup();
  
@@ -1132,6 +1129,8 @@ void __init setup_arch(char **cmdline_p)

reserve_initrd();
  
  	acpi_table_upgrade();

+   /* Look for ACPI tables and reserve memory occupied by them. */
+   acpi_boot_table_init();
  
  	vsmp_init();
  








[no subject]

2021-04-12 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, während
50% dies tun
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


Re: [PATCH net v1] lan743x: fix ethernet frame cutoff issue

2021-04-09 Thread George McCollister
On Thu, Apr 8, 2021 at 7:39 PM Sven Van Asbroeck  wrote:
>
> From: Sven Van Asbroeck 
>
> The ethernet frame length is calculated incorrectly. Depending on
> the value of RX_HEAD_PADDING, this may result in ethernet frames
> that are too short (cut off at the end), or too long (garbage added
> to the end).
>
> Fix by calculating the ethernet frame length correctly. For added
> clarity, use the ETH_FCS_LEN constant in the calculation.
>
> Many thanks to Heiner Kallweit for suggesting this solution.
>
> Fixes: 3e21a10fdea3 ("lan743x: trim all 4 bytes of the FCS; not just 2")
> Link: https://lore.kernel.org/lkml/20210408172353.21143-1-thesve...@gmail.com/
> Signed-off-by: Sven Van Asbroeck 

I'm glad everyone was able to work together to get this fixed properly
without any figure pointing or mud slinging! Kudos everyone.

Reviewed-by: George McCollister 
Tested-By: George McCollister 

> ---
>
> Tree: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git # 
> 864db232dc70
>
> To: Bryan Whitehead 
> To: "David S. Miller" 
> To: Jakub Kicinski 
> To: George McCollister 
> Cc: Heiner Kallweit 
> Cc: Andrew Lunn 
> Cc: unglinuxdri...@microchip.com
> Cc: net...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
>  drivers/net/ethernet/microchip/lan743x_main.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index 1c3e204d727c..7b6794aa8ea9 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -885,8 +885,8 @@ static int lan743x_mac_set_mtu(struct lan743x_adapter 
> *adapter, int new_mtu)
> }
>
> mac_rx &= ~(MAC_RX_MAX_SIZE_MASK_);
> -   mac_rx |= (((new_mtu + ETH_HLEN + 4) << MAC_RX_MAX_SIZE_SHIFT_) &
> - MAC_RX_MAX_SIZE_MASK_);
> +   mac_rx |= (((new_mtu + ETH_HLEN + ETH_FCS_LEN)
> + << MAC_RX_MAX_SIZE_SHIFT_) & MAC_RX_MAX_SIZE_MASK_);
> lan743x_csr_write(adapter, MAC_RX, mac_rx);
>
> if (enabled) {
> @@ -1944,7 +1944,7 @@ static int lan743x_rx_init_ring_element(struct 
> lan743x_rx *rx, int index)
> struct sk_buff *skb;
> dma_addr_t dma_ptr;
>
> -   buffer_length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING;
> +   buffer_length = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + 
> RX_HEAD_PADDING;
>
> descriptor = >ring_cpu_ptr[index];
> buffer_info = >buffer_info[index];
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
> +   frame_length = max_t(int, 0, frame_length - ETH_FCS_LEN);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;
> --
> 2.17.1
>


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 1:35 PM Sven Van Asbroeck  wrote:
>
> Hi George,
>
> On Thu, Apr 8, 2021 at 2:26 PM Sven Van Asbroeck  wrote:
> >
> > George, I will send a patch for you to try shortly. Except if you're
> > already ahead :)
>
> Would this work for you? It does for me.

Works for me too.

>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index dbdfabff3b00..7b6794aa8ea9 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -885,8 +885,8 @@ static int lan743x_mac_set_mtu(struct
> lan743x_adapter *adapter, int new_mtu)
> }
>
> mac_rx &= ~(MAC_RX_MAX_SIZE_MASK_);
> -   mac_rx |= (((new_mtu + ETH_HLEN + 4) << MAC_RX_MAX_SIZE_SHIFT_) &
> - MAC_RX_MAX_SIZE_MASK_);
> +   mac_rx |= (((new_mtu + ETH_HLEN + ETH_FCS_LEN)
> + << MAC_RX_MAX_SIZE_SHIFT_) & MAC_RX_MAX_SIZE_MASK_);
> lan743x_csr_write(adapter, MAC_RX, mac_rx);
>
> if (enabled) {
> @@ -1944,7 +1944,7 @@ static int lan743x_rx_init_ring_element(struct
> lan743x_rx *rx, int index)
> struct sk_buff *skb;
> dma_addr_t dma_ptr;
>
> -   buffer_length = netdev->mtu + ETH_HLEN + 4 + RX_HEAD_PADDING;
> +   buffer_length = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + 
> RX_HEAD_PADDING;
>
> descriptor = >ring_cpu_ptr[index];
> buffer_info = >buffer_info[index];
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
> +   frame_length = max_t(int, 0, frame_length - ETH_FCS_LEN);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 12:46 PM Sven Van Asbroeck  wrote:
>
> Hi George,
>
> On Thu, Apr 8, 2021 at 1:36 PM George McCollister
>  wrote:
> >
> > Can you explain the difference in behavior with what I was observing
> > on the LAN7431?
>
> I'm not using DSA in my application, so I cannot test or replicate
> what you were observing. It would be great if we could work together
> and settle on a solution that is acceptable to both of us.

Sounds good.

>
> > I'll retest but if this is reverted I'm going to start
> > seeing 2 extra bytes on the end of frames and it's going to break DSA
> > with the LAN7431 again.
> >
>
> Seen from my point of view, your patch is a regression. But perhaps my
> patch set is a regression for you? Catch 22...
>
> Would you be able to identify which patch broke your DSA behaviour?
> Was it one of mine? Perhaps we can start from there.

Yes, first I'm going to confirm that what is in the net branch still
works (unlikely but perhaps something else could have broken it since
last I tried it).
Then I'll confirm the patch which I believe broke it actually did and
report back.

>
> Sven


Re: [PATCH net v1] Revert "lan743x: trim all 4 bytes of the FCS; not just 2"

2021-04-08 Thread George McCollister
On Thu, Apr 8, 2021 at 12:23 PM Sven Van Asbroeck  wrote:
>
> From: Sven Van Asbroeck 
>
> This reverts commit 3e21a10fdea3c2e4e4d1b72cb9d720256461af40.
>
> The reverted patch completely breaks all network connectivity on the
> lan7430. tcpdump indicates missing bytes when receiving ping
> packets from an external host:

Can you explain the difference in behavior with what I was observing
on the LAN7431? I'll retest but if this is reverted I'm going to start
seeing 2 extra bytes on the end of frames and it's going to break DSA
with the LAN7431 again.

>
> host$ ping $lan7430_ip
> lan7430$ tcpdump -v
> IP truncated-ip - 2 bytes missing! (tos 0x0, ttl 64, id 21715,
> offset 0, flags [DF], proto ICMP (1), length 84)
>
> Fixes: 3e21a10fdea3 ("lan743x: trim all 4 bytes of the FCS; not just 2")
> Signed-off-by: Sven Van Asbroeck 
> ---
>
> To: Bryan Whitehead 
> To: "David S. Miller" 
> To: Jakub Kicinski 
> To: George McCollister 
> Cc: unglinuxdri...@microchip.com
> Cc: net...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
>  drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
> b/drivers/net/ethernet/microchip/lan743x_main.c
> index 1c3e204d727c..dbdfabff3b00 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int 
> frame_length)
> dev_kfree_skb_irq(skb);
> return NULL;
> }
> -   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
> +   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
> if (skb->len > frame_length) {
> skb->tail -= skb->len - frame_length;
> skb->len = frame_length;
> --
> 2.17.1
>

Regards,
George


[no subject]

2021-04-06 Thread george mike
cześć

Nazywam się George Mike. Z zawodu jestem prawnikiem. Chcę ci zaoferować
najbliższy krewny mojego klienta. Odziedziczysz sumę (8,5 miliona dolarów)
dolarów, które mój klient zostawił w banku przed śmiercią.

Mój klient jest obywatelem twojego kraju, który zginął wraz z żoną w
wypadku samochodowym
i jedyny syn. Będę uprawniony do 50% całkowitego funduszu, podczas gdy
50% będzie
Być dla ciebie.
Aby uzyskać więcej informacji, skontaktuj się z moim prywatnym adresem
e-mail: georgemike7...@gmail.com

Z góry bardzo dziękuję,
Panie George Mike,


Re: [PATCH] ACPI: tables: x86: Reserve memory occupied by ACPI tables

2021-03-24 Thread George Kennedy




On 3/24/2021 9:27 AM, Rafael J. Wysocki wrote:

On Wed, Mar 24, 2021 at 9:24 AM Mike Rapoport  wrote:

On Tue, Mar 23, 2021 at 08:26:52PM +0100, Rafael J. Wysocki wrote:

From: Rafael J. Wysocki 

The following problem has been reported by George Kennedy:

  Since commit 7fef431be9c9 ("mm/page_alloc: place pages to tail
  in __free_pages_core()") the following use after free occurs
  intermittently when ACPI tables are accessed.

  BUG: KASAN: use-after-free in ibft_init+0x134/0xc49
  Read of size 4 at addr 8880be453004 by task swapper/0/1
  CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc1-7a7fd0d #1
  Call Trace:
   dump_stack+0xf6/0x158
   print_address_description.constprop.9+0x41/0x60
   kasan_report.cold.14+0x7b/0xd4
   __asan_report_load_n_noabort+0xf/0x20
   ibft_init+0x134/0xc49
   do_one_initcall+0xc4/0x3e0
   kernel_init_freeable+0x5af/0x66b
   kernel_init+0x16/0x1d0
   ret_from_fork+0x22/0x30

  ACPI tables mapped via kmap() do not have their mapped pages
  reserved and the pages can be "stolen" by the buddy allocator.

Apparently, on the affected system, the ACPI table in question is
not located in "reserved" memory, like ACPI NVS or ACPI Data, that
will not be used by the buddy allocator, so the memory occupied by
that table has to be explicitly reserved to prevent the buddy
allocator from using it.

In order to address this problem, rearrange the initialization of the
ACPI tables on x86 to locate the initial tables earlier and reserve
the memory occupied by them.

The other architectures using ACPI should not be affected by this
change.

Link: 
https://lore.kernel.org/linux-acpi/1614802160-29362-1-git-send-email-george.kenn...@oracle.com/
Reported-by: George Kennedy 
Signed-off-by: Rafael J. Wysocki 

FWIW:
Reviewed-by: Mike Rapoport 

Thank you!

George, can you please try this patch on the affected system?


Rafael,

10 for 10 successful reboots with your patch.

First, verified the failure is still there with latest 5.12.0-rc4.

George
P.S. Thanks Mike, Rafael & David




---
  arch/x86/kernel/acpi/boot.c |   25 -
  arch/x86/kernel/setup.c |8 +++-
  drivers/acpi/tables.c   |   42 +++---
  include/linux/acpi.h|9 -
  4 files changed, 62 insertions(+), 22 deletions(-)

Index: linux-pm/arch/x86/kernel/acpi/boot.c
===
--- linux-pm.orig/arch/x86/kernel/acpi/boot.c
+++ linux-pm/arch/x86/kernel/acpi/boot.c
@@ -1554,10 +1554,18 @@ void __init acpi_boot_table_init(void)
   /*
* Initialize the ACPI boot-time table parser.
*/
- if (acpi_table_init()) {
+ if (acpi_locate_initial_tables())
   disable_acpi();
- return;
- }
+ else
+ acpi_reserve_initial_tables();
+}
+
+int __init early_acpi_boot_init(void)
+{
+ if (acpi_disabled)
+ return 1;
+
+ acpi_table_init_complete();

   acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);

@@ -1570,18 +1578,9 @@ void __init acpi_boot_table_init(void)
   } else {
   printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
   disable_acpi();
- return;
+ return 1;
   }
   }
-}
-
-int __init early_acpi_boot_init(void)
-{
- /*
-  * If acpi_disabled, bail out
-  */
- if (acpi_disabled)
- return 1;

   /*
* Process the Multiple APIC Description Table (MADT), if present
Index: linux-pm/arch/x86/kernel/setup.c
===
--- linux-pm.orig/arch/x86/kernel/setup.c
+++ linux-pm/arch/x86/kernel/setup.c
@@ -1045,6 +1045,9 @@ void __init setup_arch(char **cmdline_p)

   cleanup_highmap();

+ /* Look for ACPI tables and reserve memory occupied by them. */
+ acpi_boot_table_init();
+
   memblock_set_current_limit(ISA_END_ADDRESS);
   e820__memblock_setup();

@@ -1136,11 +1139,6 @@ void __init setup_arch(char **cmdline_p)

   early_platform_quirks();

- /*
-  * Parse the ACPI tables for possible boot-time SMP configuration.
-  */
- acpi_boot_table_init();
-
   early_acpi_boot_init();

   initmem_init();
Index: linux-pm/include/linux/acpi.h
===
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -222,10 +222,14 @@ void __iomem *__acpi_map_table(unsigned
  void __acpi_unmap_table(void __iomem *map, unsigned long size);
  int early_acpi_boot_init(void);
  int acpi_boot_init (void);
+void acpi_boot_table_prepare (void);
  void acpi_boot_table_init (void);
  int acpi_mps_check (void);
  int acpi_numa_init (void);

+int acpi_locate_initial_tables (void);
+void acpi_reserve_initial_tables (void);
+void acpi_table_init_complete (void);
  int acpi_table_

Re: [PATCH] ACPI: tables: x86: Reserve memory occupied by ACPI tables

2021-03-24 Thread George Kennedy




On 3/24/2021 9:27 AM, Rafael J. Wysocki wrote:

On Wed, Mar 24, 2021 at 9:24 AM Mike Rapoport  wrote:

On Tue, Mar 23, 2021 at 08:26:52PM +0100, Rafael J. Wysocki wrote:

From: Rafael J. Wysocki 

The following problem has been reported by George Kennedy:

  Since commit 7fef431be9c9 ("mm/page_alloc: place pages to tail
  in __free_pages_core()") the following use after free occurs
  intermittently when ACPI tables are accessed.

  BUG: KASAN: use-after-free in ibft_init+0x134/0xc49
  Read of size 4 at addr 8880be453004 by task swapper/0/1
  CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc1-7a7fd0d #1
  Call Trace:
   dump_stack+0xf6/0x158
   print_address_description.constprop.9+0x41/0x60
   kasan_report.cold.14+0x7b/0xd4
   __asan_report_load_n_noabort+0xf/0x20
   ibft_init+0x134/0xc49
   do_one_initcall+0xc4/0x3e0
   kernel_init_freeable+0x5af/0x66b
   kernel_init+0x16/0x1d0
   ret_from_fork+0x22/0x30

  ACPI tables mapped via kmap() do not have their mapped pages
  reserved and the pages can be "stolen" by the buddy allocator.

Apparently, on the affected system, the ACPI table in question is
not located in "reserved" memory, like ACPI NVS or ACPI Data, that
will not be used by the buddy allocator, so the memory occupied by
that table has to be explicitly reserved to prevent the buddy
allocator from using it.

In order to address this problem, rearrange the initialization of the
ACPI tables on x86 to locate the initial tables earlier and reserve
the memory occupied by them.

The other architectures using ACPI should not be affected by this
change.

Link: 
https://lore.kernel.org/linux-acpi/1614802160-29362-1-git-send-email-george.kenn...@oracle.com/
Reported-by: George Kennedy 
Signed-off-by: Rafael J. Wysocki 

FWIW:
Reviewed-by: Mike Rapoport 

Thank you!

George, can you please try this patch on the affected system?


Will do.

George



---
  arch/x86/kernel/acpi/boot.c |   25 -
  arch/x86/kernel/setup.c |8 +++-
  drivers/acpi/tables.c   |   42 +++---
  include/linux/acpi.h|9 -
  4 files changed, 62 insertions(+), 22 deletions(-)

Index: linux-pm/arch/x86/kernel/acpi/boot.c
===
--- linux-pm.orig/arch/x86/kernel/acpi/boot.c
+++ linux-pm/arch/x86/kernel/acpi/boot.c
@@ -1554,10 +1554,18 @@ void __init acpi_boot_table_init(void)
   /*
* Initialize the ACPI boot-time table parser.
*/
- if (acpi_table_init()) {
+ if (acpi_locate_initial_tables())
   disable_acpi();
- return;
- }
+ else
+ acpi_reserve_initial_tables();
+}
+
+int __init early_acpi_boot_init(void)
+{
+ if (acpi_disabled)
+ return 1;
+
+ acpi_table_init_complete();

   acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);

@@ -1570,18 +1578,9 @@ void __init acpi_boot_table_init(void)
   } else {
   printk(KERN_WARNING PREFIX "Disabling ACPI support\n");
   disable_acpi();
- return;
+ return 1;
   }
   }
-}
-
-int __init early_acpi_boot_init(void)
-{
- /*
-  * If acpi_disabled, bail out
-  */
- if (acpi_disabled)
- return 1;

   /*
* Process the Multiple APIC Description Table (MADT), if present
Index: linux-pm/arch/x86/kernel/setup.c
===
--- linux-pm.orig/arch/x86/kernel/setup.c
+++ linux-pm/arch/x86/kernel/setup.c
@@ -1045,6 +1045,9 @@ void __init setup_arch(char **cmdline_p)

   cleanup_highmap();

+ /* Look for ACPI tables and reserve memory occupied by them. */
+ acpi_boot_table_init();
+
   memblock_set_current_limit(ISA_END_ADDRESS);
   e820__memblock_setup();

@@ -1136,11 +1139,6 @@ void __init setup_arch(char **cmdline_p)

   early_platform_quirks();

- /*
-  * Parse the ACPI tables for possible boot-time SMP configuration.
-  */
- acpi_boot_table_init();
-
   early_acpi_boot_init();

   initmem_init();
Index: linux-pm/include/linux/acpi.h
===
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -222,10 +222,14 @@ void __iomem *__acpi_map_table(unsigned
  void __acpi_unmap_table(void __iomem *map, unsigned long size);
  int early_acpi_boot_init(void);
  int acpi_boot_init (void);
+void acpi_boot_table_prepare (void);
  void acpi_boot_table_init (void);
  int acpi_mps_check (void);
  int acpi_numa_init (void);

+int acpi_locate_initial_tables (void);
+void acpi_reserve_initial_tables (void);
+void acpi_table_init_complete (void);
  int acpi_table_init (void);
  int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
  int __init acpi_table_parse_entries(char *id, unsigned long table_size

Re: [PATCH net] net: dsa: don't assign an error value to tag_ops

2021-03-22 Thread George McCollister
On Mon, Mar 22, 2021 at 3:46 PM Vladimir Oltean  wrote:
>
> On Mon, Mar 22, 2021 at 03:26:50PM -0500, George McCollister wrote:
> > Use a temporary variable to hold the return value from
> > dsa_tag_driver_get() instead of assigning it to dst->tag_ops. Leaving
> > an error value in dst->tag_ops can result in deferencing an invalid
> > pointer when a deferred switch configuration happens later.
> >
> > Fixes: 357f203bb3b5 ("net: dsa: keep a copy of the tagging protocol in the 
> > DSA switch tree")
> >
> > Signed-off-by: George McCollister 
> > ---
>
> Who dereferences the invalid pointer? dsa_tree_free I guess?

I saw it occur just above on the following line the next time
dsa_port_parse_cpu() is called:
if (dst->tag_ops->proto != tag_protocol) {

-George


[PATCH net] net: dsa: don't assign an error value to tag_ops

2021-03-22 Thread George McCollister
Use a temporary variable to hold the return value from
dsa_tag_driver_get() instead of assigning it to dst->tag_ops. Leaving
an error value in dst->tag_ops can result in deferencing an invalid
pointer when a deferred switch configuration happens later.

Fixes: 357f203bb3b5 ("net: dsa: keep a copy of the tagging protocol in the DSA 
switch tree")

Signed-off-by: George McCollister 
---
 net/dsa/dsa2.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index eb709d988c54..8f9e35e1aa89 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -1068,6 +1068,7 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct 
net_device *master)
 {
struct dsa_switch *ds = dp->ds;
struct dsa_switch_tree *dst = ds->dst;
+   const struct dsa_device_ops *tag_ops;
enum dsa_tag_protocol tag_protocol;
 
tag_protocol = dsa_get_tag_protocol(dp, master);
@@ -1082,14 +1083,16 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, 
struct net_device *master)
 * nothing to do here.
 */
} else {
-   dst->tag_ops = dsa_tag_driver_get(tag_protocol);
-   if (IS_ERR(dst->tag_ops)) {
-   if (PTR_ERR(dst->tag_ops) == -ENOPROTOOPT)
+   tag_ops = dsa_tag_driver_get(tag_protocol);
+   if (IS_ERR(tag_ops)) {
+   if (PTR_ERR(tag_ops) == -ENOPROTOOPT)
return -EPROBE_DEFER;
dev_warn(ds->dev, "No tagger for this switch\n");
dp->master = NULL;
-   return PTR_ERR(dst->tag_ops);
+   return PTR_ERR(tag_ops);
}
+
+   dst->tag_ops = tag_ops;
}
 
dp->master = master;
-- 
2.11.0



Re: [PATCH 1/1] ACPI: fix acpi table use after free

2021-03-17 Thread George Kennedy




On 3/17/2021 4:14 PM, Rafael J. Wysocki wrote:

On Monday, March 15, 2021 5:19:29 PM CET Rafael J. Wysocki wrote:

On Sun, Mar 14, 2021 at 8:00 PM Mike Rapoport  wrote:

On Thu, Mar 11, 2021 at 04:36:31PM +0100, Rafael J. Wysocki wrote:

On Wed, Mar 10, 2021 at 8:47 PM David Hildenbrand  wrote:

There is some care that should be taken to make sure we get the order
right, but I don't see a fundamental issue here.

Me neither.


If I understand correctly, Rafael's concern is about changing the parts of
ACPICA that should be OS agnostic, so I think we just need another place to
call memblock_reserve() rather than acpi_tb_install_table_with_override().

Something like this.

There is also the problem that memblock_reserve() needs to be called
for all of the tables early enough, which will require some reordering
of the early init code.


Since the reservation should be done early in x86::setup_arch() (and
probably in arm64::setup_arch()) we might just have a function that parses
table headers and reserves them, similarly to how we parse the tables
during KASLR setup.

Right.

I've looked at it a bit more and we do something like the patch below that
nearly duplicates acpi_tb_parse_root_table() which is not very nice.

It looks to me that the code need not be duplicated (see below).


Besides, reserving ACPI tables early and then calling acpi_table_init()
(and acpi_tb_parse_root_table() again would mean doing the dance with
early_memremap() twice for no good reason.

That'd be simply inefficient which is kind of acceptable to me to start with.

And I changing the ACPICA code can be avoided at least initially, it
by itself would be a good enough reason.


I believe the most effective way to deal with this would be to have a
function that does parsing, reservation and installs the tables supplied by
the firmware which can be called really early and then another function
that overrides tables if needed a some later point.

I agree that this should be the direction to go into.

So maybe something like the patch below?


Do you want me to try it out in the failing setup?

George


I'm not sure if acpi_boot_table_prepare() gets called early enough, though.

Also this still may not play well with initrd-based table overrides. Erik, do
you have any insights here?

And ia64 needs to be updated too.

---
  arch/x86/kernel/acpi/boot.c |   12 +---
  arch/x86/kernel/setup.c |3 +++
  drivers/acpi/tables.c   |   24 +---
  include/linux/acpi.h|9 +++--
  4 files changed, 40 insertions(+), 8 deletions(-)

Index: linux-pm/arch/x86/kernel/acpi/boot.c
===
--- linux-pm.orig/arch/x86/kernel/acpi/boot.c
+++ linux-pm/arch/x86/kernel/acpi/boot.c
@@ -1541,7 +1541,7 @@ static const struct dmi_system_id acpi_d
   *...
   */
  
-void __init acpi_boot_table_init(void)

+void __init acpi_boot_table_prepare(void)
  {
dmi_check_system(acpi_dmi_table);
  
@@ -1554,10 +1554,16 @@ void __init acpi_boot_table_init(void)

/*
 * Initialize the ACPI boot-time table parser.
 */
-   if (acpi_table_init()) {
+   if (acpi_table_prepare())
disable_acpi();
+}
+
+void __init acpi_boot_table_init(void)
+{
+   if (acpi_disabled)
return;
-   }
+
+   acpi_table_init();
  
  	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  
Index: linux-pm/arch/x86/kernel/setup.c

===
--- linux-pm.orig/arch/x86/kernel/setup.c
+++ linux-pm/arch/x86/kernel/setup.c
@@ -1070,6 +1070,9 @@ void __init setup_arch(char **cmdline_p)
/* preallocate 4k for mptable mpc */
e820__memblock_alloc_reserved_mpc_new();
  
+	/* Look for ACPI tables and reserve memory occupied by them. */

+   acpi_boot_table_prepare();
+
  #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
setup_bios_corruption_check();
  #endif
Index: linux-pm/include/linux/acpi.h
===
--- linux-pm.orig/include/linux/acpi.h
+++ linux-pm/include/linux/acpi.h
@@ -222,11 +222,13 @@ void __iomem *__acpi_map_table(unsigned
  void __acpi_unmap_table(void __iomem *map, unsigned long size);
  int early_acpi_boot_init(void);
  int acpi_boot_init (void);
+void acpi_boot_table_prepare (void);
  void acpi_boot_table_init (void);
  int acpi_mps_check (void);
  int acpi_numa_init (void);
  
-int acpi_table_init (void);

+int acpi_table_prepare (void);
+void acpi_table_init (void);
  int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
  int __init acpi_table_parse_entries(char *id, unsigned long table_size,
  int entry_id,
@@ -814,9 +816,12 @@ static inline int acpi_boot_init(void)
return 0;
  }
  
+static inline void acpi_boot_table_prepare(void)

+{
+}
+
  static inline void acpi_boot_table_init(void)
  {
-   return;
  }
  
  static inline

[no subject]

2021-03-11 Thread george mike
Hallo

Ich heiße George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte dir anbieten
engster Verwandter meines Klienten. Sie erben die Gesamtsumme (8,5
Millionen US-Dollar).
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Klient ist ein Staatsangehöriger Ihres Landes, der mit seiner
Frau bei einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, während
50% davon berechtigt sind
Sein für dich.
Für weitere Informationen wenden Sie sich bitte an meine private
E-Mail-Adresse: georgemike7...@gmail.com

Vielen Dank im Voraus,
Herr George Mike,


[PATCH net] net: dsa: xrs700x: check if partner is same as port in hsr join

2021-03-08 Thread George McCollister
Don't assign dp to partner if it's the same port that xrs700x_hsr_join
was called with. The partner port is supposed to be the other port in
the HSR/PRP redundant pair not the same port. This fixes an issue
observed in testing where forwarding between redundant HSR ports on this
switch didn't work depending on the order the ports were added to the
hsr device.

Fixes: bd62e6f5e6a9 ("net: dsa: xrs700x: add HSR offloading support")
Signed-off-by: George McCollister 
---
 drivers/net/dsa/xrs700x/xrs700x.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/xrs700x/xrs700x.c 
b/drivers/net/dsa/xrs700x/xrs700x.c
index f025f968f96d..fde6e99274b6 100644
--- a/drivers/net/dsa/xrs700x/xrs700x.c
+++ b/drivers/net/dsa/xrs700x/xrs700x.c
@@ -528,7 +528,10 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int 
port,
return -EOPNOTSUPP;
 
dsa_hsr_foreach_port(dp, ds, hsr) {
-   partner = dp;
+   if (dp->index != port) {
+   partner = dp;
+   break;
+   }
}
 
/* We can't enable redundancy on the switch until both
@@ -582,7 +585,10 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int 
port,
unsigned int val;
 
dsa_hsr_foreach_port(dp, ds, hsr) {
-   partner = dp;
+   if (dp->index != port) {
+   partner = dp;
+   break;
+   }
}
 
if (!partner)
-- 
2.11.0



[no subject]

2021-03-07 Thread george mike
vHallo

Ich heiße George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte dir anbieten
engster Verwandter meines Klienten. Sie erben die Gesamtsumme (8,5
Millionen US-Dollar).
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Klient ist ein Staatsangehöriger Ihres Landes, der mit seiner
Frau bei einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, während
50% davon berechtigt sind
Sein für dich.
Für weitere Informationen wenden Sie sich bitte an meine private
E-Mail-Adresse: georgemike7...@gmail.com

Vielen Dank im Voraus,
Herr George Mike,


[PATCH net] lan743x: trim all 4 bytes of the FCS; not just 2

2021-03-05 Thread George McCollister
Trim all 4 bytes of the received FCS; not just 2 of them. Leaving 2
bytes of the FCS on the frame breaks DSA tailing tag drivers.

Fixes: a8db76d40e4d ("lan743x: boost performance on cpu archs w/o dma cache 
snooping")
Signed-off-by: George McCollister 
---
 drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c 
b/drivers/net/ethernet/microchip/lan743x_main.c
index 334e99ffe56f..360d16965a5c 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -2040,7 +2040,7 @@ lan743x_rx_trim_skb(struct sk_buff *skb, int frame_length)
dev_kfree_skb_irq(skb);
return NULL;
}
-   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 2);
+   frame_length = max_t(int, 0, frame_length - RX_HEAD_PADDING - 4);
if (skb->len > frame_length) {
skb->tail -= skb->len - frame_length;
skb->len = frame_length;
-- 
2.11.0



Re: [PATCH 1/1] ACPI: fix acpi table use after free

2021-03-05 Thread George Kennedy




On 3/5/2021 8:40 AM, David Hildenbrand wrote:
The ibft table, for example, is mapped in via acpi_map() and kmap(). 
The
page for the ibft table is not reserved, so it can end up on the 
freelist.


You appear to be saying that it is not sufficient to kmap() a page in
order to use it safely.  It is also necessary to reserve it upfront,
for example with the help of memblock_reserve().  Is that correct?  If
so, is there an alternative way to reserve a page frame?


If the memory is indicated by the BIOS/firmware as valid memory 
(!reserved) but contains actual tables that have to remain untouched 
what happens is:


1) Memblock thinks the memory should be given to the buddy, because it
   is valid memory and was not reserved by anyone (i.e., the bios, early
   allocations).

2) Memblock will expose the pages to the buddy, adding them to the free
   page list.

3) Anybody can allocate them, e.g., via alloc_pages().

The root issue is that pages that should not get exposed to the buddy 
as free pages get exposed to the buddy as free pages. We have to teach 
memblock that these pages are not actually to be used, but instead, 
area reserved.







Use memblock_reserve() to reserve all the ACPI table pages.

How is this going to help?

If the ibft table page is not reserved, it will end up on the freelist
and potentially be allocated before ibft_init() is called.

I believe this is the call that causes the ibft table page (in this 
case

pfn=0xbe453) to end up on the freelist:

memmap_init_range: size=bd49b, nid=0, zone=1, start_pfn=1000,
zone_end_pfn=10


David, is commit 7fef431be9c9 related to this and if so, then how?



Memory gets allocated and used in a different order, which seems to 
have exposed (yet another) latent BUG. The same could be reproduced 
via zone shuffling with a little luck.


Thank you David for the detailed problem description,
George



Re: [PATCH 1/1] ACPI: fix acpi table use after free

2021-03-04 Thread George Kennedy

Hello Rafael,

On 3/4/2021 7:14 AM, Rafael J. Wysocki wrote:

On Thu, Mar 4, 2021 at 2:22 AM George Kennedy  wrote:

Since commit 7fef431be9c9 ("mm/page_alloc: place pages to tail
in __free_pages_core()") the following use after free occurs
intermittently when acpi tables are accessed.

BUG: KASAN: use-after-free in ibft_init+0x134/0xc49
Read of size 4 at addr 8880be453004 by task swapper/0/1
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc1-7a7fd0d #1
Call Trace:
  dump_stack+0xf6/0x158
  print_address_description.constprop.9+0x41/0x60
  kasan_report.cold.14+0x7b/0xd4
  __asan_report_load_n_noabort+0xf/0x20
  ibft_init+0x134/0xc49
  do_one_initcall+0xc4/0x3e0
  kernel_init_freeable+0x5af/0x66b
  kernel_init+0x16/0x1d0
  ret_from_fork+0x22/0x30

ACPI tables mapped via kmap() do not have their mapped pages
reserved and the pages can be "stolen" by the buddy allocator.

What do you mean by this?
The ibft table, for example, is mapped in via acpi_map() and kmap(). The 
page for the ibft table is not reserved, so it can end up on the freelist.



Use memblock_reserve() to reserve all the ACPI table pages.

How is this going to help?
If the ibft table page is not reserved, it will end up on the freelist 
and potentially be allocated before ibft_init() is called.


I believe this is the call that causes the ibft table page (in this case 
pfn=0xbe453) to end up on the freelist:


memmap_init_range: size=bd49b, nid=0, zone=1, start_pfn=1000, 
zone_end_pfn=10


[    0.477319]  memmap_init_range+0x33b/0x4e2
[    0.479053]  memmap_init_zone+0x1e0/0x243
[    0.485276]  free_area_init_node+0xa4e/0xac5
[    0.498242]  free_area_init+0xf4a/0x107a
[    0.509958]  zone_sizes_init+0xd9/0x111
[    0.511731]  paging_init+0x4a/0x4c
[    0.512417]  setup_arch+0x14f8/0x1758
[    0.519193]  start_kernel+0x6c/0x46f
[    0.519921]  x86_64_start_reservations+0x37/0x39
[    0.520847]  x86_64_start_kernel+0x7b/0x7e
[    0.521666]  secondary_startup_64_no_verify+0xb0/0xbb




Signed-off-by: George Kennedy 
---
  arch/x86/kernel/setup.c| 3 +--
  drivers/acpi/acpica/tbinstal.c | 4 
  2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d883176..97deea3 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1046,6 +1046,7 @@ void __init setup_arch(char **cmdline_p)
 cleanup_highmap();

 memblock_set_current_limit(ISA_END_ADDRESS);
+   acpi_boot_table_init();

This cannot be moved before the acpi_table_upgrade() invocation AFAICS.

Why exactly do you want to move it?


Want to make sure there are slots for memblock_reserve() to be able to 
reserve the page.



 e820__memblock_setup();

 /*
@@ -1139,8 +1140,6 @@ void __init setup_arch(char **cmdline_p)
 /*
  * Parse the ACPI tables for possible boot-time SMP configuration.
  */
-   acpi_boot_table_init();
-
 early_acpi_boot_init();

 initmem_init();
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 8d1e5b5..4e32b22 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -8,6 +8,7 @@
   
*/

  #include 
+#include 
  #include "accommon.h"
  #include "actables.h"

@@ -58,6 +59,9 @@
   new_table_desc->flags,
   new_table_desc->pointer);

+   memblock_reserve(new_table_desc->address,
+PAGE_ALIGN(new_table_desc->pointer->length));
+

Why do you want to do this here in the first place?


If there is a better place to do it, I can move the memblock_reserve() 
there. The memblock_reserve() cannot be done from the ibft code - it's 
too late - the ibft table page has already ended up on the freelist by 
the time ibft_init() is called.




Things like that cannot be done in the ACPICA code in general.


Can you recommend a better place to do the memblock_reserve() from?

Thank you,
George




 acpi_tb_print_table_header(new_table_desc->address,
new_table_desc->pointer);

--




[PATCH 1/1] ACPI: fix acpi table use after free

2021-03-03 Thread George Kennedy
Since commit 7fef431be9c9 ("mm/page_alloc: place pages to tail
in __free_pages_core()") the following use after free occurs
intermittently when acpi tables are accessed.

BUG: KASAN: use-after-free in ibft_init+0x134/0xc49
Read of size 4 at addr 8880be453004 by task swapper/0/1
CPU: 3 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc1-7a7fd0d #1
Call Trace:
 dump_stack+0xf6/0x158
 print_address_description.constprop.9+0x41/0x60
 kasan_report.cold.14+0x7b/0xd4
 __asan_report_load_n_noabort+0xf/0x20
 ibft_init+0x134/0xc49
 do_one_initcall+0xc4/0x3e0
 kernel_init_freeable+0x5af/0x66b
 kernel_init+0x16/0x1d0
 ret_from_fork+0x22/0x30

ACPI tables mapped via kmap() do not have their mapped pages
reserved and the pages can be "stolen" by the buddy allocator.
Use memblock_reserve() to reserve all the ACPI table pages.

Signed-off-by: George Kennedy 
---
 arch/x86/kernel/setup.c| 3 +--
 drivers/acpi/acpica/tbinstal.c | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d883176..97deea3 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1046,6 +1046,7 @@ void __init setup_arch(char **cmdline_p)
cleanup_highmap();
 
memblock_set_current_limit(ISA_END_ADDRESS);
+   acpi_boot_table_init();
e820__memblock_setup();
 
/*
@@ -1139,8 +1140,6 @@ void __init setup_arch(char **cmdline_p)
/*
 * Parse the ACPI tables for possible boot-time SMP configuration.
 */
-   acpi_boot_table_init();
-
early_acpi_boot_init();
 
initmem_init();
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 8d1e5b5..4e32b22 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 #include "accommon.h"
 #include "actables.h"
 
@@ -58,6 +59,9 @@
  new_table_desc->flags,
  new_table_desc->pointer);
 
+   memblock_reserve(new_table_desc->address,
+PAGE_ALIGN(new_table_desc->pointer->length));
+
acpi_tb_print_table_header(new_table_desc->address,
   new_table_desc->pointer);
 
-- 
1.8.3.1



Re: [PATCH] mm, kasan: don't poison boot memory

2021-03-01 Thread George Kennedy




On 3/1/2021 9:29 AM, George Kennedy wrote:



On 2/28/2021 1:08 PM, Mike Rapoport wrote:

On Fri, Feb 26, 2021 at 11:16:06AM -0500, George Kennedy wrote:

On 2/26/2021 6:17 AM, Mike Rapoport wrote:

Hi George,

On Thu, Feb 25, 2021 at 08:19:18PM -0500, George Kennedy wrote:

Not sure if it's the right thing to do, but added
"acpi_tb_find_table_address()" to return the physical address of a 
table to

use with memblock_reserve().

virt_to_phys(table) does not seem to return the physical address 
for the

iBFT table (it would be nice if struct acpi_table_header also had a
"address" element for the physical address of the table).

virt_to_phys() does not work that early because then it is mapped with
early_memremap()  which uses different virtual to physical scheme.

I'd say that acpi_tb_find_table_address() makes sense if we'd like to
reserve ACPI tables outside of drivers/acpi.

But probably we should simply reserve all the tables during
acpi_table_init() so that any table that firmware put in the normal 
memory

will be surely reserved.

Ran 10 successful boots with the above without failure.

That's good news indeed :)
Wondering if we could do something like this instead (trying to keep 
changes

minimal). Just do the memblock_reserve() for all the standard tables.
I think something like this should work, but I'm not an ACPI expert 
to say

if this the best way to reserve the tables.

Adding ACPI maintainers to the CC list.
diff --git a/drivers/acpi/acpica/tbinstal.c 
b/drivers/acpi/acpica/tbinstal.c

index 0bb15ad..830f82c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -7,6 +7,7 @@
   *
*/ 



+#include 
  #include 
  #include "accommon.h"
  #include "actables.h"
@@ -14,6 +15,23 @@
  #define _COMPONENT  ACPI_TABLES
  ACPI_MODULE_NAME("tbinstal")

+void
+acpi_tb_reserve_standard_table(acpi_physical_address address,
+               struct acpi_table_header *header)
+{
+    struct acpi_table_header local_header;
+
+    if ((ACPI_COMPARE_NAMESEG(header->signature, ACPI_SIG_FACS)) ||
+        (ACPI_VALIDATE_RSDP_SIG(header->signature))) {
+        return;
+    }
+    /* Standard ACPI table with full common header */
+
+    memcpy(_header, header, sizeof(struct acpi_table_header));
+
+    memblock_reserve(address, PAGE_ALIGN(local_header.length));
+}
+
  /*** 


   *
   * FUNCTION:    acpi_tb_install_table_with_override
@@ -58,6 +76,9 @@
                new_table_desc->flags,
                new_table_desc->pointer);

+ acpi_tb_reserve_standard_table(new_table_desc->address,
+                   new_table_desc->pointer);
+
  acpi_tb_print_table_header(new_table_desc->address,
                 new_table_desc->pointer);

There should be no harm in doing the memblock_reserve() for all the 
standard

tables, right?
It should be ok to memblock_reserve() all the tables very early as 
long as

we don't run out of static entries in memblock.reserved.

We just need to make sure the tables are reserved before memblock
allocations are possible, so we'd still need to move 
acpi_table_init() in

x86::setup_arch() before e820__memblock_setup().
Not sure how early ACPI is initialized on arm64.


Thanks Mike. Will try to move the memblock_reserves() before 
e820__memblock_setup().


Hi Mike,

Moved acpi_table_init() in x86::setup_arch() before 
e820__memblock_setup() as you suggested.


Ran 10 boots with the following without error.

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 740f3bdb..3b1dd24 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1047,6 +1047,7 @@ void __init setup_arch(char **cmdline_p)
 cleanup_highmap();

 memblock_set_current_limit(ISA_END_ADDRESS);
+    acpi_boot_table_init();
 e820__memblock_setup();

 /*
@@ -1140,8 +1141,6 @@ void __init setup_arch(char **cmdline_p)
 /*
  * Parse the ACPI tables for possible boot-time SMP configuration.
  */
-    acpi_boot_table_init();
-
 early_acpi_boot_init();

 initmem_init();
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 0bb15ad..7830109 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -7,6 +7,7 @@
  *
*/

+#include 
 #include 
 #include "accommon.h"
 #include "actables.h"
@@ -16,6 +17,33 @@

 
/***
  *
+ * FUNCTION:    acpi_tb_reserve_standard_table
+ *
+ * PARAMETERS:  address - Table physical address
+ *  header  - Table header
+ *
+ * RETURN:  None
+ *
+ * DESCRIPTION: To avoid an acpi table page from bein

Re: [PATCH] mm, kasan: don't poison boot memory

2021-03-01 Thread George Kennedy




On 2/28/2021 1:08 PM, Mike Rapoport wrote:

On Fri, Feb 26, 2021 at 11:16:06AM -0500, George Kennedy wrote:

On 2/26/2021 6:17 AM, Mike Rapoport wrote:

Hi George,

On Thu, Feb 25, 2021 at 08:19:18PM -0500, George Kennedy wrote:

Not sure if it's the right thing to do, but added
"acpi_tb_find_table_address()" to return the physical address of a table to
use with memblock_reserve().

virt_to_phys(table) does not seem to return the physical address for the
iBFT table (it would be nice if struct acpi_table_header also had a
"address" element for the physical address of the table).

virt_to_phys() does not work that early because then it is mapped with
early_memremap()  which uses different virtual to physical scheme.

I'd say that acpi_tb_find_table_address() makes sense if we'd like to
reserve ACPI tables outside of drivers/acpi.

But probably we should simply reserve all the tables during
acpi_table_init() so that any table that firmware put in the normal memory
will be surely reserved.

Ran 10 successful boots with the above without failure.

That's good news indeed :)

Wondering if we could do something like this instead (trying to keep changes
minimal). Just do the memblock_reserve() for all the standard tables.

I think something like this should work, but I'm not an ACPI expert to say
if this the best way to reserve the tables.

Adding ACPI maintainers to the CC list.
  

diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 0bb15ad..830f82c 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -7,6 +7,7 @@
   *
*/

+#include 
  #include 
  #include "accommon.h"
  #include "actables.h"
@@ -14,6 +15,23 @@
  #define _COMPONENT  ACPI_TABLES
  ACPI_MODULE_NAME("tbinstal")

+void
+acpi_tb_reserve_standard_table(acpi_physical_address address,
+               struct acpi_table_header *header)
+{
+    struct acpi_table_header local_header;
+
+    if ((ACPI_COMPARE_NAMESEG(header->signature, ACPI_SIG_FACS)) ||
+        (ACPI_VALIDATE_RSDP_SIG(header->signature))) {
+        return;
+    }
+    /* Standard ACPI table with full common header */
+
+    memcpy(_header, header, sizeof(struct acpi_table_header));
+
+    memblock_reserve(address, PAGE_ALIGN(local_header.length));
+}
+
  
/***
   *
   * FUNCTION:    acpi_tb_install_table_with_override
@@ -58,6 +76,9 @@
                new_table_desc->flags,
                new_table_desc->pointer);

+    acpi_tb_reserve_standard_table(new_table_desc->address,
+                   new_table_desc->pointer);
+
  acpi_tb_print_table_header(new_table_desc->address,
                 new_table_desc->pointer);

There should be no harm in doing the memblock_reserve() for all the standard
tables, right?

It should be ok to memblock_reserve() all the tables very early as long as
we don't run out of static entries in memblock.reserved.

We just need to make sure the tables are reserved before memblock
allocations are possible, so we'd still need to move acpi_table_init() in
x86::setup_arch() before e820__memblock_setup().
Not sure how early ACPI is initialized on arm64.


Thanks Mike. Will try to move the memblock_reserves() before 
e820__memblock_setup().


George
  

Ran 10 boots with the above without failure.

George




Re: [PATCH 2/2] midi streaming substream names from jack names A number of devices have named substreams which are hard to remember / decypher from MIDI n names. Eg. Korg puts a pass through

2021-02-26 Thread George Harker
Thanks for the feedback, addressed in the two patches.  I’m not sure why it 
pulled the body up into the title.I’m sorry about that.  I can resubmit if that 
needs fixing.

George


[PATCH 2/2] midi streaming substream names from jack names A number of devices have named substreams which are hard to remember / decypher from MIDI n names. Eg. Korg puts a pass through on

2021-02-26 Thread George Harker
This makes it easier to connect to the correct device.  Devices which
handle naming through quirks are unaffected by this change.

Addresses TODO comment in sound/usb/midi.c

Signed-off-by: George Harker 
---
 sound/usb/midi.c | 103 ---
 sound/usb/midi.h |   2 +
 2 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 610cf54ee..9efda4b06 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -1740,12 +1740,68 @@ static void snd_usbmidi_get_port_info(struct 
snd_rawmidi *rmidi, int number,
}
 }
 
+static struct usb_midi_in_jack_descriptor *find_usb_in_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_in_jack_descriptor *injd =
+   (struct usb_midi_in_jack_descriptor *)extra;
+
+   if (injd->bLength > 4 &&
+   injd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   injd->bDescriptorSubtype == UAC_MIDI_IN_JACK &&
+   injd->bJackID == jack_id)
+   return injd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
+static struct usb_midi_out_jack_descriptor *find_usb_out_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_out_jack_descriptor *outjd =
+   (struct usb_midi_out_jack_descriptor *)extra;
+
+   if (outjd->bLength > 4 &&
+   outjd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   outjd->bDescriptorSubtype == UAC_MIDI_OUT_JACK &&
+   outjd->bJackID == jack_id)
+   return outjd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
 static void snd_usbmidi_init_substream(struct snd_usb_midi *umidi,
-  int stream, int number,
+  int stream, int number, int jack_id,
   struct snd_rawmidi_substream 
**rsubstream)
 {
struct port_info *port_info;
const char *name_format;
+   struct usb_interface *intf;
+   struct usb_host_interface *hostif;
+   struct usb_midi_in_jack_descriptor *injd;
+   struct usb_midi_out_jack_descriptor *outjd;
+   uint8_t jack_name_buf[32];
+   uint8_t *default_jack_name = "MIDI";
+   uint8_t *jack_name = default_jack_name;
+   uint8_t iJack;
+   size_t sz;
+   int res;
 
struct snd_rawmidi_substream *substream =
snd_usbmidi_find_substream(umidi, stream, number);
@@ -1755,11 +1811,36 @@ static void snd_usbmidi_init_substream(struct 
snd_usb_midi *umidi,
return;
}
 
-   /* TODO: read port name from jack descriptor */
+   intf = umidi->iface;
+   if (intf && jack_id >= 0) {
+   hostif = intf->cur_altsetting;
+   iJack = 0;
+   if (stream != SNDRV_RAWMIDI_STREAM_OUTPUT) {
+   /* in jacks connect to outs */
+   outjd = find_usb_out_jack_descriptor(hostif, jack_id);
+   if (outjd) {
+   sz = USB_DT_MIDI_OUT_SIZE(outjd->bNrInputPins);
+   iJack = *(((uint8_t *) outjd) + sz - 
sizeof(uint8_t));
+   }
+   } else {
+   /* and out jacks connect to ins */
+   injd = find_usb_in_jack_descriptor(hostif, jack_id);
+   if (injd)
+   iJack = injd->iJack;
+   }
+   if (iJack != 0) {
+   res = usb_string(umidi->dev, iJack, jack_name_buf,
+ ARRAY_SIZE(jack_name_buf));
+   if (res)
+   jack_name = jack_name_buf;
+   }
+   }
+
port_info = find_port_info(umidi, number);
-   name_format = port_info ? port_info->name : "%s MIDI %d";
+   name_format = port_info ? port_info->name :
+   (jack_name != default_jack_name  ? "%s %s" : "%s %s %d");
snprintf(substream->name, sizeof(substream->name),
-   

[PATCH 1/2] use usb headers rather than define structs locally

2021-02-26 Thread George Harker
Use struct definitions from linux/usb/midi.h rather than locally define
the structs in sound/usb/midi.c .

Signed-off-by: George Harker 
---
 sound/usb/midi.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 0c23fa6d8..610cf54ee 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -77,23 +78,6 @@ MODULE_AUTHOR("Clemens Ladisch ");
 MODULE_DESCRIPTION("USB Audio/MIDI helper module");
 MODULE_LICENSE("Dual BSD/GPL");
 
-
-struct usb_ms_header_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bcdMSC[2];
-   __le16 wTotalLength;
-} __attribute__ ((packed));
-
-struct usb_ms_endpoint_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bNumEmbMIDIJack;
-   __u8  baAssocJackID[];
-} __attribute__ ((packed));
-
 struct snd_usb_midi_in_endpoint;
 struct snd_usb_midi_out_endpoint;
 struct snd_usb_midi_endpoint;
@@ -1875,7 +1859,7 @@ static int snd_usbmidi_get_ms_info(struct snd_usb_midi 
*umidi,
ms_header->bDescriptorType == USB_DT_CS_INTERFACE &&
ms_header->bDescriptorSubtype == UAC_HEADER)
dev_dbg(>dev->dev, "MIDIStreaming version %02x.%02x\n",
-   ms_header->bcdMSC[1], ms_header->bcdMSC[0]);
+   ((uint8_t *)_header->bcdMSC)[1], ((uint8_t 
*)_header->bcdMSC)[0]);
else
dev_warn(>dev->dev,
 "MIDIStreaming interface descriptor not found\n");
-- 
2.20.1



Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-26 Thread George Kennedy

Hi Mike,

On 2/26/2021 6:17 AM, Mike Rapoport wrote:

Hi George,

On Thu, Feb 25, 2021 at 08:19:18PM -0500, George Kennedy wrote:

Mike,

To get rid of the 0xBE453000 hardcoding, I added the following patch
to your above patch to get the iBFT table "address" to use with
memblock_reserve():

diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 56d81e4..4bc7bf3 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -120,3 +120,34 @@
  (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
  return_ACPI_STATUS(status);
  }
+
+acpi_physical_address
+acpi_tb_find_table_address(char *signature)
+{
+    acpi_physical_address address = 0;
+    struct acpi_table_desc *table_desc;
+    int i;
+
+    ACPI_FUNCTION_TRACE(tb_find_table_address);
+
+printk(KERN_ERR "XXX acpi_tb_find_table_address: signature=%s\n",
signature);
+
+    (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
+    for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
+        if (memcmp(&(acpi_gbl_root_table_list.tables[i].signature),
+               signature, ACPI_NAMESEG_SIZE)) {
+
+            /* Not the requested table */
+
+            continue;
+        }
+
+        /* Table with matching signature has been found */
+        table_desc = _gbl_root_table_list.tables[i];
+        address = table_desc->address;
+    }
+
+    (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
+printk(KERN_ERR "XXX acpi_tb_find_table_address(EXIT): address=%llx\n",
address);
+    return address;
+}
diff --git a/drivers/firmware/iscsi_ibft_find.c
b/drivers/firmware/iscsi_ibft_find.c
index 95fc1a6..0de70b4 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -28,6 +28,8 @@

  #include 

+extern acpi_physical_address acpi_tb_find_table_address(char *signature);
+
  /*
   * Physical location of iSCSI Boot Format Table.
   */
@@ -116,24 +118,32 @@ void __init reserve_ibft_region(void)
  {
  struct acpi_table_ibft *table;
  unsigned long size;
+    acpi_physical_address address;

  table = find_ibft();
  if (!table)
      return;

  size = PAGE_ALIGN(table->header.length);
+    address = acpi_tb_find_table_address(table->header.signature);
  #if 0
  printk(KERN_ERR "XXX reserve_ibft_region: table=%llx,
virt_to_phys(table)=%llx, size=%lx\n",
  (u64)table, virt_to_phys(table), size);
  memblock_reserve(virt_to_phys(table), size);
  #else
-printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, 0xBE453000,
size=%lx\n",
-    (u64)table, size);
-    memblock_reserve(0xBE453000, size);
+printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, address=%llx,
size=%lx\n",
+    (u64)table, address, size);
+    if (address)
+        memblock_reserve(address, size);
+    else
+        printk(KERN_ERR "%s: Can't find table address\n", __func__);
  #endif

-    if (efi_enabled(EFI_BOOT))
+    if (efi_enabled(EFI_BOOT)) {
+printk(KERN_ERR "XXX reserve_ibft_region: calling acpi_put_table(%llx)\n",
(u64)>header);
      acpi_put_table(>header);
-    else
+    } else {
      ibft_addr = table;
+printk(KERN_ERR "XXX reserve_ibft_region: ibft_addr=%llx\n",
(u64)ibft_addr);
+    }
  }

Debug from the above:
[    0.050646] ACPI: Early table checksum verification disabled
[    0.051778] ACPI: RSDP 0xBFBFA014 24 (v02 BOCHS )
[    0.052922] ACPI: XSDT 0xBFBF90E8 4C (v01 BOCHS BXPCFACP
0001  0113)
[    0.054623] ACPI: FACP 0xBFBF5000 74 (v01 BOCHS BXPCFACP
0001 BXPC 0001)
[    0.056326] ACPI: DSDT 0xBFBF6000 00238D (v01 BOCHS BXPCDSDT
0001 BXPC 0001)
[    0.058016] ACPI: FACS 0xBFBFD000 40
[    0.058940] ACPI: APIC 0xBFBF4000 90 (v01 BOCHS BXPCAPIC
0001 BXPC 0001)
[    0.060627] ACPI: HPET 0xBFBF3000 38 (v01 BOCHS BXPCHPET
0001 BXPC 0001)
[    0.062304] ACPI: BGRT 0xBE49B000 38 (v01 INTEL EDK2
0002  0113)
[    0.063987] ACPI: iBFT 0xBE453000 000800 (v01 BOCHS BXPCFACP
  )
[    0.065683] XXX acpi_tb_find_table_address: signature=iBFT
[    0.066754] XXX acpi_tb_find_table_address(EXIT): address=be453000
[    0.067959] XXX reserve_ibft_region: table=ff24,
address=be453000, size=1000
[    0.069534] XXX reserve_ibft_region: calling
acpi_put_table(ff24)

Not sure if it's the right thing to do, but added
"acpi_tb_find_table_address()" to return the physical address of a table to
use with memblock_reserve().

virt_to_phys(table) does not seem to return the physical address for the
iBFT table (it would be nice if struct acpi_table_header also had a
"address" element for the physical address of the table).

virt_to_phys() does not work that early because then it is mapped with
early_memremap()  which uses different virtual to

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 12:33 PM, George Kennedy wrote:



On 2/25/2021 11:07 AM, Mike Rapoport wrote:

On Thu, Feb 25, 2021 at 10:22:44AM -0500, George Kennedy wrote:

On 2/24/2021 5:37 AM, Mike Rapoport wrote:

Applied just your latest patch, but same failure.

I thought there was an earlier comment (which I can't find now) that 
stated
that memblock_reserve() wouldn't reserve the page, which is what's 
needed

here.
Actually, I think that memblock_reserve() should be just fine, but it 
seems

I'm missing something in address calculation each time.

What would happen if you stuck

memblock_reserve(0xbe453000, PAGE_SIZE);

say, at the beginning of find_ibft_region()?


Good news Mike!

The above hack in yesterday's last patch works - 10 successful 
reboots. See: "BE453" below for the hack.


I'll modify the patch to use "table_desc->address" instead, which is 
the physical address of the table.


diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 7bdc023..c118dd5 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
 if (acpi_disabled)
     return;

+#if 0
 /*
  * Initialize the ACPI boot-time table parser.
  */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
     disable_acpi();
     return;
 }
+#endif

 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 740f3bdb..b045ab2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -571,16 +571,6 @@ void __init reserve_standard_io_resources(void)

 }

-static __init void reserve_ibft_region(void)
-{
-    unsigned long addr, size = 0;
-
-    addr = find_ibft_region();
-
-    if (size)
-        memblock_reserve(addr, size);
-}
-
 static bool __init snb_gfx_workaround_needed(void)
 {
 #ifdef CONFIG_PCI
@@ -1033,6 +1023,12 @@ void __init setup_arch(char **cmdline_p)
  */
 find_smp_config();

+    /*
+     * Initialize the ACPI boot-time table parser.
+     */
+    if (acpi_table_init())
+        disable_acpi();
+
 reserve_ibft_region();

 early_alloc_pgt_buf();
diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c

index 64bb945..95fc1a6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@
 #define VGA_MEM 0xA /* VGA buffer */
 #define VGA_SIZE 0x2 /* 128kB */

-static int __init find_ibft_in_mem(void)
+static void __init *acpi_find_ibft_region(void)
+{
+    int i;
+    struct acpi_table_header *table = NULL;
+    acpi_status status;
+
+    if (acpi_disabled)
+        return NULL;
+
+    for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+        status = acpi_get_table(ibft_signs[i].sign, 0, );
+        if (ACPI_SUCCESS(status))
+            return table;
+    }
+
+    return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
 {
 unsigned long pos;
 unsigned int len = 0;
@@ -70,35 +88,52 @@ static int __init find_ibft_in_mem(void)
             /* if the length of the table extends past 1M,
              * the table cannot be valid. */
             if (pos + len <= (IBFT_END-1)) {
-                    ibft_addr = (struct acpi_table_ibft *)virt;
                 pr_info("iBFT found at 0x%lx.\n", pos);
-                    goto done;
+                    return virt;
             }
         }
     }
 }
-done:
-    return len;
+
+    return NULL;
 }
+
+static void __init *find_ibft(void)
+{
+    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+     * only use ACPI for this */
+    if (!efi_enabled(EFI_BOOT))
+        return find_ibft_in_mem();
+    else
+        return acpi_find_ibft_region();
+}
+
 /*
  * Routine used to find the iSCSI Boot Format Table. The logical
  * kernel address is set in the ibft_addr global variable.
  */
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
 {
-    ibft_addr = NULL;
+    struct acpi_table_ibft *table;
+    unsigned long size;

-    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
-     * only use ACPI for this */
+    table = find_ibft();
+    if (!table)
+        return;

-    if (!efi_enabled(EFI_BOOT))
-        find_ibft_in_mem();
-
-    if (ibft_addr) {
-        *sizep = PAGE_ALIGN(ibft_addr->header.length);
-        return (u64)virt_to_phys(ibft_addr);
-    }
+    size = PAGE_ALIGN(table->header.length);
+#if 0
+printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, 
virt_to_phys(table)=%llx, size=%lx\n",

+    (u64)table, virt_to_phys(table), size);
+    memblock_reserve(virt_to_phys(table), size);
+#else
+printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, 
0xBE453000, size=%lx\n",

+    (u64)table, size);
+    memblock_reserve(0xBE453000, size

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 11:07 AM, Mike Rapoport wrote:

On Thu, Feb 25, 2021 at 10:22:44AM -0500, George Kennedy wrote:

On 2/24/2021 5:37 AM, Mike Rapoport wrote:

Applied just your latest patch, but same failure.

I thought there was an earlier comment (which I can't find now) that stated
that memblock_reserve() wouldn't reserve the page, which is what's needed
here.

Actually, I think that memblock_reserve() should be just fine, but it seems
I'm missing something in address calculation each time.

What would happen if you stuck

memblock_reserve(0xbe453000, PAGE_SIZE);

say, at the beginning of find_ibft_region()?


Good news Mike!

The above hack in yesterday's last patch works - 10 successful reboots. 
See: "BE453" below for the hack.


I'll modify the patch to use "table_desc->address" instead, which is the 
physical address of the table.


diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 7bdc023..c118dd5 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
 if (acpi_disabled)
     return;

+#if 0
 /*
  * Initialize the ACPI boot-time table parser.
  */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
     disable_acpi();
     return;
 }
+#endif

 acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 740f3bdb..b045ab2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -571,16 +571,6 @@ void __init reserve_standard_io_resources(void)

 }

-static __init void reserve_ibft_region(void)
-{
-    unsigned long addr, size = 0;
-
-    addr = find_ibft_region();
-
-    if (size)
-        memblock_reserve(addr, size);
-}
-
 static bool __init snb_gfx_workaround_needed(void)
 {
 #ifdef CONFIG_PCI
@@ -1033,6 +1023,12 @@ void __init setup_arch(char **cmdline_p)
  */
 find_smp_config();

+    /*
+     * Initialize the ACPI boot-time table parser.
+     */
+    if (acpi_table_init())
+        disable_acpi();
+
 reserve_ibft_region();

 early_alloc_pgt_buf();
diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c

index 64bb945..95fc1a6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@
 #define VGA_MEM 0xA /* VGA buffer */
 #define VGA_SIZE 0x2 /* 128kB */

-static int __init find_ibft_in_mem(void)
+static void __init *acpi_find_ibft_region(void)
+{
+    int i;
+    struct acpi_table_header *table = NULL;
+    acpi_status status;
+
+    if (acpi_disabled)
+        return NULL;
+
+    for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+        status = acpi_get_table(ibft_signs[i].sign, 0, );
+        if (ACPI_SUCCESS(status))
+            return table;
+    }
+
+    return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
 {
 unsigned long pos;
 unsigned int len = 0;
@@ -70,35 +88,52 @@ static int __init find_ibft_in_mem(void)
             /* if the length of the table extends past 1M,
              * the table cannot be valid. */
             if (pos + len <= (IBFT_END-1)) {
-                    ibft_addr = (struct acpi_table_ibft *)virt;
                 pr_info("iBFT found at 0x%lx.\n", pos);
-                    goto done;
+                    return virt;
             }
         }
     }
 }
-done:
-    return len;
+
+    return NULL;
 }
+
+static void __init *find_ibft(void)
+{
+    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+     * only use ACPI for this */
+    if (!efi_enabled(EFI_BOOT))
+        return find_ibft_in_mem();
+    else
+        return acpi_find_ibft_region();
+}
+
 /*
  * Routine used to find the iSCSI Boot Format Table. The logical
  * kernel address is set in the ibft_addr global variable.
  */
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
 {
-    ibft_addr = NULL;
+    struct acpi_table_ibft *table;
+    unsigned long size;

-    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
-     * only use ACPI for this */
+    table = find_ibft();
+    if (!table)
+        return;

-    if (!efi_enabled(EFI_BOOT))
-        find_ibft_in_mem();
-
-    if (ibft_addr) {
-        *sizep = PAGE_ALIGN(ibft_addr->header.length);
-        return (u64)virt_to_phys(ibft_addr);
-    }
+    size = PAGE_ALIGN(table->header.length);
+#if 0
+printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, 
virt_to_phys(table)=%llx, size=%lx\n",

+    (u64)table, virt_to_phys(table), size);
+    memblock_reserve(virt_to_phys(table), size);
+#else
+printk(KERN_ERR "XXX reserve_ibft_region: table=%llx, 
0xBE453000, size=%lx\n",

+    (u64)table, size);
+    memblock_reserve(0xBE453000, size);
+#endif

-    *sizep = 0;
-    return 0;
+    if (efi_enabled(

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 11:07 AM, Mike Rapoport wrote:

On Thu, Feb 25, 2021 at 10:22:44AM -0500, George Kennedy wrote:

On 2/24/2021 5:37 AM, Mike Rapoport wrote:

Applied just your latest patch, but same failure.

I thought there was an earlier comment (which I can't find now) that stated
that memblock_reserve() wouldn't reserve the page, which is what's needed
here.

Actually, I think that memblock_reserve() should be just fine, but it seems
I'm missing something in address calculation each time.

What would happen if you stuck

memblock_reserve(0xbe453000, PAGE_SIZE);

say, at the beginning of find_ibft_region()?


Added debug to your patch and this is all that shows up. Looks like the 
patch is in the wrong place as acpi_tb_parse_root_table() is only called 
for the RSDP address.


[    0.064317] ACPI: Early table checksum verification disabled
[    0.065437] XXX acpi_tb_parse_root_table: rsdp_address=bfbfa014
[    0.066612] ACPI: RSDP 0xBFBFA014 24 (v02 BOCHS )
[    0.067759] ACPI: XSDT 0xBFBF90E8 4C (v01 BOCHS BXPCFACP 
0001  0113)
[    0.069470] ACPI: FACP 0xBFBF5000 74 (v01 BOCHS BXPCFACP 
0001 BXPC 0001)
[    0.071183] ACPI: DSDT 0xBFBF6000 00238D (v01 BOCHS BXPCDSDT 
0001 BXPC 0001)

[    0.072876] ACPI: FACS 0xBFBFD000 40
[    0.073806] ACPI: APIC 0xBFBF4000 90 (v01 BOCHS BXPCAPIC 
0001 BXPC 0001)
[    0.075501] ACPI: HPET 0xBFBF3000 38 (v01 BOCHS BXPCHPET 
0001 BXPC 0001)
[    0.077194] ACPI: BGRT 0xBE49B000 38 (v01 INTEL EDK2 
0002  0113)
[    0.078880] ACPI: iBFT 0xBE453000 000800 (v01 BOCHS BXPCFACP 
  )

[    0.080588] ACPI: Local APIC address 0xfee0

diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index dfe1ac3..603b3a8 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -7,6 +7,8 @@
  *
*/

+#include 
+
 #include 
 #include "accommon.h"
 #include "actables.h"
@@ -232,6 +234,8 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 
table_index)

 acpi_status status;
 u32 table_index;

+printk(KERN_ERR "XXX acpi_tb_parse_root_table: rsdp_address=%llx\n", 
rsdp_address);

+
 ACPI_FUNCTION_TRACE(tb_parse_root_table);

 /* Map the entire RSDP and extract the address of the RSDT or XSDT */
@@ -339,6 +343,22 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 
table_index)

         acpi_tb_parse_fadt();
     }

+        if (ACPI_SUCCESS(status) &&
+            ACPI_COMPARE_NAMESEG(_gbl_root_table_list.
+                     tables[table_index].signature,
+                     ACPI_SIG_IBFT)) {
+            struct acpi_table_header *ibft;
+            struct acpi_table_desc *desc;
+
+            desc = _gbl_root_table_list.tables[table_index];
+            status = acpi_tb_get_table(desc, );
+            if (ACPI_SUCCESS(status)) {
+printk(KERN_ERR "XXX acpi_tb_parse_root_table(calling 
memblock_reserve()): addres=%llx, ibft->length=%x\n", address, 
ibft->length);

+                memblock_reserve(address, ibft->length);
+                acpi_tb_put_table(desc);
+            }
+        }
+
 next_table:

     table_entry += table_entry_size;


  

[   30.308229] iBFT detected..
[   30.308796]
==
[   30.308890] BUG: KASAN: use-after-free in ibft_init+0x134/0xc33
[   30.308890] Read of size 4 at addr 8880be453004 by task swapper/0/1
[   30.308890]
[   30.308890] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.11.0-f9593a0 #12
[   30.308890] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
0.0.0 02/06/2015
[   30.308890] Call Trace:
[   30.308890]  dump_stack+0xdb/0x120
[   30.308890]  ? ibft_init+0x134/0xc33
[   30.308890]  print_address_description.constprop.7+0x41/0x60
[   30.308890]  ? ibft_init+0x134/0xc33
[   30.308890]  ? ibft_init+0x134/0xc33
[   30.308890]  kasan_report.cold.10+0x78/0xd1
[   30.308890]  ? ibft_init+0x134/0xc33
[   30.308890]  __asan_report_load_n_noabort+0xf/0x20
[   30.308890]  ibft_init+0x134/0xc33
[   30.308890]  ? write_comp_data+0x2f/0x90
[   30.308890]  ? ibft_check_initiator_for+0x159/0x159
[   30.308890]  ? write_comp_data+0x2f/0x90
[   30.308890]  ? ibft_check_initiator_for+0x159/0x159
[   30.308890]  do_one_initcall+0xc4/0x3e0
[   30.308890]  ? perf_trace_initcall_level+0x3e0/0x3e0
[   30.308890]  ? unpoison_range+0x14/0x40
[   30.308890]  ? kasan_kmalloc.constprop.5+0x8f/0xc0
[   30.308890]  ? kernel_init_freeable+0x420/0x652
[   30.308890]  ? __kasan_kmalloc+0x9/0x10
[   30.308890]  ? __sanitizer_cov_trace_pc+0x21/0x50
[   30.308890]  kernel_init_freeable+0x596/0x652
[   30.308890]  ? console_on_rootfs+0x7d/0x7d
[   30.308890]  ? __sanitizer_cov_trace_pc+0x21/0x50
[   30.308890]  ? r

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 10:22 AM, George Kennedy wrote:



On 2/25/2021 9:57 AM, Mike Rapoport wrote:

On Thu, Feb 25, 2021 at 07:38:19AM -0500, George Kennedy wrote:

On 2/25/2021 3:53 AM, Mike Rapoport wrote:

Hi George,


On 2/24/2021 5:37 AM, Mike Rapoport wrote:

On Tue, Feb 23, 2021 at 04:46:28PM -0500, George Kennedy wrote:

Mike,

Still no luck.

[   30.193723] iscsi: registered transport (iser)
[   30.195970] iBFT detected.
[   30.196571] BUG: unable to handle page fault for address: 
ff240004

Hmm, we cannot set ibft_addr to early pointer to the ACPI table.
Let's try something more disruptive and move the reservation back to
iscsi_ibft_find.c.

diff --git a/arch/x86/kernel/acpi/boot.c 
b/arch/x86/kernel/acpi/boot.c

index 7bdc0239a943..c118dd54a747 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
    if (acpi_disabled)
    return;
+#if 0
    /*
 * Initialize the ACPI boot-time table parser.
 */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
    disable_acpi();
    return;
    }
+#endif
    acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d883176ef2ce..c615ce96c9a2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -570,16 +570,6 @@ void __init reserve_standard_io_resources(void)
    }
-static __init void reserve_ibft_region(void)
-{
-    unsigned long addr, size = 0;
-
-    addr = find_ibft_region();
-
-    if (size)
-    memblock_reserve(addr, size);
-}
-
    static bool __init snb_gfx_workaround_needed(void)
    {
    #ifdef CONFIG_PCI
@@ -1032,6 +1022,12 @@ void __init setup_arch(char **cmdline_p)
 */
    find_smp_config();
+    /*
+ * Initialize the ACPI boot-time table parser.
+ */
+    if (acpi_table_init())
+    disable_acpi();
+
    reserve_ibft_region();
    early_alloc_pgt_buf();
diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c

index 64bb94523281..01be513843d6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@ static const struct {
    #define VGA_MEM 0xA /* VGA buffer */
    #define VGA_SIZE 0x2 /* 128kB */
-static int __init find_ibft_in_mem(void)
+static void __init *acpi_find_ibft_region(void)
+{
+    int i;
+    struct acpi_table_header *table = NULL;
+    acpi_status status;
+
+    if (acpi_disabled)
+    return NULL;
+
+    for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+    status = acpi_get_table(ibft_signs[i].sign, 0, );
+    if (ACPI_SUCCESS(status))
+    return table;
+    }
+
+    return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
    {
    unsigned long pos;
    unsigned int len = 0;
@@ -70,35 +88,44 @@ static int __init find_ibft_in_mem(void)
    /* if the length of the table extends past 1M,
 * the table cannot be valid. */
    if (pos + len <= (IBFT_END-1)) {
-    ibft_addr = (struct acpi_table_ibft *)virt;
    pr_info("iBFT found at 0x%lx.\n", pos);
-    goto done;
+    return virt;
    }
    }
    }
    }
-done:
-    return len;
+
+    return NULL;
    }
+
+static void __init *find_ibft(void)
+{
+    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+ * only use ACPI for this */
+    if (!efi_enabled(EFI_BOOT))
+    return find_ibft_in_mem();
+    else
+    return acpi_find_ibft_region();
+}
+
    /*
 * Routine used to find the iSCSI Boot Format Table. The logical
 * kernel address is set in the ibft_addr global variable.
 */
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
    {
-    ibft_addr = NULL;
+    struct acpi_table_ibft *table;
+    unsigned long size;
-    /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
- * only use ACPI for this */
+    table = find_ibft();
+    if (!table)
+    return;
-    if (!efi_enabled(EFI_BOOT))
-    find_ibft_in_mem();
-
-    if (ibft_addr) {
-    *sizep = PAGE_ALIGN(ibft_addr->header.length);
-    return (u64)virt_to_phys(ibft_addr);
-    }
+    size = PAGE_ALIGN(table->header.length);
+    memblock_reserve(virt_to_phys(table), size);
-    *sizep = 0;
-    return 0;
+    if (efi_enabled(EFI_BOOT))
+    acpi_put_table(>header);
+    else
+    ibft_addr = table;
    }
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
index b7b45ca82bea..da813c891990 100644
--- a/include/linux/iscsi_ibft.h
+++ b/include/linux/iscsi_ibft.h
@@ -26,13 +26,9 @@ extern struct acpi_table_ibft *ibft_addr;
 * mapped address is set in the ibft_addr variable.
 */
    #ifdef CONF

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 9:57 AM, Mike Rapoport wrote:

On Thu, Feb 25, 2021 at 07:38:19AM -0500, George Kennedy wrote:

On 2/25/2021 3:53 AM, Mike Rapoport wrote:

Hi George,


On 2/24/2021 5:37 AM, Mike Rapoport wrote:

On Tue, Feb 23, 2021 at 04:46:28PM -0500, George Kennedy wrote:

Mike,

Still no luck.

[   30.193723] iscsi: registered transport (iser)
[   30.195970] iBFT detected.
[   30.196571] BUG: unable to handle page fault for address: ff240004

Hmm, we cannot set ibft_addr to early pointer to the ACPI table.
Let's try something more disruptive and move the reservation back to
iscsi_ibft_find.c.

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 7bdc0239a943..c118dd54a747 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
if (acpi_disabled)
return;
+#if 0
/*
 * Initialize the ACPI boot-time table parser.
 */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
disable_acpi();
return;
}
+#endif
acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d883176ef2ce..c615ce96c9a2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -570,16 +570,6 @@ void __init reserve_standard_io_resources(void)
}
-static __init void reserve_ibft_region(void)
-{
-   unsigned long addr, size = 0;
-
-   addr = find_ibft_region();
-
-   if (size)
-   memblock_reserve(addr, size);
-}
-
static bool __init snb_gfx_workaround_needed(void)
{
#ifdef CONFIG_PCI
@@ -1032,6 +1022,12 @@ void __init setup_arch(char **cmdline_p)
 */
find_smp_config();
+   /*
+* Initialize the ACPI boot-time table parser.
+*/
+   if (acpi_table_init())
+   disable_acpi();
+
reserve_ibft_region();
early_alloc_pgt_buf();
diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c
index 64bb94523281..01be513843d6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@ static const struct {
#define VGA_MEM 0xA /* VGA buffer */
#define VGA_SIZE 0x2 /* 128kB */
-static int __init find_ibft_in_mem(void)
+static void __init *acpi_find_ibft_region(void)
+{
+   int i;
+   struct acpi_table_header *table = NULL;
+   acpi_status status;
+
+   if (acpi_disabled)
+   return NULL;
+
+   for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+   status = acpi_get_table(ibft_signs[i].sign, 0, );
+   if (ACPI_SUCCESS(status))
+   return table;
+   }
+
+   return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
{
unsigned long pos;
unsigned int len = 0;
@@ -70,35 +88,44 @@ static int __init find_ibft_in_mem(void)
/* if the length of the table extends past 1M,
 * the table cannot be valid. */
if (pos + len <= (IBFT_END-1)) {
-   ibft_addr = (struct acpi_table_ibft 
*)virt;
pr_info("iBFT found at 0x%lx.\n", pos);
-   goto done;
+   return virt;
}
}
}
}
-done:
-   return len;
+
+   return NULL;
}
+
+static void __init *find_ibft(void)
+{
+   /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+* only use ACPI for this */
+   if (!efi_enabled(EFI_BOOT))
+   return find_ibft_in_mem();
+   else
+   return acpi_find_ibft_region();
+}
+
/*
 * Routine used to find the iSCSI Boot Format Table. The logical
 * kernel address is set in the ibft_addr global variable.
 */
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
{
-   ibft_addr = NULL;
+   struct acpi_table_ibft *table;
+   unsigned long size;
-   /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
-* only use ACPI for this */
+   table = find_ibft();
+   if (!table)
+   return;
-   if (!efi_enabled(EFI_BOOT))
-   find_ibft_in_mem();
-
-   if (ibft_addr) {
-   *sizep = PAGE_ALIGN(ibft_addr->header.length);
-   return (u64)virt_to_phys(ibft_addr);
-   }
+   size = PAGE_ALIGN(table->header.length);
+   memblock_reserve(virt_to_phys(table), size);
-   *sizep = 0;
-   return 0;
+   if (efi_enabled(EFI_BOOT))
+   acpi_put_table(>header);
+   else
+   ibft_addr = table;
}
diff --git a/inc

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-25 Thread George Kennedy




On 2/25/2021 3:53 AM, Mike Rapoport wrote:

Hi George,


On 2/24/2021 5:37 AM, Mike Rapoport wrote:

On Tue, Feb 23, 2021 at 04:46:28PM -0500, George Kennedy wrote:

Mike,

Still no luck.

[   30.193723] iscsi: registered transport (iser)
[   30.195970] iBFT detected.
[   30.196571] BUG: unable to handle page fault for address: ff240004

Hmm, we cannot set ibft_addr to early pointer to the ACPI table.
Let's try something more disruptive and move the reservation back to
iscsi_ibft_find.c.

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 7bdc0239a943..c118dd54a747 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
if (acpi_disabled)
return;
+#if 0
/*
 * Initialize the ACPI boot-time table parser.
 */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
disable_acpi();
return;
}
+#endif
acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d883176ef2ce..c615ce96c9a2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -570,16 +570,6 @@ void __init reserve_standard_io_resources(void)
   }
-static __init void reserve_ibft_region(void)
-{
-   unsigned long addr, size = 0;
-
-   addr = find_ibft_region();
-
-   if (size)
-   memblock_reserve(addr, size);
-}
-
   static bool __init snb_gfx_workaround_needed(void)
   {
   #ifdef CONFIG_PCI
@@ -1032,6 +1022,12 @@ void __init setup_arch(char **cmdline_p)
 */
find_smp_config();
+   /*
+* Initialize the ACPI boot-time table parser.
+*/
+   if (acpi_table_init())
+   disable_acpi();
+
reserve_ibft_region();
early_alloc_pgt_buf();
diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c
index 64bb94523281..01be513843d6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@ static const struct {
   #define VGA_MEM 0xA /* VGA buffer */
   #define VGA_SIZE 0x2 /* 128kB */
-static int __init find_ibft_in_mem(void)
+static void __init *acpi_find_ibft_region(void)
+{
+   int i;
+   struct acpi_table_header *table = NULL;
+   acpi_status status;
+
+   if (acpi_disabled)
+   return NULL;
+
+   for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+   status = acpi_get_table(ibft_signs[i].sign, 0, );
+   if (ACPI_SUCCESS(status))
+   return table;
+   }
+
+   return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
   {
unsigned long pos;
unsigned int len = 0;
@@ -70,35 +88,44 @@ static int __init find_ibft_in_mem(void)
/* if the length of the table extends past 1M,
 * the table cannot be valid. */
if (pos + len <= (IBFT_END-1)) {
-   ibft_addr = (struct acpi_table_ibft 
*)virt;
pr_info("iBFT found at 0x%lx.\n", pos);
-   goto done;
+   return virt;
}
}
}
}
-done:
-   return len;
+
+   return NULL;
   }
+
+static void __init *find_ibft(void)
+{
+   /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+* only use ACPI for this */
+   if (!efi_enabled(EFI_BOOT))
+   return find_ibft_in_mem();
+   else
+   return acpi_find_ibft_region();
+}
+
   /*
* Routine used to find the iSCSI Boot Format Table. The logical
* kernel address is set in the ibft_addr global variable.
*/
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
   {
-   ibft_addr = NULL;
+   struct acpi_table_ibft *table;
+   unsigned long size;
-   /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
-* only use ACPI for this */
+   table = find_ibft();
+   if (!table)
+   return;
-   if (!efi_enabled(EFI_BOOT))
-   find_ibft_in_mem();
-
-   if (ibft_addr) {
-   *sizep = PAGE_ALIGN(ibft_addr->header.length);
-   return (u64)virt_to_phys(ibft_addr);
-   }
+   size = PAGE_ALIGN(table->header.length);
+   memblock_reserve(virt_to_phys(table), size);
-   *sizep = 0;
-   return 0;
+   if (efi_enabled(EFI_BOOT))
+   acpi_put_table(>header);
+   else
+   ibft_addr = table;
   }
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
index b7b45ca82bea..da813c891990 100644
--- a/include/linux/iscsi_ibft.h

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-24 Thread George Kennedy




On 2/24/2021 5:37 AM, Mike Rapoport wrote:

On Tue, Feb 23, 2021 at 04:46:28PM -0500, George Kennedy wrote:

Mike,

Still no luck.

[   30.193723] iscsi: registered transport (iser)
[   30.195970] iBFT detected.
[   30.196571] BUG: unable to handle page fault for address: ff240004

Hmm, we cannot set ibft_addr to early pointer to the ACPI table.
Let's try something more disruptive and move the reservation back to
iscsi_ibft_find.c.

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 7bdc0239a943..c118dd54a747 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1551,6 +1551,7 @@ void __init acpi_boot_table_init(void)
if (acpi_disabled)
return;
  
+#if 0

/*
 * Initialize the ACPI boot-time table parser.
 */
@@ -1558,6 +1559,7 @@ void __init acpi_boot_table_init(void)
disable_acpi();
return;
}
+#endif
  
  	acpi_table_parse(ACPI_SIG_BOOT, acpi_parse_sbf);
  
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c

index d883176ef2ce..c615ce96c9a2 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -570,16 +570,6 @@ void __init reserve_standard_io_resources(void)
  
  }
  
-static __init void reserve_ibft_region(void)

-{
-   unsigned long addr, size = 0;
-
-   addr = find_ibft_region();
-
-   if (size)
-   memblock_reserve(addr, size);
-}
-
  static bool __init snb_gfx_workaround_needed(void)
  {
  #ifdef CONFIG_PCI
@@ -1032,6 +1022,12 @@ void __init setup_arch(char **cmdline_p)
 */
find_smp_config();
  
+	/*

+* Initialize the ACPI boot-time table parser.
+*/
+   if (acpi_table_init())
+   disable_acpi();
+
reserve_ibft_region();
  
  	early_alloc_pgt_buf();

diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c
index 64bb94523281..01be513843d6 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -47,7 +47,25 @@ static const struct {
  #define VGA_MEM 0xA /* VGA buffer */
  #define VGA_SIZE 0x2 /* 128kB */
  
-static int __init find_ibft_in_mem(void)

+static void __init *acpi_find_ibft_region(void)
+{
+   int i;
+   struct acpi_table_header *table = NULL;
+   acpi_status status;
+
+   if (acpi_disabled)
+   return NULL;
+
+   for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+   status = acpi_get_table(ibft_signs[i].sign, 0, );
+   if (ACPI_SUCCESS(status))
+   return table;
+   }
+
+   return NULL;
+}
+
+static void __init *find_ibft_in_mem(void)
  {
unsigned long pos;
unsigned int len = 0;
@@ -70,35 +88,44 @@ static int __init find_ibft_in_mem(void)
/* if the length of the table extends past 1M,
 * the table cannot be valid. */
if (pos + len <= (IBFT_END-1)) {
-   ibft_addr = (struct acpi_table_ibft 
*)virt;
pr_info("iBFT found at 0x%lx.\n", pos);
-   goto done;
+   return virt;
}
}
}
}
-done:
-   return len;
+
+   return NULL;
  }
+
+static void __init *find_ibft(void)
+{
+   /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
+* only use ACPI for this */
+   if (!efi_enabled(EFI_BOOT))
+   return find_ibft_in_mem();
+   else
+   return acpi_find_ibft_region();
+}
+
  /*
   * Routine used to find the iSCSI Boot Format Table. The logical
   * kernel address is set in the ibft_addr global variable.
   */
-unsigned long __init find_ibft_region(unsigned long *sizep)
+void __init reserve_ibft_region(void)
  {
-   ibft_addr = NULL;
+   struct acpi_table_ibft *table;
+   unsigned long size;
  
-	/* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will

-* only use ACPI for this */
+   table = find_ibft();
+   if (!table)
+   return;
  
-	if (!efi_enabled(EFI_BOOT))

-   find_ibft_in_mem();
-
-   if (ibft_addr) {
-   *sizep = PAGE_ALIGN(ibft_addr->header.length);
-   return (u64)virt_to_phys(ibft_addr);
-   }
+   size = PAGE_ALIGN(table->header.length);
+   memblock_reserve(virt_to_phys(table), size);
  
-	*sizep = 0;

-   return 0;
+   if (efi_enabled(EFI_BOOT))
+   acpi_put_table(>header);
+   else
+   ibft_addr = table;
  }
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
index b7b45ca82bea..da813c891990 100644
--- a/include/linux/iscsi_ibft.h
+++ b/include/linux/iscsi_ibft.h
@@ -26,13 +26,9 @@ extern 

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-23 Thread George Kennedy
3e0/0x3e0
[   30.196824]  ? asm_sysvec_error_interrupt+0x10/0x20
[   30.196824]  ? do_one_initcall+0x18c/0x3e0
[   30.196824]  kernel_init_freeable+0x596/0x652
[   30.196824]  ? console_on_rootfs+0x7d/0x7d
[   30.196824]  ? __sanitizer_cov_trace_pc+0x21/0x50
[   30.196824]  ? rest_init+0xf0/0xf0
[   30.196824]  kernel_init+0x16/0x1d0
[   30.196824]  ? rest_init+0xf0/0xf0
[   30.196824]  ret_from_fork+0x22/0x30
[   30.196824] Modules linked in:
[   30.196824] Dumping ftrace buffer:
[   30.196824]    (ftrace buffer empty)
[   30.196824] CR2: ff240004
[   30.196824] ---[ end trace 293eae51adac1398 ]---
[   30.196824] RIP: 0010:ibft_init+0x13d/0xc33
[   30.196824] Code: c1 40 84 ce 75 11 83 e0 07 38 c2 0f 9e c1 84 d2 0f 
95 c0 84 c1 74 0a be 04 00 00 00 e8 77 f2 5f ef 49 8d 7f 08 b8 ff ff 37 
00 <4d> 63 6f 04 48 89 fa 48 c1 e0 2a 48 c1 ea 03 8a 04 02 48 89 fa 83

[   30.196824] RSP: :888100fafc30 EFLAGS: 00010246
[   30.196824] RAX: 0037 RBX: 937c6fc0 RCX: 
815fcf01
[   30.196824] RDX: dc00 RSI: 0001 RDI: 
ff240008
[   30.196824] RBP: 888100fafcf8 R08: ed10201f5f12 R09: 
ed10201f5f12
[   30.196824] R10: 888100faf88f R11: ed10201f5f11 R12: 
dc00
[   30.196824] R13: 888100fafdc0 R14: 888100fafcd0 R15: 
ff24
[   30.196824] FS:  () GS:88810ad8() 
knlGS:

[   30.196824] CS:  0010 DS:  ES:  CR0: 80050033
[   30.196824] CR2: ff240004 CR3: 24e3 CR4: 
06e0
[   30.196824] DR0:  DR1:  DR2: 

[   30.196824] DR3:  DR6: fffe0ff0 DR7: 
0400

[   30.196824] Kernel panic - not syncing: Fatal exception
[   30.196824] Dumping ftrace buffer:
[   30.196824]    (ftrace buffer empty)
[   30.196824] Kernel Offset: disabled
[   30.196824] Rebooting in 1 seconds..

George


Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-23 Thread George Kennedy




On 2/23/2021 3:09 PM, Mike Rapoport wrote:

On Tue, Feb 23, 2021 at 01:05:05PM -0500, George Kennedy wrote:

On 2/23/2021 10:47 AM, Mike Rapoport wrote:

It now crashes here:

[    0.051019] ACPI: Early table checksum verification disabled
[    0.056721] ACPI: RSDP 0xBFBFA014 24 (v02 BOCHS )
[    0.057874] ACPI: XSDT 0xBFBF90E8 4C (v01 BOCHS BXPCFACP
0001  0113)
[    0.059590] ACPI: FACP 0xBFBF5000 74 (v01 BOCHS BXPCFACP
0001 BXPC 0001)
[    0.061306] ACPI: DSDT 0xBFBF6000 00238D (v01 BOCHS BXPCDSDT
0001 BXPC 0001)
[    0.063006] ACPI: FACS 0xBFBFD000 40
[    0.063938] ACPI: APIC 0xBFBF4000 90 (v01 BOCHS BXPCAPIC
0001 BXPC 0001)
[    0.065638] ACPI: HPET 0xBFBF3000 38 (v01 BOCHS BXPCHPET
0001 BXPC 0001)
[    0.067335] ACPI: BGRT 0xBE49B000 38 (v01 INTEL EDK2
0002  0113)
[    0.069030] ACPI: iBFT 0xBE453000 000800 (v01 BOCHS BXPCFACP
  )
[    0.070734] XXX acpi_find_ibft_region:
[    0.071468] XXX iBFT, status=0
[    0.072073] XXX about to call acpi_put_table()...
ibft_addr=ff24
[    0.073449] XXX acpi_find_ibft_region(EXIT):
PANIC: early exception 0x0e IP 10:9259f439 error 0 cr2
0xff240004

Right, I've missed the dereference of the ibft_addr after
acpi_find_ibft_region().

With this change to iscsi_ibft_find.c instead of the previous one it should
be better:

diff --git a/drivers/firmware/iscsi_ibft_find.c 
b/drivers/firmware/iscsi_ibft_find.c
index 64bb94523281..1be7481d5c69 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -80,6 +80,27 @@ static int __init find_ibft_in_mem(void)
  done:
return len;
  }
+
+static void __init acpi_find_ibft_region(unsigned long *sizep)
+{
+   int i;
+   struct acpi_table_header *table = NULL;
+   acpi_status status;
+
+   if (acpi_disabled)
+   return;
+
+   for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+   status = acpi_get_table(ibft_signs[i].sign, 0, );
+   if (ACPI_SUCCESS(status)) {
+   ibft_addr = (struct acpi_table_ibft *)table;
+   *sizep = PAGE_ALIGN(ibft_addr->header.length);
+   acpi_put_table(table);
+   break;
+   }
+   }
+}
+
  /*
   * Routine used to find the iSCSI Boot Format Table. The logical
   * kernel address is set in the ibft_addr global variable.
@@ -91,14 +112,16 @@ unsigned long __init find_ibft_region(unsigned long *sizep)
/* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will
 * only use ACPI for this */
  
-	if (!efi_enabled(EFI_BOOT))

+   if (!efi_enabled(EFI_BOOT)) {
find_ibft_in_mem();
-
-   if (ibft_addr) {
*sizep = PAGE_ALIGN(ibft_addr->header.length);
-   return (u64)virt_to_phys(ibft_addr);
+   } else {
+   acpi_find_ibft_region(sizep);
}
  
+	if (ibft_addr)

+   return (u64)virt_to_phys(ibft_addr);
+
*sizep = 0;
return 0;
  }

Mike,

No luck. Back to the original KASAN ibft_init crash.

I ran with only the above patch from you. Was that what you wanted? Your 
previous patch had a section defined out by #if 0. Was that supposed to 
be in there as well?


If you need the console output let me know. Got bounced because it was 
too large.


[   30.124650] iBFT detected.
[   30.125228] 
==

[   30.126201] BUG: KASAN: use-after-free in ibft_init+0x134/0xc33
[   30.126201] Read of size 4 at addr 8880be453004 by task swapper/0/1
[   30.126201]
[   30.126201] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.11.0-f9593a0 #9
[   30.126201] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
BIOS 0.0.0 02/06/2015

[   30.126201] Call Trace:
[   30.126201]  dump_stack+0xdb/0x120
[   30.126201]  ? ibft_init+0x134/0xc33
[   30.126201]  print_address_description.constprop.7+0x41/0x60
[   30.126201]  ? ibft_init+0x134/0xc33
[   30.126201]  ? ibft_init+0x134/0xc33
[   30.126201]  kasan_report.cold.10+0x78/0xd1
[   30.126201]  ? ibft_init+0x134/0xc33
[   30.126201]  __asan_report_load_n_noabort+0xf/0x20
[   30.126201]  ibft_init+0x134/0xc33
[   30.126201]  ? write_comp_data+0x2f/0x90
[   30.126201]  ? ibft_check_initiator_for+0x159/0x159
[   30.126201]  ? write_comp_data+0x2f/0x90
[   30.126201]  ? ibft_check_initiator_for+0x159/0x159
[   30.126201]  do_one_initcall+0xc4/0x3e0
[   30.126201]  ? perf_trace_initcall_level+0x3e0/0x3e0
[   30.126201]  ? unpoison_range+0x14/0x40
[   30.126201]  ? kasan_kmalloc.constprop.5+0x8f/0xc0
[   30.126201]  ? kernel_init_freeable+0x420/0x652
[   30.126201]  ? __kasan_kmalloc+0x9/0x10
[   30.126201]  ? __sanitizer_cov_trace_pc+0x21/0x50
[   30.126201]  kernel_init_freeable+0x596/0x

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-23 Thread George Kennedy




On 2/23/2021 10:47 AM, Mike Rapoport wrote:

Hi George,

On Tue, Feb 23, 2021 at 09:35:32AM -0500, George Kennedy wrote:

On 2/23/2021 5:33 AM, Mike Rapoport wrote:

(re-added CC)

On Mon, Feb 22, 2021 at 08:24:59PM -0500, George Kennedy wrote:

On 2/22/2021 4:55 PM, Mike Rapoport wrote:

On Mon, Feb 22, 2021 at 01:42:56PM -0500, George Kennedy wrote:

On 2/22/2021 11:13 AM, David Hildenbrand wrote:

On 22.02.21 16:13, George Kennedy wrote:

The PFN 0xbe453 looks a little strange, though. Do we expect ACPI tables
close to 3 GiB ? No idea. Could it be that you are trying to map a wrong
table? Just a guess.


What would be  the correct way to reserve the page so that the above
would not be hit?

I would have assumed that if this is a binary blob, that someone (which
I think would be acpi code) reserved via memblock_reserve() early during
boot.

E.g., see drivers/acpi/tables.c:acpi_table_upgrade()->memblock_reserve().

acpi_table_upgrade() gets called, but bails out before memblock_reserve() is
called. Thus, it appears no pages are getting reserved.

acpi_table_upgrade() does not actually reserve memory but rather open
codes memblock allocation with memblock_find_in_range() +
memblock_reserve(), so it does not seem related anyway.

Do you have by chance a full boot log handy?

Hello Mike,

Are you after the console output? See attached.

It includes my patch to set PG_Reserved along with the dump_page() debug
that David asked for - see: "page:"

So, iBFT is indeed at pfn 0xbe453:

[0.077698] ACPI: iBFT 0xBE453000 000800 (v01 BOCHS  BXPCFACP 
  )
and it's in E820_TYPE_RAM region rather than in ACPI data:

[0.00] BIOS-e820: [mem 0x0081-0x008f] ACPI NVS
[0.00] BIOS-e820: [mem 0x0090-0xbe49afff] usable
[0.00] BIOS-e820: [mem 0xbe49b000-0xbe49bfff] ACPI data

I could not find anywhere in x86 setup or in ACPI tables parsing the code
that reserves this memory or any other ACPI data for that matter. It could
be that I've missed some copying of the data to statically allocated
initial_tables, but AFAICS any ACPI data that was not marked as such in
e820 tables by BIOS resides in memory that is considered as free.


Close...

Applied the patch, see "[   30.136157] iBFT detected.", but now hit the
following (missing iounmap()? see full console output attached):

diff --git a/drivers/firmware/iscsi_ibft_find.c
b/drivers/firmware/iscsi_ibft_find.c
index 64bb945..2e5e040 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -80,6 +80,21 @@ static int __init find_ibft_in_mem(void)
  done:
     return len;
  }
+
+static void __init acpi_find_ibft_region(void)
+{
+   int i;
+   struct acpi_table_header *table = NULL;
+
+   if (acpi_disabled)
+   return;
+
+   for (i = 0; i < ARRAY_SIZE(ibft_signs) && !ibft_addr; i++) {
+   acpi_get_table(ibft_signs[i].sign, 0, );
+   ibft_addr = (struct acpi_table_ibft *)table;

Can you try adding

acpi_put_table(table);

here?

Mike,

It now crashes here:

[    0.051019] ACPI: Early table checksum verification disabled
[    0.056721] ACPI: RSDP 0xBFBFA014 24 (v02 BOCHS )
[    0.057874] ACPI: XSDT 0xBFBF90E8 4C (v01 BOCHS BXPCFACP 
0001  0113)
[    0.059590] ACPI: FACP 0xBFBF5000 74 (v01 BOCHS BXPCFACP 
0001 BXPC 0001)
[    0.061306] ACPI: DSDT 0xBFBF6000 00238D (v01 BOCHS BXPCDSDT 
0001 BXPC 0001)

[    0.063006] ACPI: FACS 0xBFBFD000 40
[    0.063938] ACPI: APIC 0xBFBF4000 90 (v01 BOCHS BXPCAPIC 
0001 BXPC 0001)
[    0.065638] ACPI: HPET 0xBFBF3000 38 (v01 BOCHS BXPCHPET 
0001 BXPC 0001)
[    0.067335] ACPI: BGRT 0xBE49B000 38 (v01 INTEL EDK2 
0002  0113)
[    0.069030] ACPI: iBFT 0xBE453000 000800 (v01 BOCHS BXPCFACP 
  )

[    0.070734] XXX acpi_find_ibft_region:
[    0.071468] XXX iBFT, status=0
[    0.072073] XXX about to call acpi_put_table()... 
ibft_addr=ff24

[    0.073449] XXX acpi_find_ibft_region(EXIT):
PANIC: early exception 0x0e IP 10:9259f439 error 0 cr2 
0xff240004

[    0.075711] CPU: 0 PID: 0 Comm: swapper Not tainted 5.11.0-34a2105 #8
[    0.076983] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), 
BIOS 0.0.0 02/06/2015

[    0.078579] RIP: 0010:find_ibft_region+0x470/0x577
[    0.079541] Code: f1 40 0f 9e c6 84 c9 0f 95 c1 40 84 ce 75 11 83 e0 
07 38 c2 0f 9e c1 84 d2 0f 95 c0 84 c1 74 0a be 04 00 00 00 e8 37 f8 5f 
ef <8b> 5b 04 4c 89 fa b8 ff ff 37 00 48 c1 ea 03 48 c1 e0 2a 81 c3 ff
[    0.083207] RSP: :8fe07ca8 EFLAGS: 00010046 ORIG_RAX: 

[    0.084709] RAX:  RBX: ff24 RCX: 
815fcf01
[    0.086109] RDX: dc00 RSI:

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-22 Thread George Kennedy




On 2/22/2021 11:13 AM, David Hildenbrand wrote:

On 22.02.21 16:13, George Kennedy wrote:



On 2/22/2021 4:52 AM, David Hildenbrand wrote:

On 20.02.21 00:04, George Kennedy wrote:



On 2/19/2021 11:45 AM, George Kennedy wrote:



On 2/18/2021 7:09 PM, Andrey Konovalov wrote:

On Fri, Feb 19, 2021 at 1:06 AM George Kennedy
 wrote:



On 2/18/2021 3:55 AM, David Hildenbrand wrote:

On 17.02.21 21:56, Andrey Konovalov wrote:

During boot, all non-reserved memblock memory is exposed to the
buddy
allocator. Poisoning all that memory with KASAN lengthens boot
time,
especially on systems with large amount of RAM. This patch makes
page_alloc to not call kasan_free_pages() on all new memory.

__free_pages_core() is used when exposing fresh memory during
system
boot and when onlining memory during hotplug. This patch adds 
a new

FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok()
through
free_pages_prepare() from __free_pages_core().

This has little impact on KASAN memory tracking.

Assuming that there are no references to newly exposed pages
before they
are ever allocated, there won't be any intended (but buggy)
accesses to
that memory that KASAN would normally detect.

However, with this patch, KASAN stops detecting wild and large
out-of-bounds accesses that happen to land on a fresh memory page
that
was never allocated. This is taken as an acceptable trade-off.

All memory allocated normally when the boot is over keeps getting
poisoned as usual.

Signed-off-by: Andrey Konovalov 
Change-Id: Iae6b1e4bb8216955ffc14af255a7eaaa6f35324d

Not sure this is the right thing to do, see

https://lkml.kernel.org/r/bcf8925d-0949-3fe1-baa8-cc536c529...@oracle.com 





Reversing the order in which memory gets allocated + used during
boot
(in a patch by me) might have revealed an invalid memory access
during
boot.

I suspect that that issue would no longer get detected with your
patch, as the invalid memory access would simply not get detected.
Now, I cannot prove that :)

Since David's patch we're having trouble with the iBFT ACPI table,
which
is mapped in via kmap() - see acpi_map() in "drivers/acpi/osl.c".
KASAN
detects that it is being used after free when ibft_init() accesses
the
iBFT table, but as of yet we can't find where it get's freed (we've
instrumented calls to kunmap()).

Maybe it doesn't get freed, but what you see is a wild or a large
out-of-bounds access. Since KASAN marks all memory as freed 
during the

memblock->page_alloc transition, such bugs can manifest as
use-after-frees.


It gets freed and re-used. By the time the iBFT table is accessed by
ibft_init() the page has been over-written.

Setting page flags like the following before the call to kmap()
prevents the iBFT table page from being freed:


Cleaned up version:

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0418feb..8f0a8e7 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -287,9 +287,12 @@ static void __iomem 
*acpi_map(acpi_physical_address

pg_off, unsigned long pg_sz)

    pfn = pg_off >> PAGE_SHIFT;
    if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
        if (pg_sz > PAGE_SIZE)
            return NULL;
-        return (void __iomem __force *)kmap(pfn_to_page(pfn));
+        SetPageReserved(page);
+        return (void __iomem __force *)kmap(page);
    } else
        return acpi_os_ioremap(pg_off, pg_sz);
    }
@@ -299,9 +302,12 @@ static void acpi_unmap(acpi_physical_address
pg_off, void __iomem *vaddr)
    unsigned long pfn;

    pfn = pg_off >> PAGE_SHIFT;
-    if (should_use_kmap(pfn))
-        kunmap(pfn_to_page(pfn));
-    else
+    if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
+        ClearPageReserved(page);
+        kunmap(page);
+    } else
        iounmap(vaddr);
    }

David, the above works, but wondering why it is now necessary. 
kunmap()
is not hit. What other ways could a page mapped via kmap() be 
unmapped?




Let me look into the code ... I have little experience with ACPI
details, so bear with me.

I assume that acpi_map()/acpi_unmap() map some firmware blob that is
provided via firmware/bios/... to us.

should_use_kmap() tells us whether
a) we have a "struct page" and should kmap() that one
b) we don't have a "struct page" and should ioremap.

As it is a blob, the firmware should always reserve that memory region
via memblock (e.g., memblock_reserve()), such that we either
1) don't create a memmap ("struct page") at all (-> case b) )
2) if we have to create e memmap, we mark the page PG_reserved and
    *never* expose it to the buddy (-> case a) )


Are you telling me that in this case we might have a memmap for the HW
blob that is *not* PG_reserved? In that case it most probably got
exposed to the buddy where it can happily get allocated/freed.

The latent BUG would be that that blob gets exposed to the system li

Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-22 Thread George McCollister
On Mon, Feb 22, 2021 at 7:38 AM Wenzel, Marco  wrote:
>
> On Fri, Feb 19, 2021 at 2:14 PM : George McCollister 
>  wrote:
> >
> > On Fri, Feb 19, 2021 at 2:27 AM Wenzel, Marco  > eberle.de> wrote:
> > >
> > > On Thu, Feb 18, 2021 at 6:06 PM : George McCollister
> >  wrote:
> > > >
> > > > On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  > > > eberle.de> wrote:
> > > > >
> > > > > In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms.
> > > > > When a node does not send any frame within this time, the sequence
> > > > > number check for can be ignored. This solves communication issues
> > > > > with Cisco IE 2000 in Redbox mode.
> > > > >
> > > > > Fixes: f421436a591d ("net/hsr: Add support for the
> > > > > High-availability Seamless Redundancy protocol (HSRv0)")
> > > > > Signed-off-by: Marco Wenzel 
> > > > > ---
> > > > >  net/hsr/hsr_framereg.c | 9 +++--  net/hsr/hsr_framereg.h | 1
> > > > > +
> > > > >  net/hsr/hsr_main.h | 1 +
> > > > >  3 files changed, 9 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index
> > > > > 5c97de459905..805f974923b9 100644
> > > > > --- a/net/hsr/hsr_framereg.c
> > > > > +++ b/net/hsr/hsr_framereg.c
> > > > > @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct
> > > > hsr_priv *hsr,
> > > > >  * as initialization. (0 could trigger an spurious ring error 
> > > > > warning).
> > > > >  */
> > > > > now = jiffies;
> > > > > -   for (i = 0; i < HSR_PT_PORTS; i++)
> > > > > +   for (i = 0; i < HSR_PT_PORTS; i++) {
> > > > > new_node->time_in[i] = now;
> > > > > +   new_node->time_out[i] = now;
> > > > > +   }
> > > > > for (i = 0; i < HSR_PT_PORTS; i++)
> > > > > new_node->seq_out[i] = seq_out;
> > > > >
> > > > > @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node
> > > > *node,
> > > > > struct hsr_port *port,  int hsr_register_frame_out(struct hsr_port
> > > > > *port,
> > > > struct hsr_node *node,
> > > > >u16 sequence_nr)  {
> > > > > -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port-
> > >type]))
> > > > > +   if (seq_nr_before_or_eq(sequence_nr,
> > > > > + node->seq_out[port->type])
> > > > &&
> > > > > +   time_is_after_jiffies(node->time_out[port->type] +
> > > > > +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> > > > > return 1;
> > > > >
> > > > > +   node->time_out[port->type] = jiffies;
> > > > > node->seq_out[port->type] = sequence_nr;
> > > > > return 0;
> > > > >  }
> > > > > diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index
> > > > > 86b43f539f2c..d9628e7a5f05 100644
> > > > > --- a/net/hsr/hsr_framereg.h
> > > > > +++ b/net/hsr/hsr_framereg.h
> > > > > @@ -75,6 +75,7 @@ struct hsr_node {
> > > > > enum hsr_port_type  addr_B_port;
> > > > > unsigned long   time_in[HSR_PT_PORTS];
> > > > > booltime_in_stale[HSR_PT_PORTS];
> > > > > +   unsigned long   time_out[HSR_PT_PORTS];
> > > > > /* if the node is a SAN */
> > > > > boolsan_a;
> > > > > boolsan_b;
> > > > > diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index
> > > > > 7dc92ce5a134..f79ca55d6986 100644
> > > > > --- a/net/hsr/hsr_main.h
> > > > > +++ b/net/hsr/hsr_main.h
> > > > > @@ -21,6 +21,7 @@
> > > > >  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
> > > > >  #define HSR_NODE_FORGET_TIME   6 /* ms */
> > > > >  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> > > > > +#define HSR_ENTRY_FORGET_TIME400 /* ms 

Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-22 Thread George Kennedy




On 2/22/2021 4:52 AM, David Hildenbrand wrote:

On 20.02.21 00:04, George Kennedy wrote:



On 2/19/2021 11:45 AM, George Kennedy wrote:



On 2/18/2021 7:09 PM, Andrey Konovalov wrote:

On Fri, Feb 19, 2021 at 1:06 AM George Kennedy
 wrote:



On 2/18/2021 3:55 AM, David Hildenbrand wrote:

On 17.02.21 21:56, Andrey Konovalov wrote:
During boot, all non-reserved memblock memory is exposed to the 
buddy
allocator. Poisoning all that memory with KASAN lengthens boot 
time,

especially on systems with large amount of RAM. This patch makes
page_alloc to not call kasan_free_pages() on all new memory.

__free_pages_core() is used when exposing fresh memory during 
system

boot and when onlining memory during hotplug. This patch adds a new
FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok() 
through

free_pages_prepare() from __free_pages_core().

This has little impact on KASAN memory tracking.

Assuming that there are no references to newly exposed pages
before they
are ever allocated, there won't be any intended (but buggy)
accesses to
that memory that KASAN would normally detect.

However, with this patch, KASAN stops detecting wild and large
out-of-bounds accesses that happen to land on a fresh memory page
that
was never allocated. This is taken as an acceptable trade-off.

All memory allocated normally when the boot is over keeps getting
poisoned as usual.

Signed-off-by: Andrey Konovalov 
Change-Id: Iae6b1e4bb8216955ffc14af255a7eaaa6f35324d

Not sure this is the right thing to do, see

https://lkml.kernel.org/r/bcf8925d-0949-3fe1-baa8-cc536c529...@oracle.com 




Reversing the order in which memory gets allocated + used during 
boot
(in a patch by me) might have revealed an invalid memory access 
during

boot.

I suspect that that issue would no longer get detected with your
patch, as the invalid memory access would simply not get detected.
Now, I cannot prove that :)

Since David's patch we're having trouble with the iBFT ACPI table,
which
is mapped in via kmap() - see acpi_map() in "drivers/acpi/osl.c". 
KASAN
detects that it is being used after free when ibft_init() accesses 
the

iBFT table, but as of yet we can't find where it get's freed (we've
instrumented calls to kunmap()).

Maybe it doesn't get freed, but what you see is a wild or a large
out-of-bounds access. Since KASAN marks all memory as freed during the
memblock->page_alloc transition, such bugs can manifest as
use-after-frees.


It gets freed and re-used. By the time the iBFT table is accessed by
ibft_init() the page has been over-written.

Setting page flags like the following before the call to kmap()
prevents the iBFT table page from being freed:


Cleaned up version:

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0418feb..8f0a8e7 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -287,9 +287,12 @@ static void __iomem *acpi_map(acpi_physical_address
pg_off, unsigned long pg_sz)

   pfn = pg_off >> PAGE_SHIFT;
   if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
       if (pg_sz > PAGE_SIZE)
           return NULL;
-        return (void __iomem __force *)kmap(pfn_to_page(pfn));
+        SetPageReserved(page);
+        return (void __iomem __force *)kmap(page);
   } else
       return acpi_os_ioremap(pg_off, pg_sz);
   }
@@ -299,9 +302,12 @@ static void acpi_unmap(acpi_physical_address
pg_off, void __iomem *vaddr)
   unsigned long pfn;

   pfn = pg_off >> PAGE_SHIFT;
-    if (should_use_kmap(pfn))
-        kunmap(pfn_to_page(pfn));
-    else
+    if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
+        ClearPageReserved(page);
+        kunmap(page);
+    } else
       iounmap(vaddr);
   }

David, the above works, but wondering why it is now necessary. kunmap()
is not hit. What other ways could a page mapped via kmap() be unmapped?



Let me look into the code ... I have little experience with ACPI 
details, so bear with me.


I assume that acpi_map()/acpi_unmap() map some firmware blob that is 
provided via firmware/bios/... to us.


should_use_kmap() tells us whether
a) we have a "struct page" and should kmap() that one
b) we don't have a "struct page" and should ioremap.

As it is a blob, the firmware should always reserve that memory region 
via memblock (e.g., memblock_reserve()), such that we either

1) don't create a memmap ("struct page") at all (-> case b) )
2) if we have to create e memmap, we mark the page PG_reserved and
   *never* expose it to the buddy (-> case a) )


Are you telling me that in this case we might have a memmap for the HW 
blob that is *not* PG_reserved? In that case it most probably got 
exposed to the buddy where it can happily get allocated/freed.


The latent BUG would be that that blob gets exposed to the system like 
ordinary RAM, and not reserved via memblock early during boot. 
Assuming that blob has a low p

[PATCH] staging: android: Remove filename reference from file

2021-02-21 Thread George Xanthakis
This commit fixes a checkpatch warning that references the filename in
the the file comments.

Signed-off-by: George Xanthakis 
---
 drivers/staging/android/uapi/ashmem.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/android/uapi/ashmem.h 
b/drivers/staging/android/uapi/ashmem.h
index 5442e0019..134efacb3 100644
--- a/drivers/staging/android/uapi/ashmem.h
+++ b/drivers/staging/android/uapi/ashmem.h
@@ -1,7 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 OR Apache-2.0 */
 /*
- * drivers/staging/android/uapi/ashmem.h
- *
  * Copyright 2008 Google Inc.
  * Author: Robert Love
  */
-- 
2.30.1



[PATCH] sound/usb generate midi streaming substream names from jack names

2021-02-21 Thread George Harker
A number of devices have named substreams which are hard to remember /
decypher from  MIDI n names.  Eg. Korg puts a pass through on
one substream and iConnectivity devices name the connections.

This makes it easier to connect to the correct device.  Devices which
handle naming through quirks are unaffected by this change.

Addresses TODO comment in sound/usb/midi.c

Signed-off-by: George Harker 
---
 sound/usb/midi.c | 122 ++-
 sound/usb/midi.h |   2 +
 2 files changed, 101 insertions(+), 23 deletions(-)

diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 0c23fa6d8..c6651a566 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -77,23 +78,6 @@ MODULE_AUTHOR("Clemens Ladisch ");
 MODULE_DESCRIPTION("USB Audio/MIDI helper module");
 MODULE_LICENSE("Dual BSD/GPL");
 
-
-struct usb_ms_header_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bcdMSC[2];
-   __le16 wTotalLength;
-} __attribute__ ((packed));
-
-struct usb_ms_endpoint_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bNumEmbMIDIJack;
-   __u8  baAssocJackID[];
-} __attribute__ ((packed));
-
 struct snd_usb_midi_in_endpoint;
 struct snd_usb_midi_out_endpoint;
 struct snd_usb_midi_endpoint;
@@ -1756,12 +1740,68 @@ static void snd_usbmidi_get_port_info(struct 
snd_rawmidi *rmidi, int number,
}
 }
 
+static struct usb_midi_in_jack_descriptor *find_usb_in_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_in_jack_descriptor *injd =
+   (struct usb_midi_in_jack_descriptor *)extra;
+
+   if (injd->bLength > 4 &&
+   injd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   injd->bDescriptorSubtype == UAC_MIDI_IN_JACK &&
+   injd->bJackID == jack_id)
+   return injd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
+static struct usb_midi_out_jack_descriptor *find_usb_out_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_out_jack_descriptor *outjd =
+   (struct usb_midi_out_jack_descriptor *)extra;
+
+   if (outjd->bLength > 4 &&
+   outjd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   outjd->bDescriptorSubtype == UAC_MIDI_OUT_JACK &&
+   outjd->bJackID == jack_id)
+   return outjd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
 static void snd_usbmidi_init_substream(struct snd_usb_midi *umidi,
-  int stream, int number,
+  int stream, int number, int jack_id,
   struct snd_rawmidi_substream 
**rsubstream)
 {
struct port_info *port_info;
const char *name_format;
+   struct usb_interface *intf;
+   struct usb_host_interface *hostif;
+   struct usb_midi_in_jack_descriptor *injd;
+   struct usb_midi_out_jack_descriptor *outjd;
+   uint8_t jack_name_buf[32];
+   uint8_t *default_jack_name = "MIDI";
+   uint8_t *jack_name = default_jack_name;
+   uint8_t iJack;
+   size_t sz;
+   int res;
 
struct snd_rawmidi_substream *substream =
snd_usbmidi_find_substream(umidi, stream, number);
@@ -1771,11 +1811,35 @@ static void snd_usbmidi_init_substream(struct 
snd_usb_midi *umidi,
return;
}
 
-   /* TODO: read port name from jack descriptor */
+   intf = umidi->iface;
+   if (intf && jack_id >= 0) {
+   hostif = intf->cur_altsetting;
+   iJack = 0;
+   if (stream != SNDRV_RAWMIDI_STREAM_OUTPUT) {
+   /* in jacks connect to outs */
+   outjd = find_usb_out_jack_descriptor(hostif, jack_id);
+   if (outjd) {
+   sz = USB_DT_MIDI_OUT_SIZE(outjd->bNrInputPins);
+  

[PATCH] sound/usb generate midi streaming substream names from jack names

2021-02-21 Thread George Harker
A number of devices have named substreams which are hard to remember /
decypher from  MIDI n names.  Eg. Korg puts a pass through on
one substream and iConnectivity devices name the connections.

This makes it easier to connect to the correct device.  Devices which
handle naming through quirks are unaffected by this change.

Addresses TODO comment in sound/usb/midi.c

Signed-off-by: George Harker 
---
 sound/usb/midi.c | 122 ++-
 sound/usb/midi.h |   2 +
 2 files changed, 101 insertions(+), 23 deletions(-)

diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 0c23fa6d8..c6651a566 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -77,23 +78,6 @@ MODULE_AUTHOR("Clemens Ladisch ");
 MODULE_DESCRIPTION("USB Audio/MIDI helper module");
 MODULE_LICENSE("Dual BSD/GPL");
 
-
-struct usb_ms_header_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bcdMSC[2];
-   __le16 wTotalLength;
-} __attribute__ ((packed));
-
-struct usb_ms_endpoint_descriptor {
-   __u8  bLength;
-   __u8  bDescriptorType;
-   __u8  bDescriptorSubtype;
-   __u8  bNumEmbMIDIJack;
-   __u8  baAssocJackID[];
-} __attribute__ ((packed));
-
 struct snd_usb_midi_in_endpoint;
 struct snd_usb_midi_out_endpoint;
 struct snd_usb_midi_endpoint;
@@ -1756,12 +1740,68 @@ static void snd_usbmidi_get_port_info(struct 
snd_rawmidi *rmidi, int number,
}
 }
 
+static struct usb_midi_in_jack_descriptor *find_usb_in_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_in_jack_descriptor *injd =
+   (struct usb_midi_in_jack_descriptor *)extra;
+
+   if (injd->bLength > 4 &&
+   injd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   injd->bDescriptorSubtype == UAC_MIDI_IN_JACK &&
+   injd->bJackID == jack_id)
+   return injd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
+static struct usb_midi_out_jack_descriptor *find_usb_out_jack_descriptor(
+   struct usb_host_interface *hostif, 
uint8_t jack_id)
+{
+   unsigned char *extra = hostif->extra;
+   int extralen = hostif->extralen;
+
+   while (extralen > 4) {
+   struct usb_midi_out_jack_descriptor *outjd =
+   (struct usb_midi_out_jack_descriptor *)extra;
+
+   if (outjd->bLength > 4 &&
+   outjd->bDescriptorType == USB_DT_CS_INTERFACE &&
+   outjd->bDescriptorSubtype == UAC_MIDI_OUT_JACK &&
+   outjd->bJackID == jack_id)
+   return outjd;
+   if (!extra[0])
+   break;
+   extralen -= extra[0];
+   extra += extra[0];
+   }
+   return NULL;
+}
+
 static void snd_usbmidi_init_substream(struct snd_usb_midi *umidi,
-  int stream, int number,
+  int stream, int number, int jack_id,
   struct snd_rawmidi_substream 
**rsubstream)
 {
struct port_info *port_info;
const char *name_format;
+   struct usb_interface *intf;
+   struct usb_host_interface *hostif;
+   struct usb_midi_in_jack_descriptor *injd;
+   struct usb_midi_out_jack_descriptor *outjd;
+   uint8_t jack_name_buf[32];
+   uint8_t *default_jack_name = "MIDI";
+   uint8_t *jack_name = default_jack_name;
+   uint8_t iJack;
+   size_t sz;
+   int res;
 
struct snd_rawmidi_substream *substream =
snd_usbmidi_find_substream(umidi, stream, number);
@@ -1771,11 +1811,35 @@ static void snd_usbmidi_init_substream(struct 
snd_usb_midi *umidi,
return;
}
 
-   /* TODO: read port name from jack descriptor */
+   intf = umidi->iface;
+   if (intf && jack_id >= 0) {
+   hostif = intf->cur_altsetting;
+   iJack = 0;
+   if (stream != SNDRV_RAWMIDI_STREAM_OUTPUT) {
+   /* in jacks connect to outs */
+   outjd = find_usb_out_jack_descriptor(hostif, jack_id);
+   if (outjd) {
+   sz = USB_DT_MIDI_OUT_SIZE(outjd->bNrInputPins);
+  

Re: [PATCH net-next] net: dsa: Fix dependencies with HSR

2021-02-20 Thread George McCollister
On Fri, Feb 19, 2021 at 11:14 PM Florian Fainelli  wrote:
>
>
>
> On 2/19/2021 9:12 PM, Florian Fainelli wrote:
> > The core DSA framework uses hsr_is_master() which would not resolve to a
> > valid symbol if HSR is built-into the kernel and DSA is a module.
> >
> > Fixes: 18596f504a3e ("net: dsa: add support for offloading HSR")
> > Reported-by: kernel test robot 
> > Signed-off-by: Florian Fainelli 
> > ---
> > David, Jakub,
> >
> > This showed up in linux-next which means it will show up in Linus' tree
> > soon as well when your pull request gets sent out.
>
> I had initially considered making is_hsr_master() a static inline that
> would compare dev->dev.type->name with "hsr" since the HSR master would
> set a custom dev_type, however the xrs700x driver would still fail to
> link because it calls hsr_get_version() and for that one there is no
> easy solution.

Thanks for looking into this. It's not something I've run into before.
It didn't occur to me what would happen if HSR was a module. I'll look
out for this in the future.

Sorry for the inconvenience.

Reviewed-by: George McCollister 

-George

> --
> Florian


Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-19 Thread George Kennedy




On 2/19/2021 11:45 AM, George Kennedy wrote:



On 2/18/2021 7:09 PM, Andrey Konovalov wrote:

On Fri, Feb 19, 2021 at 1:06 AM George Kennedy
 wrote:



On 2/18/2021 3:55 AM, David Hildenbrand wrote:

On 17.02.21 21:56, Andrey Konovalov wrote:

During boot, all non-reserved memblock memory is exposed to the buddy
allocator. Poisoning all that memory with KASAN lengthens boot time,
especially on systems with large amount of RAM. This patch makes
page_alloc to not call kasan_free_pages() on all new memory.

__free_pages_core() is used when exposing fresh memory during system
boot and when onlining memory during hotplug. This patch adds a new
FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok() through
free_pages_prepare() from __free_pages_core().

This has little impact on KASAN memory tracking.

Assuming that there are no references to newly exposed pages 
before they
are ever allocated, there won't be any intended (but buggy) 
accesses to

that memory that KASAN would normally detect.

However, with this patch, KASAN stops detecting wild and large
out-of-bounds accesses that happen to land on a fresh memory page 
that

was never allocated. This is taken as an acceptable trade-off.

All memory allocated normally when the boot is over keeps getting
poisoned as usual.

Signed-off-by: Andrey Konovalov 
Change-Id: Iae6b1e4bb8216955ffc14af255a7eaaa6f35324d

Not sure this is the right thing to do, see

https://lkml.kernel.org/r/bcf8925d-0949-3fe1-baa8-cc536c529...@oracle.com 



Reversing the order in which memory gets allocated + used during boot
(in a patch by me) might have revealed an invalid memory access during
boot.

I suspect that that issue would no longer get detected with your
patch, as the invalid memory access would simply not get detected.
Now, I cannot prove that :)
Since David's patch we're having trouble with the iBFT ACPI table, 
which

is mapped in via kmap() - see acpi_map() in "drivers/acpi/osl.c". KASAN
detects that it is being used after free when ibft_init() accesses the
iBFT table, but as of yet we can't find where it get's freed (we've
instrumented calls to kunmap()).

Maybe it doesn't get freed, but what you see is a wild or a large
out-of-bounds access. Since KASAN marks all memory as freed during the
memblock->page_alloc transition, such bugs can manifest as
use-after-frees.


It gets freed and re-used. By the time the iBFT table is accessed by 
ibft_init() the page has been over-written.


Setting page flags like the following before the call to kmap() 
prevents the iBFT table page from being freed:


Cleaned up version:

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0418feb..8f0a8e7 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -287,9 +287,12 @@ static void __iomem *acpi_map(acpi_physical_address 
pg_off, unsigned long pg_sz)


 pfn = pg_off >> PAGE_SHIFT;
 if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
     if (pg_sz > PAGE_SIZE)
         return NULL;
-        return (void __iomem __force *)kmap(pfn_to_page(pfn));
+        SetPageReserved(page);
+        return (void __iomem __force *)kmap(page);
 } else
     return acpi_os_ioremap(pg_off, pg_sz);
 }
@@ -299,9 +302,12 @@ static void acpi_unmap(acpi_physical_address 
pg_off, void __iomem *vaddr)

 unsigned long pfn;

 pfn = pg_off >> PAGE_SHIFT;
-    if (should_use_kmap(pfn))
-        kunmap(pfn_to_page(pfn));
-    else
+    if (should_use_kmap(pfn)) {
+        struct page *page = pfn_to_page(pfn);
+
+        ClearPageReserved(page);
+        kunmap(page);
+    } else
     iounmap(vaddr);
 }

David, the above works, but wondering why it is now necessary. kunmap() 
is not hit. What other ways could a page mapped via kmap() be unmapped?


Thank you,
George



diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0418feb..41c1bbd 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -287,9 +287,14 @@ static void __iomem 
*acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)


    pfn = pg_off >> PAGE_SHIFT;
    if (should_use_kmap(pfn)) {
+   struct page *page =  pfn_to_page(pfn);
+
    if (pg_sz > PAGE_SIZE)
    return NULL;
-   return (void __iomem __force *)kmap(pfn_to_page(pfn));
+
+   page->flags |= ((1UL << PG_unevictable) | (1UL << 
PG_reserved) | (1UL << PG_locked));

+
+   return (void __iomem __force *)kmap(page);
    } else
    return acpi_os_ioremap(pg_off, pg_sz);
 }

Just not sure of the correct way to set the page flags.

George





Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-19 Thread George Kennedy




On 2/18/2021 7:09 PM, Andrey Konovalov wrote:

On Fri, Feb 19, 2021 at 1:06 AM George Kennedy
 wrote:



On 2/18/2021 3:55 AM, David Hildenbrand wrote:

On 17.02.21 21:56, Andrey Konovalov wrote:

During boot, all non-reserved memblock memory is exposed to the buddy
allocator. Poisoning all that memory with KASAN lengthens boot time,
especially on systems with large amount of RAM. This patch makes
page_alloc to not call kasan_free_pages() on all new memory.

__free_pages_core() is used when exposing fresh memory during system
boot and when onlining memory during hotplug. This patch adds a new
FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok() through
free_pages_prepare() from __free_pages_core().

This has little impact on KASAN memory tracking.

Assuming that there are no references to newly exposed pages before they
are ever allocated, there won't be any intended (but buggy) accesses to
that memory that KASAN would normally detect.

However, with this patch, KASAN stops detecting wild and large
out-of-bounds accesses that happen to land on a fresh memory page that
was never allocated. This is taken as an acceptable trade-off.

All memory allocated normally when the boot is over keeps getting
poisoned as usual.

Signed-off-by: Andrey Konovalov 
Change-Id: Iae6b1e4bb8216955ffc14af255a7eaaa6f35324d

Not sure this is the right thing to do, see

https://lkml.kernel.org/r/bcf8925d-0949-3fe1-baa8-cc536c529...@oracle.com

Reversing the order in which memory gets allocated + used during boot
(in a patch by me) might have revealed an invalid memory access during
boot.

I suspect that that issue would no longer get detected with your
patch, as the invalid memory access would simply not get detected.
Now, I cannot prove that :)

Since David's patch we're having trouble with the iBFT ACPI table, which
is mapped in via kmap() - see acpi_map() in "drivers/acpi/osl.c". KASAN
detects that it is being used after free when ibft_init() accesses the
iBFT table, but as of yet we can't find where it get's freed (we've
instrumented calls to kunmap()).

Maybe it doesn't get freed, but what you see is a wild or a large
out-of-bounds access. Since KASAN marks all memory as freed during the
memblock->page_alloc transition, such bugs can manifest as
use-after-frees.


It gets freed and re-used. By the time the iBFT table is accessed by 
ibft_init() the page has been over-written.


Setting page flags like the following before the call to kmap() prevents 
the iBFT table page from being freed:


diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 0418feb..41c1bbd 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -287,9 +287,14 @@ static void __iomem *acpi_map(acpi_physical_address 
pg_off, unsigned long pg_sz)


    pfn = pg_off >> PAGE_SHIFT;
    if (should_use_kmap(pfn)) {
+   struct page *page =  pfn_to_page(pfn);
+
    if (pg_sz > PAGE_SIZE)
    return NULL;
-   return (void __iomem __force *)kmap(pfn_to_page(pfn));
+
+   page->flags |= ((1UL << PG_unevictable) | (1UL << 
PG_reserved) | (1UL << PG_locked));

+
+   return (void __iomem __force *)kmap(page);
    } else
    return acpi_os_ioremap(pg_off, pg_sz);
 }

Just not sure of the correct way to set the page flags.

George



Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-19 Thread George McCollister
On Fri, Feb 19, 2021 at 2:27 AM Wenzel, Marco  wrote:
>
> On Thu, Feb 18, 2021 at 6:06 PM : George McCollister 
>  wrote:
> >
> > On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  > eberle.de> wrote:
> > >
> > > In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms. When
> > > a node does not send any frame within this time, the sequence number
> > > check for can be ignored. This solves communication issues with Cisco
> > > IE 2000 in Redbox mode.
> > >
> > > Fixes: f421436a591d ("net/hsr: Add support for the High-availability
> > > Seamless Redundancy protocol (HSRv0)")
> > > Signed-off-by: Marco Wenzel 
> > > ---
> > >  net/hsr/hsr_framereg.c | 9 +++--
> > >  net/hsr/hsr_framereg.h | 1 +
> > >  net/hsr/hsr_main.h | 1 +
> > >  3 files changed, 9 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index
> > > 5c97de459905..805f974923b9 100644
> > > --- a/net/hsr/hsr_framereg.c
> > > +++ b/net/hsr/hsr_framereg.c
> > > @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct
> > hsr_priv *hsr,
> > >  * as initialization. (0 could trigger an spurious ring error 
> > > warning).
> > >  */
> > > now = jiffies;
> > > -   for (i = 0; i < HSR_PT_PORTS; i++)
> > > +   for (i = 0; i < HSR_PT_PORTS; i++) {
> > > new_node->time_in[i] = now;
> > > +   new_node->time_out[i] = now;
> > > +   }
> > > for (i = 0; i < HSR_PT_PORTS; i++)
> > > new_node->seq_out[i] = seq_out;
> > >
> > > @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node
> > *node,
> > > struct hsr_port *port,  int hsr_register_frame_out(struct hsr_port *port,
> > struct hsr_node *node,
> > >u16 sequence_nr)  {
> > > -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]))
> > > +   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type])
> > &&
> > > +   time_is_after_jiffies(node->time_out[port->type] +
> > > +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> > > return 1;
> > >
> > > +   node->time_out[port->type] = jiffies;
> > > node->seq_out[port->type] = sequence_nr;
> > > return 0;
> > >  }
> > > diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h index
> > > 86b43f539f2c..d9628e7a5f05 100644
> > > --- a/net/hsr/hsr_framereg.h
> > > +++ b/net/hsr/hsr_framereg.h
> > > @@ -75,6 +75,7 @@ struct hsr_node {
> > > enum hsr_port_type  addr_B_port;
> > > unsigned long   time_in[HSR_PT_PORTS];
> > > booltime_in_stale[HSR_PT_PORTS];
> > > +   unsigned long   time_out[HSR_PT_PORTS];
> > > /* if the node is a SAN */
> > > boolsan_a;
> > > boolsan_b;
> > > diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h index
> > > 7dc92ce5a134..f79ca55d6986 100644
> > > --- a/net/hsr/hsr_main.h
> > > +++ b/net/hsr/hsr_main.h
> > > @@ -21,6 +21,7 @@
> > >  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
> > >  #define HSR_NODE_FORGET_TIME   6 /* ms */
> > >  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> > > +#define HSR_ENTRY_FORGET_TIME400 /* ms */
> > >
> > >  /* By how much may slave1 and slave2 timestamps of latest received
> > frame from
> > >   * each node differ before we notify of communication problem?
> > > --
> > > 2.30.0
> > >
> >
> > scripts/checkpatch.pl gives errors about DOS line endings but once that is
> > resolved this looks good. I tested it on an HSR network with the software
> > implementation and the xrs700x which uses offloading and everything still
> > works. I don't have a way to force anything on the HSR network to reuse
> > sequence numbers after 400ms.
> >
> > Reviewed-by: George McCollister  > Tested-by: George McCollister 
> Thank you very much for reviewing, testing and supporting!
>
> Where do you see the incorrect line endings? I just ran scripts/checkpath.pl 
> as git commit hook and it did not report any errors. When I run it again 
> manually, it also does not report any errors:
>
> # ./scripts/checkpatch.pl --strict 
> /tmp/0001-net-hsr-add-support-for-EntryForgetTime.patch
> total: 0 errors, 0 warnings, 0 checks, 38 lines checked
>
> /tmp/0001-net-hsr-add-support-for-EntryForgetTime.patch has no obvious style 
> problems and is ready for submission.

Sorry about this. It seems when I downloaded the patch with Chromium
from gmail in Linux it added DOS new lines (this is unexpected). When
I downloaded it from lore.kernel.org it's fine.

Reviewed-by: George McCollister 
Tested-by: George McCollister 

>
>
> Regards,
> Marco Wenzel


Re: [PATCH] mm, kasan: don't poison boot memory

2021-02-18 Thread George Kennedy




On 2/18/2021 3:55 AM, David Hildenbrand wrote:

On 17.02.21 21:56, Andrey Konovalov wrote:

During boot, all non-reserved memblock memory is exposed to the buddy
allocator. Poisoning all that memory with KASAN lengthens boot time,
especially on systems with large amount of RAM. This patch makes
page_alloc to not call kasan_free_pages() on all new memory.

__free_pages_core() is used when exposing fresh memory during system
boot and when onlining memory during hotplug. This patch adds a new
FPI_SKIP_KASAN_POISON flag and passes it to __free_pages_ok() through
free_pages_prepare() from __free_pages_core().

This has little impact on KASAN memory tracking.

Assuming that there are no references to newly exposed pages before they
are ever allocated, there won't be any intended (but buggy) accesses to
that memory that KASAN would normally detect.

However, with this patch, KASAN stops detecting wild and large
out-of-bounds accesses that happen to land on a fresh memory page that
was never allocated. This is taken as an acceptable trade-off.

All memory allocated normally when the boot is over keeps getting
poisoned as usual.

Signed-off-by: Andrey Konovalov 
Change-Id: Iae6b1e4bb8216955ffc14af255a7eaaa6f35324d


Not sure this is the right thing to do, see

https://lkml.kernel.org/r/bcf8925d-0949-3fe1-baa8-cc536c529...@oracle.com

Reversing the order in which memory gets allocated + used during boot 
(in a patch by me) might have revealed an invalid memory access during 
boot.


I suspect that that issue would no longer get detected with your 
patch, as the invalid memory access would simply not get detected. 
Now, I cannot prove that :)


Since David's patch we're having trouble with the iBFT ACPI table, which 
is mapped in via kmap() - see acpi_map() in "drivers/acpi/osl.c". KASAN 
detects that it is being used after free when ibft_init() accesses the 
iBFT table, but as of yet we can't find where it get's freed (we've 
instrumented calls to kunmap()).


Thank you,
George



Re: [PATCH] net: hsr: add support for EntryForgetTime

2021-02-18 Thread George McCollister
On Thu, Feb 18, 2021 at 9:01 AM Marco Wenzel  wrote:
>
> In IEC 62439-3 EntryForgetTime is defined with a value of 400 ms. When a
> node does not send any frame within this time, the sequence number check
> for can be ignored. This solves communication issues with Cisco IE 2000
> in Redbox mode.
>
> Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless 
> Redundancy protocol (HSRv0)")
> Signed-off-by: Marco Wenzel 
> ---
>  net/hsr/hsr_framereg.c | 9 +++--
>  net/hsr/hsr_framereg.h | 1 +
>  net/hsr/hsr_main.h | 1 +
>  3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
> index 5c97de459905..805f974923b9 100644
> --- a/net/hsr/hsr_framereg.c
> +++ b/net/hsr/hsr_framereg.c
> @@ -164,8 +164,10 @@ static struct hsr_node *hsr_add_node(struct hsr_priv 
> *hsr,
>  * as initialization. (0 could trigger an spurious ring error 
> warning).
>  */
> now = jiffies;
> -   for (i = 0; i < HSR_PT_PORTS; i++)
> +   for (i = 0; i < HSR_PT_PORTS; i++) {
> new_node->time_in[i] = now;
> +   new_node->time_out[i] = now;
> +   }
> for (i = 0; i < HSR_PT_PORTS; i++)
> new_node->seq_out[i] = seq_out;
>
> @@ -411,9 +413,12 @@ void hsr_register_frame_in(struct hsr_node *node, struct 
> hsr_port *port,
>  int hsr_register_frame_out(struct hsr_port *port, struct hsr_node *node,
>u16 sequence_nr)
>  {
> -   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]))
> +   if (seq_nr_before_or_eq(sequence_nr, node->seq_out[port->type]) &&
> +   time_is_after_jiffies(node->time_out[port->type] +
> +   msecs_to_jiffies(HSR_ENTRY_FORGET_TIME)))
> return 1;
>
> +   node->time_out[port->type] = jiffies;
> node->seq_out[port->type] = sequence_nr;
> return 0;
>  }
> diff --git a/net/hsr/hsr_framereg.h b/net/hsr/hsr_framereg.h
> index 86b43f539f2c..d9628e7a5f05 100644
> --- a/net/hsr/hsr_framereg.h
> +++ b/net/hsr/hsr_framereg.h
> @@ -75,6 +75,7 @@ struct hsr_node {
> enum hsr_port_type  addr_B_port;
> unsigned long   time_in[HSR_PT_PORTS];
> booltime_in_stale[HSR_PT_PORTS];
> +   unsigned long   time_out[HSR_PT_PORTS];
> /* if the node is a SAN */
> boolsan_a;
> boolsan_b;
> diff --git a/net/hsr/hsr_main.h b/net/hsr/hsr_main.h
> index 7dc92ce5a134..f79ca55d6986 100644
> --- a/net/hsr/hsr_main.h
> +++ b/net/hsr/hsr_main.h
> @@ -21,6 +21,7 @@
>  #define HSR_LIFE_CHECK_INTERVAL 2000 /* ms */
>  #define HSR_NODE_FORGET_TIME   6 /* ms */
>  #define HSR_ANNOUNCE_INTERVAL100 /* ms */
> +#define HSR_ENTRY_FORGET_TIME400 /* ms */
>
>  /* By how much may slave1 and slave2 timestamps of latest received frame from
>   * each node differ before we notify of communication problem?
> --
> 2.30.0
>

scripts/checkpatch.pl gives errors about DOS line endings but once
that is resolved this looks good. I tested it on an HSR network with
the software implementation and the xrs700x which uses offloading and
everything still works. I don't have a way to force anything on the
HSR network to reuse sequence numbers after 400ms.

Reviewed-by: George McCollister 

Re: [PATCH] mtd: spi-nor: boya: add support for boya by25q128as

2021-02-13 Thread George Brooke

Hello Tudor,

tudor.amba...@microchip.com writes:


Hi, George,

On 2/7/21 2:30 PM, George Brooke wrote:
EXTERNAL EMAIL: Do not click links or open attachments unless 
you know the content is safe


Adds support for the Boya Microelectronics BY25Q128AS 128 Mbit 
flash.
I tested this on the Creality WB-01 embedded device which uses 
this,
although that was with OpenWrt which is still using 5.4 so I 
had to
do a bit of porting work. Don't see how that would make much of 
a

difference though.

Signed-off-by: George Brooke 
---
 drivers/mtd/spi-nor/Makefile |  1 +
 drivers/mtd/spi-nor/boya.c   | 23 +++
 drivers/mtd/spi-nor/core.c   |  1 +
 drivers/mtd/spi-nor/core.h   |  1 +
 4 files changed, 26 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/boya.c

diff --git a/drivers/mtd/spi-nor/Makefile 
b/drivers/mtd/spi-nor/Makefile

index 653923896205..7d1551fbfbaa 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -2,6 +2,7 @@

 spi-nor-objs   := core.o sfdp.o
 spi-nor-objs   += atmel.o
+spi-nor-objs   += boya.o
 spi-nor-objs   += catalyst.o
 spi-nor-objs   += eon.o
 spi-nor-objs   += esmt.o
diff --git a/drivers/mtd/spi-nor/boya.c 
b/drivers/mtd/spi-nor/boya.c

new file mode 100644
index ..014b0087048a
--- /dev/null
+++ b/drivers/mtd/spi-nor/boya.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2005, Intec Automation Inc.
+ * Copyright (C) 2014, Freescale Semiconductor, Inc.
+ */
+
+#include 
+
+#include "core.h"
+
+static const struct flash_info boya_parts[] = {
+   /* Boya */
+   { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256,


The manufacturer’s identification code is defined by one or more
eight (8) bit fields each consisting of seven (7) data bits plus 
one (1)
odd parity bit. It is a single field limiting the possible 
number of
vendors to 126. To expand the maximum number of identification 
codes a

continuation scheme has been defined.

According to JEP106BA, the manufacturer ID for Boya should be 
preceded by
eight continuation codes. So I would expect the manufacturer ID 
for this
flash to be: 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 
0x68.


Without the continuation codes, we will have collisions between
manufacturer IDs, Convex Computer being an example.

I see that the datasheet [1] for this flash doesn't specify 
anything
about the continuation codes, so I suspect that Boya just got it 
wrong.


It appears you are right. I thought it would be the best idea to 
actually
interact with the flash chip and read its responses, so I found a 
tool

called spincl [2] to send some commands to it with a Raspberry Pi:

$ spincl -ib -m0 -c0 -s0 -p0 6 0x90
0x00 0x00 0x00 0x00 0x68 0x17
$ spincl -ib -m0 -c0 -s0 -p0 4 0x9F
0x00 0x68 0x40 0x18
and indeed there doesn't seem to be any continuation codes.

We'll have to check other datasheets from Boya and see if they 
got
their manufacturer ID wrong for all their flashes. We'll have to 
add


The BY25Q64AS [3] appears to be described similarly.

some fixup mechanism for the manufacturers ID handling, in order 
to

avoid collisions with other manufacturers IDs.


I looked into this a bit more, and what I'm realising is that I'm 
not sure if
there even is any mechanism to deliver the continuation codes 
within the
base SPI-NOR standard? Take esmt.c: the f25l32qa has a device id 
0x8c4116.
JEP106BA attribytes 8c to Monolithic Memories in the first bank, 
while
Elite Flash Storage (presumably an alias of ESMT) should be 
identifying
as 0x7f, 0x7f, 0x7f, 0x8c. Its datasheet [4] appears to be equally 
sparse on
detail. To my untrained eye, this seems to be the exact same 
situation we
find ourselves in here. (You probably know a lot more about this 
then I do -

if I'm wrong do point it out!)

That said I can't seem to find any formalised definition of what 
the 0x90
"manufacturer and device ID" command is actually supposed to do in 
the case of
a manufacturer ID that isn't in the first bank. Likewise with 0x9f 
"JEDEC ID".
Do you know of any flashes made by companies not in the first bank 
that

identify themselves correctly?

As far as I can tell the only proper method available is in SFDP, 
where the
Parameter ID of a vendor specific table would be the bank number 
in the MSB
and the actual manufacturer code in the LSB. However, this is a 
very
over-engineered solution, wouldn't work on devices with no vendor 
specific
tables, and in this case, I couldn't even get the SFDP table to 
read out of

the by25q128as at all:
$ spincl -ib -m0 -c0 -s0 -p0 32 0x5A
0x00 0x00 0x00 0x00 0x00 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 
0xff 0xff ...
(This may very well be a peculiarity of the way I'm accessing it, 
but in any

case I don't think this fix would be a very good idea.)

I'm not sure what would actually make a good fixup in this 

Re: [PATCH 1/1] iscsi_ibft: KASAN false positive failure occurs in ibft_init()

2021-02-12 Thread George Kennedy




On 2/12/2021 10:36 AM, David Hildenbrand wrote:

On 12.02.21 14:51, Dmitry Vyukov wrote:

On Fri, Feb 12, 2021 at 2:31 PM George Kennedy
 wrote:

On 2/10/2021 4:51 PM, George Kennedy wrote:

On 2/3/2021 2:35 PM, Dmitry Vyukov wrote:

On Wed, Feb 3, 2021 at 8:29 PM Konrad Rzeszutek Wilk
 wrote:

Hey Dmitry, Rafael, George, please see below..

On Wed, Jan 27, 2021 at 10:10:07PM +0100, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 9:01 PM George Kennedy
 wrote:

Hi Dmitry,

On 1/27/2021 1:48 PM, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 7:44 PM Konrad Rzeszutek Wilk
 wrote:

On Tue, Jan 26, 2021 at 01:03:21PM -0500, George Kennedy wrote:

During boot of kernel with CONFIG_KASAN the following KASAN false
positive failure will occur when ibft_init() reads the
ACPI iBFT table: BUG: KASAN: use-after-free in ibft_init

The ACPI iBFT table is not allocated, and the iscsi driver uses
a pointer to it to calculate checksum, etc. KASAN complains
about this pointer with use-after-free, which this is not.

Andrey, Alexander, Dmitry,

I think this is the right way for this, but was wondering if 
you have

other suggestions?

Thanks!

Hi George, Konrad,

Please provide a sample KASAN report and kernel version to match
line numbers.

5.4.17-2102.200.0.0.20210106_

[   24.413536] iBFT detected.
[   24.414074]
==
[   24.407342] BUG: KASAN: use-after-free in ibft_init+0x134/0xb8b
[   24.407342] Read of size 4 at addr 8880be452004 by task
swapper/0/1
[   24.407342]
[   24.407342] CPU: 1 PID: 1 Comm: swapper/0 Not tainted
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.407342] Hardware name: QEMU Standard PC (i440FX + PIIX,
1996), BIOS 0.0.0 02/06/2015
[   24.407342] Call Trace:
[   24.407342]  dump_stack+0xd4/0x119
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342] print_address_description.constprop.6+0x20/0x220
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  __kasan_report.cold.9+0x37/0x77
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  kasan_report+0x14/0x1b
[   24.407342] __asan_report_load_n_noabort+0xf/0x11
[   24.407342]  ibft_init+0x134/0xb8b
[   24.407342]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.407342]  ? dmi_walk+0x72/0x89
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  ? rvt_init_port+0x110/0x101
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  do_one_initcall+0xc3/0x44d
[   24.407342]  ? perf_trace_initcall_level+0x410/0x405
[   24.407342]  kernel_init_freeable+0x551/0x673
[   24.407342]  ? start_kernel+0x94b/0x94b
[   24.407342]  ? __sanitizer_cov_trace_const_cmp1+0x1a/0x1c
[   24.407342]  ? __kasan_check_write+0x14/0x16
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  kernel_init+0x16/0x1bd
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  ret_from_fork+0x2b/0x36
[   24.407342]
[   24.407342] The buggy address belongs to the page:
[   24.407342] page:ea0002f91480 refcount:0 mapcount:0
mapping: index:0x1
[   24.407342] flags: 0xfc000()
[   24.407342] raw: 000fc000 ea0002fca588
ea0002fb1a88 
[   24.407342] raw: 0001 
 
[   24.407342] page dumped because: kasan: bad access detected
[   24.407342]
[   24.407342] Memory state around the buggy address:
[   24.407342]  8880be451f00: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[   24.407342]  8880be451f80: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[   24.407342] >8880be452000: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[   24.407342]    ^
[   24.407342]  8880be452080: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[   24.407342]  8880be452100: ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff
[   24.407342]
==
[   24.407342] Disabling lock debugging due to kernel taint
[   24.451021] Kernel panic - not syncing: panic_on_warn set ...
[   24.452002] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G B
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.452002] Hardware name: QEMU Standard PC (i440FX + PIIX,
1996), BIOS 0.0.0 02/06/2015
[   24.452002] Call Trace:
[   24.452002]  dump_stack+0xd4/0x119
[   24.452002]  ? ibft_init+0x102/0xb8b
[   24.452002]  panic+0x28f/0x6e0
[   24.452002]  ? __warn_printk+0xe0/0xe0
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  end_report+0x4c/0x54
[   24.452002]  __kasan_report.cold.9+0x55/0x77
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  kasan_report+0x14/0x1b
[   24.452002] __asan_report_load_n_noabort+0xf/0x11
[   24.452002]  ibft_init+0x134/0xb8b
[   24.452002]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.452002]  ? dmi_walk+0x72/0x89
[   24.452

Re: [PATCH 1/1] iscsi_ibft: KASAN false positive failure occurs in ibft_init()

2021-02-12 Thread George Kennedy




On 2/10/2021 4:51 PM, George Kennedy wrote:



On 2/3/2021 2:35 PM, Dmitry Vyukov wrote:
On Wed, Feb 3, 2021 at 8:29 PM Konrad Rzeszutek Wilk 
 wrote:

Hey Dmitry, Rafael, George, please see below..

On Wed, Jan 27, 2021 at 10:10:07PM +0100, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 9:01 PM George Kennedy
 wrote:

Hi Dmitry,

On 1/27/2021 1:48 PM, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 7:44 PM Konrad Rzeszutek Wilk
 wrote:

On Tue, Jan 26, 2021 at 01:03:21PM -0500, George Kennedy wrote:

During boot of kernel with CONFIG_KASAN the following KASAN false
positive failure will occur when ibft_init() reads the
ACPI iBFT table: BUG: KASAN: use-after-free in ibft_init

The ACPI iBFT table is not allocated, and the iscsi driver uses
a pointer to it to calculate checksum, etc. KASAN complains
about this pointer with use-after-free, which this is not.

Andrey, Alexander, Dmitry,

I think this is the right way for this, but was wondering if you have
other suggestions?

Thanks!

Hi George, Konrad,

Please provide a sample KASAN report and kernel version to match 
line numbers.


5.4.17-2102.200.0.0.20210106_

[   24.413536] iBFT detected.
[   24.414074]
==
[   24.407342] BUG: KASAN: use-after-free in ibft_init+0x134/0xb8b
[   24.407342] Read of size 4 at addr 8880be452004 by task 
swapper/0/1

[   24.407342]
[   24.407342] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.407342] Hardware name: QEMU Standard PC (i440FX + PIIX, 
1996), BIOS 0.0.0 02/06/2015

[   24.407342] Call Trace:
[   24.407342]  dump_stack+0xd4/0x119
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342] print_address_description.constprop.6+0x20/0x220
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  __kasan_report.cold.9+0x37/0x77
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  kasan_report+0x14/0x1b
[   24.407342]  __asan_report_load_n_noabort+0xf/0x11
[   24.407342]  ibft_init+0x134/0xb8b
[   24.407342]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.407342]  ? dmi_walk+0x72/0x89
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  ? rvt_init_port+0x110/0x101
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  do_one_initcall+0xc3/0x44d
[   24.407342]  ? perf_trace_initcall_level+0x410/0x405
[   24.407342]  kernel_init_freeable+0x551/0x673
[   24.407342]  ? start_kernel+0x94b/0x94b
[   24.407342]  ? __sanitizer_cov_trace_const_cmp1+0x1a/0x1c
[   24.407342]  ? __kasan_check_write+0x14/0x16
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  kernel_init+0x16/0x1bd
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  ret_from_fork+0x2b/0x36
[   24.407342]
[   24.407342] The buggy address belongs to the page:
[   24.407342] page:ea0002f91480 refcount:0 mapcount:0 
mapping: index:0x1

[   24.407342] flags: 0xfc000()
[   24.407342] raw: 000fc000 ea0002fca588 
ea0002fb1a88 
[   24.407342] raw: 0001  
 

[   24.407342] page dumped because: kasan: bad access detected
[   24.407342]
[   24.407342] Memory state around the buggy address:
[   24.407342]  8880be451f00: ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff
[   24.407342]  8880be451f80: ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff
[   24.407342] >8880be452000: ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff

[   24.407342]    ^
[   24.407342]  8880be452080: ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff
[   24.407342]  8880be452100: ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff

[   24.407342]
==
[   24.407342] Disabling lock debugging due to kernel taint
[   24.451021] Kernel panic - not syncing: panic_on_warn set ...
[   24.452002] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G B 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.452002] Hardware name: QEMU Standard PC (i440FX + PIIX, 
1996), BIOS 0.0.0 02/06/2015

[   24.452002] Call Trace:
[   24.452002]  dump_stack+0xd4/0x119
[   24.452002]  ? ibft_init+0x102/0xb8b
[   24.452002]  panic+0x28f/0x6e0
[   24.452002]  ? __warn_printk+0xe0/0xe0
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  end_report+0x4c/0x54
[   24.452002]  __kasan_report.cold.9+0x55/0x77
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  kasan_report+0x14/0x1b
[   24.452002]  __asan_report_load_n_noabort+0xf/0x11
[   24.452002]  ibft_init+0x134/0xb8b
[   24.452002]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.452002]  ? dmi_walk+0x72/0x89
[   24.452002]  ? ibft_check_initiator_for+0x159/0x159
[   24.452002]  ? rvt_init_port+0x110/0x101
[   24.452002]  ? ibft_check_initiator_for+0x159/0x

Re: [PATCH 1/1] iscsi_ibft: KASAN false positive failure occurs in ibft_init()

2021-02-10 Thread George Kennedy




On 2/3/2021 2:35 PM, Dmitry Vyukov wrote:

On Wed, Feb 3, 2021 at 8:29 PM Konrad Rzeszutek Wilk  wrote:

Hey Dmitry, Rafael, George, please see below..

On Wed, Jan 27, 2021 at 10:10:07PM +0100, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 9:01 PM George Kennedy
 wrote:

Hi Dmitry,

On 1/27/2021 1:48 PM, Dmitry Vyukov wrote:

On Wed, Jan 27, 2021 at 7:44 PM Konrad Rzeszutek Wilk
 wrote:

On Tue, Jan 26, 2021 at 01:03:21PM -0500, George Kennedy wrote:

During boot of kernel with CONFIG_KASAN the following KASAN false
positive failure will occur when ibft_init() reads the
ACPI iBFT table: BUG: KASAN: use-after-free in ibft_init

The ACPI iBFT table is not allocated, and the iscsi driver uses
a pointer to it to calculate checksum, etc. KASAN complains
about this pointer with use-after-free, which this is not.

Andrey, Alexander, Dmitry,

I think this is the right way for this, but was wondering if you have
other suggestions?

Thanks!

Hi George, Konrad,

Please provide a sample KASAN report and kernel version to match line numbers.

5.4.17-2102.200.0.0.20210106_

[   24.413536] iBFT detected.
[   24.414074]
==
[   24.407342] BUG: KASAN: use-after-free in ibft_init+0x134/0xb8b
[   24.407342] Read of size 4 at addr 8880be452004 by task swapper/0/1
[   24.407342]
[   24.407342] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.407342] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
0.0.0 02/06/2015
[   24.407342] Call Trace:
[   24.407342]  dump_stack+0xd4/0x119
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  print_address_description.constprop.6+0x20/0x220
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  __kasan_report.cold.9+0x37/0x77
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  kasan_report+0x14/0x1b
[   24.407342]  __asan_report_load_n_noabort+0xf/0x11
[   24.407342]  ibft_init+0x134/0xb8b
[   24.407342]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.407342]  ? dmi_walk+0x72/0x89
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  ? rvt_init_port+0x110/0x101
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  do_one_initcall+0xc3/0x44d
[   24.407342]  ? perf_trace_initcall_level+0x410/0x405
[   24.407342]  kernel_init_freeable+0x551/0x673
[   24.407342]  ? start_kernel+0x94b/0x94b
[   24.407342]  ? __sanitizer_cov_trace_const_cmp1+0x1a/0x1c
[   24.407342]  ? __kasan_check_write+0x14/0x16
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  kernel_init+0x16/0x1bd
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  ret_from_fork+0x2b/0x36
[   24.407342]
[   24.407342] The buggy address belongs to the page:
[   24.407342] page:ea0002f91480 refcount:0 mapcount:0 
mapping: index:0x1
[   24.407342] flags: 0xfc000()
[   24.407342] raw: 000fc000 ea0002fca588 ea0002fb1a88 

[   24.407342] raw: 0001   

[   24.407342] page dumped because: kasan: bad access detected
[   24.407342]
[   24.407342] Memory state around the buggy address:
[   24.407342]  8880be451f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]  8880be451f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342] >8880be452000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]^
[   24.407342]  8880be452080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]  8880be452100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]
==
[   24.407342] Disabling lock debugging due to kernel taint
[   24.451021] Kernel panic - not syncing: panic_on_warn set ...
[   24.452002] CPU: 1 PID: 1 Comm: swapper/0 Tainted: GB 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.452002] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
0.0.0 02/06/2015
[   24.452002] Call Trace:
[   24.452002]  dump_stack+0xd4/0x119
[   24.452002]  ? ibft_init+0x102/0xb8b
[   24.452002]  panic+0x28f/0x6e0
[   24.452002]  ? __warn_printk+0xe0/0xe0
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  end_report+0x4c/0x54
[   24.452002]  __kasan_report.cold.9+0x55/0x77
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  kasan_report+0x14/0x1b
[   24.452002]  __asan_report_load_n_noabort+0xf/0x11
[   24.452002]  ibft_init+0x134/0xb8b
[   24.452002]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.452002]  ? dmi_walk+0x72/0x89
[   24.452002]  ? ibft_check_initiator_for+0x159/0x159
[   24.452002]  ? rvt_init_port+0x110/0x101
[   24.452002]  ? ibft_check_initiator_for+0x159/0x159
[   24.452002]  do_one_initcall+0xc3/0x

[PATCH] mtd: spi-nor: boya: add support for boya by25q128as

2021-02-07 Thread George Brooke
Adds support for the Boya Microelectronics BY25Q128AS 128 Mbit flash.
I tested this on the Creality WB-01 embedded device which uses this,
although that was with OpenWrt which is still using 5.4 so I had to
do a bit of porting work. Don't see how that would make much of a
difference though.

Signed-off-by: George Brooke 
---
 drivers/mtd/spi-nor/Makefile |  1 +
 drivers/mtd/spi-nor/boya.c   | 23 +++
 drivers/mtd/spi-nor/core.c   |  1 +
 drivers/mtd/spi-nor/core.h   |  1 +
 4 files changed, 26 insertions(+)
 create mode 100644 drivers/mtd/spi-nor/boya.c

diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile
index 653923896205..7d1551fbfbaa 100644
--- a/drivers/mtd/spi-nor/Makefile
+++ b/drivers/mtd/spi-nor/Makefile
@@ -2,6 +2,7 @@
 
 spi-nor-objs   := core.o sfdp.o
 spi-nor-objs   += atmel.o
+spi-nor-objs   += boya.o
 spi-nor-objs   += catalyst.o
 spi-nor-objs   += eon.o
 spi-nor-objs   += esmt.o
diff --git a/drivers/mtd/spi-nor/boya.c b/drivers/mtd/spi-nor/boya.c
new file mode 100644
index ..014b0087048a
--- /dev/null
+++ b/drivers/mtd/spi-nor/boya.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2005, Intec Automation Inc.
+ * Copyright (C) 2014, Freescale Semiconductor, Inc.
+ */
+
+#include 
+
+#include "core.h"
+
+static const struct flash_info boya_parts[] = {
+   /* Boya */
+   { "by25q128as", INFO(0x684018, 0, 64 * 1024, 256,
+   SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ |
+   SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB)
+   },
+};
+
+const struct spi_nor_manufacturer spi_nor_boya = {
+   .name = "boya",
+   .parts = boya_parts,
+   .nparts = ARRAY_SIZE(boya_parts),
+};
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 20df44b753da..4d0d003e9c3f 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2160,6 +2160,7 @@ int spi_nor_sr2_bit7_quad_enable(struct spi_nor *nor)
 
 static const struct spi_nor_manufacturer *manufacturers[] = {
_nor_atmel,
+   _nor_boya,
_nor_catalyst,
_nor_eon,
_nor_esmt,
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index d631ee299de3..d5ed5217228b 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -409,6 +409,7 @@ struct spi_nor_manufacturer {
 
 /* Manufacturer drivers. */
 extern const struct spi_nor_manufacturer spi_nor_atmel;
+extern const struct spi_nor_manufacturer spi_nor_boya;
 extern const struct spi_nor_manufacturer spi_nor_catalyst;
 extern const struct spi_nor_manufacturer spi_nor_eon;
 extern const struct spi_nor_manufacturer spi_nor_esmt;
-- 
2.30.0



[no subject]

2021-02-07 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


Re: [PATCH net-next 1/2] net: add EXPORT_INDIRECT_CALLABLE wrapper

2021-02-04 Thread George McCollister
I don't see the second patch.

Regards,
George McCollister


[no subject]

2021-02-03 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


[no subject]

2021-01-30 Thread george mike
Hallo

Mitt navn er George Mike. Jeg er advokat av yrke. Jeg ønsker å tilby deg
den pårørende til klienten min. Du vil arve summen av ($ 8,5 millioner)
dollar klienten min etterlot seg i banken før han døde.

Min klient er statsborger i landet ditt som døde i en bilulykke med sin kone
og eneste sønn. Jeg vil være berettiget med 50% av det totale fondet
mens 50% vil
være for deg.
Ta kontakt med min private e-post her for mer informasjon:
georgemike7...@gmail.com

Takk på forhånd,
Mr. George Mike,


Re: [PATCH 1/1] iscsi_ibft: KASAN false positive failure occurs in ibft_init()

2021-01-27 Thread George Kennedy
Hi Dmitry,

On 1/27/2021 1:48 PM, Dmitry Vyukov wrote:
> On Wed, Jan 27, 2021 at 7:44 PM Konrad Rzeszutek Wilk
>  wrote:
>> On Tue, Jan 26, 2021 at 01:03:21PM -0500, George Kennedy wrote:
>>> During boot of kernel with CONFIG_KASAN the following KASAN false
>>> positive failure will occur when ibft_init() reads the
>>> ACPI iBFT table: BUG: KASAN: use-after-free in ibft_init
>>>
>>> The ACPI iBFT table is not allocated, and the iscsi driver uses
>>> a pointer to it to calculate checksum, etc. KASAN complains
>>> about this pointer with use-after-free, which this is not.
>>>
>> Andrey, Alexander, Dmitry,
>>
>> I think this is the right way for this, but was wondering if you have
>> other suggestions?
>>
>> Thanks!
> Hi George, Konrad,
>
> Please provide a sample KASAN report and kernel version to match line numbers.

5.4.17-2102.200.0.0.20210106_

[   24.413536] iBFT detected.
[   24.414074]
==
[   24.407342] BUG: KASAN: use-after-free in ibft_init+0x134/0xb8b
[   24.407342] Read of size 4 at addr 8880be452004 by task swapper/0/1
[   24.407342]
[   24.407342] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.407342] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
0.0.0 02/06/2015
[   24.407342] Call Trace:
[   24.407342]  dump_stack+0xd4/0x119
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  print_address_description.constprop.6+0x20/0x220
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  __kasan_report.cold.9+0x37/0x77
[   24.407342]  ? ibft_init+0x134/0xb8b
[   24.407342]  kasan_report+0x14/0x1b
[   24.407342]  __asan_report_load_n_noabort+0xf/0x11
[   24.407342]  ibft_init+0x134/0xb8b
[   24.407342]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.407342]  ? dmi_walk+0x72/0x89
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  ? rvt_init_port+0x110/0x101
[   24.407342]  ? ibft_check_initiator_for+0x159/0x159
[   24.407342]  do_one_initcall+0xc3/0x44d
[   24.407342]  ? perf_trace_initcall_level+0x410/0x405
[   24.407342]  kernel_init_freeable+0x551/0x673
[   24.407342]  ? start_kernel+0x94b/0x94b
[   24.407342]  ? __sanitizer_cov_trace_const_cmp1+0x1a/0x1c
[   24.407342]  ? __kasan_check_write+0x14/0x16
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  kernel_init+0x16/0x1bd
[   24.407342]  ? rest_init+0xe6/0xe6
[   24.407342]  ret_from_fork+0x2b/0x36
[   24.407342]
[   24.407342] The buggy address belongs to the page:
[   24.407342] page:ea0002f91480 refcount:0 mapcount:0 
mapping: index:0x1
[   24.407342] flags: 0xfc000()
[   24.407342] raw: 000fc000 ea0002fca588 ea0002fb1a88 

[   24.407342] raw: 0001   

[   24.407342] page dumped because: kasan: bad access detected
[   24.407342]
[   24.407342] Memory state around the buggy address:
[   24.407342]  8880be451f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]  8880be451f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342] >8880be452000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]^
[   24.407342]  8880be452080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]  8880be452100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff
[   24.407342]
==
[   24.407342] Disabling lock debugging due to kernel taint
[   24.451021] Kernel panic - not syncing: panic_on_warn set ...
[   24.452002] CPU: 1 PID: 1 Comm: swapper/0 Tainted: GB 
5.4.17-2102.200.0.0.20210106_.syzk #1
[   24.452002] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
0.0.0 02/06/2015
[   24.452002] Call Trace:
[   24.452002]  dump_stack+0xd4/0x119
[   24.452002]  ? ibft_init+0x102/0xb8b
[   24.452002]  panic+0x28f/0x6e0
[   24.452002]  ? __warn_printk+0xe0/0xe0
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? add_taint+0x68/0xb3
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  end_report+0x4c/0x54
[   24.452002]  __kasan_report.cold.9+0x55/0x77
[   24.452002]  ? ibft_init+0x134/0xb8b
[   24.452002]  kasan_report+0x14/0x1b
[   24.452002]  __asan_report_load_n_noabort+0xf/0x11
[   24.452002]  ibft_init+0x134/0xb8b
[   24.452002]  ? dmi_sysfs_init+0x1a5/0x1a5
[   24.452002]  ? dmi_walk+0x72/0x89
[   24.452002]  ? ibft_check_initiator_for+0x159/0x159
[   24.452002]  ? rvt_init_port+0x110/0x101
[   24.452002]  ? ibft_check_initiator_for+0x159/0x159
[   24.452002]  do_one_initcall+0xc3/0x44d
[   24.452002]  ? perf_trace_initcall_level+0x410/0x405
[   24.452002]  kernel_init_freeab

[PATCH 1/1] iscsi_ibft: KASAN false positive failure occurs in ibft_init()

2021-01-26 Thread George Kennedy
During boot of kernel with CONFIG_KASAN the following KASAN false
positive failure will occur when ibft_init() reads the
ACPI iBFT table: BUG: KASAN: use-after-free in ibft_init

The ACPI iBFT table is not allocated, and the iscsi driver uses
a pointer to it to calculate checksum, etc. KASAN complains
about this pointer with use-after-free, which this is not.

Signed-off-by: George Kennedy 
---
 drivers/firmware/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 5e013b6..30ddab5 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -14,6 +14,9 @@ obj-$(CONFIG_INTEL_STRATIX10_SERVICE) += stratix10-svc.o
 obj-$(CONFIG_INTEL_STRATIX10_RSU) += stratix10-rsu.o
 obj-$(CONFIG_ISCSI_IBFT_FIND)  += iscsi_ibft_find.o
 obj-$(CONFIG_ISCSI_IBFT)   += iscsi_ibft.o
+KASAN_SANITIZE_iscsi_ibft.o := n
+KCOV_INSTRUMENT_iscsi_ibft.o := n
+
 obj-$(CONFIG_FIRMWARE_MEMMAP)  += memmap.o
 obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
 obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o
-- 
1.8.3.1



[PATCH net-next 0/2] Add devlink health reporters for NIX block

2021-01-19 Thread George Cherian
Devlink health reporters are added for the NIX block.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

This series is in continuation to
https://www.spinics.net/lists/netdev/msg707798.html

Added Documentation for the same.

George Cherian (2):
  octeontx2-af: Add devlink health reporters for NIX
  docs: octeontx2: Add Documentation for NIX health reporters

 .../ethernet/marvell/octeontx2.rst|  70 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 652 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  27 +
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 4 files changed, 758 insertions(+), 1 deletion(-)

-- 
2.25.1



[PATCH net-next 2/2] docs: octeontx2: Add Documentation for NIX health reporters

2021-01-19 Thread George Cherian
Add devlink health reporter documentation for NIX block.

Signed-off-by: George Cherian 
---
 .../ethernet/marvell/octeontx2.rst| 70 +++
 1 file changed, 70 insertions(+)

diff --git 
a/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst 
b/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
index 61e850460e18..dd5cd69467be 100644
--- a/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
+++ b/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
@@ -217,3 +217,73 @@ For example::
 NPA_AF_ERR:
NPA Error Interrupt Reg : 4096
AQ Doorbell Error
+
+
+NIX Reporters
+-
+The NIX reporters are responsible for reporting and recovering the following 
group of errors:
+
+1. GENERAL events
+
+   - Receive mirror/multicast packet drop due to insufficient buffer.
+   - SMQ Flush operation.
+
+2. ERROR events
+
+   - Memory Fault due to WQE read/write from multicast/mirror buffer.
+   - Receive multicast/mirror replication list error.
+   - Receive packet on an unmapped PF.
+   - Fault due to NIX_AQ_INST_S read or NIX_AQ_RES_S write.
+   - AQ Doorbell Error.
+
+3. RAS events
+
+   - RAS Error Reporting for NIX Receive Multicast/Mirror Entry Structure.
+   - RAS Error Reporting for WQE/Packet Data read from Multicast/Mirror 
Buffer..
+   - RAS Error Reporting for NIX_AQ_INST_S/NIX_AQ_RES_S.
+
+4. RVU events
+
+   - Error due to unmapped slot.
+
+Sample Output::
+
+   ~# ./devlink health
+   pci/0002:01:00.0:
+ reporter hw_npa_intr
+   state healthy error 0 recover 0 grace_period 0 auto_recover true 
auto_dump true
+ reporter hw_npa_gen
+   state healthy error 0 recover 0 grace_period 0 auto_recover true 
auto_dump true
+ reporter hw_npa_err
+   state healthy error 0 recover 0 grace_period 0 auto_recover true 
auto_dump true
+ reporter hw_npa_ras
+   state healthy error 0 recover 0 grace_period 0 auto_recover true 
auto_dump true
+ reporter hw_nix_intr
+   state healthy error 1121 recover 1121 last_dump_date 2021-01-19 
last_dump_time 05:42:26 grace_period 0 auto_recover true auto_dump true
+ reporter hw_nix_gen
+   state healthy error 949 recover 949 last_dump_date 2021-01-19 
last_dump_time 05:42:43 grace_period 0 auto_recover true auto_dump true
+ reporter hw_nix_err
+   state healthy error 1147 recover 1147 last_dump_date 2021-01-19 
last_dump_time 05:42:59 grace_period 0 auto_recover true auto_dump true
+ reporter hw_nix_ras
+   state healthy error 409 recover 409 last_dump_date 2021-01-19 
last_dump_time 05:43:16 grace_period 0 auto_recover true auto_dump true
+
+Each reporter dumps the
+
+ - Error Type
+ - Error Register value
+ - Reason in words
+
+For example::
+
+   ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr
+NIX_AF_RVU:
+   NIX RVU Interrupt Reg : 1
+   Unmap Slot Error
+   ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen
+NIX_AF_GENERAL:
+   NIX General Interrupt Reg : 1
+   Rx multicast pkt drop
+   ~# devlink health dump show pci/0002:01:00.0 reporter hw_nix_err
+NIX_AF_ERR:
+   NIX Error Interrupt Reg : 64
+   Rx on unmapped PF_FUNC
-- 
2.25.1



[PATCH net-next 1/2] octeontx2-af: Add devlink health reporters for NIX

2021-01-19 Thread George Cherian
Add health reporters for RVU NIX block.
NIX Health reporters handle following HW event groups
- GENERAL events
- ERROR events
- RAS events
- RVU event

Output:

 # devlink health
 pci/0002:01:00.0:
   reporter hw_npa_intr
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_npa_gen
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_npa_err
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_npa_ras
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_nix_intr
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_nix_gen
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_nix_err
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
   reporter hw_nix_ras
 state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true

 # devlink health dump show pci/0002:01:00.0 reporter hw_nix_intr
  NIX_AF_RVU:
NIX RVU Interrupt Reg : 1
Unmap Slot Error
 # devlink health dump show pci/0002:01:00.0 reporter hw_nix_gen
  NIX_AF_GENERAL:
NIX General Interrupt Reg : 1
Rx multicast pkt drop

Each reporter dump shows the Register value and the description of the cause.

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 652 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  27 +
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 3 files changed, 688 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index bc0e4113370e..10a98bcb7c54 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -52,6 +52,650 @@ static bool rvu_common_request_irq(struct rvu *rvu, int 
offset,
return rvu->irq_allocated[offset];
 }
 
+static void rvu_nix_intr_work(struct work_struct *work)
+{
+   struct rvu_nix_health_reporters *rvu_nix_health_reporter;
+
+   rvu_nix_health_reporter = container_of(work, struct 
rvu_nix_health_reporters, intr_work);
+   devlink_health_report(rvu_nix_health_reporter->rvu_hw_nix_intr_reporter,
+ "NIX_AF_RVU Error",
+ rvu_nix_health_reporter->nix_event_ctx);
+}
+
+static irqreturn_t rvu_nix_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->rvu_nix_health_reporter->nix_event_ctx;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_RVU_INT);
+   nix_event_context->nix_af_rvu_int = intr;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT_ENA_W1C, ~0ULL);
+   queue_work(rvu_dl->devlink_wq, 
_dl->rvu_nix_health_reporter->intr_work);
+
+   return IRQ_HANDLED;
+}
+
+static void rvu_nix_gen_work(struct work_struct *work)
+{
+   struct rvu_nix_health_reporters *rvu_nix_health_reporter;
+
+   rvu_nix_health_reporter = container_of(work, struct 
rvu_nix_health_reporters, gen_work);
+   devlink_health_report(rvu_nix_health_reporter->rvu_hw_nix_gen_reporter,
+ "NIX_AF_GEN Error",
+ rvu_nix_health_reporter->nix_event_ctx);
+}
+
+static irqreturn_t rvu_nix_af_rvu_gen_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->rvu_nix_health_reporter->nix_event_ctx;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_GEN_INT);
+   nix_event_context->nix_af_rvu_gen = intr;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_GEN_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_GEN_INT_ENA_W1C, ~0ULL);
+   queue_work(rvu_dl->devlink_wq, 
_dl->rvu_nix_health_reporter->gen_work);
+
+   return IRQ_HANDLED;
+}
+
+static void rvu_nix_err_work(struct work_struct *work)
+{
+   struct rvu_nix_health_reporters *rvu_nix_health_reporter;
+
+   rvu_nix_health_reporter = container_

Re: [PATCH v2] docs: octeontx2: tune rst markup

2021-01-06 Thread George Cherian
On Wed, Jan 6, 2021 at 9:51 PM Lukas Bulwahn  wrote:
>
> Commit 80b9414832a1 ("docs: octeontx2: Add Documentation for NPA health
> reporters") added new documentation with improper formatting for rst, and
> caused a few new warnings for make htmldocs in octeontx2.rst:169--202.
>
> Tune markup and formatting for better presentation in the HTML view.
>
> Signed-off-by: Lukas Bulwahn 
> ---
> v1 -> v2: minor stylistic tuning as suggested by Randy
>
> applies cleanly on current master (v5.11-rc2) and next-20210106
>
> George, please ack.
> Jonathan, please pick this minor formatting clean-up patch.
>
Acked-by: George Cherian 

Regards
-George


Re: [PATCH v2] scripts/gdb: fix list_for_each

2021-01-05 Thread George Prekas

On 9/24/2020 9:20 AM, George Prekas wrote:

If the list is uninitialized (next pointer is NULL), list_for_each gets
stuck in an infinite loop. Print a message and treat list as empty.

Signed-off-by: George Prekas 
---
 scripts/gdb/linux/lists.py | 5 +
 1 file changed, 5 insertions(+)

diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py
index c487ddf09d38..bae4d70b7eae 100644
--- a/scripts/gdb/linux/lists.py
+++ b/scripts/gdb/linux/lists.py
@@ -27,6 +27,11 @@ def list_for_each(head):
 raise TypeError("Must be struct list_head not {}"
    .format(head.type))

+    if head['next'] == 0:
+    gdb.write("list_for_each: Uninitialized list '{}' treated as 
empty\n"

+ .format(head.address))
+    return
+
 node = head['next'].dereference()
 while node.address != head.address:
 yield node.address


Happy New Year!

Any updates on this?

Thanks,
George



[no subject]

2020-12-17 Thread george mike
dzień dobry

Nazywam się George Mike. Z zawodu jestem prawnikiem. Chcę ci zaoferować
najbliższy krewny mojego klienta. Odziedziczysz sumę (8,5 miliona dolarów)
dolarów, które mój klient zostawił w banku przed śmiercią.

Mój klient jest obywatelem twojego kraju, który zginął wraz z żoną w
wypadku samochodowym
i jedyny syn. Będę uprawniony do 50% całkowitego funduszu, podczas gdy
50% będzie
Być dla ciebie.
Aby uzyskać więcej informacji, skontaktuj się z moim prywatnym adresem
e-mail: georgemike7031gmail.com

Z góry bardzo dziękuję,
Panie George Mike


RE: [PATCH][next] octeontx2-af: Fix undetected unmap PF error check

2020-12-16 Thread George Cherian


> -Original Message-
> From: Colin King 
> Sent: Wednesday, December 16, 2020 6:06 PM
> To: Sunil Kovvuri Goutham ; Linu Cherian
> ; Geethasowjanya Akula ;
> Jerin Jacob Kollanukkaran ; David S . Miller
> ; Jakub Kicinski ; George
> Cherian ; net...@vger.kernel.org
> Cc: kernel-janit...@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH][next] octeontx2-af: Fix undetected unmap PF error
> check
> 
> From: Colin Ian King 
> 
> Currently the check for an unmap PF error is always going to be false because
> intr_val is a 32 bit int and is being bit-mask checked against 1ULL << 32.  
> Fix
> this by making intr_val a u64 to match the type at it is copied from, namely
> npa_event_context->npa_af_rvu_ge.
> 
> Addresses-Coverity: ("Operands don't affect result")
> Fixes: f1168d1e207c ("octeontx2-af: Add devlink health reporters for NPA")
> Signed-off-by: Colin Ian King 
Acked-by: George Cherian 

> ---
>  drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> index 3f9d0ab6d5ae..bc0e4113370e 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
> @@ -275,7 +275,8 @@ static int rvu_npa_report_show(struct devlink_fmsg
> *fmsg, void *ctx,
>  enum npa_af_rvu_health health_reporter)  {
>   struct rvu_npa_event_ctx *npa_event_context;
> - unsigned int intr_val, alloc_dis, free_dis;
> +     unsigned int alloc_dis, free_dis;
> + u64 intr_val;
>   int err;
> 
>   npa_event_context = ctx;
> --
> 2.29.2

Regards,
-George


[no subject]

2020-12-13 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


[PATCHv6 net-next 0/3] Add devlink and devlink health reporters to

2020-12-10 Thread George Cherian
Add basic devlink and devlink health reporters.
Devlink health reporters are added for NPA block.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

For now, I have dropped the NIX block health reporters. 
This series attempts to add health reporters only for the NPA block.
As per Jakub's suggestion separate reporters per event is used and also
got rid of the counters.

Change-log:
v6
 - Address Jakub comments
 - Add reporters per event for each block.
 - Remove the Sw counter.
 - Remove the mbox version from devlink info.

v5 
 - Address Jiri's comment
 - use devlink_fmsg_arr_pair_nest_start() for NIX blocks 

v4 
 - Rebase to net-next (no logic changes).
 
v3
 - Address Saeed's comments on v2.
 - Renamed the reporter name as hw_*.
 - Call devlink_health_report() when an event is raised.
 - Added recover op too.

v2
 - Address Willem's comments on v1.
 - Fixed the sparse issues, reported by Jakub.


George Cherian (3):
  octeontx2-af: Add devlink suppoort to af driver
  octeontx2-af: Add devlink health reporters for NPA
  docs: octeontx2: Add Documentation for NPA health reporters

 .../ethernet/marvell/octeontx2.rst|  50 ++
 .../net/ethernet/marvell/octeontx2/Kconfig|   1 +
 .../ethernet/marvell/octeontx2/af/Makefile|   2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   9 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   4 +
 .../marvell/octeontx2/af/rvu_devlink.c| 770 ++
 .../marvell/octeontx2/af/rvu_devlink.h|  55 ++
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 8 files changed, 912 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

-- 
2.25.1



[PATCHv6 net-next 1/3] octeontx2-af: Add devlink suppoort to af driver

2020-12-10 Thread George Cherian
Add devlink support to AF driver. Basic devlink support is added.
Currently info_get is the only supported devlink ops.

devlink ouptput looks like this
 # devlink dev
 pci/0002:01:00.0
 # devlink dev info
 pci/0002:01:00.0:
  driver octeontx2-af
 #

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../net/ethernet/marvell/octeontx2/Kconfig|  1 +
 .../ethernet/marvell/octeontx2/af/Makefile|  2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  9 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 64 +++
 .../marvell/octeontx2/af/rvu_devlink.h| 20 ++
 6 files changed, 98 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

diff --git a/drivers/net/ethernet/marvell/octeontx2/Kconfig 
b/drivers/net/ethernet/marvell/octeontx2/Kconfig
index 543a1d047567..16caa02095fe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/Kconfig
+++ b/drivers/net/ethernet/marvell/octeontx2/Kconfig
@@ -9,6 +9,7 @@ config OCTEONTX2_MBOX
 config OCTEONTX2_AF
tristate "Marvell OcteonTX2 RVU Admin Function driver"
select OCTEONTX2_MBOX
+   select NET_DEVLINK
depends on (64BIT && COMPILE_TEST) || ARM64
depends on PCI
help
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/Makefile 
b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
index 7100d1dd856e..eb535c98ca38 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/Makefile
+++ b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
- rvu_cpt.o
+ rvu_cpt.o rvu_devlink.o
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index 9f901c0edcbb..e8fd712860a1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2826,17 +2826,23 @@ static int rvu_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (err)
goto err_flr;
 
+   err = rvu_register_dl(rvu);
+   if (err)
+   goto err_irq;
+
rvu_setup_rvum_blk_revid(rvu);
 
/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
-   goto err_irq;
+   goto err_dl;
 
/* Initialize debugfs */
rvu_dbg_init(rvu);
 
return 0;
+err_dl:
+   rvu_unregister_dl(rvu);
 err_irq:
rvu_unregister_interrupts(rvu);
 err_flr:
@@ -2868,6 +2874,7 @@ static void rvu_remove(struct pci_dev *pdev)
 
rvu_dbg_exit(rvu);
rvu_unregister_interrupts(rvu);
+   rvu_unregister_dl(rvu);
rvu_flr_wq_destroy(rvu);
rvu_cgx_exit(rvu);
rvu_fwdata_exit(rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index b6c0977499ab..b1a6ecfd563e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -12,7 +12,10 @@
 #define RVU_H
 
 #include 
+#include 
+
 #include "rvu_struct.h"
+#include "rvu_devlink.h"
 #include "common.h"
 #include "mbox.h"
 #include "npc.h"
@@ -422,6 +425,7 @@ struct rvu {
 #ifdef CONFIG_DEBUG_FS
struct rvu_debugfs  rvu_dbg;
 #endif
+   struct rvu_devlink  *rvu_dl;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
new file mode 100644
index ..5dabca04a34b
--- /dev/null
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 RVU Devlink
+ *
+ * Copyright (C) 2020 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+#define DRV_NAME "octeontx2-af"
+
+static int rvu_devlink_info_get(struct devlink *devlink, struct 
devlink_info_req *req,
+   struct netlink_ext_ack *extack)
+{
+   return devlink_info_driver_name_put(req, DRV_NAME);
+}
+
+static const struct devlink_ops rvu_devlink_ops = {
+   .info_get = rvu_devlink_info_get,
+};
+
+int rvu_register_dl(struct rvu *rvu)
+{
+   struct rvu_devlink *rvu_dl;
+   struct devlink *dl;
+   int err;
+
+   rvu_dl = kzalloc(sizeof(*rvu_dl), GFP_KERNEL);
+   if (!rvu_dl)
+   return -ENOMEM;
+
+   dl = devlink_alloc(_devlink_ops, sizeof(struct rvu_devlink));
+   if (!dl) {
+ 

[PATCH 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-12-10 Thread George Cherian
Add health reporters for RVU NPA block.
NPA Health reporters handle following HW event groups
 - GENERAL events
 - ERROR events
 - RAS events
 - RVU event

Output:
 #devlink health
 pci/0002:01:00.0:
   reporter hw_npa_intr
 state healthy error 0 recover 0 grace_period 0 auto_recover true
 auto_dump true
   reporter hw_npa_gen
 state healthy error 0 recover 0 grace_period 0 auto_recover true
 auto_dump true
   reporter hw_npa_err
 state healthy error 0 recover 0 grace_period 0 auto_recover true
 auto_dump true
   reporter hw_npa_ras
 state healthy error 0 recover 0 grace_period 0 auto_recover true
 auto_dump true

 #devlink health dump show  pci/0002:01:00.0 reporter hw_npa_err
 NPA_AF_ERR:
NPA Error Interrupt Reg : 4096
AQ Doorbell Error
 #devlink health dump show  pci/0002:01:00.0 reporter hw_npa_ras
 NPA_AF_RVU_RAS:
NPA RAS Interrupt Reg : 0

 Each reporter dump shows the Register value and the description of the
cause.

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 708 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  35 +
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 3 files changed, 765 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 5dabca04a34b..3f9d0ab6d5ae 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -5,10 +5,714 @@
  *
  */
 
+#include
+
 #include "rvu.h"
+#include "rvu_reg.h"
+#include "rvu_struct.h"
 
 #define DRV_NAME "octeontx2-af"
 
+static int rvu_report_pair_start(struct devlink_fmsg *fmsg, const char *name)
+{
+   int err;
+
+   err = devlink_fmsg_pair_nest_start(fmsg, name);
+   if (err)
+   return err;
+
+   return  devlink_fmsg_obj_nest_start(fmsg);
+}
+
+static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
+{
+   int err;
+
+   err = devlink_fmsg_obj_nest_end(fmsg);
+   if (err)
+   return err;
+
+   return devlink_fmsg_pair_nest_end(fmsg);
+}
+
+static bool rvu_common_request_irq(struct rvu *rvu, int offset,
+  const char *name, irq_handler_t fn)
+{
+   struct rvu_devlink *rvu_dl = rvu->rvu_dl;
+   int rc;
+
+   sprintf(>irq_name[offset * NAME_SIZE], name);
+   rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0,
+>irq_name[offset * NAME_SIZE], rvu_dl);
+   if (rc)
+   dev_warn(rvu->dev, "Failed to register %s irq\n", name);
+   else
+   rvu->irq_allocated[offset] = true;
+
+   return rvu->irq_allocated[offset];
+}
+
+static void rvu_npa_intr_work(struct work_struct *work)
+{
+   struct rvu_npa_health_reporters *rvu_npa_health_reporter;
+
+   rvu_npa_health_reporter = container_of(work, struct 
rvu_npa_health_reporters, intr_work);
+   devlink_health_report(rvu_npa_health_reporter->rvu_hw_npa_intr_reporter,
+ "NPA_AF_RVU Error",
+ rvu_npa_health_reporter->npa_event_ctx);
+}
+
+static irqreturn_t rvu_npa_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   npa_event_context = rvu_dl->rvu_npa_health_reporter->npa_event_ctx;
+   intr = rvu_read64(rvu, blkaddr, NPA_AF_RVU_INT);
+   npa_event_context->npa_af_rvu_int = intr;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT_ENA_W1C, ~0ULL);
+   queue_work(rvu_dl->devlink_wq, 
_dl->rvu_npa_health_reporter->intr_work);
+
+   return IRQ_HANDLED;
+}
+
+static void rvu_npa_gen_work(struct work_struct *work)
+{
+   struct rvu_npa_health_reporters *rvu_npa_health_reporter;
+
+   rvu_npa_health_reporter = container_of(work, struct 
rvu_npa_health_reporters, gen_work);
+   devlink_health_report(rvu_npa_health_reporter->rvu_hw_npa_gen_reporter,
+ "NPA_AF_GEN Error",
+ rvu_npa_health_reporter->npa_event_ctx);
+}
+
+static irqreturn_t rvu_npa_af_gen_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   

[PATCH 3/3] docs: octeontx2: Add Documentation for NPA health reporters

2020-12-10 Thread George Cherian
Add Documentation for devlink health reporters for NPA block.

Signed-off-by: George Cherian 
---
 .../ethernet/marvell/octeontx2.rst| 50 +++
 1 file changed, 50 insertions(+)

diff --git 
a/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst 
b/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
index 88f508338c5f..d3fcf536d14e 100644
--- a/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
+++ b/Documentation/networking/device_drivers/ethernet/marvell/octeontx2.rst
@@ -12,6 +12,7 @@ Contents
 - `Overview`_
 - `Drivers`_
 - `Basic packet flow`_
+- `Devlink health reporters`_
 
 Overview
 
@@ -157,3 +158,52 @@ Egress
 3. The SQ descriptor ring is maintained in buffers allocated from SQ mapped 
pool of NPA block LF.
 4. NIX block transmits the pkt on the designated channel.
 5. NPC MCAM entries can be installed to divert pkt onto a different channel.
+
+Devlink health reporters
+
+
+NPA Reporters
+-
+The NPA reporters are responsible for reporting and recovering the following 
group of errors
+1. GENERAL events
+   - Error due to operation of unmapped PF.
+   - Error due to disabled alloc/free for other HW blocks (NIX, SSO, TIM, DPI 
and AURA).
+2. ERROR events
+   - Fault due to NPA_AQ_INST_S read or NPA_AQ_RES_S write.
+   - AQ Doorbell Error.
+3. RAS events
+   - RAS Error Reporting for NPA_AQ_INST_S/NPA_AQ_RES_S.
+4. RVU events
+   - Error due to unmapped slot.
+
+Sample Output
+-
+~# devlink health
+pci/0002:01:00.0:
+  reporter hw_npa_intr
+  state healthy error 2872 recover 2872 last_dump_date 2020-12-10 
last_dump_time 09:39:09 grace_period 0 auto_recover true auto_dump true
+  reporter hw_npa_gen
+  state healthy error 2872 recover 2872 last_dump_date 2020-12-11 
last_dump_time 04:43:04 grace_period 0 auto_recover true auto_dump true
+  reporter hw_npa_err
+  state healthy error 2871 recover 2871 last_dump_date 2020-12-10 
last_dump_time 09:39:17 grace_period 0 auto_recover true auto_dump true
+   reporter hw_npa_ras
+  state healthy error 0 recover 0 last_dump_date 2020-12-10 last_dump_time 
09:32:40 grace_period 0 auto_recover true auto_dump true
+
+Each reporter dumps the
+ - Error Type
+ - Error Register value
+ - Reason in words
+
+For eg:
+~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_gen
+ NPA_AF_GENERAL:
+ NPA General Interrupt Reg : 1
+ NIX0: free disabled RX
+~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_intr
+ NPA_AF_RVU:
+ NPA RVU Interrupt Reg : 1
+ Unmap Slot Error
+~# devlink health dump show  pci/0002:01:00.0 reporter hw_npa_err
+ NPA_AF_ERR:
+NPA Error Interrupt Reg : 4096
+AQ Doorbell Error
-- 
2.25.1



Re: [PATCH v4 net-next 1/2] net: dsa: add optional stats64 support

2020-12-07 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Allow DSA drivers to export stats64
>
> Signed-off-by: Oleksij Rempel 
> Reviewed-by: Vladimir Oltean 

Reviewed-by: George McCollister 

I've already updated my xrs700x dsa driver for v3 to use this. I'm
blocked on sending v3 until this is in. Please CC me on any updates.

Thanks,
George


[no subject]

2020-12-05 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


Re: [PATCH v4 net-next 2/2] net: dsa: qca: ar9331: export stats64

2020-12-04 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Add stats support for the ar9331 switch.
>
> Signed-off-by: Oleksij Rempel 
> ---
>  drivers/net/dsa/qca/ar9331.c | 247 ++-
>  1 file changed, 246 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c
> index 605d7b675216..4c1a4c448d80 100644
> --- a/drivers/net/dsa/qca/ar9331.c
> +++ b/drivers/net/dsa/qca/ar9331.c
> @@ -101,6 +101,57 @@
>  AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN 
> | \
>  AR9331_SW_PORT_STATUS_SPEED_M)
>
> +/* MIB registers */
> +#define AR9331_MIB_COUNTER(x)  (0x2 + ((x) * 0x100))
> +
> +#define AR9331_PORT_MIB_rxbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x00)
> +#define AR9331_PORT_MIB_rxpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x04)
> +#define AR9331_PORT_MIB_rxmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x08)
> +#define AR9331_PORT_MIB_rxfcserr(_port)
> (AR9331_MIB_COUNTER(_port) + 0x0c)
> +#define AR9331_PORT_MIB_rxalignerr(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x10)
> +#define AR9331_PORT_MIB_rxrunt(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x14)
> +#define AR9331_PORT_MIB_rxfragment(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x18)
> +#define AR9331_PORT_MIB_rx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x1c)
> +#define AR9331_PORT_MIB_rx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x20)
> +#define AR9331_PORT_MIB_rx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x24)
> +#define AR9331_PORT_MIB_rx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x28)
> +#define AR9331_PORT_MIB_rx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x2c)
> +#define AR9331_PORT_MIB_rx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x30)
> +#define AR9331_PORT_MIB_rxmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x34)
> +#define AR9331_PORT_MIB_rxtoolong(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x38)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxgoodbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x3c)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxbadbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x44)
> +
> +#define AR9331_PORT_MIB_rxoverflow(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x4c)
> +#define AR9331_PORT_MIB_filtered(_port)
> (AR9331_MIB_COUNTER(_port) + 0x50)
> +#define AR9331_PORT_MIB_txbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x54)
> +#define AR9331_PORT_MIB_txpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x58)
> +#define AR9331_PORT_MIB_txmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x5c)
> +#define AR9331_PORT_MIB_txunderrun(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x60)
> +#define AR9331_PORT_MIB_tx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x64)
> +#define AR9331_PORT_MIB_tx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x68)
> +#define AR9331_PORT_MIB_tx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x6c)
> +#define AR9331_PORT_MIB_tx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x70)
> +#define AR9331_PORT_MIB_tx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x74)
> +#define AR9331_PORT_MIB_tx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x78)
> +#define AR9331_PORT_MIB_txmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x7c)
> +#define AR9331_PORT_MIB_txoversize(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x80)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_txbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x84)
> +
> +#define AR9331_PORT_MIB_txcollision(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x8c)
> +#define AR9331_PORT_MIB_txabortcol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x90)
> +#define AR9331_PORT_MIB_txmulticol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x94)
> +#define AR9331_PORT_MIB_txsinglecol(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x98)
> +#define AR9331_PORT_MIB_txexcdefer(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x9c)
> +#define AR9331_PORT_MIB_txdefer(_port) (AR9331_MIB_COUNTER(_port) + 
> 0xa0)
> +#define AR9331_PORT_MIB_txlatecol(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0xa4)
> +
>  /* Phy bypass mode
>   * 
>   * Bit:   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 |
> @@ -154,6 +205,59 @@
>  #define AR9331_SW_MDIO_POLL_SLEEP_US   1
>  #define AR9331_SW_MDIO_POLL_TIMEOUT_US 20
>
> +#define STATS_INTERVAL_JIFFIES (3 * HZ)
> +
> +struct ar9331_sw_stats {
> +   u64 rxbroad;
> +   u64 rxpause;
> +   u64 rxmulti;
> +   u64 rxfcserr;
> +   u64 rxalignerr;
> +   u64 rxrunt;
> +   u64 rxfragment;
> +   u64 rx64byte;
> +   u64 rx128byte;
> +   u64 rx256byte;
> +   u64 rx512byte;
> +   u64 rx1024byte;
> +   u64 rx1518byte;
> +  

Re: [PATCH v4 net-next 2/2] net: dsa: qca: ar9331: export stats64

2020-12-04 Thread George McCollister
On Fri, Dec 4, 2020 at 8:59 AM Oleksij Rempel  wrote:
>
> Add stats support for the ar9331 switch.
>
> Signed-off-by: Oleksij Rempel 
> ---
>  drivers/net/dsa/qca/ar9331.c | 247 ++-
>  1 file changed, 246 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/qca/ar9331.c b/drivers/net/dsa/qca/ar9331.c
> index 605d7b675216..4c1a4c448d80 100644
> --- a/drivers/net/dsa/qca/ar9331.c
> +++ b/drivers/net/dsa/qca/ar9331.c
> @@ -101,6 +101,57 @@
>  AR9331_SW_PORT_STATUS_RX_FLOW_EN | AR9331_SW_PORT_STATUS_TX_FLOW_EN 
> | \
>  AR9331_SW_PORT_STATUS_SPEED_M)
>
> +/* MIB registers */
> +#define AR9331_MIB_COUNTER(x)  (0x2 + ((x) * 0x100))
> +
> +#define AR9331_PORT_MIB_rxbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x00)
> +#define AR9331_PORT_MIB_rxpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x04)
> +#define AR9331_PORT_MIB_rxmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x08)
> +#define AR9331_PORT_MIB_rxfcserr(_port)
> (AR9331_MIB_COUNTER(_port) + 0x0c)
> +#define AR9331_PORT_MIB_rxalignerr(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x10)
> +#define AR9331_PORT_MIB_rxrunt(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x14)
> +#define AR9331_PORT_MIB_rxfragment(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x18)
> +#define AR9331_PORT_MIB_rx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x1c)
> +#define AR9331_PORT_MIB_rx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x20)
> +#define AR9331_PORT_MIB_rx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x24)
> +#define AR9331_PORT_MIB_rx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x28)
> +#define AR9331_PORT_MIB_rx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x2c)
> +#define AR9331_PORT_MIB_rx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x30)
> +#define AR9331_PORT_MIB_rxmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x34)
> +#define AR9331_PORT_MIB_rxtoolong(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x38)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxgoodbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x3c)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_rxbadbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x44)
> +
> +#define AR9331_PORT_MIB_rxoverflow(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x4c)
> +#define AR9331_PORT_MIB_filtered(_port)
> (AR9331_MIB_COUNTER(_port) + 0x50)
> +#define AR9331_PORT_MIB_txbroad(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x54)
> +#define AR9331_PORT_MIB_txpause(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x58)
> +#define AR9331_PORT_MIB_txmulti(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x5c)
> +#define AR9331_PORT_MIB_txunderrun(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x60)
> +#define AR9331_PORT_MIB_tx64byte(_port)
> (AR9331_MIB_COUNTER(_port) + 0x64)
> +#define AR9331_PORT_MIB_tx128byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x68)
> +#define AR9331_PORT_MIB_tx256byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x6c)
> +#define AR9331_PORT_MIB_tx512byte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x70)
> +#define AR9331_PORT_MIB_tx1024byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x74)
> +#define AR9331_PORT_MIB_tx1518byte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x78)
> +#define AR9331_PORT_MIB_txmaxbyte(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0x7c)
> +#define AR9331_PORT_MIB_txoversize(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x80)
> +
> +/* 64 bit counter */
> +#define AR9331_PORT_MIB_txbyte(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x84)
> +
> +#define AR9331_PORT_MIB_txcollision(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x8c)
> +#define AR9331_PORT_MIB_txabortcol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x90)
> +#define AR9331_PORT_MIB_txmulticol(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x94)
> +#define AR9331_PORT_MIB_txsinglecol(_port) (AR9331_MIB_COUNTER(_port) + 
> 0x98)
> +#define AR9331_PORT_MIB_txexcdefer(_port)  (AR9331_MIB_COUNTER(_port) + 
> 0x9c)
> +#define AR9331_PORT_MIB_txdefer(_port) (AR9331_MIB_COUNTER(_port) + 
> 0xa0)
> +#define AR9331_PORT_MIB_txlatecol(_port)   (AR9331_MIB_COUNTER(_port) + 
> 0xa4)
> +
>  /* Phy bypass mode
>   * 
>   * Bit:   | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |10 |11 |12 |13 |14 |15 |
> @@ -154,6 +205,59 @@
>  #define AR9331_SW_MDIO_POLL_SLEEP_US   1
>  #define AR9331_SW_MDIO_POLL_TIMEOUT_US 20
>
> +#define STATS_INTERVAL_JIFFIES (3 * HZ)
> +
> +struct ar9331_sw_stats {
> +   u64 rxbroad;
> +   u64 rxpause;
> +   u64 rxmulti;
> +   u64 rxfcserr;
> +   u64 rxalignerr;
> +   u64 rxrunt;
> +   u64 rxfragment;
> +   u64 rx64byte;
> +   u64 rx128byte;
> +   u64 rx256byte;
> +   u64 rx512byte;
> +   u64 rx1024byte;
> +   u64 rx1518byte;
> +  

RE: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-30 Thread George Cherian



> -Original Message-
> From: George Cherian
> Sent: Tuesday, December 1, 2020 10:49 AM
> To: 'Jakub Kicinski' 
> Cc: 'net...@vger.kernel.org' ; 'linux-
> ker...@vger.kernel.org' ;
> 'da...@davemloft.net' ; Sunil Kovvuri Goutham
> ; Linu Cherian ;
> Geethasowjanya Akula ; 'masahi...@kernel.org'
> ; 'willemdebruijn.ker...@gmail.com'
> ; 'sa...@kernel.org'
> ; 'j...@resnulli.us' 
> Subject: RE: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> reporters for NPA
> 
> Jakub,
> 
> > -Original Message-
> > From: George Cherian
> > Sent: Tuesday, December 1, 2020 9:06 AM
> > To: Jakub Kicinski 
> > Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> > da...@davemloft.net; Sunil Kovvuri Goutham
> ;
> > Linu Cherian ; Geethasowjanya Akula
> > ; masahi...@kernel.org;
> > willemdebruijn.ker...@gmail.com; sa...@kernel.org; j...@resnulli.us
> > Subject: Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> > reporters for NPA
> >
> > Hi Jakub,
> >
> > > -Original Message-
> > > From: Jakub Kicinski 
> > > Sent: Tuesday, December 1, 2020 7:59 AM
> > > To: George Cherian 
> > > Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> > > da...@davemloft.net; Sunil Kovvuri Goutham
> > ;
> > > Linu Cherian ; Geethasowjanya Akula
> > > ; masahi...@kernel.org;
> > > willemdebruijn.ker...@gmail.com; sa...@kernel.org; j...@resnulli.us
> > > Subject: Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> > > reporters for NPA
> > >
> > > On Thu, 26 Nov 2020 19:32:50 +0530 George Cherian wrote:
> > > > Add health reporters for RVU NPA block.
> > > > NPA Health reporters handle following HW event groups
> > > >  - GENERAL events
> > > >  - ERROR events
> > > >  - RAS events
> > > >  - RVU event
> > > > An event counter per event is maintained in SW.
> > > >
> > > > Output:
> > > >  # devlink health
> > > >  pci/0002:01:00.0:
> > > >reporter hw_npa
> > > >  state healthy error 0 recover 0  # devlink  health dump show
> > > > pci/0002:01:00.0 reporter hw_npa
> > > >  NPA_AF_GENERAL:
> > > > Unmap PF Error: 0
> > > > NIX:
> > > > 0: free disabled RX: 0 free disabled TX: 0
> > > > 1: free disabled RX: 0 free disabled TX: 0
> > > > Free Disabled for SSO: 0
> > > > Free Disabled for TIM: 0
> > > > Free Disabled for DPI: 0
> > > > Free Disabled for AURA: 0
> > > > Alloc Disabled for Resvd: 0
> > > >   NPA_AF_ERR:
> > > > Memory Fault on NPA_AQ_INST_S read: 0
> > > > Memory Fault on NPA_AQ_RES_S write: 0
> > > > AQ Doorbell Error: 0
> > > > Poisoned data on NPA_AQ_INST_S read: 0
> > > > Poisoned data on NPA_AQ_RES_S write: 0
> > > > Poisoned data on HW context read: 0
> > > >   NPA_AF_RVU:
> > > > Unmap Slot Error: 0
> > >
> > > You seem to have missed the feedback Saeed and I gave you on v2.
> > >
> > > Did you test this with the errors actually triggering? Devlink
> > > should store only
> > Yes, the same was tested using devlink health test interface by
> > injecting errors.
> > The dump gets generated automatically and the counters do get out of
> > sync, in case of continuous error.
> > That wouldn't be much of an issue as the user could manually trigger a
> > dump clear and Re-dump the counters to get the exact status of the
> > counters at any point of time.
> 
> Now that recover op is added the devlink error counter and recover counter
> will be proper. The internal counter for each event is needed just to
> understand within a specific reporter, how many such events occurred.
> 
> Following is the log snippet of the devlink health test being done on hw_nix
> reporter.
> # for i in `seq 1 33` ; do  devlink health test pci/0002:01:00.0 reporter 
> hw_nix;
> done //Inject 33 errors (16  of NIX_AF_RVU and 17 of NIX_AF_RAS and
> NIX_AF_GENERAL errors) # devlink health
> pci/0002:01:00.0:
>   reporter hw_npa
> state healthy error 0 recover 0 grace_period 0 auto_recover true
> auto_dump true
>   reporter hw_nix
> state healthy error 250 recover 250 last_dump_date 1970-01-01
> last_dump_time 00:04:16 grace_period 0 auto_recover true auto_dump true
Oops,

RE: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-30 Thread George Cherian
Jakub,

> -Original Message-
> From: George Cherian
> Sent: Tuesday, December 1, 2020 9:06 AM
> To: Jakub Kicinski 
> Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> da...@davemloft.net; Sunil Kovvuri Goutham ;
> Linu Cherian ; Geethasowjanya Akula
> ; masahi...@kernel.org;
> willemdebruijn.ker...@gmail.com; sa...@kernel.org; j...@resnulli.us
> Subject: Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> reporters for NPA
> 
> Hi Jakub,
> 
> > -Original Message-
> > From: Jakub Kicinski 
> > Sent: Tuesday, December 1, 2020 7:59 AM
> > To: George Cherian 
> > Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> > da...@davemloft.net; Sunil Kovvuri Goutham
> ;
> > Linu Cherian ; Geethasowjanya Akula
> > ; masahi...@kernel.org;
> > willemdebruijn.ker...@gmail.com; sa...@kernel.org; j...@resnulli.us
> > Subject: Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> > reporters for NPA
> >
> > On Thu, 26 Nov 2020 19:32:50 +0530 George Cherian wrote:
> > > Add health reporters for RVU NPA block.
> > > NPA Health reporters handle following HW event groups
> > >  - GENERAL events
> > >  - ERROR events
> > >  - RAS events
> > >  - RVU event
> > > An event counter per event is maintained in SW.
> > >
> > > Output:
> > >  # devlink health
> > >  pci/0002:01:00.0:
> > >reporter hw_npa
> > >  state healthy error 0 recover 0  # devlink  health dump show
> > > pci/0002:01:00.0 reporter hw_npa
> > >  NPA_AF_GENERAL:
> > > Unmap PF Error: 0
> > > NIX:
> > > 0: free disabled RX: 0 free disabled TX: 0
> > > 1: free disabled RX: 0 free disabled TX: 0
> > > Free Disabled for SSO: 0
> > > Free Disabled for TIM: 0
> > > Free Disabled for DPI: 0
> > > Free Disabled for AURA: 0
> > > Alloc Disabled for Resvd: 0
> > >   NPA_AF_ERR:
> > > Memory Fault on NPA_AQ_INST_S read: 0
> > > Memory Fault on NPA_AQ_RES_S write: 0
> > > AQ Doorbell Error: 0
> > > Poisoned data on NPA_AQ_INST_S read: 0
> > > Poisoned data on NPA_AQ_RES_S write: 0
> > > Poisoned data on HW context read: 0
> > >   NPA_AF_RVU:
> > > Unmap Slot Error: 0
> >
> > You seem to have missed the feedback Saeed and I gave you on v2.
> >
> > Did you test this with the errors actually triggering? Devlink should
> > store only
> Yes, the same was tested using devlink health test interface by injecting
> errors.
> The dump gets generated automatically and the counters do get out of sync,
> in case of continuous error.
> That wouldn't be much of an issue as the user could manually trigger a dump
> clear and Re-dump the counters to get the exact status of the counters at
> any point of time.

Now that recover op is added the devlink error counter and recover counter will 
be 
proper. The internal counter for each event is needed just to understand within 
a specific reporter, how 
many such events occurred. 

Following is the log snippet of the devlink health test being done on hw_nix 
reporter.
# for i in `seq 1 33` ; do  devlink health test pci/0002:01:00.0 reporter 
hw_nix; done
//Inject 33 errors (16  of NIX_AF_RVU and 17 of NIX_AF_RAS and  NIX_AF_GENERAL 
errors)
# devlink health 
pci/0002:01:00.0:
  reporter hw_npa
state healthy error 0 recover 0 grace_period 0 auto_recover true auto_dump 
true
  reporter hw_nix
state healthy error 250 recover 250 last_dump_date 1970-01-01 
last_dump_time 00:04:16 grace_period 0 auto_recover true auto_dump true
# devlink health dump show pci/0002:01:00.0 reporter hw_nix
NIX_AF_GENERAL:
Memory Fault on NIX_AQ_INST_S read: 1 
Memory Fault on NIX_AQ_RES_S write: 1 
AQ Doorbell error: 1 
Rx on unmapped PF_FUNC: 1 
Rx multicast replication error: 1 
Memory fault on NIX_RX_MCE_S read: 1 
Memory fault on multicast WQE read: 1 
Memory fault on mirror WQE read: 1 
Memory fault on mirror pkt write: 1 
Memory fault on multicast pkt write: 1
  NIX_AF_RAS:
Poisoned data on NIX_AQ_INST_S read: 1 
Poisoned data on NIX_AQ_RES_S write: 1 
Poisoned data on HW context read: 1 
Poisoned data on packet read from mirror buffer: 1 
Poisoned data on packet read from mcast buffer: 1 
Poisoned data on WQE read from mirror buffer: 1 
Poisoned data on WQE read from multicast buffer: 1 
Poisoned data on NIX_RX_MCE_S read: 1
  NIX_AF_RVU:
Unmap Slot Error: 0
# 

Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-30 Thread George Cherian
Hi Jakub,

> -Original Message-
> From: Jakub Kicinski 
> Sent: Tuesday, December 1, 2020 7:59 AM
> To: George Cherian 
> Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> da...@davemloft.net; Sunil Kovvuri Goutham ;
> Linu Cherian ; Geethasowjanya Akula
> ; masahi...@kernel.org;
> willemdebruijn.ker...@gmail.com; sa...@kernel.org; j...@resnulli.us
> Subject: Re: [PATCHv5 net-next 2/3] octeontx2-af: Add devlink health
> reporters for NPA
> 
> On Thu, 26 Nov 2020 19:32:50 +0530 George Cherian wrote:
> > Add health reporters for RVU NPA block.
> > NPA Health reporters handle following HW event groups
> >  - GENERAL events
> >  - ERROR events
> >  - RAS events
> >  - RVU event
> > An event counter per event is maintained in SW.
> >
> > Output:
> >  # devlink health
> >  pci/0002:01:00.0:
> >reporter hw_npa
> >  state healthy error 0 recover 0
> >  # devlink  health dump show pci/0002:01:00.0 reporter hw_npa
> >  NPA_AF_GENERAL:
> > Unmap PF Error: 0
> > NIX:
> > 0: free disabled RX: 0 free disabled TX: 0
> > 1: free disabled RX: 0 free disabled TX: 0
> > Free Disabled for SSO: 0
> > Free Disabled for TIM: 0
> > Free Disabled for DPI: 0
> > Free Disabled for AURA: 0
> > Alloc Disabled for Resvd: 0
> >   NPA_AF_ERR:
> > Memory Fault on NPA_AQ_INST_S read: 0
> > Memory Fault on NPA_AQ_RES_S write: 0
> > AQ Doorbell Error: 0
> > Poisoned data on NPA_AQ_INST_S read: 0
> > Poisoned data on NPA_AQ_RES_S write: 0
> > Poisoned data on HW context read: 0
> >   NPA_AF_RVU:
> > Unmap Slot Error: 0
> 
> You seem to have missed the feedback Saeed and I gave you on v2.
> 
> Did you test this with the errors actually triggering? Devlink should store 
> only
Yes, the same was tested using devlink health test interface by injecting 
errors.
The dump gets generated automatically and the counters do get out of sync, 
in case of continuous error.
That wouldn't be much of an issue as the user could manually trigger a dump 
clear and 
Re-dump the counters to get the exact status of the counters at any point of 
time.

> one dump, are the counters not going to get out of sync unless something
> clears the dump every time it triggers?

Regards,
-George


[no subject]

2020-11-27 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


[PATCHv5 net-next 3/3] octeontx2-af: Add devlink health reporters for NIX

2020-11-26 Thread George Cherian
Add health reporters for RVU NIX block.
NIX Health reporter handle following HW event groups
 - GENERAL events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # devlink health
 pci/0002:01:00.0:
   reporter hw_npa
 state healthy error 0 recover 0
   reporter hw_nix
 state healthy error 0 recover 0
 # devlink  health dump show pci/0002:01:00.0 reporter hw_nix
  NIX_AF_GENERAL:
 Memory Fault on NIX_AQ_INST_S read: 0
 Memory Fault on NIX_AQ_RES_S write: 0
 AQ Doorbell error: 0
 Rx on unmapped PF_FUNC: 0
 Rx multicast replication error: 0
 Memory fault on NIX_RX_MCE_S read: 0
 Memory fault on multicast WQE read: 0
 Memory fault on mirror WQE read: 0
 Memory fault on mirror pkt write: 0
 Memory fault on multicast pkt write: 0
   NIX_AF_RAS:
 Poisoned data on NIX_AQ_INST_S read: 0
 Poisoned data on NIX_AQ_RES_S write: 0
 Poisoned data on HW context read: 0
 Poisoned data on packet read from mirror buffer: 0
 Poisoned data on packet read from mcast buffer: 0
 Poisoned data on WQE read from mirror buffer: 0
 Poisoned data on WQE read from multicast buffer: 0
 Poisoned data on NIX_RX_MCE_S read: 0
   NIX_AF_RVU:
 Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 414 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 3 files changed, 453 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 377264d65d0c..2f20d8b9eef3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -35,6 +35,131 @@ static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
return devlink_fmsg_pair_nest_end(fmsg);
 }
 
+static irqreturn_t rvu_nix_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_RVU_INT);
+   nix_event_context->nix_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   nix_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_nix_health_reporter, "NIX_AF_RVU 
Error",
+ nix_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t rvu_nix_af_err_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_ERR_INT);
+   nix_event_context->nix_af_rvu_err = intr;
+
+   if (intr & BIT_ULL(14))
+   nix_event_count->aq_inst_count++;
+   if (intr & BIT_ULL(13))
+   nix_event_count->aq_res_count++;
+   if (intr & BIT_ULL(12))
+   nix_event_count->aq_db_count++;
+   if (intr & BIT_ULL(6))
+   nix_event_count->rx_on_unmap_pf_count++;
+   if (intr & BIT_ULL(5))
+   nix_event_count->rx_mcast_repl_count++;
+   if (intr & BIT_ULL(4))
+   nix_event_count->rx_mcast_memfault_count++;
+   if (intr & BIT_ULL(3))
+   nix_event_count->rx_mcast_wqe_memfault_count++;
+   if (intr & BIT_ULL(2))
+   nix_event_count->rx_mirror_wqe_memfault_count++;
+   if (intr & BIT_ULL(1))
+   nix_event_count->rx_mirror_pktw_memfault_count++;
+   if (intr & BIT_ULL(0))
+   nix_event_count->rx_mcast_pktw_memfault_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT_ENA_W1C, ~0ULL);
+   dev

[PATCHv5 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-26 Thread George Cherian
Add health reporters for RVU NPA block.
NPA Health reporters handle following HW event groups
 - GENERAL events
 - ERROR events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # devlink health
 pci/0002:01:00.0:
   reporter hw_npa
 state healthy error 0 recover 0
 # devlink  health dump show pci/0002:01:00.0 reporter hw_npa
 NPA_AF_GENERAL:
Unmap PF Error: 0
NIX:
0: free disabled RX: 0 free disabled TX: 0
1: free disabled RX: 0 free disabled TX: 0
Free Disabled for SSO: 0
Free Disabled for TIM: 0
Free Disabled for DPI: 0
Free Disabled for AURA: 0
Alloc Disabled for Resvd: 0
  NPA_AF_ERR:
Memory Fault on NPA_AQ_INST_S read: 0
Memory Fault on NPA_AQ_RES_S write: 0
AQ Doorbell Error: 0
Poisoned data on NPA_AQ_INST_S read: 0
Poisoned data on NPA_AQ_RES_S write: 0
Poisoned data on HW context read: 0
  NPA_AF_RVU:
Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 498 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 3 files changed, 551 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 04ef945e7e75..377264d65d0c 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -5,10 +5,504 @@
  *
  */
 
+#include
+
 #include "rvu.h"
+#include "rvu_reg.h"
+#include "rvu_struct.h"
 
 #define DRV_NAME "octeontx2-af"
 
+static int rvu_report_pair_start(struct devlink_fmsg *fmsg, const char *name)
+{
+   int err;
+
+   err = devlink_fmsg_pair_nest_start(fmsg, name);
+   if (err)
+   return err;
+
+   return  devlink_fmsg_obj_nest_start(fmsg);
+}
+
+static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
+{
+   int err;
+
+   err = devlink_fmsg_obj_nest_end(fmsg);
+   if (err)
+   return err;
+
+   return devlink_fmsg_pair_nest_end(fmsg);
+}
+
+static bool rvu_common_request_irq(struct rvu *rvu, int offset,
+  const char *name, irq_handler_t fn)
+{
+   struct rvu_devlink *rvu_dl = rvu->rvu_dl;
+   int rc;
+
+   sprintf(>irq_name[offset * NAME_SIZE], name);
+   rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0,
+>irq_name[offset * NAME_SIZE], rvu_dl);
+   if (rc)
+   dev_warn(rvu->dev, "Failed to register %s irq\n", name);
+   else
+   rvu->irq_allocated[offset] = true;
+
+   return rvu->irq_allocated[offset];
+}
+
+static irqreturn_t rvu_npa_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_npa_event_cnt *npa_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   npa_event_context = rvu_dl->npa_event_ctx;
+   npa_event_count = _event_context->npa_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NPA_AF_RVU_INT);
+   npa_event_context->npa_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   npa_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_npa_health_reporter, "NPA_AF_RVU 
Error",
+ npa_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static int rvu_npa_inpq_to_cnt(u16 in,
+  struct rvu_npa_event_cnt *npa_event_count)
+{
+   switch (in) {
+   case 0:
+   return 0;
+   case BIT(NPA_INPQ_NIX0_RX):
+   return npa_event_count->free_dis_nix0_rx_count++;
+   case BIT(NPA_INPQ_NIX0_TX):
+   return npa_event_count->free_dis_nix0_tx_count++;
+   case BIT(NPA_INPQ_NIX1_RX):
+   return npa_event_count->free_dis_nix1_rx_count++;
+   case BIT(NPA_INPQ_NIX1_TX):
+   return npa_event_count->free_dis_nix1_tx_count++;
+   case BIT(NPA_INPQ_SSO):
+   return npa_event_count->free_dis_sso_count++;
+   case BIT(NPA_INPQ_TIM):
+   return npa_event_count->free_dis_tim_count++;
+   case BIT(NPA_INPQ_DPI):
+   return npa_event_count->free_dis_dpi_count++;
+   case BIT(NPA_INPQ_AURA_OP):
+   return npa_event_cou

[PATCHv5 net-next 1/3] octeontx2-af: Add devlink suppoort to af driver

2020-11-26 Thread George Cherian
Add devlink support to AF driver. Basic devlink support is added.
Currently info_get is the only supported devlink ops.

devlink ouptput looks like this
 # devlink dev
 pci/0002:01:00.0
 # devlink dev info
 pci/0002:01:00.0:
  driver octeontx2-af
  versions:
  fixed:
mbox version: 9

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../net/ethernet/marvell/octeontx2/Kconfig|  1 +
 .../ethernet/marvell/octeontx2/af/Makefile|  2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  9 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 72 +++
 .../marvell/octeontx2/af/rvu_devlink.h| 20 ++
 6 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

diff --git a/drivers/net/ethernet/marvell/octeontx2/Kconfig 
b/drivers/net/ethernet/marvell/octeontx2/Kconfig
index 543a1d047567..16caa02095fe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/Kconfig
+++ b/drivers/net/ethernet/marvell/octeontx2/Kconfig
@@ -9,6 +9,7 @@ config OCTEONTX2_MBOX
 config OCTEONTX2_AF
tristate "Marvell OcteonTX2 RVU Admin Function driver"
select OCTEONTX2_MBOX
+   select NET_DEVLINK
depends on (64BIT && COMPILE_TEST) || ARM64
depends on PCI
help
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/Makefile 
b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
index 7100d1dd856e..eb535c98ca38 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/Makefile
+++ b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
- rvu_cpt.o
+ rvu_cpt.o rvu_devlink.o
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index 9f901c0edcbb..e8fd712860a1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2826,17 +2826,23 @@ static int rvu_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (err)
goto err_flr;
 
+   err = rvu_register_dl(rvu);
+   if (err)
+   goto err_irq;
+
rvu_setup_rvum_blk_revid(rvu);
 
/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
-   goto err_irq;
+   goto err_dl;
 
/* Initialize debugfs */
rvu_dbg_init(rvu);
 
return 0;
+err_dl:
+   rvu_unregister_dl(rvu);
 err_irq:
rvu_unregister_interrupts(rvu);
 err_flr:
@@ -2868,6 +2874,7 @@ static void rvu_remove(struct pci_dev *pdev)
 
rvu_dbg_exit(rvu);
rvu_unregister_interrupts(rvu);
+   rvu_unregister_dl(rvu);
rvu_flr_wq_destroy(rvu);
rvu_cgx_exit(rvu);
rvu_fwdata_exit(rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index b6c0977499ab..b1a6ecfd563e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -12,7 +12,10 @@
 #define RVU_H
 
 #include 
+#include 
+
 #include "rvu_struct.h"
+#include "rvu_devlink.h"
 #include "common.h"
 #include "mbox.h"
 #include "npc.h"
@@ -422,6 +425,7 @@ struct rvu {
 #ifdef CONFIG_DEBUG_FS
struct rvu_debugfs  rvu_dbg;
 #endif
+   struct rvu_devlink  *rvu_dl;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
new file mode 100644
index ..04ef945e7e75
--- /dev/null
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 RVU Devlink
+ *
+ * Copyright (C) 2020 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+#define DRV_NAME "octeontx2-af"
+
+static int rvu_devlink_info_get(struct devlink *devlink, struct 
devlink_info_req *req,
+   struct netlink_ext_ack *extack)
+{
+   char buf[10];
+   int err;
+
+   err = devlink_info_driver_name_put(req, DRV_NAME);
+   if (err)
+   return err;
+
+   sprintf(buf, "%X", OTX2_MBOX_VERSION);
+   return devlink_info_version_fixed_put(req, "mbox version:", buf);
+}
+
+static const struct devlink_ops rvu_devlink_ops = {
+   .info_get = rvu_devlink_info_get,
+};
+
+int rvu_register_dl(struct rvu *rvu)
+{
+   struct

[PATCHv5 net-next 0/3] Add devlink and devlink health reporters to

2020-11-26 Thread George Cherian


Add basic devlink and devlink health reporters.
Devlink health reporters are added for NPA and NIX blocks.
These reporters report the error count in respective blocks.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

Change-log:
v5 
 - Address Jiri's comment
 - use devlink_fmsg_arr_pair_nest_start() for NIX blocks 

v4 
 - Rebase to net-next (no logic changes).
 
v3
 - Address Saeed's comments on v2.
 - Renamed the reporter name as hw_*.
 - Call devlink_health_report() when an event is raised.
 - Added recover op too.

v2
 - Address Willem's comments on v1.
 - Fixed the sparse issues, reported by Jakub.


George Cherian (3):
  octeontx2-af: Add devlink suppoort to af driver
  octeontx2-af: Add devlink health reporters for NPA
  octeontx2-af: Add devlink health reporters for NIX

 .../net/ethernet/marvell/octeontx2/Kconfig|   1 +
 .../ethernet/marvell/octeontx2/af/Makefile|   2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   9 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   4 +
 .../marvell/octeontx2/af/rvu_devlink.c| 978 ++
 .../marvell/octeontx2/af/rvu_devlink.h|  82 ++
 .../marvell/octeontx2/af/rvu_struct.h |  33 +
 7 files changed, 1107 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

-- 
2.25.1



Re: [PATCHv4 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-23 Thread George Cherian
Hi Jiri,

> -Original Message-
> From: Jiri Pirko 
> Sent: Monday, November 23, 2020 3:52 PM
> To: George Cherian 
> Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> k...@kernel.org; da...@davemloft.net; Sunil Kovvuri Goutham
> ; Linu Cherian ;
> Geethasowjanya Akula ; masahi...@kernel.org;
> willemdebruijn.ker...@gmail.com; sa...@kernel.org
> Subject: Re: [PATCHv4 net-next 2/3] octeontx2-af: Add devlink health
> reporters for NPA
> 
> Mon, Nov 23, 2020 at 03:49:06AM CET, gcher...@marvell.com wrote:
> >
> >
> >> -Original Message-
> >> From: Jiri Pirko 
> >> Sent: Saturday, November 21, 2020 7:44 PM
> >> To: George Cherian 
> >> Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> >> k...@kernel.org; da...@davemloft.net; Sunil Kovvuri Goutham
> >> ; Linu Cherian ;
> >> Geethasowjanya Akula ; masahi...@kernel.org;
> >> willemdebruijn.ker...@gmail.com; sa...@kernel.org
> >> Subject: Re: [PATCHv4 net-next 2/3] octeontx2-af: Add devlink health
> >> reporters for NPA
> >>
> >> Sat, Nov 21, 2020 at 05:02:00AM CET, george.cher...@marvell.com wrote:
> >> >Add health reporters for RVU NPA block.
> >> >NPA Health reporters handle following HW event groups
> >> > - GENERAL events
> >> > - ERROR events
> >> > - RAS events
> >> > - RVU event
> >> >An event counter per event is maintained in SW.
> >> >
> >> >Output:
> >> > # devlink health
> >> > pci/0002:01:00.0:
> >> >   reporter npa
> >> > state healthy error 0 recover 0  # devlink  health dump show
> >> >pci/0002:01:00.0 reporter npa
> >> > NPA_AF_GENERAL:
> >> >Unmap PF Error: 0
> >> >Free Disabled for NIX0 RX: 0
> >> >Free Disabled for NIX0 TX: 0
> >> >Free Disabled for NIX1 RX: 0
> >> >Free Disabled for NIX1 TX: 0
> >>
> >> This is for 2 ports if I'm not mistaken. Then you need to have this
> >> reporter per-port. Register ports and have reporter for each.
> >>
> >No, these are not port specific reports.
> >NIX is the Network Interface Controller co-processor block.
> >There are (max of) 2 such co-processor blocks per SoC.
> 
> Ah. I see. In that case, could you please structure the json differently. 
> Don't
> concatenate the number with the string. Instead of that, please have 2
> subtrees, one for each NIX.
> 
NPA_AF_GENERAL:
Unmap PF Error: 0
Free Disabled for NIX0 
RX: 0
TX: 0
Free Disabled for NIX1
RX: 0
TX: 0

Something like this?

Regards,
-George
> 
> >
> >Moreover, this is an NPA (Network Pool/Buffer Allocator co- processor)
> reporter.
> >This tells whether a free or alloc operation is skipped due to the
> >configurations set by other co-processor blocks (NIX,SSO,TIM etc).
> >
> >https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__www.kernel.org_doc
> >_html_latest_networking_device-
> 5Fdrivers_ethernet_marvell_octeontx2.htm
> >l=DwIBAg=nKjWec2b6R0mOyPaz7xtfQ=npgTSgHrUSLmXpBZJKVhk0
> lE_XNvtVDl8
> >ZA2zBvBqPw=FNPm6lB8fRvGYvMqQWer6S9WI6rZIlMmDCqbM8xrnxM
> =B47zBTfDlIdM
> >xUmK0hmQkuoZnsGZYSzkvbZUloevT0A=
> >> NAK.



Re: [PATCHv4 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-22 Thread George Cherian



> -Original Message-
> From: Jiri Pirko 
> Sent: Saturday, November 21, 2020 7:44 PM
> To: George Cherian 
> Cc: net...@vger.kernel.org; linux-kernel@vger.kernel.org;
> k...@kernel.org; da...@davemloft.net; Sunil Kovvuri Goutham
> ; Linu Cherian ;
> Geethasowjanya Akula ; masahi...@kernel.org;
> willemdebruijn.ker...@gmail.com; sa...@kernel.org
> Subject: Re: [PATCHv4 net-next 2/3] octeontx2-af: Add devlink health
> reporters for NPA
> 
> Sat, Nov 21, 2020 at 05:02:00AM CET, george.cher...@marvell.com wrote:
> >Add health reporters for RVU NPA block.
> >NPA Health reporters handle following HW event groups
> > - GENERAL events
> > - ERROR events
> > - RAS events
> > - RVU event
> >An event counter per event is maintained in SW.
> >
> >Output:
> > # devlink health
> > pci/0002:01:00.0:
> >   reporter npa
> > state healthy error 0 recover 0
> > # devlink  health dump show pci/0002:01:00.0 reporter npa
> > NPA_AF_GENERAL:
> >Unmap PF Error: 0
> >Free Disabled for NIX0 RX: 0
> >Free Disabled for NIX0 TX: 0
> >Free Disabled for NIX1 RX: 0
> >Free Disabled for NIX1 TX: 0
> 
> This is for 2 ports if I'm not mistaken. Then you need to have this reporter
> per-port. Register ports and have reporter for each.
> 
No, these are not port specific reports.
NIX is the Network Interface Controller co-processor block.
There are (max of) 2 such co-processor blocks per SoC.

Moreover, this is an NPA (Network Pool/Buffer Allocator co- processor) reporter.
This tells whether a free or alloc operation is skipped due to the 
configurations set by
other co-processor blocks (NIX,SSO,TIM etc).

https://www.kernel.org/doc/html/latest/networking/device_drivers/ethernet/marvell/octeontx2.html
> NAK.


[PATCHv4 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-20 Thread George Cherian
Add health reporters for RVU NPA block.
NPA Health reporters handle following HW event groups
 - GENERAL events
 - ERROR events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
 # devlink  health dump show pci/0002:01:00.0 reporter npa
 NPA_AF_GENERAL:
Unmap PF Error: 0
Free Disabled for NIX0 RX: 0
Free Disabled for NIX0 TX: 0
Free Disabled for NIX1 RX: 0
Free Disabled for NIX1 TX: 0
Free Disabled for SSO: 0
Free Disabled for TIM: 0
Free Disabled for DPI: 0
Free Disabled for AURA: 0
Alloc Disabled for Resvd: 0
  NPA_AF_ERR:
Memory Fault on NPA_AQ_INST_S read: 0
Memory Fault on NPA_AQ_RES_S write: 0
AQ Doorbell Error: 0
Poisoned data on NPA_AQ_INST_S read: 0
Poisoned data on NPA_AQ_RES_S write: 0
Poisoned data on HW context read: 0
  NPA_AF_RVU:
Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 492 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 3 files changed, 545 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 04ef945e7e75..b7f0691d86b0 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -5,10 +5,498 @@
  *
  */
 
+#include
+
 #include "rvu.h"
+#include "rvu_reg.h"
+#include "rvu_struct.h"
 
 #define DRV_NAME "octeontx2-af"
 
+static int rvu_report_pair_start(struct devlink_fmsg *fmsg, const char *name)
+{
+   int err;
+
+   err = devlink_fmsg_pair_nest_start(fmsg, name);
+   if (err)
+   return err;
+
+   return  devlink_fmsg_obj_nest_start(fmsg);
+}
+
+static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
+{
+   int err;
+
+   err = devlink_fmsg_obj_nest_end(fmsg);
+   if (err)
+   return err;
+
+   return devlink_fmsg_pair_nest_end(fmsg);
+}
+
+static bool rvu_common_request_irq(struct rvu *rvu, int offset,
+  const char *name, irq_handler_t fn)
+{
+   struct rvu_devlink *rvu_dl = rvu->rvu_dl;
+   int rc;
+
+   sprintf(>irq_name[offset * NAME_SIZE], name);
+   rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0,
+>irq_name[offset * NAME_SIZE], rvu_dl);
+   if (rc)
+   dev_warn(rvu->dev, "Failed to register %s irq\n", name);
+   else
+   rvu->irq_allocated[offset] = true;
+
+   return rvu->irq_allocated[offset];
+}
+
+static irqreturn_t rvu_npa_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_npa_event_cnt *npa_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   npa_event_context = rvu_dl->npa_event_ctx;
+   npa_event_count = _event_context->npa_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NPA_AF_RVU_INT);
+   npa_event_context->npa_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   npa_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_npa_health_reporter, "NPA_AF_RVU 
Error",
+ npa_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static int rvu_npa_inpq_to_cnt(u16 in,
+  struct rvu_npa_event_cnt *npa_event_count)
+{
+   switch (in) {
+   case 0:
+   return 0;
+   case BIT(NPA_INPQ_NIX0_RX):
+   return npa_event_count->free_dis_nix0_rx_count++;
+   case BIT(NPA_INPQ_NIX0_TX):
+   return npa_event_count->free_dis_nix0_tx_count++;
+   case BIT(NPA_INPQ_NIX1_RX):
+   return npa_event_count->free_dis_nix1_rx_count++;
+   case BIT(NPA_INPQ_NIX1_TX):
+   return npa_event_count->free_dis_nix1_tx_count++;
+   case BIT(NPA_INPQ_SSO):
+   return npa_event_count->free_dis_sso_count++;
+   case BIT(NPA_INPQ_TIM):
+   return npa_event_count->free_dis_tim_count++;
+   case BIT(NPA_INPQ_DPI):
+   return npa_event_count->free_dis_dpi_count++;
+   case BIT(NPA_INPQ_AURA_OP):

[PATCHv4 net-next 3/3] octeontx2-af: Add devlink health reporters for NIX

2020-11-20 Thread George Cherian
Add health reporters for RVU NIX block.
NIX Health reporter handle following HW event groups
 - GENERAL events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # ./devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
   reporter nix
 state healthy error 0 recover 0
 # ./devlink  health dump show pci/0002:01:00.0 reporter nix
  NIX_AF_GENERAL:
 Memory Fault on NIX_AQ_INST_S read: 0
 Memory Fault on NIX_AQ_RES_S write: 0
 AQ Doorbell error: 0
 Rx on unmapped PF_FUNC: 0
 Rx multicast replication error: 0
 Memory fault on NIX_RX_MCE_S read: 0
 Memory fault on multicast WQE read: 0
 Memory fault on mirror WQE read: 0
 Memory fault on mirror pkt write: 0
 Memory fault on multicast pkt write: 0
   NIX_AF_RAS:
 Poisoned data on NIX_AQ_INST_S read: 0
 Poisoned data on NIX_AQ_RES_S write: 0
 Poisoned data on HW context read: 0
 Poisoned data on packet read from mirror buffer: 0
 Poisoned data on packet read from mcast buffer: 0
 Poisoned data on WQE read from mirror buffer: 0
 Poisoned data on WQE read from multicast buffer: 0
 Poisoned data on NIX_RX_MCE_S read: 0
   NIX_AF_RVU:
 Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 414 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 3 files changed, 453 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index b7f0691d86b0..c02d0f56ae7a 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -35,6 +35,131 @@ static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
return devlink_fmsg_pair_nest_end(fmsg);
 }
 
+static irqreturn_t rvu_nix_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_RVU_INT);
+   nix_event_context->nix_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   nix_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_nix_health_reporter, "NIX_AF_RVU 
Error",
+ nix_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t rvu_nix_af_err_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_ERR_INT);
+   nix_event_context->nix_af_rvu_err = intr;
+
+   if (intr & BIT_ULL(14))
+   nix_event_count->aq_inst_count++;
+   if (intr & BIT_ULL(13))
+   nix_event_count->aq_res_count++;
+   if (intr & BIT_ULL(12))
+   nix_event_count->aq_db_count++;
+   if (intr & BIT_ULL(6))
+   nix_event_count->rx_on_unmap_pf_count++;
+   if (intr & BIT_ULL(5))
+   nix_event_count->rx_mcast_repl_count++;
+   if (intr & BIT_ULL(4))
+   nix_event_count->rx_mcast_memfault_count++;
+   if (intr & BIT_ULL(3))
+   nix_event_count->rx_mcast_wqe_memfault_count++;
+   if (intr & BIT_ULL(2))
+   nix_event_count->rx_mirror_wqe_memfault_count++;
+   if (intr & BIT_ULL(1))
+   nix_event_count->rx_mirror_pktw_memfault_count++;
+   if (intr & BIT_ULL(0))
+   nix_event_count->rx_mcast_pktw_memfault_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT_ENA_W1C, ~0ULL);
+   dev

[PATCHv4 net-next 1/3] octeontx2-af: Add devlink suppoort to af driver

2020-11-20 Thread George Cherian
Add devlink support to AF driver. Basic devlink support is added.
Currently info_get is the only supported devlink ops.

devlink ouptput looks like this
 # devlink dev
 pci/0002:01:00.0
 # devlink dev info
 pci/0002:01:00.0:
  driver octeontx2-af
  versions:
  fixed:
mbox version: 9

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../net/ethernet/marvell/octeontx2/Kconfig|  1 +
 .../ethernet/marvell/octeontx2/af/Makefile|  2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  9 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 72 +++
 .../marvell/octeontx2/af/rvu_devlink.h| 20 ++
 6 files changed, 106 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

diff --git a/drivers/net/ethernet/marvell/octeontx2/Kconfig 
b/drivers/net/ethernet/marvell/octeontx2/Kconfig
index 543a1d047567..16caa02095fe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/Kconfig
+++ b/drivers/net/ethernet/marvell/octeontx2/Kconfig
@@ -9,6 +9,7 @@ config OCTEONTX2_MBOX
 config OCTEONTX2_AF
tristate "Marvell OcteonTX2 RVU Admin Function driver"
select OCTEONTX2_MBOX
+   select NET_DEVLINK
depends on (64BIT && COMPILE_TEST) || ARM64
depends on PCI
help
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/Makefile 
b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
index 7100d1dd856e..eb535c98ca38 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/Makefile
+++ b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
@@ -10,4 +10,4 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
  rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \
- rvu_cpt.o
+ rvu_cpt.o rvu_devlink.o
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index 9f901c0edcbb..e8fd712860a1 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2826,17 +2826,23 @@ static int rvu_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (err)
goto err_flr;
 
+   err = rvu_register_dl(rvu);
+   if (err)
+   goto err_irq;
+
rvu_setup_rvum_blk_revid(rvu);
 
/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
-   goto err_irq;
+   goto err_dl;
 
/* Initialize debugfs */
rvu_dbg_init(rvu);
 
return 0;
+err_dl:
+   rvu_unregister_dl(rvu);
 err_irq:
rvu_unregister_interrupts(rvu);
 err_flr:
@@ -2868,6 +2874,7 @@ static void rvu_remove(struct pci_dev *pdev)
 
rvu_dbg_exit(rvu);
rvu_unregister_interrupts(rvu);
+   rvu_unregister_dl(rvu);
rvu_flr_wq_destroy(rvu);
rvu_cgx_exit(rvu);
rvu_fwdata_exit(rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index b6c0977499ab..b1a6ecfd563e 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -12,7 +12,10 @@
 #define RVU_H
 
 #include 
+#include 
+
 #include "rvu_struct.h"
+#include "rvu_devlink.h"
 #include "common.h"
 #include "mbox.h"
 #include "npc.h"
@@ -422,6 +425,7 @@ struct rvu {
 #ifdef CONFIG_DEBUG_FS
struct rvu_debugfs  rvu_dbg;
 #endif
+   struct rvu_devlink  *rvu_dl;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
new file mode 100644
index ..04ef945e7e75
--- /dev/null
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 RVU Devlink
+ *
+ * Copyright (C) 2020 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+#define DRV_NAME "octeontx2-af"
+
+static int rvu_devlink_info_get(struct devlink *devlink, struct 
devlink_info_req *req,
+   struct netlink_ext_ack *extack)
+{
+   char buf[10];
+   int err;
+
+   err = devlink_info_driver_name_put(req, DRV_NAME);
+   if (err)
+   return err;
+
+   sprintf(buf, "%X", OTX2_MBOX_VERSION);
+   return devlink_info_version_fixed_put(req, "mbox version:", buf);
+}
+
+static const struct devlink_ops rvu_devlink_ops = {
+   .info_get = rvu_devlink_info_get,
+};
+
+int rvu_register_dl(struct rvu *rvu)
+{
+   struct

[PATCHv3 net-next 0/3] Add devlink and devlink health reporters to

2020-11-20 Thread George Cherian
Add basic devlink and devlink health reporters.
Devlink health reporters are added for NPA and NIX blocks.
These reporters report the error count in respective blocks.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

Change-log:
v4 
 - Rebase to net-next (no logic changes).
 
v3
 - Address Saeed's comments on v2.
 - Renamed the reporter name as hw_*.
 - Call devlink_health_report() when an event is raised.
 - Added recover op too.

v2
 - Address Willem's comments on v1.
 - Fixed the sparse issues, reported by Jakub.


George Cherian (3):
  octeontx2-af: Add devlink suppoort to af driver
  octeontx2-af: Add devlink health reporters for NPA
  octeontx2-af: Add devlink health reporters for NIX

 .../net/ethernet/marvell/octeontx2/Kconfig|   1 +
 .../ethernet/marvell/octeontx2/af/Makefile|   2 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   9 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   4 +
 .../marvell/octeontx2/af/rvu_devlink.c| 972 ++
 .../marvell/octeontx2/af/rvu_devlink.h|  82 ++
 .../marvell/octeontx2/af/rvu_struct.h |  33 +
 7 files changed, 1101 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

-- 
2.25.1



[PATCH] octeontx2-af: Add support for RSS hashing based on Transport protocol field

2020-11-20 Thread George Cherian
Add support to choose RSS flow key algorithm with IPv4 transport protocol
field included in hashing input data. This will be enabled by default.
There-by enabling 3/5 tuple hash

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: George Cherian 
---
 drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 1 +
 drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c  | 7 +++
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h 
b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index f46de8419b77..97c8566b7da8 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -644,6 +644,7 @@ struct nix_rss_flowkey_cfg {
 #define NIX_FLOW_KEY_TYPE_INNR_SCTP BIT(16)
 #define NIX_FLOW_KEY_TYPE_INNR_ETH_DMAC BIT(17)
 #define NIX_FLOW_KEY_TYPE_VLAN BIT(20)
+#define NIX_FLOW_KEY_TYPE_IPV4_PROTO   BIT(21)
u32 flowkey_cfg; /* Flowkey types selected */
u8  group;   /* RSS context or group */
 };
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 8bac1dd3a1c2..ef016521b277 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -2429,6 +2429,13 @@ static int set_flowkey_fields(struct nix_rx_flowkey_alg 
*alg, u32 flow_cfg)
/* This should be set to 1, when SEL_CHAN is set */
field->bytesm1 = 1;
break;
+   case NIX_FLOW_KEY_TYPE_IPV4_PROTO:
+   field->lid = NPC_LID_LC;
+   field->hdr_offset = 9; /* offset */
+   field->bytesm1 = 0; /* 1 byte */
+   field->ltype_match = NPC_LT_LC_IP;
+   field->ltype_mask = 0xF;
+   break;
case NIX_FLOW_KEY_TYPE_IPV4:
case NIX_FLOW_KEY_TYPE_INNR_IPV4:
field->lid = NPC_LID_LC;
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c 
b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 9f3d6715748e..2ab927408656 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -355,7 +355,8 @@ int otx2_rss_init(struct otx2_nic *pfvf)
rss->flowkey_cfg = rss->enable ? rss->flowkey_cfg :
   NIX_FLOW_KEY_TYPE_IPV4 | NIX_FLOW_KEY_TYPE_IPV6 |
   NIX_FLOW_KEY_TYPE_TCP | NIX_FLOW_KEY_TYPE_UDP |
-  NIX_FLOW_KEY_TYPE_SCTP | NIX_FLOW_KEY_TYPE_VLAN;
+  NIX_FLOW_KEY_TYPE_SCTP | NIX_FLOW_KEY_TYPE_VLAN |
+  NIX_FLOW_KEY_TYPE_IPV4_PROTO;
 
ret = otx2_set_flowkey_cfg(pfvf);
if (ret)
-- 
2.25.1



[PATCHv3 net-next 2/3] octeontx2-af: Add devlink health reporters for NPA

2020-11-19 Thread George Cherian
Add health reporters for RVU NPA block.
NPA Health reporters handle following HW event groups
 - GENERAL events
 - ERROR events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
 # devlink  health dump show pci/0002:01:00.0 reporter npa
 NPA_AF_GENERAL:
Unmap PF Error: 0
Free Disabled for NIX0 RX: 0
Free Disabled for NIX0 TX: 0
Free Disabled for NIX1 RX: 0
Free Disabled for NIX1 TX: 0
Free Disabled for SSO: 0
Free Disabled for TIM: 0
Free Disabled for DPI: 0
Free Disabled for AURA: 0
Alloc Disabled for Resvd: 0
  NPA_AF_ERR:
Memory Fault on NPA_AQ_INST_S read: 0
Memory Fault on NPA_AQ_RES_S write: 0
AQ Doorbell Error: 0
Poisoned data on NPA_AQ_INST_S read: 0
Poisoned data on NPA_AQ_RES_S write: 0
Poisoned data on HW context read: 0
  NPA_AF_RVU:
Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 492 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  23 +
 3 files changed, 545 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index 04ef945e7e75..b7f0691d86b0 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -5,10 +5,498 @@
  *
  */
 
+#include
+
 #include "rvu.h"
+#include "rvu_reg.h"
+#include "rvu_struct.h"
 
 #define DRV_NAME "octeontx2-af"
 
+static int rvu_report_pair_start(struct devlink_fmsg *fmsg, const char *name)
+{
+   int err;
+
+   err = devlink_fmsg_pair_nest_start(fmsg, name);
+   if (err)
+   return err;
+
+   return  devlink_fmsg_obj_nest_start(fmsg);
+}
+
+static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
+{
+   int err;
+
+   err = devlink_fmsg_obj_nest_end(fmsg);
+   if (err)
+   return err;
+
+   return devlink_fmsg_pair_nest_end(fmsg);
+}
+
+static bool rvu_common_request_irq(struct rvu *rvu, int offset,
+  const char *name, irq_handler_t fn)
+{
+   struct rvu_devlink *rvu_dl = rvu->rvu_dl;
+   int rc;
+
+   sprintf(>irq_name[offset * NAME_SIZE], name);
+   rc = request_irq(pci_irq_vector(rvu->pdev, offset), fn, 0,
+>irq_name[offset * NAME_SIZE], rvu_dl);
+   if (rc)
+   dev_warn(rvu->dev, "Failed to register %s irq\n", name);
+   else
+   rvu->irq_allocated[offset] = true;
+
+   return rvu->irq_allocated[offset];
+}
+
+static irqreturn_t rvu_npa_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_npa_event_ctx *npa_event_context;
+   struct rvu_npa_event_cnt *npa_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPA, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   npa_event_context = rvu_dl->npa_event_ctx;
+   npa_event_count = _event_context->npa_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NPA_AF_RVU_INT);
+   npa_event_context->npa_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   npa_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NPA_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_npa_health_reporter, "NPA_AF_RVU 
Error",
+ npa_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static int rvu_npa_inpq_to_cnt(u16 in,
+  struct rvu_npa_event_cnt *npa_event_count)
+{
+   switch (in) {
+   case 0:
+   return 0;
+   case BIT(NPA_INPQ_NIX0_RX):
+   return npa_event_count->free_dis_nix0_rx_count++;
+   case BIT(NPA_INPQ_NIX0_TX):
+   return npa_event_count->free_dis_nix0_tx_count++;
+   case BIT(NPA_INPQ_NIX1_RX):
+   return npa_event_count->free_dis_nix1_rx_count++;
+   case BIT(NPA_INPQ_NIX1_TX):
+   return npa_event_count->free_dis_nix1_tx_count++;
+   case BIT(NPA_INPQ_SSO):
+   return npa_event_count->free_dis_sso_count++;
+   case BIT(NPA_INPQ_TIM):
+   return npa_event_count->free_dis_tim_count++;
+   case BIT(NPA_INPQ_DPI):
+   return npa_event_count->free_dis_dpi_count++;
+   case BIT(NPA_INPQ_AURA_OP):

[PATCHv3 net-next 3/3] octeontx2-af: Add devlink health reporters for NIX

2020-11-19 Thread George Cherian
Add health reporters for RVU NIX block.
NIX Health reporter handle following HW event groups
 - GENERAL events
 - RAS events
 - RVU event
An event counter per event is maintained in SW.

Output:
 # ./devlink health
 pci/0002:01:00.0:
   reporter npa
 state healthy error 0 recover 0
   reporter nix
 state healthy error 0 recover 0
 # ./devlink  health dump show pci/0002:01:00.0 reporter nix
  NIX_AF_GENERAL:
 Memory Fault on NIX_AQ_INST_S read: 0
 Memory Fault on NIX_AQ_RES_S write: 0
 AQ Doorbell error: 0
 Rx on unmapped PF_FUNC: 0
 Rx multicast replication error: 0
 Memory fault on NIX_RX_MCE_S read: 0
 Memory fault on multicast WQE read: 0
 Memory fault on mirror WQE read: 0
 Memory fault on mirror pkt write: 0
 Memory fault on multicast pkt write: 0
   NIX_AF_RAS:
 Poisoned data on NIX_AQ_INST_S read: 0
 Poisoned data on NIX_AQ_RES_S write: 0
 Poisoned data on HW context read: 0
 Poisoned data on packet read from mirror buffer: 0
 Poisoned data on packet read from mcast buffer: 0
 Poisoned data on WQE read from mirror buffer: 0
 Poisoned data on WQE read from multicast buffer: 0
 Poisoned data on NIX_RX_MCE_S read: 0
   NIX_AF_RVU:
 Unmap Slot Error: 0

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../marvell/octeontx2/af/rvu_devlink.c| 414 +-
 .../marvell/octeontx2/af/rvu_devlink.h|  31 ++
 .../marvell/octeontx2/af/rvu_struct.h |  10 +
 3 files changed, 453 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
index b7f0691d86b0..c02d0f56ae7a 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -35,6 +35,131 @@ static int rvu_report_pair_end(struct devlink_fmsg *fmsg)
return devlink_fmsg_pair_nest_end(fmsg);
 }
 
+static irqreturn_t rvu_nix_af_rvu_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_RVU_INT);
+   nix_event_context->nix_af_rvu_int = intr;
+
+   if (intr & BIT_ULL(0))
+   nix_event_count->unmap_slot_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_RVU_INT_ENA_W1C, ~0ULL);
+   devlink_health_report(rvu_dl->rvu_nix_health_reporter, "NIX_AF_RVU 
Error",
+ nix_event_context);
+
+   return IRQ_HANDLED;
+}
+
+static irqreturn_t rvu_nix_af_err_intr_handler(int irq, void *rvu_irq)
+{
+   struct rvu_nix_event_ctx *nix_event_context;
+   struct rvu_nix_event_cnt *nix_event_count;
+   struct rvu_devlink *rvu_dl = rvu_irq;
+   struct rvu *rvu;
+   int blkaddr;
+   u64 intr;
+
+   rvu = rvu_dl->rvu;
+   blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, 0);
+   if (blkaddr < 0)
+   return IRQ_NONE;
+
+   nix_event_context = rvu_dl->nix_event_ctx;
+   nix_event_count = _event_context->nix_event_cnt;
+   intr = rvu_read64(rvu, blkaddr, NIX_AF_ERR_INT);
+   nix_event_context->nix_af_rvu_err = intr;
+
+   if (intr & BIT_ULL(14))
+   nix_event_count->aq_inst_count++;
+   if (intr & BIT_ULL(13))
+   nix_event_count->aq_res_count++;
+   if (intr & BIT_ULL(12))
+   nix_event_count->aq_db_count++;
+   if (intr & BIT_ULL(6))
+   nix_event_count->rx_on_unmap_pf_count++;
+   if (intr & BIT_ULL(5))
+   nix_event_count->rx_mcast_repl_count++;
+   if (intr & BIT_ULL(4))
+   nix_event_count->rx_mcast_memfault_count++;
+   if (intr & BIT_ULL(3))
+   nix_event_count->rx_mcast_wqe_memfault_count++;
+   if (intr & BIT_ULL(2))
+   nix_event_count->rx_mirror_wqe_memfault_count++;
+   if (intr & BIT_ULL(1))
+   nix_event_count->rx_mirror_pktw_memfault_count++;
+   if (intr & BIT_ULL(0))
+   nix_event_count->rx_mcast_pktw_memfault_count++;
+
+   /* Clear interrupts */
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT, intr);
+   rvu_write64(rvu, blkaddr, NIX_AF_ERR_INT_ENA_W1C, ~0ULL);
+   dev

[PATCHv3 net-next 0/3] Add devlink and devlink health reporters to

2020-11-19 Thread George Cherian
Add basic devlink and devlink health reporters.
Devlink health reporters are added for NPA and NIX blocks.
These reporters report the error count in respective blocks.

Address Jakub's comment to add devlink support for error reporting.
https://www.spinics.net/lists/netdev/msg670712.html

Change-log:
v3
 - Address Saeed's comments on v2.
 - Renamed the reporter name as hw_*.
 - Call devlink_health_report() when an event is raised.
 - Added recover op too.

v2
 - Address Willem's comments on v1.
 - Fixed the sparse issues, reported by Jakub.

George Cherian (3):
  octeontx2-af: Add devlink suppoort to af driver
  octeontx2-af: Add devlink health reporters for NPA
  octeontx2-af: Add devlink health reporters for NIX

 .../net/ethernet/marvell/octeontx2/Kconfig|   1 +
 .../ethernet/marvell/octeontx2/af/Makefile|   3 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |   9 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |   4 +
 .../marvell/octeontx2/af/rvu_devlink.c| 972 ++
 .../marvell/octeontx2/af/rvu_devlink.h|  82 ++
 .../marvell/octeontx2/af/rvu_struct.h |  33 +
 7 files changed, 1102 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

-- 
2.25.1



[PATCHv3 net-next 1/3] octeontx2-af: Add devlink suppoort to af driver

2020-11-19 Thread George Cherian
Add devlink support to AF driver. Basic devlink support is added.
Currently info_get is the only supported devlink ops.

devlink ouptput looks like this
 # devlink dev
 pci/0002:01:00.0
 # devlink dev info
 pci/0002:01:00.0:
  driver octeontx2-af
  versions:
  fixed:
mbox version: 9

Signed-off-by: Sunil Kovvuri Goutham 
Signed-off-by: Jerin Jacob 
Signed-off-by: George Cherian 
---
 .../net/ethernet/marvell/octeontx2/Kconfig|  1 +
 .../ethernet/marvell/octeontx2/af/Makefile|  3 +-
 .../net/ethernet/marvell/octeontx2/af/rvu.c   |  9 ++-
 .../net/ethernet/marvell/octeontx2/af/rvu.h   |  4 ++
 .../marvell/octeontx2/af/rvu_devlink.c| 72 +++
 .../marvell/octeontx2/af/rvu_devlink.h| 20 ++
 6 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
 create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.h

diff --git a/drivers/net/ethernet/marvell/octeontx2/Kconfig 
b/drivers/net/ethernet/marvell/octeontx2/Kconfig
index 543a1d047567..16caa02095fe 100644
--- a/drivers/net/ethernet/marvell/octeontx2/Kconfig
+++ b/drivers/net/ethernet/marvell/octeontx2/Kconfig
@@ -9,6 +9,7 @@ config OCTEONTX2_MBOX
 config OCTEONTX2_AF
tristate "Marvell OcteonTX2 RVU Admin Function driver"
select OCTEONTX2_MBOX
+   select NET_DEVLINK
depends on (64BIT && COMPILE_TEST) || ARM64
depends on PCI
help
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/Makefile 
b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
index 2f7a861d0c7b..20135f1d3387 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/Makefile
+++ b/drivers/net/ethernet/marvell/octeontx2/af/Makefile
@@ -9,4 +9,5 @@ obj-$(CONFIG_OCTEONTX2_AF) += octeontx2_af.o
 
 octeontx2_mbox-y := mbox.o rvu_trace.o
 octeontx2_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \
- rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o
+ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o \
+ rvu_devlink.o
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index a28a518c0eae..67d6e05d1037 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -2816,17 +2816,23 @@ static int rvu_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
if (err)
goto err_flr;
 
+   err = rvu_register_dl(rvu);
+   if (err)
+   goto err_irq;
+
rvu_setup_rvum_blk_revid(rvu);
 
/* Enable AF's VFs (if any) */
err = rvu_enable_sriov(rvu);
if (err)
-   goto err_irq;
+   goto err_dl;
 
/* Initialize debugfs */
rvu_dbg_init(rvu);
 
return 0;
+err_dl:
+   rvu_unregister_dl(rvu);
 err_irq:
rvu_unregister_interrupts(rvu);
 err_flr:
@@ -2858,6 +2864,7 @@ static void rvu_remove(struct pci_dev *pdev)
 
rvu_dbg_exit(rvu);
rvu_unregister_interrupts(rvu);
+   rvu_unregister_dl(rvu);
rvu_flr_wq_destroy(rvu);
rvu_cgx_exit(rvu);
rvu_fwdata_exit(rvu);
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
index 5ac9bb12415f..282566235918 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.h
@@ -12,7 +12,10 @@
 #define RVU_H
 
 #include 
+#include 
+
 #include "rvu_struct.h"
+#include "rvu_devlink.h"
 #include "common.h"
 #include "mbox.h"
 
@@ -376,6 +379,7 @@ struct rvu {
 #ifdef CONFIG_DEBUG_FS
struct rvu_debugfs  rvu_dbg;
 #endif
+   struct rvu_devlink  *rvu_dl;
 };
 
 static inline void rvu_write64(struct rvu *rvu, u64 block, u64 offset, u64 val)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c 
b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
new file mode 100644
index ..04ef945e7e75
--- /dev/null
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Marvell OcteonTx2 RVU Devlink
+ *
+ * Copyright (C) 2020 Marvell.
+ *
+ */
+
+#include "rvu.h"
+
+#define DRV_NAME "octeontx2-af"
+
+static int rvu_devlink_info_get(struct devlink *devlink, struct 
devlink_info_req *req,
+   struct netlink_ext_ack *extack)
+{
+   char buf[10];
+   int err;
+
+   err = devlink_info_driver_name_put(req, DRV_NAME);
+   if (err)
+   return err;
+
+   sprintf(buf, "%X", OTX2_MBOX_VERSION);
+   return devlink_info_version_fixed_put(req, "mbox version:", buf);
+}
+
+static const struct devlink_ops rvu_devlink_ops = {
+   .info_get = rvu_devlink_info_get,
+};
+
+int rvu_register_dl(struct rvu *rvu)
+{
+   struct rvu_devlink *rvu_dl;
+

[no subject]

2020-11-19 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


I wish you read my mail in a good heart.

2020-11-19 Thread George Olivia
With due respect, I am Mrs. George Olivia; I have decided to donate
what I have to  Motherless babies/Less privileged/Widows' because I am
dying and diagnosed for cancer for about 4 years ago. I have been
touched by God Almighty to donate from what I have inherited from my
late husband to you for good work of God Almighty. I have asked
Almighty God to forgive me and believe he has, because he is a
Merciful God I will be going in for an operation surgery soon.

I decided to donate the sum of ($ 8.1 million DOLLARS) to you for the
good work of God Almighty for you to help the motherless and less
privilege and also forth assistance of the widows. At the moment I
cannot take any telephone calls right now due to the fact that my
relatives (that have squandered the funds gave them for this purpose
before) are around me and my health status also. I have adjusted my
will.

I wish you all the best and May the good Lord bless you abundantly,
and please use the funds judiciously and always extend the good work
to others. As soon as you get back to me, I shall give you info on
what I need from you, then you will contact the bank and tell them I
have willed those properties to you by quoting my personal file
routing and account information. And I have also notified the bank
that I am willing that properties to you for a good, effective and
prudent work. I know I don't know you but I have been directed to do
this by God Almighty.

If you are interested in carrying out this task, get back to me for
more details on this noble project of mine.

Yours Faithfully,
Mrs. George Olivia


[no subject]

2020-11-14 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


[no subject]

2020-11-12 Thread george mike
Hallo

Mein Name ist George Mike. Ich bin von Beruf Rechtsanwalt. Ich möchte
Ihnen anbieten
der nächste Verwandte meines Klienten. Sie erben die Summe von (8,5
Millionen US-Dollar)
Dollar, die mein Kunde vor seinem Tod auf der Bank gelassen hat.

Mein Kunde ist ein Staatsbürger Ihres Landes, der mit seiner Frau bei
einem Autounfall ums Leben gekommen ist
und einziger Sohn. Ich habe Anspruch auf 50% des Gesamtfonds, 50% darauf
sein für dich.
Bitte kontaktieren Sie meine private E-Mail hier für weitere
Informationen: georgemike7...@gmail.com

Vielen Dank im Voraus,
Mr. George Mike,


[no subject]

2020-11-11 Thread george mike
Witaj

Nazywam się George Mike. Z zawodu jestem prawnikiem. Chcę ci zaoferować
najbliższy krewny mojego klienta. Dziedziczysz całkowitą sumę (8.5.1)
Mln dolarów).
Dolary, które mój klient zostawił w banku przed śmiercią.

Mój klient jest obywatelem twojego kraju, który jest z żoną
zginął w wypadku samochodowym
i jedyny syn. Mam prawo do 50% całkowitego funduszu, 50% do niego
To dla Ciebie.
Aby uzyskać więcej informacji, skontaktuj się z moim prywatnym
Adres e-mail: georgemike7...@gmail.com

Z góry dziękuję,
Panie George Mike


  1   2   3   4   5   6   7   8   9   10   >