lists.openwall.net   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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 13 Aug 2010 16:27:51 +0300
From:	Maxim Levitsky <maximlevitsky@...il.com>
To:	linux-kernel <linux-kernel@...r.kernel.org>
Cc:	Alex Dubov <oakad@...oo.com>
Subject: [QUESTION] Need some explanations in regard to memory alignment of
 requests that a block device receives

Hi,

I currently am writing a block driver for Legacy Memory sticks.

I have few questions about that type of data my ->request will receive
from kernel.

First of all I think that by default, driver receives requests that
contains just one sector and it isn't in high memory.

However I am opting in to allow to receive requests that have many
sectors span several memory regions, and be in highmem).
The request is converted to scatterlist upon which I operate.
(Untill this point I did the same think Alex does in mspro_blk.c)

For simplicity lets assume 512 byte hardware sector size.

However is there a guarantee that incoming memory segments will be
aligned on 512 byte boundary?

If this isn't true I run into 2 problems:

1. Sector can span 2 pages. Therefore if I decide to do pio, and I use
kmap_atomic (because of highmem), I need first map 1st page, read/write
it, unmap it, and then then do the same with 2nd page.


2. Sectors can span 2 memory regions.
This is even worse. For DMA I would need to bounce the sector.
Also it becames very difficult to handle input on sector by sector basis
(short of bouncing everything...)


If the above is true (I hope), then I have different problem.

The problem is that I will have small buffer that will contain few
hardware sectors.
I currently allocate it using kmalloc.
However I want to send that buffer to same functions that deal with IO,
therefore I need it to be aligned on 512 byte boundary.

Is there a way to allocate aligned memory (short of allocating more and
aligning pointer manually which I hate to do)
Maybe I should just use __get_free_pages?
(I will need a buffer of page or two (once per driver load) I think).

Best regards,
Maxim Levitsky


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ