xen/arch/x86/hvm/svm/nestedsvm.c | 65 +++++++++++--------------------- xen/arch/x86/mm/paging.c | 1 - 2 files changed, 22 insertions(+), 44 deletions(-)
From: Chunjie Zhu <chunjie.zhu@citrix.com>
Nested virtualization is only permitted together with HAP:
sanitise_domain_config() rejects XEN_DOMCTL_CDF_nested_virt without
XEN_DOMCTL_CDF_hap. The L1 domain therefore cannot be in shadow paging
mode while nested virt is enabled, and paging_mode_shadow(v->domain) is
always false in the nested SVM code.
nsvm_vcpu_hostrestore(), nsvm_vmcb_prepare4vmrun(),
nsvm_vmcb_prepare4vmexit() and nestedsvm_check_intercepts() still carry
incomplete, never-executed handling for the "host shadow paging + guest
shadow paging" case. Drop it, and guard the remaining branch with
BUG_ON(paging_mode_shadow(v->domain)) to document the invariant.
In nestedsvm_check_intercepts()'s #PF handling, test
nestedhvm_paging_mode_hap() first, so the reachable "host nested paging +
guest shadow paging" case returns NESTEDHVM_VMEXIT_INJECT directly.
Also drop the now always-true paging_mode_hap() check from
svm_nested_features_on_efer_update(), and the stale "shadow-on-shadow"
TODO in paging_update_nestedmode().
No functional change.
Signed-off-by: Chunjie Zhu <chunjie.zhu@citrix.com>
---
xen/arch/x86/hvm/svm/nestedsvm.c | 65 +++++++++++---------------------
xen/arch/x86/mm/paging.c | 1 -
2 files changed, 22 insertions(+), 44 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index dc2b6a42534a..748c821d40f8 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -304,21 +304,12 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
/* host nested paging + guest nested paging. */
/* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
}
- else if ( paging_mode_hap(v->domain) )
- {
- /* host nested paging + guest shadow paging. */
- /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
- }
else
{
- /* host shadow paging + guest shadow paging. */
-
- /* Reset MMU context -- XXX (hostrestore) not yet working*/
- if ( !pagetable_is_null(v->arch.guest_table) )
- put_page(pagetable_get_page(v->arch.guest_table));
- v->arch.guest_table = pagetable_null();
- /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
+ /* host shadow paging + guest shadow paging cannot happen */
+ BUG_ON(paging_mode_shadow(v->domain));
}
+
rc = hvm_set_cr3(n1vmcb->_cr3, false, true);
if ( rc == X86EMUL_EXCEPTION )
hvm_inject_hw_exception(X86_EXC_GP, 0);
@@ -580,8 +571,11 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
if ( rc != X86EMUL_OKAY )
gdprintk(XENLOG_ERR, "hvm_set_cr3 failed, rc: %u\n", rc);
}
- else if ( paging_mode_hap(v->domain) )
+ else
{
+ /* host shadow paging + guest shadow paging cannot happen */
+ BUG_ON(paging_mode_shadow(v->domain));
+
/* host nested paging + guest shadow paging. */
vmcb_set_np(n2vmcb, true);
/* Keep h_cr3 as it is. */
@@ -596,16 +590,6 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
if ( rc != X86EMUL_OKAY )
gdprintk(XENLOG_ERR, "hvm_set_cr3 failed, rc: %u\n", rc);
}
- else
- {
- /* host shadow paging + guest shadow paging. */
- vmcb_set_np(n2vmcb, false);
- n2vmcb->_h_cr3 = 0x0;
-
- /* TODO: Once shadow-shadow paging is in place come back to here
- * and set host_vmcb->_cr3 to the shadowed shadow table.
- */
- }
/* DRn */
if ( !clean.dr )
@@ -1088,8 +1072,11 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs)
* unshadowed guest h_cr3 is kept in ns_vmcb->h_cr3,
* hence we keep the ns_vmcb->h_cr3 value. */
}
- else if ( paging_mode_hap(v->domain) )
+ else
{
+ /* host shadow paging + guest shadow paging cannot happen */
+ BUG_ON(paging_mode_shadow(v->domain));
+
/* host nested paging + guest shadow paging. */
vmcb_set_np(ns_vmcb, false);
/* Throw h_cr3 away. Guest is not allowed to set it or
@@ -1099,15 +1086,6 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs)
* by restoring cached intercepts). */
ns_vmcb->_cr3 = n2vmcb->_cr3;
}
- else
- {
- /* host shadow paging + guest shadow paging. */
- vmcb_set_np(ns_vmcb, false);
- ns_vmcb->_h_cr3 = 0x0;
- /* The vmcb->_cr3 is the shadowed cr3. The original
- * unshadowed guest cr3 is kept in ns_vmcb->_cr3,
- * hence we keep the ns_vmcb->_cr3 value. */
- }
/* LBR virtualization - keep lbr control as is */
@@ -1320,16 +1298,16 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
/* host nested paging + guest nested paging */
return NESTEDHVM_VMEXIT_HOST;
}
- if ( paging_mode_hap(v->domain) )
+ else
{
+ /* host shadow paging + guest shadow paging cannot happen */
+ BUG_ON(paging_mode_shadow(v->domain));
+
if ( is_intercepted )
return NESTEDHVM_VMEXIT_FATALERROR;
/* host nested paging + guest shadow paging */
return NESTEDHVM_VMEXIT_HOST;
}
- /* host shadow paging + guest shadow paging */
- /* Can this happen? */
- BUG();
case VMEXIT_EXCEPTION_PF:
if ( nestedhvm_paging_mode_hap(v) )
@@ -1341,12 +1319,14 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
/* l2 guest intercepts #PF unnecessarily */
return NESTEDHVM_VMEXIT_INJECT;
}
- if ( !paging_mode_hap(v->domain) )
- /* host shadow paging + guest shadow paging */
- return NESTEDHVM_VMEXIT_HOST;
+ else
+ {
+ /* host shadow paging + guest shadow paging cannot happen */
+ BUG_ON(!paging_mode_hap(v->domain));
- /* host nested paging + guest shadow paging */
- return NESTEDHVM_VMEXIT_INJECT;
+ /* host nested paging + guest shadow paging */
+ return NESTEDHVM_VMEXIT_INJECT;
+ }
case VMEXIT_VMMCALL:
/* Always let the guest handle VMMCALL/VMCALL */
return NESTEDHVM_VMEXIT_INJECT;
@@ -1619,7 +1599,6 @@ void svm_nested_features_on_efer_update(struct vcpu *v)
if ( nsvm_efer_svm_enabled(v) )
{
if ( !vmcb->virt_ext.fields.vloadsave_enable &&
- paging_mode_hap(v->domain) &&
cpu_has_svm_vloadsave )
{
vmcb->virt_ext.fields.vloadsave_enable = 1;
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 65455a686787..277d84fb4cb8 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -924,7 +924,6 @@ void paging_update_nestedmode(struct vcpu *v)
/* nested-on-nested */
v->arch.paging.nestedmode = hap_paging_get_mode(v);
else
- /* TODO: shadow-on-shadow */
v->arch.paging.nestedmode = NULL;
hvm_asid_flush_vcpu(v);
}
--
2.34.1
On 20.10.2026 05:05, chunjie.zhu@citrix.com wrote:
> --- a/xen/arch/x86/hvm/svm/nestedsvm.c
> +++ b/xen/arch/x86/hvm/svm/nestedsvm.c
> @@ -304,21 +304,12 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
> /* host nested paging + guest nested paging. */
> /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
> }
> - else if ( paging_mode_hap(v->domain) )
> - {
> - /* host nested paging + guest shadow paging. */
> - /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
> - }
> else
> {
> - /* host shadow paging + guest shadow paging. */
> -
> - /* Reset MMU context -- XXX (hostrestore) not yet working*/
> - if ( !pagetable_is_null(v->arch.guest_table) )
> - put_page(pagetable_get_page(v->arch.guest_table));
> - v->arch.guest_table = pagetable_null();
> - /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
> + /* host shadow paging + guest shadow paging cannot happen */
> + BUG_ON(paging_mode_shadow(v->domain));
How's "guest shadow paging" relevant here; the BUG_ON() solely depends on
"host", doesn't it? IOW I think the comment wants wording differently.
Also, nit: Please correct comment style while touching comments.
Furthermore: Why would the check be relevant only on the "else" path? It
could equally well live ahead of it, with the comments in if() and "else"
then talking of just the guest mode.
(All comments apply elsewhere as well.)
> @@ -1341,12 +1319,14 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
> /* l2 guest intercepts #PF unnecessarily */
> return NESTEDHVM_VMEXIT_INJECT;
> }
> - if ( !paging_mode_hap(v->domain) )
> - /* host shadow paging + guest shadow paging */
> - return NESTEDHVM_VMEXIT_HOST;
> + else
> + {
> + /* host shadow paging + guest shadow paging cannot happen */
> + BUG_ON(!paging_mode_hap(v->domain));
>
> - /* host nested paging + guest shadow paging */
> - return NESTEDHVM_VMEXIT_INJECT;
> + /* host nested paging + guest shadow paging */
> + return NESTEDHVM_VMEXIT_INJECT;
> + }
> case VMEXIT_VMMCALL:
> /* Always let the guest handle VMMCALL/VMCALL */
> return NESTEDHVM_VMEXIT_INJECT;
This results in (apparently) un-annotated fall-through. As both if() and
"else" now return NESTEDHVM_VMEXIT_INJECT, those return-s want folding.
Then also please add a blank line between return and next case.
Jan
From: Chunjie Zhu <chunjie.zhu@citrix.com>
Nested virtualization on a domain is only permitted together with HAP:
sanitise_domain_config() rejects XEN_DOMCTL_CDF_nested_virt requested
without XEN_DOMCTL_CDF_hap, since shadow paging is too slow to be usable
as the L0 paging mode underneath an L1 hypervisor. This means the host
(L0) can never be in shadow paging mode while nested_virt is enabled,
i.e. paging_mode_shadow(v->domain) is always false in this context.
The nested SVM code still had incomplete/speculative handling for the
'host shadow paging + guest shadow paging' case in
nsvm_vcpu_hostrestore(), nsvm_vmcb_prepare4vmrun(),
nsvm_vmcb_prepare4vmexit() and nestedsvm_check_intercepts(). Remove it,
and assert the host paging mode with a single
BUG_ON(paging_mode_shadow(v->domain)) ahead of the guest paging mode
checks, so the remaining comments only describe the guest mode.
In nestedsvm_check_intercepts()'s #PF handling, fold the two identical
NESTEDHVM_VMEXIT_INJECT returns.
Also drop the now always-true paging_mode_hap() check from
svm_nested_features_on_efer_update(), and the stale "shadow-on-shadow"
TODO in paging_update_nestedmode().
No functional change.
Signed-off-by: Chunjie Zhu <chunjie.zhu@citrix.com>
---
v2:
* Move the BUG_ON(paging_mode_shadow()) ahead of the guest paging mode
checks; comments now describe only the guest mode.
* Fix comment style in touched comments.
* Fold the identical NESTEDHVM_VMEXIT_INJECT returns in the #PF case and
add a blank line before the next case.
xen/arch/x86/hvm/svm/nestedsvm.c | 125 ++++++++++++-------------------
xen/arch/x86/mm/paging.c | 1 -
2 files changed, 48 insertions(+), 78 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index 2b998e26bcff..ea30c777451d 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -237,27 +237,10 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
hvm_update_guest_cr(v, 2);
/* CR3 */
- /* Nested paging mode */
- if ( nestedhvm_paging_mode_hap(v) )
- {
- /* host nested paging + guest nested paging. */
- /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
- }
- else if ( !paging_mode_shadow(v->domain) )
- {
- /* host nested paging + guest shadow paging. */
- /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
- }
- else
- {
- /* host shadow paging + guest shadow paging. */
+ /* Nested virt requires HAP, so the host is never in shadow mode. */
+ BUG_ON(paging_mode_shadow(v->domain));
- /* Reset MMU context -- XXX (hostrestore) not yet working*/
- if ( !pagetable_is_null(v->arch.guest_table) )
- put_page(pagetable_get_page(v->arch.guest_table));
- v->arch.guest_table = pagetable_null();
- /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
- }
+ /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
rc = hvm_set_cr3(n1vmcb->_cr3, false, true);
if ( rc == X86EMUL_EXCEPTION )
hvm_inject_hw_exception(X86_EXC_GP, 0);
@@ -517,10 +500,13 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
v->arch.hvm.guest_cr[2] = ns_vmcb->_cr2;
hvm_update_guest_cr(v, 2);
+ /* Nested virt requires HAP, so the host is never in shadow mode. */
+ BUG_ON(paging_mode_shadow(v->domain));
+
/* Nested paging mode */
if ( nestedhvm_paging_mode_hap(v) )
{
- /* host nested paging + guest nested paging. */
+ /* Guest uses nested paging. */
vmcb_set_np(n2vmcb, true);
nestedsvm_vmcb_set_nestedp2m(v, ns_vmcb, n2vmcb);
@@ -532,13 +518,14 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
if ( rc != X86EMUL_OKAY )
gdprintk(XENLOG_ERR, "hvm_set_cr3 failed, rc: %u\n", rc);
}
- else if ( !paging_mode_shadow(v->domain) )
+ else
{
- /* host nested paging + guest shadow paging. */
+ /* Guest uses shadow paging. */
vmcb_set_np(n2vmcb, true);
/* Keep h_cr3 as it is. */
n2vmcb->_h_cr3 = n1vmcb->_h_cr3;
- /* When l1 guest does shadow paging
+ /*
+ * When l1 guest does shadow paging
* we assume it intercepts page faults.
*/
/* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
@@ -548,16 +535,6 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
if ( rc != X86EMUL_OKAY )
gdprintk(XENLOG_ERR, "hvm_set_cr3 failed, rc: %u\n", rc);
}
- else
- {
- /* host shadow paging + guest shadow paging. */
- vmcb_set_np(n2vmcb, false);
- n2vmcb->_h_cr3 = 0x0;
-
- /* TODO: Once shadow-shadow paging is in place come back to here
- * and set host_vmcb->_cr3 to the shadowed shadow table.
- */
- }
/* DRn */
if ( !clean.dr )
@@ -1030,35 +1007,35 @@ nsvm_vmcb_prepare4vmexit(struct vcpu *v, struct cpu_user_regs *regs)
ns_vmcb->event_inj.raw = 0;
+ /* Nested virt requires HAP, so the host is never in shadow mode. */
+ BUG_ON(paging_mode_shadow(v->domain));
+
/* Nested paging mode */
if ( nestedhvm_paging_mode_hap(v) )
{
- /* host nested paging + guest nested paging. */
+ /* Guest uses nested paging. */
vmcb_set_np(ns_vmcb, vmcb_get_np(n2vmcb));
ns_vmcb->_cr3 = n2vmcb->_cr3;
- /* The vmcb->h_cr3 is the shadowed h_cr3. The original
+ /*
+ * The vmcb->h_cr3 is the shadowed h_cr3. The original
* unshadowed guest h_cr3 is kept in ns_vmcb->h_cr3,
- * hence we keep the ns_vmcb->h_cr3 value. */
- }
- else if ( !paging_mode_shadow(v->domain) )
- {
- /* host nested paging + guest shadow paging. */
- vmcb_set_np(ns_vmcb, false);
- /* Throw h_cr3 away. Guest is not allowed to set it or
- * it can break out, otherwise (security hole!) */
- ns_vmcb->_h_cr3 = 0x0;
- /* Stop intercepting #PF (already done above
- * by restoring cached intercepts). */
- ns_vmcb->_cr3 = n2vmcb->_cr3;
+ * hence we keep the ns_vmcb->h_cr3 value.
+ */
}
else
{
- /* host shadow paging + guest shadow paging. */
+ /* Guest uses shadow paging. */
vmcb_set_np(ns_vmcb, false);
+ /*
+ * Throw h_cr3 away. Guest is not allowed to set it or
+ * it can break out, otherwise (security hole!)
+ */
ns_vmcb->_h_cr3 = 0x0;
- /* The vmcb->_cr3 is the shadowed cr3. The original
- * unshadowed guest cr3 is kept in ns_vmcb->_cr3,
- * hence we keep the ns_vmcb->_cr3 value. */
+ /*
+ * Stop intercepting #PF (already done above
+ * by restoring cached intercepts).
+ */
+ ns_vmcb->_cr3 = n2vmcb->_cr3;
}
/* LBR virtualization - keep lbr control as is */
@@ -1260,40 +1237,35 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
return NESTEDHVM_VMEXIT_HOST;
case VMEXIT_NPF:
+ /* Nested virt requires HAP, so the host is never in shadow mode. */
+ BUG_ON(paging_mode_shadow(v->domain));
+
if ( nestedhvm_paging_mode_hap(v) )
{
+ /* Guest uses nested paging. */
if ( !is_intercepted )
return NESTEDHVM_VMEXIT_FATALERROR;
- /* host nested paging + guest nested paging */
return NESTEDHVM_VMEXIT_HOST;
}
- if ( !paging_mode_shadow(v->domain) )
- {
- if ( is_intercepted )
- return NESTEDHVM_VMEXIT_FATALERROR;
- /* host nested paging + guest shadow paging */
- return NESTEDHVM_VMEXIT_HOST;
- }
- /* host shadow paging + guest shadow paging */
- /* Can this happen? */
- BUG();
+
+ /* Guest uses shadow paging. */
+ if ( is_intercepted )
+ return NESTEDHVM_VMEXIT_FATALERROR;
+ return NESTEDHVM_VMEXIT_HOST;
case VMEXIT_EXCEPTION_PF:
- if ( nestedhvm_paging_mode_hap(v) )
- {
- /* host nested paging + guest nested paging */
- if ( !is_intercepted )
- /* l1 guest intercepts #PF unnecessarily */
- return NESTEDHVM_VMEXIT_HOST;
- /* l2 guest intercepts #PF unnecessarily */
- return NESTEDHVM_VMEXIT_INJECT;
- }
- if ( paging_mode_shadow(v->domain) )
- /* host shadow paging + guest shadow paging */
- return NESTEDHVM_VMEXIT_HOST;
+ /* Nested virt requires HAP, so the host is never in shadow mode. */
+ BUG_ON(paging_mode_shadow(v->domain));
- /* host nested paging + guest shadow paging */
+ /*
+ * Guest uses nested paging and L1 doesn't intercept #PF: it is
+ * L0's business. Otherwise (L2 intercepts #PF unnecessarily, or
+ * guest uses shadow paging) hand it to L1.
+ */
+ if ( nestedhvm_paging_mode_hap(v) && !is_intercepted )
+ return NESTEDHVM_VMEXIT_HOST;
return NESTEDHVM_VMEXIT_INJECT;
+
case VMEXIT_VMMCALL:
/* Always let the guest handle VMMCALL/VMCALL */
return NESTEDHVM_VMEXIT_INJECT;
@@ -1566,7 +1538,6 @@ void svm_nested_features_on_efer_update(struct vcpu *v)
if ( nsvm_efer_svm_enabled(v) )
{
if ( !vmcb->virt_ext.fields.vloadsave_enable &&
- !paging_mode_shadow(v->domain) &&
cpu_has_svm_vloadsave )
{
vmcb->virt_ext.fields.vloadsave_enable = 1;
diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 4bb8d169de1c..7c6df8d5d07c 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -932,7 +932,6 @@ void paging_update_nestedmode(struct vcpu *v)
/* nested-on-nested */
v->arch.paging.nestedmode = hap_paging_get_mode(v);
else
- /* TODO: shadow-on-shadow */
v->arch.paging.nestedmode = NULL;
hvm_asid_flush_vcpu(v);
}
--
2.34.1
On 27.10.2026 08:37, chunjie.zhu@citrix.com wrote:
> --- a/xen/arch/x86/hvm/svm/nestedsvm.c
> +++ b/xen/arch/x86/hvm/svm/nestedsvm.c
> @@ -237,27 +237,10 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)
> hvm_update_guest_cr(v, 2);
>
> /* CR3 */
> - /* Nested paging mode */
> - if ( nestedhvm_paging_mode_hap(v) )
> - {
> - /* host nested paging + guest nested paging. */
> - /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
> - }
> - else if ( !paging_mode_shadow(v->domain) )
> - {
> - /* host nested paging + guest shadow paging. */
> - /* hvm_set_cr3() below sets v->arch.hvm.guest_cr[3] for us. */
> - }
> - else
> - {
> - /* host shadow paging + guest shadow paging. */
> + /* Nested virt requires HAP, so the host is never in shadow mode. */
> + BUG_ON(paging_mode_shadow(v->domain));
See below as to the use of "host" in the comment.
> @@ -517,10 +500,13 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)
> v->arch.hvm.guest_cr[2] = ns_vmcb->_cr2;
> hvm_update_guest_cr(v, 2);
>
> + /* Nested virt requires HAP, so the host is never in shadow mode. */
> + BUG_ON(paging_mode_shadow(v->domain));
> +
> /* Nested paging mode */
> if ( nestedhvm_paging_mode_hap(v) )
> {
> - /* host nested paging + guest nested paging. */
> + /* Guest uses nested paging. */
> vmcb_set_np(n2vmcb, true);
"Guest" alone ends up ambiguous. The "host" / "guest" terminology used before
wasn't quite clear either, but at least there was some distinction. Easiest
may be to drop "Guest uses" here (and below). Else, to be unambiguous, it may
need to be something like "L1 runs L2 under nested paging".
If you agree with dropping "Guest uses" and replacing "host" by "L1", I can
make these adjustments while committing, implying
Acked-by: Jan Beulich <jbeulich@suse.com>
in that shape. Otherwise please submit a v3 with adjustments you consider
suitable.
Jan
On Wed, Oct 28, 2026 at 12:06:45 PM, Jan Beulich <jbeulich@suse.com> wrote: > "Guest" alone ends up ambiguous. The "host" / "guest" terminology used before > wasn't quite clear either, but at least there was some distinction. Easiest > may be to drop "Guest uses" here (and below). Else, to be unambiguous, it may > need to be something like "L1 runs L2 under nested paging". > > If you agree with dropping "Guest uses" and replacing "host" by "L1", I can > make these adjustments while committing, implying > Acked-by: Jan Beulich <jbeulich@suse.com> > in that shape. Otherwise please submit a v3 with adjustments you consider > suitable. > > Jan Yes, I agree with both changes. Thank you for the review. Regards, Chunjie
On 27.10.2026 08:37, chunjie.zhu@citrix.com wrote: > From: Chunjie Zhu <chunjie.zhu@citrix.com> > > Nested virtualization on a domain is only permitted together with HAP: > sanitise_domain_config() rejects XEN_DOMCTL_CDF_nested_virt requested > without XEN_DOMCTL_CDF_hap, since shadow paging is too slow to be usable > as the L0 paging mode underneath an L1 hypervisor. This means the host > (L0) can never be in shadow paging mode while nested_virt is enabled, > i.e. paging_mode_shadow(v->domain) is always false in this context. > > The nested SVM code still had incomplete/speculative handling for the > 'host shadow paging + guest shadow paging' case in > nsvm_vcpu_hostrestore(), nsvm_vmcb_prepare4vmrun(), > nsvm_vmcb_prepare4vmexit() and nestedsvm_check_intercepts(). Remove it, > and assert the host paging mode with a single > BUG_ON(paging_mode_shadow(v->domain)) ahead of the guest paging mode > checks, so the remaining comments only describe the guest mode. > > In nestedsvm_check_intercepts()'s #PF handling, fold the two identical > NESTEDHVM_VMEXIT_INJECT returns. > > Also drop the now always-true paging_mode_hap() check from > svm_nested_features_on_efer_update(), and the stale "shadow-on-shadow" > TODO in paging_update_nestedmode(). > > No functional change. > > Signed-off-by: Chunjie Zhu <chunjie.zhu@citrix.com> Two formal things only for now (will look at the patch itself later): Please send new versions of patches as roots of new threads, not in reply to any earlier thread. And please adhere to the To: vs Cc: separation there, too. Jan
© 2016 - 2026 Red Hat, Inc.