All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alejandro Vallejo" <alejandro.garciavallejo@amd.com>
To: "Jan Beulich" <jbeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Teddy Astie" <teddy.astie@vates.tech>,
	"Roger Pau Monné" <roger@xenproject.org>
Subject: Re: [PATCH] x86/HVM: replace paging_mode_hap() uses
Date: Mon, 21 Sep 2026 15:45:29 +0200	[thread overview]
Message-ID: <DLL1G8IR03BR.3KDSA5APZ73TY@amd.com> (raw)
In-Reply-To: <f456b455-bcae-46a0-b68b-cebf31afa38f@suse.com>

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 )

Cheers,
Alejandro


  reply	other threads:[~2026-09-21 13:45 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 [this message]
2026-09-21 14:06   ` Roger Pau Monné
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=DLL1G8IR03BR.3KDSA5APZ73TY@amd.com \
    --to=alejandro.garciavallejo@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger@xenproject.org \
    --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.