All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: Ricardo Koller <ricarkol@google.com>,
	kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	andrew.jones@linux.dev, pbonzini@redhat.com,
	alexandru.elisei@arm.com, eric.auger@redhat.com,
	yuzenghui@huawei.com
Subject: Re: [PATCH 4/4] KVM: selftests: aarch64: Test read-only PT memory regions
Date: Wed, 25 Jan 2023 12:26:01 +0000	[thread overview]
Message-ID: <864jsen6li.wl-maz@kernel.org> (raw)
In-Reply-To: <Y9A3kVCnVgl+x5UJ@thinky-boi>

On Tue, 24 Jan 2023 19:54:57 +0000,
Oliver Upton <oliver.upton@linux.dev> wrote:
> 
> On Tue, Jan 24, 2023 at 08:26:02AM -0800, Ricardo Koller wrote:
> > On Mon, Jan 23, 2023 at 11:36:52PM +0000, Oliver Upton wrote:
> > > On Tue, Jan 10, 2023 at 02:24:32AM +0000, Ricardo Koller wrote:
> > > > Extend the read-only memslot tests in page_fault_test to test read-only PT
> > > > (Page table) memslots. Note that this was not allowed before commit "KVM:
> > > > arm64: Fix handling of S1PTW S2 fault on RO memslots" as all S1PTW faults
> > > > were treated as writes which resulted in an (unrecoverable) exception
> > > > inside the guest.
> > > 
> > > Do we need an additional test that the guest gets nuked if TCR_EL1.HA =
> > > 0b1 and AF is clear in one of the stage-1 PTEs?
> > > 
> > 
> > That should be easy to add. The only issue is whether that's also a case
> > of checking for very specific KVM behavior that could change in the
> > future.
> 
> From the perspective of the guest I believe this to match the
> architecture. An external abort is appropriate if the hardware update to
> a descriptor failed.
> 
> I believe that the current implementation of this in KVM is slightly
> wrong, though. AFAICT, we encode the abort with an FSC of 0x10, which
> indicates an SEA occurred outside of a table walk. The other nuance of
> reporting SEAs due to a TTW is that the FSC encodes the level at which
> the external abort occurred. Nonetheless, I think we can hide behind
> R_BGPQR of DDI0487I.a and always encode a level of 0:
> 
> """
>   If a synchronous External abort is generated due to a TLB or
>   intermediate TLB caching structure, including parity or ECC errors,
>   then all of the following are permitted:
>    - If the PE cannot precisely determine the translation stage at which
>      the error occurred, then it is reported and prioritized as a stage 1
>      fault.
>    - If the PE cannot precisely determine the lookup level at which the
>      error occurred, then the lookup level is reported and prioritized
>      as one of the following:
>      - The lowest-numbered lookup level that could have caused the error.
>      - If the PE cannot determine any information about the lookup level,
>      then level 0.
> """
> 
> Thoughts?

Indeed, the abort injection has always been on the dodgy side of
things. I remember Christoffer and I writing this, saying that it was
something we'd have to eventually fix. 10 years down the line, this
code is, unsurprisingly, still dodgy.

My vote would be to slightly extend the API to take a set of
KVM-specific flags to give context to the injection helpers (such as
SEA during a TTW), and bring the KVM behaviour in line with the
architecture.

Reporting 0 in the FSC is probably OK, but we should also be able to
determine which level this fails at:

- Sample FAR_EL2[55] to derive which TTBR this translates from (n)
- From TCR_EL1.{TnSZ,TGn}, you can determine the number of levels

There is a bunch of tables for this in the ARM ARM, and it is possible
to come up with a decent formula that encompass all the possible
combinations.

But as I said, 0 is probably fine... ;-)

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2023-01-25 12:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10  2:24 [PATCH 0/4] KVM: selftests: aarch64: page_fault_test S1PTW related fixes Ricardo Koller
2023-01-10  2:24 ` [PATCH 1/4] KVM: selftests: aarch64: Relax userfaultfd read vs. write checks Ricardo Koller
2023-01-23 23:07   ` Oliver Upton
2023-01-24 16:17     ` Ricardo Koller
2023-01-24 18:40       ` Oliver Upton
2023-01-10  2:24 ` [PATCH 2/4] KVM: selftests: aarch64: Do not default to dirty PTE pages on all S1PTWs Ricardo Koller
2023-01-10  2:24 ` [PATCH 3/4] KVM: selftests: aarch64: Fix check of dirty log PT write Ricardo Koller
2023-01-10  2:24 ` [PATCH 4/4] KVM: selftests: aarch64: Test read-only PT memory regions Ricardo Koller
2023-01-23 23:36   ` Oliver Upton
2023-01-24 16:26     ` Ricardo Koller
2023-01-24 19:54       ` Oliver Upton
2023-01-25 12:26         ` Marc Zyngier [this message]
2023-01-25 14:02           ` Ricardo Koller
2023-01-25 14:14             ` Marc Zyngier
2023-01-23 23:41 ` [PATCH 0/4] KVM: selftests: aarch64: page_fault_test S1PTW related fixes Oliver Upton
2023-01-23 23:43   ` Oliver Upton
2023-01-24 16:16     ` Ricardo Koller

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=864jsen6li.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=eric.auger@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=ricarkol@google.com \
    --cc=yuzenghui@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.