lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 18 Feb 2019 11:58:07 +0100
From:   Thomas Bogendoerfer <>
To:     Christoph Hellwig <>
Cc:     Bjorn Helgaas <>,
        James Hogan <>,,,,
        Lorenzo Pieralisi <>,
        Paul Burton <>,
        Ralf Baechle <>
Subject: Re: [PATCH 6/7] MIPS: SGI-IP27: use generic PCI driver

On Mon, 28 Jan 2019 05:32:15 -0800
Christoph Hellwig <> wrote:

> Note that we could probably fix these by just switching IP27 and
> other users of the bridge chip to use the dma_pfn_offset field
> in struct device and stop overriding these functions.

during my final round of tests for v2 of the patchset I found a problem with
the current implementation regarding dma_pfn_offset. Right now it asumes that
dma addresses are lower than physical addresses, which probably came from the
sh7786 usage (at least that's how I understand the SH7786 datasheet). But for
IP27 physical addresses starts at 0 and dma address is more at the end of the
64bit address space. So using following patch gets it right for IP27:

diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
index b7338702592a..19dfadc292f5 100644
--- a/include/linux/dma-direct.h
+++ b/include/linux/dma-direct.h
@@ -12,14 +12,14 @@ static inline dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
        dma_addr_t dev_addr = (dma_addr_t)paddr;
-       return dev_addr - ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+       return dev_addr + ((dma_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
 static inline phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
        phys_addr_t paddr = (phys_addr_t)dev_addr;
-       return paddr + ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
+       return paddr - ((phys_addr_t)dev->dma_pfn_offset << PAGE_SHIFT);
 static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)

This of course will break SH7786. To fix both cases how about making dma_pfn_offset
a signed long ?


SUSE Linux GmbH
GF: Felix Imend├Ârffer, Jane Smithard, Graham Norton
HRB 21284 (AG N├╝rnberg)

Powered by blists - more mailing lists