From: Jan Beulich <jbeulich@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
Kevin Tian <kevin.tian@intel.com>,
Jun Nakajima <jun.nakajima@intel.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 3/3] x86/vmx: implement Notify VM Exit
Date: Tue, 7 Jun 2022 09:43:25 +0200 [thread overview]
Message-ID: <c8f22652-abd5-76f8-75d3-ed581d1c4752@suse.com> (raw)
In-Reply-To: <YpoeuOJPS0gobz5u@Air-de-Roger>
On 03.06.2022 16:46, Roger Pau Monné wrote:
> On Fri, Jun 03, 2022 at 02:49:54PM +0200, Jan Beulich wrote:
>> On 26.05.2022 13:11, Roger Pau Monne wrote:
>>> --- a/xen/arch/x86/hvm/vmx/vmx.c
>>> +++ b/xen/arch/x86/hvm/vmx/vmx.c
>>> @@ -1419,10 +1419,19 @@ static void cf_check vmx_update_host_cr3(struct vcpu *v)
>>>
>>> void vmx_update_debug_state(struct vcpu *v)
>>> {
>>> + unsigned int mask = 1u << TRAP_int3;
>>> +
>>> + if ( !cpu_has_monitor_trap_flag && cpu_has_vmx_notify_vm_exiting )
>>
>> I'm puzzled by the lack of symmetry between this and ...
>>
>>> + /*
>>> + * Only allow toggling TRAP_debug if notify VM exit is enabled, as
>>> + * unconditionally setting TRAP_debug is part of the XSA-156 fix.
>>> + */
>>> + mask |= 1u << TRAP_debug;
>>> +
>>> if ( v->arch.hvm.debug_state_latch )
>>> - v->arch.hvm.vmx.exception_bitmap |= 1U << TRAP_int3;
>>> + v->arch.hvm.vmx.exception_bitmap |= mask;
>>> else
>>> - v->arch.hvm.vmx.exception_bitmap &= ~(1U << TRAP_int3);
>>> + v->arch.hvm.vmx.exception_bitmap &= ~mask;
>>>
>>> vmx_vmcs_enter(v);
>>> vmx_update_exception_bitmap(v);
>>> @@ -4155,6 +4164,9 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
>>> switch ( vector )
>>> {
>>> case TRAP_debug:
>>> + if ( cpu_has_monitor_trap_flag && cpu_has_vmx_notify_vm_exiting )
>>> + goto exit_and_crash;
>>
>> ... this condition. Shouldn't one be the inverse of the other (and
>> then it's the one down here which wants adjusting)?
>
> The condition in vmx_update_debug_state() sets the mask so that
> TRAP_debug will only be added or removed from the bitmap if
> !cpu_has_monitor_trap_flag && cpu_has_vmx_notify_vm_exiting (note that
> otherwise TRAP_debug is unconditionally set if
> !cpu_has_vmx_notify_vm_exiting).
>
> Hence it's impossible to get a VMExit TRAP_debug with
> cpu_has_monitor_trap_flag && cpu_has_vmx_notify_vm_exiting because
> TRAP_debug will never be set by vmx_update_debug_state() in that
> case.
Hmm, yes, I've been misguided by you not altering the existing setting
of v->arch.hvm.vmx.exception_bitmap in construct_vmcs(). Instead you
add an entirely new block of code near the bottom of the function. Is
there any chance you could move up that adjustment, perhaps along the
lines of
v->arch.hvm.vmx.exception_bitmap = HVM_TRAP_MASK
| (paging_mode_hap(d) ? 0 : (1U << TRAP_page_fault))
| (v->arch.fully_eager_fpu ? 0 : (1U << TRAP_no_device));
if ( cpu_has_vmx_notify_vm_exiting )
{
__vmwrite(NOTIFY_WINDOW, vm_notify_window);
/*
* Disable #AC and #DB interception: by using VM Notify Xen is
* guaranteed to get a VM exit even if the guest manages to lock the
* CPU.
*/
v->arch.hvm.vmx.exception_bitmap &= ~((1U << TRAP_debug) |
(1U << TRAP_alignment_check));
}
vmx_update_exception_bitmap(v);
Jan
next prev parent reply other threads:[~2022-06-07 7:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-26 11:11 [PATCH v2 0/3] x86/vmx: implement Bus Lock and VM Notify Roger Pau Monne
2022-05-26 11:11 ` [PATCH v2 1/3] x86/vmx: implement Bus Lock detection Roger Pau Monne
2022-06-03 12:16 ` Jan Beulich
2022-06-03 14:29 ` Roger Pau Monné
2022-06-07 7:20 ` Jan Beulich
2022-06-06 13:27 ` Andrew Cooper
2022-06-07 6:54 ` Jan Beulich
2022-06-07 10:03 ` Roger Pau Monné
2022-05-26 11:11 ` [PATCH v2 2/3] x86/vmx: introduce helper to set VMX_INTR_SHADOW_NMI Roger Pau Monne
2022-06-03 12:20 ` Jan Beulich
2022-05-26 11:11 ` [PATCH v2 3/3] x86/vmx: implement Notify VM Exit Roger Pau Monne
2022-06-03 12:49 ` Jan Beulich
2022-06-03 14:46 ` Roger Pau Monné
2022-06-07 7:43 ` Jan Beulich [this message]
2022-06-07 10:05 ` Roger Pau Monné
2022-06-08 3:51 ` Tian, Kevin
2022-06-09 7:04 ` Tian, Kevin
2022-06-09 7:39 ` Xiaoyao Li
2022-06-09 10:09 ` Roger Pau Monné
2022-06-16 11:17 ` Roger Pau Monné
2022-06-16 11:57 ` Xiaoyao Li
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=c8f22652-abd5-76f8-75d3-ed581d1c4752@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=julien@xen.org \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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.