📜 ⬆️ ⬇️

How the physical address is displayed in rows and banks DRAM

In the last article, we discussed how Intel Sandy Bridge processors map physical addresses in the L3 cache.

Now I will explain how the memory controllers of these processors match the physical addresses with the location in DRAM — in particular, the row, bank, and column numbers in the DRAM modules. Let's call this the mapping of DRAM addresses . I use one test machine as an example.

Motivation: Rowhammer bug


I am interested in the mapping of DRAM addresses, since it belongs to the Rowhammer bug .
')
Rowhammer is a problem with some DRAM modules, when certain worst-case memory access models can damage memory. In these DRAMs, repeated activation of a memory line (“line clogging”) causes electrical interference that changes bits in vulnerable cells of adjacent lines.

These repeated line activations can be triggered by multiple access to a pair of DRAM addresses that are on different lines of the same DRAM bank. Knowledge of the mapping of DRAM addresses is useful because it indicates which address pairs satisfy this “one bank, different rows” property (same bank, different row; SBDR).

Guessing and checking the display of addresses


For the test, I have a car with DRAM modules vulnerable to the Rowhammer bug. Running rowhammer_test on this machine demonstrates a bit change.

I would like to know the DRAM address mapping scheme for this machine, but it is not documented publicly: here is the Sandy Bridge processor, but Intel does not document the address mapping used by the memory controllers of these processors.

In fact, the rowhammer_test test rowhammer_test not need to know a pair of SBDR addresses. He just tries several times to randomly select address pairs. Usually 1/8 or 1/16 of them are SBDR pairs, because in our car there are 8 banks in each DIMM (and 16 banks in total). Thus, we do not need to know the mapping of DRAM addresses to cause a change of bits in the memory, but such knowledge will help to carry out the test more purposefully.

Although the address mapping is not documented, I found that I can make a reasonable assumption about it based on the DRAM geometry, and then check the assumption based on the physical addresses reported by rowhammer_test . The test reports the physical addresses where the bit shifts ( “victims” ) and the pair of physical addresses that make these shifts ( “aggressors” ) occur. Since these pairs must be SBDR pairs, we can test a hypothetical comparison of addresses with these empirical data.

Memory geometry


First step: check how many DIMMs are installed in the machine and how they are internally organized.

I can request DIMM information using the decode-dimms in Linux (it is in the I2C-tools package in Ubuntu). This tool decodes SPD (Serial Presence Detect) metadata to DIMM.

On my test machine, there are two four - gigabyte SO-DIMMs , which gives 8 GB of memory.

The decode-dimms reports the following information for each of the modules:

  Size 4096 MB
 Banks x Rows x Columns x Bits 8 x 15 x 10 x 64
 Ranks 2 

This means that both DIMMs have:


Each DIMM has 2 ranks and 8 banks. A cross-check of the capacity of a DIMM module gives the size as expected:

8 KB in a row * 32768 lines * 2 ranks * 8 banks = 4096 MB = 4 GB

Display DRAM addresses


On my test computer, the bits of the physical addresses are used as follows:


Why such a mapping?


This mapping is consistent with the results of rowhammer_test (see below), but we can also explain that the address bits are mapped in such a way as to provide good performance for typical memory access patterns, such as sequential access and step or step access ( strided access):


Cverka c issue rowhammer_test


The work of rowhammer_test_ext (an enhanced version of rowhammer_test ) on a test machine for 6 hours revealed a repeated change of bits in 22 places. (see the source data and analysis code ).

The test of striking lines generates sets of three addresses (A1, A2, V):


For all these results, we expect the following three properties to be met:


Possible further tests


In the future, you can run two more experiments to check if the mapping of DRAM addresses correctly evaluates the SBDR property:


In addition, the removal of one DIMM module from the system unit must remove the channel bit from the mapping of DRAM addresses and accordingly change the addresses of the aggressor and the victim. This can also be verified.

Source: https://habr.com/ru/post/431102/


All Articles