misc: Fix dynamic decision of TranslatingPortProxy.
In commit 83b14e56, getVirtProxy is replaced by inline ternary operators
to decide between FS or SE version. However, dynamic dispatch will not
work in this scenario and the virtual function of SETranslatingPortProxy
will not be called. It may lead to failure in m5op read_file in SE mode.
Change-Id: I9b5f757096cfdbd6fb8bc14b1b0e02245703a0ac
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62611
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
@@ -354,8 +354,11 @@ struct Argument<Aapcs32, Composite, typename std::enable_if_t<
|
||||
}
|
||||
|
||||
if (bytes) {
|
||||
(FullSystem ? TranslatingPortProxy(tc) :
|
||||
SETranslatingPortProxy(tc)).readBlob(
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.readBlob(
|
||||
state.nsaa, buf, bytes);
|
||||
|
||||
state.stackUsed = true;
|
||||
|
||||
@@ -1295,8 +1295,11 @@ TarmacParserRecord::readMemNoEffect(Addr addr, uint8_t *data, unsigned size,
|
||||
return false;
|
||||
// the translating proxy will perform the virtual to physical
|
||||
// translation again
|
||||
(FullSystem ? TranslatingPortProxy(thread) :
|
||||
SETranslatingPortProxy(thread)).readBlob(addr, data, size);
|
||||
TranslatingPortProxy fs_proxy(thread);
|
||||
SETranslatingPortProxy se_proxy(thread);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.readBlob(addr, data, size);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -723,16 +723,22 @@ BaseRemoteGDB::processCommands(int signum)
|
||||
bool
|
||||
BaseRemoteGDB::readBlob(Addr vaddr, size_t size, char *data)
|
||||
{
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc))
|
||||
.readBlob(vaddr, data, size);
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.readBlob(vaddr, data, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
BaseRemoteGDB::writeBlob(Addr vaddr, size_t size, const char *data)
|
||||
{
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc))
|
||||
.writeBlob(vaddr, data, size);
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.writeBlob(vaddr, data, size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -262,8 +262,11 @@ addsymbol(ThreadContext *tc, Addr addr, Addr symbolAddr)
|
||||
addr, symbolAddr);
|
||||
|
||||
std::string symbol;
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
|
||||
readString(symbol, symbolAddr);
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.readString(symbol, symbolAddr);
|
||||
|
||||
DPRINTF(Loader, "Loaded symbol: %s @ %#llx\n", symbol, addr);
|
||||
|
||||
@@ -393,8 +396,11 @@ readfile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset)
|
||||
}
|
||||
|
||||
close(fd);
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
|
||||
writeBlob(vaddr, buf, result);
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.writeBlob(vaddr, buf, result);
|
||||
delete [] buf;
|
||||
return result;
|
||||
}
|
||||
@@ -408,8 +414,11 @@ writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
|
||||
|
||||
// copy out target filename
|
||||
std::string filename;
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
|
||||
readString(filename, filename_addr);
|
||||
TranslatingPortProxy fs_proxy(tc);
|
||||
SETranslatingPortProxy se_proxy(tc);
|
||||
PortProxy &virt_proxy = FullSystem ? fs_proxy : se_proxy;
|
||||
|
||||
virt_proxy.readString(filename, filename_addr);
|
||||
|
||||
OutputStream *out;
|
||||
if (offset == 0) {
|
||||
@@ -434,8 +443,8 @@ writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
|
||||
|
||||
// copy out data and write to file
|
||||
char *buf = new char[len];
|
||||
(FullSystem ? TranslatingPortProxy(tc) : SETranslatingPortProxy(tc)).
|
||||
readBlob(vaddr, buf, len);
|
||||
|
||||
virt_proxy.readBlob(vaddr, buf, len);
|
||||
os->write(buf, len);
|
||||
if (os->fail() || os->bad())
|
||||
panic("Error while doing writefile!\n");
|
||||
|
||||
Reference in New Issue
Block a user