Skip to content

Commit 1c8f45b

Browse files
Jianguo Wurtg-canonical
Jianguo Wu
authored andcommitted
mm/vmemmap: fix wrong use of virt_to_page
BugLink: http://bugs.launchpad.net/bugs/1087865 commit ae64ffc upstream. I enable CONFIG_DEBUG_VIRTUAL and CONFIG_SPARSEMEM_VMEMMAP, when doing memory hotremove, there is a kernel BUG at arch/x86/mm/physaddr.c:20. It is caused by free_section_usemap()->virt_to_page(), virt_to_page() is only used for kernel direct mapping address, but sparse-vmemmap uses vmemmap address, so it is going wrong here. ------------[ cut here ]------------ kernel BUG at arch/x86/mm/physaddr.c:20! invalid opcode: 0000 [#1] SMP Modules linked in: acpihp_drv acpihp_slot edd cpufreq_conservative cpufreq_userspace cpufreq_powersave acpi_cpufreq mperf fuse vfat fat loop dm_mod coretemp kvm crc32c_intel ipv6 ixgbe igb iTCO_wdt i7core_edac edac_core pcspkr iTCO_vendor_support ioatdma microcode joydev sr_mod i2c_i801 dca lpc_ich mfd_core mdio tpm_tis i2c_core hid_generic tpm cdrom sg tpm_bios rtc_cmos button ext3 jbd mbcache usbhid hid uhci_hcd ehci_hcd usbcore usb_common sd_mod crc_t10dif processor thermal_sys hwmon scsi_dh_alua scsi_dh_hp_sw scsi_dh_rdac scsi_dh_emc scsi_dh ata_generic ata_piix libata megaraid_sas scsi_mod CPU 39 Pid: 6454, comm: sh Not tainted 3.7.0-rc1-acpihp-final+ torvalds#45 QCI QSSC-S4R/QSSC-S4R RIP: 0010:[<ffffffff8103c908>] [<ffffffff8103c908>] __phys_addr+0x88/0x90 RSP: 0018:ffff8804440d7c08 EFLAGS: 00010006 RAX: 0000000000000006 RBX: ffffea0012000000 RCX: 000000000000002c ... Signed-off-by: Jianguo Wu <[email protected]> Signed-off-by: Jiang Liu <[email protected]> Reviewd-by: Wen Congyang <[email protected]> Acked-by: Johannes Weiner <[email protected]> Reviewed-by: Yasuaki Ishimatsu <[email protected]> Reviewed-by: Michal Hocko <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Herton Ronaldo Krzesinski <[email protected]>
1 parent c0db6fb commit 1c8f45b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: mm/sparse.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
622622
{
623623
return; /* XXX: Not implemented yet */
624624
}
625-
static void free_map_bootmem(struct page *page, unsigned long nr_pages)
625+
static void free_map_bootmem(struct page *memmap, unsigned long nr_pages)
626626
{
627627
}
628628
#else
@@ -663,10 +663,11 @@ static void __kfree_section_memmap(struct page *memmap, unsigned long nr_pages)
663663
get_order(sizeof(struct page) * nr_pages));
664664
}
665665

666-
static void free_map_bootmem(struct page *page, unsigned long nr_pages)
666+
static void free_map_bootmem(struct page *memmap, unsigned long nr_pages)
667667
{
668668
unsigned long maps_section_nr, removing_section_nr, i;
669669
unsigned long magic;
670+
struct page *page = virt_to_page(memmap);
670671

671672
for (i = 0; i < nr_pages; i++, page++) {
672673
magic = (unsigned long) page->lru.next;
@@ -715,13 +716,10 @@ static void free_section_usemap(struct page *memmap, unsigned long *usemap)
715716
*/
716717

717718
if (memmap) {
718-
struct page *memmap_page;
719-
memmap_page = virt_to_page(memmap);
720-
721719
nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page))
722720
>> PAGE_SHIFT;
723721

724-
free_map_bootmem(memmap_page, nr_pages);
722+
free_map_bootmem(memmap, nr_pages);
725723
}
726724
}
727725

0 commit comments

Comments
 (0)