Skip to content

Commit 8b4fffe

Browse files
authored
Merge pull request #1601 from riscv-software-src/ns16550-address-space-size
Reduce NS16550 address space size to one page
2 parents 3a53c80 + b08054f commit 8b4fffe

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

riscv/ns16550.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <sstream>
33
#include "devices.h"
44
#include "processor.h"
5+
#include "mmu.h"
56
#include "term.h"
67
#include "sim.h"
78
#include "dts.h"
@@ -170,6 +171,9 @@ bool ns16550_t::load(reg_t addr, size_t len, uint8_t* bytes)
170171
if (reg_io_width != len) {
171172
return false;
172173
}
174+
if (addr + len > PGSIZE) {
175+
return false;
176+
}
173177
addr >>= reg_shift;
174178
addr &= 7;
175179

@@ -230,6 +234,9 @@ bool ns16550_t::store(reg_t addr, size_t len, const uint8_t* bytes)
230234
if (reg_io_width != len) {
231235
return false;
232236
}
237+
if (addr + len > PGSIZE) {
238+
return false;
239+
}
233240
addr >>= reg_shift;
234241
addr &= 7;
235242
val = bytes[0];

0 commit comments

Comments
 (0)