xen: one cleanup for 4.17-rc4

-----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQRTLbB6QfY48x44uB6AXGG7T9hjvgUCWuwoogAKCRCAXGG7T9hj
 vr23AP4vj3yoii3mihZYjDahwyE+3fILUWECl/d/cMXGxq5tbgD9Esvb6DgtKHJr
 Hi/lPMVM0XmN/DIXhY9x7SqO2cKvEAU=
 =XwLB
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-4.17-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen cleanup from Juergen Gross:
 "One cleanup to remove VLAs from the kernel"

* tag 'for-linus-4.17-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  x86/xen: Remove use of VLAs
This commit is contained in:
Linus Torvalds 2018-05-04 05:47:21 -10:00
commit 625e2001e9

View File

@ -421,45 +421,33 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
{ {
unsigned long va = dtr->address; unsigned long va = dtr->address;
unsigned int size = dtr->size + 1; unsigned int size = dtr->size + 1;
unsigned pages = DIV_ROUND_UP(size, PAGE_SIZE); unsigned long pfn, mfn;
unsigned long frames[pages]; int level;
int f; pte_t *ptep;
void *virt;
/* /* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
* A GDT can be up to 64k in size, which corresponds to 8192 BUG_ON(size > PAGE_SIZE);
* 8-byte entries, or 16 4k pages..
*/
BUG_ON(size > 65536);
BUG_ON(va & ~PAGE_MASK); BUG_ON(va & ~PAGE_MASK);
for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) { /*
int level; * The GDT is per-cpu and is in the percpu data area.
pte_t *ptep; * That can be virtually mapped, so we need to do a
unsigned long pfn, mfn; * page-walk to get the underlying MFN for the
void *virt; * hypercall. The page can also be in the kernel's
* linear range, so we need to RO that mapping too.
*/
ptep = lookup_address(va, &level);
BUG_ON(ptep == NULL);
/* pfn = pte_pfn(*ptep);
* The GDT is per-cpu and is in the percpu data area. mfn = pfn_to_mfn(pfn);
* That can be virtually mapped, so we need to do a virt = __va(PFN_PHYS(pfn));
* page-walk to get the underlying MFN for the
* hypercall. The page can also be in the kernel's
* linear range, so we need to RO that mapping too.
*/
ptep = lookup_address(va, &level);
BUG_ON(ptep == NULL);
pfn = pte_pfn(*ptep); make_lowmem_page_readonly((void *)va);
mfn = pfn_to_mfn(pfn); make_lowmem_page_readonly(virt);
virt = __va(PFN_PHYS(pfn));
frames[f] = mfn; if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
make_lowmem_page_readonly((void *)va);
make_lowmem_page_readonly(virt);
}
if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
BUG(); BUG();
} }
@ -470,34 +458,22 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
{ {
unsigned long va = dtr->address; unsigned long va = dtr->address;
unsigned int size = dtr->size + 1; unsigned int size = dtr->size + 1;
unsigned pages = DIV_ROUND_UP(size, PAGE_SIZE); unsigned long pfn, mfn;
unsigned long frames[pages]; pte_t pte;
int f;
/* /* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
* A GDT can be up to 64k in size, which corresponds to 8192 BUG_ON(size > PAGE_SIZE);
* 8-byte entries, or 16 4k pages..
*/
BUG_ON(size > 65536);
BUG_ON(va & ~PAGE_MASK); BUG_ON(va & ~PAGE_MASK);
for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) { pfn = virt_to_pfn(va);
pte_t pte; mfn = pfn_to_mfn(pfn);
unsigned long pfn, mfn;
pfn = virt_to_pfn(va); pte = pfn_pte(pfn, PAGE_KERNEL_RO);
mfn = pfn_to_mfn(pfn);
pte = pfn_pte(pfn, PAGE_KERNEL_RO); if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
BUG();
if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0)) if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
BUG();
frames[f] = mfn;
}
if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
BUG(); BUG();
} }