[PATCH] tools/xl: vcpu-pin: Skip global affinity when the hard affinity is not changed

Julien Grall posted 1 patch 3 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20200430110051.8965-1-julien@xen.org
Maintainers: Anthony PERARD <anthony.perard@citrix.com>, Wei Liu <wl@xen.org>, Ian Jackson <ian.jackson@eu.citrix.com>
tools/xl/xl_vcpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tools/xl: vcpu-pin: Skip global affinity when the hard affinity is not changed
Posted by Julien Grall 3 years, 11 months ago
From: Julien Grall <jgrall@amazon.com>

After XSA-273, it is not possible to modify the vCPU soft affinity using
xl vcpu-pin without modifying the hard affinity. Instead the command
will crash.

42sh> gdb /usr/local/sbin/xl
(gdb) r vcpu-pin 0 0 - 10
[...]
Program received signal SIGSEGV, Segmentation fault.
[...]
(gdb) bt

This is happening because 'xl' will use NULL when an affinity doesn't
need to be modified. However, we will still try to apply the global
affinity in the this case.

As the hard affinity is not changed, then we don't need to apply the
global affinity. So skip it when hard is NULL.

Backport: 4.6+ # Any release with XSA-273
Fixes: aa67b97ed342 ("xl.conf: Add global affinity masks")
Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
 tools/xl/xl_vcpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
index 9ff5354f749b..66877a57dee4 100644
--- a/tools/xl/xl_vcpu.c
+++ b/tools/xl/xl_vcpu.c
@@ -283,7 +283,7 @@ int main_vcpupin(int argc, char **argv)
     }
 
     /* Only hard affinity matters here */
-    if (!ignore_masks) {
+    if (!ignore_masks && hard) {
         libxl_dominfo dominfo;
 
         if (libxl_domain_info(ctx, &dominfo, domid)) {
-- 
2.17.1


Re: [PATCH] tools/xl: vcpu-pin: Skip global affinity when the hard affinity is not changed
Posted by Wei Liu 3 years, 11 months ago
On Thu, Apr 30, 2020 at 12:00:51PM +0100, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> After XSA-273, it is not possible to modify the vCPU soft affinity using
> xl vcpu-pin without modifying the hard affinity. Instead the command
> will crash.
> 
> 42sh> gdb /usr/local/sbin/xl
> (gdb) r vcpu-pin 0 0 - 10
> [...]
> Program received signal SIGSEGV, Segmentation fault.
> [...]
> (gdb) bt
> 
> This is happening because 'xl' will use NULL when an affinity doesn't
> need to be modified. However, we will still try to apply the global
> affinity in the this case.
> 
> As the hard affinity is not changed, then we don't need to apply the
> global affinity. So skip it when hard is NULL.
> 
> Backport: 4.6+ # Any release with XSA-273
> Fixes: aa67b97ed342 ("xl.conf: Add global affinity masks")
> Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
> Signed-off-by: Julien Grall <jgrall@amazon.com>

Acked-by: Wei Liu <wl@xen.org>

> ---
>  tools/xl/xl_vcpu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/xl/xl_vcpu.c b/tools/xl/xl_vcpu.c
> index 9ff5354f749b..66877a57dee4 100644
> --- a/tools/xl/xl_vcpu.c
> +++ b/tools/xl/xl_vcpu.c
> @@ -283,7 +283,7 @@ int main_vcpupin(int argc, char **argv)
>      }
>  
>      /* Only hard affinity matters here */
> -    if (!ignore_masks) {
> +    if (!ignore_masks && hard) {
>          libxl_dominfo dominfo;
>  
>          if (libxl_domain_info(ctx, &dominfo, domid)) {
> -- 
> 2.17.1
>