diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index 3ea29d6442ca..c3efa66b672a 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -8,7 +8,7 @@ CFLAGS_switch.nvhe.o += -Wno-override-init hyp-obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \ hyp-main.o hyp-smp.o psci-relay.o alloc.o early_alloc.o page_alloc.o \ cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o ffa.o \ - serial.o alloc_mgt.o iommu/iommu.o power/hvc.o power/scmi.o + serial.o alloc_mgt.o iommu/iommu.o power/hvc.o power/scmi.o device/device.o hyp-obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../fpsimd.o ../hyp-entry.o ../exception.o ../pgtable.o hyp-obj-$(CONFIG_LIST_HARDENED) += list_debug.o diff --git a/arch/arm64/kvm/hyp/nvhe/device/device.c b/arch/arm64/kvm/hyp/nvhe/device/device.c new file mode 100644 index 000000000000..4e8085fb4321 --- /dev/null +++ b/arch/arm64/kvm/hyp/nvhe/device/device.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Google LLC + * Author: Mostafa Saleh + */ + +struct pkvm_device *registered_devices; +unsigned long registered_devices_nr; diff --git a/include/kvm/device.h b/include/kvm/device.h new file mode 100644 index 000000000000..5e53a98d757c --- /dev/null +++ b/include/kvm/device.h @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Google LLC + * Author: Mostafa Saleh + */ + +#ifndef __KVM_DEVICE_H +#define __KVM_DEVICE_H + +#include + +/* + * @base: physical address of MMIO resource. + * @size: size of resource in bytes. + */ +struct pkvm_dev_resource { + u64 base; + u64 size; +}; + +/* + * @id: hypervisor ID of the IOMMU as defined by the driver. + * @endpoint: endpoint ID of the device. + */ +struct pkvm_dev_iommu { + u64 id; + u64 endpoint; +}; + +#define PKVM_DEVICE_MAX_RESOURCE 32 +#define PKVM_DEVICE_MAX_IOMMU 32 + +struct pkvm_device { + struct pkvm_dev_resource resources[PKVM_DEVICE_MAX_RESOURCE]; + struct pkvm_dev_iommu iommus[PKVM_DEVICE_MAX_IOMMU]; + u32 nr_resources; + u32 nr_iommus; + u32 group_id; + void *ctxt; /* Current context of the device*/ +}; + +#endif /* #ifndef __KVM_DEVICE_H */