Skip to content

rcipdev/linux

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMPE283 Assignments

University Details:

San Jose State University

Course: CMPE 283 - Virtualization Technology

Professor: Mike Larkin

Team -

  1. Ruchik Pravasi (SID: 017452461)

Assignment 1 Discovering VMX features

Assignment is to create a Linux kernel module that will query various MSRs to determine virtualization features available in your CPU. This module will report (via the system message log) the features it discovers.

Questions

  1. For each member in your team, provide 1 paragraph detailing what parts of the lab that member implemented / researched. (You may skip this question if you are doing the lab by yourself).
  2. Describe in detail the steps you used to complete the assignment. Consider your reader to be someone skilled in software development but otherwise unfamiliar with the assignment. Good answers to this question will be recipes that someone can follow to reproduce your development steps.

Individual Contributions:

Answers:

  1. I did all by myself

Steps followed for Assignment 1:

  1. Create GCP account and use terminal to create image and VM
  2. Copy below command to create image and enable nested virualization
gcloud compute images create virtualizationnested --source-image=ubuntu-pro-2004-focal-v20231213 --source-image-project=ubuntu-os-pro-cloud --licenses="https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"
  1. Copy below command to create instance from above created image
gcloud compute instances create virtualization --zone=us-east4-a --image=virtualizationnested

We will be using Ubuntu 20.04.3 in by allocating 8 VCPU's, and 100 GB disk space.

  1. Check if VM created is nested virtualizable or not by below command
cat /proc/cpuinfo

This command will show vmx flags, if flags are not shown VM is not nested virtualizable.

  1. Fork the master branch of linux repository from https://github.com/torvalds/linux to your github account.

  2. Install Git using command "sudo apt install git".

  3. Ensure git is installed using "git --version". If version is not displayed, try update command "sudo apt-get update" and reinstall git.

  4. Configure git using following commands

    • git config --global user.name "<your_github_username"
    • git config --global user.email "<your_github_email_address>"
  5. Clone the forked repository into your VM created on GCP using git clone command (Note: Install Git if not installed already).

  6. Steps for cloning

    • Go to github.com and point the repository to linux.
    • Click on Code button that appears and copy the URL for HTTPS.
    • Change the working directory where you want to work with the repo and type below command
    git clone https://github.com/rcipdev/linux.git
    • Ensure git is pointing to the forked repo and not the torvalds/linux repo.
    • Git downloads the code and resolves dependencies from the link pointed.
  7. These are the list of libraries required for compiling and installing kernel code

    • sudo apt-get update
    • sudo apt-get upgrade
    • sudo apt-get install libncurses-dev
    • sudo apt-get install libssl-dev
    • sudo apt-get install make
    • sudo apt-get install gcc
    • sudo apt-get install flex
    • sudo apt-get install bison
    • sudo apt-get install libelf-dev
    • sudo apt-get install libelf-dev
    • sudo apt install zstd
  8. Steps for building kernel

    • Navigate to linux folder

    • Type Command "make menuconfig" to view the interactive shell for loading kernel configuration (Nothing to be done/selected here, it displays configuration menu)

    • Exit from menu config

    • Check for current kernel version using command "uname -a"

    • To avoid version conflict/mismatch, copy the current kernel config file to a new config file in current (inside linux folder) directory using below command

    cp /boot/config-5.15.0-1047-gcp /home/rkpravasi77/linux/.config
    • Type command
    make oldconfig
    • Type command
    make prepare
    • There were some certificate-related errors while running the "make prepare" command. I solved it by following the method outlined below.
        scripts/config --disable SYSTEM_TRUSTED_KEYS
        scripts/config --disable SYSTEM_REVOCATION_KEYS
    • Make modules using
    make -j 8 modules

    (Replace 8 with the number of vcpu's allocated during VM creation)

    • Type command for making kernel
    make -j 8
    • Type command for installing modules (Note: INSTALL_MOD_STRIP=1 is used to skip debugging information)
    sudo make INSTALL_MOD_STRIP=1 modules_install
    • Type command
    sudo make install
    • Type command to restart the VM inorder to apply our changes
    sudo reboot
  9. After rebooting, use "uname -a" to determine the kernel version. If the kernel version and timestamp have been updated to the most recent version, the kernel is properly installed and running.

  10. Create a folder named cmpe283 inside linux folder and add cmpe283-1.c and Make file to this cmpe283 folder.

  11. Navigate to cmpe283 folder and type "make" to generate kernel object file for cmpe283-1.c

  12. Verify if the object file is created using "ls |grep *.ko"

  13. Next step is to insert the cmpe283-1.ko into kernel. Use below steps to do that

    • sudo insmod cmpe283-1.ko
    • Check if the module is inserted using "lsmod | grep cmpe283". It should display cmpe283_1.
  14. Finally, use "dmesg" command to display vmx features.

Output Screenshots

  1. Commit cmpe283-1.c and Makefile to the repository.

About

Linux kernel source tree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.3%
  • Assembly 0.7%
  • Shell 0.4%
  • Makefile 0.2%
  • Python 0.2%
  • Perl 0.1%
  • Other 0.1%