Ciro Santilli has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/22831 )
Change subject: dev-virtio,configs: expose 9p diod virtio on ARM
......................................................................
dev-virtio,configs: expose 9p diod virtio on ARM
9p allows the guest Linux kernel to mount a host directory into the guest.
This allows to very easily modify test programs after a run at the end of
boot, without the need to re-insert the changes into a disk image.
It is enabled on both fs.py and fs_bigLITTLE.py with the --vio-9p
option.
Adapted from code originally present on the wiki: http://gem5.org/WA-gem5
As documented in the CLI option help, the current setup requires the guest
to know the full path to the host share, which is annoying, but overcoming
that would require actually parsing a bit of the protocol rather than just
forwarding everything to diod.
Change-Id: Iaeb1ed185dccfa8332fe6657a54e7550f64230eb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22831
Reviewed-by: Jason Lowe-Power <ja...@lowepower.com>
Reviewed-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Maintainer: Jason Lowe-Power <ja...@lowepower.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M configs/common/FSConfig.py
M configs/common/Options.py
M configs/example/arm/fs_bigLITTLE.py
M configs/example/fs.py
4 files changed, 50 insertions(+), 9 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, but someone else must approve; Looks
good to me, approved
Giacomo Travaglini: Looks good to me, approved
kokoro: Regressions pass
diff --git a/configs/common/FSConfig.py b/configs/common/FSConfig.py
index 55a6e91..ecc5f1c 100644
--- a/configs/common/FSConfig.py
+++ b/configs/common/FSConfig.py
@@ -42,6 +42,7 @@
from __future__ import print_function
from __future__ import absolute_import
+import m5
from m5.objects import *
from m5.util import *
from .Benchmarks import *
@@ -71,6 +72,19 @@
badaddr_responder = BadAddr()
default = Self.badaddr_responder.pio
+def attach_9p(parent, bus):
+ viopci = PciVirtIO()
+ viopci.vio = VirtIO9PDiod()
+ viodir = os.path.join(m5.options.outdir, '9p')
+ viopci.vio.root = os.path.join(viodir, 'share')
+ viopci.vio.socketPath = os.path.join(viodir, 'socket')
+ if not os.path.exists(viopci.vio.root):
+ os.makedirs(viopci.vio.root)
+ if os.path.exists(viopci.vio.socketPath):
+ os.remove(viopci.vio.socketPath)
+ parent.viopci = viopci
+ parent.attachPciDevice(viopci, bus)
+
def fillInCmdline(mdesc, template, **kwargs):
kwargs.setdefault('disk', mdesc.disk())
kwargs.setdefault('rootdev', mdesc.rootdev())
@@ -206,7 +220,8 @@
def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None,
dtb_filename=None, bare_metal=False, cmdline=None,
- external_memory="", ruby=False, security=False):
+ external_memory="", ruby=False, security=False,
+ vio_9p=None):
assert machine_type
pci_devices = []
@@ -374,6 +389,9 @@
self.terminal = Terminal()
self.vncserver = VncServer()
+ if vio_9p:
+ attach_9p(self.realview, self.iobus)
+
if not ruby:
self.system_port = self.membus.slave
diff --git a/configs/common/Options.py b/configs/common/Options.py
index c47d4f7..71d22a4 100644
--- a/configs/common/Options.py
+++ b/configs/common/Options.py
@@ -48,6 +48,16 @@
from .Benchmarks import *
from . import ObjectList
+vio_9p_help = """\
+Enable the Virtio 9P device and set the path to share. The default 9p path
is
+m5ou5/9p/share, and it can be changed by setting VirtIO9p.root with
--param. A
+sample guest mount command is: "mount -t 9p -o
+trans=virtio,version=9p2000.L,aname=<host-full-path> gem5 /mnt/9p" where
+"<host-full-path>" is the full path being shared on the host, and "gem5"
is a
+fixed mount tag. This option requires the diod 9P server to be installed
in the
+host PATH or selected with with: VirtIO9PDiod.diod.
+"""
+
def _listCpuTypes(option, opt, value, parser):
ObjectList.cpu_list.print()
sys.exit(0)
@@ -434,6 +444,7 @@
parser.add_option("--enable-context-switch-stats-dump", \
action="store_true", help="Enable stats dump at context "\
"switches and dump tasks file (required for Streamline)")
+ parser.add_option("--vio-9p", action="store_true",
help=vio_9p_help)
# Benchmark options
parser.add_option("--dual", action="store_true",
diff --git a/configs/example/arm/fs_bigLITTLE.py
b/configs/example/arm/fs_bigLITTLE.py
index 94e2846..4645d9e 100644
--- a/configs/example/arm/fs_bigLITTLE.py
+++ b/configs/example/arm/fs_bigLITTLE.py
@@ -52,8 +52,10 @@
m5.util.addToPath("../../")
+from common import FSConfig
from common import SysPaths
from common import ObjectList
+from common import Options
from common.cores.arm import ex5_big, ex5_LITTLE
import devices
@@ -209,6 +211,8 @@
"sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 "
"Direct parameters of the root object are not accessible, "
"only parameters of its children.")
+ parser.add_argument("--vio-9p", action="store_true",
+ help=Options.vio_9p_help)
return parser
def build(options):
@@ -296,6 +300,9 @@
m5.tlm.tlm_global_quantum_instance().set(
sc.sc_time(10000.0 / 100000000.0, sc.sc_time.SC_SEC))
+ if options.vio_9p:
+ FSConfig.attach_9p(system.realview, system.iobus)
+
return root
def _build_kvm(system, cpus):
diff --git a/configs/example/fs.py b/configs/example/fs.py
index c927319..7efe433 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -92,14 +92,19 @@
test_sys = makeLinuxX86System(test_mem_mode, np, bm[0],
options.ruby,
cmdline=cmdline)
elif buildEnv['TARGET_ISA'] == "arm":
- test_sys = makeArmSystem(test_mem_mode, options.machine_type, np,
- bm[0], options.dtb_filename,
- bare_metal=options.bare_metal,
- cmdline=cmdline,
- external_memory=
- options.external_memory_system,
- ruby=options.ruby,
-
security=options.enable_security_extensions)
+ test_sys = makeArmSystem(
+ test_mem_mode,
+ options.machine_type,
+ np,
+ bm[0],
+ options.dtb_filename,
+ bare_metal=options.bare_metal,
+ cmdline=cmdline,
+ external_memory=options.external_memory_system,
+ ruby=options.ruby,
+ security=options.enable_security_extensions,
+ vio_9p=options.vio_9p,
+ )
if options.enable_context_switch_stats_dump:
test_sys.enable_context_switch_stats_dump = True
else:
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/22831
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Iaeb1ed185dccfa8332fe6657a54e7550f64230eb
Gerrit-Change-Number: 22831
Gerrit-PatchSet: 8
Gerrit-Owner: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Anouk Van Laer <anouk.vanl...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Ciro Santilli <ciro.santi...@arm.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-CC: Brandon Potter <brandon.pot...@amd.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev