mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-23 17:11:09 +00:00
target-arm: Apply S2 MMU startlevel table size check to AArch64
The S2 starting level table size check applies to both AArch32 and AArch64. Move it to common code. Backports commit 98d68ec289750139258d9cd9ab3f6d7dd10bb762 from qemu
This commit is contained in:
parent
d3e5003e53
commit
bab59f6b18
|
@ -6122,11 +6122,19 @@ typedef enum {
|
|||
static bool check_s2_startlevel(ARMCPU *cpu, bool is_aa64, int level,
|
||||
int inputsize, int stride)
|
||||
{
|
||||
const int grainsize = stride + 3;
|
||||
int startsizecheck;
|
||||
|
||||
/* Negative levels are never allowed. */
|
||||
if (level < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
startsizecheck = inputsize - ((3 - level) * stride + grainsize);
|
||||
if (startsizecheck < 1 || startsizecheck > stride + 4) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_aa64) {
|
||||
unsigned int pamax = arm_pamax(cpu);
|
||||
|
||||
|
@ -6150,20 +6158,12 @@ static bool check_s2_startlevel(ARMCPU *cpu, bool is_aa64, int level,
|
|||
g_assert_not_reached();
|
||||
}
|
||||
} else {
|
||||
const int grainsize = stride + 3;
|
||||
int startsizecheck;
|
||||
|
||||
/* AArch32 only supports 4KB pages. Assert on that. */
|
||||
assert(stride == 9);
|
||||
|
||||
if (level == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
startsizecheck = inputsize - ((3 - level) * stride + grainsize);
|
||||
if (startsizecheck < 1 || startsizecheck > stride + 4) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue