qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: qemu-devel@nongnu.org, Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH 2/7] target/riscv: env->misa_mxl is a constant
Date: Thu, 6 Mar 2025 14:00:04 +0100	[thread overview]
Message-ID: <ab9b6720-cb48-4b8f-9059-2856c78b5577@redhat.com> (raw)
In-Reply-To: <CAKmqyKMdUONoXD69m3RH1PeoLLtL8qT-eXweVh9WHEZM5Feufg@mail.gmail.com>

On 3/6/25 02:16, Alistair Francis wrote:
> On Wed, Feb 19, 2025 at 3:01 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> There is nothing that overwrites env->misa_mxl, so it is a constant.  Do
> 
> The idea is that misa_mxl can change, although that's not supported now.

At run-time, or only at configuration time (before realize)?

>> not let a corrupted migration stream change the value; changing misa_mxl
> 
> Does this actually happen? If the migration data is corrupted won't we
> have all sorts of strange issues?

Generally migration data (just like disk image formats) is treated as 
security-sensitive, overriding any other considerations.  So you have to 
assume that the corruption is intentional, and sneaky enough to cause 
trouble.

Paolo

> Alistair
> 
>> would have a snowball effect on, for example, the valid VM modes.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   target/riscv/machine.c | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/target/riscv/machine.c b/target/riscv/machine.c
>> index d8445244ab2..c3d8e7c4005 100644
>> --- a/target/riscv/machine.c
>> +++ b/target/riscv/machine.c
>> @@ -375,6 +375,18 @@ static const VMStateDescription vmstate_ssp = {
>>       }
>>   };
>>
>> +static bool riscv_validate_misa_mxl(void *opaque, int version_id)
>> +{
>> +    RISCVCPU *cpu = RISCV_CPU(opaque);
>> +    CPURISCVState *env = &cpu->env;
>> +    RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
>> +    uint32_t misa_mxl_saved = env->misa_mxl;
>> +
>> +    /* Preserve misa_mxl even if the migration stream corrupted it  */
>> +    env->misa_mxl = mcc->misa_mxl_max;
>> +    return misa_mxl_saved == mcc->misa_mxl_max;
>> +}
>> +
>>   const VMStateDescription vmstate_riscv_cpu = {
>>       .name = "cpu",
>>       .version_id = 10,
>> @@ -394,6 +406,7 @@ const VMStateDescription vmstate_riscv_cpu = {
>>           VMSTATE_UINTTL(env.priv_ver, RISCVCPU),
>>           VMSTATE_UINTTL(env.vext_ver, RISCVCPU),
>>           VMSTATE_UINT32(env.misa_mxl, RISCVCPU),
>> +        VMSTATE_VALIDATE("MXL must match", riscv_validate_misa_mxl),
>>           VMSTATE_UINT32(env.misa_ext, RISCVCPU),
>>           VMSTATE_UNUSED(4),
>>           VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU),
>> --
>> 2.48.1
>>
>>
> 
> 



  reply	other threads:[~2025-03-06 13:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18 16:57 [PATCH 0/7] target/riscv: store max SATP mode as a single integer in RISCVCPUConfig Paolo Bonzini
2025-02-18 16:57 ` [PATCH 1/7] hw/riscv: acpi: only create RHCT MMU entry for supported types Paolo Bonzini
2025-03-06  1:13   ` Alistair Francis
2025-03-06 12:11     ` Paolo Bonzini
2025-02-18 16:57 ` [PATCH 2/7] target/riscv: env->misa_mxl is a constant Paolo Bonzini
2025-03-06  1:16   ` Alistair Francis
2025-03-06 13:00     ` Paolo Bonzini [this message]
2025-03-07  0:44       ` Alistair Francis
2025-03-10 17:34         ` Paolo Bonzini
2025-03-10 22:18           ` Alistair Francis
2025-03-11  6:17             ` Paolo Bonzini
2025-03-19  1:35               ` Alistair Francis
2025-02-18 16:57 ` [PATCH 3/7] target/riscv: assert argument to set_satp_mode_max_supported is valid Paolo Bonzini
2025-03-06  1:23   ` Alistair Francis
2025-02-18 16:57 ` [PATCH 4/7] target/riscv: cpu: store max SATP mode as a single integer Paolo Bonzini
2025-03-06  1:30   ` Alistair Francis
2025-03-06  2:57   ` Alistair Francis
2025-02-18 16:57 ` [PATCH 5/7] target/riscv: update max_satp_mode based on QOM properties Paolo Bonzini
2025-03-06  1:41   ` Alistair Francis
2025-02-18 16:57 ` [PATCH 6/7] target/riscv: remove supported from RISCVSATPMap Paolo Bonzini
2025-03-06  2:39   ` Alistair Francis
2025-02-18 16:57 ` [PATCH 7/7] target/riscv: move satp_mode.{map,init} out of CPUConfig Paolo Bonzini
2025-03-06  2:42   ` [PATCH 7/7] target/riscv: move satp_mode.{map, init} " Alistair Francis

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=ab9b6720-cb48-4b8f-9059-2856c78b5577@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).