qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Ricky Zhou <ricky@rzhou.org>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, eduardo@habkost.net
Subject: Re: [PATCH 1/1] target/i386: Raise #GP on unaligned m128 accesses when required.
Date: Mon, 29 Aug 2022 15:54:04 -0700	[thread overview]
Message-ID: <fda2702b-5bf2-91c4-3a96-5a51e9438e20@linaro.org> (raw)
In-Reply-To: <CAFoVXjgHBPs8XhOqLN9BpD1-GN7Amsor5o660WOmBdQ54dxW5w@mail.gmail.com>

On 8/29/22 13:46, Ricky Zhou wrote:
> Thanks for taking a look at this - did you see the bit in the cover
> letter where I discuss doing this via alignment requirements on the
> memory operation? My logic was that the memop alignment checks seem to
> be more oriented towards triggering #AC exceptions (even though this is
> not currently implemented),

I missed that in the cover.  However... implementing #AC is pretty hypothetical.  It's not 
something that I've ever seen used, and not something that anyone has asked for.

> One slightly more involved way to use alignment on the MemOp could be to
> arrange to pass the problematic MemOp to do_unaligned_access and
> helper_unaligned_{ld,st}. Then we could allow CPUs to handle
> misalignment of different MemOps differently (e.g. raise #GP/SIGSEGV for
> certain ops and #AC/SIGBUS for others). For this change to x86, we could
> maybe get away with making MO_ALIGN_16 and above trigger #GP/SIGSEGV and
> everything else trigger #AC/SIGBUS. If that's a little hacky, we could
> instead add some dedicated bits to MemOp that distinguish different
> types of unaligned accesses.

There's another related problem that actually has gotten a bug report in the past: when 
the form of the address should raise #SS instead of #GP in system mode.

My initial thought was to record information about "the" memory access in the per-insn 
unwind info, until I realized that there are insns with  multiple memory operations 
requiring different treatment.  E.g. "push (%rax)", where the read might raise #GP and the 
write might raise #SS.  So I think we'd need to encode #GP vs #SS into the mmu_idx used 
(e.g. in the lsb).

However, I don't think there are any similar situations of multiple memory types affecting 
SSE, so #AC vs #GP could in fact be encoded into the per-insn unwind info.

As for SIGBUS vs SIGSEGV for SSE and user-only, you only need implement the 
x86_cpu_ops.record_sigbus hook.  C.f. the s390x version which raises PGM_SPECIFICATION -> 
SIGILL for unaligned atomic operations.


r~


      reply	other threads:[~2022-08-29 22:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-29 14:23 [PATCH 0/1] target/i386: Raise #GP on unaligned m128 accesses when required Ricky Zhou
2022-08-29 14:23 ` [PATCH 1/1] " Ricky Zhou
2022-08-29 16:45   ` Richard Henderson
2022-08-29 20:46     ` Ricky Zhou
2022-08-29 22:54       ` 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=fda2702b-5bf2-91c4-3a96-5a51e9438e20@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ricky@rzhou.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).