ANDROID: KVM: arm64: devices: Add initial device definitions

In preparation for supporting device assignment in pKVM, the
hypervisor should be able to authenticate assigned devices by
providing HVCs to the guest to get trusted description about the
device.

To be able to do this the hypervisor should get assignable devices
description at boot when the kernel is still trusted.

Bug: 357781595
Bug: 348382247
Change-Id: I8bf38c253786eb56cbb1368531b2a3dea048ae88
Signed-off-by: Mostafa Saleh <smostafa@google.com>
This commit is contained in:
Mostafa Saleh
2023-08-02 11:19:08 +00:00
parent 510f86993d
commit 2cb178cea5
3 changed files with 51 additions and 1 deletions
+1 -1
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2023 Google LLC
* Author: Mostafa Saleh <smostafa@google.com>
*/
struct pkvm_device *registered_devices;
unsigned long registered_devices_nr;
+42
View File
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2023 Google LLC
* Author: Mostafa Saleh <smostafa@google.com>
*/
#ifndef __KVM_DEVICE_H
#define __KVM_DEVICE_H
#include <asm/kvm_host.h>
/*
* @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 */