Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178179844
D62224.1796208385.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
D62224.1796208385.diff
View Options
diff --git a/sys/arm64/arm64/gicv5.c b/sys/arm64/arm64/gicv5.c
--- a/sys/arm64/arm64/gicv5.c
+++ b/sys/arm64/arm64/gicv5.c
@@ -417,7 +417,7 @@
{
uint64_t cfgr;
- cfgr = (ilog2_int(vm_id_count) << IRS_VMT_VM_ID_BITS_SHIFT) &
+ cfgr = (order_base_2(vm_id_count) << IRS_VMT_VM_ID_BITS_SHIFT) &
IRS_VMT_VM_ID_BITS_MASK;
IRS_CFG_WRITE_4(irs, IRS_VMT_CFGR, cfgr);
@@ -702,7 +702,7 @@
idr4 = IRS_CFG_READ_4(irs, IRS_IDR4);
if (idr3 & IRS_IDR3_VMD)
- irs->vmd_size = 1 << ((idr4 & IRS_IDR3_VMD_SZ_MASK) >>
+ irs->vmd_size = 1 << ((idr3 & IRS_IDR3_VMD_SZ_MASK) >>
IRS_IDR3_VMD_SZ_SHIFT);
else
irs->vmd_size = 0;
@@ -725,7 +725,7 @@
}
int
-gicv5_alloc_vm(device_t dev, int nr_vpes)
+gicv5_alloc_vm(device_t dev, int nr_vpes, int *vm_id)
{
struct gicv5_vm_data *vm_data;
struct gicv5_softc *sc;
@@ -754,7 +754,7 @@
vm_data->vpet = contigmalloc(VPETE_SIZE * nr_vpes,
M_DEVBUF, M_ZERO | M_WAITOK, 0, IRS_VMT_BASER_ADDR_LIMIT,
- VPETE_SIZE * ilog2_int(nr_vpes), 0);
+ VPETE_SIZE << order_base_2(nr_vpes), 0);
vm_data->vpete = contigmalloc(irs->vped_size * nr_vpes,
M_DEVBUF, M_ZERO | M_WAITOK, 0, IRS_VMT_BASER_ADDR_LIMIT,
irs->vped_size, 0);
@@ -786,7 +786,7 @@
for (i = 0; i < nr_vpes; i++) {
vm_data->vpet[i] = (vtophys(vpete_p) & VPETE_VPED_ADDR_MASK) |
VPETE_VALID;
- vpete_p += VPE_DESC_SIZE;
+ vpete_p += irs->vped_size;
}
/* Allocate VM ID */
@@ -809,14 +809,12 @@
BIT_CLR(irs->vm_id_count, vm_data->vm_id, &irs->vm_ids);
SLIST_INSERT_HEAD(&irs->vm_data_head, vm_data, node);
- mtx_unlock(&irs->vm_lock);
-
/* Fill in VMT entry now we have a VM ID */
vmte = &irs->vmt_base[vm_data->vm_id * 4];
vmte[L2_VMTE_VPE_ADDR_IDX] =
(vtophys(vm_data->vpet) & L2_VMTE_VPET_ADDR_MASK) |
- ((uint64_t)ilog2_int(nr_vpes) << L2_VMTE_VPE_ID_BITS_SHIFT);
+ ((uint64_t)order_base_2(nr_vpes) << L2_VMTE_VPE_ID_BITS_SHIFT);
vmte[L2_VMTE_SPI_ADDR_IDX] =
(vtophys(vm_data->spi_ist) & L2_VMTE_SPI_IST_ADDR_MASK) |
((uint64_t)spi_id_bits << L2_VMTE_SPI_ID_BITS_SHIFT) |
@@ -836,15 +834,13 @@
/* Ensure the IRS observed zeroed memory */
dsb(ishst);
} else {
- cpu_dcache_wbinv_range(vmte, sizeof(L2_VMTE_SIZE));
- cpu_dcache_wbinv_range(vm_data->vpet,
- sizeof(VPETE_SIZE) * nr_vpes);
- cpu_dcache_wbinv_range(vm_data->vpete,
- sizeof(VPE_DESC_SIZE) * nr_vpes);
- cpu_dcache_wbinv_range(vm_data->lpi_ist,
- sizeof(L2_ISTE_SIZE) * (1 << lpi_id_bits));
- cpu_dcache_wbinv_range(vm_data->spi_ist,
- sizeof(L2_ISTE_SIZE) * (1 << spi_id_bits));
+ cpu_dcache_wbinv_range(vmte, L2_VMTE_SIZE);
+ cpu_dcache_wbinv_range(vm_data->vpet, VPETE_SIZE * nr_vpes);
+ cpu_dcache_wbinv_range(vm_data->vpete, irs->vped_size * nr_vpes);
+ cpu_dcache_wbinv_range(vm_data->lpi_ist, L2_ISTE_SIZE <<
+ lpi_id_bits);
+ cpu_dcache_wbinv_range(vm_data->spi_ist, L2_ISTE_SIZE <<
+ spi_id_bits);
if (irs->vmd_size)
cpu_dcache_wbinv_range(vm_data->vmd, irs->vmd_size);
}
@@ -852,10 +848,14 @@
IRS_CFG_WRITE_8(irs, IRS_VMAP_VMR,
IRS_VMAP_VMR_M | (vm_data->vm_id & IRS_VMAP_VMR_VM_ID_MASK));
+ mtx_unlock(&irs->vm_lock);
+
mtx_lock_spin(&irs->irs_lock);
gicv5_wait_for_op(irs, IRS_VMT_STATUSR, IRS_VMT_STATUSR_IDLE, NULL);
mtx_unlock_spin(&irs->irs_lock);
+ *vm_id = vm_data->vm_id;
+
return (0);
}
diff --git a/sys/arm64/arm64/gicv5reg.h b/sys/arm64/arm64/gicv5reg.h
--- a/sys/arm64/arm64/gicv5reg.h
+++ b/sys/arm64/arm64/gicv5reg.h
@@ -1103,9 +1103,6 @@
#define VPETE_VPED_ADDR_MASK 0x00ffffffffffffe0ul
#define VPETE_VALID (0x1ul << 0)
-/* VPE_DESC - Virtual PE descriptor table entry */
-#define VPE_DESC_SIZE 32
-
/*
* Misc
*/
diff --git a/sys/arm64/arm64/gicv5var.h b/sys/arm64/arm64/gicv5var.h
--- a/sys/arm64/arm64/gicv5var.h
+++ b/sys/arm64/arm64/gicv5var.h
@@ -78,7 +78,7 @@
void gicv5_attach_iwb(device_t, device_t);
-int gicv5_alloc_vm(device_t, int);
+int gicv5_alloc_vm(device_t, int, int *);
int gicv5_free_vm(device_t, int);
int gicv5_get_max_vpe_count(device_t);
diff --git a/sys/arm64/vmm/io/vgic_v5.c b/sys/arm64/vmm/io/vgic_v5.c
--- a/sys/arm64/vmm/io/vgic_v5.c
+++ b/sys/arm64/vmm/io/vgic_v5.c
@@ -631,6 +631,7 @@
struct vm *vm;
struct vgic_v5 *vgic;
device_t parent;
+ int err;
switch (descr->ver.version) {
case 3:
@@ -649,7 +650,9 @@
hyp->vgic->vgic_ver = 5;
parent = device_get_parent(dev);
- vgic->vm_id = gicv5_alloc_vm(parent, vm_get_maxcpus(hyp->vm));
+ err = gicv5_alloc_vm(parent, vm_get_maxcpus(hyp->vm), &vgic->vm_id);
+ if (err)
+ return (err);
vgic->irs_start = descr->v3_regs.dist_start;
vgic->irs_end = descr->v3_regs.dist_start + descr->v3_regs.dist_size;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 2, 10:46 AM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42127464
Default Alt Text
D62224.1796208385.diff (4 KB)
Attached To
Mode
D62224: arm64/gicv5: Fix bugs around VM allocation / initialisation
Attached
Detach File
Event Timeline