55std::unique_ptr<ExtensionBase>
58 return std::make_unique<PartitionFieldExtension>(*
this);
101using namespace misc_regs;
107 return ind ?
reg.partidI :
reg.partidD;
114 return ind ?
reg.pmgI :
reg.pmgD;
123 (
el ==
EL1 && mpamhcr.el1Vpmen));
127mapVpmv(ThreadContext *tc,
PartID vpartid)
129 uint8_t reg_index = vpartid / 4;
130 uint8_t reg_field = vpartid % 4;
133 size_t reg_field_size =
sizeof(
PartID) * 8;
136 uint8_t lsb = reg_field * reg_field_size;
137 uint8_t msb = lsb + reg_field_size - 1;
140 return bits(vpmv, msb ,lsb);
143static std::optional<PartID>
144virtToPhysPart(ThreadContext *tc,
PartID vpartid, MPAMIDR mpamidr)
147 const uint8_t vpartid_max = (mpamidr.vpmrMax << 2) + 3;
150 if (vpartid > vpartid_max) {
151 vpartid = vpartid % (vpartid_max + 1);
155 if (
bits(mpam_vpmv, vpartid)) {
157 phys_partid = mapVpmv(tc, vpartid);
158 }
else if (
bits(mpam_vpmv, 0)) {
160 phys_partid = mapVpmv(tc, 0);
166 return phys_partid > mpamidr.partidMax ?
167 std::nullopt : std::make_optional(phys_partid);
170static std::optional<PartID>
174 auto partid = getPARTID(tc,
el, ind);
176 if (partid > mpamidr.partidMax) {
178 }
else if (useVirtualPartitions(tc,
el, mpamidr)) {
179 return virtToPhysPart(tc, partid, mpamidr);
185static std::optional<PMG>
189 PMG pgroup = getPMG(tc,
el, ind);
190 return pgroup > mpamidr.pmgMax ? std::nullopt : std::make_optional(pgroup);
194isEnabled(ThreadContext *tc)
200static std::shared_ptr<PartitionFieldExtension>
204 auto ext = std::make_shared<PartitionFieldExtension>();
210static std::shared_ptr<PartitionFieldExtension>
211genExtension(ThreadContext *tc,
bool ind)
218 mpamhcr.gstappPlk && !hcr.tge;
224 auto ext = std::make_shared<
225 PartitionFieldExtension>();
227 auto part_id = genPARTID(tc, curr_el, ind).value_or(
229 auto part_mon_id = genPMG(tc, curr_el, ind).value_or(
232 ext->setPartitionID(part_id);
233 ext->setPartitionMonitoringID(part_mon_id);
242 if (!
HaveExt(tc, ArmExtension::FEAT_MPAM) || !isEnabled(tc))
247 auto ext = mpamidr.hasSdeflt && mpam3.el3.sdeflt &&
isSecure(tc) ?
248 genExtensionDefault() :
249 genExtension(tc, ind);
252 "MPAM Tagging req %#x => PART_ID: %d, PART_MON_ID: %d\n",
254 ext->getPartitionID(),
255 ext->getPartitionMonitoringID());
258 if (!mpam_ns && mpam3.el3.forceNs) {
262 ext->setMpamNS(mpam_ns);
264 req->setExtension(
ext);
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal readMiscReg(RegIndex misc_reg)=0
virtual BaseCPU * getCpuPtr()=0
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.