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:	Wed, 27 Mar 2013 14:09:18 -0700
From:	Tony Lindgren <tony@...mide.com>
To:	Pali Rohár <pali.rohar@...il.com>
Cc:	Juha Yrjola <juha.yrjola@...idboot.com>,
	Russell King <linux@....linux.org.uk>,
	Matt Mackall <mpm@...enic.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	linux-omap@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] OMAP3 ROM Random Number Generator support

* Pali Rohár <pali.rohar@...il.com> [130228 10:09]:
> --- /dev/null
> +++ b/drivers/char/hw_random/omap3-rom-asm.S
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright (C) 2009 Nokia Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#include <linux/linkage.h>
> +#include <asm/assembler.h>
> +
> +ENTRY(omap3_rng_call_rom_asm)
> +	.arch_extension sec
> +	stmfd	sp!, {r4-r12, lr}
> +	stmfd	sp!, {r0-r3}
> +	bl	v7_flush_dcache_all
> +	ldmfd	sp!, {r0-r3}
> +	mov	r6, #0xff
> +	mov	r12, r0
> +	smc	#1
> +	mov	r12, r0
> +	bl	v7_flush_dcache_all
> +	mov	r0, #0
> +	mcr	p15, 0, r0, c7, c5, 0
> +	mov	r0, r12
> +	ldmfd	sp!, {r4-r12, pc}

This part should be in arch/arm/mach-omap2 because of the
direct calls to v7_flush_dcache_all. Then you can pass a pointer
to this function in platform_data for now, and set it up based
on the compatible flag with device tree from driver later on.

> --- /dev/null
> +++ b/drivers/char/hw_random/omap3-rom-drv.c
> @@ -0,0 +1,167 @@
> +/*
> + * omap3-rom-drv.c - RNG driver for TI OMAP3 CPU family
> + *
> + * Copyright (C) 2009 Nokia Corporation
> + * Author: Juha Yrjola <juha.yrjola@...idboot.com>
> + *
> + * This file is licensed under  the terms of the GNU General Public
> + * License version 2. This program is licensed "as is" without any
> + * warranty of any kind, whether express or implied.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/random.h>
> +#include <linux/hw_random.h>
> +#include <linux/timer.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/platform_device.h>
> +
> +#include "../../../arch/arm/mach-omap2/soc.h"

NAK for this, this must be private to arch/arm/mach-omap2.

Instead, just create a minimal include/linux/platform_data/omap3-rom.h,
and pass the function pointer in the pdata if passed.

> +static int omap3_rom_rng_probe(struct platform_device *pdev)
> +{
> +	printk(KERN_INFO "%s: initializing\n", omap3_rom_rng_name);
> +	if (!cpu_is_omap34xx()) {
> +		printk(KERN_ERR "%s: currently supports only OMAP34xx CPUs\n",
> +		       omap3_rom_rng_name);
> +		return -ENODEV;
> +	}
> +	if (omap_type() == OMAP2_DEVICE_TYPE_GP) {
> +		printk(KERN_ERR "%s: GP OMAPs not supported\n",
> +		       omap3_rom_rng_name);
> +		return -ENODEV;
> +	}
> +
> +	setup_timer(&idle_timer, omap3_rom_idle_rng, 0);
> +	rng_clk = clk_get_sys("omap_rng", "ick");
> +	if (IS_ERR(rng_clk)) {
> +		printk(KERN_ERR "%s: unable to get RNG clock\n",
> +		       omap3_rom_rng_name);
> +		return IS_ERR(rng_clk);
> +	}
> +
> +	/* Leave the RNG in reset state. */
> +	clk_prepare_enable(rng_clk);
> +	omap3_rom_idle_rng(0);
> +
> +	return hwrng_register(&omap3_rom_rng_ops);
> +}

You should replace the cpu_is_omap34xx() and omap_type() with
some flags that you pass in the pdata. These too can be then
deciphered based on the DT compatible flag later on. And then
you don't need to include soc.h.

Regards,

Tony
--
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