FYI these patches are merged in the develop branch atm:

https://gem5-review.googlesource.com/c/public/gem5/+/36795
https://gem5-review.googlesource.com/c/public/gem5/+/31218/6/tests/gem5/configs/arm_generic.py

And they should fix your problem (will be part of gem5 21.0)
The second one is just an example; you should add those lines to your config 
script:

        if issubclass(self.cpu_class, ArmV8KvmCPU):
            GenericTimer.generateDeviceTree = SimObject.generateDeviceTree
            system.realview.gic.simulate_gic = True

Would you let me know if these patches alone are enough to solve your problem?

(Commenting Liyichao's changes below)


> -----Original Message-----
> From: Tracy Mac via gem5-users <gem5-users@gem5.org>
> Sent: 26 January 2021 11:50
> To: Liyichao <liyic...@huawei.com>
> Cc: gem5 users mailing list <gem5-users@gem5.org>; Tracy Mac
> <fgzs...@gmail.com>
> Subject: [gem5-users] Re: KVM Doesn't Work
>
> Hi Liyichao!
> Thanks, I'll check it out.
>
> On Tue, Jan 26, 2021 at 7:44 PM Liyichao <liyic...@huawei.com> wrote:
> >
> > You have to modify TIMER and GIC.
> >
> >
> > diff --git a/src/dev/arm/GenericTimer.py b/src/dev/arm/GenericTimer.py
> > index ed81b2471..aee15b738 100644
> > --- a/src/dev/arm/GenericTimer.py
> > +++ b/src/dev/arm/GenericTimer.py
> > @@ -98,6 +98,7 @@ Reference:
> >      # value, so this initial value will be discarded
> >      cntfrq = Param.UInt64(0x1800000, "Value for the CNTFRQ timer
> > register")
> >
> > +    '''
> >      def generateDeviceTree(self, state):
> >          node = FdtNode("timer")
> >
> > @@ -115,7 +116,8 @@ Reference:
> >              node.append(self.counter.unproxy(self).generateDtb())
> >
> >          yield node
> > -
> > +    '''
> > +
> >  class GenericTimerFrame(PioDevice):
> >      """
> >  Memory-mapped timer frame implementation. Controlled from
> > GenericTimerMem, diff --git a/src/dev/arm/RealView.py
> > b/src/dev/arm/RealView.py index 9ab04725d..3fd0e9168 100644
> > --- a/src/dev/arm/RealView.py
> > +++ b/src/dev/arm/RealView.py
> > @@ -67,8 +67,10 @@ from m5.objects.SMMUv3 import SMMUv3  #
> emulation.
> > Use a GIC model that automatically switches between  # gem5's GIC
> > model and KVM's GIC model if KVM is available.
> >  try:
> > -    from m5.objects.KvmGic import MuxingKvmGic
> > -    kvm_gicv2_class = MuxingKvmGic
> > +    # from m5.objects.KvmGic import MuxingKvmGic
> > +    # kvm_gicv2_class = MuxingKvmGic
> > +    from m5.objects.KvmGic import Gic400
> > +    kvm_gicv2_class = Gic400
> >  except ImportError:
> >      # KVM support wasn't compiled into gem5. Fallback to a
> >      # software-only GIC.
> > diff --git a/src/dev/arm/generic_timer.cc
> > b/src/dev/arm/generic_timer.cc index 458a2eb7a..509153cab 100644
> > --- a/src/dev/arm/generic_timer.cc
> > +++ b/src/dev/arm/generic_timer.cc
> > @@ -289,8 +289,12 @@ ArchTimer::updateCounter()
> >              _interrupt->clear();
> >          }
> >
> > -        _control.istatus = 0;
> > -
> > +        // _control.istatus = 0;
> > +        if (_control.istatus) {
> > +            DPRINTF(Timer, "Clearing interrupt\n");
> > +            _interrupt->clear();
> > +            _control.istatus = 0;
> > +        }
> >          if (scheduleEvents()) {
> >              _parent.schedule(_counterLimitReachedEvent,
> >                               whenValue(_counterLimit)); diff --git


I am not sure this is needed.
First portion of the snippet is already checking if there is a pending 
interrupt and it is clearing it if that's the case
(clearing irq and setting istatus to zero)

        // Clear the interurpt when timers conditions are not met
        if (_interrupt->active()) {
            DPRINTF(Timer, "Clearing interrupt\n");
            _interrupt->clear();
        }

        _control.istatus = 0;


> > a/util/m5/src/abi/aarch64/SConsopts
> > b/util/m5/src/abi/aarch64/SConsopts
> > index 47ada0209..683c4f2eb 100644
> > --- a/util/m5/src/abi/aarch64/SConsopts
> > +++ b/util/m5/src/abi/aarch64/SConsopts
> > @@ -27,6 +27,7 @@ Import('*')
> >
> >  env['ABI'] = 'aarch64'
> >  get_abi_opt('CROSS_COMPILE', 'aarch64-linux-gnu-')
> > +env.Append(CFLAGS='-DM5OP_ADDR=0x10010000')
> >
> >  env['CALL_TYPE']['inst'].impl('m5op.S', 'verify_inst.cc',
> > default=True)
> >  env['CALL_TYPE']['addr'].impl('m5op_addr.S')
> >
> >

This one is needed to issue memory mapped m5 ops. Gabe refactored the m5 
utility so that you can specify this at
Runtime rather than compile time:

$m5 --addr 0x10010000 <op>

I though it was already in 20.1 but I am probably wrong. Again, this will be 
part of gem5-21.0 for sure

Kind Regards

Giacomo


> >
> > -----邮件原件-----
> > 发件人: Tracy Mac via gem5-users [mailto:gem5-users@gem5.org]
> > 发送时间: 2021年1月26日 19:09
> > 收件人: gem5 users mailing list <gem5-users@gem5.org>
> > 抄送: Tracy Mac <fgzs...@gmail.com>
> > 主题: [gem5-users] KVM Doesn't Work
> >
> > Hi All
> > I run the fs.py script in gem5(20.1.0.0), but there is no information in the
> m5term console. I don't know what went wrong.
> > In gem5(20.0.0.3 develop),kvm can work very well,I have no idea how to
> change the new version.
> >
> > INFO:
> > gem5 Simulator System.  http://gem5.org
> > gem5 is copyrighted software; use the --copyright option for details.
> >
> > gem5 version 20.1.0.2
> > gem5 compiled Jan 26 2021 17:54:32
> > gem5 started Jan 26 2021 18:36:35
> > gem5 executing on ubuntu, pid 28630
> > command line: ./build/ARM/gem5.opt configs/example/fs.py
> > --cpu-type=ArmV8KvmCPU
> > --disk-image=/home/tracy/Desktop/image/aarch-system-20170616/disks/lin
> > aro-minimal-aarch64.img --kernel=/home/tracy/Desktop/vmlinux.euler
> >
> > warn: iobus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: bridge.master is deprecated. `master` is now called
> > `mem_side_port`
> > warn: membus.master is deprecated. `master` is now called
> > `mem_side_ports`
> > warn: bridge.slave is deprecated. `slave` is now called
> > `cpu_side_port`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: iobus.master is deprecated. `master` is now called
> > `mem_side_ports`
> > warn: iobridge.slave is deprecated. `slave` is now called
> > `cpu_side_port`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: iobridge.master is deprecated. `master` is now called
> > `mem_side_port`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: membus.slave is deprecated. `slave` is now called
> > `cpu_side_ports`
> > warn: membus.master is deprecated. `master` is now called
> > `mem_side_ports` Global frequency set at 1000000000000 ticks per
> > second
> > warn: No dot file generated. Please install pydot to generate the dot file 
> > and
> pdf.
> > warn: DRAM device capacity (8192 Mbytes) does not match the address
> > range assigned (512 Mbytes)
> > info: kernel located at: /home/tracy/Desktop/vmlinux.euler
> > warn: Highest ARM exception-level set to AArch32 but the workload is for
> AArch64. Assuming you wanted these to match.
> > system.vncserver: Listening for connections on port 5900
> > system.terminal: Listening for connections on port 3456
> > system.realview.uart1.device: Listening for connections on port 3457
> > system.realview.uart2.device: Listening for connections on port 3458
> > system.realview.uart3.device: Listening for connections on port 3459
> > 0: system.remote_gdb: listening for remote gdb on port 7000
> > warn: CoherentXBar system.membus has no snooping ports attached!
> > info: Using bootloader at address 0x10
> > info: Using kernel entry physical address at 0x80080000
> > info: Loading DTB file: m5out/system.dtb at address 0x88000000
> > **** REAL SIMULATION ****
> > info: KVM: Coalesced MMIO disabled by config.
> > warn: Existing EnergyCtrl, but no enabled DVFSHandler found.
> > info: Entering event queue @ 0.  Starting simulation...
> > warn: Returning zero for read from miscreg pmintenset_el1
> > warn: Returning zero for read from miscreg pmintenclr_el1
> > warn: Returning zero for read from miscreg pmcr_el0
> > warn: Returning zero for read from miscreg pmcntenset_el0
> > warn: Returning zero for read from miscreg pmcntenclr_el0
> > warn: Returning zero for read from miscreg pmovsclr_el0
> > warn: Returning zero for read from miscreg pmswinc_el0
> > warn: Returning zero for read from miscreg pmselr_el0
> > warn: Returning zero for read from miscreg pmccntr_el0
> > warn: Returning zero for read from miscreg pmuserenr_el0
> > warn: Returning zero for read from miscreg pmovsset_el0
> > warn: Returning zero for read from miscreg pmevcntr0_el0
> > warn: Returning zero for read from miscreg pmevcntr1_el0
> > warn: Returning zero for read from miscreg pmevcntr2_el0
> > warn: Returning zero for read from miscreg pmevcntr3_el0
> > warn: Returning zero for read from miscreg pmevcntr4_el0
> > warn: Returning zero for read from miscreg pmevcntr5_el0
> > warn: Returning zero for read from miscreg pmevtyper0_el0
> > warn: Returning zero for read from miscreg pmevtyper1_el0
> > warn: Returning zero for read from miscreg pmevtyper2_el0
> > warn: Returning zero for read from miscreg pmevtyper3_el0
> > warn: Returning zero for read from miscreg pmevtyper4_el0
> > warn: Returning zero for read from miscreg pmevtyper5_el0
> > warn: Returning zero for read from miscreg pmccfiltr_el0
> > warn: SCReg: Access to unknown device dcc0:site0:pos0:fn7:dev0
> > 1152383696405000: system.terminal: attach terminal 0
> >
> >
> > command line: ./build/ARM/gem5.opt configs/example.fs.py
> > --cpu-type=ArmV8KvmCPU--
> kernel=/home/tracy/gem5/fs_image_arm/binaries/
> > vmlinux.vexpress_gem5_v1_64.20170616
> > --disk=/home/tracy/gem5/fs_image_arm/disks/linaro-minimal-aarch64.img
> >
> >
> > Host CPU Architecture: ARMV8
> >
> > Host OS: ubuntu 18.04.4
> > _______________________________________________
> > 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
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

Reply via email to