From: Stanislaw Gruszka <sgruszka@redhat.com>
To: "Tomáš Janoušek" <tomi@nomi.cz>
Cc: linux-kernel@vger.kernel.org, Wey-Yi Guy <wey-yi.w.guy@intel.com>,
linux-wireless@vger.kernel.org
Subject: Re: iwlagn: memory corruption with WPA enterprise
Date: Mon, 21 Nov 2011 14:40:57 +0100 [thread overview]
Message-ID: <20111121134056.GB4010@redhat.com> (raw)
In-Reply-To: <20111121130916.GA11136@nomi.cz>
[-- Attachment #1: Type: text/plain, Size: 1622 bytes --]
On Mon, Nov 21, 2011 at 02:09:16PM +0100, Tomáš Janoušek wrote:
> On Mon, Nov 21, 2011 at 02:05:28PM +0100, Stanislaw Gruszka wrote:
> > The farther we get the problem is more and more strange.
> >
> > Device that write to wrong address, would generate:
> >
> > DMAR:[DMA Write] Request device [00:02.0] fault addr 6df084000
> > DMAR:[fault reason 05] PTE Write access is not set
>
> And that's exactly what happens if I don't disable firewire-ohci, because of
> that stupid Ricoh multifunction blah blah issue.
So maybe problem is caused by Ricoh, not by iwlagn. But if so
why blacklisting iwlagn help? Wired. Did you disable firewire in
BIOS, or just blacklist module?
> > Try "dmesg | grep DMAR" to see if DMA remapping is really is
> > in use.
>
> Well, this message is not printed, but as I said, loading firewire-ohci
> triggers DMAR faults, so it should be in use anyway.
So IOMMU is in use and it does not prevent corruption, crap.
Ok maybe let's try to find some better reproducer first.
I wrote simple program that fill memory with some pattern, and
then check every one second if pattern is still there.
It can be used like:
./checkmem 100M 30M
where first argument is size of memory it will alloc and check,
second specify number of internal loops to make cpu busy (bigger
value will cause more cpu power consumption). Many instances of
the program can be running at once.
Tomáš, please try to reproduce with that program, I'm attaching
it. When corruption will be detected, checkmem will print invalid
values, maybe would be possible to find out what contents is
written to memory.
Stanislaw
[-- Attachment #2: checkmem.c --]
[-- Type: text/plain, Size: 2337 bytes --]
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>
unsigned int pattern;
unsigned int *ptr;
int finish = 0;
long size = 1 * 1024 * 1024;
long loops = 10 * 1024 * 1024;
void initArgs(int argc, char *argv[])
{
int rc, i;
char suf;
long arg;
if (argc > 3)
goto exit;
for (i = 1; i < argc; i++) {
rc = sscanf(argv[i], "%ld%c", &arg, &suf);
if (rc == 2) {
switch (suf) {
case 'M':
case 'm':
arg *= 1024 * 1024;
break;
case 'K':
case 'k':
arg *= 1024;
break;
default:
goto exit;
}
} else if (rc != 1)
goto exit;
if (i == 1)
size = arg;
else if (i == 2)
loops = arg;
}
printf("size %ld loops %ld\n", size, loops);
return;
exit:
fprintf(stderr, "usage: %s size loops\n", argv[0]);
exit(1);
}
void initPattern()
{
struct timeval tv = { 0xdeadbeaf, 0 };
gettimeofday(&tv, NULL);
srand(tv.tv_sec ^ tv.tv_usec);
pattern = rand();
printf("pattern %08x\n", pattern);
}
void initChunk()
{
int i;
ptr = malloc(size);
if (ptr == NULL) {
fprintf(stderr, "fail to allocate mem\n");
fflush(stderr);
exit(1);
}
for (i = 0; i < size/4; i++)
ptr[i] = pattern;
printf("initialized %d MB\n", size/(1024*1024));
fflush(stdout);
}
void sig_handler()
{
finish = 1;
}
void checkChunks()
{
int i;
int ok = 1;
int printed = 0;
for (i = 0; i < size/4; i++) {
if (ptr[i] != pattern) {
if (!printed) {
fprintf(stderr, "memory corruption!\n");
fflush(stderr);
printed = 1;
}
fprintf(stderr, "%p: 0x%08x\n", &ptr[i], ptr[i]);
fflush(stderr);
ok = 0;
}
}
if (ok) {
printf("check ok\n");
fflush(stdout);
} else {
/* In case of memory corruption sleep forever */
while (1)
sleep(1);
}
}
void alarm_handler()
{
checkChunks();
alarm(1);
}
#define barrier() __asm__ __volatile__("": : :"memory")
void use_cpu()
{
long i;
static long a = 0;
for (i = 0; i < loops; i++) {
a++;
barrier();
a += 3;
barrier();
a += 10;
barrier();
}
}
int main(int argc, char *argv[])
{
initArgs(argc, argv);
initPattern();
initChunk();
signal(SIGUSR1, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
signal(SIGALRM, alarm_handler);
alarm(1);
while (finish == 0) {
use_cpu();
sleep(1);
}
checkChunks();
return 0;
}
next prev parent reply other threads:[~2011-11-21 13:38 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-29 17:15 iwlagn: memory corruption with WPA enterprise Tomáš Janoušek
2011-10-31 16:03 ` Stanislaw Gruszka
2011-11-09 15:54 ` Tomáš Janoušek
2011-11-09 15:59 ` wwguy
2011-11-09 16:51 ` Stanislaw Gruszka
2011-11-10 9:18 ` Tomáš Janoušek
2011-11-10 11:47 ` Stanislaw Gruszka
2011-11-10 12:53 ` Tomáš Janoušek
2011-11-10 16:07 ` Stanislaw Gruszka
2011-11-10 15:24 ` Guy, Wey-Yi
2011-11-10 16:42 ` Tomáš Janoušek
2011-11-10 17:02 ` Larry Finger
2011-11-10 16:30 ` Tomáš Janoušek
2011-11-11 5:47 ` Stanislaw Gruszka
2011-11-11 15:01 ` Tomáš Janoušek
2011-11-14 14:07 ` Stanislaw Gruszka
2011-11-19 18:11 ` Tomáš Janoušek
2011-11-20 2:13 ` wwguy
2011-11-20 3:20 ` Tomáš Janoušek
2011-11-20 4:28 ` wwguy
2011-11-20 20:40 ` Tomáš Janoušek
2012-02-10 18:09 ` Tomáš Janoušek
2012-02-13 9:25 ` Stanislaw Gruszka
2012-02-13 13:09 ` Stanislaw Gruszka
2012-02-13 13:29 ` Tomáš Janoušek
2012-02-14 9:20 ` Stanislaw Gruszka
2012-03-05 14:01 ` Tomáš Janoušek
2012-03-05 14:57 ` Stanislaw Gruszka
2012-03-05 15:00 ` Tomáš Janoušek
2012-03-05 15:11 ` Stanislaw Gruszka
2012-03-05 15:18 ` Tomáš Janoušek
2011-11-21 13:05 ` Stanislaw Gruszka
2011-11-21 13:09 ` Tomáš Janoušek
2011-11-21 13:40 ` Stanislaw Gruszka [this message]
2011-11-21 14:32 ` Tomáš Janoušek
2011-11-10 19:31 ` Adrian Chadd
2011-11-11 5:44 ` Stanislaw Gruszka
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=20111121134056.GB4010@redhat.com \
--to=sgruszka@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=tomi@nomi.cz \
--cc=wey-yi.w.guy@intel.com \
/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).