• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2023 Google LLC
4  * Author: Mostafa Saleh <smostafa@google.com>
5  */
6 
7 #ifndef __KVM_DEVICE_H
8 #define __KVM_DEVICE_H
9 
10 #include <asm/kvm_host.h>
11 
12 /*
13  * @base: physical address of MMIO resource.
14  * @size: size of resource in bytes.
15  */
16 struct pkvm_dev_resource {
17 	u64 base;
18 	u64 size;
19 };
20 
21 /*
22  * @id: hypervisor ID of the IOMMU as defined by the driver.
23  * @endpoint: endpoint ID of the device.
24  */
25 struct pkvm_dev_iommu {
26 	u64 id;
27 	u64 endpoint;
28 };
29 
30 #define PKVM_DEVICE_MAX_RESOURCE	32
31 #define PKVM_DEVICE_MAX_IOMMU		32
32 
33 struct pkvm_device {
34 	struct pkvm_dev_resource resources[PKVM_DEVICE_MAX_RESOURCE];
35 	struct pkvm_dev_iommu iommus[PKVM_DEVICE_MAX_IOMMU];
36 	u32 nr_resources;
37 	u32 nr_iommus;
38 	u32 group_id;
39 	void *ctxt; /* Current context of the device*/
40 	unsigned short refcount;
41 	int (*reset_handler)(void *cookie, bool host_to_guest);
42 	void *cookie; /* cookie from drivers. */
43 };
44 
45 #endif /* #ifndef __KVM_DEVICE_H */
46