* [PATCH v4] core-parking: fix build with gcc12 and NR_CPUS=1
@ 2023-02-28 12:34 Jan Beulich
2023-03-13 13:36 ` Andrew Cooper
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2023-02-28 12:34 UTC (permalink / raw
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
Wei Liu, Roger Pau Monné
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>
---
v4: Restrict the arch_do_sysctl() change.
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
@@ -178,6 +178,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);
--- 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v4] core-parking: fix build with gcc12 and NR_CPUS=1
2023-02-28 12:34 [PATCH v4] core-parking: fix build with gcc12 and NR_CPUS=1 Jan Beulich
@ 2023-03-13 13:36 ` Andrew Cooper
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cooper @ 2023-03-13 13:36 UTC (permalink / raw
To: Jan Beulich, xen-devel@lists.xenproject.org
Cc: George Dunlap, Julien Grall, Stefano Stabellini, Wei Liu,
Roger Pau Monné
On 28/02/2023 12:34 pm, Jan Beulich wrote:
> 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>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-13 13:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 12:34 [PATCH v4] core-parking: fix build with gcc12 and NR_CPUS=1 Jan Beulich
2023-03-13 13:36 ` Andrew Cooper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).