| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/17 02:34 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The changes modify the Cadence MACB/GEM Ethernet driver (drivers/net/ethernet/cadence/), adding KUnit tests, TXQ segment allocation logic, and channel configuration support via ethtool. On the amd64 target architecture, Cadence MACB/GEM is structurally unreachable because it targets embedded SoC platforms (Microchip AT91/SAMA, Xilinx Zynq/Versal, Mobileye EyeQ5) and specialized hardware not emulated in standard QEMU x86_64 or GCE virtualized environments. KUnit unit tests are self-tests not fuzzed by syzkaller. Therefore, the modified code cannot be reached during fuzzing.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/17 02:34 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 695bd284177093b3067470a484dfa4f50537eec9\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Oct 17 02:34:01 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig\nindex 5b2a461dfd28c..a901f74fd4abd 100644\n--- a/drivers/net/ethernet/cadence/Kconfig\n+++ b/drivers/net/ethernet/cadence/Kconfig\n@@ -51,4 +51,16 @@ config MACB_PCI\n \t To compile this driver as a module, choose M here: the module\n \t will be called macb_pci.\n \n+config MACB_KUNIT_TEST\n+\ttristate \"KUnit test for MACB\" if !KUNIT_ALL_TESTS\n+\tdepends on KUNIT\n+\tdefault KUNIT_ALL_TESTS\n+\thelp\n+\t Build KUnit tests for the MACB driver.\n+\n+\t For more information on KUnit and unit tests in general,\n+\t please refer to the KUnit documentation.\n+\n+\t If unsure, say N.\n+\n endif # NET_VENDOR_CADENCE\ndiff --git a/drivers/net/ethernet/cadence/Makefile b/drivers/net/ethernet/cadence/Makefile\nindex 1f33cdca9a3c0..a0740da686492 100644\n--- a/drivers/net/ethernet/cadence/Makefile\n+++ b/drivers/net/ethernet/cadence/Makefile\n@@ -2,7 +2,7 @@\n #\n # Makefile for the Atmel network device drivers.\n #\n-macb-y\t:= macb_main.o\n+macb-y\t:= macb_main.o macb_utils.o\n \n ifeq ($(CONFIG_MACB_USE_HWSTAMP),y)\n macb-y\t+= macb_ptp.o\n@@ -10,3 +10,6 @@ endif\n \n obj-$(CONFIG_MACB) += macb.o\n obj-$(CONFIG_MACB_PCI) += macb_pci.o\n+\n+obj-$(CONFIG_MACB_KUNIT_TEST) += macb_test.o\n+macb_test-y := macb_kunit.o macb_utils.o\ndiff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h\nindex 82499ec6a9f0d..60d61efbf3e46 100644\n--- a/drivers/net/ethernet/cadence/macb.h\n+++ b/drivers/net/ethernet/cadence/macb.h\n@@ -194,6 +194,10 @@\n /* Screener Type 2 match registers */\n #define GEM_SCRT2\t\t0x540\n \n+/* Tx queue segment allocation */\n+#define GEM_TXQSEGALLOC_LOWER\t0x05A0\n+#define GEM_TXQSEGALLOC_UPPER\t0x05A4\n+\n /* EtherType registers */\n #define GEM_ETHT\t\t0x06E0\n \n@@ -545,6 +549,8 @@\n #define GEM_PBUF_CUTTHRU_SIZE\t\t\t1\n #define GEM_DAW64_OFFSET\t\t\t23\n #define GEM_DAW64_SIZE\t\t\t\t1\n+#define GEM_SEGMENTS_BIT_SIZE_OFFSET\t\t16\n+#define GEM_SEGMENTS_BIT_SIZE_SIZE\t\t3\n \n /* Bitfields in DCFG8. */\n #define GEM_T1SCR_OFFSET\t\t\t24\n@@ -657,6 +663,13 @@\n #define GEM_CMPCEN_OFFSET\t\t\t30 /* Compare C Enable */\n #define GEM_CMPCEN_SIZE\t\t\t\t1\n \n+/* Bitfields in TXQSEGALLOC (Q0 at 2:0, Q1 at 6:4, etc.) */\n+#define GEM_TXQSEGALLOC_MASK(q_) \\\n+\t({ \\\n+\t\ttypeof(q_) q__ = (q_); \\\n+\t\tGENMASK(4 * (q__) + 2, 4 * (q__)); \\\n+\t})\n+\n /* Bitfields in ETHT */\n #define GEM_ETHTCMP_OFFSET\t\t\t0 /* EtherType compare value */\n #define GEM_ETHTCMP_SIZE\t\t\t16\n@@ -785,6 +798,7 @@\n #define MACB_CAPS_USRIO_HAS_MII\t\t\tBIT(26)\n #define MACB_CAPS_USRIO_HAS_REFCLK_SOURCE\tBIT(27)\n #define MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE\tBIT(28)\n+#define MACB_CAPS_TXQSEGALLOC\t\t\tBIT(29)\n \n /* LSO settings */\n #define MACB_LSO_UFO_ENABLE\t\t\t0x01\n@@ -1314,6 +1328,9 @@ struct macb {\n \tunsigned int\t\ttx_ring_size;\n \n \tunsigned int\t\tnum_queues;\n+\tunsigned int\t\tmax_num_queues;\n+\t/* Queue mask gated by the current TAPRIO schedule (RTNL-protected). */\n+\tu32\t\t\ttaprio_gated_queues;\n \tstruct macb_queue\tqueues[MACB_MAX_QUEUES];\n \n \tspinlock_t\t\tlock;\n@@ -1508,4 +1525,7 @@ struct macb_queue_enst_config {\n \tu32 off_time_bytes;\n };\n \n+u32 gem_sram_distribute_segments(unsigned int num_queues,\n+\t\t\t\t unsigned int num_segments);\n+\n #endif /* _MACB_H */\ndiff --git a/drivers/net/ethernet/cadence/macb_kunit.c b/drivers/net/ethernet/cadence/macb_kunit.c\nnew file mode 100644\nindex 0000000000000..9efafd34eeca1\n--- /dev/null\n+++ b/drivers/net/ethernet/cadence/macb_kunit.c\n@@ -0,0 +1,78 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+#include \u003ckunit/test.h\u003e\n+#include \u003clinux/netdevice.h\u003e\n+#include \"macb.h\"\n+\n+struct macb_sram_segments_case {\n+\tunsigned int num_queues, num_segments;\n+};\n+\n+static void macb_sram_segments_test(struct kunit *test)\n+{\n+\tconst struct macb_sram_segments_case *p = test-\u003eparam_value;\n+\tu32 val = gem_sram_distribute_segments(p-\u003enum_queues, p-\u003enum_segments);\n+\tunsigned int i, sum_segments = 0, max_assigned_segments;\n+\tunsigned int num_queues = min(p-\u003enum_queues, p-\u003enum_segments);\n+\n+\tfor (i = 0; i \u003c num_queues; i++) {\n+\t\tunsigned int q_segments = field_get(GEM_TXQSEGALLOC_MASK(i),\n+\t\t\t\t\t\t val);\n+\n+\t\tq_segments = 1U \u003c\u003c q_segments;\n+\t\tsum_segments += q_segments;\n+\t\tKUNIT_ASSERT_GT_MSG(test, q_segments, 0, \"queue %d, val %#x\",\n+\t\t\t\t i, val);\n+\t}\n+\n+\tfor (i = num_queues; i \u003c MACB_MAX_QUEUES; i++) {\n+\t\tunsigned int pow = field_get(GEM_TXQSEGALLOC_MASK(i), val);\n+\n+\t\tKUNIT_ASSERT_EQ_MSG(test, pow, 0, \"queue %d, val %#x\", i, val);\n+\t}\n+\n+\tmax_assigned_segments = min(p-\u003enum_segments,\n+\t\t\t\t MACB_MAX_QUEUES * num_queues);\n+\tKUNIT_ASSERT_EQ_MSG(test, sum_segments, max_assigned_segments,\n+\t\t\t \"val %#x\", val);\n+}\n+\n+struct macb_sram_segments_case macb_sram_segments_cases[] = {\n+\t/* num_segments can only be powers of two. */\n+\t{ .num_queues = 4, .num_segments = 2 },\n+\t{ .num_queues = 1, .num_segments = 16 },\n+\t{ .num_queues = 4, .num_segments = 16 },\n+\t{ .num_queues = 5, .num_segments = 16 },\n+\t{ .num_queues = 1, .num_segments = 128 },\n+\t{ .num_queues = 8, .num_segments = 128 },\n+};\n+\n+static void macb_sram_segments_case_desc(struct macb_sram_segments_case *t,\n+\t\t\t\t\t char *desc)\n+{\n+\tu32 val = gem_sram_distribute_segments(t-\u003enum_queues, t-\u003enum_segments);\n+\n+\tsnprintf(desc, KUNIT_PARAM_DESC_SIZE,\n+\t\t \"num_queues=%d num_segments=%d TXQSEGALLOC=%#x\",\n+\t\t t-\u003enum_queues, t-\u003enum_segments, val);\n+}\n+\n+KUNIT_ARRAY_PARAM(macb_sram_segments,\n+\t\t macb_sram_segments_cases,\n+\t\t macb_sram_segments_case_desc);\n+\n+static struct kunit_case macb_test_cases[] = {\n+\tKUNIT_CASE_PARAM(macb_sram_segments_test,\n+\t\t\t macb_sram_segments_gen_params),\n+\t{}\n+};\n+\n+static struct kunit_suite macb_test_suite = {\n+\t.name = \"macb\",\n+\t.test_cases = macb_test_cases,\n+};\n+\n+kunit_test_suite(macb_test_suite);\n+\n+MODULE_LICENSE(\"GPL\");\n+MODULE_DESCRIPTION(\"Cadence MACB/GEM Ethernet driver kunit tests\");\n+MODULE_AUTHOR(\"Théo Lebrun\");\ndiff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c\nindex 020a47353d011..b70b81f51161c 100644\n--- a/drivers/net/ethernet/cadence/macb_main.c\n+++ b/drivers/net/ethernet/cadence/macb_main.c\n@@ -473,9 +473,26 @@ static void macb_init_buffers(struct macb *bp)\n \t\t\t upper_32_bits(bp-\u003equeues[0].tx_ring_dma));\n \t}\n \n-\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003enum_queues; ++q, ++queue) {\n-\t\tqueue_writel(queue, RBQP, lower_32_bits(queue-\u003erx_ring_dma));\n-\t\tqueue_writel(queue, TBQP, lower_32_bits(queue-\u003etx_ring_dma));\n+\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003emax_num_queues; ++q, ++queue) {\n+\t\tif (q \u003c bp-\u003enum_queues) {\n+\t\t\tqueue_writel(queue, RBQP,\n+\t\t\t\t lower_32_bits(queue-\u003erx_ring_dma));\n+\t\t\tqueue_writel(queue, TBQP,\n+\t\t\t\t lower_32_bits(queue-\u003etx_ring_dma));\n+\t\t} else {\n+\t\t\t/*\n+\t\t\t * macb_set_channels(), which is the only way of writing\n+\t\t\t * to bp-\u003enum_queues, is only allowed if\n+\t\t\t * MACB_CAPS_QUEUE_DISABLE.\n+\t\t\t */\n+\t\t\tqueue_writel(queue, RBQP, MACB_BIT(QUEUE_DISABLE));\n+\t\t\tqueue_writel(queue, TBQP, MACB_BIT(QUEUE_DISABLE));\n+\n+\t\t\t/* Disable all interrupts */\n+\t\t\tqueue_writel(queue, IDR, -1);\n+\t\t\tqueue_readl(queue, ISR);\n+\t\t\tmacb_queue_isr_clear(bp, queue, -1);\n+\t\t}\n \t}\n }\n \n@@ -2044,7 +2061,7 @@ static void macb_quiesce_start(struct macb *bp)\n \tbp-\u003eirq_quiesced = true;\n \tspin_unlock_irqrestore(\u0026bp-\u003elock, flags);\n \n-\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003enum_queues; ++q, ++queue)\n+\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003emax_num_queues; ++q, ++queue)\n \t\tsynchronize_irq(queue-\u003eirq);\n \n \tcancel_work_sync(\u0026bp-\u003ehresp_err_bh_work);\n@@ -2209,6 +2226,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)\n \tstruct macb_queue *queue = dev_id;\n \tstruct macb *bp = queue-\u003ebp;\n \tstruct net_device *netdev = bp-\u003enetdev;\n+\tunsigned int q = queue - bp-\u003equeues;\n \tbool hresp_err = false;\n \tu32 status;\n \n@@ -2220,16 +2238,18 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)\n \tspin_lock(\u0026bp-\u003elock);\n \n \twhile (status) {\n-\t\t/* self-disarm while the netdev is closed */\n-\t\tif (unlikely(bp-\u003eirq_quiesced)) {\n+\t\t/* Self-disarm while the netdev is closed or\n+\t\t * the current queue is disabled.\n+\t\t */\n+\t\tif (unlikely(bp-\u003eirq_quiesced ||\n+\t\t\t q \u003e= READ_ONCE(bp-\u003enum_queues))) {\n \t\t\tqueue_writel(queue, IDR, -1);\n \t\t\tmacb_queue_isr_clear(bp, queue, -1);\n \t\t\tbreak;\n \t\t}\n \n \t\tnetdev_vdbg(netdev, \"queue = %u, isr = 0x%08lx\\n\",\n-\t\t\t (unsigned int)(queue - bp-\u003equeues),\n-\t\t\t (unsigned long)status);\n+\t\t\t q, (unsigned long)status);\n \n \t\tif (status \u0026 bp-\u003erx_intr_mask) {\n \t\t\t/* There's no point taking any more interrupts\n@@ -3143,6 +3163,20 @@ static void macb_init_hw(struct macb *bp)\n \tif (bp-\u003ecaps \u0026 MACB_CAPS_JUMBO)\n \t\tbp-\u003erx_frm_len_mask = MACB_RX_JFRMLEN_MASK;\n \n+\t/* Distribute Tx SRAM segments evenly based on active number of queues.\n+\t * TXQSEGALLOC is only documented for some GEM integrations.\n+\t */\n+\tif (bp-\u003ecaps \u0026 MACB_CAPS_TXQSEGALLOC) {\n+\t\tunsigned int num_segments;\n+\t\tu32 val;\n+\n+\t\tnum_segments = 1U \u003c\u003c GEM_BFEXT(SEGMENTS_BIT_SIZE,\n+\t\t\t\t\t gem_readl(bp, DCFG6));\n+\t\tval = gem_sram_distribute_segments(bp-\u003enum_queues,\n+\t\t\t\t\t\t num_segments);\n+\t\tgem_writel(bp, TXQSEGALLOC_LOWER, val);\n+\t}\n+\n \tmacb_configure_dma(bp);\n \n \t/* Enable RX partial store and forward and set watermark */\n@@ -4247,6 +4281,51 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)\n \treturn ret;\n }\n \n+static void macb_get_channels(struct net_device *netdev,\n+\t\t\t struct ethtool_channels *ch)\n+{\n+\tstruct macb *bp = netdev_priv(netdev);\n+\n+\tch-\u003emax_combined = bp-\u003emax_num_queues;\n+\tch-\u003ecombined_count = bp-\u003enum_queues;\n+}\n+\n+static int macb_set_channels(struct net_device *netdev,\n+\t\t\t struct ethtool_channels *ch)\n+{\n+\tstruct macb *bp = netdev_priv(netdev);\n+\tunsigned int count = ch-\u003ecombined_count;\n+\tint ret;\n+\n+\t/* MACB_CAPS_QUEUE_DISABLE means that the field QUEUE_DISABLE/BIT0 in\n+\t * the per-queue RBQP/TBQP registers disable Tx/Rx queues. If we don't\n+\t * have that capability we can have multiple queues but we must always\n+\t * run with all enabled.\n+\t */\n+\tif (!(bp-\u003ecaps \u0026 MACB_CAPS_QUEUE_DISABLE))\n+\t\treturn -EOPNOTSUPP;\n+\n+\t/* TODO: reuse context swapping once it is merged. */\n+\tif (netif_running(bp-\u003enetdev))\n+\t\treturn -EBUSY;\n+\n+\t/* If we allow disable a queue which has TAPRIO active, we'll keep a\n+\t * transmission window which will be unusable.\n+\t */\n+\tif (bp-\u003etaprio_gated_queues \u003e\u003e count) {\n+\t\tnetdev_err(bp-\u003enetdev, \"TAPRIO schedule gates queues \u003e= %u; destroy the qdisc before reducing channels\\n\",\n+\t\t\t count);\n+\t\treturn -EBUSY;\n+\t}\n+\n+\tret = netif_set_real_num_queues(bp-\u003enetdev, count, count);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tbp-\u003enum_queues = count;\n+\treturn 0;\n+}\n+\n static const struct ethtool_ops macb_ethtool_ops = {\n \t.get_regs_len\t\t= macb_get_regs_len,\n \t.get_regs\t\t= macb_get_regs,\n@@ -4262,6 +4341,8 @@ static const struct ethtool_ops macb_ethtool_ops = {\n \t.set_link_ksettings = macb_set_link_ksettings,\n \t.get_ringparam\t\t= macb_get_ringparam,\n \t.set_ringparam\t\t= macb_set_ringparam,\n+\t.get_channels\t\t= macb_get_channels,\n+\t.set_channels\t\t= macb_set_channels,\n };\n \n static int macb_get_eee(struct net_device *netdev, struct ethtool_keee *eee)\n@@ -4296,12 +4377,14 @@ static const struct ethtool_ops gem_ethtool_ops = {\n \t.set_link_ksettings = macb_set_link_ksettings,\n \t.get_ringparam\t\t= macb_get_ringparam,\n \t.set_ringparam\t\t= macb_set_ringparam,\n-\t.get_rxnfc\t\t\t= gem_get_rxnfc,\n-\t.set_rxnfc\t\t\t= gem_set_rxnfc,\n-\t.get_rx_ring_count\t\t= gem_get_rx_ring_count,\n-\t.nway_reset\t\t\t= phy_ethtool_nway_reset,\n+\t.get_rxnfc\t\t= gem_get_rxnfc,\n+\t.set_rxnfc\t\t= gem_set_rxnfc,\n+\t.get_rx_ring_count\t= gem_get_rx_ring_count,\n+\t.nway_reset\t\t= phy_ethtool_nway_reset,\n \t.get_eee\t\t= macb_get_eee,\n \t.set_eee\t\t= macb_set_eee,\n+\t.get_channels\t\t= macb_get_channels,\n+\t.set_channels\t\t= macb_set_channels,\n };\n \n static int macb_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)\n@@ -4443,7 +4526,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,\n \tint err;\n \n \tif (conf-\u003enum_entries \u003e bp-\u003enum_queues) {\n-\t\tnetdev_err(netdev, \"Too many TAPRIO entries: %zu \u003e %d queues\\n\",\n+\t\tnetdev_err(netdev, \"Too many TAPRIO entries: %zu \u003e %u active queues\\n\",\n \t\t\t conf-\u003enum_entries, bp-\u003enum_queues);\n \t\treturn -EINVAL;\n \t}\n@@ -4493,7 +4576,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,\n \t\t/* gate_mask must not select queues outside the valid queues */\n \t\tqueue_id = order_base_2(entry-\u003egate_mask);\n \t\tif (queue_id \u003e= bp-\u003enum_queues) {\n-\t\t\tnetdev_err(netdev, \"Entry %zu: gate_mask 0x%x exceeds queue range (max_queues=%d)\\n\",\n+\t\t\tnetdev_err(netdev, \"Entry %zu: gate_mask 0x%x exceeds active queue range (num_queues=%u)\\n\",\n \t\t\t\t i, entry-\u003egate_mask, bp-\u003enum_queues);\n \t\t\terr = -EINVAL;\n \t\t\tgoto cleanup;\n@@ -4553,7 +4636,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,\n \t/* All validations passed - proceed with hardware configuration */\n \tscoped_guard(spinlock_irqsave, \u0026bp-\u003elock) {\n \t\t/* Disable ENST queues if running before configuring */\n-\t\tqueue_mask = BIT_U32(bp-\u003enum_queues) - 1;\n+\t\tqueue_mask = BIT_U32(bp-\u003emax_num_queues) - 1;\n \t\tgem_writel(bp, ENST_CONTROL,\n \t\t\t queue_mask \u003c\u003c GEM_ENST_DISABLE_QUEUE_OFFSET);\n \n@@ -4571,6 +4654,9 @@ static int macb_taprio_setup_replace(struct net_device *netdev,\n \t\tgem_writel(bp, ENST_CONTROL, configured_queues);\n \t}\n \n+\t/* Remember which queues are gated, to validate .set_channels(). */\n+\tbp-\u003etaprio_gated_queues = configured_queues;\n+\n \tnetdev_info(netdev, \"TAPRIO configuration completed successfully: %zu entries, %d queues configured\\n\",\n \t\t conf-\u003enum_entries, hweight32(configured_queues));\n \n@@ -4587,7 +4673,7 @@ static void macb_taprio_destroy(struct net_device *netdev)\n \tunsigned int q;\n \n \tnetdev_reset_tc(netdev);\n-\tqueue_mask = BIT_U32(bp-\u003enum_queues) - 1;\n+\tqueue_mask = BIT_U32(bp-\u003emax_num_queues) - 1;\n \n \tscoped_guard(spinlock_irqsave, \u0026bp-\u003elock) {\n \t\t/* Single disable command for all queues */\n@@ -4595,12 +4681,14 @@ static void macb_taprio_destroy(struct net_device *netdev)\n \t\t\t queue_mask \u003c\u003c GEM_ENST_DISABLE_QUEUE_OFFSET);\n \n \t\t/* Clear all queue ENST registers in batch */\n-\t\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003enum_queues; ++q, ++queue) {\n+\t\tfor (q = 0, queue = bp-\u003equeues; q \u003c bp-\u003emax_num_queues;\n+\t\t ++q, ++queue) {\n \t\t\tqueue_writel(queue, ENST_START_TIME, 0);\n \t\t\tqueue_writel(queue, ENST_ON_TIME, 0);\n \t\t\tqueue_writel(queue, ENST_OFF_TIME, 0);\n \t\t}\n \t}\n+\tbp-\u003etaprio_gated_queues = 0;\n \tnetdev_info(netdev, \"TAPRIO destroy: All gates disabled\\n\");\n }\n \n@@ -5743,7 +5831,7 @@ static const struct macb_config sama5d2_config = {\n \n static const struct macb_config sama5d29_config = {\n \t.caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | MACB_CAPS_GEM_HAS_PTP |\n-\t\tMACB_CAPS_USRIO_HAS_MII,\n+\t\tMACB_CAPS_USRIO_HAS_MII | MACB_CAPS_QUEUE_DISABLE,\n \t.dma_burst_length = 16,\n \t.usrio = \u0026at91_default_usrio,\n };\n@@ -5780,6 +5868,7 @@ static const struct macb_config zynqmp_config = {\n \t.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |\n \t\tMACB_CAPS_JUMBO |\n \t\tMACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH |\n+\t\tMACB_CAPS_TXQSEGALLOC |\n \t\tMACB_CAPS_USRIO_HAS_MII,\n \t.dma_burst_length = 16,\n \t.init = init_reset_optional,\n@@ -5799,7 +5888,8 @@ static const struct macb_config mpfs_config = {\n \t.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |\n \t\tMACB_CAPS_JUMBO |\n \t\tMACB_CAPS_GEM_HAS_PTP |\n-\t\tMACB_CAPS_USRIO_HAS_TSUCLK_SOURCE,\n+\t\tMACB_CAPS_USRIO_HAS_TSUCLK_SOURCE |\n+\t\tMACB_CAPS_QUEUE_DISABLE,\n \t.dma_burst_length = 16,\n \t.init = init_reset_optional,\n \t.usrio = \u0026mpfs_usrio,\n@@ -5812,7 +5902,7 @@ static const struct macb_config sama7g5_gem_config = {\n \t\tMACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |\n \t\tMACB_CAPS_USRIO_HAS_REFCLK_SOURCE |\n \t\tMACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP |\n-\t\tMACB_CAPS_USRIO_HAS_MII,\n+\t\tMACB_CAPS_USRIO_HAS_MII | MACB_CAPS_QUEUE_DISABLE,\n \t.dma_burst_length = 16,\n \t.usrio = \u0026sama7g5_gem_usrio,\n };\n@@ -5831,7 +5921,7 @@ static const struct macb_config versal_config = {\n \t.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |\n \t\tMACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH |\n \t\tMACB_CAPS_NEED_TSUCLK | MACB_CAPS_QUEUE_DISABLE |\n-\t\tMACB_CAPS_QBV |\n+\t\tMACB_CAPS_QBV | MACB_CAPS_TXQSEGALLOC |\n \t\tMACB_CAPS_USRIO_HAS_MII,\n \t.dma_burst_length = 16,\n \t.init = init_reset_optional,\n@@ -5842,7 +5932,7 @@ static const struct macb_config versal_config = {\n static const struct macb_config eyeq5_config = {\n \t.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |\n \t\tMACB_CAPS_GEM_HAS_PTP | MACB_CAPS_QUEUE_DISABLE |\n-\t\tMACB_CAPS_NO_LSO | MACB_CAPS_EEE,\n+\t\tMACB_CAPS_NO_LSO | MACB_CAPS_EEE | MACB_CAPS_TXQSEGALLOC,\n \t.dma_burst_length = 16,\n \t.init = eyeq5_init,\n \t.jumbo_max_len = 10240,\n@@ -5971,6 +6061,7 @@ static int macb_probe(struct platform_device *pdev)\n \t\tbp-\u003emacb_reg_writel = hw_writel;\n \t}\n \tbp-\u003enum_queues = num_queues;\n+\tbp-\u003emax_num_queues = num_queues;\n \tbp-\u003edma_burst_length = macb_config-\u003edma_burst_length;\n \tbp-\u003epclk = pclk;\n \tbp-\u003ehclk = hclk;\ndiff --git a/drivers/net/ethernet/cadence/macb_utils.c b/drivers/net/ethernet/cadence/macb_utils.c\nnew file mode 100644\nindex 0000000000000..64ffba0c05224\n--- /dev/null\n+++ b/drivers/net/ethernet/cadence/macb_utils.c\n@@ -0,0 +1,60 @@\n+// SPDX-License-Identifier: GPL-2.0-only\n+#include \u003clinux/netdevice.h\u003e\n+#include \"macb.h\"\n+\n+/*\n+ * Distribute evenly available segments across queues. The computation is\n+ * complex because (1) segments are counted in powers of two and (2) a queue\n+ * can only use up to 8 segments. There are four types of cases:\n+ * - Sharing all segments equally is doable. Take num_queues=4 and\n+ * num_segments=16. Each queue will get 2^2=4 segments.\n+ * - Sharing all segments is doable. Take num_queues=5 and num_segments=16.\n+ * Three queues will get 2^2=4 segments and two will get 2^1=2 segments.\n+ * - Sharing all segments is not doable because not enough queues are\n+ * available. Take num_queues=1 and num_segments=16; queue 0 can only have 8\n+ * segments.\n+ * - Sharing all segments is not doable because not enough segments are\n+ * available. Take num_queues=4 and num_segments=2.\n+ *\n+ * We start by computing the power each queue will have. For num_queues=5 and\n+ * num_segments=16, each queue will have at least 2^1 segments. That leaves us\n+ * with remaining_segments=6. If we increase the power for a queue, we get a\n+ * delta of 2 (2^2-2^1). The first three queues will therefore be advantaged\n+ * and each have 2^2 segments. The remaining 2 queues will only have 2^1\n+ * segments.\n+ */\n+u32 gem_sram_distribute_segments(unsigned int num_queues,\n+\t\t\t\t unsigned int num_segments)\n+{\n+\tunsigned int pow, remaining_segments, i;\n+\tunsigned int num_advantaged_queues = 0;\n+\tu32 val = 0;\n+\n+\t/* When growing the max # of queues, make sure to return a u64 here and\n+\t * to write into GEM_TXQSEGALLOC_UPPER.\n+\t */\n+\tstatic_assert(MACB_MAX_QUEUES == 8);\n+\n+\t/* pow=0 for all queues. ilog2(0) is dangerous. */\n+\tif (num_queues \u003e= num_segments)\n+\t\treturn 0;\n+\n+\tpow = min_t(unsigned int, ilog2(num_segments / num_queues), 3);\n+\tremaining_segments = num_segments - num_queues * (1U \u003c\u003c pow);\n+\n+\t/* We can only distribute remaining segments if (1) there are remaining\n+\t * segments and (2) we did not reach the max segments per queue (2^3).\n+\t */\n+\tif (remaining_segments != 0 \u0026\u0026 pow != 3) {\n+\t\tunsigned int delta = (1U \u003c\u003c (pow + 1)) - (1U \u003c\u003c pow);\n+\n+\t\tnum_advantaged_queues = remaining_segments / delta;\n+\t}\n+\n+\tfor (i = 0; i \u003c num_advantaged_queues; i++)\n+\t\tval |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow + 1);\n+\tfor (i = num_advantaged_queues; i \u003c num_queues; i++)\n+\t\tval |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow);\n+\n+\treturn val;\n+}\n"
} |
| 2/1 | 2026/10/17 02:34 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The changes modify the Cadence MACB/GEM Ethernet driver (drivers/net/ethernet/cadence/), adding KUnit tests, TXQ segment allocation logic, and channel configuration support via ethtool. On the amd64 target architecture, Cadence MACB/GEM is structurally unreachable because it targets embedded SoC platforms (Microchip AT91/SAMA, Xilinx Zynq/Versal, Mobileye EyeQ5) and specialized hardware not emulated in standard QEMU x86_64 or GCE virtualized environments. KUnit unit tests are self-tests not fuzzed by syzkaller. Therefore, the modified code cannot be reached during fuzzing.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 695bd284177093b3067470a484dfa4f50537eec9
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Oct 17 02:34:01 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index 5b2a461dfd28c..a901f74fd4abd 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -51,4 +51,16 @@ config MACB_PCI
To compile this driver as a module, choose M here: the module
will be called macb_pci.
+config MACB_KUNIT_TEST
+ tristate "KUnit test for MACB" if !KUNIT_ALL_TESTS
+ depends on KUNIT
+ default KUNIT_ALL_TESTS
+ help
+ Build KUnit tests for the MACB driver.
+
+ For more information on KUnit and unit tests in general,
+ please refer to the KUnit documentation.
+
+ If unsure, say N.
+
endif # NET_VENDOR_CADENCE
diff --git a/drivers/net/ethernet/cadence/Makefile b/drivers/net/ethernet/cadence/Makefile
index 1f33cdca9a3c0..a0740da686492 100644
--- a/drivers/net/ethernet/cadence/Makefile
+++ b/drivers/net/ethernet/cadence/Makefile
@@ -2,7 +2,7 @@
#
# Makefile for the Atmel network device drivers.
#
-macb-y := macb_main.o
+macb-y := macb_main.o macb_utils.o
ifeq ($(CONFIG_MACB_USE_HWSTAMP),y)
macb-y += macb_ptp.o
@@ -10,3 +10,6 @@ endif
obj-$(CONFIG_MACB) += macb.o
obj-$(CONFIG_MACB_PCI) += macb_pci.o
+
+obj-$(CONFIG_MACB_KUNIT_TEST) += macb_test.o
+macb_test-y := macb_kunit.o macb_utils.o
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 82499ec6a9f0d..60d61efbf3e46 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -194,6 +194,10 @@
/* Screener Type 2 match registers */
#define GEM_SCRT2 0x540
+/* Tx queue segment allocation */
+#define GEM_TXQSEGALLOC_LOWER 0x05A0
+#define GEM_TXQSEGALLOC_UPPER 0x05A4
+
/* EtherType registers */
#define GEM_ETHT 0x06E0
@@ -545,6 +549,8 @@
#define GEM_PBUF_CUTTHRU_SIZE 1
#define GEM_DAW64_OFFSET 23
#define GEM_DAW64_SIZE 1
+#define GEM_SEGMENTS_BIT_SIZE_OFFSET 16
+#define GEM_SEGMENTS_BIT_SIZE_SIZE 3
/* Bitfields in DCFG8. */
#define GEM_T1SCR_OFFSET 24
@@ -657,6 +663,13 @@
#define GEM_CMPCEN_OFFSET 30 /* Compare C Enable */
#define GEM_CMPCEN_SIZE 1
+/* Bitfields in TXQSEGALLOC (Q0 at 2:0, Q1 at 6:4, etc.) */
+#define GEM_TXQSEGALLOC_MASK(q_) \
+ ({ \
+ typeof(q_) q__ = (q_); \
+ GENMASK(4 * (q__) + 2, 4 * (q__)); \
+ })
+
/* Bitfields in ETHT */
#define GEM_ETHTCMP_OFFSET 0 /* EtherType compare value */
#define GEM_ETHTCMP_SIZE 16
@@ -785,6 +798,7 @@
#define MACB_CAPS_USRIO_HAS_MII BIT(26)
#define MACB_CAPS_USRIO_HAS_REFCLK_SOURCE BIT(27)
#define MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE BIT(28)
+#define MACB_CAPS_TXQSEGALLOC BIT(29)
/* LSO settings */
#define MACB_LSO_UFO_ENABLE 0x01
@@ -1314,6 +1328,9 @@ struct macb {
unsigned int tx_ring_size;
unsigned int num_queues;
+ unsigned int max_num_queues;
+ /* Queue mask gated by the current TAPRIO schedule (RTNL-protected). */
+ u32 taprio_gated_queues;
struct macb_queue queues[MACB_MAX_QUEUES];
spinlock_t lock;
@@ -1508,4 +1525,7 @@ struct macb_queue_enst_config {
u32 off_time_bytes;
};
+u32 gem_sram_distribute_segments(unsigned int num_queues,
+ unsigned int num_segments);
+
#endif /* _MACB_H */
diff --git a/drivers/net/ethernet/cadence/macb_kunit.c b/drivers/net/ethernet/cadence/macb_kunit.c
new file mode 100644
index 0000000000000..9efafd34eeca1
--- /dev/null
+++ b/drivers/net/ethernet/cadence/macb_kunit.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <kunit/test.h>
+#include <linux/netdevice.h>
+#include "macb.h"
+
+struct macb_sram_segments_case {
+ unsigned int num_queues, num_segments;
+};
+
+static void macb_sram_segments_test(struct kunit *test)
+{
+ const struct macb_sram_segments_case *p = test->param_value;
+ u32 val = gem_sram_distribute_segments(p->num_queues, p->num_segments);
+ unsigned int i, sum_segments = 0, max_assigned_segments;
+ unsigned int num_queues = min(p->num_queues, p->num_segments);
+
+ for (i = 0; i < num_queues; i++) {
+ unsigned int q_segments = field_get(GEM_TXQSEGALLOC_MASK(i),
+ val);
+
+ q_segments = 1U << q_segments;
+ sum_segments += q_segments;
+ KUNIT_ASSERT_GT_MSG(test, q_segments, 0, "queue %d, val %#x",
+ i, val);
+ }
+
+ for (i = num_queues; i < MACB_MAX_QUEUES; i++) {
+ unsigned int pow = field_get(GEM_TXQSEGALLOC_MASK(i), val);
+
+ KUNIT_ASSERT_EQ_MSG(test, pow, 0, "queue %d, val %#x", i, val);
+ }
+
+ max_assigned_segments = min(p->num_segments,
+ MACB_MAX_QUEUES * num_queues);
+ KUNIT_ASSERT_EQ_MSG(test, sum_segments, max_assigned_segments,
+ "val %#x", val);
+}
+
+struct macb_sram_segments_case macb_sram_segments_cases[] = {
+ /* num_segments can only be powers of two. */
+ { .num_queues = 4, .num_segments = 2 },
+ { .num_queues = 1, .num_segments = 16 },
+ { .num_queues = 4, .num_segments = 16 },
+ { .num_queues = 5, .num_segments = 16 },
+ { .num_queues = 1, .num_segments = 128 },
+ { .num_queues = 8, .num_segments = 128 },
+};
+
+static void macb_sram_segments_case_desc(struct macb_sram_segments_case *t,
+ char *desc)
+{
+ u32 val = gem_sram_distribute_segments(t->num_queues, t->num_segments);
+
+ snprintf(desc, KUNIT_PARAM_DESC_SIZE,
+ "num_queues=%d num_segments=%d TXQSEGALLOC=%#x",
+ t->num_queues, t->num_segments, val);
+}
+
+KUNIT_ARRAY_PARAM(macb_sram_segments,
+ macb_sram_segments_cases,
+ macb_sram_segments_case_desc);
+
+static struct kunit_case macb_test_cases[] = {
+ KUNIT_CASE_PARAM(macb_sram_segments_test,
+ macb_sram_segments_gen_params),
+ {}
+};
+
+static struct kunit_suite macb_test_suite = {
+ .name = "macb",
+ .test_cases = macb_test_cases,
+};
+
+kunit_test_suite(macb_test_suite);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Cadence MACB/GEM Ethernet driver kunit tests");
+MODULE_AUTHOR("Théo Lebrun");
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 020a47353d011..b70b81f51161c 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -473,9 +473,26 @@ static void macb_init_buffers(struct macb *bp)
upper_32_bits(bp->queues[0].tx_ring_dma));
}
- for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
- queue_writel(queue, RBQP, lower_32_bits(queue->rx_ring_dma));
- queue_writel(queue, TBQP, lower_32_bits(queue->tx_ring_dma));
+ for (q = 0, queue = bp->queues; q < bp->max_num_queues; ++q, ++queue) {
+ if (q < bp->num_queues) {
+ queue_writel(queue, RBQP,
+ lower_32_bits(queue->rx_ring_dma));
+ queue_writel(queue, TBQP,
+ lower_32_bits(queue->tx_ring_dma));
+ } else {
+ /*
+ * macb_set_channels(), which is the only way of writing
+ * to bp->num_queues, is only allowed if
+ * MACB_CAPS_QUEUE_DISABLE.
+ */
+ queue_writel(queue, RBQP, MACB_BIT(QUEUE_DISABLE));
+ queue_writel(queue, TBQP, MACB_BIT(QUEUE_DISABLE));
+
+ /* Disable all interrupts */
+ queue_writel(queue, IDR, -1);
+ queue_readl(queue, ISR);
+ macb_queue_isr_clear(bp, queue, -1);
+ }
}
}
@@ -2044,7 +2061,7 @@ static void macb_quiesce_start(struct macb *bp)
bp->irq_quiesced = true;
spin_unlock_irqrestore(&bp->lock, flags);
- for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
+ for (q = 0, queue = bp->queues; q < bp->max_num_queues; ++q, ++queue)
synchronize_irq(queue->irq);
cancel_work_sync(&bp->hresp_err_bh_work);
@@ -2209,6 +2226,7 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
struct macb_queue *queue = dev_id;
struct macb *bp = queue->bp;
struct net_device *netdev = bp->netdev;
+ unsigned int q = queue - bp->queues;
bool hresp_err = false;
u32 status;
@@ -2220,16 +2238,18 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
spin_lock(&bp->lock);
while (status) {
- /* self-disarm while the netdev is closed */
- if (unlikely(bp->irq_quiesced)) {
+ /* Self-disarm while the netdev is closed or
+ * the current queue is disabled.
+ */
+ if (unlikely(bp->irq_quiesced ||
+ q >= READ_ONCE(bp->num_queues))) {
queue_writel(queue, IDR, -1);
macb_queue_isr_clear(bp, queue, -1);
break;
}
netdev_vdbg(netdev, "queue = %u, isr = 0x%08lx\n",
- (unsigned int)(queue - bp->queues),
- (unsigned long)status);
+ q, (unsigned long)status);
if (status & bp->rx_intr_mask) {
/* There's no point taking any more interrupts
@@ -3143,6 +3163,20 @@ static void macb_init_hw(struct macb *bp)
if (bp->caps & MACB_CAPS_JUMBO)
bp->rx_frm_len_mask = MACB_RX_JFRMLEN_MASK;
+ /* Distribute Tx SRAM segments evenly based on active number of queues.
+ * TXQSEGALLOC is only documented for some GEM integrations.
+ */
+ if (bp->caps & MACB_CAPS_TXQSEGALLOC) {
+ unsigned int num_segments;
+ u32 val;
+
+ num_segments = 1U << GEM_BFEXT(SEGMENTS_BIT_SIZE,
+ gem_readl(bp, DCFG6));
+ val = gem_sram_distribute_segments(bp->num_queues,
+ num_segments);
+ gem_writel(bp, TXQSEGALLOC_LOWER, val);
+ }
+
macb_configure_dma(bp);
/* Enable RX partial store and forward and set watermark */
@@ -4247,6 +4281,51 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
return ret;
}
+static void macb_get_channels(struct net_device *netdev,
+ struct ethtool_channels *ch)
+{
+ struct macb *bp = netdev_priv(netdev);
+
+ ch->max_combined = bp->max_num_queues;
+ ch->combined_count = bp->num_queues;
+}
+
+static int macb_set_channels(struct net_device *netdev,
+ struct ethtool_channels *ch)
+{
+ struct macb *bp = netdev_priv(netdev);
+ unsigned int count = ch->combined_count;
+ int ret;
+
+ /* MACB_CAPS_QUEUE_DISABLE means that the field QUEUE_DISABLE/BIT0 in
+ * the per-queue RBQP/TBQP registers disable Tx/Rx queues. If we don't
+ * have that capability we can have multiple queues but we must always
+ * run with all enabled.
+ */
+ if (!(bp->caps & MACB_CAPS_QUEUE_DISABLE))
+ return -EOPNOTSUPP;
+
+ /* TODO: reuse context swapping once it is merged. */
+ if (netif_running(bp->netdev))
+ return -EBUSY;
+
+ /* If we allow disable a queue which has TAPRIO active, we'll keep a
+ * transmission window which will be unusable.
+ */
+ if (bp->taprio_gated_queues >> count) {
+ netdev_err(bp->netdev, "TAPRIO schedule gates queues >= %u; destroy the qdisc before reducing channels\n",
+ count);
+ return -EBUSY;
+ }
+
+ ret = netif_set_real_num_queues(bp->netdev, count, count);
+ if (ret)
+ return ret;
+
+ bp->num_queues = count;
+ return 0;
+}
+
static const struct ethtool_ops macb_ethtool_ops = {
.get_regs_len = macb_get_regs_len,
.get_regs = macb_get_regs,
@@ -4262,6 +4341,8 @@ static const struct ethtool_ops macb_ethtool_ops = {
.set_link_ksettings = macb_set_link_ksettings,
.get_ringparam = macb_get_ringparam,
.set_ringparam = macb_set_ringparam,
+ .get_channels = macb_get_channels,
+ .set_channels = macb_set_channels,
};
static int macb_get_eee(struct net_device *netdev, struct ethtool_keee *eee)
@@ -4296,12 +4377,14 @@ static const struct ethtool_ops gem_ethtool_ops = {
.set_link_ksettings = macb_set_link_ksettings,
.get_ringparam = macb_get_ringparam,
.set_ringparam = macb_set_ringparam,
- .get_rxnfc = gem_get_rxnfc,
- .set_rxnfc = gem_set_rxnfc,
- .get_rx_ring_count = gem_get_rx_ring_count,
- .nway_reset = phy_ethtool_nway_reset,
+ .get_rxnfc = gem_get_rxnfc,
+ .set_rxnfc = gem_set_rxnfc,
+ .get_rx_ring_count = gem_get_rx_ring_count,
+ .nway_reset = phy_ethtool_nway_reset,
.get_eee = macb_get_eee,
.set_eee = macb_set_eee,
+ .get_channels = macb_get_channels,
+ .set_channels = macb_set_channels,
};
static int macb_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
@@ -4443,7 +4526,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
int err;
if (conf->num_entries > bp->num_queues) {
- netdev_err(netdev, "Too many TAPRIO entries: %zu > %d queues\n",
+ netdev_err(netdev, "Too many TAPRIO entries: %zu > %u active queues\n",
conf->num_entries, bp->num_queues);
return -EINVAL;
}
@@ -4493,7 +4576,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
/* gate_mask must not select queues outside the valid queues */
queue_id = order_base_2(entry->gate_mask);
if (queue_id >= bp->num_queues) {
- netdev_err(netdev, "Entry %zu: gate_mask 0x%x exceeds queue range (max_queues=%d)\n",
+ netdev_err(netdev, "Entry %zu: gate_mask 0x%x exceeds active queue range (num_queues=%u)\n",
i, entry->gate_mask, bp->num_queues);
err = -EINVAL;
goto cleanup;
@@ -4553,7 +4636,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
/* All validations passed - proceed with hardware configuration */
scoped_guard(spinlock_irqsave, &bp->lock) {
/* Disable ENST queues if running before configuring */
- queue_mask = BIT_U32(bp->num_queues) - 1;
+ queue_mask = BIT_U32(bp->max_num_queues) - 1;
gem_writel(bp, ENST_CONTROL,
queue_mask << GEM_ENST_DISABLE_QUEUE_OFFSET);
@@ -4571,6 +4654,9 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
gem_writel(bp, ENST_CONTROL, configured_queues);
}
+ /* Remember which queues are gated, to validate .set_channels(). */
+ bp->taprio_gated_queues = configured_queues;
+
netdev_info(netdev, "TAPRIO configuration completed successfully: %zu entries, %d queues configured\n",
conf->num_entries, hweight32(configured_queues));
@@ -4587,7 +4673,7 @@ static void macb_taprio_destroy(struct net_device *netdev)
unsigned int q;
netdev_reset_tc(netdev);
- queue_mask = BIT_U32(bp->num_queues) - 1;
+ queue_mask = BIT_U32(bp->max_num_queues) - 1;
scoped_guard(spinlock_irqsave, &bp->lock) {
/* Single disable command for all queues */
@@ -4595,12 +4681,14 @@ static void macb_taprio_destroy(struct net_device *netdev)
queue_mask << GEM_ENST_DISABLE_QUEUE_OFFSET);
/* Clear all queue ENST registers in batch */
- for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
+ for (q = 0, queue = bp->queues; q < bp->max_num_queues;
+ ++q, ++queue) {
queue_writel(queue, ENST_START_TIME, 0);
queue_writel(queue, ENST_ON_TIME, 0);
queue_writel(queue, ENST_OFF_TIME, 0);
}
}
+ bp->taprio_gated_queues = 0;
netdev_info(netdev, "TAPRIO destroy: All gates disabled\n");
}
@@ -5743,7 +5831,7 @@ static const struct macb_config sama5d2_config = {
static const struct macb_config sama5d29_config = {
.caps = MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII | MACB_CAPS_GEM_HAS_PTP |
- MACB_CAPS_USRIO_HAS_MII,
+ MACB_CAPS_USRIO_HAS_MII | MACB_CAPS_QUEUE_DISABLE,
.dma_burst_length = 16,
.usrio = &at91_default_usrio,
};
@@ -5780,6 +5868,7 @@ static const struct macb_config zynqmp_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
MACB_CAPS_JUMBO |
MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH |
+ MACB_CAPS_TXQSEGALLOC |
MACB_CAPS_USRIO_HAS_MII,
.dma_burst_length = 16,
.init = init_reset_optional,
@@ -5799,7 +5888,8 @@ static const struct macb_config mpfs_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
MACB_CAPS_JUMBO |
MACB_CAPS_GEM_HAS_PTP |
- MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE,
+ MACB_CAPS_USRIO_HAS_TSUCLK_SOURCE |
+ MACB_CAPS_QUEUE_DISABLE,
.dma_burst_length = 16,
.init = init_reset_optional,
.usrio = &mpfs_usrio,
@@ -5812,7 +5902,7 @@ static const struct macb_config sama7g5_gem_config = {
MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII |
MACB_CAPS_USRIO_HAS_REFCLK_SOURCE |
MACB_CAPS_MIIONRGMII | MACB_CAPS_GEM_HAS_PTP |
- MACB_CAPS_USRIO_HAS_MII,
+ MACB_CAPS_USRIO_HAS_MII | MACB_CAPS_QUEUE_DISABLE,
.dma_burst_length = 16,
.usrio = &sama7g5_gem_usrio,
};
@@ -5831,7 +5921,7 @@ static const struct macb_config versal_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_BD_RD_PREFETCH |
MACB_CAPS_NEED_TSUCLK | MACB_CAPS_QUEUE_DISABLE |
- MACB_CAPS_QBV |
+ MACB_CAPS_QBV | MACB_CAPS_TXQSEGALLOC |
MACB_CAPS_USRIO_HAS_MII,
.dma_burst_length = 16,
.init = init_reset_optional,
@@ -5842,7 +5932,7 @@ static const struct macb_config versal_config = {
static const struct macb_config eyeq5_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_QUEUE_DISABLE |
- MACB_CAPS_NO_LSO | MACB_CAPS_EEE,
+ MACB_CAPS_NO_LSO | MACB_CAPS_EEE | MACB_CAPS_TXQSEGALLOC,
.dma_burst_length = 16,
.init = eyeq5_init,
.jumbo_max_len = 10240,
@@ -5971,6 +6061,7 @@ static int macb_probe(struct platform_device *pdev)
bp->macb_reg_writel = hw_writel;
}
bp->num_queues = num_queues;
+ bp->max_num_queues = num_queues;
bp->dma_burst_length = macb_config->dma_burst_length;
bp->pclk = pclk;
bp->hclk = hclk;
diff --git a/drivers/net/ethernet/cadence/macb_utils.c b/drivers/net/ethernet/cadence/macb_utils.c
new file mode 100644
index 0000000000000..64ffba0c05224
--- /dev/null
+++ b/drivers/net/ethernet/cadence/macb_utils.c
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/netdevice.h>
+#include "macb.h"
+
+/*
+ * Distribute evenly available segments across queues. The computation is
+ * complex because (1) segments are counted in powers of two and (2) a queue
+ * can only use up to 8 segments. There are four types of cases:
+ * - Sharing all segments equally is doable. Take num_queues=4 and
+ * num_segments=16. Each queue will get 2^2=4 segments.
+ * - Sharing all segments is doable. Take num_queues=5 and num_segments=16.
+ * Three queues will get 2^2=4 segments and two will get 2^1=2 segments.
+ * - Sharing all segments is not doable because not enough queues are
+ * available. Take num_queues=1 and num_segments=16; queue 0 can only have 8
+ * segments.
+ * - Sharing all segments is not doable because not enough segments are
+ * available. Take num_queues=4 and num_segments=2.
+ *
+ * We start by computing the power each queue will have. For num_queues=5 and
+ * num_segments=16, each queue will have at least 2^1 segments. That leaves us
+ * with remaining_segments=6. If we increase the power for a queue, we get a
+ * delta of 2 (2^2-2^1). The first three queues will therefore be advantaged
+ * and each have 2^2 segments. The remaining 2 queues will only have 2^1
+ * segments.
+ */
+u32 gem_sram_distribute_segments(unsigned int num_queues,
+ unsigned int num_segments)
+{
+ unsigned int pow, remaining_segments, i;
+ unsigned int num_advantaged_queues = 0;
+ u32 val = 0;
+
+ /* When growing the max # of queues, make sure to return a u64 here and
+ * to write into GEM_TXQSEGALLOC_UPPER.
+ */
+ static_assert(MACB_MAX_QUEUES == 8);
+
+ /* pow=0 for all queues. ilog2(0) is dangerous. */
+ if (num_queues >= num_segments)
+ return 0;
+
+ pow = min_t(unsigned int, ilog2(num_segments / num_queues), 3);
+ remaining_segments = num_segments - num_queues * (1U << pow);
+
+ /* We can only distribute remaining segments if (1) there are remaining
+ * segments and (2) we did not reach the max segments per queue (2^3).
+ */
+ if (remaining_segments != 0 && pow != 3) {
+ unsigned int delta = (1U << (pow + 1)) - (1U << pow);
+
+ num_advantaged_queues = remaining_segments / delta;
+ }
+
+ for (i = 0; i < num_advantaged_queues; i++)
+ val |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow + 1);
+ for (i = num_advantaged_queues; i < num_queues; i++)
+ val |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow);
+
+ return val;
+}
|
| 3/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 11114 output: 33 thoughts: 636 Thoughts: **Fuzzing Feasibility Assessment: Cadence MACB Driver** Okay, so I need to decide if this patch warrants fuzzing with syzkaller on amd64. Let's break it down. First, I'll go through the diff step by step to understand what's changed: 1. A KUnit test has been added (`drivers/net/ethernet/cadence/Kconfig`, `Makefile`, `macb_kunit.c`), which in itself isn't a huge red flag for fuzzing, but it suggests new functionality is being introduced. 2. The header file (`macb.h`) now includes register definitions, a `max_num_queues` field, and changes related to TAPRIO, and a prototype for `gem_sram_distribute_segments`. 3. The main driver (`macb_main.c`) shows modifications across several key functions: `macb_init_buffers`, `macb_quiesce_start`, `macb_interrupt`, `macb_init_hw`, `macb_get_channels`, `macb_set_channels`, and ethtool operations, TAPRIO setup/destroy all utilizing the new `max_num_queues` and `taprio_gated_queues` variables. There's also hardware configuration changes for different platforms. This seems pretty significant. I see it uses a function `gem_sram_distribute_segments` 4. There's also a utils file (`macb_utils.c`) implementing this new `gem_sram_distribute_segments` function. Alright, so a lot of the changes are around improving queue handling and ethtool support. Now the key question for fuzzing: Can this driver be reasonably reached in a standard, virtualized environment? My target architecture is amd64. I need to figure out if the Cadence MACB / GEM ethernet driver is reachable in QEMU or GCE. Wait a second...is the MACB/GEM emulated by QEMU, or is it a PCI device? Or a platform device? I need to check how it's integrated. There's a `macb_pci.c` file! This is a good sign. If it's a PCI device, that increases the likelihood of being able to trigger it in a standard VM. I need to investigate `macb_pci.c` specifically. Let's search the codebase for uses of Cadence MACB with QEMU, or PCI IDs or look for references to platform devices. This will help determine if it is reachable, which in turn determines if fuzzing is worth the effort. |
| 4/2 | 2026/10/17 02:34 | tool | grepper |
0mArgs:{
"Expression": "macb",
"PathPrefixes": [
"drivers/net/ethernet/cadence/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 3109 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (8 files in total):\ndrivers/net/ethernet/cadence/Kconfig:2\ndrivers/net/ethernet/cadence/Makefile:6\ndrivers/net/ethernet/cadence/macb.h:69\ndrivers/net/ethernet/cadence/macb_kunit.c:16\ndrivers/net/ethernet/cadence/macb_main.c:871\ndrivers/net/ethernet/cadence/macb_pci.c:12\ndrivers/net/ethernet/cadence/macb_ptp.c:37\ndrivers/net/ethernet/cadence/macb_utils.c:1\n\ndrivers/net/ethernet/cadence/Kconfig=22=config MACB\n--\ndrivers/net/ethernet/cadence/Kconfig-34-\t To compile this driver as a module, choose M here: the module\ndrivers/net/ethernet/cadence/Kconfig:35:\t will be macb.\ndrivers/net/ethernet/cadence/Kconfig-36-\n--\ndrivers/net/ethernet/cadence/Kconfig=45=config MACB_PCI\n--\ndrivers/net/ethernet/cadence/Kconfig-51-\t To compile this driver as a module, choose M here: the module\ndrivers/net/ethernet/cadence/Kconfig:52:\t will be called macb_pci.\ndrivers/net/ethernet/cadence/Kconfig-53-\n--\ndrivers/net/ethernet/cadence/Makefile-4-#\ndrivers/net/ethernet/cadence/Makefile:5:macb-y\t:= macb_main.o macb_utils.o\ndrivers/net/ethernet/cadence/Makefile-6-\ndrivers/net/ethernet/cadence/Makefile=7=ifeq ($(CONFIG_MACB_USE_HWSTAMP),y)\ndrivers/net/ethernet/cadence/Makefile:8:macb-y\t+= macb_ptp.o\ndrivers/net/ethernet/cadence/Makefile-9-endif\ndrivers/net/ethernet/cadence/Makefile-10-\ndrivers/net/ethernet/cadence/Makefile:11:obj-$(CONFIG_MACB) += macb.o\ndrivers/net/ethernet/cadence/Makefile:12:obj-$(CONFIG_MACB_PCI) += macb_pci.o\ndrivers/net/ethernet/cadence/Makefile-13-\ndrivers/net/ethernet/cadence/Makefile:14:obj-$(CONFIG_MACB_KUNIT_TEST) += macb_test.o\ndrivers/net/ethernet/cadence/Makefile:15:macb_test-y := macb_kunit.o macb_utils.o\n--\ndrivers/net/ethernet/cadence/macb.h-834-/* Register access macros */\ndrivers/net/ethernet/cadence/macb.h:835:#define macb_readl(port, reg)\t\t(port)-\u003emacb_reg_readl((port), MACB_##reg)\ndrivers/net/ethernet/cadence/macb.h:836:#define macb_writel(port, reg, value)\t(port)-\u003emacb_reg_writel((port), MACB_##reg, (value))\ndrivers/net/ethernet/cadence/macb.h:837:#define gem_readl(port, reg)\t\t(port)-\u003emacb_reg_readl((port), GEM_##reg)\ndrivers/net/ethernet/cadence/macb.h:838:#define gem_writel(port, reg, value)\t(port)-\u003emacb_reg_writel((port), GEM_##reg, (value))\ndrivers/net/ethernet/cadence/macb.h:839:#define queue_readl(queue, reg)\t\t(queue)-\u003ebp-\u003emacb_reg_readl((queue)-\u003ebp, (queue)-\u003ereg)\ndrivers/net/ethernet/cadence/macb.h:840:#define queue_writel(queue, reg, value)\t(queue)-\u003ebp-\u003emacb_reg_writel((queue)-\u003ebp, (queue)-\u003ereg, (value))\ndrivers/net/ethernet/cadence/macb.h:841:#define gem_readl_n(port, reg, idx)\t\t(port)-\u003emacb_reg_readl((port), GEM_##reg + idx * 4)\ndrivers/net/ethernet/cadence/macb.h:842:#define gem_writel_n(port, reg, idx, value)\t(port)-\u003emacb_reg_writel((port), GEM_##reg + idx * 4, (value))\ndrivers/net/ethernet/cadence/macb.h-843-\n--\ndrivers/net/ethernet/cadence/macb.h-845- * register dependent on whether the device is a GEM or a MACB. For registers\ndrivers/net/ethernet/cadence/macb.h:846: * and bitfields that are common across both devices, use macb_{read,write}l\ndrivers/net/ethernet/cadence/macb.h-847- * to avoid the cost of the conditional.\ndrivers/net/ethernet/cadence/macb.h-848- */\ndrivers/net/ethernet/cadence/macb.h:849:#define macb_or_gem_writel(__bp, __reg, __value) \\\ndrivers/net/ethernet/cadence/macb.h-850-\t({ \\\ndrivers/net/ethernet/cadence/macb.h:851:\t\tif (macb_is_gem((__bp))) \\\ndrivers/net/ethernet/cadence/macb.h-852-\t\t\tgem_writel((__bp), __reg, __value); \\\ndrivers/net/ethernet/cadence/macb.h-853-\t\telse \\\ndrivers/net/ethernet/cadence/macb.h:854:\t\t\tmacb_writel((__bp), __reg, __value); \\\ndrivers/net/ethernet/cadence/macb.h-855-\t})\ndrivers/net/ethernet/cadence/macb.h-856-\ndrivers/net/ethernet/cadence/macb.h:857:#define macb_or_gem_readl(__bp, __reg) \\\ndrivers/net/ethernet/cadence/macb.h-858-\t({ \\\ndrivers/net/ethernet/cadence/macb.h-859-\t\tu32 __v; \\\ndrivers/net/ethernet/cadence/macb.h:860:\t\tif (macb_is_gem((__bp))) \\\ndrivers/net/ethernet/cadence/macb.h-861-\t\t\t__v = gem_readl((__bp), __reg); \\\ndrivers/net/ethernet/cadence/macb.h-862-\t\telse \\\ndrivers/net/ethernet/cadence/macb.h:863:\t\t\t__v = macb_readl((__bp), __reg); \\\ndrivers/net/ethernet/cadence/macb.h-864-\t\t__v; \\\n--\ndrivers/net/ethernet/cadence/macb.h-866-\ndrivers/net/ethernet/cadence/macb.h:867:#define MACB_READ_NSR(bp)\tmacb_readl(bp, NSR)\ndrivers/net/ethernet/cadence/macb.h-868-\ndrivers/net/ethernet/cadence/macb.h:869:/* struct macb_dma_desc - Hardware DMA descriptor\ndrivers/net/ethernet/cadence/macb.h-870- * @addr: DMA address of data buffer\n--\ndrivers/net/ethernet/cadence/macb.h-872- */\ndrivers/net/ethernet/cadence/macb.h:873:struct macb_dma_desc {\ndrivers/net/ethernet/cadence/macb.h-874-\tu32\taddr;\n--\ndrivers/net/ethernet/cadence/macb.h-877-\ndrivers/net/ethernet/cadence/macb.h:878:struct macb_dma_desc_64 {\ndrivers/net/ethernet/cadence/macb.h-879-\tu32 addrh;\n--\ndrivers/net/ethernet/cadence/macb.h-882-\ndrivers/net/ethernet/cadence/macb.h:883:struct macb_dma_desc_ptp {\ndrivers/net/ethernet/cadence/macb.h-884-\tu32\tts_1;\n--\ndrivers/net/ethernet/cadence/macb.h-979-\ndrivers/net/ethernet/cadence/macb.h:980:/* struct macb_tx_skb - data about an skb which is being transmitted\ndrivers/net/ethernet/cadence/macb.h-981- * @skb: skb currently being transmitted, only set for the last buffer\n--\ndrivers/net/ethernet/cadence/macb.h-989- */\ndrivers/net/ethernet/cadence/macb.h:990:struct macb_tx_skb {\ndrivers/net/ethernet/cadence/macb.h-991-\tstruct sk_buff\t\t*skb;\n--\ndrivers/net/ethernet/cadence/macb.h-1000- */\ndrivers/net/ethernet/cadence/macb.h:1001:struct macb_stats {\ndrivers/net/ethernet/cadence/macb.h-1002-\tu64\trx_pause_frames;\n--\ndrivers/net/ethernet/cadence/macb.h=1197=static const struct gem_statistic queue_statistics[] = {\n--\ndrivers/net/ethernet/cadence/macb.h-1207-\ndrivers/net/ethernet/cadence/macb.h:1208:struct macb;\ndrivers/net/ethernet/cadence/macb.h:1209:struct macb_queue;\ndrivers/net/ethernet/cadence/macb.h-1210-\ndrivers/net/ethernet/cadence/macb.h:1211:struct macb_or_gem_ops {\ndrivers/net/ethernet/cadence/macb.h:1212:\tint\t(*mog_alloc_rx_buffers)(struct macb *bp);\ndrivers/net/ethernet/cadence/macb.h:1213:\tvoid\t(*mog_free_rx_buffers)(struct macb *bp);\ndrivers/net/ethernet/cadence/macb.h:1214:\tint\t(*mog_init_rings)(struct macb *bp);\ndrivers/net/ethernet/cadence/macb.h:1215:\tint\t(*mog_rx)(struct macb_queue *queue, struct napi_struct *napi,\ndrivers/net/ethernet/cadence/macb.h-1216-\t\t\t int budget);\n--\ndrivers/net/ethernet/cadence/macb.h-1219-/* MACB-PTP interface: adapt to platform needs. */\ndrivers/net/ethernet/cadence/macb.h:1220:struct macb_ptp_info {\ndrivers/net/ethernet/cadence/macb.h-1221-\tvoid (*ptp_init)(struct net_device *netdev);\n--\ndrivers/net/ethernet/cadence/macb.h-1223-\ts32 (*get_ptp_max_adj)(void);\ndrivers/net/ethernet/cadence/macb.h:1224:\tunsigned int (*get_tsu_rate)(struct macb *bp);\ndrivers/net/ethernet/cadence/macb.h-1225-\tint (*get_ts_info)(struct net_device *netdev,\n--\ndrivers/net/ethernet/cadence/macb.h-1233-\ndrivers/net/ethernet/cadence/macb.h:1234:struct macb_pm_data {\ndrivers/net/ethernet/cadence/macb.h-1235-\tu32 scrt2;\n--\ndrivers/net/ethernet/cadence/macb.h-1238-\ndrivers/net/ethernet/cadence/macb.h:1239:struct macb_usrio_config {\ndrivers/net/ethernet/cadence/macb.h-1240-\tu32 mii;\n--\ndrivers/net/ethernet/cadence/macb.h-1249-\ndrivers/net/ethernet/cadence/macb.h:1250:struct macb_config {\ndrivers/net/ethernet/cadence/macb.h-1251-\tu32\t\t\tcaps;\n--\ndrivers/net/ethernet/cadence/macb.h-1258-\tint\tjumbo_max_len;\ndrivers/net/ethernet/cadence/macb.h:1259:\tconst struct macb_usrio_config *usrio;\ndrivers/net/ethernet/cadence/macb.h-1260-};\n--\ndrivers/net/ethernet/cadence/macb.h=1262=struct tsu_incr {\n--\ndrivers/net/ethernet/cadence/macb.h-1266-\ndrivers/net/ethernet/cadence/macb.h:1267:struct macb_queue {\ndrivers/net/ethernet/cadence/macb.h:1268:\tstruct macb\t\t*bp;\ndrivers/net/ethernet/cadence/macb.h-1269-\tint\t\t\tirq;\n--\ndrivers/net/ethernet/cadence/macb.h-1286-\tunsigned int\t\ttx_head, tx_tail;\ndrivers/net/ethernet/cadence/macb.h:1287:\tstruct macb_dma_desc\t*tx_ring;\ndrivers/net/ethernet/cadence/macb.h:1288:\tstruct macb_tx_skb\t*tx_skb;\ndrivers/net/ethernet/cadence/macb.h-1289-\tdma_addr_t\t\ttx_ring_dma;\n--\ndrivers/net/ethernet/cadence/macb.h-1297-\tunsigned int\t\trx_prepared_head;\ndrivers/net/ethernet/cadence/macb.h:1298:\tstruct macb_dma_desc\t*rx_ring;\ndrivers/net/ethernet/cadence/macb.h-1299-\tstruct sk_buff\t\t**rx_skbuff;\n--\ndrivers/net/ethernet/cadence/macb.h=1310=struct ethtool_rx_fs_list {\n--\ndrivers/net/ethernet/cadence/macb.h-1314-\ndrivers/net/ethernet/cadence/macb.h:1315:struct macb {\ndrivers/net/ethernet/cadence/macb.h-1316-\tvoid __iomem\t\t*regs;\n--\ndrivers/net/ethernet/cadence/macb.h-1319-\t/* hardware IO accessors */\ndrivers/net/ethernet/cadence/macb.h:1320:\tu32\t(*macb_reg_readl)(struct macb *bp, int offset);\ndrivers/net/ethernet/cadence/macb.h:1321:\tvoid\t(*macb_reg_writel)(struct macb *bp, int offset, u32 value);\ndrivers/net/ethernet/cadence/macb.h-1322-\ndrivers/net/ethernet/cadence/macb.h:1323:\tstruct macb_dma_desc\t*rx_ring_tieoff;\ndrivers/net/ethernet/cadence/macb.h-1324-\tdma_addr_t\t\trx_ring_tieoff_dma;\n--\ndrivers/net/ethernet/cadence/macb.h-1333-\tu32\t\t\ttaprio_gated_queues;\ndrivers/net/ethernet/cadence/macb.h:1334:\tstruct macb_queue\tqueues[MACB_MAX_QUEUES];\ndrivers/net/ethernet/cadence/macb.h-1335-\n--\ndrivers/net/ethernet/cadence/macb.h-1346-\tunion {\ndrivers/net/ethernet/cadence/macb.h:1347:\t\tstruct macb_stats\tmacb;\ndrivers/net/ethernet/cadence/macb.h-1348-\t\tstruct gem_stats\tgem;\n--\ndrivers/net/ethernet/cadence/macb.h-1350-\ndrivers/net/ethernet/cadence/macb.h:1351:\tstruct macb_or_gem_ops\tmacbgem_ops;\ndrivers/net/ethernet/cadence/macb.h-1352-\n--\ndrivers/net/ethernet/cadence/macb.h-1364-\t/* AT91RM9200 transmit queue (1 on wire + 1 queued) */\ndrivers/net/ethernet/cadence/macb.h:1365:\tstruct macb_tx_skb\trm9200_txq[2];\ndrivers/net/ethernet/cadence/macb.h-1366-\tunsigned int\t\tmax_tx_length;\n--\ndrivers/net/ethernet/cadence/macb.h-1378-\ndrivers/net/ethernet/cadence/macb.h:1379:\tstruct macb_ptp_info\t*ptp_info;\t/* macb-ptp interface */\ndrivers/net/ethernet/cadence/macb.h-1380-\n--\ndrivers/net/ethernet/cadence/macb.h-1411-\ndrivers/net/ethernet/cadence/macb.h:1412:\tstruct macb_pm_data pm_data;\ndrivers/net/ethernet/cadence/macb.h:1413:\tconst struct macb_usrio_config *usrio;\ndrivers/net/ethernet/cadence/macb.h-1414-};\n--\ndrivers/net/ethernet/cadence/macb.h-1420-\ndrivers/net/ethernet/cadence/macb.h:1421:enum macb_bd_control {\ndrivers/net/ethernet/cadence/macb.h-1422-\tTSTAMP_DISABLED,\n--\ndrivers/net/ethernet/cadence/macb.h=1429=void gem_ptp_remove(struct net_device *netdev);\ndrivers/net/ethernet/cadence/macb.h:1430:void gem_ptp_txstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc);\ndrivers/net/ethernet/cadence/macb.h:1431:void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc);\ndrivers/net/ethernet/cadence/macb.h:1432:static inline void gem_ptp_do_txstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc)\ndrivers/net/ethernet/cadence/macb.h-1433-{\n--\ndrivers/net/ethernet/cadence/macb.h-1439-\ndrivers/net/ethernet/cadence/macb.h:1440:static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc)\ndrivers/net/ethernet/cadence/macb.h-1441-{\n--\ndrivers/net/ethernet/cadence/macb.h=1455=static inline void gem_ptp_remove(struct net_device *netdev) { }\ndrivers/net/ethernet/cadence/macb.h-1456-\ndrivers/net/ethernet/cadence/macb.h:1457:static inline void gem_ptp_do_txstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc) { }\ndrivers/net/ethernet/cadence/macb.h:1458:static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc) { }\ndrivers/net/ethernet/cadence/macb.h-1459-#endif\ndrivers/net/ethernet/cadence/macb.h-1460-\ndrivers/net/ethernet/cadence/macb.h:1461:static inline bool macb_is_gem(struct macb *bp)\ndrivers/net/ethernet/cadence/macb.h-1462-{\n\n"
} |
| 5/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17716 output: 44 thoughts: 13 Thoughts: Okay, let's dive in. Here's my thought process as I approach this: **Analyzing `macb_pci.c`** Alright, the objective is pretty clear. I need to take a look at `macb_pci.c`. My mind is already starting to consider what I expect to find in there, given the filename. I'm guessing this is likely the PCI-specific driver code for the MACB Ethernet controller. That means I'll be looking for things like PCI device ID matching, initialization routines specific to PCI, resource allocation, and of course, the PCI configuration space accesses for setting up the hardware. I’ll expect to see functions that handle probe and remove operations, likely hooked into the PCI subsystem. I'm going to pay close attention to the interrupt handling mechanism implemented here and how it's tied to the device. Any power management related implementations would also be interesting. Let's get started. |
| 6/2 | 2026/10/17 02:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/cadence/macb_pci.c",
"FirstLine": 1,
"LineCount": 100
}Results: {
"Contents": " 1:\t// SPDX-License-Identifier: GPL-2.0-only\n 2:\t/*\n 3:\t * DOC: Cadence GEM PCI wrapper.\n 4:\t *\n 5:\t * Copyright (C) 2016 Cadence Design Systems - https://www.cadence.com\n 6:\t *\n 7:\t * Authors: Rafal Ozieblo \u003crafalo@cadence.com\u003e\n 8:\t *\t Bartosz Folta \u003cbfolta@cadence.com\u003e\n 9:\t */\n 10:\t\n 11:\t#include \u003clinux/clk.h\u003e\n 12:\t#include \u003clinux/clk-provider.h\u003e\n 13:\t#include \u003clinux/etherdevice.h\u003e\n 14:\t#include \u003clinux/module.h\u003e\n 15:\t#include \u003clinux/pci.h\u003e\n 16:\t#include \u003clinux/platform_device.h\u003e\n 17:\t#include \"macb.h\"\n 18:\t\n 19:\t#define PCI_DRIVER_NAME \"macb_pci\"\n 20:\t#define PLAT_DRIVER_NAME \"macb\"\n 21:\t\n 22:\t#define PCI_DEVICE_ID_CDNS_MACB 0xe007\n 23:\t\n 24:\t#define GEM_PCLK_RATE 50000000\n 25:\t#define GEM_HCLK_RATE 50000000\n 26:\t\n 27:\tstatic int macb_probe(struct pci_dev *pci, const struct pci_device_id *id)\n 28:\t{\n 29:\t\tint err;\n 30:\t\tstruct platform_device *pdev;\n 31:\t\tstruct platform_device_info plat_info;\n 32:\t\tstruct macb_platform_data plat_data;\n 33:\t\tstruct resource res[2];\n 34:\t\n 35:\t\t/* enable pci device */\n 36:\t\terr = pcim_enable_device(pci);\n 37:\t\tif (err \u003c 0) {\n 38:\t\t\tdev_err(\u0026pci-\u003edev, \"Enabling PCI device has failed: %d\", err);\n 39:\t\t\treturn err;\n 40:\t\t}\n 41:\t\n 42:\t\tpci_set_master(pci);\n 43:\t\n 44:\t\t/* set up resources */\n 45:\t\tmemset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));\n 46:\t\tres[0].start = pci_resource_start(pci, 0);\n 47:\t\tres[0].end = pci_resource_end(pci, 0);\n 48:\t\tres[0].name = PCI_DRIVER_NAME;\n 49:\t\tres[0].flags = IORESOURCE_MEM;\n 50:\t\tres[1].start = pci_irq_vector(pci, 0);\n 51:\t\tres[1].name = PCI_DRIVER_NAME;\n 52:\t\tres[1].flags = IORESOURCE_IRQ;\n 53:\t\n 54:\t\tdev_info(\u0026pci-\u003edev, \"EMAC physical base addr: %pa\\n\",\n 55:\t\t\t \u0026res[0].start);\n 56:\t\n 57:\t\t/* set up macb platform data */\n 58:\t\tmemset(\u0026plat_data, 0, sizeof(plat_data));\n 59:\t\n 60:\t\t/* initialize clocks */\n 61:\t\tplat_data.pclk = clk_register_fixed_rate(\u0026pci-\u003edev, \"pclk\", NULL, 0,\n 62:\t\t\t\t\t\t\t GEM_PCLK_RATE);\n 63:\t\tif (IS_ERR(plat_data.pclk)) {\n 64:\t\t\terr = PTR_ERR(plat_data.pclk);\n 65:\t\t\tgoto err_pclk_register;\n 66:\t\t}\n 67:\t\n 68:\t\tplat_data.hclk = clk_register_fixed_rate(\u0026pci-\u003edev, \"hclk\", NULL, 0,\n 69:\t\t\t\t\t\t\t GEM_HCLK_RATE);\n 70:\t\tif (IS_ERR(plat_data.hclk)) {\n 71:\t\t\terr = PTR_ERR(plat_data.hclk);\n 72:\t\t\tgoto err_hclk_register;\n 73:\t\t}\n 74:\t\n 75:\t\t/* set up platform device info */\n 76:\t\tmemset(\u0026plat_info, 0, sizeof(plat_info));\n 77:\t\tplat_info.parent = \u0026pci-\u003edev;\n 78:\t\tplat_info.fwnode = pci-\u003edev.fwnode;\n 79:\t\tplat_info.name = PLAT_DRIVER_NAME;\n 80:\t\tplat_info.id = pci-\u003edevfn;\n 81:\t\tplat_info.res = res;\n 82:\t\tplat_info.num_res = ARRAY_SIZE(res);\n 83:\t\tplat_info.data = \u0026plat_data;\n 84:\t\tplat_info.size_data = sizeof(plat_data);\n 85:\t\tplat_info.dma_mask = pci-\u003edma_mask;\n 86:\t\n 87:\t\t/* register platform device */\n 88:\t\tpdev = platform_device_register_full(\u0026plat_info);\n 89:\t\tif (IS_ERR(pdev)) {\n 90:\t\t\terr = PTR_ERR(pdev);\n 91:\t\t\tgoto err_plat_dev_register;\n 92:\t\t}\n 93:\t\n 94:\t\tpci_set_drvdata(pci, pdev);\n 95:\t\n 96:\t\treturn 0;\n 97:\t\n 98:\terr_plat_dev_register:\n 99:\t\tclk_unregister_fixed_rate(plat_data.hclk);\n 100:\t\n"
} |
| 7/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19497 output: 45 thoughts: 16 Thoughts: Okay, here's my summary, presented as a stream of thought: **Diving into `macb_pci.c`** Alright, time to crack open the rest of `macb_pci.c`. I've been working with this driver for a while, but there's always something new to glean, some nuance I might have missed before. I'm especially interested in the PCI-specific parts, since that's the interface we're focusing on for this project. Let's see how the MACB interacts with the PCI bus here. Are we dealing with standard PCI config space access, or are there any interesting quirks specific to this particular implementation? I'll be looking for things like resource allocation, interrupt handling, and any power management considerations. I'm expecting to see calls to `pci_request_regions()`, `pci_enable_device()`, and likely some interrupt registration using `request_irq()`. Beyond the basic PCI setup, I'll be keeping an eye out for any hardware-specific initialization that deviates from the common MACB driver approach. Any register writes that are conditional on the PCI device ID, or the revision ID, for instance? I'll also be trying to spot any subtle workarounds for silicon errata or board-specific hardware limitations. Always the interesting stuff. And finally, I'll be tracing the flow of initialization, from probe to removal, and making sure I fully grasp how the driver manages the lifecycle of the MACB on this platform. |
| 8/2 | 2026/10/17 02:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/cadence/macb_pci.c",
"FirstLine": 101,
"LineCount": 40
}Results: {
"Contents": " 101:\terr_hclk_register:\n 102:\t\tclk_unregister_fixed_rate(plat_data.pclk);\n 103:\t\n 104:\terr_pclk_register:\n 105:\t\treturn err;\n 106:\t}\n 107:\t\n 108:\tstatic void macb_remove(struct pci_dev *pci)\n 109:\t{\n 110:\t\tstruct platform_device *pdev = pci_get_drvdata(pci);\n 111:\t\tstruct macb_platform_data *plat_data = dev_get_platdata(\u0026pdev-\u003edev);\n 112:\t\tstruct clk *pclk = plat_data-\u003epclk;\n 113:\t\tstruct clk *hclk = plat_data-\u003ehclk;\n 114:\t\n 115:\t\tplatform_device_unregister(pdev);\n 116:\t\tclk_unregister_fixed_rate(pclk);\n 117:\t\tclk_unregister_fixed_rate(hclk);\n 118:\t}\n 119:\t\n 120:\tstatic const struct pci_device_id dev_id_table[] = {\n 121:\t\t{ PCI_VDEVICE(CDNS, PCI_DEVICE_ID_CDNS_MACB) },\n 122:\t\t{ 0, }\n 123:\t};\n 124:\t\n 125:\tstatic struct pci_driver macb_pci_driver = {\n 126:\t\t.name = PCI_DRIVER_NAME,\n 127:\t\t.id_table = dev_id_table,\n 128:\t\t.probe = macb_probe,\n 129:\t\t.remove\t = macb_remove,\n 130:\t};\n 131:\t\n 132:\tmodule_pci_driver(macb_pci_driver);\n 133:\tMODULE_DEVICE_TABLE(pci, dev_id_table);\n 134:\tMODULE_LICENSE(\"GPL\");\n 135:\tMODULE_DESCRIPTION(\"Cadence NIC PCI wrapper\");\n"
} |
| 9/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20437 output: 38 thoughts: 37 Thoughts: Okay, let's dive into this. Here's how I'd approach summarizing the Kconfig dependencies, framed as my own thought process: **Analyzing `drivers/net/ethernet/cadence/Kconfig` for `CONFIG_MACB` and `CONFIG_MACB_PCI` Dependencies** Right, so I need to figure out the dependencies for `CONFIG_MACB` and `CONFIG_MACB_PCI` within the Cadence Ethernet driver's Kconfig file. This is standard procedure when I'm debugging driver configurations, or trying to understand how a particular feature is enabled. I know from experience that the Kconfig files are the heart of how these decisions are made. I'm assuming that by exploring what these configuration options depend on, I can better understand their requirements and potentially troubleshoot any related build or runtime issues. Knowing these dependencies will give me a better understanding of the wider context of the driver and its place within the kernel's Ethernet subsystem. Let's get to work and see what the Kconfig tells us. |
| 10/2 | 2026/10/17 02:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/cadence/Kconfig",
"FirstLine": 1,
"LineCount": 60
}Results: {
"Contents": " 1:\t# SPDX-License-Identifier: GPL-2.0-only\n 2:\t#\n 3:\t# Cadence device configuration\n 4:\t#\n 5:\t\n 6:\tconfig NET_VENDOR_CADENCE\n 7:\t\tbool \"Cadence devices\"\n 8:\t\tdepends on HAS_IOMEM\n 9:\t\tdefault y\n 10:\t\thelp\n 11:\t\t If you have a network (Ethernet) card belonging to this class, say Y.\n 12:\t\n 13:\t\t If unsure, say Y.\n 14:\t\n 15:\t\t Note that the answer to this question doesn't directly affect the\n 16:\t\t kernel: saying N will just cause the configurator to skip all the\n 17:\t\t remaining Cadence network card questions. If you say Y, you will be\n 18:\t\t asked for your specific card in the following questions.\n 19:\t\n 20:\tif NET_VENDOR_CADENCE\n 21:\t\n 22:\tconfig MACB\n 23:\t\ttristate \"Cadence MACB/GEM support\"\n 24:\t\tdepends on HAS_DMA \u0026\u0026 COMMON_CLK\n 25:\t\tdepends on PTP_1588_CLOCK_OPTIONAL\n 26:\t\tselect PHYLINK\n 27:\t\tselect CRC32\n 28:\t\thelp\n 29:\t\t The Cadence MACB ethernet interface is found on many Atmel AT32 and\n 30:\t\t AT91 parts. This driver also supports the Cadence GEM (Gigabit\n 31:\t\t Ethernet MAC found in some ARM SoC devices). Say Y to include\n 32:\t\t support for the MACB/GEM chip.\n 33:\t\n 34:\t\t To compile this driver as a module, choose M here: the module\n 35:\t\t will be macb.\n 36:\t\n 37:\tconfig MACB_USE_HWSTAMP\n 38:\t\tbool \"Use IEEE 1588 hwstamp\"\n 39:\t\tdepends on MACB\n 40:\t\tdepends on PTP_1588_CLOCK\n 41:\t\tdefault y\n 42:\t\thelp\n 43:\t\t Enable IEEE 1588 Precision Time Protocol (PTP) support for MACB.\n 44:\t\n 45:\tconfig MACB_PCI\n 46:\t\ttristate \"Cadence PCI MACB/GEM support\"\n 47:\t\tdepends on MACB \u0026\u0026 PCI\n 48:\t\thelp\n 49:\t\t This is PCI wrapper for MACB driver.\n 50:\t\n 51:\t\t To compile this driver as a module, choose M here: the module\n 52:\t\t will be called macb_pci.\n 53:\t\n 54:\tconfig MACB_KUNIT_TEST\n 55:\t\ttristate \"KUnit test for MACB\" if !KUNIT_ALL_TESTS\n 56:\t\tdepends on KUNIT\n 57:\t\tdefault KUNIT_ALL_TESTS\n 58:\t\thelp\n 59:\t\t Build KUnit tests for the MACB driver.\n 60:\t\n"
} |
| 11/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21529 output: 38 thoughts: 905 Thoughts: **Analyzing Cadence GEM Reachability in Syzkaller and QEMU**
Okay, first things first, I need to figure out if the Cadence MACB/GEM is even something that can be targeted by syzkaller. I'm wondering if QEMU emulates it, and if so, how. Okay, QEMU *does* have `hw/net/cadence_gem.c`, that's promising! But wait, is it emulated for amd64, the architecture syzkaller typically runs on, or is it specific to ARM (like Zynq or ZynqMP)? It looks like, in QEMU's implementation, `cadence_gem.c` is a sysbus (platform) device, `TYPE_CADENCE_GEM`, used by specific ARM machines.
So, is there a *PCI* Cadence GEM device? No, let's check for any PCI wrappers. Ah, `cadence_gem` is a SysBusDevice, and it's used in `hw/arm/xilinx_zynq.c`, `hw/arm/xlnx-zynqmp.c`, and `hw/arm/xlnx-versal.c`. But what about amd64? Can a platform device or PCI device with vendor CDNS (0x17cd) and device 0xe007 even be emulated in standard QEMU x86_64? I'm focusing on what's available in standard QEMU x86_64, the environment syzkaller runs in (or on GCE). Does this standard QEMU build have Cadence GEM? Can I use `-device ...` to instantiate it?
Nope. `cadence_gem` is *not* a PCI device in QEMU. It's a sysbus device, which can't be instantiated on x86_64 PC / Q35 machines. What about `macb_pci`? QEMU *does NOT* have a Cadence PCI device. It looks like the PCI ID 0x17cd:0xe007 was a custom FPGA or test board made by Cadence ("Cadence GEM PCI wrapper", "Copyright 2016 Cadence Design Systems").
Now, can syzkaller instantiate platform devices? Syzkaller runs on x86_64. Can user-space instantiate platform devices or mock them, or is Cadence MACB just structurally unreachable hardware in this context?
Alright, let's go back to the instructions. The primary concern is reachability: if the code is structurally unreachable, it shouldn't be fuzzed. It mentions "Structurally unreachable hardware: * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU." This is the problem.
But what about KUnit tests? Let's check the patch diff. I see `CONFIG_MACB_KUNIT_TEST` and `macb_kunit.c`. Is that something syzkaller fuzzes? Ah, no! "User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/) that do not affect the compiled kernel image (vmlinux) or kernel modules." KUnit tests are unit tests that run at boot or module load time by KUnit runner. It's not fuzzed by syzkaller.
Finally, what about `macb_main.c` and `macb_utils.c`? Can `macb` be instantiated or probed without specific physical hardware? Let's check `macb_probe` in `macb_main.c`.
|
| 12/2 | 2026/10/17 02:34 | tool | grepper |
0mArgs:{
"Expression": "static int macb_probe\\(",
"PathPrefixes": [
"drivers/net/ethernet/cadence/"
]
}Results: {
"Output": "drivers/net/ethernet/cadence/macb_main.c=5990=static const struct macb_config default_gem_config = {\n--\ndrivers/net/ethernet/cadence/macb_main.c-5998-\ndrivers/net/ethernet/cadence/macb_main.c:5999:static int macb_probe(struct platform_device *pdev)\ndrivers/net/ethernet/cadence/macb_main.c-6000-{\n--\ndrivers/net/ethernet/cadence/macb_pci.c-26-\ndrivers/net/ethernet/cadence/macb_pci.c:27:static int macb_probe(struct pci_dev *pci, const struct pci_device_id *id)\ndrivers/net/ethernet/cadence/macb_pci.c-28-{\n"
} |
| 13/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23522 output: 45 thoughts: 19 Thoughts: Okay, let's dive into this. Here's my take on examining `macb_probe` in `macb_main.c`: **Deep Dive into `macb_probe`** Alright, I'm thinking, let's get into the heart of this MACB driver. The first thing I'm reaching for is `macb_probe` within `macb_main.c`. This is where the magic really starts, the initial hardware detection and setup phase. I want to understand exactly how the driver identifies the hardware, validates its capabilities, and prepares it for operation. I'm imagining it: identifying the device, allocating resources, possibly mapping registers, and probably doing some basic testing to ensure everything is connected and talking. I'll be looking for how it handles different hardware revisions or configurations, and how it deals with potential errors during this initial process. Is there robust error handling implemented? Are there specific checks for particular hardware features? My focus will be on the nitty-gritty details of the initialization process. This is the foundation upon which everything else rests, so it's a critical area to understand completely. The goal is to see if there are any quirks or optimizations that stand out. |
| 14/2 | 2026/10/17 02:34 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/cadence/macb_main.c",
"FirstLine": 5998,
"LineCount": 80
}Results: {
"Contents": "5998:\t\n5999:\tstatic int macb_probe(struct platform_device *pdev)\n6000:\t{\n6001:\t\tstruct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;\n6002:\t\tstruct device_node *np = pdev-\u003edev.of_node;\n6003:\t\tconst struct macb_config *macb_config;\n6004:\t\tstruct clk *tsu_clk = NULL;\n6005:\t\tphy_interface_t interface;\n6006:\t\tstruct net_device *netdev;\n6007:\t\tstruct resource *regs;\n6008:\t\tu32 wtrmrk_rst_val;\n6009:\t\tvoid __iomem *mem;\n6010:\t\tstruct macb *bp;\n6011:\t\tint num_queues;\n6012:\t\tbool native_io;\n6013:\t\tint err, val;\n6014:\t\n6015:\t\tmem = devm_platform_get_and_ioremap_resource(pdev, 0, \u0026regs);\n6016:\t\tif (IS_ERR(mem))\n6017:\t\t\treturn PTR_ERR(mem);\n6018:\t\n6019:\t\tmacb_config = of_device_get_match_data(\u0026pdev-\u003edev);\n6020:\t\tif (!macb_config)\n6021:\t\t\tmacb_config = \u0026default_gem_config;\n6022:\t\n6023:\t\terr = macb_clk_init(pdev, \u0026pclk, \u0026hclk, \u0026tx_clk, \u0026rx_clk, \u0026tsu_clk,\n6024:\t\t\t\t macb_config);\n6025:\t\tif (err)\n6026:\t\t\treturn err;\n6027:\t\n6028:\t\tpm_runtime_set_autosuspend_delay(\u0026pdev-\u003edev, MACB_PM_TIMEOUT);\n6029:\t\tpm_runtime_use_autosuspend(\u0026pdev-\u003edev);\n6030:\t\tpm_runtime_get_noresume(\u0026pdev-\u003edev);\n6031:\t\tpm_runtime_set_active(\u0026pdev-\u003edev);\n6032:\t\tpm_runtime_enable(\u0026pdev-\u003edev);\n6033:\t\tnative_io = hw_is_native_io(mem);\n6034:\t\n6035:\t\tnum_queues = macb_probe_queues(\u0026pdev-\u003edev, mem, native_io);\n6036:\t\tif (num_queues \u003c 0) {\n6037:\t\t\terr = num_queues;\n6038:\t\t\tgoto err_disable_clocks;\n6039:\t\t}\n6040:\t\n6041:\t\tnetdev = alloc_etherdev_mq(sizeof(*bp), num_queues);\n6042:\t\tif (!netdev) {\n6043:\t\t\terr = -ENOMEM;\n6044:\t\t\tgoto err_disable_clocks;\n6045:\t\t}\n6046:\t\n6047:\t\tnetdev-\u003ebase_addr = regs-\u003estart;\n6048:\t\n6049:\t\tSET_NETDEV_DEV(netdev, \u0026pdev-\u003edev);\n6050:\t\n6051:\t\tbp = netdev_priv(netdev);\n6052:\t\tbp-\u003epdev = pdev;\n6053:\t\tbp-\u003enetdev = netdev;\n6054:\t\tbp-\u003eregs = mem;\n6055:\t\tbp-\u003enative_io = native_io;\n6056:\t\tif (native_io) {\n6057:\t\t\tbp-\u003emacb_reg_readl = hw_readl_native;\n6058:\t\t\tbp-\u003emacb_reg_writel = hw_writel_native;\n6059:\t\t} else {\n6060:\t\t\tbp-\u003emacb_reg_readl = hw_readl;\n6061:\t\t\tbp-\u003emacb_reg_writel = hw_writel;\n6062:\t\t}\n6063:\t\tbp-\u003enum_queues = num_queues;\n6064:\t\tbp-\u003emax_num_queues = num_queues;\n6065:\t\tbp-\u003edma_burst_length = macb_config-\u003edma_burst_length;\n6066:\t\tbp-\u003epclk = pclk;\n6067:\t\tbp-\u003ehclk = hclk;\n6068:\t\tbp-\u003etx_clk = tx_clk;\n6069:\t\tbp-\u003erx_clk = rx_clk;\n6070:\t\tbp-\u003etsu_clk = tsu_clk;\n6071:\t\tbp-\u003ejumbo_max_len = macb_config-\u003ejumbo_max_len;\n6072:\t\n6073:\t\tif (!hw_is_gem(bp-\u003eregs, bp-\u003enative_io))\n6074:\t\t\tbp-\u003emax_tx_length = MACB_MAX_TX_LEN;\n6075:\t\telse if (macb_config-\u003emax_tx_length)\n6076:\t\t\tbp-\u003emax_tx_length = macb_config-\u003emax_tx_length;\n6077:\t\telse\n"
} |
| 15/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25197 output: 23 thoughts: 632 Thoughts: **Analyzing the MACB Driver for Emulation Feasibility** Okay, let's break this down. First, I see `macb_main.c` is clearly a platform driver. That's straightforward enough: the code snippet confirms it with the `platform_driver` structure. Then, we have `macb_pci.c`, which wraps this functionality for a specific PCI ID: `0x17cd:0xe007`. The critical question is, can I instantiate either of these within a standard QEMU environment, or even on Google Compute Engine x86_64? My first instinct is to check QEMU's emulation capabilities. Let's see if it emulates that specific PCI ID (`0x17cd:0xe007`), or anything related to "macb" or "cdns" ethernet controllers. Diving into the QEMU source within `hw/net/`, I see various network devices: e1000, igb, virtio-net-pci, etc., and most interestingly, `cadence_gem.c`. However, this is for a "cdns.gem" type sysbus device which is exclusively used on ARM boards like Zynq, ZynqMP, and Versal. There's no Cadence GEM PCI device in QEMU, which is a major red flag. On x86_64, there's no Device Tree or Open Firmware support for these, since x86 doesn't generally use that kind of platform configuration. Now, a slightly different angle: could Syzkaller be used to instantiate this on x86_64? The answer is no! Syzkaller cannot instantiate random platform devices which require specific resources like MMIO memory and clocks. The `macb_probe` function itself requires MMIO registers and clocks through things like `clk_get`, and will fail on x86_64 because the hardware does not exist and it will fail the `hw_is_gem(bp->regs, ...)` check when trying to read hardware registers. Even if I could somehow create a platform device via sysfs (which the kernel generally doesn't allow for arbitrary resource-requiring platform devices), I'd still hit that hardware dependency. The question then becomes could USB or anything else emulate a MACB? No, the MACB is specifically a SoC Ethernet MAC, either Cadence MACB or GEM. There's no path to abstraction here. The next thing I must investigate is whether there is any mock or dummy driver that might use MACB to simulate the driver functionality. Let's grep the kernel tree for `macb` and see if anything else touches this. |
| 16/2 | 2026/10/17 02:34 | tool | grepper |
0mArgs:{
"Expression": "gem_sram_distribute_segments"
}Results: {
"Output": "drivers/net/ethernet/cadence/macb.h=1522=struct macb_queue_enst_config {\n--\ndrivers/net/ethernet/cadence/macb.h-1527-\ndrivers/net/ethernet/cadence/macb.h:1528:u32 gem_sram_distribute_segments(unsigned int num_queues,\ndrivers/net/ethernet/cadence/macb.h-1529-\t\t\t\t unsigned int num_segments);\n--\ndrivers/net/ethernet/cadence/macb_kunit.c=10=static void macb_sram_segments_test(struct kunit *test)\n--\ndrivers/net/ethernet/cadence/macb_kunit.c-12-\tconst struct macb_sram_segments_case *p = test-\u003eparam_value;\ndrivers/net/ethernet/cadence/macb_kunit.c:13:\tu32 val = gem_sram_distribute_segments(p-\u003enum_queues, p-\u003enum_segments);\ndrivers/net/ethernet/cadence/macb_kunit.c-14-\tunsigned int i, sum_segments = 0, max_assigned_segments;\n--\ndrivers/net/ethernet/cadence/macb_kunit.c=49=static void macb_sram_segments_case_desc(struct macb_sram_segments_case *t,\n--\ndrivers/net/ethernet/cadence/macb_kunit.c-51-{\ndrivers/net/ethernet/cadence/macb_kunit.c:52:\tu32 val = gem_sram_distribute_segments(t-\u003enum_queues, t-\u003enum_segments);\ndrivers/net/ethernet/cadence/macb_kunit.c-53-\n--\ndrivers/net/ethernet/cadence/macb_main.c=3134=static void macb_init_hw(struct macb *bp)\n--\ndrivers/net/ethernet/cadence/macb_main.c-3174-\t\t\t\t\t gem_readl(bp, DCFG6));\ndrivers/net/ethernet/cadence/macb_main.c:3175:\t\tval = gem_sram_distribute_segments(bp-\u003enum_queues,\ndrivers/net/ethernet/cadence/macb_main.c-3176-\t\t\t\t\t\t num_segments);\n--\ndrivers/net/ethernet/cadence/macb_utils.c-25- */\ndrivers/net/ethernet/cadence/macb_utils.c:26:u32 gem_sram_distribute_segments(unsigned int num_queues,\ndrivers/net/ethernet/cadence/macb_utils.c-27-\t\t\t\t unsigned int num_segments)\n"
} |
| 17/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27130 output: 18 thoughts: 24 Thoughts: Okay, here's my summary, tailored for an expert audience, as if I'm thinking these things myself: **Investigating Potential MACB Driver Dependencies** Alright, time to get to work. First things first, I need to understand the scope of the `macb` driver within the system and see what might be relying on it. Let's start with a thorough check. Specifically, I'll be sifting through the codebase outside of the `drivers/net/ethernet/cadence/` directory. The goal is to identify if anything *external* is referencing `macb`. This will allow me to assess the potential impact of any changes or removals to the driver, and ensure compatibility. The cross-referencing I undertake should bring to light all dependent aspects, so I can ensure I'm not overlooking a hidden dependency, potential build failures or unexpected behaviour. |
| 18/2 | 2026/10/17 02:34 | tool | grepper |
0mArgs:{
"Expression": "\\\u003cmacb_"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 2695 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (11 files in total):\narch/arm/boot/dts/microchip/at91rm9200.dtsi:2\narch/arm/boot/dts/microchip/at91sam9260.dtsi:3\narch/arm/boot/dts/microchip/at91sam9263.dtsi:2\narch/arm/boot/dts/microchip/at91sam9g45.dtsi:2\ndrivers/net/ethernet/cadence/Kconfig:1\ndrivers/net/ethernet/cadence/Makefile:5\ndrivers/net/ethernet/cadence/macb.h:61\ndrivers/net/ethernet/cadence/macb_kunit.c:14\ndrivers/net/ethernet/cadence/macb_main.c:722\ndrivers/net/ethernet/cadence/macb_pci.c:9\ndrivers/net/ethernet/cadence/macb_ptp.c:21\n\narch/arm/boot/dts/microchip/at91rm9200.dtsi=344=\t\t\t\tmacb {\narch/arm/boot/dts/microchip/at91rm9200.dtsi:345:\t\t\t\t\tpinctrl_macb_rmii: macb_rmii-0 {\narch/arm/boot/dts/microchip/at91rm9200.dtsi-346-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91rm9200.dtsi=355=\t\t\t\t\t\t\t AT91_PIOA 15 AT91_PERIPH_A AT91_PINCTRL_NONE\t/* PA15 periph A */\n--\narch/arm/boot/dts/microchip/at91rm9200.dtsi-358-\narch/arm/boot/dts/microchip/at91rm9200.dtsi:359:\t\t\t\t\tpinctrl_macb_rmii_mii: macb_rmii_mii-0 {\narch/arm/boot/dts/microchip/at91rm9200.dtsi-360-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9260.dtsi=308=\t\t\t\tmacb {\narch/arm/boot/dts/microchip/at91sam9260.dtsi:309:\t\t\t\t\tpinctrl_macb_rmii: macb_rmii-0 {\narch/arm/boot/dts/microchip/at91sam9260.dtsi-310-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9260.dtsi=319=\t\t\t\t\t\t\t AT91_PIOA 20 AT91_PERIPH_A AT91_PINCTRL_NONE\t/* PA20 periph A */\n--\narch/arm/boot/dts/microchip/at91sam9260.dtsi-322-\narch/arm/boot/dts/microchip/at91sam9260.dtsi:323:\t\t\t\t\tpinctrl_macb_rmii_mii: macb_rmii_mii-0 {\narch/arm/boot/dts/microchip/at91sam9260.dtsi-324-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9260.dtsi=331=\t\t\t\t\t\t\t AT91_PIOA 28 AT91_PERIPH_B AT91_PINCTRL_NONE\t/* PA28 periph B */\n--\narch/arm/boot/dts/microchip/at91sam9260.dtsi-334-\narch/arm/boot/dts/microchip/at91sam9260.dtsi:335:\t\t\t\t\tpinctrl_macb_rmii_mii_alt: macb_rmii_mii-1 {\narch/arm/boot/dts/microchip/at91sam9260.dtsi-336-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9263.dtsi=257=\t\t\t\tmacb {\narch/arm/boot/dts/microchip/at91sam9263.dtsi:258:\t\t\t\t\tpinctrl_macb_rmii: macb_rmii-0 {\narch/arm/boot/dts/microchip/at91sam9263.dtsi-259-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9263.dtsi=268=\t\t\t\t\t\t\t AT91_PIOE 29 AT91_PERIPH_A AT91_PINCTRL_NONE\t/* PE29 periph A */\n--\narch/arm/boot/dts/microchip/at91sam9263.dtsi-271-\narch/arm/boot/dts/microchip/at91sam9263.dtsi:272:\t\t\t\t\tpinctrl_macb_rmii_mii: macb_rmii_mii-0 {\narch/arm/boot/dts/microchip/at91sam9263.dtsi-273-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9g45.dtsi=383=\t\t\t\tmacb {\narch/arm/boot/dts/microchip/at91sam9g45.dtsi:384:\t\t\t\t\tpinctrl_macb_rmii: macb_rmii-0 {\narch/arm/boot/dts/microchip/at91sam9g45.dtsi-385-\t\t\t\t\t\tatmel,pins =\n--\narch/arm/boot/dts/microchip/at91sam9g45.dtsi=394=\t\t\t\t\t\t\t AT91_PIOA 18 AT91_PERIPH_A AT91_PINCTRL_NONE\t/* PA18 periph A */\n--\narch/arm/boot/dts/microchip/at91sam9g45.dtsi-397-\narch/arm/boot/dts/microchip/at91sam9g45.dtsi:398:\t\t\t\t\tpinctrl_macb_rmii_mii: macb_rmii_mii-0 {\narch/arm/boot/dts/microchip/at91sam9g45.dtsi-399-\t\t\t\t\t\tatmel,pins =\n--\ndrivers/net/ethernet/cadence/Kconfig=45=config MACB_PCI\n--\ndrivers/net/ethernet/cadence/Kconfig-51-\t To compile this driver as a module, choose M here: the module\ndrivers/net/ethernet/cadence/Kconfig:52:\t will be called macb_pci.\ndrivers/net/ethernet/cadence/Kconfig-53-\n--\ndrivers/net/ethernet/cadence/Makefile-4-#\ndrivers/net/ethernet/cadence/Makefile:5:macb-y\t:= macb_main.o macb_utils.o\ndrivers/net/ethernet/cadence/Makefile-6-\ndrivers/net/ethernet/cadence/Makefile=7=ifeq ($(CONFIG_MACB_USE_HWSTAMP),y)\ndrivers/net/ethernet/cadence/Makefile:8:macb-y\t+= macb_ptp.o\ndrivers/net/ethernet/cadence/Makefile-9-endif\n--\ndrivers/net/ethernet/cadence/Makefile=11=obj-$(CONFIG_MACB) += macb.o\ndrivers/net/ethernet/cadence/Makefile:12:obj-$(CONFIG_MACB_PCI) += macb_pci.o\ndrivers/net/ethernet/cadence/Makefile-13-\ndrivers/net/ethernet/cadence/Makefile:14:obj-$(CONFIG_MACB_KUNIT_TEST) += macb_test.o\ndrivers/net/ethernet/cadence/Makefile:15:macb_test-y := macb_kunit.o macb_utils.o\n--\ndrivers/net/ethernet/cadence/macb.h-834-/* Register access macros */\ndrivers/net/ethernet/cadence/macb.h:835:#define macb_readl(port, reg)\t\t(port)-\u003emacb_reg_readl((port), MACB_##reg)\ndrivers/net/ethernet/cadence/macb.h:836:#define macb_writel(port, reg, value)\t(port)-\u003emacb_reg_writel((port), MACB_##reg, (value))\ndrivers/net/ethernet/cadence/macb.h:837:#define gem_readl(port, reg)\t\t(port)-\u003emacb_reg_readl((port), GEM_##reg)\ndrivers/net/ethernet/cadence/macb.h:838:#define gem_writel(port, reg, value)\t(port)-\u003emacb_reg_writel((port), GEM_##reg, (value))\ndrivers/net/ethernet/cadence/macb.h:839:#define queue_readl(queue, reg)\t\t(queue)-\u003ebp-\u003emacb_reg_readl((queue)-\u003ebp, (queue)-\u003ereg)\ndrivers/net/ethernet/cadence/macb.h:840:#define queue_writel(queue, reg, value)\t(queue)-\u003ebp-\u003emacb_reg_writel((queue)-\u003ebp, (queue)-\u003ereg, (value))\ndrivers/net/ethernet/cadence/macb.h:841:#define gem_readl_n(port, reg, idx)\t\t(port)-\u003emacb_reg_readl((port), GEM_##reg + idx * 4)\ndrivers/net/ethernet/cadence/macb.h:842:#define gem_writel_n(port, reg, idx, value)\t(port)-\u003emacb_reg_writel((port), GEM_##reg + idx * 4, (value))\ndrivers/net/ethernet/cadence/macb.h-843-\n--\ndrivers/net/ethernet/cadence/macb.h-845- * register dependent on whether the device is a GEM or a MACB. For registers\ndrivers/net/ethernet/cadence/macb.h:846: * and bitfields that are common across both devices, use macb_{read,write}l\ndrivers/net/ethernet/cadence/macb.h-847- * to avoid the cost of the conditional.\ndrivers/net/ethernet/cadence/macb.h-848- */\ndrivers/net/ethernet/cadence/macb.h:849:#define macb_or_gem_writel(__bp, __reg, __value) \\\ndrivers/net/ethernet/cadence/macb.h-850-\t({ \\\ndrivers/net/ethernet/cadence/macb.h:851:\t\tif (macb_is_gem((__bp))) \\\ndrivers/net/ethernet/cadence/macb.h-852-\t\t\tgem_writel((__bp), __reg, __value); \\\ndrivers/net/ethernet/cadence/macb.h-853-\t\telse \\\ndrivers/net/ethernet/cadence/macb.h:854:\t\t\tmacb_writel((__bp), __reg, __value); \\\ndrivers/net/ethernet/cadence/macb.h-855-\t})\ndrivers/net/ethernet/cadence/macb.h-856-\ndrivers/net/ethernet/cadence/macb.h:857:#define macb_or_gem_readl(__bp, __reg) \\\ndrivers/net/ethernet/cadence/macb.h-858-\t({ \\\ndrivers/net/ethernet/cadence/macb.h-859-\t\tu32 __v; \\\ndrivers/net/ethernet/cadence/macb.h:860:\t\tif (macb_is_gem((__bp))) \\\ndrivers/net/ethernet/cadence/macb.h-861-\t\t\t__v = gem_readl((__bp), __reg); \\\ndrivers/net/ethernet/cadence/macb.h-862-\t\telse \\\ndrivers/net/ethernet/cadence/macb.h:863:\t\t\t__v = macb_readl((__bp), __reg); \\\ndrivers/net/ethernet/cadence/macb.h-864-\t\t__v; \\\n--\ndrivers/net/ethernet/cadence/macb.h-866-\ndrivers/net/ethernet/cadence/macb.h:867:#define MACB_READ_NSR(bp)\tmacb_readl(bp, NSR)\ndrivers/net/ethernet/cadence/macb.h-868-\ndrivers/net/ethernet/cadence/macb.h:869:/* struct macb_dma_desc - Hardware DMA descriptor\ndrivers/net/ethernet/cadence/macb.h-870- * @addr: DMA address of data buffer\n--\ndrivers/net/ethernet/cadence/macb.h-872- */\ndrivers/net/ethernet/cadence/macb.h:873:struct macb_dma_desc {\ndrivers/net/ethernet/cadence/macb.h-874-\tu32\taddr;\n--\ndrivers/net/ethernet/cadence/macb.h-877-\ndrivers/net/ethernet/cadence/macb.h:878:struct macb_dma_desc_64 {\ndrivers/net/ethernet/cadence/macb.h-879-\tu32 addrh;\n--\ndrivers/net/ethernet/cadence/macb.h-882-\ndrivers/net/ethernet/cadence/macb.h:883:struct macb_dma_desc_ptp {\ndrivers/net/ethernet/cadence/macb.h-884-\tu32\tts_1;\n--\ndrivers/net/ethernet/cadence/macb.h-979-\ndrivers/net/ethernet/cadence/macb.h:980:/* struct macb_tx_skb - data about an skb which is being transmitted\ndrivers/net/ethernet/cadence/macb.h-981- * @skb: skb currently being transmitted, only set for the last buffer\n--\ndrivers/net/ethernet/cadence/macb.h-989- */\ndrivers/net/ethernet/cadence/macb.h:990:struct macb_tx_skb {\ndrivers/net/ethernet/cadence/macb.h-991-\tstruct sk_buff\t\t*skb;\n--\ndrivers/net/ethernet/cadence/macb.h-1000- */\ndrivers/net/ethernet/cadence/macb.h:1001:struct macb_stats {\ndrivers/net/ethernet/cadence/macb.h-1002-\tu64\trx_pause_frames;\n--\ndrivers/net/ethernet/cadence/macb.h=1208=struct macb;\ndrivers/net/ethernet/cadence/macb.h:1209:struct macb_queue;\ndrivers/net/ethernet/cadence/macb.h-1210-\ndrivers/net/ethernet/cadence/macb.h:1211:struct macb_or_gem_ops {\ndrivers/net/ethernet/cadence/macb.h-1212-\tint\t(*mog_alloc_rx_buffers)(struct macb *bp);\n--\ndrivers/net/ethernet/cadence/macb.h-1214-\tint\t(*mog_init_rings)(struct macb *bp);\ndrivers/net/ethernet/cadence/macb.h:1215:\tint\t(*mog_rx)(struct macb_queue *queue, struct napi_struct *napi,\ndrivers/net/ethernet/cadence/macb.h-1216-\t\t\t int budget);\n--\ndrivers/net/ethernet/cadence/macb.h-1219-/* MACB-PTP interface: adapt to platform needs. */\ndrivers/net/ethernet/cadence/macb.h:1220:struct macb_ptp_info {\ndrivers/net/ethernet/cadence/macb.h-1221-\tvoid (*ptp_init)(struct net_device *netdev);\n--\ndrivers/net/ethernet/cadence/macb.h-1233-\ndrivers/net/ethernet/cadence/macb.h:1234:struct macb_pm_data {\ndrivers/net/ethernet/cadence/macb.h-1235-\tu32 scrt2;\n--\ndrivers/net/ethernet/cadence/macb.h-1238-\ndrivers/net/ethernet/cadence/macb.h:1239:struct macb_usrio_config {\ndrivers/net/ethernet/cadence/macb.h-1240-\tu32 mii;\n--\ndrivers/net/ethernet/cadence/macb.h-1249-\ndrivers/net/ethernet/cadence/macb.h:1250:struct macb_config {\ndrivers/net/ethernet/cadence/macb.h-1251-\tu32\t\t\tcaps;\n--\ndrivers/net/ethernet/cadence/macb.h-1258-\tint\tjumbo_max_len;\ndrivers/net/ethernet/cadence/macb.h:1259:\tconst struct macb_usrio_config *usrio;\ndrivers/net/ethernet/cadence/macb.h-1260-};\n--\ndrivers/net/ethernet/cadence/macb.h=1262=struct tsu_incr {\n--\ndrivers/net/ethernet/cadence/macb.h-1266-\ndrivers/net/ethernet/cadence/macb.h:1267:struct macb_queue {\ndrivers/net/ethernet/cadence/macb.h-1268-\tstruct macb\t\t*bp;\n--\ndrivers/net/ethernet/cadence/macb.h-1286-\tunsigned int\t\ttx_head, tx_tail;\ndrivers/net/ethernet/cadence/macb.h:1287:\tstruct macb_dma_desc\t*tx_ring;\ndrivers/net/ethernet/cadence/macb.h:1288:\tstruct macb_tx_skb\t*tx_skb;\ndrivers/net/ethernet/cadence/macb.h-1289-\tdma_addr_t\t\ttx_ring_dma;\n--\ndrivers/net/ethernet/cadence/macb.h-1297-\tunsigned int\t\trx_prepared_head;\ndrivers/net/ethernet/cadence/macb.h:1298:\tstruct macb_dma_desc\t*rx_ring;\ndrivers/net/ethernet/cadence/macb.h-1299-\tstruct sk_buff\t\t**rx_skbuff;\n--\ndrivers/net/ethernet/cadence/macb.h=1315=struct macb {\n--\ndrivers/net/ethernet/cadence/macb.h-1319-\t/* hardware IO accessors */\ndrivers/net/ethernet/cadence/macb.h:1320:\tu32\t(*macb_reg_readl)(struct macb *bp, int offset);\ndrivers/net/ethernet/cadence/macb.h:1321:\tvoid\t(*macb_reg_writel)(struct macb *bp, int offset, u32 value);\ndrivers/net/ethernet/cadence/macb.h-1322-\ndrivers/net/ethernet/cadence/macb.h:1323:\tstruct macb_dma_desc\t*rx_ring_tieoff;\ndrivers/net/ethernet/cadence/macb.h-1324-\tdma_addr_t\t\trx_ring_tieoff_dma;\n--\ndrivers/net/ethernet/cadence/macb.h-1333-\tu32\t\t\ttaprio_gated_queues;\ndrivers/net/ethernet/cadence/macb.h:1334:\tstruct macb_queue\tqueues[MACB_MAX_QUEUES];\ndrivers/net/ethernet/cadence/macb.h-1335-\n--\ndrivers/net/ethernet/cadence/macb.h-1346-\tunion {\ndrivers/net/ethernet/cadence/macb.h:1347:\t\tstruct macb_stats\tmacb;\ndrivers/net/ethernet/cadence/macb.h-1348-\t\tstruct gem_stats\tgem;\n--\ndrivers/net/ethernet/cadence/macb.h-1350-\ndrivers/net/ethernet/cadence/macb.h:1351:\tstruct macb_or_gem_ops\tmacbgem_ops;\ndrivers/net/ethernet/cadence/macb.h-1352-\n--\ndrivers/net/ethernet/cadence/macb.h-1364-\t/* AT91RM9200 transmit queue (1 on wire + 1 queued) */\ndrivers/net/ethernet/cadence/macb.h:1365:\tstruct macb_tx_skb\trm9200_txq[2];\ndrivers/net/ethernet/cadence/macb.h-1366-\tunsigned int\t\tmax_tx_length;\n--\ndrivers/net/ethernet/cadence/macb.h-1378-\ndrivers/net/ethernet/cadence/macb.h:1379:\tstruct macb_ptp_info\t*ptp_info;\t/* macb-ptp interface */\ndrivers/net/ethernet/cadence/macb.h-1380-\n\n"
} |
| 19/2 | 2026/10/17 02:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32955 output: 176 thoughts: 1808 Thoughts: **WorthFuzzing Decision: Structurally Unreachable Hardware - Cadence MACB/GEM on amd64** Okay, let's break this down meticulously. The instructions are clear: if the modified code falls into the "structurally unreachable hardware" category, we return `WorthFuzzing=false`. The target architecture is amd64. My task is to determine if the Cadence MACB/GEM driver, and any related code, is reachable on amd64 in a standard fuzzer environment. First, I need to understand what the Cadence MACB/GEM is. It's an Ethernet MAC, typically found on ARM-based SoCs like Atmel, Microchip, Xilinx Zynq/Versal, and Mobileye. Crucially, I see no indication of this hardware existing on standard x86/amd64 systems, or being emulated within QEMU's `qemu-system-x86_64`. QEMU *does* emulate it, but only for specific ARM and AArch64 boards. This is a critical point. I examined `macb_pci.c`, which wraps the MACB as a PCI device. The PCI device ID is `0x17cd:0xe007`. Does standard QEMU emulate this particular PCI device? No. Does Google Compute Engine (GCE) offer this hardware in its virtualized instances? No, GCE uses standard virtualization methods. Given this, on amd64, the Cadence MACB/GEM hardware is fundamentally *unreachable*. It requires specific physical hardware or, in the case of emulation, ARM-based platforms or a specific PCI development board not emulated in standard QEMU. Then, there's `macb_kunit.c` with a KUnit test. KUnit tests are kernel self-tests, and syzkaller *doesn't* fuzz KUnit tests. Syzkaller is focused on syscalls against the running kernel. The key document explicitly states that we only fuzz code that is *reachable* in standard virtualized environments. KUnit tests are not. The fuzzing goal is to find crash bugs and triggered assertions. I'm now double-checking for a backdoor way to execute `macb_main.c` or `macb_utils.c` on amd64. Could `netdev`, `tun`, `tap`, or `virtio` somehow call the code like `gem_sram_distribute_segments` or any function in `macb_main.c`? No. The code in `macb_main.c` registers the platform driver `macb_driver` and `macb_pci.c` registers `macb_pci_driver`. It registers the platform driver and PCI driver. All functions within `macb_main.c` depend on the MACB hardware successfully probing - which will never occur on amd64 due to the hardware's absence. Therefore, the code is structurally unreachable. The modified code falls squarely within the "structurally unreachable hardware" negative criterion. It is a vendor-specific NIC driver for ARM/SoC platforms that requires hardware not present in the standard virtualized environments used by fuzzers. In conclusion: `WorthFuzzing=false`. My reasoning includes clear evidence of the hardware's absence in the fuzzing environment, and that KUnit tests are self-tests and not fuzzed by syzkaller. The code paths are inaccessible. The decision is now backed up by detailed technical analysis and verification against the defined criteria. |
| 20/2 | 2026/10/17 02:35 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The changes modify the Cadence MACB/GEM Ethernet driver (drivers/net/ethernet/cadence/), adding KUnit tests, TXQ segment allocation logic, and channel configuration support via ethtool. On the amd64 target architecture, Cadence MACB/GEM is structurally unreachable because it targets embedded SoC platforms (Microchip AT91/SAMA, Xilinx Zynq/Versal, Mobileye EyeQ5) and specialized hardware not emulated in standard QEMU x86_64 or GCE virtualized environments. KUnit unit tests are self-tests not fuzzed by syzkaller. Therefore, the modified code cannot be reached during fuzzing.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The changes modify the Cadence MACB/GEM Ethernet driver (drivers/net/ethernet/cadence/), adding KUnit tests, TXQ segment allocation logic, and channel configuration support via ethtool. On the amd64 target architecture, Cadence MACB/GEM is structurally unreachable because it targets embedded SoC platforms (Microchip AT91/SAMA, Xilinx Zynq/Versal, Mobileye EyeQ5) and specialized hardware not emulated in standard QEMU x86_64 or GCE virtualized environments. KUnit unit tests are self-tests not fuzzed by syzkaller. Therefore, the modified code cannot be reached during fuzzing.",
"WorthFuzzing": false
} |
| 21/1 | 2026/10/17 02:35 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|