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

set_memory.h (3787B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2#ifndef _ASM_X86_SET_MEMORY_H
      3#define _ASM_X86_SET_MEMORY_H
      4
      5#include <linux/mm.h>
      6#include <asm/page.h>
      7#include <asm-generic/set_memory.h>
      8
      9/*
     10 * The set_memory_* API can be used to change various attributes of a virtual
     11 * address range. The attributes include:
     12 * Cacheability  : UnCached, WriteCombining, WriteThrough, WriteBack
     13 * Executability : eXecutable, NoteXecutable
     14 * Read/Write    : ReadOnly, ReadWrite
     15 * Presence      : NotPresent
     16 * Encryption    : Encrypted, Decrypted
     17 *
     18 * Within a category, the attributes are mutually exclusive.
     19 *
     20 * The implementation of this API will take care of various aspects that
     21 * are associated with changing such attributes, such as:
     22 * - Flushing TLBs
     23 * - Flushing CPU caches
     24 * - Making sure aliases of the memory behind the mapping don't violate
     25 *   coherency rules as defined by the CPU in the system.
     26 *
     27 * What this API does not do:
     28 * - Provide exclusion between various callers - including callers that
     29 *   operation on other mappings of the same physical page
     30 * - Restore default attributes when a page is freed
     31 * - Guarantee that mappings other than the requested one are
     32 *   in any state, other than that these do not violate rules for
     33 *   the CPU you have. Do not depend on any effects on other mappings,
     34 *   CPUs other than the one you have may have more relaxed rules.
     35 * The caller is required to take care of these.
     36 */
     37
     38int __set_memory_prot(unsigned long addr, int numpages, pgprot_t prot);
     39int _set_memory_uc(unsigned long addr, int numpages);
     40int _set_memory_wc(unsigned long addr, int numpages);
     41int _set_memory_wt(unsigned long addr, int numpages);
     42int _set_memory_wb(unsigned long addr, int numpages);
     43int set_memory_uc(unsigned long addr, int numpages);
     44int set_memory_wc(unsigned long addr, int numpages);
     45int set_memory_wb(unsigned long addr, int numpages);
     46int set_memory_np(unsigned long addr, int numpages);
     47int set_memory_4k(unsigned long addr, int numpages);
     48int set_memory_encrypted(unsigned long addr, int numpages);
     49int set_memory_decrypted(unsigned long addr, int numpages);
     50int set_memory_np_noalias(unsigned long addr, int numpages);
     51int set_memory_nonglobal(unsigned long addr, int numpages);
     52int set_memory_global(unsigned long addr, int numpages);
     53
     54int set_pages_array_uc(struct page **pages, int addrinarray);
     55int set_pages_array_wc(struct page **pages, int addrinarray);
     56int set_pages_array_wb(struct page **pages, int addrinarray);
     57
     58/*
     59 * For legacy compatibility with the old APIs, a few functions
     60 * are provided that work on a "struct page".
     61 * These functions operate ONLY on the 1:1 kernel mapping of the
     62 * memory that the struct page represents, and internally just
     63 * call the set_memory_* function. See the description of the
     64 * set_memory_* function for more details on conventions.
     65 *
     66 * These APIs should be considered *deprecated* and are likely going to
     67 * be removed in the future.
     68 * The reason for this is the implicit operation on the 1:1 mapping only,
     69 * making this not a generally useful API.
     70 *
     71 * Specifically, many users of the old APIs had a virtual address,
     72 * called virt_to_page() or vmalloc_to_page() on that address to
     73 * get a struct page* that the old API required.
     74 * To convert these cases, use set_memory_*() on the original
     75 * virtual address, do not use these functions.
     76 */
     77
     78int set_pages_uc(struct page *page, int numpages);
     79int set_pages_wb(struct page *page, int numpages);
     80int set_pages_ro(struct page *page, int numpages);
     81int set_pages_rw(struct page *page, int numpages);
     82
     83int set_direct_map_invalid_noflush(struct page *page);
     84int set_direct_map_default_noflush(struct page *page);
     85bool kernel_page_present(struct page *page);
     86
     87extern int kernel_set_to_readonly;
     88
     89#endif /* _ASM_X86_SET_MEMORY_H */