Skip to contentSkip to conversation

e7e61e51f9 ("fw_cfg: do DMA read operation"): kernel BUG at arch/x86/mm/physaddr.c:75!

DISCUSSION Marc-Andre Lureau 1 participant 1 message Feb 6, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi

Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Marc-Andre Lureau

Hi

Quoted 1 line · Michael S. Tsirkin

On Fri, Feb 02, 2018 at 06:01:01AM +0800, kernel test robot wrote:

That's actually the regression, before Peter patch squashed in v10, we checked if the given address wasn't NULL before doing dma_map_single. Now it is gone and raises the panic.

Thus, the diff I propose is:

drivers/firmware/qemu_fw_cfg.c +3 -2
index 3b3cf6222c97..08309939cd94 100644
@@ -128,7 +128,7 @@ static ssize_t fw_cfg_dma_transfer(struct device *dev,
        }
 
        *d = (struct fw_cfg_dma) {
-               .address = cpu_to_be64(virt_to_phys(address)),
+               .address = address ? cpu_to_be64(virt_to_phys(address)) : 0,
                .length = cpu_to_be32(length),
                .control = cpu_to_be32(control)
        };
@@ -518,7 +518,8 @@ static ssize_t fw_cfg_sysfs_read_raw(struct file
 *filp, struct kobject *kobj,
        if (count > entry->f.size - pos)
                count = entry->f.size - pos;
 
-       return fw_cfg_read_blob(dev, entry->f.select, buf, pos, count, true);
+       /* do not use DMA, virt_to_phys(buf) might not be ok */
+       return fw_cfg_read_blob(dev, entry->f.select, buf, pos, count, false);
 }
 
Quoted 5 lines
Quoted 3 lines

(and I tested it works both with x86 and x86_64 kernel/qemu)

thanks

Point is there are callers where address is on stack.

Which one do you see left where we don't pass dma=false?

Quoted 2 lines

Let's try to do a minimal approach - enable coredump writes first. Defer speedups to next version.

Fair enough (although it would have been nice to ask before reaching v12)