History

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

Linus Torvalds committed 8 years ago

Commit 625e2002 parents 54c6fd5 eb0b4aa1 file · +31 −55Browse files

Unified · Split

arch/x86/xen/enlighten_pv.c+31−55
@@ -421,45 +421,33 @@ static void xen_load_gdt(const struct desc_ptr *dtr) · 420 unmodified lines
421421 {
422422 unsigned long va = dtr->address;
423423 unsigned int size = dtr->size + 1;
424− unsigned pages = DIV_ROUND_UP(size, PAGE_SIZE);
425− unsigned long frames[pages];
426− int f;
427−
428− /*
429− * A GDT can be up to 64k in size, which corresponds to 8192
430− * 8-byte entries, or 16 4k pages..
431− */
424+ unsigned long pfn, mfn;
425+ int level;
426+ pte_t *ptep;
427+ void *virt;
432428
433− BUG_ON(size > 65536);
429+ /* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
430+ BUG_ON(size > PAGE_SIZE);
434431 BUG_ON(va & ~PAGE_MASK);
435432
436− for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
437− int level;
438− pte_t *ptep;
439− unsigned long pfn, mfn;
440− void *virt;
441−
442− /*
443− * The GDT is per-cpu and is in the percpu data area.
444− * That can be virtually mapped, so we need to do a
445− * page-walk to get the underlying MFN for the
446− * hypercall. The page can also be in the kernel's
447− * linear range, so we need to RO that mapping too.
448− */
449− ptep = lookup_address(va, &level);
450− BUG_ON(ptep == NULL);
451−
452− pfn = pte_pfn(*ptep);
453− mfn = pfn_to_mfn(pfn);
454− virt = __va(PFN_PHYS(pfn));
433+ /*
434+ * The GDT is per-cpu and is in the percpu data area.
435+ * That can be virtually mapped, so we need to do a
436+ * page-walk to get the underlying MFN for the
437+ * hypercall. The page can also be in the kernel's
438+ * linear range, so we need to RO that mapping too.
439+ */
440+ ptep = lookup_address(va, &level);
441+ BUG_ON(ptep == NULL);
455442
456− frames[f] = mfn;
443+ pfn = pte_pfn(*ptep);
444+ mfn = pfn_to_mfn(pfn);
445+ virt = __va(PFN_PHYS(pfn));
457446
458− make_lowmem_page_readonly((void *)va);
459− make_lowmem_page_readonly(virt);
460− }
447+ make_lowmem_page_readonly((void *)va);
448+ make_lowmem_page_readonly(virt);
461449
462− if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
450+ if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
463451 BUG();
464452 }
465453
@@ -470,34 +458,22 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr) · 4 unmodified lines
470458 {
471459 unsigned long va = dtr->address;
472460 unsigned int size = dtr->size + 1;
473− unsigned pages = DIV_ROUND_UP(size, PAGE_SIZE);
474− unsigned long frames[pages];
475− int f;
476−
477− /*
478− * A GDT can be up to 64k in size, which corresponds to 8192
479− * 8-byte entries, or 16 4k pages..
480− */
461+ unsigned long pfn, mfn;
462+ pte_t pte;
481463
482− BUG_ON(size > 65536);
464+ /* @size should be at most GDT_SIZE which is smaller than PAGE_SIZE. */
465+ BUG_ON(size > PAGE_SIZE);
483466 BUG_ON(va & ~PAGE_MASK);
484467
485− for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
486− pte_t pte;
487− unsigned long pfn, mfn;
468+ pfn = virt_to_pfn(va);
469+ mfn = pfn_to_mfn(pfn);
488470
489− pfn = virt_to_pfn(va);
490− mfn = pfn_to_mfn(pfn);
471+ pte = pfn_pte(pfn, PAGE_KERNEL_RO);
491472
492− pte = pfn_pte(pfn, PAGE_KERNEL_RO);
493−
494− if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
495− BUG();
496−
497− frames[f] = mfn;
498− }
473+ if (HYPERVISOR_update_va_mapping((unsigned long)va, pte, 0))
474+ BUG();
499475
500− if (HYPERVISOR_set_gdt(frames, size / sizeof(struct desc_struct)))
476+ if (HYPERVISOR_set_gdt(&mfn, size / sizeof(struct desc_struct)))
501477 BUG();
502478 }
503479

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t