aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2021-05-03 00:57:37 -0700
committerH. Peter Anvin <hpa@zytor.com>2021-05-03 00:57:37 -0700
commit312a5b754911d3d34e450f55ef86bd0c08902479 (patch)
treeacd735d65f2ec323e499703903a898c334f609cb
downloadfred-scripts-312a5b754911d3d34e450f55ef86bd0c08902479.tar.gz
fred-scripts-312a5b754911d3d34e450f55ef86bd0c08902479.tar.xz
fred-scripts-312a5b754911d3d34e450f55ef86bd0c08902479.zip
Initial set of scripts
-rw-r--r--.gitignore2
-rw-r--r--README85
-rw-r--r--fred-smp.simics2
-rw-r--r--fred-up.simics2
-rw-r--r--fred.simics64
-rwxr-xr-xupdateimage.sh6
6 files changed, 161 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..79bd298
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.xz
diff --git a/README b/README
new file mode 100644
index 0000000..7d04d36
--- /dev/null
+++ b/README
@@ -0,0 +1,85 @@
+How to run Simics and the FRED kernel prototype
+-----------------------------------------------
+
+To install and run Simics:
+
+1. Get intel-simics-package-manager and simics-6-package manager from:
+
+ https://downloadcenter.intel.com/download/30403/Intel-Simics-Public-Release-Preview/
+
+2. Unpack intel-simics-package-manager.
+
+3. Run:
+
+ ispm install --install-dir <where you want it>
+
+2. Run ispm, select install from bundle, choose
+ simics-6-packages-2021-16-linux64.ispm
+
+3. Set up a Simics project directory from ispm-gui
+
+4. Get the FRED prototype kernel sources from:
+
+ https://git.zytor.com/linux/kernel/fred.git
+
+ -> This is a temporary location!! <-
+
+ As of this writing, the latest development branch is called
+ "fred-v5.12", but it is subject to be redone at any time.
+
+ For the image generation scripts to work, merge in the branch
+ "x86.genimage".
+
+5. Get the Simics scripts from:
+
+ https://git.zytor.com/linux/kernel/fred-scripts.git
+
+ -> This is also a temporary location!! <-
+
+6. Get a user space disk image. There is one at:
+
+ https://www.zytor.com/linux/fred/disk.img.xz
+
+ ... but there is nothing "magic" about it. Any valid Linux
+ userspace should work; if an initrd is required then it can be
+ added to the updateimage.sh script via the option
+ "FDINITRD=filename".
+
+6. In the Simics project directory:
+
+ a. Put the Simics script into the project directory.
+
+ b. Put or linux the user space disk image so that it is named
+ "disk.img". By default, Simics will not modify this image.
+
+ c. Clone the Linux kernel into a directory "linux", or
+ Make a symlink "linux" to the Linux kernel object directory.
+
+ d. Build the kernel with the config file config.simics.
+
+ e. Run ./updateimage.sh to build the kernel disk image.
+
+ f. Run ./simics fred[-up,-smp].simics
+
+
+PREVIOUS TODO ITEMS NOW DONE
+----------------------------
+a. Initialize FRED directly, rather than setting up the IDT just to
+ tear it back down. This will also permit using vectors 0x10-0x1f
+ and 0x80 for hardware interrupts.
+
+
+PROBABLY PARTIAL TODO LIST
+--------------------------
+
+a. Factoring things into a clean patchset!!!
+
+b. Try to get hardware irqstacks working, if possible without turning
+ the code into a huge mess.
+
+c. Suspend/resume.
+
+d. KVM.
+
+ ... more ...
+
diff --git a/fred-smp.simics b/fred-smp.simics
new file mode 100644
index 0000000..2c5748c
--- /dev/null
+++ b/fred-smp.simics
@@ -0,0 +1,2 @@
+$num_cores = 2
+run-command-file "fred.simics"
diff --git a/fred-up.simics b/fred-up.simics
new file mode 100644
index 0000000..cfc3409
--- /dev/null
+++ b/fred-up.simics
@@ -0,0 +1,2 @@
+$num_cores = 1
+run-command-file "fred.simics"
diff --git a/fred.simics b/fred.simics
new file mode 100644
index 0000000..b73e2e9
--- /dev/null
+++ b/fred.simics
@@ -0,0 +1,64 @@
+#
+# Add a link "linux" to the kernel obj tree for this script to run
+#
+log-setup -time-stamp
+$disk0_image = "linux/arch/x86/boot/hdimage"
+$disk1_image = "disk.img"
+$disk1_size = NIL
+$cpu_comp_class = "x86QSP2"
+
+run-command-file "targets/qsp-x86/qsp-client-core.simics"
+
+# Simics uses the wrong device ID for the Bochs VGA model...
+board.mb.gpu.vga->config_registers[0] = 0x11111234
+
+#
+# Some features are expected to be baseline features on FRED-enabled
+# processors but are not on by default in the Simics QSP2 model.
+#
+# Furthermore, the QSP2 FMS is old enough to trigger a bunch
+# of errata workarounds in Linux, so bump it up to a more modern.
+#
+# NOTE: This is not an official list of any kind.
+#
+$family = 6
+$model = 0x9e # Kaby Lake
+$stepping = 15
+$ucoderev = 0x10
+
+foreach $cpu in (board.get-processor-list) {
+ # Update FMS
+ if $family > 15 {
+ $cpu->cpuid_family_id_override = 15
+ $cpu->cpuid_ext_family_id_override = ($family - 15)
+ } else {
+ $cpu->cpuid_family_id_override = $family
+ $cpu->cpuid_ext_family_id_override = 0
+ }
+ $cpu->cpuid_model_override = ($model & 15)
+ $cpu->cpuid_ext_model_id_override = ($model >> 4)
+ $cpu->cpuid_stepping_id_override = $stepping
+
+ # Make IA32_BIOS_SIGN_ID readonly with the specified version
+ $cpu->add_msr += [[0x8b, 1, $ucoderev, (~0), 0, TRUE, "ia32_bios_sign_id", 0]]
+
+ # IA32_ARCH_CAPABILITIES MSR
+ $cpu->add_msr += [[0x10a, 1, 0x73, (~0), 0, TRUE, "ia32_arch_capabilities", 0]]
+ $cpu->cpuid_arch_capabilities_override = 1
+
+ # IA32_SPEC_CTRL, IA32_PRED_CMD MSRs
+ $cpu->add_msr += [[0x48, 0, 0, 0, (~7), TRUE, "ia32_spec_ctrl", 0]]
+ $cpu->add_msr += [[0x49, 0, 0, 1, (~1), TRUE, "ia32_pred_cmd", 0]]
+ $cpu->cpuid_ibrs_ibpb_override = 1
+ $cpu->cpuid_stibp_override = 1
+ $cpu->cpuid_ssbd_override = 1
+
+ # IA32_FLUSH_CMD MSR
+ $cpu->add_msr += [[0x10b, 0, 0, 1, (~1), TRUE, "ia32_flush_cmd", 0]]
+ $cpu->cpuid_l1d_flush_override = 1
+}
+
+enable-debugger
+add-symbol-file linux/vmlinux
+board.serconsole.con.capture-start "ttyS0.txt" -overwrite
+board.serconsole1.con.capture-start "ttyS1.txt" -overwrite
diff --git a/updateimage.sh b/updateimage.sh
new file mode 100755
index 0000000..d1698b7
--- /dev/null
+++ b/updateimage.sh
@@ -0,0 +1,6 @@
+#!/bin/bash -xe
+parallel=$((2*$(grep '^processor' /proc/cpuinfo | wc -l)))
+make="make -j$parallel -C linux"
+$make
+$make hdimage \
+ FDARGS='ro root=/dev/sdb2 debug console=tty0 console=ttyS0,115200 earlyprintk=serial,ttyS0,115200 show_lapic=all'