Commit aca7cc6d authored by David Hildenbrand's avatar David Hildenbrand Committed by Khalid Elmously

KVM: x86: drop picdev_in_range()

BugLink: https://bugs.launchpad.net/bugs/1864775

[ Upstream commit 9fecaa9e ]

We already have the exact same checks a couple of lines below.
Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 6f55f873
...@@ -456,46 +456,33 @@ static u32 elcr_ioport_read(void *opaque, u32 addr1) ...@@ -456,46 +456,33 @@ static u32 elcr_ioport_read(void *opaque, u32 addr1)
return s->elcr; return s->elcr;
} }
static int picdev_in_range(gpa_t addr)
{
switch (addr) {
case 0x20:
case 0x21:
case 0xa0:
case 0xa1:
case 0x4d0:
case 0x4d1:
return 1;
default:
return 0;
}
}
static int picdev_write(struct kvm_pic *s, static int picdev_write(struct kvm_pic *s,
gpa_t addr, int len, const void *val) gpa_t addr, int len, const void *val)
{ {
unsigned char data = *(unsigned char *)val; unsigned char data = *(unsigned char *)val;
if (!picdev_in_range(addr))
return -EOPNOTSUPP;
if (len != 1) { if (len != 1) {
pr_pic_unimpl("non byte write\n"); pr_pic_unimpl("non byte write\n");
return 0; return 0;
} }
pic_lock(s);
switch (addr) { switch (addr) {
case 0x20: case 0x20:
case 0x21: case 0x21:
case 0xa0: case 0xa0:
case 0xa1: case 0xa1:
pic_lock(s);
pic_ioport_write(&s->pics[addr >> 7], addr, data); pic_ioport_write(&s->pics[addr >> 7], addr, data);
pic_unlock(s);
break; break;
case 0x4d0: case 0x4d0:
case 0x4d1: case 0x4d1:
pic_lock(s);
elcr_ioport_write(&s->pics[addr & 1], addr, data); elcr_ioport_write(&s->pics[addr & 1], addr, data);
pic_unlock(s);
break; break;
default:
return -EOPNOTSUPP;
} }
pic_unlock(s);
return 0; return 0;
} }
...@@ -503,29 +490,31 @@ static int picdev_read(struct kvm_pic *s, ...@@ -503,29 +490,31 @@ static int picdev_read(struct kvm_pic *s,
gpa_t addr, int len, void *val) gpa_t addr, int len, void *val)
{ {
unsigned char data = 0; unsigned char data = 0;
if (!picdev_in_range(addr))
return -EOPNOTSUPP;
if (len != 1) { if (len != 1) {
memset(val, 0, len); memset(val, 0, len);
pr_pic_unimpl("non byte read\n"); pr_pic_unimpl("non byte read\n");
return 0; return 0;
} }
pic_lock(s);
switch (addr) { switch (addr) {
case 0x20: case 0x20:
case 0x21: case 0x21:
case 0xa0: case 0xa0:
case 0xa1: case 0xa1:
pic_lock(s);
data = pic_ioport_read(&s->pics[addr >> 7], addr); data = pic_ioport_read(&s->pics[addr >> 7], addr);
pic_unlock(s);
break; break;
case 0x4d0: case 0x4d0:
case 0x4d1: case 0x4d1:
pic_lock(s);
data = elcr_ioport_read(&s->pics[addr & 1], addr); data = elcr_ioport_read(&s->pics[addr & 1], addr);
pic_unlock(s);
break; break;
default:
return -EOPNOTSUPP;
} }
*(unsigned char *)val = data; *(unsigned char *)val = data;
pic_unlock(s);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment