mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/riscv: use ~0 instead of ULONG_MAX to disable the VS-timer
vstimecmp is a 64-bit CSR independently of XLEN, which is why it is
written with csr_write64(). On RV32 that macro splits the value into
the vstimecmp/vstimecmph pair, so passing ULONG_MAX (0xffffffff there)
writes all ones to the low half and zero to the high half, leaving the
CSR at 0x00000000ffffffff rather than at its maximum. A VS-timer irq
would then become pending as soon as (time + htimedelta) reaches 2^32,
which is exactly what the code is trying to avoid.
Use ~0 instead: csr_write64() converts its argument to uint64_t, and the
conversion of the signed -1 sign-extends to all ones, so both halves get
0xffffffff. On RV64 the result is equal to ULONG_MAX, so no functional
change there.
Fixes: 25e0327306 ("xen/riscv: allow Xen to use SSTC while hiding it from guests")
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Reviewed-by: Baptiste Le Duc <baptiste.le-duc@vates.tech>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
9157d62632
commit
a92d2ba89b
1 file changed
+2
-2
@@ -101,8 +101,8 @@ void __init preinit_xen_time(void)
|
|||||||
* A VS-timer interrupt becomes pending whenever the value of
|
* A VS-timer interrupt becomes pending whenever the value of
|
||||||
* (time + htimedelta) is greater than or equal to vstimecmp CSR.
|
* (time + htimedelta) is greater than or equal to vstimecmp CSR.
|
||||||
* Thereby to avoid spurious VS-timer irqs set vstimecmp CSR to
|
* Thereby to avoid spurious VS-timer irqs set vstimecmp CSR to
|
||||||
* ULONG_MAX.
|
* ~0.
|
||||||
*/
|
*/
|
||||||
csr_write64(CSR_VSTIMECMP, ULONG_MAX);
|
csr_write64(CSR_VSTIMECMP, ~0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||