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

xen-front-pgdir-shbuf.h (2370B)


      1/* SPDX-License-Identifier: GPL-2.0 OR MIT */
      2
      3/*
      4 * Xen frontend/backend page directory based shared buffer
      5 * helper module.
      6 *
      7 * Copyright (C) 2018 EPAM Systems Inc.
      8 *
      9 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
     10 */
     11
     12#ifndef __XEN_FRONT_PGDIR_SHBUF_H_
     13#define __XEN_FRONT_PGDIR_SHBUF_H_
     14
     15#include <linux/kernel.h>
     16
     17#include <xen/grant_table.h>
     18
     19struct xen_front_pgdir_shbuf_ops;
     20
     21struct xen_front_pgdir_shbuf {
     22	/*
     23	 * Number of references granted for the backend use:
     24	 *
     25	 *  - for frontend allocated/imported buffers this holds the number
     26	 *    of grant references for the page directory and the pages
     27	 *    of the buffer
     28	 *
     29	 *  - for the buffer provided by the backend this only holds the number
     30	 *    of grant references for the page directory itself as grant
     31	 *    references for the buffer will be provided by the backend.
     32	 */
     33	int num_grefs;
     34	grant_ref_t *grefs;
     35	/* Page directory backing storage. */
     36	u8 *directory;
     37
     38	/*
     39	 * Number of pages for the shared buffer itself (excluding the page
     40	 * directory).
     41	 */
     42	int num_pages;
     43	/*
     44	 * Backing storage of the shared buffer: these are the pages being
     45	 * shared.
     46	 */
     47	struct page **pages;
     48
     49	struct xenbus_device *xb_dev;
     50
     51	/* These are the ops used internally depending on be_alloc mode. */
     52	const struct xen_front_pgdir_shbuf_ops *ops;
     53
     54	/* Xen map handles for the buffer allocated by the backend. */
     55	grant_handle_t *backend_map_handles;
     56};
     57
     58struct xen_front_pgdir_shbuf_cfg {
     59	struct xenbus_device *xb_dev;
     60
     61	/* Number of pages of the buffer backing storage. */
     62	int num_pages;
     63	/* Pages of the buffer to be shared. */
     64	struct page **pages;
     65
     66	/*
     67	 * This is allocated outside because there are use-cases when
     68	 * the buffer structure is allocated as a part of a bigger one.
     69	 */
     70	struct xen_front_pgdir_shbuf *pgdir;
     71	/*
     72	 * Mode of grant reference sharing: if set then backend will share
     73	 * grant references to the buffer with the frontend.
     74	 */
     75	int be_alloc;
     76};
     77
     78int xen_front_pgdir_shbuf_alloc(struct xen_front_pgdir_shbuf_cfg *cfg);
     79
     80grant_ref_t
     81xen_front_pgdir_shbuf_get_dir_start(struct xen_front_pgdir_shbuf *buf);
     82
     83int xen_front_pgdir_shbuf_map(struct xen_front_pgdir_shbuf *buf);
     84
     85int xen_front_pgdir_shbuf_unmap(struct xen_front_pgdir_shbuf *buf);
     86
     87void xen_front_pgdir_shbuf_free(struct xen_front_pgdir_shbuf *buf);
     88
     89#endif /* __XEN_FRONT_PGDIR_SHBUF_H_ */