Giter Site home page Giter Site logo

yujie-cui / slice-reverse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miaous-group/slice-reverse

0.0 0.0 0.0 64 KB

Code from the paper "Reverse Engineering Intel Last-Level Cache Complex Addressing Using Performance Counters", with updates for Kaby Lake CPUs

License: GNU General Public License v2.0

Makefile 0.78% C 98.36% Shell 0.87%

slice-reverse's Introduction

slice-reverse

Code from the paper "Reverse Engineering Intel Last-Level Cache Complex Addressing Using Performance Counters" by Clémentine Maurice, Nicolas Le Scouarnec, Christoph Neumann, Olivier Heen and Aurélien Francillon, published at RAID 2015, with updates for Kaby Lake CPUs.

The code is distributed under the GNU General Public License, version 2.

Programs scan and reverse

The "scan" program allocates some memory and outputs the count of access for each slice, for each address (with a 64B stride). It thus deduces the slice mapped to each physical address. Run this first to be sure everything works as expected.

The "reverse" program allocates memory in huge pages (2MB pages for Core machines, 1GB for Xeon machines). This is to allocate as much contiguous memory as possible and facilitate the reverse. What would also be possible is to write a driver to directly allocate contiguous physical memory. Allocating 1GB pages is usually possible with Xeon machines, but only by reserving them at boot time. If the machine has a lot of memory, it will be faster to recover the higher bits in the function than if the huge pages are 2MB. However, if it is not possible to modify the boot parameters for your machine, it is possible to modify the code and use 2MB pages (execution will be slower).

Parameters for the scan programs

  • --help -h prints this help
  • --clflush -f does not use performance counters but clflush method
  • --verbose -v output additional details

Running the "scan" program

  1. Charge the msr module (need to be root)

# modprobe msr

  1. Run the scan program (need to be root to access the MSRs), eg for my Sandy Bridge laptop

# ./scan

Parameters for the reverse programs

  • --help -h prints this help
  • --clflush -f does not use performance counters but clflush method
  • --scan -s does not reverse-engineer the function but finds the slice for a few addresses
  • --verbose -v output additional details

Running the "reverse" program

For Core machines:

  1. Reserve 2MB pages (need to be root): https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt

# echo 1000 > /proc/sys/vm/nr_hugepages

  1. Verify the pages have been allocated

$ cat /proc/meminfo | grep -i huge

For Xeon machines:

  1. Reserve 1GB pages: can only be done at boot time, by passing parameters to the kernel (can be done in Grub)

default_hugepagesz=1G hugepagesz=1G hugepages=N

  1. When the machine is booted, verify that the pages have been allocated

$ cat /proc/meminfo | grep -i huge

Both Core and Xeon: 3. Charge the msr module (need to be root)

# modprobe msr

  1. Change the number of pages acquired in reverse.c (NB_PAGES for Xeon, NB_PAGES_CORE for Core) and make

  2. Run the reverse program (need to be root to access the MSRs), eg for my Sandy Bridge laptop

# ./reverse -c 2

If not enough huge pages are allocated, a message will be displayed to inform which bits of the function cannot be retrieved. Maybe try to reboot the machine to acquire more huge pages.

slice-reverse's People

Contributors

guillaumedidier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.