[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3] core-parking: fix build with gcc12 and NR_CPUS=1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 28 Feb 2023 10:08:42 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9re3QZsju2Hvu85/uQgjvpi6KNtyr011Ea0rEBRmpHs=; b=Wdrro/si4B76djCSi9CMi6psrOJBqs89zQwCkshe8C8AJjXUXVTboBTBUY26vQurhfaE43DB0LqjTa4Qd5QjwYOVVKsfQaGh01xvo+MhTFJZ+BtBPUXLGf140JWpuGtyvJzWWMYQEYhvnbe/mHaU8J7V+dmCrJmGOfXWzKtigLcnSpfOuoQbXdXYeIjTv2nxcOEYhtyN5OJ4/dhySZeOBI4vOjezuT+gW67AHca3Y6LqCwW6Roo9PsxrtYge4Xg8QbQ/TP9miU+M21zE011rrG4pTohchhMziLw3/V1I2VmRuuiMJpcsa84soLq9md8x2/9RiiB8jjZo2yeyrD5PbA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmWiKKEaai+6MbYtAZB49tWVz0RLkdRkdEGHO3LEREHa/HPL4IvX8FdEQnz6P/dPC8C892lf1jjoWVEe4YjKg+aCGKgcDdn2SUY+dK7Y8Hg85hpFb94EAwV+xl8fJr/unZbzf8GIGV4GsYHPJmboFz5TOSomXqzNXCl8uIEdNa49qI/8CgOquyfUnLv4nmi10eUpZEZUlPWKiByZ6c0HDk3XWRSeYmWb6hFfgOfl4IbGkwefEwkKDErrtyUf3YtrCJsgrsz99+QCQ0hIGazknZNhGRw2DYPtBHaUZsbqT6d6C1SkpEZ3sOqsuEHq5qFOvaenCXW5TGytUBdAfpnQ1Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 28 Feb 2023 09:09:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Gcc12 takes issue with core_parking_remove()'s

    for ( ; i < cur_idle_nums; ++i )
        core_parking_cpunum[i] = core_parking_cpunum[i + 1];

complaining that the right hand side array access is past the bounds of
1. Clearly the compiler can't know that cur_idle_nums can only ever be
zero in this case (as the sole CPU cannot be parked).

Arrange for core_parking.c's contents to not be needed altogether, and
then disable its building when NR_CPUS == 1.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3: Use "imply" and "depends on" in Kconfig. Adjust the arch_do_sysctl()
    change.
v2: Disable building of core_parking.c altogether.

--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -10,7 +10,7 @@ config X86
        select ALTERNATIVE_CALL
        select ARCH_MAP_DOMAIN_PAGE
        select ARCH_SUPPORTS_INT128
-       select CORE_PARKING
+       imply CORE_PARKING
        select HAS_ALTERNATIVE
        select HAS_COMPAT
        select HAS_CPUFREQ
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -727,12 +727,17 @@ ret_t do_platform_op(
         case XEN_CORE_PARKING_SET:
             idle_nums = min_t(uint32_t,
                     op->u.core_parking.idle_nums, num_present_cpus() - 1);
-            ret = continue_hypercall_on_cpu(
-                    0, core_parking_helper, (void *)(unsigned long)idle_nums);
+            if ( CONFIG_NR_CPUS > 1 )
+                ret = continue_hypercall_on_cpu(
+                        0, core_parking_helper,
+                        (void *)(unsigned long)idle_nums);
+            else if ( idle_nums )
+                ret = -EINVAL;
             break;
 
         case XEN_CORE_PARKING_GET:
-            op->u.core_parking.idle_nums = get_cur_idle_nums();
+            op->u.core_parking.idle_nums = CONFIG_NR_CPUS > 1
+                                           ? get_cur_idle_nums() : 0;
             ret = __copy_field_to_guest(u_xenpf_op, op, u.core_parking) ?
                   -EFAULT : 0;
             break;
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -152,6 +152,10 @@ long arch_do_sysctl(
         long (*fn)(void *);
         void *hcpu;
 
+        if ( CONFIG_NR_CPUS <= 1 )
+            /* Mimic behavior of the functions otherwise invoked. */
+            return op != XEN_SYSCTL_CPU_HOTPLUG_OFFLINE ? 0 : -EINVAL;
+
         switch ( op )
         {
         case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -10,6 +10,7 @@ config COMPAT
 
 config CORE_PARKING
        bool
+       depends on NR_CPUS > 1
 
 config GRANT_TABLE
        bool "Grant table support" if EXPERT



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.