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

Re: [PATCH 1/4] xen: make stop_machine_run() take const void *


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 17 Nov 2026 21:44:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HJzR1wUEaX8q2Ib14WNH4EogHp/b+IvlKUADDKOReSQ=; b=QaDpvMg5yC58RPQGbT1F1PBJgGz8Gnko3ZfDn2Zi+htNgiyG7PJsn4a/+7IiFOLLgsRk+833oIOYz39wzFp079c93MF4NfxhlPQH0h4QvmtpIKP95Y8E3tNyujIQk6fSWaAv+oBhGpiNIybxKHpMKOIdJXAC4bQpu5yqdQskiMSRvpeIVGlYJ1qGI+FJTt7bkh1G7UknQ0nb5zebIjanswzNSR0ZcXAoXCZUKTHZHTTKq5JqO371jMYpdezfuD3Z7fMTQAx7xH+1IdrtfCoGJjuIDMtG1Yk7aCnzNM0d3kaPVXC6WLtbooPmCCaa/LUjNfXGESdabb4Xo7GLh+5rmA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IejFVDUaLsiYoaunGs9/Jplvtew3ginMzXbFC6mIA7P60YX4inxCnWmQo8QSWB2+sbEdJxMUCHseG7van82btGZWbZgefHJ97LtGC0zhkNBGqHe5fUCjeK52lKWGmgfHKCV+Y/9iscVM5kMWbDCFqn0JCGQOhVJJ+00LibiSHe6eMlKOHGAoogeORC2m1PMpm9MwIJtQ1A4kQ3m4mW6503AfYbYZomSqru6GI/uVzwyFLHehbZLzmkK+x9bKQSad6dYmN4yaYK/uJE7TANSGdZ93w0DGQbzbZVOwqjF7uEP+nK1UbnehCTMnX/5yne+28n7q7LoShByZEr+6etpHHQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Tue, 17 Nov 2026 19:44:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 11/4/26 13:49, Andrew Cooper wrote:
On 03/11/2026 10:29 am, Dmytro Prokopchuk1 wrote:
MISRA C Rule 11.8 forbids casts that remove the const qualifier from
the pointed-to type. On Arm, enable_cpu_capabilities() and
enable_nonboot_cpu_caps() cast a const struct arm_cpu_capabilities
pointer to void * so that it can be passed to the capability enable
callback, either directly or through stop_machine_run().

None of the stop_machine_run() callbacks modify the data they are
given. Make stop_machine_run() and its callback type take const void *,
and update the callbacks to match:

  - the Arm capability enable hook and its implementations
    (enable_smccc_arch_workaround_1(), enable_spectre_bhb_workaround(),
    enable_bp_inv_hardening() and enable_ic_inv_hardening()),
  - __apply_alternatives_multi_stop() on Arm,
  - do_microcode_update() on x86,
  - take_cpu_down() in common code.

This allows the casts in cpufeature.c to be dropped.

take_cpu_down() is always invoked with NULL, so it now passes NULL to
_take_cpu_down() explicitly. _take_cpu_down() keeps its void * argument
because it is also used as an on_selected_cpus() callback.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>

I think this is a backwards step.  It is pure luck that none of the
callbacks right now modify their passed pointer, but it is very
intentional that some callbacks might.

Callbacks use mutable void pointers in C, and this is a known friction
with the C type system.  If there existed a way of matching mutability
between the callback and the pointer, we'd be using that, but it doesn't
exist in C.

The safety here comes from the fact that an individual function doesn't
modify the thing it was passed a pointer to.  I think those want local
deviations.

~Andrew

Understood, thanks. I will drop this patch. And I will think about the deviations.

BR, Dmytro.




 


Rackspace

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