|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 2/2] x86/nestedhvm: Don't treat an emulated INT $n as an exception
On 11/27/26 7:55 AM, chunjie.zhu@xxxxxxxxxx wrote:
> On 11/20/26 9:00 AM, Stephen Cheng wrote:
>> +bool cf_check nvmx_intercepts_event(
>> + struct vcpu *v, const struct x86_event *event)
>> {
>> + const unsigned int vector = event->vector;
>> + const int error_code = event->error_code;
>> u32 exception_bitmap, pfec_match=0, pfec_mask=0;
>> int r;
>>
>> + /* INT $n is not an exception, and is never in the exception bitmap. */
>> + if ( event->type == X86_ET_SW_INT )
>> + return false;
>
> An alternative idea,
>
> Since nhvm_vmcx_guest_intercepts_event() cannot tell an exception from
> a software interrupt by itself, would it be cleaner to split the hook
> in two and let hvm_inject_event() pick one by event->type? Roughly:
>
> nhvm_vmcx_guest_intercepts_exception(v, vector, errcode)
> nhvm_vmcx_guest_intercepts_swint(v, vector)
>
> SVM would check VMEXIT_EXCEPTION_DE + vector in the first and
> VMEXIT_SWINT in the second. VMX would keep nvmx_intercepts_exception()
> as it is, with its ASSERT(vector < 32) still meaning "exceptions only",
> and the second hook would simply return false, as INT $n never causes a
> VM exit on VMX. That also avoids passing the whole struct x86_event
> to the hooks.
Thanks for looking at this. I did think about splitting the hook, but
I'd prefer to keep passing the event, for two reasons.
hvm_inject_event() is not the only caller on VMX. In staging,
vmx_inject_event() also calls nvmx_intercepts_exception() directly,
before queueing the event for L2, and it gets there with an INT $n
too: with the split, hvm_inject_event() would ask the swint hook, get
false, and fall through to hvm_funcs.inject_event, i.e.
vmx_inject_event(), still with the X86_ET_SW_INT event. For n >= 32
that hits ASSERT(vector < 32) in a debug build, and in a release build
tests bit n of the 32-bit exception bitmap. So vmx_inject_event()
would need its own X86_ET_SW_INT check as well. Every caller would
have to remember to pick the right hook by type. When the hook takes
the event, that check is in one place, inside the hook.
It also matches the hook next to it. nhvm_vcpu_vmexit_event(), which
hvm_inject_event() calls right after the intercept check, already
takes const struct x86_event *. Passing the same event to both means
the "is it intercepted?" question and the #VMEXIT that follows are
worked out from the same input. On SVM both use
nsvm_event_exitcode().
Stephen
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |