All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles()
@ 2013-09-09 19:26 ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2013-09-09 19:26 UTC (permalink / raw)
  To: linux-m68k
  Cc: Thorsten Glaser, Theodore Ts'o, linux-kernel, Geert Uytterhoeven

Currently get_cycles() always returns zero.  As get_cycles() is called to
add entropy to the random number generator pool, security can be increased
by adding a hook where platforms can provide their own implementation.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/include/asm/machdep.h |    1 +
 arch/m68k/include/asm/timex.h   |    5 +----
 arch/m68k/kernel/time.c         |   13 +++++++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h
index 953ca21..334f751 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -22,6 +22,7 @@ extern unsigned int (*mach_get_ss)(void);
 extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_clock_mmss)(unsigned long);
+extern cycles_t (*mach_get_cycles)(void);
 extern void (*mach_reset)( void );
 extern void (*mach_halt)( void );
 extern void (*mach_power_off)( void );
diff --git a/arch/m68k/include/asm/timex.h b/arch/m68k/include/asm/timex.h
index 6759dad..0fdc5d2 100644
--- a/arch/m68k/include/asm/timex.h
+++ b/arch/m68k/include/asm/timex.h
@@ -23,9 +23,6 @@
 
 typedef unsigned long cycles_t;
 
-static inline cycles_t get_cycles(void)
-{
-	return 0;
-}
+extern cycles_t get_cycles(void);
 
 #endif
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 7eb9792..65b1663 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -28,6 +28,19 @@
 #include <linux/timex.h>
 #include <linux/profile.h>
 
+
+cycles_t (*mach_get_cycles)(void);
+
+cycles_t get_cycles(void)
+{
+	if (mach_get_cycles)
+		return mach_get_cycles();
+
+	return 0;
+}
+EXPORT_SYMBOL(get_cycles);
+
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "xtime_update()" routine every clocktick
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles()
@ 2013-09-09 19:26 ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2013-09-09 19:26 UTC (permalink / raw)
  To: linux-m68k
  Cc: Thorsten Glaser, Theodore Ts'o, linux-kernel, Geert Uytterhoeven

Currently get_cycles() always returns zero.  As get_cycles() is called to
add entropy to the random number generator pool, security can be increased
by adding a hook where platforms can provide their own implementation.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/include/asm/machdep.h |    1 +
 arch/m68k/include/asm/timex.h   |    5 +----
 arch/m68k/kernel/time.c         |   13 +++++++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/include/asm/machdep.h b/arch/m68k/include/asm/machdep.h
index 953ca21..334f751 100644
--- a/arch/m68k/include/asm/machdep.h
+++ b/arch/m68k/include/asm/machdep.h
@@ -22,6 +22,7 @@ extern unsigned int (*mach_get_ss)(void);
 extern int (*mach_get_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_rtc_pll)(struct rtc_pll_info *);
 extern int (*mach_set_clock_mmss)(unsigned long);
+extern cycles_t (*mach_get_cycles)(void);
 extern void (*mach_reset)( void );
 extern void (*mach_halt)( void );
 extern void (*mach_power_off)( void );
diff --git a/arch/m68k/include/asm/timex.h b/arch/m68k/include/asm/timex.h
index 6759dad..0fdc5d2 100644
--- a/arch/m68k/include/asm/timex.h
+++ b/arch/m68k/include/asm/timex.h
@@ -23,9 +23,6 @@
 
 typedef unsigned long cycles_t;
 
-static inline cycles_t get_cycles(void)
-{
-	return 0;
-}
+extern cycles_t get_cycles(void);
 
 #endif
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c
index 7eb9792..65b1663 100644
--- a/arch/m68k/kernel/time.c
+++ b/arch/m68k/kernel/time.c
@@ -28,6 +28,19 @@
 #include <linux/timex.h>
 #include <linux/profile.h>
 
+
+cycles_t (*mach_get_cycles)(void);
+
+cycles_t get_cycles(void)
+{
+	if (mach_get_cycles)
+		return mach_get_cycles();
+
+	return 0;
+}
+EXPORT_SYMBOL(get_cycles);
+
+
 /*
  * timer_interrupt() needs to keep up the real-time clock,
  * as well as call the "xtime_update()" routine every clocktick
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/RFC 2/2] m68k/amiga: Provide mach_get_cycles()
  2013-09-09 19:26 ` Geert Uytterhoeven
  (?)
@ 2013-09-09 19:26 ` Geert Uytterhoeven
  -1 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2013-09-09 19:26 UTC (permalink / raw)
  To: linux-m68k
  Cc: Thorsten Glaser, Theodore Ts'o, linux-kernel, Geert Uytterhoeven

Use the 24-bit Time-Of-Day clock in CIA B, which is clocked by HSYNC.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
  1. Completely untested! It does compile ;-)

  2. Is a 24-bit counter running at 15-31 kHz good enough?
     Two cascaded 16-bit CIA timers running from the 700 kHz E-clock would
     be better, but as jiffies use CIA B Timer A and the floppy driver uses
     CIA A Timer B, we don't have two available timers in the same CIA
     without some code shuffling.

  3. What are the semantics of get_cycles()?
     Does it have to be a "nice" counter, or can there be some
     irregularities?
     I.e. can I add one more line
     
	x = (x << 8) | ciab.talo;	// low byte of 700 kHz timer
	
     to get 32 bits?

 arch/m68k/amiga/config.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index acd9c16..914e056 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -358,6 +358,20 @@ static void __init amiga_identify(void)
 #undef AMIGAHW_ANNOUNCE
 }
 
+
+static cycles_t amiga_get_cycles(void)
+{
+	cycles_t x;
+
+	/* CIA B 24-bit TOD is clocked by HSYNC */
+	x = ciab.todhi;
+	x = (x << 8) | ciab.todmid;
+	x = (x << 8) | ciab.todlo;
+
+	return x;
+}
+
+
     /*
      *  Setup the Amiga configuration info
      */
@@ -395,6 +409,8 @@ void __init config_amiga(void)
 	mach_heartbeat = amiga_heartbeat;
 #endif
 
+	mach_get_cycles = amiga_get_cycles;
+
 	/* Fill in the clock value (based on the 700 kHz E-Clock) */
 	amiga_colorclock = 5*amiga_eclock;	/* 3.5 MHz */
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH/RFC 2/2] m68k/amiga: Provide mach_get_cycles()
  2013-09-09 19:26 ` Geert Uytterhoeven
  (?)
  (?)
@ 2013-09-09 19:26 ` Geert Uytterhoeven
  -1 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2013-09-09 19:26 UTC (permalink / raw)
  To: linux-m68k
  Cc: Thorsten Glaser, Theodore Ts'o, linux-kernel, Geert Uytterhoeven

Use the 24-bit Time-Of-Day clock in CIA B, which is clocked by HSYNC.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
  1. Completely untested! It does compile ;-)

  2. Is a 24-bit counter running at 15-31 kHz good enough?
     Two cascaded 16-bit CIA timers running from the 700 kHz E-clock would
     be better, but as jiffies use CIA B Timer A and the floppy driver uses
     CIA A Timer B, we don't have two available timers in the same CIA
     without some code shuffling.

  3. What are the semantics of get_cycles()?
     Does it have to be a "nice" counter, or can there be some
     irregularities?
     I.e. can I add one more line
     
	x = (x << 8) | ciab.talo;	// low byte of 700 kHz timer
	
     to get 32 bits?

 arch/m68k/amiga/config.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index acd9c16..914e056 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -358,6 +358,20 @@ static void __init amiga_identify(void)
 #undef AMIGAHW_ANNOUNCE
 }
 
+
+static cycles_t amiga_get_cycles(void)
+{
+	cycles_t x;
+
+	/* CIA B 24-bit TOD is clocked by HSYNC */
+	x = ciab.todhi;
+	x = (x << 8) | ciab.todmid;
+	x = (x << 8) | ciab.todlo;
+
+	return x;
+}
+
+
     /*
      *  Setup the Amiga configuration info
      */
@@ -395,6 +409,8 @@ void __init config_amiga(void)
 	mach_heartbeat = amiga_heartbeat;
 #endif
 
+	mach_get_cycles = amiga_get_cycles;
+
 	/* Fill in the clock value (based on the 700 kHz E-Clock) */
 	amiga_colorclock = 5*amiga_eclock;	/* 3.5 MHz */
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles()
  2013-09-09 19:26 ` Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  (?)
@ 2013-09-09 20:35 ` Thorsten Glaser
  -1 siblings, 0 replies; 5+ messages in thread
From: Thorsten Glaser @ 2013-09-09 20:35 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, Theodore Ts'o, linux-kernel

Geert Uytterhoeven dixit:

>Currently get_cycles() always returns zero.  As get_cycles() is called to
>add entropy to the random number generator pool, security can be increased

You rock for having something before MIPS ;-) (Note that other
architectures like CRIS are also affected… just, MIPS probably
has the broadest impact… even I have a FreeWRT WLAN AP.)

Sorry I can’t provide any feedback because I’m out of my depth on
both the hardware and the requirements aspect.

bye,
//mirabilos
-- 
Sometimes they [people] care too much: pretty printers [and syntax highligh-
ting, d.A.] mechanically produce pretty output that accentuates irrelevant
detail in the program, which is as sensible as putting all the prepositions
in English text in bold font.	-- Rob Pike in "Notes on Programming in C"

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-09 21:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-09 19:26 [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles() Geert Uytterhoeven
2013-09-09 19:26 ` Geert Uytterhoeven
2013-09-09 19:26 ` [PATCH/RFC 2/2] m68k/amiga: Provide mach_get_cycles() Geert Uytterhoeven
2013-09-09 19:26 ` Geert Uytterhoeven
2013-09-09 20:35 ` [PATCH 1/2] m68k: Add infrastructure for machine-specific get_cycles() Thorsten Glaser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.