Great question! Since KVM is executing using the host's hardware, you can't use the magic instructions! However, we have another interface (called `m5_addr` or `m5-addr` in the code, IIRC) that will work with KVM. If you compile using -DM5_ADDR=<address>, it should work in KVM. For x86, we usually use 0xFFFF0000. Then, I believe you need to call a function to map the memory (not sure what it's called, it's not in the documentation) before calling any m5 functions.
See https://gem5.googlesource.com/public/gem5-resources/+/refs/heads/stable/src/parsec/disk-image/parsec/parsec-benchmark/pkgs/libs/hooks/src/hooks.c#96 for an example. Also see https://gem5.googlesource.com/public/gem5-resources/+/refs/heads/stable/src/parsec/disk-image/parsec/parsec-benchmark/pkgs/libs/hooks/src/Makefile.shared#9 for how we compile the parsec hooks with m5 addr. Note: it looks like either parsec is a bit out of date with current gem5 develop or the README.md in util/m5 is out of date. I'm not sure which. Cheers, Jason On Wed, Mar 9, 2022 at 4:47 PM George Michelogiannakis < mixelog...@yahoo.co.uk> wrote: > Hello Jason and everyone, > > I'll add the fix to my todo list :) > > But before then, I'm confused by something. Thanks for the link to hooks > and indeed I "m5_work_begin(0,0);. I recompiled the benchmarks I had with > work begin and end. It's just adding "m5_work_begin(0,0)" and > "m5_work_end(0,0)" > at the right spots, without anything else fancy. It compiles and links > fine. When I try to run natively as expected they terminate due to an > illegal instruction ("./run: line 1: 1161 Illegal instruction"). > However, the exact same error happens if I run the same binary in FS mode. > Note that I'm running first in KVM mode on a x86 host hoping to switch CPUs > once the work start event happens. Are magic ops unsupported in KVM mode? > > Thanks! > > > On Wednesday, March 9, 2022, 09:14:24 AM PST, Jason Lowe-Power via > gem5-users <gem5-users@gem5.org> wrote: > > > Hi George, > > For workbegin/workend, they can be called from within applications if you > link to the libm5 library. For instance, in the parsec resource here: > https://resources.gem5.org/resources/parsec we use the m5_workbegin() > function in the ROI hooks. See > https://gem5.googlesource.com/public/gem5-resources/+/refs/heads/stable/src/parsec/disk-image/parsec/parsec-benchmark/pkgs/libs/hooks/src/hooks.c#96 > for the code. > > This works in both SE mode and FS mode. I have no idea why those functions > are not available in the m5 binary. This seems like an oversight, and it > should be a simple fix. If you want to make the fix, we'd appreciate it, > otherwise, we'll put it on the to do list :). > > If you require using the m5 binary without any changes, then you can use > `m5 exit` and modify your run script to "understand" that the first exit is > to reset the stats, the second exit means to dump the stats, etc. > > Cheers, > Jason > > On Wed, Mar 9, 2022 at 4:08 AM Gabe Black via gem5-users < > gem5-users@gem5.org> wrote: > > I don't think we ever transitioned from an assembly based mechanism to a C > based one, since we have always (as far as I know) used both, assembly to > actually invoke the call into gem5, and C to provide a friendly > interface/wrapper around the assembly. That said, yes, it looks like work > begin and work end are just not in the utility, but they are in the header > files and are implemented in gem5 itself. > > Looking at this again triggered a vague memory where I think these didn't > make sense being called from the utility for some reason? Maybe they only > make sense in SE mode, or they should be called from code directly instead > of from a shell or script? I'm not very familiar with them so I can't say > for sure, but I vaguely remember there was something like that. > > Gabe > > On Wed, Mar 9, 2022 at 2:45 AM Giacomo Travaglini < > giacomo.travagl...@arm.com> wrote: > > Hi George, > > > > Thanks for reporting this, I noticed the same issue. When we transitioned > from the old m5 subsystem (assembly based) to the new C based one we forgot > to provide an implementation for workbegin and workend I suppose. Putting > Gabe on CC > > > > Kind Regards > > > > Giacomo > > > > *From: *George Michelogiannakis via gem5-users <gem5-users@gem5.org> > *Date: *Wednesday, 9 March 2022 at 06:54 > *To: *gem5-users@gem5.org <gem5-users@gem5.org> > *Cc: *George Michelogiannakis <mixelog...@yahoo.co.uk> > *Subject: *[gem5-users] M5 Fs utility workbegin > > Hello Gem5 community, > > > > I'm trying to use the M5 utility meant for full system mode to signal work > begin and end. I see in the documentation that the utility supports these > parameters: > > > > - workbegin: Cause an exit evet of type, “workbegin”, that could be > used to mark the begining of an ROI. > - workend: Cause an exit event of type, “workend”, that could be used > to mark the termination of an ROI. > > But when I run the utility in X86 after compiling it for X86 those two > options aren't available as commands. There is a "fail" option with a > parameter that isn't mentioned in the documentation. Is that the way to > simulate workbegin and workend? > > > > Thanks in advance, > > George M > > > > > IMPORTANT NOTICE: The contents of this email and any attachments are > confidential and may also be privileged. If you are not the intended > recipient, please notify the sender immediately and do not disclose the > contents to any other person, use it for any purpose, or store or copy the > information in any medium. Thank you. > > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s > > _______________________________________________ > gem5-users mailing list -- gem5-users@gem5.org > To unsubscribe send an email to gem5-users-le...@gem5.org > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >
_______________________________________________ gem5-users mailing list -- gem5-users@gem5.org To unsubscribe send an email to gem5-users-le...@gem5.org %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s