Skip to content

Commit 27a26b4

Browse files
committed
target/loongarch: Fix page size set issue with CSR_STLBPS
When modify register CSR_STLBPS, the page size should come from input parameter rather than old value. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn>
1 parent 349f3ec commit 27a26b4

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

target/loongarch/cpu-csr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ FIELD(CSR_PWCH, DIR4_WIDTH, 18, 6)
106106

107107
#define LOONGARCH_CSR_STLBPS 0x1e /* Stlb page size */
108108
FIELD(CSR_STLBPS, PS, 0, 5)
109+
FIELD(CSR_STLBPS, RESERVE, 5, 27)
109110

110111
#define LOONGARCH_CSR_RVACFG 0x1f /* Reduced virtual address config */
111112
FIELD(CSR_RVACFG, RBITS, 0, 4)

target/loongarch/tcg/csr_helper.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ target_ulong helper_csrwr_stlbps(CPULoongArchState *env, target_ulong val)
2626
* The real hardware only supports the min tlb_ps is 12
2727
* tlb_ps=0 may cause undefined-behavior.
2828
*/
29-
uint8_t tlb_ps = FIELD_EX64(env->CSR_STLBPS, CSR_STLBPS, PS);
29+
uint8_t tlb_ps = FIELD_EX64(val, CSR_STLBPS, PS);
3030
if (!check_ps(env, tlb_ps)) {
3131
qemu_log_mask(LOG_GUEST_ERROR,
3232
"Attempted set ps %d\n", tlb_ps);
3333
} else {
3434
/* Only update PS field, reserved bit keeps zero */
35-
env->CSR_STLBPS = FIELD_DP64(old_v, CSR_STLBPS, PS, tlb_ps);
35+
val = FIELD_DP64(val, CSR_STLBPS, RESERVE, 0);
36+
env->CSR_STLBPS = val;
3637
}
3738

3839
return old_v;

0 commit comments

Comments
 (0)