Skip to contentSkip to conversation

libxl: move calling libxl__arch_domain_construct_memmap to right place

PATCH In review Wei Liu 3 participants 9 messages Aug 5, 2015 – Aug 6, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl: move calling libxl__arch_domain_construct_memmap to right place

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

Move the call of said function to the right place -- before the other two functions which reply on its output.

---
Cc: "Chen, Tiejun" <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>

Discovered this issue by code inspection. This issue is not discovered by osstest because we don't have hardware or test case to test that code path.

Tiejun, can you confirm this is the right fix? Can you test this change?

---
 tools/libxl/libxl_dom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl_dom.c +5 -5
index 5555fea..811f7da 100644
@@ -960,6 +960,11 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
+    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) {
+        LOG(ERROR, "setting domain memory map failed");
+        goto out;
+    }
+
     if (info->num_vnuma_nodes != 0) {
         int i;
 
@@ -997,11 +1002,6 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) {
-        LOG(ERROR, "setting domain memory map failed");
-        goto out;
-    }
-
     ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
Signature · 1 line
2.4.6
#1 lore raw
Quoted 2 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably one or the other of those functions reaches the wrong conclusion?

Quoted 50 lines

Move the call of said function to the right place -- before the other two functions which reply on its output.

---
Cc: "Chen, Tiejun" <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>

Discovered this issue by code inspection. This issue is not discovered by osstest because we don't have hardware or test case to test that code path.

Tiejun, can you confirm this is the right fix? Can you test this change?

---
 tools/libxl/libxl_dom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl_dom.c +5 -5
index 5555fea..811f7da 100644
@@ -960,6 +960,11 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
+    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) 
 {
+        LOG(ERROR, "setting domain memory map failed");
+        goto out;
+    }
+
     if (info->num_vnuma_nodes != 0) {
         int i;
@@ -997,11 +1002,6 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) 
 {
-        LOG(ERROR, "setting domain memory map failed");
-        goto out;
-    }
-
     ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
author
#2 lore raw
Quoted 6 lines · Ian Campbell
Quoted 2 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably one or the other of those functions reaches the wrong conclusion?

Originally, by the time that function got called, all guest pages were already populated. The end result is E820 map disagrees with what vNUMA says and what address ranges memory actually resides, i.e. risk of guest accessing region that doesn't have backing pages.

Quoted 51 lines
Quoted 51 lines

Move the call of said function to the right place -- before the other two functions which reply on its output.

---
Cc: "Chen, Tiejun" <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>

Discovered this issue by code inspection. This issue is not discovered by osstest because we don't have hardware or test case to test that code path.

Tiejun, can you confirm this is the right fix? Can you test this change?

---
 tools/libxl/libxl_dom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl_dom.c +5 -5
index 5555fea..811f7da 100644
@@ -960,6 +960,11 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
+    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) 
 {
+        LOG(ERROR, "setting domain memory map failed");
+        goto out;
+    }
+
     if (info->num_vnuma_nodes != 0) {
         int i;
@@ -997,11 +1002,6 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
         goto out;
     }
 
-    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, &args)) 
 {
-        LOG(ERROR, "setting domain memory map failed");
-        goto out;
-    }
-
     ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
                                &state->console_mfn, state->store_domid,
#3 lore raw
Quoted 5 lines · Wei Liu
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

Quoted 8 lines
Quoted 3 lines

What is the effect of this call being in the wrong place? Presumably one or
the other of those functions reaches the wrong conclusion?

Originally, by the time that function got called, all guest pages were already populated. The end result is E820 map disagrees with what vNUMA says and what address ranges memory actually resides, i.e. risk of guest accessing region that doesn't have backing pages.

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

Although perhaps we should wait for confirmation this fix doesn't regress RMRR somehow?

Quoted 57 lines

Move the call of said function to the right place -- before the other

Quoted 56 lines
Quoted 56 lines

two functions which reply on its output.

---
Cc: "Chen, Tiejun" <[email protected]>
Cc: Ian Campbell <[email protected]>
Cc: Ian Jackson <[email protected]>

Discovered this issue by code inspection. This issue is not discovered
by osstest because we don't have hardware or test case to test that code path.

Tiejun, can you confirm this is the right fix? Can you test this change?

---
 tools/libxl/libxl_dom.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/libxl/libxl_dom.c +5 -0
index 5555fea..811f7da 100644
@@ -960,6 +960,11 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t 
 domid,
         goto out;
     }
 
+    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, 
 &args)) 
 {
+        LOG(ERROR, "setting domain memory map failed");
+        goto out;
+    }
+
     if (info->num_vnuma_nodes != 0) {
         int i;
tools/libxl/libxl_dom.c +0 -5
@@ -997,11 +1002,6 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t 
 domid,
         goto out;
     }
 
-    if (libxl__arch_domain_construct_memmap(gc, d_config, domid, 
 &args)) 
 {
-        LOG(ERROR, "setting domain memory map failed");
-        goto out;
-    }
-
     ret = hvm_build_set_params(ctx->xch, domid, info, state
->store_port,
                                &state->store_mfn, state
->console_port,
                                &state->console_mfn, state

->store_domid,

author
#4 lore raw
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Wei Liu
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably one or
the other of those functions reaches the wrong conclusion?

Quoted 9 lines
Quoted 4 lines

Originally, by the time that function got called, all guest pages were already populated. The end result is E820 map disagrees with what vNUMA says and what address ranges memory actually resides, i.e. risk of guest accessing region that doesn't have backing pages.

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

I will post v2 shortly with that information in commit message.

Quoted 3 lines

Although perhaps we should wait for confirmation this fix doesn't regress RMRR somehow?

I doubt it will. The code as-is is already broken for RMRR. But let's wait till tomorrow for Tiejun to reply.

If he doesn't reply by tomorrow, I suggest we apply v2 first and fix up any subsequent issues later.

Wei.

#5 lore raw
Quoted 33 lines · Wei Liu
Quoted 20 lines · Ian Campbell
Quoted 11 lines · Wei Liu
Quoted 9 lines · Ian Campbell
Quoted 3 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably
one or
the other of those functions reaches the wrong conclusion?

Quoted 7 lines

Originally, by the time that function got called, all guest pages were
already populated. The end result is E820 map disagrees with what vNUMA
says and what address ranges memory actually resides, i.e. risk of guest
accessing region that doesn't have backing pages.

Quoted 4 lines

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

I will post v2 shortly with that information in commit message.

Quoted 4 lines

Although perhaps we should wait for confirmation this fix doesn't regress
RMRR somehow?

Quoted 5 lines

I doubt it will. The code as-is is already broken for RMRR. But let's wait till tomorrow for Tiejun to reply.

If he doesn't reply by tomorrow, I suggest we apply v2 first and fix up any subsequent issues later.

Agreed.

author
#6 lore raw
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 20 lines · Ian Campbell
Quoted 11 lines · Wei Liu
Quoted 9 lines · Ian Campbell
Quoted 3 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably
one or
the other of those functions reaches the wrong conclusion?

Quoted 7 lines

Originally, by the time that function got called, all guest pages were
already populated. The end result is E820 map disagrees with what vNUMA
says and what address ranges memory actually resides, i.e. risk of guest
accessing region that doesn't have backing pages.

Quoted 4 lines

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

I will post v2 shortly with that information in commit message.

Quoted 4 lines

Although perhaps we should wait for confirmation this fix doesn't regress
RMRR somehow?

Quoted 7 lines
Quoted 5 lines

I doubt it will. The code as-is is already broken for RMRR. But let's wait till tomorrow for Tiejun to reply.

If he doesn't reply by tomorrow, I suggest we apply v2 first and fix up any subsequent issues later.

Agreed.

Actually I want to retract this patch. I confused hvm path with pv path and drew my conclusion when looking at both code paths.

In hvm path, neither libxl__vnuma_build_vmemragen_hvm nor xc_hvm_build depends on output of libxl__arch_domain_construct_memmap (in fact it doesn't change anything). So the code is OK.

In pv path, there is a path which relies on having a valid E820 map first, but that path 1) relies on host E820 map; 2) doesn't involve RMRR support.

In the end, moving that function call has no effect whatsoever.

Sorry for the noise!

Wei.

#7 lore raw
Quoted 50 lines · Wei Liu
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 20 lines · Ian Campbell
Quoted 11 lines · Wei Liu
Quoted 9 lines · Ian Campbell
Quoted 3 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably
one or
the other of those functions reaches the wrong conclusion?

Quoted 7 lines

Originally, by the time that function got called, all guest pages were
already populated. The end result is E820 map disagrees with what vNUMA
says and what address ranges memory actually resides, i.e. risk of guest
accessing region that doesn't have backing pages.

Quoted 4 lines

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

I will post v2 shortly with that information in commit message.

Quoted 4 lines

Although perhaps we should wait for confirmation this fix doesn't regress
RMRR somehow?

Quoted 7 lines
Quoted 5 lines

I doubt it will. The code as-is is already broken for RMRR. But let's wait till tomorrow for Tiejun to reply.

If he doesn't reply by tomorrow, I suggest we apply v2 first and fix up any subsequent issues later.

Agreed.

Actually I want to retract this patch. I confused hvm path with pv path and drew my conclusion when looking at both code paths.

In hvm path, neither libxl__vnuma_build_vmemragen_hvm nor xc_hvm_build depends on output of libxl__arch_domain_construct_memmap (in fact it doesn't change anything). So the code is OK.

Quoted 5 lines

In pv path, there is a path which relies on having a valid E820 map first, but that path 1) relies on host E820 map; 2) doesn't involve RMRR support.

In the end, moving that function call has no effect whatsoever.

Sorry I don't go into this details but seems I have nothing to do about this, ultimately. Right?

Thanks
Tiejun

Quoted 6 lines

Sorry for the noise!

Wei.

author
#8 lore raw
Quoted 51 lines · Tiejun
Quoted 50 lines · Wei Liu
Quoted 34 lines · Ian Campbell
Quoted 33 lines · Wei Liu
Quoted 20 lines · Ian Campbell
Quoted 11 lines · Wei Liu
Quoted 9 lines · Ian Campbell
Quoted 3 lines · Wei Liu

This function was called in the wrong place, because both libxl__vnuma_build_vmemrange_hvm and xc_hvm_build rely on its output.

What is the effect of this call being in the wrong place? Presumably
one or
the other of those functions reaches the wrong conclusion?

Quoted 7 lines

Originally, by the time that function got called, all guest pages were
already populated. The end result is E820 map disagrees with what vNUMA
says and what address ranges memory actually resides, i.e. risk of guest
accessing region that doesn't have backing pages.

Quoted 4 lines

Ouch. This should certainly be explained in the commit message.

With that: Acked-by: Ian Campbell <[email protected]>

I will post v2 shortly with that information in commit message.

Quoted 4 lines

Although perhaps we should wait for confirmation this fix doesn't regress
RMRR somehow?

Quoted 7 lines
Quoted 5 lines

I doubt it will. The code as-is is already broken for RMRR. But let's wait till tomorrow for Tiejun to reply.

If he doesn't reply by tomorrow, I suggest we apply v2 first and fix up any subsequent issues later.

Agreed.

Actually I want to retract this patch. I confused hvm path with pv path and drew my conclusion when looking at both code paths.

In hvm path, neither libxl__vnuma_build_vmemragen_hvm nor xc_hvm_build depends on output of libxl__arch_domain_construct_memmap (in fact it doesn't change anything). So the code is OK.

Quoted 9 lines
Quoted 5 lines

In pv path, there is a path which relies on having a valid E820 map first, but that path 1) relies on host E820 map; 2) doesn't involve RMRR support.

In the end, moving that function call has no effect whatsoever.

Sorry I don't go into this details but seems I have nothing to do about this, ultimately. Right?

Yes. Nothing to worry about at the moment.

Wei.

Quoted 9 lines

Thanks
Tiejun

Quoted 6 lines

Sorry for the noise!

Wei.