From: Richard Henderson <richard.henderson@linaro.org>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Bin Meng <bmeng.cn@gmail.com>
Cc: Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Andrew Jones <ajones@ventanamicro.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-riscv@nongnu.org, qemu-devel@nongnu.org,
kvm-riscv@lists.infradead.org
Subject: Re: [PATCH v2 1/1] target/riscv: enable floating point unit
Date: Thu, 3 Oct 2024 11:40:12 -0700 [thread overview]
Message-ID: <ec6ed202-f67c-402a-9abc-19c31f03ec8d@linaro.org> (raw)
In-Reply-To: <20240925061704.12440-1-heinrich.schuchardt@canonical.com>
On 9/24/24 23:17, Heinrich Schuchardt wrote:
> The status and mstatus CSRs contain bit field FS, which control if the
> floating point unit of RISC-V hart is enabled.
>
> There seems to be no specification prescribing the value of the field when
> entering S-mode from M-mode. But OpenSBI, as the leading SBI M-mode
> firmware, has set a precedent by enabling the FPU by setting the value of
> FS to 3 (dirty).
>
> In TCG mode, QEMU uses OpenSBI by default. Users can reasonably expect that
> software running QEMU in TCG mode and in KVM mode behaves similarly.
>
> When QEMU in KVM mode creates a vCPU, Linux' KVM code sets FS=1 (initial)
> in kvm_riscv_vcpu_fp_reset(). However, QEMU internally keeps a value of
> FS=0 (off) and then synchronizes this value into KVM. Thus VS-mode software
> is invoked with a disabled floating point unit.
This suggests that qemu is incorrectly syncing the registers from kvm at vcpu startup.
> + if (riscv_has_ext(env, RVF) || riscv_has_ext(env, RVD)) {
> + env->mstatus = set_field(env->mstatus, MSTATUS_FS, env->misa_mxl);
Storing misa_mxl here is wrong. That's '1' for rv32 and '2' for rv64.
You want a single constant value, either '1' (initial) or '2' (clean).
From the kvm source, initial seems preferable.
r~
prev parent reply other threads:[~2024-10-03 18:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-25 6:17 [PATCH v2 1/1] target/riscv: enable floating point unit Heinrich Schuchardt
2024-09-25 11:06 ` Andrew Jones
2024-10-03 18:40 ` Richard Henderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec6ed202-f67c-402a-9abc-19c31f03ec8d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=heinrich.schuchardt@canonical.com \
--cc=kvm-riscv@lists.infradead.org \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).