Commit 625e2001 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 54c6fd56 eb0b4aa8
...@@ -421,24 +421,15 @@ static void xen_load_gdt(const struct desc_ptr *dtr) ...@@ -421,24 +421,15 @@ 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 f;
/*
* A GDT can be up to 64k in size, which corresponds to 8192
* 8-byte entries, or 16 4k pages..
*/
BUG_ON(size > 65536);
BUG_ON(va & ~PAGE_MASK);
for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
int level; int level;
pte_t *ptep; pte_t *ptep;
unsigned long pfn, mfn;
void *virt; void *virt;
/* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
BUG_ON(size > PAGE_SIZE);
BUG_ON(va & ~PAGE_MASK);
/* /*
* The GDT is per-cpu and is in the percpu data area. * The GDT is per-cpu and is in the percpu data area.
* That can be virtually mapped, so we need to do a * That can be virtually mapped, so we need to do a
...@@ -453,13 +444,10 @@ static void xen_load_gdt(const struct desc_ptr *dtr) ...@@ -453,13 +444,10 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
mfn = pfn_to_mfn(pfn); mfn = pfn_to_mfn(pfn);
virt = __va(PFN_PHYS(pfn)); virt = __va(PFN_PHYS(pfn));
frames[f] = mfn;
make_lowmem_page_readonly((void *)va); make_lowmem_page_readonly((void *)va);
make_lowmem_page_readonly(virt); make_lowmem_page_readonly(virt);
}
if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct))) if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
BUG(); BUG();
} }
...@@ -470,22 +458,13 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr) ...@@ -470,22 +458,13 @@ 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;
/*
* A GDT can be up to 64k in size, which corresponds to 8192
* 8-byte entries, or 16 4k pages..
*/
BUG_ON(size > 65536); /* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
BUG_ON(size > PAGE_SIZE);
BUG_ON(va & ~PAGE_MASK); BUG_ON(va & ~PAGE_MASK);
for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
pte_t pte;
unsigned long pfn, mfn;
pfn = virt_to_pfn(va); pfn = virt_to_pfn(va);
mfn = pfn_to_mfn(pfn); mfn = pfn_to_mfn(pfn);
...@@ -494,10 +473,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr) ...@@ -494,10 +473,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0)) if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
BUG(); BUG();
frames[f] = mfn; if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
}
if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
BUG(); BUG();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment