Skip to contentSkip to conversation

Help on Modifying a Driver on Native Linux

DISCUSSION Richard Akintola 2 participants 3 messages Apr 1, 2025 – Apr 2, 2025

lore
Share & tools
lore
#0 lore raw

I learnt that e1000 didn't work because the driver is included in VM images and not on Linux native, and a variant of e1000 on Linux native is the e1000e driver.

Below are some of the drivers that one could modify on Linux native in order have the "I can modify Linux kernel\n" effect.

Using the e1000e driver

1. vim drivers/net/ethernet/intel/e1000e/netdev.c

2. Find the probe function

static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

{
        struct net_device *netdev;
        struct e1000_adapter *adapter;
        struct e1000_hw *hw;
        const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
        resource_size_t mmio_start, mmio_len;
        resource_size_t flash_start, flash_len;
        static int cards_found;
        u16 aspm_disable_flag = 0;
        u16 eeprom_data = 0;
        u16 eeprom_apme_mask = E1000_EEPROM_APME;
        int bars, i, err;
        s32 ret_val = 0;

        printk(KERN_DEBUG "I can modify the Linux kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

Or you could use the bluetooth driver

1. vim drivers/bluetooth/btusb.c

2. Find the probe function

static int btusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)

{
        struct usb_endpoint_descriptor *ep_desc;
        struct gpio_desc *reset_gpio;
        struct btusb_data *data;
        struct hci_dev *hdev;
        unsigned ifnum_base;
        int i, err, priv_size;

        printk(KERN_DEBUG "I can modify the Linux Kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

I hope this helps.

#1 lore raw

Sent from my iPhone

Quoted 9 lines · Richard Akintola

I learnt that e1000 didn't work because the driver is included in VM images and not on Linux native, and a variant of e1000 on Linux native is the e1000e driver.

Below are some of the drivers that one could modify on Linux native in order have the "I can modify Linux kernel\n" effect.

Super. I will update the tutorial accordingly.

Quoted 50 lines

Using the e1000e driver

1. vim drivers/net/ethernet/intel/e1000e/netdev.c

2. Find the probe function

static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

{
       struct net_device *netdev;
       struct e1000_adapter *adapter;
       struct e1000_hw *hw;
       const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
       resource_size_t mmio_start, mmio_len;
       resource_size_t flash_start, flash_len;
       static int cards_found;
       u16 aspm_disable_flag = 0;
       u16 eeprom_data = 0;
       u16 eeprom_apme_mask = E1000_EEPROM_APME;
       int bars, i, err;
       s32 ret_val = 0;

       printk(KERN_DEBUG "I can modify the Linux kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

Or you could use the bluetooth driver

1. vim drivers/bluetooth/btusb.c

2. Find the probe function

static int btusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)

{
       struct usb_endpoint_descriptor *ep_desc;
       struct gpio_desc *reset_gpio;
       struct btusb_data *data;
       struct hci_dev *hdev;
       unsigned ifnum_base;
       int i, err, priv_size;

       printk(KERN_DEBUG "I can modify the Linux Kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

I hope this helps.

#2 lore raw
In reply to Richard Akintola
Quoted 3 lines · Richard Akintola

I learnt that e1000 didn't work because the driver is included in VM images and not on Linux native, and a variant of e1000 on Linux native is the e1000e driver.

Thanks for the suggested text. You can see it here:

https://kernelnewbies.org/FirstKernelPatch#DriverChange

julia

Quoted 55 lines

Below are some of the drivers that one could modify on Linux native in order have the "I can modify Linux kernel\n" effect.

Using the e1000e driver

1. vim drivers/net/ethernet/intel/e1000e/netdev.c

2. Find the probe function

static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

{
        struct net_device *netdev;
        struct e1000_adapter *adapter;
        struct e1000_hw *hw;
        const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
        resource_size_t mmio_start, mmio_len;
        resource_size_t flash_start, flash_len;
        static int cards_found;
        u16 aspm_disable_flag = 0;
        u16 eeprom_data = 0;
        u16 eeprom_apme_mask = E1000_EEPROM_APME;
        int bars, i, err;
        s32 ret_val = 0;

        printk(KERN_DEBUG "I can modify the Linux kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

Or you could use the bluetooth driver

1. vim drivers/bluetooth/btusb.c

2. Find the probe function

static int btusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)

{
        struct usb_endpoint_descriptor *ep_desc;
        struct gpio_desc *reset_gpio;
        struct btusb_data *data;
        struct hci_dev *hdev;
        unsigned ifnum_base;
        int i, err, priv_size;

        printk(KERN_DEBUG "I can modify the Linux Kernel\n");

3. Save the file and recompile the kernel, you should see the text printed when you run the "dmesg | less" command after rebooting.

I hope this helps.