BEFORE STARTING

You will need to download the programs provided with the OSTEP textbook. This can be done by cloning the git repo that contains them with

git clone https://github.com/remzi-arpacidusseau/ostep-homework/

For this assignment, you will be using the following to answer questions.

  • vm-segmentation/segmentation.py

Play around with these scripts to familiarize yourself before answering the below questions.

Questions

Justify all answers. Short answers are more likely to receive poor grades. Think of it this way…​you’re trying to convince the grader that you understand the topic.

  1. segmentation.py: This script simulates processes with 2 segments to their address space. The first grows positively (code+heap) and the other grows negatively (stack). How do we run this script such that we have the following?

    • a virtual address space of 256 bytes

    • a physical address space of 1024 bytes

    • the code+heap segment has a base of 0 and a size of 40

    • and the stack segment has a base of 1024 and a size of 40

  2. segmentation.py: Using the setup from Question 1, answer the following.

    1. What is the highest legal virtual address in the code+heap segment?

    2. What is the lowest legal virtual address in the stack segment?

    3. What are the lowest and highest illegal addresses in the virtual address space?

    4. How would you run the script with the -A flag to verify your answers?

  3. segmentation.py: Suppose we have an address space of 16-bytes and a physical address space of 128-bytes. What base and bounds would we setup for the segments such that when accessing the virtual addresses 0 thru 15 (in order) would result in the following pattern:

    valid, valid, violation, …​, violation, valid, valid

    Give the script command we would run to test this.

  4. segmentation.py: Suppose we want 90% of randomly-generated virtual addresses to be valid. How would we configure the simulator? Which parameters are important to getting this outcome? Give the command we would run.

  5. segmentation.py: Is it possible to run the simulator such that no virtual addresses are valid? If so, how?