<feed xmlns='http://www.w3.org/2005/Atom'>
<title>opensbi.git/lib/sbi, branch v1.1</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/opensbi.git/atom/lib/sbi?h=v1.1</id>
<link rel='self' href='http://cgit.235523.xyz/opensbi.git/atom/lib/sbi?h=v1.1'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/'/>
<updated>2022-06-25T03:14:20Z</updated>
<entry>
<title>lib: pmu: allow to use the highest available counter</title>
<updated>2022-06-25T03:14:20Z</updated>
<author>
<name>Sergey Matyukevich</name>
<email>geomatsi@gmail.com</email>
</author>
<published>2022-06-24T11:03:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=3f66465fb6bf0aea99f7dbe5801996dec9605d3c'/>
<id>urn:sha1:3f66465fb6bf0aea99f7dbe5801996dec9605d3c</id>
<content type='text'>
OpenSBI explicitly assumes that there is no pmu hardware counter with
index 1: hardware uses that bit for TM control. So OpenSBI filters
out that index in sanity checks. However OpenSBI also excludes that
counter when reports total amount of hardware counters to Linux. As
a result, Linux uses incomplete counters mask excluding the highest
available counter.

Return accurate number of counters, update the firmware counter
starting index, fix range checks that include num_hw_ctrs.

The simple test is to make sure that there is no counter multiplexing
in the following command:

$ perf stat -e \
	r8000000000000000,r8000000000000001,r8000000000000002,r8000000000000003, \
	r8000000000000004,r8000000000000005,r8000000000000006,r8000000000000007, \
	r8000000000000008,r8000000000000009,r800000000000000a,r800000000000000b, \
	r800000000000000c,r800000000000000d,r800000000000000e,r800000000000000f  \
	ls

Note that 16 firmware events with 16 counters won't require multiplexing.

Signed-off-by: Sergey Matyukevich &lt;geomatsi@gmail.com&gt;
Signed-off-by: Atish Patra &lt;atishp@rivosinc.com&gt;
Reviewed-by: Atish Patra &lt;atishp@rivosinc.com&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Fix tval and tinst for sbi_get_insn()</title>
<updated>2022-06-21T03:01:56Z</updated>
<author>
<name>dramforever</name>
<email>dramforever@live.com</email>
</author>
<published>2022-06-09T07:07:31Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=a07402ac9cea19b3af70ed6469bb6d937132a18f'/>
<id>urn:sha1:a07402ac9cea19b3af70ed6469bb6d937132a18f</id>
<content type='text'>
We should not change trap-&gt;tval to mepc because mtval already points to
the faulting portion of the emulated instruction fetch, which is also
what stval is expected to be.

In addition, htinst is only allowed to be zero for instruction access
faults or page faults, and is only allowed to be zero or a
psuedoinstruction for instruction guest-page faults. Fix trap-&gt;tinst for
these cases.

Signed-off-by: dramforever &lt;dramforever@live.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: Fixup tinst for exceptions in sbi_misaligned_*()</title>
<updated>2022-06-21T03:01:14Z</updated>
<author>
<name>dramforever</name>
<email>dramforever@live.com</email>
</author>
<published>2022-06-09T07:07:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=187127fb89b99790793d4b2663286371b59021ae'/>
<id>urn:sha1:187127fb89b99790793d4b2663286371b59021ae</id>
<content type='text'>
If there is an exception while emulating a misaligned load/store, fixup
uptrap.tinst before redirecting. Otherwise, HS-mode software may receive
an htinst describing the lbu/sb instruction that faulted during
emulation[1].

[1]: https://github.com/riscv-software-src/opensbi/issues/258

Signed-off-by: dramforever &lt;dramforever@live.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_hsm: Assume a consistent resume address</title>
<updated>2022-06-13T06:24:06Z</updated>
<author>
<name>Samuel Holland</name>
<email>samuel@sholland.org</email>
</author>
<published>2022-06-13T01:03:48Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=79e42eb2d646097198aed935042e289e53ff9876'/>
<id>urn:sha1:79e42eb2d646097198aed935042e289e53ff9876</id>
<content type='text'>
The suspend code needs to know the resume address for two reasons:
  1) Programming some hardware register or management firmware. Here we
     assume the hardware/firmware maintains its state between suspends,
     so it only needs to be programmed once at startup.
  2) When a non-retentive suspend request ends up being retentive, due
     to lack of hardware support, pending interrupt, or for some other
     reason. However, the behavior here is not platform-dependent, and
     this can be handled in the generic hart suspend function.

Since neither situation requires the platform-level suspend function to
know the resume address, stop passing it to that function. Instead,
handle the non-retentive to retentive situation generically.

Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_hsm: Call a device hook during hart resume</title>
<updated>2022-06-13T06:24:06Z</updated>
<author>
<name>Samuel Holland</name>
<email>samuel@sholland.org</email>
</author>
<published>2022-06-13T01:03:47Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=b20ed9febe0b78228055ce69d8e3fbb13f64f1cc'/>
<id>urn:sha1:b20ed9febe0b78228055ce69d8e3fbb13f64f1cc</id>
<content type='text'>
Non-retentive suspend states may require platform-specific actions
during resume. For example, firmware may need to save and restore the
values of custom CSRs. Add a hook to support this.

Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_trap: Redirect exception based on hedeleg</title>
<updated>2022-06-13T05:32:49Z</updated>
<author>
<name>dramforever</name>
<email>dramforever@live.com</email>
</author>
<published>2022-06-12T05:57:37Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=adc3388d76af18487d8ba4a53a1d1e83655435f3'/>
<id>urn:sha1:adc3388d76af18487d8ba4a53a1d1e83655435f3</id>
<content type='text'>
HS-mode software can choose what exceptions to delegate to VS-mode using
the hedeleg CSR. Synthetic VS/VU-mode exceptions should also honor
hedeleg. They should be redirected to VS-mode if and only if delegated
by HS-mode.

Signed-off-by: dramforever &lt;dramforever@live.com&gt;
Reviewed-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_illegal_insn: Add emulation for fence.tso</title>
<updated>2022-06-01T11:50:20Z</updated>
<author>
<name>Samuel Holland</name>
<email>samuel@sholland.org</email>
</author>
<published>2022-05-29T18:25:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=cb8271c8e43e3c317436b7377c4fa0ac669f8fb5'/>
<id>urn:sha1:cb8271c8e43e3c317436b7377c4fa0ac669f8fb5</id>
<content type='text'>
While OpenC906 appears to properly decode `fence.tso` as a fence
instruction[1], the version of the C906 taped out in the Allwinner D1
does not, and raises illegal instruction.

Handle this errata by emulating `fence.tso` as `fence rw, rw`.

[1]: https://github.com/T-head-Semi/openc906/blob/30827e7f/C906_RTL_FACTORY/gen_rtl/idu/rtl/aq_idu_id_decd.v#L2097

Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_illegal_insn: Constify illegal_insn_table</title>
<updated>2022-05-30T05:24:31Z</updated>
<author>
<name>Samuel Holland</name>
<email>samuel@sholland.org</email>
</author>
<published>2022-05-29T18:25:29Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=ff65bfec4e4fdef31de0871d03f58ca020d6ada2'/>
<id>urn:sha1:ff65bfec4e4fdef31de0871d03f58ca020d6ada2</id>
<content type='text'>
This table does not need to be modified at runtime.

Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi_timer: Drop unnecessary get_platform_ticks wrapper</title>
<updated>2022-05-30T05:13:03Z</updated>
<author>
<name>Samuel Holland</name>
<email>samuel@sholland.org</email>
</author>
<published>2022-05-29T17:00:48Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=295e5f3c6912bef798e31d6946ba0aacb91f95d0'/>
<id>urn:sha1:295e5f3c6912bef798e31d6946ba0aacb91f95d0</id>
<content type='text'>
The device's timer_value callback is already the right prototype to use
for the get_time_val function pointer.

Signed-off-by: Samuel Holland &lt;samuel@sholland.org&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
<entry>
<title>lib: sbi: fix system_opcode_insn</title>
<updated>2022-05-30T04:52:13Z</updated>
<author>
<name>Xiang W</name>
<email>wxjstz@126.com</email>
</author>
<published>2022-05-26T14:14:44Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/opensbi.git/commit/?id=f067bb84cf2dd6493ff3fa49294d3ec80481ad75'/>
<id>urn:sha1:f067bb84cf2dd6493ff3fa49294d3ec80481ad75</id>
<content type='text'>
If the csr's operation comes from M mode, it should not be forwarded
to low-privilege processing, this patch fixes this problem.

Signed-off-by: Xiang W &lt;wxjstz@126.com&gt;
Reviewed-by: Anup Patel &lt;anup@brainfault.org&gt;
</content>
</entry>
</feed>
