From: Piotras <piotras@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] page fault during ins
Date: Mon, 13 Dec 2004 15:52:12 +0100 [thread overview]
Message-ID: <da63183704121306524ea9ac3d@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 566 bytes --]
Hi!
The current implementation of ins (Input from Port to String) is
not-restartable. If page fault occurs during write, the port read
is redone and for some devices this may give unexpected results.
This is different from what real CPU does. From my tests with
Pentium II it seems that the CPU first makes sure that data can
be written, and then issue IO read. I'm attaching my test program
-- it may do harm to your system, so be very careful. The test
assumes that there is a CDROM connected as master to second
IDE controller (hdc).
Regards,
Piotrek
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-ide.c --]
[-- Type: text/x-csrc; name="test-ide.c", Size: 919 bytes --]
#include <sys/io.h>
#include <sys/mman.h>
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
uint16_t *data;
void segv()
{
printf("SEGV\n");
data = mmap(data, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (data == MAP_FAILED) {
exit(1);
}
}
int main()
{
int i;
unsigned char v;
data = mmap(0, 4096, PROT_NONE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (data == MAP_FAILED) {
exit(1);
}
signal(SIGSEGV, segv);
iopl(3);
do {
v = inb(0x0177);
} while ((v & 0xc0) != 0x40);
outb(0x00, 0x0176);
outb(0xa1, 0x0177);
do {
v = inb(0x0177);
} while ((v & 0x08) != 0x08);
insw(0x0170, data, 256);
for(i = 0; i < 256; ++ i) {
printf("%04x%c", data[i], (i % 8 != 7)? ' ': '\n');
}
}
next reply other threads:[~2004-12-13 15:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-13 14:52 Piotras [this message]
2004-12-14 21:40 ` [Qemu-devel] page fault during ins Fabrice Bellard
2004-12-14 22:29 ` malc
2004-12-15 8:17 ` Piotras
2004-12-17 0:07 ` Mark Williamson
2004-12-23 8:45 ` Benjamin Herrenschmidt
2004-12-15 8:22 ` Piotras
-- strict thread matches above, loose matches on Subject: below --
2004-12-15 18:36 Juergen Keil
2004-12-15 20:07 ` Piotras
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=da63183704121306524ea9ac3d@mail.gmail.com \
--to=piotras@gmail.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).