From: "Roger Pau Monné" <roger@xenproject.org>
To: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Cc: Jan Beulich <jbeulich@suse.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Teddy Astie <teddy.astie@vates.tech>
Subject: Re: [PATCH] x86/HVM: replace paging_mode_hap() uses
Date: Mon, 21 Sep 2026 16:06:55 +0200 [thread overview]
Message-ID: <arE5_-rKgHavu5hz@macbook.local> (raw)
In-Reply-To: <DLL1G8IR03BR.3KDSA5APZ73TY@amd.com>
On Mon, Sep 21, 2026 at 03:45:29PM +0200, Alejandro Vallejo wrote:
> On Mon Sep 21, 2026 at 3:19 PM CEST, Jan Beulich wrote:
> > HVM guests cannot run without either HAP or shadow enabled. While
> > paging_mode_shadow() is compile-time-constant when SHADOW_PAGING=n,
> > paging_mode_hap() isn't. Hence the former is preferred to leverage DCE.
> >
> > In svm_update_guest_cr() combine two adjacent conditionals.
> >
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> Yes, please.
>
> Reviewed-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
>
> A couple of nits below. Take them or leave them.
>
> > --- a/xen/arch/x86/hvm/svm/svm.c
> > +++ b/xen/arch/x86/hvm/svm/svm.c
> > @@ -113,7 +113,8 @@ static void cf_check svm_update_guest_cr
> > switch ( cr )
> > {
> > case 0:
> > - if ( paging_mode_hap(v->domain) )
> > + value = v->arch.hvm.guest_cr[0];
> > + if ( !paging_mode_shadow(v->domain) )
> > {
> > uint32_t intercepts = vmcb_get_cr_intercepts(vmcb);
> >
> > @@ -122,9 +123,7 @@ static void cf_check svm_update_guest_cr
> > monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) )
> > vmcb_set_cr_intercepts(vmcb, intercepts | CR_INTERCEPT_CR3_WRITE);
> > }
> > -
> > - value = v->arch.hvm.guest_cr[0];
> > - if ( paging_mode_shadow(v->domain) )
> > + else
> > value |= X86_CR0_PG | X86_CR0_WP;
>
> nit: This would be clearer with the polarity reversed. Check shadow
> first and have hap later. It'd also make the diff (marginally) smaller too.
>
> > vmcb_set_cr0(vmcb, value);
> > break;
> > --- a/xen/arch/x86/hvm/vmx/vmcs.c
> > +++ b/xen/arch/x86/hvm/vmx/vmcs.c
>
> [snip]
>
> > v->arch.hvm.vmx.exception_bitmap = HVM_TRAP_MASK
> > - | (paging_mode_hap(d) ? 0 : (1U << X86_EXC_PF));
> > + | (!paging_mode_shadow(d) ? 0 : (1U << X86_EXC_PF));
>
> nit: Shouldn't | be on the prior line? It was there before, but seeing
> how you're adjusting indentation might as well move that char.
>
> In the same vein as before, it'd be a bit clearer with the polarity
> inverted (shadow() ? bit : 0 )
I agree with both suggestions in principle, always better if we can
avoid negations.
Acked-by: Roger Pau Monné <roger@xenproject.org>
Thanks, Roger.
next prev parent reply other threads:[~2026-09-21 14:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 13:19 [PATCH] x86/HVM: replace paging_mode_hap() uses Jan Beulich
2026-09-21 13:45 ` Alejandro Vallejo
2026-09-21 14:06 ` Roger Pau Monné [this message]
2026-09-21 14:56 ` Jan Beulich
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=arE5_-rKgHavu5hz@macbook.local \
--to=roger@xenproject.org \
--cc=alejandro.garciavallejo@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=teddy.astie@vates.tech \
--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.