gem5 v24.0.0.0
Loading...
Searching...
No Matches
backdoor_manager.test.cc
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <gtest/gtest.h>
29#include <vector>
30
31#include "base/addr_range.hh"
32#include "base/gtest/logging.hh"
33#include "mem/backdoor.hh"
35
36namespace gem5
37{
38namespace backdoor_manager_test
39{
42
43class BackdoorManagerTest : public BackdoorManager, public ::testing::Test
44{
45 public:
49};
50
52{
57 AddrRange pkt_range = originalRanges[0];
58
59 uint8_t *ptr = nullptr;
60 MemBackdoor remapped_backdoor(remappedRanges[0], ptr,
61 MemBackdoor::Flags::Readable);
62 MemBackdoorPtr reverted_backdoor =
63 getRevertedBackdoor(&remapped_backdoor, pkt_range);
64
65 EXPECT_EQ(reverted_backdoor->range(), originalRanges[0]);
66 EXPECT_EQ(reverted_backdoor->ptr(), ptr);
67 ASSERT_EQ(backdoorLists[0].size(), 1);
68 EXPECT_EQ(backdoorLists[0].begin()->get(), reverted_backdoor);
69
74 remapped_backdoor.invalidate();
75 EXPECT_EQ(backdoorLists[0].size(), 0);
76}
77
79{
80 AddrRange pkt_range = originalRanges[0];
81
86 Addr diff = 0x1000;
87 AddrRange remapped_backdoor_range(
88 remappedRanges[0].start() - diff, // 0x0
89 remappedRanges[0].end() + diff); // 0x3000
90
91 uint8_t *ptr = nullptr;
92 MemBackdoor remapped_backdoor(remapped_backdoor_range, ptr,
93 MemBackdoor::Flags::Readable);
94 MemBackdoorPtr reverted_backdoor =
95 getRevertedBackdoor(&remapped_backdoor, pkt_range);
96
97 EXPECT_EQ(reverted_backdoor->range(), originalRanges[0]);
98 EXPECT_EQ(reverted_backdoor->ptr(), ptr + diff);
99
100 remapped_backdoor.invalidate();
101}
102
104{
109 Addr mid = originalRanges[0].start() + originalRanges[0].size() / 2;
110 AddrRange pkt_range_0 = AddrRange(originalRanges[0].start(), mid);
111 AddrRange pkt_range_1 = AddrRange(mid, originalRanges[0].end());
112
117 uint8_t *ptr = nullptr;
118 MemBackdoor remapped_backdoor(remappedRanges[0], ptr,
119 MemBackdoor::Flags::Readable);
123 MemBackdoorPtr reverted_backdoor_0 =
124 getRevertedBackdoor(&remapped_backdoor, pkt_range_0);
125 EXPECT_EQ(backdoorLists[0].size(), 1);
126
131 MemBackdoorPtr reverted_backdoor_1 =
132 getRevertedBackdoor(&remapped_backdoor, pkt_range_1);
133 EXPECT_EQ(reverted_backdoor_0, reverted_backdoor_1);
134 EXPECT_EQ(backdoorLists[0].size(), 1);
135
136 remapped_backdoor.invalidate();
137}
138
139} // namespace backdoor_manager_test
140} // namespace gem5
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
This class manages the backdoors for RangeAddrMapper.
uint8_t * ptr() const
Definition backdoor.hh:62
const AddrRange & range() const
Definition backdoor.hh:58
STL vector class.
Definition stl.hh:37
const std::vector< AddrRange > kRemappedRange({AddrRange(0x1000, 0x2000)})
TEST_F(BackdoorManagerTest, BasicRemapTest)
const std::vector< AddrRange > kOriginalRange({AddrRange(0x0, 0x1000)})
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0