lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025111922-rearrange-manned-8a47@gregkh>
Date: Wed, 19 Nov 2025 02:42:03 -0500
From: Greg KH <gregkh@...uxfoundation.org>
To: Shrikanth Hegde <sshegde@...ux.ibm.com>
Cc: linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
	mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
	vincent.guittot@...aro.org, tglx@...utronix.de,
	yury.norov@...il.com, maddy@...ux.ibm.com, srikar@...ux.ibm.com,
	pbonzini@...hat.com, seanjc@...gle.com, kprateek.nayak@....com,
	vschneid@...hat.com, iii@...ux.ibm.com, huschle@...ux.ibm.com,
	rostedt@...dmis.org, dietmar.eggemann@....com,
	christophe.leroy@...roup.eu
Subject: Re: [HELPER PATCH 1] sysfs: Provide write method for paravirt

On Wed, Nov 19, 2025 at 11:50:59AM +0530, Shrikanth Hegde wrote:
> This is helper patch which could be used to set the range of CPUs as
> paravirt. One could make use of this for quick testing of this infra
> instead of writing arch specific code.
> 
> This is currently not meant be merged, since paravirt sysfs file is meant
> to be Read-Only.
> 
> echo 100-200,600-700 >  /sys/devices/system/cpu/paravirt
> cat /sys/devices/system/cpu/paravirt
> 100-200,600-700
> 
> echo > /sys/devices/system/cpu/paravirt
> cat /sys/devices/system/cpu/paravirt
> 
> Signed-off-by: Shrikanth Hegde <sshegde@...ux.ibm.com>
> ---
>  drivers/base/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 46 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 59ceae217b22..043e4f4ce1a9 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -375,12 +375,57 @@ static int cpu_uevent(const struct device *dev, struct kobj_uevent_env *env)
>  #endif
>  
>  #ifdef CONFIG_PARAVIRT
> +static ssize_t store_paravirt_cpus(struct device *dev,
> +				   struct device_attribute *attr,
> +				   const char *buf, size_t count)
> +{
> +	cpumask_var_t temp_mask;
> +	int retval = 0;
> +
> +	if (!alloc_cpumask_var(&temp_mask, GFP_KERNEL))
> +		return -ENOMEM;
> +
> +	retval = cpulist_parse(buf, temp_mask);
> +	if (retval)
> +		goto free_mask;
> +
> +	/* ALL cpus can't be marked as paravirt */
> +	if (cpumask_equal(temp_mask, cpu_online_mask)) {
> +		retval = -EINVAL;
> +		goto free_mask;
> +	}
> +	if (cpumask_weight(temp_mask) > num_online_cpus()) {
> +		retval = -EINVAL;
> +		goto free_mask;
> +	}
> +
> +	/* No more paravirt cpus */
> +	if (cpumask_empty(temp_mask)) {
> +		cpumask_copy((struct cpumask *)&__cpu_paravirt_mask, temp_mask);
> +	} else {
> +		cpumask_copy((struct cpumask *)&__cpu_paravirt_mask, temp_mask);
> +
> +		/* Enable tick on nohz_full cpu */
> +		int cpu;
> +		for_each_cpu(cpu, temp_mask) {
> +			if (tick_nohz_full_cpu(cpu))
> +				tick_nohz_dep_set_cpu(cpu, TICK_DEP_BIT_SCHED);
> +		}
> +	}
> +
> +	retval = count;
> +
> +free_mask:
> +	free_cpumask_var(temp_mask);
> +	return retval;
> +}
> +
>  static ssize_t print_paravirt_cpus(struct device *dev,
>  				   struct device_attribute *attr, char *buf)
>  {
>  	return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(cpu_paravirt_mask));
>  }
> -static DEVICE_ATTR(paravirt, 0444, print_paravirt_cpus, NULL);
> +static DEVICE_ATTR(paravirt, 0644, print_paravirt_cpus, store_paravirt_cpus);

DEVICE_ATTR_RW()?

And where is the documentation update for this sysfs file change?

>  #endif
>  
>  const struct bus_type cpu_subsys = {
> @@ -675,7 +720,6 @@ static void __init cpu_register_vulnerabilities(void)
>  		put_device(dev);
>  	}
>  }
> -
>  #else

Why is this change needed?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ