Skip to contentSkip to conversation

x86/shadow: Fix build with no PG_log_dirty

PATCH In review Andrew Cooper 2 participants 2 messages Mar 23, 2023 – Mar 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/shadow: Fix build with no PG_log_dirty

Gitlab Randconfig found:

arch/x86/mm/shadow/common.c: In function 'shadow_prealloc':
arch/x86/mm/shadow/common.c:1023:18: error: implicit declaration of function
'paging_logdirty_levels'; did you mean 'paging_log_dirty_init'? [-Werror=implicit-function-declaration]

   1023 |         count += paging_logdirty_levels();
        |                  ^~~~~~~~~~~~~~~~~~~~~~
        |                  paging_log_dirty_init

arch/x86/mm/shadow/common.c:1023:18: error: nested extern declaration of 'paging_logdirty_levels' [-Werror=nested-externs]

Move the declaration outside of #if PG_log_dirty.

Fixes 33fb3a661223 ("x86/shadow: account for log-dirty mode when pre-allocating")

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>

An alternative would be to double paging_logdirty_levels() up in the else case, returning 0. The underlying logc in shadow_prealloc() succumbs to DCE either way.

---
 xen/arch/x86/include/asm/paging.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
xen/arch/x86/include/asm/paging.h +4 -4
index 38bec8af2ed1..2ca22f20adff 100644
@@ -149,6 +149,10 @@ struct paging_mode {
 /*****************************************************************************
  * Log dirty code */
 
+#define paging_logdirty_levels() \
+    (DIV_ROUND_UP(PADDR_BITS - PAGE_SHIFT - (PAGE_SHIFT + 3), \
+                  PAGE_SHIFT - ilog2(sizeof(mfn_t))) + 1)
+
 #if PG_log_dirty
 
 /* get the dirty bitmap for a specific range of pfns */
@@ -187,10 +191,6 @@ bool paging_mfn_is_dirty(const struct domain *d, mfn_t gmfn);
 #define L4_LOGDIRTY_IDX(pfn) ((pfn_x(pfn) >> (PAGE_SHIFT + 3 + PAGETABLE_ORDER * 2)) & \
                               (LOGDIRTY_NODE_ENTRIES-1))
 
-#define paging_logdirty_levels() \
-    (DIV_ROUND_UP(PADDR_BITS - PAGE_SHIFT - (PAGE_SHIFT + 3), \
-                  PAGE_SHIFT - ilog2(sizeof(mfn_t))) + 1)
-
 #ifdef CONFIG_HVM
 /* VRAM dirty tracking support */
 struct sh_dirty_vram {
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andrew Cooper

Gitlab Randconfig found:

arch/x86/mm/shadow/common.c: In function 'shadow_prealloc':
arch/x86/mm/shadow/common.c:1023:18: error: implicit declaration of function
'paging_logdirty_levels'; did you mean 'paging_log_dirty_init'? [-Werror=implicit-function-declaration]

   1023 |         count += paging_logdirty_levels();
        |                  ^~~~~~~~~~~~~~~~~~~~~~
        |                  paging_log_dirty_init

arch/x86/mm/shadow/common.c:1023:18: error: nested extern declaration of 'paging_logdirty_levels' [-Werror=nested-externs]

Okay, that's SHADOW_PAGING && !HVM && PV_SHIM_EXCLUSIVE - I can see how I missed to test that case.

Quoted 4 lines

Move the declaration outside of #if PG_log_dirty.

Fixes 33fb3a661223 ("x86/shadow: account for log-dirty mode when pre-allocating")
Quoted 3 lines

An alternative would be to double paging_logdirty_levels() up in the else case, returning 0. The underlying logc in shadow_prealloc() succumbs to DCE either way.

I think I prefer the way you have it.

Jan