# Linux Kernel Module Cheat

#### 14.3.3. gem5 graphic mode internals

We cannot use mainline Linux because the gem5 arm Linux kernel patches are required at least to provide the `CONFIG_DRM_VIRT_ENCODER` option.

gem5 emulates the HDLCD ARM Holdings hardware for `arm` and `aarch64`.

The kernel uses HDLCD to implement the DRM interface, the required kernel config options are present at: linux_config/display.

TODO: minimize out the `--custom-config-file`. If we just remove it on `arm`: it does not work with a failing dmesg:

    [    0.066208] [drm] found ARM HDLCD version r0p0
    [    0.066241] hdlcd 2b000000.hdlcd: bound virt-encoder (ops drm_vencoder_ops)
    [    0.066247] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
    [    0.066252] [drm] No driver support for vblank timestamp query.
    [    0.066276] hdlcd 2b000000.hdlcd: Cannot do DMA to address 0x0000000000000000
    [    0.066281] swiotlb: coherent allocation failed for device 2b000000.hdlcd size=8294400
    [    0.066288] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.15.0 #1
    [    0.066293] Hardware name: V2P-AARCH64 (DT)
    [    0.066296] Call trace:
    [    0.066301]  dump_backtrace+0x0/0x1b0
    [    0.066306]  show_stack+0x24/0x30
    [    0.066311]  dump_stack+0xb8/0xf0
    [    0.066316]  swiotlb_alloc_coherent+0x17c/0x190
    [    0.066321]  __dma_alloc+0x68/0x160
    [    0.066325]  drm_gem_cma_create+0x98/0x120
    [    0.066330]  drm_fbdev_cma_create+0x74/0x2e0
    [    0.066335]  __drm_fb_helper_initial_config_and_unlock+0x1d8/0x3a0
    [    0.066341]  drm_fb_helper_initial_config+0x4c/0x58
    [    0.066347]  drm_fbdev_cma_init_with_funcs+0x98/0x148
    [    0.066352]  drm_fbdev_cma_init+0x40/0x50
    [    0.066357]  hdlcd_drm_bind+0x220/0x428
    [    0.066362]  try_to_bring_up_master+0x21c/0x2b8
    [    0.066367]  component_master_add_with_match+0xa8/0xf0
    [    0.066372]  hdlcd_probe+0x60/0x78
    [    0.066377]  platform_drv_probe+0x60/0xc8
    [    0.066382]  driver_probe_device+0x30c/0x478
    [    0.066388]  __driver_attach+0x10c/0x128
    [    0.066393]  bus_for_each_dev+0x70/0xb0
    [    0.066398]  driver_attach+0x30/0x40
    [    0.066402]  bus_add_driver+0x1d0/0x298
    [    0.066408]  driver_register+0x68/0x100
    [    0.066413]  __platform_driver_register+0x54/0x60
    [    0.066418]  hdlcd_platform_driver_init+0x20/0x28
    [    0.066424]  do_one_initcall+0x44/0x130
    [    0.066428]  kernel_init_freeable+0x13c/0x1d8
    [    0.066433]  kernel_init+0x18/0x108
    [    0.066438]  ret_from_fork+0x10/0x1c
    [    0.066444] hdlcd 2b000000.hdlcd: Failed to set initial hw configuration.
    [    0.066470] hdlcd 2b000000.hdlcd: master bind failed: -12
    [    0.066477] hdlcd: probe of 2b000000.hdlcd failed with error -12

So what other options are missing from `gem5_defconfig`? It would be cool to minimize it out to better understand the options.