LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-17-2020, 12:03 PM   #1
RAMSEYWALID
LQ Newbie
 
Registered: Oct 2020
Posts: 1

Rep: Reputation: Disabled
How to read eax outside of my own process's state?


I want to make an rng that uses CPU registers for randomness/entropy (a personal project). The problem is, when I access the eax register through a C program, it increments upwards at a constant rate. I think this is because of two things

1) I wrote a sleep function that uses a while loop for waiting (hence the incrementing upwards) and 2) the eax register is reverted back to its old state whenever my program gets runtime (I overlooked process state saving). Is it possible to read eax when my program is not running on the cpu, or to fix the constant incrementation?

Ive tried reading from different registers, but usually they will just give a different issue - for example, ebx stays constant. I haven't tried every register, though.

One idea I have is to make a system call/some kernel space code that reads eax and outputs it to a file, and have the kernel run it periodically. I dont know if this would fix the underlying issue, though. Any suggestions?
 
Old 10-18-2020, 10:00 PM   #2
tinfoil3d
Member
 
Registered: Apr 2020
Location: Japan/RJCC
Distribution: debian, lfs, whatever else i need in qemu
Posts: 268

Rep: Reputation: 75
registers don't change on their own, that's all i can tell.
kernel should not directly write to files.

and why not use already provided /dev/random or urandom which are reliable granted you do have some entropy available after system boot?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
error: unknown register name '%eax' in 'asm' roMoon Programming 2 03-15-2011 12:18 PM
EAX and 5.1 Sound Support... trey85stang Linux - Hardware 0 07-06-2004 04:18 PM
EAX with SB live 5.1 under Linux hotel-lima Linux - Hardware 5 06-10-2004 05:19 PM
Environmental Sound (like EAX) with 4 Speakers royconejo Linux - Hardware 0 05-29-2004 06:01 PM
EAX vs A3D dj_relentless General 0 02-06-2002 06:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration