Commit Graph

14595 Commits

Author SHA1 Message Date
Hoa Nguyen
f615ee4cd4 arch-riscv: Fix generateDisassembly for Store with 1 source reg
Currently, store instructions are assumed to have two source registers.
However, since we are supporting the RISC-V CMO instructions, which
are Store instructions in gem5 but they only have one source register.
This change allows printing disassembly of Store instructions with
one source register.

Change-Id: I4dd7818c9ac8a89d5e10e77db72248942a25e938
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-30 21:44:18 +00:00
Hoa Nguyen
2521ba0664 arch-riscv: Fix implementation of CMO extension instructions
This change introduces a template for store instruction's mem access.
The new template is called CacheBlockBasedStore.

The reasons for not reusing the current Store's mem access template
are as follows,
- The CMO extension instructions operate on cache block size granularity,
while regular load/store instructions operate on data of size 64 bits or
fewer.
- The writeMemAtomicLE/writeMemTimingLE interfaces do not allow passing
nullptr as data. However, CPUs in gem5 rely on (data == NULL) to detect
CACHE_BLOCK_ZERO instructions. Setting `Mem = 0;` to `uint64_t Mem;`
does not solve the problem as the reference is allocated and thus,
it's always true that `&Mem != NULL`. This change uses the
writeMemAtomic/writeMemTiming interfaces instead.
- Per CMO v1.0.1, the instructions in the spec do not generate
address misaligned faults.
- The CMO extension instructions do not use IMM.

Change-Id: I323615639a4ba882fe40a55ed32c7632e0251421
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-30 21:44:18 +00:00
Jason Lowe-Power
d0113185c6 arch-riscv: Dynamically add V extension to device tree (#464)
Currently, we are hardcoding the ISA string in the device tree
generator. The ISA string from the device tree affects which
ISA extensions will be used by the bootloader/kernel.

This function allows generating the ISA string from the gem5's
ISA object rather than using hardcoded values.

This series of changes also correct a couple of hardcoded
RISC-V ISA strings in the standard library, as well as not
enable RVV instructions for the U74 core model.

Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-30 10:29:25 -07:00
Jason Lowe-Power
3d93584900 mem-ruby, stdlib: Far atomics fix (#514)
This PR is fixing https://github.com/gem5/gem5/issues/449 by applying
the following changes

1) Setting up alloc_on_atomic=False in the stdlib
This is directly related to the error message reported by the Issue #449

2) Disabling far atomics in stdlib with policy type = 0
There is an invalid transaction error, likely caused by the fact the
current implementation
is expecting a 2 level cache hierarchy whereas the stdlib example only
allocates one
level of caches (L1). This needs further investigation

3) Explicitly clearing the atomic log
Even by disabling far atomics, the execution of atomicPartial was
populating
the atomic log queue without ever clearing it. This caused the OOM
killer in Linux
to detect the leak and to kill it when the physical resources of the
machine no longer
sufficed. IMHO the atomic log interface should be revamped as atomic
users should
be allocating the atomic log only if explicitly needed
2023-10-30 09:59:49 -07:00
Hoa Nguyen
0218103162 arch-riscv: Correct BootloaderKernelWorkload symbol table (#511)
Currently, the kernel's symbols are shifted by `kernel_paddr_offset`,
which is where the kernel is located in the physcial address space.
However, the symbols are mapped to virtual addresses, which stay the
same even though the physical address space is shifted.

This patch removes the offset for the kernel's symbols virtual
addresses.

Change-Id: I7c35f925777220f56bd8c69bba14c267d2048ade

Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-30 09:56:10 -07:00
Giacomo Travaglini
d131ff488e arch-arm: Set UNCACHEABLE flag in Request in SE mode (#515)
As pointed out by [1], Arm doesn't seem to respect the cacheability
attribute when mapping uncacheable memory. This is because the request
is not tagged as uncacheable during SE translation With this patch we
are checking for the cacheability attribute before finalizing
translation

[1]: https://github.com/gem5/gem5/issues/509

Change-Id: I42df0e119af61763971d5766ae764a540055781b

Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-30 10:43:22 +00:00
Giacomo Travaglini
1087041698 stdlib: Use near atomics in the CHI component nodes
This is a temporary solution to fix daily tests. We could revert
to the default (policy_type = 1) once the problem is properly
fixed

Change-Id: Ia80af9a7d84d5c777ddeb441110a91a1680c1030
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-29 09:26:26 +00:00
Giacomo Travaglini
1b05c0050b mem-ruby: Clear the atomic log from the DataBlock in CHI
The new far atomics implementation [1] didn't take into consideration
it was supposed to manually clear the atomic log. This caused a
memory leak where the log queue was getting bigger and bigger
as no cleaning was happening

[1]: https://github.com/gem5/gem5/pull/177

Change-Id: I4a74fbf15d21e35caec69c29117e2d98cc86d5ff
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-29 09:26:09 +00:00
Giacomo Travaglini
e496d29171 stdlib: Explicitly set alloc_on_atomic for the CHI example
gem5 will otherwise fatal with the error message:

fatal: ... alloc_on_atomic without default or user set value

See github issue [1] for further details

[1]: https://github.com/gem5/gem5/issues/449

Change-Id: I0bb8fccf0ac6d60fc6c1229436a35e91b2fb45cd
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-29 09:25:49 +00:00
Roger Chang
e561f3b6f1 arch-riscv: Move insts/vector from header to source
Move the implemention of following classes
- VMaskMergeMicroInst
- VxsatMicroInst

Change-Id: I42ec45681064a0f599c3b2313c2125da7cfc849b
2023-10-26 18:04:58 +08:00
Roger Chang
62af678d5c arch-riscv: Move VArith implementations from header to source
Move VArith implementations from heaher_output to decoder_output
and exec_output respectively

Change-Id: I406eedbd9dd625aa939ec0e20aa29ef4f18ba79c
2023-10-26 18:04:58 +08:00
Roger Chang
605ec6899e arch-riscv: Move VMem implementation from header to source
Move the VMem implementation from header_output to
decoder_output and exec_output respectively.

Change-Id: I699e197f37f22a59ecb9f92a64b5e296d2e9f5fa
2023-10-26 18:04:58 +08:00
Andreas Sandberg
60290c7c2f cpu: Branch Predictor Refactoring (#455)
Major refactoring of the branch predictor unit.
- Clearer control flow of the main branch predictor
- Remove `uncondBranch` and `btbUpdate` functions in favor
  of a common `historyUpdate` function. There is now only
  one lookup function for conditional branches and the new
  `historyUpdate` for speculative history update.
- Added a new *target provider* class.
- More expressive statistics depending on the different branch
  types.
- Cleanup the branch history management
2023-10-26 09:15:11 +01:00
Hoa Nguyen
50196863a4 stdlib,dev: Fix several hardcoded RISC-V ISA strings
The "s" and "u" letters are not recognized by the Linux kernel as
RISC-V extensions [1].

[1] https://elixir.bootlin.com/linux/v6.5.7/source/arch/riscv/kernel/cpufeature.c#L170

Change-Id: I2a99557482cde6e6d6160626b3995275c41b1577
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-25 20:12:57 +00:00
Hoa Nguyen
dce8d07703 stdlib: Turn off RVV for U74 core
The U74 core doesn't support vector instructions.

Change-Id: Iadfb6b43ef8c62dcad23391e468a43b908e4a22c
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-25 20:12:57 +00:00
Hoa Nguyen
4f72f6172a stdlib: Use the ISA string generator in the RiscvBoard
Current hardcoded value does not support vector instructions.
The new ISA string generator function allows the flexibility
of using or not using the vector extension.

Change-Id: Ic78c4b6629ad3813fc172f700d77ea956552e613
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-25 20:12:57 +00:00
Hoa Nguyen
a47ca9dadc arch-riscv: Add a function generating the ISA string
Currently, we are hardcoding the ISA string in the device tree
generator. The ISA string from the device tree affects which
ISA extensions will be used by the bootloader/kernel.

This function allows generating the ISA string from the gem5's
ISA object rather than using hardcoded values.

Change-Id: I2f3720fb6da24347f38f26d9a49939484b11d3bb
Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-25 20:12:55 +00:00
David Schall
ccbb85c67f cpu: Branch Predictor Refactoring
Major refactoring of the branch predictor unit.
- Clearer control flow of the main branch predictor
- Remove `uncondBranch` and `btbUpdate` functions in favour of a
  common `historyUpdate` function. There is now only one lookup
  function for conditional branches and the new `historyUpdate` for
  speculative history update.
- Added a new *target provider* class.
- More expressive statistics depending on the different branch types.
- Cleanup the branch history management

Change-Id: I21fa555b5663e4abad7c836fc1d41a9c8b205263
Signed-off-by: David Schall <david.schall@ed.ac.uk>
2023-10-24 18:53:20 +00:00
Giacomo Travaglini
6ddf8c94ee arch-arm: Fix KVM Failed to set register (0x603000000013808c) (#486)
Some debug registers were incorrectly tagged
(e.g. as being writeable). This was causing a bug in some gem5-KVM runs
where gem5 was trying to initialize the state of those registers
(OSLSR_EL1) [1] but KVM was returning an error (as the registers were
RO).

[1]: https://github.com/gem5/gem5/blob/stable/\
    src/arch/arm/kvm/armv8_cpu.cc#L408
2023-10-20 11:30:19 -07:00
Boris Shingarov
8b78e87f1b misc: Integrate a Capstone Disassembler in gem5 (#494)
Capstone is an open source disassembler [1] already used by
other projects (like QEMU).

gem5 is already capable of disassembling instructions.  Every StaticInst
is supposed to define a generateDisassembly method which returns the
instruction mnemonic (opcode + operand list) as a string.

This "distributed" implementation of a disassembler relies
on the developer to properly populate the metadata fields
of the base instruction class.
The growing complexity of the ISA code and the massive reuse
of base classes beyond their intended use has led to a
disassembling logic which contains several bugs.

By allowing a tracer to rely on a third party disassembler, we fill the
instruction trace with a more trustworthy instruction stream.

This will make any trace parsing tool to work better and it will
also allow us to spot/fix our own bugs by comparing instruction
traces with native vs custom disassembler

[1]: http://www.capstone-engine.org/
2023-10-20 13:47:23 -04:00
Giacomo Travaglini
8233aa8a9b arch-arm: Implement a CapstoneDisassembler for Arm
Change-Id: Id3135bda065efa9b4f3ab36972957fd00c05a53c
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:51 +01:00
Giacomo Travaglini
82675648c8 cpu: Implement a CapstoneDisassembler
Capstone is an open source disassembler [1] already used by
other projects (like QEMU).

gem5 is already capable of disassembling instructions.  Every StaticInst
is supposed to define a generateDisassembly method which returns the
instruction mnemonic (opcode + operand list) as a string.

This "distributed" implementation of a disassembler relies
on the developer to properly populate the metadata fields
of the base instruction class.
The growing complexity of the ISA code and the massive reuse
of base classes beyond their intended use has led to a
disassembling logic which contains several bugs.

By allowing a tracer to rely on a third party disassembler, we fill the
intruction trace with a more trustworthy instruction stream.

This will make any trace parsing tool to work better and it will
also allow us to spot/fix our own bugs by comparing instruction
traces with native vs custom disassembler

[1]: http://www.capstone-engine.org/

Change-Id: I3c4db5072c03d2731265d0398d3863c101dcb180
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:51 +01:00
Giacomo Travaglini
34336208b7 arch-arm: Disassemble through InstDisassembler in TarmacTracer
Change-Id: I5407338501084c016522749be697dd688ca51735
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:51 +01:00
Giacomo Travaglini
27ce721ad3 arch-arm: Pass a reference of the parent tracer to TarmacContext
Change-Id: I7ab0442353a8b5854bb6b50bd54dac89f83ecc1d
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:51 +01:00
Giacomo Travaglini
81b6e296dd arch-arm: disassemble member variable not used by TarmacParser
We move it to the child class which is what the TarmacTracer
actually uses.

Change-Id: Ia30892723d2e1f7306dae87c6c9c1d69d00ad73d
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:50 +01:00
Giacomo Travaglini
237bbf0e42 cpu: Disassemble through the InstDisassembler in the ExeTracer
Change-Id: I4a0c585b9b8824a0694066bef0ee004f68407111
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:50 +01:00
Giacomo Travaglini
952c4f5eea cpu: Pass a reference of the parent tracer to the ExeTracerRecord
Change-Id: I3576df2b7bee1289db60bb6072bd9c90038ca8ce
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:50 +01:00
Giacomo Travaglini
2d85707a75 sim: Define an InstructionDisassembler SimObject
We want to be able to configure from python the disassembler
used by an instruction tracer. The default/base version will
reuse existing instruction logic and it will simply
call the StaticInst::disassemble method.

Change-Id: Ieb16f059a436757c5892dcc82882f6d42090927f
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
2023-10-20 09:27:50 +01:00
Roger Chang
069baed971 scons: Explicit the config option HAVE_PROTOBUF type boolean
Ensure the type of HAVE_PROTOBUF is boolean

Change-Id: I9cf18c52ac290000168f5228b7f4ba3621225a85
2023-10-20 11:46:02 +08:00
Roger Chang
fe20f4ada6 scons: Explicit the config option HAVE_DEPRECATED_NAMESPACE type bool
Currently the type of HAVE_DEPRECATED_NAMESPACE is used to detect
if the compiler support gnu::deprecated feature. The return type
of conf.TryCompile is int, but HAVE_DEPRECATED_NAMESPACE is used
as boolean type. The CL is add bool type caster to ensure the type
of it is boolean.

Change-Id: Ife7d9716e485a8be8722d58776f064e7c2268a30
2023-10-20 11:41:53 +08:00
Alvaro Moreno
edf1d69257 arch-riscv: Define vlwhole/vswhole mem acceses using vlen.
This patch fixes the size of the memory acceses in vswhole and
vlwhole instructions to the maximum vector length.

Change-Id: Ib86b5356d9f1dfa277cb4b367893e3b08242f93e
2023-10-19 00:27:58 +02:00
Alvaro Moreno
52219e5e6f arch-riscv: Add elen configuration to vector config instructions
This patch adds elen as a member of vector configuration instructions so it can be used with the especulative execution

Change-Id: Iaf79015717a006374c5198aaa36e050edde40cee
2023-10-19 00:27:58 +02:00
Alvaro Moreno
2c9fca7b60 arch-riscv: Add vlen configuration to vector instructions
In first place, vlen is added as a member of Vector Macro Instructions
where it is needed to split the instruction in Micro Instructions.

Then, new PCState methods are used to get dynamic vlen and vlenb
values at execution.

Finally, vector length data types are fixed to 32 bits so every vlen value
is considered.

Change-Id: I5b8ceb0d291f456a30a4b0ae2f58601231d33a7a
2023-10-19 00:27:58 +02:00
Alvaro Moreno
8a20f20f79 arch-riscv: Add vlen component to decoder state
This patch add vlen definition to the riscv decoder so it can be used in Vector Instruction Constructors

Change-Id: I52292bc261c43562b690062b16d2b323675c2fe0
2023-10-19 00:27:58 +02:00
Alvaro Moreno
5d97cb8b0b arch-riscv: Define VLEN and ELEN through the ISA object
This commit define VLEN and ELEN values as parameters of the RiscvISA class.

Change-Id: Ic5b80397d316522d729e4db4f906aa189f27a491
2023-10-19 00:27:58 +02:00
Alvaro Moreno
57e0ba7765 arch-riscv: Define VecRegContainer with maximum expected length
This path redefine VecRegContainer for RISCV so it can hold every VLEN + ELEN possible configuration used at execution time

Change-Id: Ie6abd01a1c4ebe9aae3d93f4e835fcfdc4a82dcd
2023-10-19 00:27:58 +02:00
Hoa Nguyen
c3acfdc9b8 arch-riscv: Copy Misc Regs when swiching cpus (#479)
Misc Regs might contain rather important information about the state of
a core, e.g., information in CSR registers.

This patch enforces copying the CSR registers when switching cpus. The
bug and the proposed fix are reported here [1].

[1] https://github.com/gem5/gem5/issues/451

Change-Id: I611782e6e3bcd5530ddac346342a9e0e44b0f757

Signed-off-by: Hoa Nguyen <hn@hnpl.org>
2023-10-18 10:51:37 -07:00
Harshil Patel
7bd0b99635 tests: Changed percent atomics to 0 in memtest to fix daily test (#477) 2023-10-18 10:09:45 -07:00
Bobby R. Bruce
334df18dce arch-riscv: Add bootloader+kernel workload (#390)
Aims to boot OpenSBI + Linux kernel.
2023-10-18 09:17:12 -07:00
Andreas Sandberg
42d1c8b3c3 cpu: Restructure RAS (#428) 2023-10-17 19:14:13 +01:00
David Schall
5387e67114 cpu: Restructure RAS
The return address stack (RAS) is restructured to be a separate SimObject.
This enables disabling the RAS and better separation of the functionality.
Furthermore, easier statistics and debugging.

Change-Id: I8aacf7d4c8e308165d0e7e15bc5a5d0df77f8192
Signed-off-by: David Schall <david.schall@ed.ac.uk>
2023-10-17 15:30:56 +00:00
Bobby R. Bruce
adb5470996 arch-arm: Fix (other) line-length errors (#468)
https://github.com/gem5/gem5/pull/459 missed a couple.
This commit should complete the task.
2023-10-16 17:47:46 -07:00
Bobby R. Bruce
aaefda3b08 arch-arm: Fix line-length error in branch64.is
Change-Id: I62c5d5fd47927a838e6731a464fc7e6d8afab768
2023-10-16 10:57:03 -07:00
Hoa Nguyen
d048ad34d6 arch-riscv: Change to VS bits to DIRTY for rvv insts changing vregs (#376)
This is similar to [1] and [2].

Essentially, the VS bits of STATUS CSR keep track of the state of
the vector registers. (VS bits == DIRTY) means the content of vector
registers have been updated since the last time the VS bits were
updated.

This chain of changes is supposed to change the VS bits to DIRTY for if
any
vector register is potentially updated.

[1] https://gem5-review.googlesource.com/c/public/gem5/+/65272
[2] https://github.com/gem5/gem5/pull/370

Change-Id: I0427890dadc63b74a470d7405807dcfcad18005b
2023-10-16 10:07:40 -07:00
Hoa Nguyen
9b2b6cd8d2 arch-riscv: Mark vector configuration insts as vector insts (#463) 2023-10-16 09:40:09 -07:00
Bobby R. Bruce
a9464a41f5 stdlib,resources: Generalize exception for request retry (#466)
In commit bbc301f2f0 the generalized
`Exception` was changed back to the more specific `HTTPError`.

In this case we do not desire specific error handling. If the connection
to the database fails I want the exception handled in the way outlined:
i.e., i want the connection to be retried 4 times before giving up. With
`HTTPError`, only `HTTPError`s warrent a retry.

Changing this to `HTTPError` cause tests to fail due to a failure to
retry downloading of a resource. Here is an example:
https://github.com/gem5/gem5/actions/runs/6521543885/job/17710779784

In this case `request.urlopen` raised a `URLError`. I suspect this was
some issued to do with reaching the DNS servers. It likely would've
succeeded if it had just tried again.
2023-10-16 09:39:44 -07:00
Bobby R. Bruce
322b105b9d arch-arm: Fix (another) line-length error in misc.cc
https://github.com/gem5/gem5/pull/459 missed one.
This commit should complete the task.

Change-Id: I0aeba79d6f13ddc45effe141945f5636b75daecc
2023-10-16 09:37:51 -07:00
Bobby R. Bruce
97f4b44dd3 arch-arm: Fix line-length error in misc.cc (#459) 2023-10-16 08:35:54 -07:00
Giacomo Travaglini
f9cf8bf8a2 cpu, arch-arm: Add IsPseudo tag for gem5 pseudo instructions (#465)
This only applies to pseudo instructions with their own encoding (m5
ops)... In other
words memory mapped m5 operations are not supported. This make sense as
they should
rather be treated as device accesses... Though it is something to take
into consideration
when relying on the flag
2023-10-16 16:15:05 +01:00
Bobby R. Bruce
d42eeb6b68 cpu: Explicitly define cache_line_size -> 64-bit unsigned int (#329)
While it's plausible to define the cache_line_size as a 32-bit unsigned
int, the use of cache_line_size is way out of its original scope.

cache_line_size has been used to produce an address mask, which masking
out the offset bits from an address. For example, [1], [2], [3], and
[4]. However, since the cache_line_size is an "unsigned int", the type
of the value is not guaranteed to be 64-bit long. Subsequently, the bit
twiddling hacks in [1], [2], [3], and [4] produce 32-bit mask, i.e.,
0x00000000FFFFFFC0.

This behavior at least caused a problem in LLSC in RISC-V [5], where the
load reservation (LR) relies on the mask to produce the cache block
address. Two distinct 64-bit addresses can be mapped to the same cache
block using the above mask.

This patch explicitly defines cache_line_size as a 64-bit unsigned int
so the cache block mask can be produced correctly for 64-bit addresses.

[1]
3bdcfd6f7a/src/cpu/simple/atomic.hh (L147)
[2]
3bdcfd6f7a/src/cpu/simple/timing.hh (L224)
[3]
3bdcfd6f7a/src/cpu/o3/lsq_unit.cc (L241)
[4]
3bdcfd6f7a/src/cpu/minor/lsq.cc (L1425)
[5]
3bdcfd6f7a/src/arch/riscv/isa.cc (L787)
2023-10-16 07:50:35 -07:00