cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

bootmem_info.h (1635B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef __LINUX_BOOTMEM_INFO_H
      3#define __LINUX_BOOTMEM_INFO_H
      4
      5#include <linux/mm.h>
      6
      7/*
      8 * Types for free bootmem stored in page->lru.next. These have to be in
      9 * some random range in unsigned long space for debugging purposes.
     10 */
     11enum {
     12	MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE = 12,
     13	SECTION_INFO = MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE,
     14	MIX_SECTION_INFO,
     15	NODE_INFO,
     16	MEMORY_HOTPLUG_MAX_BOOTMEM_TYPE = NODE_INFO,
     17};
     18
     19#ifdef CONFIG_HAVE_BOOTMEM_INFO_NODE
     20void __init register_page_bootmem_info_node(struct pglist_data *pgdat);
     21
     22void get_page_bootmem(unsigned long info, struct page *page,
     23		      unsigned long type);
     24void put_page_bootmem(struct page *page);
     25
     26/*
     27 * Any memory allocated via the memblock allocator and not via the
     28 * buddy will be marked reserved already in the memmap. For those
     29 * pages, we can call this function to free it to buddy allocator.
     30 */
     31static inline void free_bootmem_page(struct page *page)
     32{
     33	unsigned long magic = page->index;
     34
     35	/*
     36	 * The reserve_bootmem_region sets the reserved flag on bootmem
     37	 * pages.
     38	 */
     39	VM_BUG_ON_PAGE(page_ref_count(page) != 2, page);
     40
     41	if (magic == SECTION_INFO || magic == MIX_SECTION_INFO)
     42		put_page_bootmem(page);
     43	else
     44		VM_BUG_ON_PAGE(1, page);
     45}
     46#else
     47static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)
     48{
     49}
     50
     51static inline void put_page_bootmem(struct page *page)
     52{
     53}
     54
     55static inline void get_page_bootmem(unsigned long info, struct page *page,
     56				    unsigned long type)
     57{
     58}
     59
     60static inline void free_bootmem_page(struct page *page)
     61{
     62	free_reserved_page(page);
     63}
     64#endif
     65
     66#endif /* __LINUX_BOOTMEM_INFO_H */