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

Re: [PATCH v2 23/39] xen/riscv: look up the exception table for any trap taken in Xen context



> do_trap() consulted the exception table only for CAUSE_ILLEGAL_INSTRUCTION,
> which covers csr_read_safe() but not the hlv/hlvx sequences reading guest
> memory: those fault with load/store (guest) page fault causes and would
> reach do_unexpected_trap() instead of their fixup.
> 
> Move the lookup ahead of the cause switch, and gate it on the trap having
> been taken in Xen context and not being an interrupt:
> 
> - sepc of a trap taken from the guest is a guest VA/PA, which the
>   guest can point at an address listed in the exception table; Xen would
>   then act on that entry and, for EX_TYPE_TRAP_INFO, write through a
>   pointer fully under guest control. Entries are matched by exact address,
>   so this needs no more than a numerical collision.
> 
> - 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 and
>   handing the caller the interrupt's scause as a fault cause.
> 
> Returning early skips check_for_pcpu_work(), which is correct: that only
> runs for traps taken from the guest.
> 
> With that in place a G-stage fault reaching the switch can no longer have
> been caused by an hlv/hlvx covered by an entry, so anything left must have
> come from the guest; assert as much.
What means `assert as much` here? As you referencing any assert in the code,
because in this patch, I couldn't find any.
> 
> Cache the "trap came from the guest" test in a local, it is now used four
> times.
Nit: By reading this sentence, I would expect to have the introduction
of `from_guest` local here instead of in patch cc2d3b97e8
xen/riscv: add guest page fault handling stub

-- 
Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>



 


Rackspace

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