devarch: restrict i/o port access to 64K, disallow msr 32-bit wrap arround (thanks aiju)
This commit is contained in:
parent
4f2cdcf74b
commit
ba7b07d51a
1 changed files with 9 additions and 2 deletions
|
@ -309,8 +309,11 @@ iounused(int start, int end)
|
|||
}
|
||||
|
||||
static void
|
||||
checkport(int start, int end)
|
||||
checkport(uint start, uint end)
|
||||
{
|
||||
if(end < start || end > 0x10000)
|
||||
error(Ebadarg);
|
||||
|
||||
/* standard vga regs are OK */
|
||||
if(start >= 0x2b0 && end <= 0x2df+1)
|
||||
return;
|
||||
|
@ -356,12 +359,12 @@ archread(Chan *c, void *a, long n, vlong offset)
|
|||
{
|
||||
char buf[32], *p;
|
||||
uint port, end;
|
||||
int i;
|
||||
ushort *sp;
|
||||
ulong *lp;
|
||||
vlong *vp;
|
||||
IOMap *m;
|
||||
Rdwrfn *fn;
|
||||
int i;
|
||||
|
||||
port = offset;
|
||||
end = port+n;
|
||||
|
@ -394,6 +397,8 @@ archread(Chan *c, void *a, long n, vlong offset)
|
|||
case Qmsr:
|
||||
if(n & 7)
|
||||
error(Ebadarg);
|
||||
if((uint)n/8 > -port)
|
||||
error(Ebadarg);
|
||||
end = port+(n/8);
|
||||
for(vp = a; port < end; port++)
|
||||
if(rdmsr(port, vp++) < 0)
|
||||
|
@ -465,6 +470,8 @@ archwrite(Chan *c, void *a, long n, vlong offset)
|
|||
case Qmsr:
|
||||
if(n & 7)
|
||||
error(Ebadarg);
|
||||
if((uint)n/8 > -port)
|
||||
error(Ebadarg);
|
||||
end = port+(n/8);
|
||||
for(vp = a; port < end; port++)
|
||||
if(wrmsr(port, *vp++) < 0)
|
||||
|
|
Loading…
Reference in a new issue