{"id":16567809,"url":"https://github.com/thenetadmin/lens","last_synced_at":"2025-03-21T11:33:23.965Z","repository":{"id":109730836,"uuid":"304180763","full_name":"TheNetAdmin/LENS","owner":"TheNetAdmin","description":"[MICRO'20] LENS: A Low-level NVRAM Profiler [USENIX Security'23] NVLeak: Off-Chip Side-Channel Attacks via Non-Volatile Memory Systems","archived":false,"fork":false,"pushed_at":"2024-07-08T21:52:21.000Z","size":16710,"stargazers_count":14,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-12T21:07:37.714Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/TheNetAdmin/LENS-VANS","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TheNetAdmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-10-15T01:47:19.000Z","updated_at":"2024-01-14T06:02:07.000Z","dependencies_parsed_at":"2024-02-25T03:33:31.126Z","dependency_job_id":"395ac111-4f15-427a-8645-320501fe47e3","html_url":"https://github.com/TheNetAdmin/LENS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNetAdmin%2FLENS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNetAdmin%2FLENS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNetAdmin%2FLENS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheNetAdmin%2FLENS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheNetAdmin","download_url":"https://codeload.github.com/TheNetAdmin/LENS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221815024,"owners_count":16885097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T21:07:33.460Z","updated_at":"2024-10-28T10:05:53.242Z","avatar_url":"https://github.com/TheNetAdmin.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LENS: A Low-level Heterogeneous Memory Profiler\n\nLENS is a low-level non-volatile memory profiler, which is built based on [LATTester](https://github.com/NVSL/OptaneStudy).\n\nLENS is part of our [MICRO 2020 paper](https://github.com/TheNetAdmin/LENS-VANS).\n\nBased on LENS we developed [NVLeak](https://github.com/TheNetAdmin/NVLeak), which is part of our [USENIX Security 2023 paper](https://github.com/TheNetAdmin/NVLeak)\n\n## Introduction\n\nLENS contains two modules, each of them needs to be mounted on a pmem device (in fsdax mode):\n\n**LatencyFS**: LatencyFS (LatFS) is the working area of the tester. A series of memory accesses will be issued to locations within this area.\n\n**ReportFS**: ReportFS (RepFS) is used to store access latency of individual requests, or intermediate data like pointer chasing index. User can gather the result using `dd if=/dev/pmemX of=result bs=\u003cbs\u003e count=\u003ccount\u003e`\n\n\n### Requirement\n\n1. Linux 4.13 kernel (with devel)\n2. CPU with clwb/AVX-512 support (i.e., support Optane DIMM)\n3. Two real or emulated PMem regions\n4. LENS will overwrite the content of the PMem devices\n\n## Usage\n\n### Run LENS\n\nLENS contains three sets of microbenchmarks (three \"prober\"s):\n\n1. buffer prober: profiles on-DIMM buffers\n2. policy prober: profiles control policies\n3. performance prober: profiles microarchitecture components performance\n\nRead the paper for more details of these probers.\n\nThe scripts of these probers are under `scripts/prober/`.\nTo run a prober, please use the script `scripts/lens.sh`, e.g.:\n\n```\n$ cd scripts\n$ ./lens.sh /dev/pmem0 /dev/pmem14 prober/buffer/pointer_chasing.sh\n```\n\nIn this example, `lens.sh` compiles the source code, runs the `pointer_chasing` job from buffer prober on `/dev/pmem14`, and writes the result in the `results` directory.\n\nMost of the probers have pre-predefined options (e.g. access size or stride size).\nCheck their script code for more details about how to change the options.\n\n### Parse results\n\nWe provide a few Python3 scripts (`scripts/prober/*/parse.py`) to parse the results from LENS.\nThese scripts use the *f-string* feature to print results, which requires Python 3.6 or later version.\nYou can modify the code to replace *f-string* with *str.format()* if you are using older versions.\n\nTo install dependencies:\n\n```shell\n$ pip3 install click numpy\n```\n\nAn example to parse `pointer_chasing.sh` results:\n\n```shell\n$ python3 scripts/prober/buffer/parse.py pointer-chasing \\\n          --src_file results/your_task_id/stdout.log \\\n          --out_file pointer_chasing.csv\n```\n\n### Compile and load modules\n\n`lens.sh` script can compile the code and launch the tests.\nBut if you want to compile and load the modules yourself:\n\n```shell\n$ cd scripts\n\n# Compile and load modules\n$ ./utils/mount.sh /dev/pmem0 /dev/pmem14\n\n# Unload modules\n$ ./utils/umount.sh\n```\n\nIn this example, the script `mount.sh` compiles the source code in `src` directory, and mount `/dev/pmem0` as `ReportFS`, `/dev/pmem14` as `LatencyFS`.\n\n### Launch a test through command line\n\nIt is recommended to use `lens.sh` with prober scripts under `scripts/prober/` to launch tests.\nYou can modify the prober scripts to meet your requirements.\n\nBut if you need to manually launch some tests through command line:\n\n```shell\n# Compile and load modules\n$ ./scripts/utils/mount.sh /dev/pmem0 /dev/pmem14\n\n# Run a pointer chasing test\n$ cat \"task=7,pc_region_size=4096,pc_block_size=64,message=try_ptr_chasing_test\" \u003e /proc/lens\n```\n\nTo find more details about LENS options:\n\n```\n$ cat /proc/lens\n\nLENS task=\u003ctask\u003e op=\u003cop\u003e [options]\nTasks:\n        1: Basic Latency Test (not configurable)\n        2: Strided Latency Test  [access_size] [stride_size]\n        3: Strided Bandwidth Test [access_size] [stride_size] [delay] [parallel] [runtime] [global]\n        4: Random Size-Bandwidth Test [bwtest_bit] [access_size] [parallel] [runtime] [align_mode]\n        5: Overwrite Test [stride_size]\n        6: Pointer Chasing Write Test [pc_region_size] [pc_block_size]\n        7: Pointer Chasing Read and Write Test [pc_region_size] [pc_block_size]\n        8: Pointer Chasing Read after Write Test [pc_region_size] [pc_block_size]\n        9: Sequencial Test [access_size], [parallel]\n        10: Flush First Test [stride_size] [access_size] [op]\n\nOptions:\n        [op|o]             Operation (see source code for the correct op, some tasks may not use the ops defined here): 0=Load, 1=Load(NT) 2=Write(clwb), 3=Write+Flush(clwb+flush) default=0\n        [access_size|a]    Access size (bytes), default=64\n        [stride_size|s]    Stride size (bytes), default=64\n        [pc_region_size|R] Pointer chasing region size (bytes), default=64\n        [pc_block_size|B]  Pointer chasing block size (bytes), default=64\n        [align_mode|l]     Align mode: 0 = Global (anywhere), 1 = Per-Thread pool (default) 2 = Per-DIMM pool 3=Per-iMC pool\n                                       4 = Per-Channel Group, 5 = [NIOnly!!!]: Global, 6 = [NIOnly!!!]: Per-DIMM\n        [delay|d]          Delay (cycles), default=0\n        [parallel|p]       Concurrent kthreads, default=1\n        [bwsize_bit|b]     Aligned size (2^b bytes), default=6\n        [runtime|t]        Runtime (seconds), default=10\n        [write_addr|w]     For Straight Write: access location, default=0\n        [write_size|z]     For Straight Write: access size, default=0\n        [fence_rate|f]     Access size before issuing a sfence instruction\n        [clwb_rate|c]      Access size before issuing a clwb instruction\n        [repeat|r]    Number of test rounds\n        [message|m]        A string as a unique ID for the current job\n\nAvailable pointer chasing benchmarks:\n        No.     Name                    Block Size (Byte)\n        0       pointer-chasing-64      64\n        1       pointer-chasing-128     128\n        2       pointer-chasing-256     256\n        3       pointer-chasing-512     512\n        4       pointer-chasing-1024    1024\n        5       pointer-chasing-2048    2048\n        6       pointer-chasing-4096    4096\n```\n\n\n## Configuration\n\n### Hardware\n\nItem | Description\n---|---\nCPUs | 2\nCPU | Intel Xeon Platinum 8260 ES (Cascade Lake SP)\nCPUFreq. | 24 Cores at 2.2 GHz base clock\nCPU L1 | 32 KB i-Cache, 32 KB d-cache\nCPU L2 | 1 MB\nCPU L3 | 33 MB (shared)\nDRAM | 2x6x32 GB Micron DDR4 2666 MHz (36ASF4G72PZ)\nPM | 2x6x256 GB Intel Optane DC 2666 MHz QS (NMA1XXD256GQS)\n\n### Software\n\nItem | Description\n---|---\nGNU/Linux Distro | Fedora 27\nLinux Kernel | 4.13.0\nCPU Governor | Performance\nHyperThreading (SMP) | Disabled\nNVDIMM Firmware | 01.01.00.5253\nKASLR | Disabled\nCPU mitigations | Off\n\n## Bibliography\n\n```bibtex\n@inproceedings{Wang2020LensVans,\n  author={Zixuan Wang and Xiao Liu and Jian Yang and Theodore Michailidis and Steven Swanson and Jishen Zhao},\n  booktitle={2020 53rd Annual IEEE/ACM International Symposium on Microarchitecture (MICRO)}, \n  title={Characterizing and Modeling Non-Volatile Memory Systems}, \n  year={2020},\n  pages={496-508},\n  doi={10.1109/MICRO50266.2020.00049}\n}\n\n@inproceedings{Wang2023NVLeak,\n  title     = {{NVLeak}: Off-Chip Side-Channel Attacks via Non-Volatile Memory Systems},\n  author    = {Zixuan Wang and Mohammadkazem Taram and Daniel Moghimi and Steven Swanson and Dean Tullsen and Jishen Zhao},\n  booktitle = {32nd {USENIX} Security Symposium ({USENIX} Security 23)},\n  year      = {2023}\n}\n```\n\n## License\n\n[![](https://img.shields.io/github/license/TheNetAdmin/LENS)](LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenetadmin%2Flens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthenetadmin%2Flens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthenetadmin%2Flens/lists"}