[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v8 3/5] xen/riscv: look up the exception table for any trap taken in Xen context





On 10/26/26 4:14 PM, Baptiste Le Duc wrote:
From: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>

do_trap() consulted the exception table only for CAUSE_ILLEGAL_INSTRUCTION,
which covers csr_read_safe() but not a probing access faulting with a page
fault cause: it would reach do_unexpected_trap() instead of its fixup.
There is no such access yet, the A/D update scheme probe will be the first.

Move the lookup ahead of the cause switch, and only do it for exceptions
taken in Xen context. Both other cases must skip it:

- Traps taken from the guest: sepc is then a guest address, which the
   guest can point at an address listed in the exception table, making Xen
   act on an entry fully under guest control. Entries are matched by exact
   address, so this needs no more than a numerical collision.

Nit: Identations here and ..


- Interrupts: an interrupt taken at an address listed in the table would
   otherwise be "fixed up" as if the access itself had faulted, silently
   skipping it.

... looks incorrect a little bit. An extra space should be dropped.


Returning early skips check_for_pcpu_work(), which is correct: that only
runs for traps taken from the guest.

Cache the "trap came from the guest" test in a local as it is now used
three times.

Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
[Baptiste: drop the parts depending on the vAPLIC/vIMSIC series, adapt
  the commit message]
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>
---
Changes since v7:
- new patch, needed by the A/D update scheme probe of the next patch,
   whose store page fault would otherwise not be fixed up. Taken from:
   
https://patch.msgid.link/4e2b4e7a99f4d2133ff92559303d19382749de7a.1790779209.git.oleksii.kurochko@xxxxxxxxx
- commit message adapted to this subset: drop the hlv/hlvx and
   EX_TYPE_TRAP_INFO parts and the paragraph on the guest page fault
   BUG_ON(), whose code isn't taken; mention the from_guest local, which
   this subset introduces.
- apply my v3 review suggestion to the commit message: state up front
   that the lookup is only done for exceptions taken in Xen context and
   list traps taken from the guest and interrupts as the skipped cases.
---
LGTM:

Reviewed-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>

~ Oleksii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.