LCOV - code coverage report
Current view: top level - arch/x86/kernel - resource.c (source / functions) Hit Total Coverage
Test: landlock.info Lines: 0 23 0.0 %
Date: 2021-04-22 12:43:58 Functions: 0 3 0.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : #include <linux/ioport.h>
       3             : #include <asm/e820/api.h>
       4             : 
       5           0 : static void resource_clip(struct resource *res, resource_size_t start,
       6             :                           resource_size_t end)
       7             : {
       8           0 :         resource_size_t low = 0, high = 0;
       9             : 
      10           0 :         if (res->end < start || res->start > end)
      11             :                 return;         /* no conflict */
      12             : 
      13           0 :         if (res->start < start)
      14           0 :                 low = start - res->start;
      15             : 
      16           0 :         if (res->end > end)
      17           0 :                 high = res->end - end;
      18             : 
      19             :         /* Keep the area above or below the conflict, whichever is larger */
      20           0 :         if (low > high)
      21           0 :                 res->end = start - 1;
      22             :         else
      23           0 :                 res->start = end + 1;
      24             : }
      25             : 
      26           0 : static void remove_e820_regions(struct resource *avail)
      27             : {
      28           0 :         int i;
      29           0 :         struct e820_entry *entry;
      30             : 
      31           0 :         for (i = 0; i < e820_table->nr_entries; i++) {
      32           0 :                 entry = &e820_table->entries[i];
      33             : 
      34           0 :                 resource_clip(avail, entry->addr,
      35           0 :                               entry->addr + entry->size - 1);
      36             :         }
      37           0 : }
      38             : 
      39           0 : void arch_remove_reservations(struct resource *avail)
      40             : {
      41             :         /*
      42             :          * Trim out BIOS area (high 2MB) and E820 regions. We do not remove
      43             :          * the low 1MB unconditionally, as this area is needed for some ISA
      44             :          * cards requiring a memory range, e.g. the i82365 PCMCIA controller.
      45             :          */
      46           0 :         if (avail->flags & IORESOURCE_MEM) {
      47           0 :                 resource_clip(avail, BIOS_ROM_BASE, BIOS_ROM_END);
      48             : 
      49           0 :                 remove_e820_regions(avail);
      50             :         }
      51           0 : }

Generated by: LCOV version 1.14