MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dmar_maxaddr2mgaw

Function dmar_maxaddr2mgaw

freebsd/x86/iommu/intel_utils.c:150–171  ·  view source on GitHub ↗

* Find a best fit mgaw for the given maxaddr: * - if allow_less is false, must find sagaw which maps all requested * addresses (used by identity mappings); * - if allow_less is true, and no supported sagaw can map all requested * address space, accept the biggest sagaw, whatever is it. */

Source from the content-addressed store, hash-verified

148 * address space, accept the biggest sagaw, whatever is it.
149 */
150int
151dmar_maxaddr2mgaw(struct dmar_unit *unit, iommu_gaddr_t maxaddr, bool allow_less)
152{
153 int i;
154
155 for (i = 0; i < nitems(sagaw_bits); i++) {
156 if ((1ULL << sagaw_bits[i].agaw) >= maxaddr &&
157 (DMAR_CAP_SAGAW(unit->hw_cap) & sagaw_bits[i].cap) != 0)
158 break;
159 }
160 if (allow_less && i == nitems(sagaw_bits)) {
161 do {
162 i--;
163 } while ((DMAR_CAP_SAGAW(unit->hw_cap) & sagaw_bits[i].cap)
164 == 0);
165 }
166 if (i < nitems(sagaw_bits))
167 return (sagaw_bits[i].agaw);
168 KASSERT(0, ("no mgaw for maxaddr %jx allow_less %d",
169 (uintmax_t) maxaddr, allow_less));
170 return (-1);
171}
172
173/*
174 * Calculate the total amount of page table pages needed to map the

Callers 1

dmar_domain_allocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected