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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 23 Jan 2015 12:31:40 +0000
From:	Punit Agrawal <punit.agrawal@....com>
To:	"Suzuki K. Poulose" <suzuki.poulose@....com>
Cc:	linux-arm-kernel@...ts.infradead.org, leo.yan@...aro.org,
	yexl@...vell.com, Will.Deacon@....com, Catalin.Marinas@....com,
	Mark.Rutland@....com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] arm64: Consolidate hotplug notifier for instruction emulation

Hi Suzuki,

A possible simplification below.

"Suzuki K. Poulose" <suzuki.poulose@....com> writes:

> From: "Suzuki K. Poulose" <suzuki.poulose@....com>
>
> As of now each insn_emulation has a cpu hotplug notifier that
> enables/disables the CPU feature bit for the functionality. This
> patch re-arranges the code, such that there is only one notifier
> that runs through the list of registered emulation hooks and runs
> their corresponding set_hw_mode.
>
> We do nothing when a CPU is dying as we will set the appropriate bits
> as it comes back online based on the state of the hooks.
>
> Signed-off-by: Mark Rutland <mark.rutland@....com>
> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@....com>
> Cc: Will Deacon <will.deacon@....com>
> Cc: Catalin Marinas <catalin.marinas@....com>
> Cc: Punit Agrawal <punit.agrawal@....com>
> ---
>  arch/arm64/include/asm/cputype.h     |    2 +
>  arch/arm64/kernel/armv8_deprecated.c |  125 +++++++++++++++++++++-------------
>  2 files changed, 79 insertions(+), 48 deletions(-)
>

[...]

> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> index c363671..2c991f1 100644
> --- a/arch/arm64/kernel/armv8_deprecated.c
> +++ b/arch/arm64/kernel/armv8_deprecated.c
> @@ -19,6 +19,7 @@
>  #include <asm/system_misc.h>
>  #include <asm/traps.h>
>  #include <asm/uaccess.h>
> +#include <asm/cpufeature.h>
>  
>  #define CREATE_TRACE_POINTS
>  #include "trace-events-emulation.h"
> @@ -85,6 +86,57 @@ static void remove_emulation_hooks(struct insn_emulation_ops *ops)
>  	pr_notice("Removed %s emulation handler\n", ops->name);
>  }
>  
> +static void enable_insn_hw_mode(void *data)
> +{
> +	struct insn_emulation *insn = (struct insn_emulation *)data;
> +	if (insn && insn->ops->set_hw_mode)

You can simplify (drop?) this...

> +		insn->ops->set_hw_mode(true);
> +}
> +
> +static void disable_insn_hw_mode(void *data)
> +{
> +	struct insn_emulation *insn = (struct insn_emulation *)data;
> +	if (insn && insn->ops->set_hw_mode)

and this check since...

> +		insn->ops->set_hw_mode(false);
> +}
> +
> +/* Run set_hw_mode(mode) on all active CPUs */
> +static int run_all_cpu_set_hw_mode(struct insn_emulation *insn, bool enable)
> +{
> +	if (!insn->ops->set_hw_mode)
> +		return -EINVAL;

insn->ops->set_hw_mode is already checked here.

> +	if (enable)
> +		on_each_cpu(enable_insn_hw_mode, (void *)insn, true);
> +	else
> +		on_each_cpu(disable_insn_hw_mode, (void *)insn, true);
> +	return 0;
> +}
> +
> +/*
> + * Run set_hw_mode for all insns on a starting CPU.
> + * Returns:
> + *  0 		- If all the hooks ran successfully.
> + * -EINVAL	- At least one hook is not supported by the CPU.
> + */
> +static int run_all_insn_set_hw_mode(unsigned long cpu)
> +{
> +	int rc = 0;
> +	unsigned long flags;
> +	struct insn_emulation *insn;
> +
> +	raw_spin_lock_irqsave(&insn_emulation_lock, flags);
> +	list_for_each_entry(insn, &insn_emulation, node) {
> +		bool enable = (insn->current_mode == INSN_HW);
> +		if (insn->ops->set_hw_mode && insn->ops->set_hw_mode(enable)) {
> +			pr_warn(enable, "CPU[%ld] cannot support the emulation of %s",
> +							cpu, insn->ops->name);
> +			rc = -EINVAL;
> +		}
> +	}
> +	raw_spin_unlock_irqrestore(&insn_emulation_lock, flags);
> +	return rc;
> +}
> +
>  static int update_insn_emulation_mode(struct insn_emulation *insn,
>  				       enum insn_emulation_mode prev)
>  {

[...]

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ