Skip to content

Commit 9d02932

Browse files
JasonChenCJjren1
authored andcommitted
ptdev: change the ptdev_list from per-vm to global
this patch is a preparation for changing ptdev remapping entry from virtual to physical based, it changes the ptdev_list from per-vm to global, as entries based on physical mode are global resource. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent 9519916 commit 9d02932

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

hypervisor/arch/x86/assign.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
/* SOFTIRQ_DEV_ASSIGN list for all CPUs */
4242
static struct list_head softirq_dev_entry_list;
43+
/* passthrough device link */
44+
static struct list_head ptdev_list;
4345

4446
/*
4547
* entry could both be in ptdev_list and softirq_dev_entry_list.
@@ -98,10 +100,10 @@ _get_remapping_entry(struct vm *vm, uint32_t id)
98100
struct ptdev_remapping_info *entry;
99101
struct list_head *pos;
100102

101-
list_for_each(pos, &vm->ptdev_list) {
103+
list_for_each(pos, &ptdev_list) {
102104
entry = list_entry(pos, struct ptdev_remapping_info,
103105
entry_node);
104-
if (entry_id(entry) == id)
106+
if (entry_id(entry) == id && entry->vm == vm)
105107
return entry;
106108
}
107109

@@ -213,7 +215,7 @@ alloc_entry(struct vm *vm, enum ptdev_intr_type type)
213215
entry->type = type;
214216
entry->vm = vm;
215217
atomic_clear_int(&entry->active, ACTIVE_FLAG);
216-
list_add(&entry->entry_node, &vm->ptdev_list);
218+
list_add(&entry->entry_node, &ptdev_list);
217219

218220
return entry;
219221
}
@@ -245,10 +247,11 @@ release_all_entry(struct vm *vm)
245247
struct ptdev_remapping_info *entry;
246248
struct list_head *pos, *tmp;
247249

248-
list_for_each_safe(pos, tmp, &vm->ptdev_list) {
250+
list_for_each_safe(pos, tmp, &ptdev_list) {
249251
entry = list_entry(pos, struct ptdev_remapping_info,
250252
entry_node);
251-
release_entry(entry);
253+
if (entry->vm == vm)
254+
release_entry(entry);
252255
}
253256
}
254257

@@ -295,13 +298,14 @@ static void check_deactive_pic_intx(struct vm *vm, uint8_t phys_pin)
295298
return;
296299

297300
spinlock_obtain(&vm->ptdev_lock);
298-
list_for_each(pos, &vm->ptdev_list) {
301+
list_for_each(pos, &ptdev_list) {
299302
entry = list_entry(pos, struct ptdev_remapping_info,
300303
entry_node);
301304
if (entry->type == PTDEV_INTR_INTX &&
302305
entry->intx.vpin_src == PTDEV_VPIN_PIC &&
303306
entry->intx.phys_pin == phys_pin &&
304-
entry_is_active(entry)) {
307+
entry_is_active(entry) &&
308+
entry->vm == vm) {
305309
GSI_MASK_IRQ(pin_to_irq(phys_pin));
306310
ptdev_deactivate_entry(entry);
307311
dev_dbg(ACRN_DBG_IRQ,
@@ -855,13 +859,13 @@ void ptdev_init(void)
855859
if (get_cpu_id() > 0)
856860
return;
857861

862+
INIT_LIST_HEAD(&ptdev_list);
858863
INIT_LIST_HEAD(&softirq_dev_entry_list);
859864
spinlock_init(&softirq_dev_lock);
860865
}
861866

862867
void ptdev_vm_init(struct vm *vm)
863868
{
864-
INIT_LIST_HEAD(&vm->ptdev_list);
865869
spinlock_init(&vm->ptdev_lock);
866870
}
867871

@@ -987,7 +991,7 @@ int get_ptdev_info(char *str, int str_max)
987991
list_for_each(vm_pos, &vm_list) {
988992
vm = list_entry(vm_pos, struct vm, list);
989993
spinlock_obtain(&vm->ptdev_lock);
990-
list_for_each(pos, &vm->ptdev_list) {
994+
list_for_each(pos, &ptdev_list) {
991995
entry = list_entry(pos, struct ptdev_remapping_info,
992996
entry_node);
993997
if (entry_is_active(entry)) {

hypervisor/include/arch/x86/guest/vm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ struct vm {
174174
struct _vm_virtual_device_node *tail;
175175
} virtual_device_list;
176176

177-
/* passthrough device link */
178-
struct list_head ptdev_list;
179177
spinlock_t ptdev_lock;
180178

181179
unsigned char GUID[16];

0 commit comments

Comments
 (0)