From: Serge Vakulenko <serge@vak.ru>
To: qemu-devel@nongnu.org
Cc: Leon Alrae <leon.alrae@imgtec.com>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH pic32 3/7] Fixed random index generation for TLBWR instruction. It was not quite random and did not skip Wired entries.
Date: Mon, 29 Jun 2015 22:03:44 -0700 [thread overview]
Message-ID: <CANacOGUTXsQE7g5_Ee4rdhREDiHamp2JEnKARHJpVhYKo1DtPw@mail.gmail.com> (raw)
Signed-off-by: Serge Vakulenko <serge@vak.ru>
---
hw/mips/cputimer.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/hw/mips/cputimer.c b/hw/mips/cputimer.c
index 3d23c1b..ec0cffa 100644
--- a/hw/mips/cputimer.c
+++ b/hw/mips/cputimer.c
@@ -25,21 +25,13 @@
#include "qemu/timer.h"
#include "sysemu/kvm.h"
-#define TIMER_FREQ 100 * 1000 * 1000
-
-/* XXX: do not use a global */
+/* Generate a random TLB index.
+ * Skip wired entries. */
uint32_t cpu_mips_get_random (CPUMIPSState *env)
{
- static uint32_t lfsr = 1;
- static uint32_t prev_idx = 0;
- uint32_t idx;
- /* Don't return same value twice, so get another value */
- do {
- lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xd0000001u);
- idx = lfsr % (env->tlb->nb_tlb - env->CP0_Wired) + env->CP0_Wired;
- } while (idx == prev_idx);
- prev_idx = idx;
- return idx;
+ env->CP0_Random = env->CP0_Wired +
+ random() % (env->tlb->nb_tlb - env->CP0_Wired);
+ return env->CP0_Random;
}
/* MIPS R4K timer */
--
1.9.1
reply other threads:[~2015-06-30 5:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CANacOGUTXsQE7g5_Ee4rdhREDiHamp2JEnKARHJpVhYKo1DtPw@mail.gmail.com \
--to=serge@vak.ru \
--cc=aurelien@aurel32.net \
--cc=leon.alrae@imgtec.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).