Skip to content

Commit 0a2c9d8

Browse files
committed
Merge branch 'kvm-arm64/misc' into kvmarm/next
* kvm-arm64/misc: : Miscellaneous fixes/cleanups for KVM/arm64 : : - Fixes for computing POE output permissions : : - Return ENXIO for invalid VGIC device attribute : : - String helper conversions arm64: kvm: trace_handle_exit: use string choices helper arm64: kvm: sys_regs: use string choices helper KVM: arm64: Follow specification when implementing WXN KVM: arm64: Remove the wi->{e0,}poe vs wr->{p,u}ov confusion KVM: arm64: vgic-its: Return -ENXIO to invalid KVM_DEV_ARM_VGIC_GRP_CTRL attrs Signed-off-by: Oliver Upton <[email protected]>
2 parents 1f315e9 + f509de1 commit 0a2c9d8

File tree

5 files changed

+50
-39
lines changed

5 files changed

+50
-39
lines changed

arch/arm64/kvm/at.c

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,34 +1047,51 @@ static void compute_s1_overlay_permissions(struct kvm_vcpu *vcpu,
10471047

10481048
idx = FIELD_GET(PTE_PO_IDX_MASK, wr->desc);
10491049

1050-
switch (wi->regime) {
1051-
case TR_EL10:
1052-
pov_perms = perm_idx(vcpu, POR_EL1, idx);
1053-
uov_perms = perm_idx(vcpu, POR_EL0, idx);
1054-
break;
1055-
case TR_EL20:
1056-
pov_perms = perm_idx(vcpu, POR_EL2, idx);
1057-
uov_perms = perm_idx(vcpu, POR_EL0, idx);
1058-
break;
1059-
case TR_EL2:
1060-
pov_perms = perm_idx(vcpu, POR_EL2, idx);
1061-
uov_perms = 0;
1062-
break;
1063-
}
1050+
if (wr->pov) {
1051+
switch (wi->regime) {
1052+
case TR_EL10:
1053+
pov_perms = perm_idx(vcpu, POR_EL1, idx);
1054+
break;
1055+
case TR_EL20:
1056+
pov_perms = perm_idx(vcpu, POR_EL2, idx);
1057+
break;
1058+
case TR_EL2:
1059+
pov_perms = perm_idx(vcpu, POR_EL2, idx);
1060+
break;
1061+
}
1062+
1063+
if (pov_perms & ~POE_RWX)
1064+
pov_perms = POE_NONE;
10641065

1065-
if (pov_perms & ~POE_RWX)
1066-
pov_perms = POE_NONE;
1066+
/* R_QXXPC, S1PrivOverflow enabled */
1067+
if (wr->pwxn && (pov_perms & POE_X))
1068+
pov_perms &= ~POE_W;
10671069

1068-
if (wi->poe && wr->pov) {
10691070
wr->pr &= pov_perms & POE_R;
10701071
wr->pw &= pov_perms & POE_W;
10711072
wr->px &= pov_perms & POE_X;
10721073
}
10731074

1074-
if (uov_perms & ~POE_RWX)
1075-
uov_perms = POE_NONE;
1075+
if (wr->uov) {
1076+
switch (wi->regime) {
1077+
case TR_EL10:
1078+
uov_perms = perm_idx(vcpu, POR_EL0, idx);
1079+
break;
1080+
case TR_EL20:
1081+
uov_perms = perm_idx(vcpu, POR_EL0, idx);
1082+
break;
1083+
case TR_EL2:
1084+
uov_perms = 0;
1085+
break;
1086+
}
1087+
1088+
if (uov_perms & ~POE_RWX)
1089+
uov_perms = POE_NONE;
1090+
1091+
/* R_NPBXC, S1UnprivOverlay enabled */
1092+
if (wr->uwxn && (uov_perms & POE_X))
1093+
uov_perms &= ~POE_W;
10761094

1077-
if (wi->e0poe && wr->uov) {
10781095
wr->ur &= uov_perms & POE_R;
10791096
wr->uw &= uov_perms & POE_W;
10801097
wr->ux &= uov_perms & POE_X;
@@ -1095,24 +1112,15 @@ static void compute_s1_permissions(struct kvm_vcpu *vcpu,
10951112
if (!wi->hpd)
10961113
compute_s1_hierarchical_permissions(vcpu, wi, wr);
10971114

1098-
if (wi->poe || wi->e0poe)
1099-
compute_s1_overlay_permissions(vcpu, wi, wr);
1115+
compute_s1_overlay_permissions(vcpu, wi, wr);
11001116

1101-
/* R_QXXPC */
1102-
if (wr->pwxn) {
1103-
if (!wr->pov && wr->pw)
1104-
wr->px = false;
1105-
if (wr->pov && wr->px)
1106-
wr->pw = false;
1107-
}
1117+
/* R_QXXPC, S1PrivOverlay disabled */
1118+
if (!wr->pov)
1119+
wr->px &= !(wr->pwxn && wr->pw);
11081120

1109-
/* R_NPBXC */
1110-
if (wr->uwxn) {
1111-
if (!wr->uov && wr->uw)
1112-
wr->ux = false;
1113-
if (wr->uov && wr->ux)
1114-
wr->uw = false;
1115-
}
1121+
/* R_NPBXC, S1UnprivOverlay disabled */
1122+
if (!wr->uov)
1123+
wr->ux &= !(wr->uwxn && wr->uw);
11161124

11171125
pan = wi->pan && (wr->ur || wr->uw ||
11181126
(pan3_enabled(vcpu, wi->regime) && wr->ux));

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4523,7 +4523,7 @@ static bool kvm_esr_cp10_id_to_sys64(u64 esr, struct sys_reg_params *params)
45234523
return true;
45244524

45254525
kvm_pr_unimpl("Unhandled cp10 register %s: %u\n",
4526-
params->is_write ? "write" : "read", reg_id);
4526+
str_write_read(params->is_write), reg_id);
45274527
return false;
45284528
}
45294529

arch/arm64/kvm/sys_regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ inline void print_sys_reg_msg(const struct sys_reg_params *p,
108108
/* Look, we even formatted it for you to paste into the table! */
109109
kvm_pr_unimpl("%pV { Op0(%2u), Op1(%2u), CRn(%2u), CRm(%2u), Op2(%2u), func_%s },\n",
110110
&(struct va_format){ fmt, &va },
111-
p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, p->is_write ? "write" : "read");
111+
p->Op0, p->Op1, p->CRn, p->CRm, p->Op2, str_write_read(p->is_write));
112112
va_end(va);
113113
}
114114

arch/arm64/kvm/trace_handle_exit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ TRACE_EVENT(kvm_sys_access,
113113
__entry->vcpu_pc, __entry->name ?: "UNKN",
114114
__entry->Op0, __entry->Op1, __entry->CRn,
115115
__entry->CRm, __entry->Op2,
116-
__entry->is_write ? "write" : "read")
116+
str_write_read(__entry->is_write))
117117
);
118118

119119
TRACE_EVENT(kvm_set_guest_debug,

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,9 @@ static int vgic_its_ctrl(struct kvm *kvm, struct vgic_its *its, u64 attr)
26942694
case KVM_DEV_ARM_ITS_RESTORE_TABLES:
26952695
ret = abi->restore_tables(its);
26962696
break;
2697+
default:
2698+
ret = -ENXIO;
2699+
break;
26972700
}
26982701

26992702
mutex_unlock(&its->its_lock);

0 commit comments

Comments
 (0)