ppc: Check partition and process table alignment

Check if partition and process tables are properly aligned, in
their size, according to PowerISA 3.1B, Book III 6.7.6 programming
note. Hardware and KVM also raise an exception in these cases.

Signed-off-by: Leandro Lupori <leandro.lupori@eldorado.org.br>
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Message-Id: <20220628133959.15131-2-leandro.lupori@eldorado.org.br>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Leandro Lupori 2022-06-28 10:39:57 -03:00 committed by Daniel Henrique Barboza
parent 3778aa970f
commit 3c2e80ad2f
4 changed files with 32 additions and 4 deletions

View file

@ -920,6 +920,7 @@ static target_ulong h_register_process_table(PowerPCCPU *cpu,
target_ulong page_size = args[2];
target_ulong table_size = args[3];
target_ulong update_lpcr = 0;
target_ulong table_byte_size;
uint64_t cproc;
if (flags & ~FLAGS_MASK) { /* Check no reserved bits are set */
@ -927,6 +928,14 @@ static target_ulong h_register_process_table(PowerPCCPU *cpu,
}
if (flags & FLAG_MODIFY) {
if (flags & FLAG_REGISTER) {
/* Check process table alignment */
table_byte_size = 1ULL << (table_size + 12);
if (proc_tbl & (table_byte_size - 1)) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: process table not properly aligned: proc_tbl 0x"
TARGET_FMT_lx" proc_tbl_size 0x"TARGET_FMT_lx"\n",
__func__, proc_tbl, table_byte_size);
}
if (flags & FLAG_RADIX) { /* Register new RADIX process table */
if (proc_tbl & 0xfff || proc_tbl >> 60) {
return H_P2;