x86/shadow: Delete the none.c dummy file
PATCH 1/1 x86/shadow: Delete the none.c dummy file
It only has 2 callers, both of which can be conditionally removed.
---
I'd be ok conditionalising the else branch on...
IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)
logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so none.c is only compiled out in that case.
I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.c
xen/arch/x86/mm/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/ obj-$(CONFIG_ALTP2M) += altp2m.o
xen/arch/x86/mm/paging.c +2 -2
@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);return rc;
@@ -645,7 +645,7 @@ void paging_vcpu_init(struct vcpu *v) {if (hap_enabled (v->domain) )hap_vcpu_init (v); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) )shadow_vcpu_init (v); }
xen/arch/x86/mm/shadow/Makefile +0 -4
@@ -1,7 +1,3 @@ -ifeq ($(CONFIG_SHADOW_PAGING),y) obj-y += common.o set.o obj-$(CONFIG_HVM) += hvm.o guest_2.o guest_3.o guest_4.o oos.o obj-$(CONFIG_PV) += pv.o guest_4.o -else -obj-y += none.o -endif
xen/arch/x86/mm/shadow/none.c deleted +0 -77
77 lines not on this page · raw message
base-commit: 1ee8b11c1106dca6b8fe0d54c0e79146bb6545f0
Signature · 1 line
2.43.0
Quoted 6 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...
Quoted 6 lines
IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.
I'm not sure I understand this remark. Is this about something in the other patch (which I haven't looked at yet), or ...
Quoted 12 lines
xen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);return rc;
xen/arch/x86/mm/paging.c void paging_vcpu_init(struct vcpu *v) · line 650
Quoted 7 lines
xen/arch/x86/mm/paging.c +1
-1@@ -645,7 +645,7 @@ void paging_vcpu_init(struct vcpu *v) {if (hap_enabled (v->domain) )hap_vcpu_init (v); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) )shadow_vcpu_init (v); }
... these two hunks? In this latter case, I don't think the bigger conditional would be correct.
Quoted 22 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-19@@ -1,77 +0,0 @@ -#include <xen/mm.h> -#include <asm/shadow.h> - -static int cf_check _toggle_log_dirty(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -return -EOPNOTSUPP ; -} - -static void cf_check _clean_dirty_bitmap(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -} - -static void cf_check _update_paging_modes(struct vcpu *v) -{ -ASSERT_UNREACHABLE (); -} -
xen/arch/x86/mm/shadow/none.c line 29
Quoted 10 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-10-int shadow_domain_init (struct domain *d) -{ -/* For HVM set up pointers for safety, then fail. */ -static const struct log_dirty_ops sh_none_ops = { - .enable = _toggle_log_dirty, - .disable = _toggle_log_dirty, - .clean = _clean_dirty_bitmap, - }; - -paging_log_dirty_init (d, &sh_none_ops);
How do you avoid d->arch.paging.log_dirty.ops remaining NULL with this removed?
xen/arch/x86/mm/shadow/none.c line 31
Quoted 1 line
xen/arch/x86/mm/shadow/none.c deleted +0
-1- d->arch.paging.update_paging_modes = _update_paging_modes;
Same question for this function pointer.
Quoted 34 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-34-return is_hvm_domain (d) ? -EOPNOTSUPP :0 ; -} - -static int cf_check _page_fault( -struct vcpu *v,unsigned long va,struct cpu_user_regs *regs) -{ -ASSERT_UNREACHABLE (); -return 0 ; -} - -static bool cf_check _invlpg(struct vcpu *v, unsigned long linear) -{ -ASSERT_UNREACHABLE (); -return true; -} - -#ifdef CONFIG_HVM -static unsigned long cf_check _gva_to_gfn ( -struct vcpu *v,struct p2m_domain *p2m,unsigned long va,uint32_t *pfec) -{ -ASSERT_UNREACHABLE (); -return gfn_x (INVALID_GFN ); -} -#endif - -static pagetable_t cf_check _update_cr3(struct vcpu *v, bool noflush) -{ -ASSERT_UNREACHABLE (); -return pagetable_null (); -} - -static const struct paging_mode sh_paging_none = { - .page_fault = _page_fault, - .invlpg = _invlpg,
xen/arch/x86/mm/shadow/none.c line 76
Quoted 10 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-10-#ifdef CONFIG_HVM - .gva_to_gfn = _gva_to_gfn, -#endif - .update_cr3 = _update_cr3, -}; - -void shadow_vcpu_init (struct vcpu *v) -{ -ASSERT (is_pv_vcpu (v)); - v->arch.paging.mode = &sh_paging_none;
And the same question yet again for this pointer.
Jan
Quoted 27 lines · Jan Beulich
Quoted 6 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...Quoted 6 lines
IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure I understand this remark. Is this about something in the other patch (which I haven't looked at yet), or ...
Quoted 10 lines
xen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);
Quoted 12 lines
xen/arch/x86/mm/paging.c void paging_vcpu_init(struct vcpu *v) · line 650
Quoted 9 lines
xen/arch/x86/mm/paging.c +1
-1return rc;@@ -645,7 +645,7 @@ void paging_vcpu_init(struct vcpu *v) {if (hap_enabled (v->domain) )hap_vcpu_init (v); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) )shadow_vcpu_init (v); }... these two hunks? In this latter case, I don't think the bigger conditional would be correct.
It'd be about these hunks and the inclusion condition for shadow/. I suggest that because...
Quoted 28 lines
Quoted 28 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-24@@ -1,77 +0,0 @@ -#include <xen/mm.h> -#include <asm/shadow.h> - -static int cf_check _toggle_log_dirty(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -return -EOPNOTSUPP ; -} - -static void cf_check _clean_dirty_bitmap(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -} - -static void cf_check _update_paging_modes(struct vcpu *v) -{ -ASSERT_UNREACHABLE (); -} - -int shadow_domain_init (struct domain *d) -{ -/* For HVM set up pointers for safety, then fail. */ -static const struct log_dirty_ops sh_none_ops = { - .enable = _toggle_log_dirty,
Quoted 8 lines
xen/arch/x86/mm/shadow/none.c line 29
Quoted 5 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-5- .disable = _toggle_log_dirty, - .clean = _clean_dirty_bitmap, - }; - -paging_log_dirty_init (d, &sh_none_ops);How do you avoid
d->arch.paging.log_dirty.opsremaining NULL with this removed?
... as you point out, the ops don't get initialised. Adding the log-dirty condition ensures there's no uninitialised ops (even when unreachable).
Quoted 7 lines
xen/arch/x86/mm/shadow/none.c line 31
Quoted 2 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-1- d->arch.paging.update_paging_modes = _update_paging_modes;Same question for this function pointer.
Quoted 2 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-2-return is_hvm_domain (d) ? -EOPNOTSUPP :0 ; -}
Oh. This was a hard miss, true that.
Quoted 45 lines
Quoted 32 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-32- -static int cf_check _page_fault( -struct vcpu *v,unsigned long va,struct cpu_user_regs *regs) -{ -ASSERT_UNREACHABLE (); -return 0 ; -} - -static bool cf_check _invlpg(struct vcpu *v, unsigned long linear) -{ -ASSERT_UNREACHABLE (); -return true; -} - -#ifdef CONFIG_HVM -static unsigned long cf_check _gva_to_gfn ( -struct vcpu *v,struct p2m_domain *p2m,unsigned long va,uint32_t *pfec) -{ -ASSERT_UNREACHABLE (); -return gfn_x (INVALID_GFN ); -} -#endif - -static pagetable_t cf_check _update_cr3(struct vcpu *v, bool noflush) -{ -ASSERT_UNREACHABLE (); -return pagetable_null (); -} - -static const struct paging_mode sh_paging_none = { - .page_fault = _page_fault, - .invlpg = _invlpg,xen/arch/x86/mm/shadow/none.c line 76
Quoted 10 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-10-#ifdef CONFIG_HVM - .gva_to_gfn = _gva_to_gfn, -#endif - .update_cr3 = _update_cr3, -}; - -void shadow_vcpu_init (struct vcpu *v) -{ -ASSERT (is_pv_vcpu (v)); - v->arch.paging.mode = &sh_paging_none;And the same question yet again for this pointer.
Quoted 1 line
Jan
However, on the whole. Under what circumstances are these handlers invoked?
They are only compiled in for !CONFIG_SHADOW. But these are only applied with HAP disabled. Are they for PV or something?
Cheers,
Alejandro
Quoted 81 lines · Alejandro Vallejo
Quoted 27 lines · Jan Beulich
Quoted 6 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...Quoted 6 lines
IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure I understand this remark. Is this about something in the other patch (which I haven't looked at yet), or ...
Quoted 10 lines
xen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);Quoted 12 lines
xen/arch/x86/mm/paging.c void paging_vcpu_init(struct vcpu *v) · line 650
Quoted 9 lines
xen/arch/x86/mm/paging.c +1
-1return rc;@@ -645,7 +645,7 @@ void paging_vcpu_init(struct vcpu *v) {if (hap_enabled (v->domain) )hap_vcpu_init (v); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) )shadow_vcpu_init (v); }... these two hunks? In this latter case, I don't think the bigger conditional would be correct.
It'd be about these hunks and the inclusion condition for shadow/. I suggest that because...
Quoted 28 lines
Quoted 28 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-24@@ -1,77 +0,0 @@ -#include <xen/mm.h> -#include <asm/shadow.h> - -static int cf_check _toggle_log_dirty(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -return -EOPNOTSUPP ; -} - -static void cf_check _clean_dirty_bitmap(struct domain *d) -{ -ASSERT (is_pv_domain (d)); -} - -static void cf_check _update_paging_modes(struct vcpu *v) -{ -ASSERT_UNREACHABLE (); -} - -int shadow_domain_init (struct domain *d) -{ -/* For HVM set up pointers for safety, then fail. */ -static const struct log_dirty_ops sh_none_ops = { - .enable = _toggle_log_dirty,Quoted 8 lines
xen/arch/x86/mm/shadow/none.c line 29
Quoted 5 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-5- .disable = _toggle_log_dirty, - .clean = _clean_dirty_bitmap, - }; - -paging_log_dirty_init (d, &sh_none_ops);How do you avoid
d->arch.paging.log_dirty.opsremaining NULL with this removed?
Quoted 2 lines
... as you point out, the ops don't get initialised. Adding the log-dirty condition ensures there's no uninitialised ops (even when unreachable).
IOW the remark is kind of (but not quite) making that other change a prereq? (See my remark there as to typing together SHADOW_PAGING and LOG_DIRTY.)
Quoted 54 lines
Quoted 6 lines
xen/arch/x86/mm/shadow/none.c line 31
Quoted 1 line
xen/arch/x86/mm/shadow/none.c deleted +0
-1- d->arch.paging.update_paging_modes = _update_paging_modes;Same question for this function pointer.
Quoted 2 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-2-return is_hvm_domain (d) ? -EOPNOTSUPP :0 ; -}Oh. This was a hard miss, true that.
Quoted 36 lines
Quoted 36 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-36- -static int cf_check _page_fault( -struct vcpu *v,unsigned long va,struct cpu_user_regs *regs) -{ -ASSERT_UNREACHABLE (); -return 0 ; -} - -static bool cf_check _invlpg(struct vcpu *v, unsigned long linear) -{ -ASSERT_UNREACHABLE (); -return true; -} - -#ifdef CONFIG_HVM -static unsigned long cf_check _gva_to_gfn ( -struct vcpu *v,struct p2m_domain *p2m,unsigned long va,uint32_t *pfec) -{ -ASSERT_UNREACHABLE (); -return gfn_x (INVALID_GFN ); -} -#endif - -static pagetable_t cf_check _update_cr3(struct vcpu *v, bool noflush) -{ -ASSERT_UNREACHABLE (); -return pagetable_null (); -} - -static const struct paging_mode sh_paging_none = { - .page_fault = _page_fault, - .invlpg = _invlpg, -#ifdef CONFIG_HVM - .gva_to_gfn = _gva_to_gfn, -#endif - .update_cr3 = _update_cr3,Quoted 8 lines
xen/arch/x86/mm/shadow/none.c line 76
Quoted 6 lines
xen/arch/x86/mm/shadow/none.c deleted +0
-6-}; - -void shadow_vcpu_init (struct vcpu *v) -{ -ASSERT (is_pv_vcpu (v)); - v->arch.paging.mode = &sh_paging_none;And the same question yet again for this pointer.
Quoted 4 lines
However, on the whole. Under what circumstances are these handlers invoked?
They are only compiled in for !CONFIG_SHADOW. But these are only applied with HAP disabled. Are they for PV or something?
The .gva_to_gfn hook is clearly HVM-only. We still want to be sure to have no NULL pointers around that we could stumble across, especially as long as PV=y.
Jan
Quoted 37 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/ obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +0
-0
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 6 lines
xen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);
If you want to go this route you will need to set rc = -EOPNOTSUPP; prior to the if ... else if on the HVM case. Otherwise when shadow is compiled out, and the toolstack has not specified the HAP flag at domain creation you will end up with a domain that doesn't have the paging operations initialized as paging_domain_init() would return 0 with neither HAP nor shadow having been setup. That's likely to trigger NULL pointer dereferences inside of Xen.
Also, seeing the code in arch_sanitise_domain_config() we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.
Thanks, Roger.
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/
Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.
Maybe this instead
else
rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;And gate none.c on PV && !SHADOW_PAGING, which seems to be the only use.
It's a lot easier to see the safety on the HVM-only case, particularly with...
Quoted 10 lines
is compiled out, and the toolstack has not specified the HAP flag at domain creation you will end up with a domain that doesn't have the paging operations initialized as
paging_domain_init()would return 0 with neither HAP nor shadow having been setup. That's likely to trigger NULL pointer dereferences inside of Xen.Also, seeing the code in
arch_sanitise_domain_config()we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.
... this patch you meantion. Thanks.
I'm guessing it's still a hot potato in for non-shadow PV, which strongly hints at our being better off leaving it in that case. On HVM-only configurations it seems rather silly.
Cheers,
Alejandro
Quoted 49 lines · Alejandro Vallejo
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.
Quoted 4 lines
Maybe this instead
else rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;
But even for the PV case we cannot call shadow_domain_init() if shadow is compiled out? I think you want:
if ( hap_enabled(d) )
hap_domain_init(d);
else if ( IS_ENABLED(CONFIG_SHADOW_PAGING) )
rc = shadow_domain_init(d);
else
rc = is_hvm_domain(d) ? -EOPNOTSUPP : 0;Quoted 15 lines
And gate
none.con PV && !SHADOW_PAGING, which seems to be the only use.It's a lot easier to see the safety on the HVM-only case, particularly with...
Quoted 10 lines
is compiled out, and the toolstack has not specified the HAP flag at domain creation you will end up with a domain that doesn't have the paging operations initialized as
paging_domain_init()would return 0 with neither HAP nor shadow having been setup. That's likely to trigger NULL pointer dereferences inside of Xen.Also, seeing the code in
arch_sanitise_domain_config()we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.
Quoted 5 lines
... this patch you meantion. Thanks.
I'm guessing it's still a hot potato in for non-shadow PV, which strongly hints at our being better off leaving it in that case. On HVM-only configurations it seems rather silly.
I'm not sure I follow exactly what you mean. Some rants below which might or might not be along the lines of what you suggest.
PV needs shadow for migration. HVM can use shadow or HAP, and our default is HAP. For HVM only builds it could be possible to not recommend enabling shadow. Even for deployments where only dom0 is using PV mode, it does still make sense to possible recommend not enabling shadow for attack surface reduction.
Thanks, Roger.
Quoted 58 lines · Roger Pau Monné
Quoted 49 lines · Alejandro Vallejo
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.Quoted 4 lines
Maybe this instead
else rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;But even for the PV case we cannot call
shadow_domain_init()if shadow is compiled out? I think you want:
Quoted 6 lines
if ( hap_enabled(d) )
hap_domain_init(d);
else if ( IS_ENABLED(CONFIG_SHADOW_PAGING) )
rc = shadow_domain_init(d);
else
rc = is_hvm_domain(d) ? -EOPNOTSUPP : 0;Wouldn't this still leave NULL pointers in places where they can be rather dangerous with PV guests?
Jan
Quoted 66 lines · Jan Beulich
Quoted 58 lines · Roger Pau Monné
Quoted 49 lines · Alejandro Vallejo
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.Quoted 4 lines
Maybe this instead
else rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;But even for the PV case we cannot call
shadow_domain_init()if shadow is compiled out? I think you want:Quoted 6 lines
if ( hap_enabled(d) ) hap_domain_init(d); else if ( IS_ENABLED(CONFIG_SHADOW_PAGING) ) rc = shadow_domain_init(d); else rc = is_hvm_domain(d) ? -EOPNOTSUPP : 0;
Quoted 2 lines
Wouldn't this still leave NULL pointers in places where they can be rather dangerous with PV guests?
Possibly, I didn't look much further on this patch, as returning rc == 0 and not having initialized neither HAP nor shadow is likely to already lead to NULL pointer dereferences.
Regards, Roger.
Quoted 58 lines · Roger Pau Monné
Quoted 49 lines · Alejandro Vallejo
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.Quoted 4 lines
Maybe this instead
else rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;But even for the PV case we cannot call
shadow_domain_init()if shadow is compiled out? I think you want:
Quoted 7 lines
if ( hap_enabled(d) )
hap_domain_init(d);
else if ( IS_ENABLED(CONFIG_SHADOW_PAGING) )
rc = shadow_domain_init(d);
else
rc = is_hvm_domain(d) ? -EOPNOTSUPP : 0;none.c would need to stay in PV for what I proposed. For what you proposed PV would return 0, but all the hooks would be gone. And I really don't know if they would be triggered or not.
Quoted 15 lines
Quoted 15 lines
And gate
none.con PV && !SHADOW_PAGING, which seems to be the only use.It's a lot easier to see the safety on the HVM-only case, particularly with...
Quoted 10 lines
is compiled out, and the toolstack has not specified the HAP flag at domain creation you will end up with a domain that doesn't have the paging operations initialized as
paging_domain_init()would return 0 with neither HAP nor shadow having been setup. That's likely to trigger NULL pointer dereferences inside of Xen.Also, seeing the code in
arch_sanitise_domain_config()we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.
Quoted 7 lines
Quoted 5 lines
... this patch you meantion. Thanks.
I'm guessing it's still a hot potato in for non-shadow PV, which strongly hints at our being better off leaving it in that case. On HVM-only configurations it seems rather silly.
I'm not sure I follow exactly what you mean.
I'm not sure _I_ follow exactly what I mean. Part of the confusion is the overloaded use of "shadow" to mean "shadow paging" and "fault-and-track" of logdirty behaviour.
Quoted 2 lines
Some rants below which
might or might not be along the lines of what you suggest.
Thanks.
Quoted 2 lines
PV needs shadow for migration.
shadow in the sense of shadow paging? So PV-only + !SHADOW means migrations are impossible? Why can't Xen operate on the PV pagetables rather than using shadow?
Quoted 1 line
HVM can use shadow or HAP, and our default is HAP.
For regular use or migrations?
Quoted 4 lines
For HVM only builds it could be possible to not recommend enabling shadow. Even for deployments where only dom0 is using PV mode, it does still make sense to possible recommend not enabling shadow for attack surface reduction.
What do you mean by "enabling shadow"? compiling it in? Running HVM without HAP?
Cheers,
Alejandro
Quoted 14 lines · Alejandro Vallejo
Quoted 13 lines · Roger Pau Monné
Quoted 11 lines · Alejandro Vallejo
Quoted 4 lines · Roger Pau Monné
Also, seeing the code in
arch_sanitise_domain_config()we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.... this patch you meantion. Thanks.
I'm guessing it's still a hot potato in for non-shadow PV, which strongly hints at our being better off leaving it in that case. On HVM-only configurations it seems rather silly.
Quoted 5 lines
Quoted 1 line
I'm not sure I follow exactly what you mean.
I'm not sure _I_ follow exactly what I mean. Part of the confusion is the overloaded use of "shadow" to mean "shadow paging" and "fault-and-track" of logdirty behaviour.
There's no such overload, I don't think. Shadow paging is _needed_ for certain operations. E.g. to put a PV guest in log-dirty mode.
Quoted 6 lines
Quoted 2 lines
Some rants below which
might or might not be along the lines of what you suggest.Thanks.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
PV needs shadow for migration.
shadow in the sense of shadow paging? So PV-only + !SHADOW means migrations are impossible? Why can't Xen operate on the PV pagetables rather than using shadow?
Quoted 1 line
HVM can use shadow or HAP, and our default is HAP.
For regular use or migrations?
HVM guests always have paging enabled - either HAP or shadow. Hence this distinction makes sense only for PV. However, the answer is still: Both. Because besides for log-dirty tracking, shadow mode is also used there to mitigate L1TF for guests not doing so on their own.
Jan
Quoted 67 lines · Alejandro Vallejo
Quoted 58 lines · Roger Pau Monné
Quoted 49 lines · Alejandro Vallejo
Quoted 32 lines · Roger Pau Monné
Quoted 31 lines · Alejandro Vallejo
It only has 2 callers, both of which can be conditionally removed.
Signed-off-by Alejandro Vallejo <[email protected]>---
I'd be ok conditionalising the else branch on...IS_ENABLED(CONFIG_SHADOW_PAGING )|| IS_ENABLED(CONFIG_LOG_DIRTY)logdirty patch: https://lore.kernel.org/xen-devel/[email protected]
... to avoid the danger of stale pointers, with required changes elsewhere so
none.cis only compiled out in that case.I'm not sure how much it matters seeing how they are all unreachable.
--- xen/arch/x86/mm/Makefile | 2 +- xen/arch/x86/mm/paging.c | 4 +- xen/arch/x86/mm/shadow/Makefile | 4 -- xen/arch/x86/mm/shadow/none.c | 77 --------------------------------- 4 files changed, 3 insertions(+), 84 deletions(-) delete mode 100644 xen/arch/x86/mm/shadow/none.cxen/arch/x86/mm/Makefile +1
-1@@ -1,4 +1,4 @@ -obj-y += shadow/ +obj-$(CONFIG_SHADOW_PAGING) += shadow/ obj-$(CONFIG_HVM) += hap/Quoted 15 lines
xen/arch/x86/mm/paging.c int paging_domain_init(struct domain *d) · line 638
Quoted 12 lines
xen/arch/x86/mm/Makefile +0
-0obj-$(CONFIG_ALTP2M) += altp2m.oxen/arch/x86/mm/paging.c +1
-1@@ -634,7 +634,7 @@ int paging_domain_init(struct domain *d)*/ if (hap_enabled (d) )hap_domain_init (d); -else +else if (IS_ENABLED (CONFIG_SHADOW_PAGING ) ) rc =shadow_domain_init (d);If you want to go this route you will need to set rc =
-EOPNOTSUPP; prior to theif ... else ifon the HVM case.Quoted 4 lines
Maybe this instead
else rc = IS_ENABLED(PV) ? shadow_domain_init(d) : -EOPNOTSUPP;But even for the PV case we cannot call
shadow_domain_init()if shadow is compiled out? I think you want:Quoted 7 lines
if ( hap_enabled(d) ) hap_domain_init(d); else if ( IS_ENABLED(CONFIG_SHADOW_PAGING) ) rc = shadow_domain_init(d); else rc = is_hvm_domain(d) ? -EOPNOTSUPP : 0;
Quoted 3 lines
none.cwould need to stay in PV for what I proposed. For what you proposed PV would return 0, but all the hooks would be gone. And I really don't know if they would be triggered or not.
Oh, OK, so that would already diverge form the current patch - in this proposal you completely remove none.c. I see at least two of the hooks look to be reachable from PV seeing the ASSERTs in there, or at least that was the expectation.
Quoted 30 lines
Quoted 15 lines
Quoted 15 lines
And gate
none.con PV && !SHADOW_PAGING, which seems to be the only use.It's a lot easier to see the safety on the HVM-only case, particularly with...
Quoted 10 lines
is compiled out, and the toolstack has not specified the HAP flag at domain creation you will end up with a domain that doesn't have the paging operations initialized as
paging_domain_init()would return 0 with neither HAP nor shadow having been setup. That's likely to trigger NULL pointer dereferences inside of Xen.Also, seeing the code in
arch_sanitise_domain_config()we possibly want to return an error at that point if toolstack attempts to create an HVM guest without HAP enabled, and shadow is build time disabled. I've sent a patch to that end.Quoted 7 lines
Quoted 5 lines
... this patch you meantion. Thanks.
I'm guessing it's still a hot potato in for non-shadow PV, which strongly hints at our being better off leaving it in that case. On HVM-only configurations it seems rather silly.
I'm not sure I follow exactly what you mean.
I'm not sure _I_ follow exactly what I mean. Part of the confusion is the overloaded use of "shadow" to mean "shadow paging" and "fault-and-track" of logdirty behaviour.
Quoted 2 lines
Some rants below which
might or might not be along the lines of what you suggest.
Quoted 7 lines
Thanks.
Quoted 2 lines
PV needs shadow for migration.
shadow in the sense of shadow paging? So PV-only + !SHADOW means migrations are impossible? Why can't Xen operate on the PV pagetables rather than using shadow?
At the time it was likely seen as easier to re-use the shadow code rather than add more complexity to the PV one?
Quoted 3 lines
Quoted 1 line
HVM can use shadow or HAP, and our default is HAP.
For regular use or migrations?
HAP doesn't need shadow to perform migrations, so in HVM there's no dependency between HAP and shadow.
Quoted 6 lines
Quoted 4 lines
For HVM only builds it could be possible to not recommend enabling shadow. Even for deployments where only dom0 is using PV mode, it does still make sense to possible recommend not enabling shadow for attack surface reduction.
What do you mean by "enabling shadow"? compiling it in? Running HVM without HAP?
I meant not compiling it in. If the only PV guest running on the system is dom0, and the domUs are all HVM + HAP, you don't need shadow for neither of them. PV dom0 will never migrate, and HVM + HAP domUs won't use the shadow code for migration (or anything).
Thanks, Roger.
Quoted 6 lines · Alejandro Vallejo
Quoted 5 lines · Roger Pau Monné
Quoted 4 lines · Alejandro Vallejo
Quoted 1 line · Roger Pau Monné
PV needs shadow for migration.
shadow in the sense of shadow paging? So PV-only + !SHADOW means migrations are impossible? Why can't Xen operate on the PV pagetables rather than using shadow?
This question doesn't appear to have been answered.
Because PV guests can read their own pagetabes, and need to not see an absence of _PAGE_RW where it has a writeable page.
~Andrew