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 <jason@lowepower.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ciro Santilli
2019-10-24 17:45:43 +01:00
parent e53051c889
commit 55c5b66ae4
4 changed files with 50 additions and 9 deletions

View File

@@ -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 @@ class MemBus(SystemXBar):
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 makeSparcSystem(mem_mode, mdesc=None, cmdline=None):
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 @@ def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None,
self.terminal = Terminal()
self.vncserver = VncServer()
if vio_9p:
attach_9p(self.realview, self.iobus)
if not ruby:
self.system_port = self.membus.slave

View File

@@ -48,6 +48,16 @@ from m5.objects import *
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 @@ def addFSOptions(parser):
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",

View File

@@ -52,8 +52,10 @@ from m5.objects import *
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 @@ def addOptions(parser):
"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 @@ def build(options):
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):

View File

@@ -92,14 +92,19 @@ def build_test_system(np):
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: