qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Michael Tokarev <mjt@tls.msk.ru>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: Re: [PATCH for-8.2?] target/i386: Fix 32-bit wrapping of pc/eip computation
Date: Mon, 1 Jan 2024 13:00:22 +1100	[thread overview]
Message-ID: <643f1d00-c917-4bb0-a499-ab7edacac3e9@linaro.org> (raw)
In-Reply-To: <f07b02b9-6c6c-40c1-9f21-2a9bd033a5a5@tls.msk.ru>

On 12/25/23 07:49, Michael Tokarev wrote:
> 12.12.2023 20:25, Richard Henderson:
>> In 32-bit mode, pc = eip + cs_base is also 32-bit, and must wrap.
>> Failure to do so results in incorrect memory exceptions to the guest.
>> Before 732d548732ed, this was implicitly done via truncation to
>> target_ulong but only in qemu-system-i386, not qemu-system-x86_64.
>>
>> To fix this, we must add conditional zero-extensions.
>> Since we have to test for 32 vs 64-bit anyway, note that cs_base
>> is always zero in 64-bit mode.
>>
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2022
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>
>> This may be too late for 8.2; if not, then 8.2.1 and 8.1.next.
>> I think I have found all forms of pc <-> eip, but another set
>> of eyes would be appreciated.
> 
> This change breaks trivial 4M edk2 boot - both in 8.2.0 and in
> 8.1.4 (which also has this commit now).
> 
>   qemu-system-x86_64 -machine q35 -no-user-config -nodefaults -display none \
>    -serial stdio \
>    -drive file=/usr/share/OVMF/OVMF_CODE_4M.secboot.fd,if=pflash,format=raw,readonly=on \
>    -drive file=/usr/share/OVMF/OVMF_VARS_4M.ms.fd,if=pflash,format=raw,snapshot=on
> 
> After this change, nothing is printed on the serial console anymore
> (or in vga, whatever). Before that commit, usual edk2 boot sequence
> is seen.
> 
> Nothing has changed with the 2M variant though.

Ack.  Looking at it....


r~



      reply	other threads:[~2024-01-01  2:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12 17:25 [PATCH for-8.2?] target/i386: Fix 32-bit wrapping of pc/eip computation Richard Henderson
2023-12-12 21:06 ` Stefan Hajnoczi
2023-12-12 21:08 ` Paolo Bonzini
2023-12-12 21:22   ` Richard Henderson
2023-12-12 21:23     ` Paolo Bonzini
2023-12-24 20:49 ` Michael Tokarev
2024-01-01  2:00   ` 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=643f1d00-c917-4bb0-a499-ab7edacac3e9@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.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).