<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/arch/arm64/kvm/hyp/exception.c, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-08-28T18:39:48Z</updated>
<entry>
<title>KVM: arm64: Simplify sysreg access on exception delivery</title>
<updated>2025-08-28T18:39:48Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2025-08-17T12:19:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e3f6836a632e6d68201b6bc6e02bda92b00f3f57'/>
<id>urn:sha1:e3f6836a632e6d68201b6bc6e02bda92b00f3f57</id>
<content type='text'>
Distinguishing between NV and VHE is slightly pointless, and only
serves as an extra complication, or a way to introduce bugs, such
as the way SPSR_EL1 gets written without checking for the state
being resident.

Get rid if this silly distinction, and fix the bug in one go.

Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20250817121926.217900-3-maz@kernel.org
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Check for SYSREGS_ON_CPU before accessing the 32bit state</title>
<updated>2025-08-28T18:39:48Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2025-08-17T12:19:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b720269334f55f2e683fbb8f1f065a12f2c72eb6'/>
<id>urn:sha1:b720269334f55f2e683fbb8f1f065a12f2c72eb6</id>
<content type='text'>
Just like c6e35dff58d3 ("KVM: arm64: Check for SYSREGS_ON_CPU before
accessing the CPU state") fixed the 64bit state access, add a check
for the 32bit state actually being on the CPU before writing it.

Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20250817121926.217900-2-maz@kernel.org
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Check for SYSREGS_ON_CPU before accessing the CPU state</title>
<updated>2025-07-21T16:34:57Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2025-07-20T10:22:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c6e35dff58d348c1a9489e9b3b62b3721e62631d'/>
<id>urn:sha1:c6e35dff58d348c1a9489e9b3b62b3721e62631d</id>
<content type='text'>
Mark Brown reports that since we commit to making exceptions
visible without the vcpu being loaded, the external abort selftest
fails.

Upon investigation, it turns out that the code that makes registers
affected by an exception visible to the guest is completely broken
on VHE, as we don't check whether the system registers are loaded
on the CPU at this point. We managed to get away with this so far,
but that's obviously as bad as it gets,

Add the required checksm and document the absolute need to check
for the SYSREGS_ON_CPU flag before calling into any of the
__vcpu_write_sys_reg_to_cpu()__vcpu_read_sys_reg_from_cpu() helpers.

Reported-by: Mark Brown &lt;broonie@kernel.org&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/18535df8-e647-4643-af9a-bb780af03a70@sirena.org.uk
Link: https://lore.kernel.org/r/20250720102229.179114-1-maz@kernel.org
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Route SEAs to the SError vector when EASE is set</title>
<updated>2025-07-08T18:36:35Z</updated>
<author>
<name>Oliver Upton</name>
</author>
<published>2025-07-08T17:25:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fff97df2a0bd215979ae224b97e3e4075030a953'/>
<id>urn:sha1:fff97df2a0bd215979ae224b97e3e4075030a953</id>
<content type='text'>
One of the finest additions of FEAT_DoubleFault2 is the ability for
software to request *synchronous* external aborts be taken to the
SError vector, which of coure are *asynchronous* in nature.

Opinions be damned, implement the architecture and send SEAs to the
SError vector if EASE is set for the target context.

Reviewed-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20250708172532.1699409-18-oliver.upton@linux.dev
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: nv: Honor SError exception routing / masking</title>
<updated>2025-07-08T18:36:31Z</updated>
<author>
<name>Oliver Upton</name>
</author>
<published>2025-07-08T17:25:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=77ee70a073575977b403e9add25f185d614217d8'/>
<id>urn:sha1:77ee70a073575977b403e9add25f185d614217d8</id>
<content type='text'>
To date KVM has used HCR_EL2.VSE to track the state of a pending SError
for the guest. With this bit set, hardware respects the EL1 exception
routing / masking rules and injects the vSError when appropriate.

This isn't correct for NV guests as hardware is oblivious to vEL2's
intentions for SErrors. Better yet, with FEAT_NV2 the guest can change
the routing behind our back as HCR_EL2 is redirected to memory. Cope
with this mess by:

 - Using a flag (instead of HCR_EL2.VSE) to track the pending SError
   state when SErrors are unconditionally masked for the current context

 - Resampling the routing / masking of a pending SError on every guest
   entry/exit

 - Emulating exception entry when SError routing implies a translation
   regime change

Reviewed-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20250708172532.1699409-7-oliver.upton@linux.dev
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Add assignment-specific sysreg accessor</title>
<updated>2025-06-05T13:17:32Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2025-06-03T07:08:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6678791ee3da0b78c28fe7d77814097f53cbb8df'/>
<id>urn:sha1:6678791ee3da0b78c28fe7d77814097f53cbb8df</id>
<content type='text'>
Assigning a value to a system register doesn't do what it is
supposed to be doing if that register is one that has RESx bits.

The main problem is that we use __vcpu_sys_reg(), which can be used
both as a lvalue and rvalue. When used as a lvalue, the bit masking
occurs *before* the new value is assigned, meaning that we (1) do
pointless work on the old cvalue, and (2) potentially assign an
invalid value as we fail to apply the masks to it.

Fix this by providing a new __vcpu_assign_sys_reg() that does
what it says on the tin, and sanitises the *new* value instead of
the old one. This comes with a significant amount of churn.

Reviewed-by: Miguel Luis &lt;miguel.luis@oracle.com&gt;
Reviewed-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
Link: https://lore.kernel.org/r/20250603070824.1192795-2-maz@kernel.org
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: nv: Support virtual EL2 exceptions</title>
<updated>2023-02-11T09:16:11Z</updated>
<author>
<name>Jintack Lim</name>
</author>
<published>2023-02-09T17:58:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=47f3a2fc765ae2719e6daf39c0a1c757934b152e'/>
<id>urn:sha1:47f3a2fc765ae2719e6daf39c0a1c757934b152e</id>
<content type='text'>
Support injecting exceptions and performing exception returns to and
from virtual EL2.  This must be done entirely in software except when
taking an exception from vEL0 to vEL2 when the virtual HCR_EL2.{E2H,TGE}
== {1,1}  (a VHE guest hypervisor).

[maz: switch to common exception injection framework, illegal exeption
 return handling]

Reviewed-by: Ganapatrao Kulkarni &lt;gankulkarni@os.amperecomputing.com&gt;
Signed-off-by: Jintack Lim &lt;jintack.lim@linaro.org&gt;
Signed-off-by: Christoffer Dall &lt;christoffer.dall@arm.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Link: https://lore.kernel.org/r/20230209175820.1939006-10-maz@kernel.org
Signed-off-by: Oliver Upton &lt;oliver.upton@linux.dev&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Fix bad dereference on MTE-enabled systems</title>
<updated>2022-10-27T18:49:40Z</updated>
<author>
<name>Ryan Roberts</name>
</author>
<published>2022-10-27T12:09:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b6bcdc9f6b8321e4471ff45413b6410e16762a8d'/>
<id>urn:sha1:b6bcdc9f6b8321e4471ff45413b6410e16762a8d</id>
<content type='text'>
enter_exception64() performs an MTE check, which involves dereferencing
vcpu-&gt;kvm. While vcpu has already been fixed up to be a HYP VA pointer,
kvm is still a pointer in the kernel VA space.

This only affects nVHE configurations with MTE enabled, as in other
cases, the pointer is either valid (VHE) or not dereferenced (!MTE).

Fix this by first converting kvm to a HYP VA pointer.

Fixes: ea7fc1bb1cd1 ("KVM: arm64: Introduce MTE VM feature")
Signed-off-by: Ryan Roberts &lt;ryan.roberts@arm.com&gt;
Reviewed-by: Steven Price &lt;steven.price@arm.com&gt;
[maz: commit message tidy-up]
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20221027120945.29679-1-ryan.roberts@arm.com
</content>
</entry>
<entry>
<title>KVM: arm64: Move vcpu PC/Exception flags to the input flag set</title>
<updated>2022-06-10T08:54:34Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2022-05-28T11:38:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=699bb2e0c6f3796549dabac329501df7ffd99439'/>
<id>urn:sha1:699bb2e0c6f3796549dabac329501df7ffd99439</id>
<content type='text'>
The PC update flags (which also deal with exception injection)
is one of the most complicated use of the flag we have. Make it
more fool prof by:

- moving it over to the new accessors and assign it to the
  input flag set

- turn the combination of generic ELx flags with another flag
  indicating the target EL itself into an explicit set of
  flags for each EL and vector combination

- add a new accessor to pend the exception

This is otherwise a pretty straightformward conversion.

Reviewed-by: Fuad Tabba &lt;tabba@google.com&gt;
Reviewed-by: Reiji Watanabe &lt;reijiw@google.com&gt;
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
</content>
</entry>
<entry>
<title>KVM: arm64: Use shadow SPSR_EL1 when injecting exceptions on !VHE</title>
<updated>2022-01-24T09:39:03Z</updated>
<author>
<name>Marc Zyngier</name>
</author>
<published>2022-01-21T18:42:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=278583055a237270fac70518275ba877bf9e4013'/>
<id>urn:sha1:278583055a237270fac70518275ba877bf9e4013</id>
<content type='text'>
Injecting an exception into a guest with non-VHE is risky business.
Instead of writing in the shadow register for the switch code to
restore it, we override the CPU register instead. Which gets
overriden a few instructions later by said restore code.

The result is that although the guest correctly gets the exception,
it will return to the original context in some random state,
depending on what was there the first place... Boo.

Fix the issue by writing to the shadow register. The original code
is absolutely fine on VHE, as the state is already loaded, and writing
to the shadow register in that case would actually be a bug.

Fixes: bb666c472ca2 ("KVM: arm64: Inject AArch64 exceptions from HYP")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier &lt;maz@kernel.org&gt;
Reviewed-by: Fuad Tabba &lt;tabba@google.com&gt;
Link: https://lore.kernel.org/r/20220121184207.423426-1-maz@kernel.org
</content>
</entry>
</feed>
