]> xenbits.xensource.com Git - xen.git/commitdiff
core-parking: fix build with gcc12 and NR_CPUS=1
authorJan Beulich <jbeulich@suse.com>
Tue, 21 Mar 2023 12:50:18 +0000 (13:50 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 21 Mar 2023 12:50:18 +0000 (13:50 +0100)
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@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: 4b0422f70feb4b1cd04598ffde805fc224f3812e
master date: 2023-03-13 15:15:42 +0100

xen/arch/x86/Kconfig
xen/arch/x86/platform_hypercall.c
xen/arch/x86/sysctl.c
xen/common/Kconfig

index 3c14096c8017b392674309d4a3463f5670e4f548..8e2b50492354ac54692b01db7845f82bead4b169 100644 (file)
@@ -8,7 +8,7 @@ config X86
        select ACPI_LEGACY_TABLES_LOOKUP
        select ALTERNATIVE_CALL
        select ARCH_SUPPORTS_INT128
-       select CORE_PARKING
+       imply CORE_PARKING
        select HAS_ALTERNATIVE
        select HAS_COMPAT
        select HAS_CPUFREQ
index bf4090c94201df2617207d366e547a3cca39ddfa..c35e5669a4f96030cd2684eab7c20f811756725d 100644 (file)
@@ -725,12 +725,17 @@ ret_t do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_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;
index aff52a13f373dd1d1d5e39d17b3aea286a529de1..ff843eaee25fa19ae494309390327ef6dedc5e91 100644 (file)
@@ -179,6 +179,9 @@ long arch_do_sysctl(
                 ret = -EBUSY;
                 break;
             }
+            if ( CONFIG_NR_CPUS <= 1 )
+                /* Mimic behavior of smt_up_down_helper(). */
+                return 0;
             plug = op == XEN_SYSCTL_CPU_HOTPLUG_SMT_ENABLE;
             fn = smt_up_down_helper;
             hcpu = _p(plug);
index 64439438891c06d063eb6e630c4342b17a30f789..c9f4b7f49240cc2247c4e3392928b997d6f8dfea 100644 (file)
@@ -10,6 +10,7 @@ config COMPAT
 
 config CORE_PARKING
        bool
+       depends on NR_CPUS > 1
 
 config GRANT_TABLE
        bool "Grant table support" if EXPERT