Skip to content

Commit 8ffb418

Browse files
author
Marc Zyngier
committed
KVM: arm64: pkvm: Make the ERR/ERX*_EL1 registers RAZ/WI
The ERR*/ERX* registers should be handled as RAZ/WI, and there should be no need to involve EL1 for that. Add a helper that handles such registers, and repaint the sysreg table to declare these registers as RAZ/WI. Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Fuad Tabba <[email protected]> Tested-by: Fuad Tabba <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ce75916 commit 8ffb418

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

arch/arm64/kvm/hyp/nvhe/sys_regs.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ static u64 read_id_reg(const struct kvm_vcpu *vcpu,
248248
return pvm_read_id_reg(vcpu, reg_to_encoding(r));
249249
}
250250

251+
/* Handler to RAZ/WI sysregs */
252+
static bool pvm_access_raz_wi(struct kvm_vcpu *vcpu, struct sys_reg_params *p,
253+
const struct sys_reg_desc *r)
254+
{
255+
if (!p->is_write)
256+
p->regval = 0;
257+
258+
return true;
259+
}
260+
251261
/*
252262
* Accessor for AArch32 feature id registers.
253263
*
@@ -270,9 +280,7 @@ static bool pvm_access_id_aarch32(struct kvm_vcpu *vcpu,
270280
BUILD_BUG_ON(FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1),
271281
PVM_ID_AA64PFR0_RESTRICT_UNSIGNED) > ID_AA64PFR0_ELx_64BIT_ONLY);
272282

273-
/* Use 0 for architecturally "unknown" values. */
274-
p->regval = 0;
275-
return true;
283+
return pvm_access_raz_wi(vcpu, p, r);
276284
}
277285

278286
/*
@@ -301,6 +309,9 @@ static bool pvm_access_id_aarch64(struct kvm_vcpu *vcpu,
301309
/* Mark the specified system register as an AArch64 feature id register. */
302310
#define AARCH64(REG) { SYS_DESC(REG), .access = pvm_access_id_aarch64 }
303311

312+
/* Mark the specified system register as Read-As-Zero/Write-Ignored */
313+
#define RAZ_WI(REG) { SYS_DESC(REG), .access = pvm_access_raz_wi }
314+
304315
/* Mark the specified system register as not being handled in hyp. */
305316
#define HOST_HANDLED(REG) { SYS_DESC(REG), .access = NULL }
306317

@@ -388,14 +399,14 @@ static const struct sys_reg_desc pvm_sys_reg_descs[] = {
388399
HOST_HANDLED(SYS_AFSR1_EL1),
389400
HOST_HANDLED(SYS_ESR_EL1),
390401

391-
HOST_HANDLED(SYS_ERRIDR_EL1),
392-
HOST_HANDLED(SYS_ERRSELR_EL1),
393-
HOST_HANDLED(SYS_ERXFR_EL1),
394-
HOST_HANDLED(SYS_ERXCTLR_EL1),
395-
HOST_HANDLED(SYS_ERXSTATUS_EL1),
396-
HOST_HANDLED(SYS_ERXADDR_EL1),
397-
HOST_HANDLED(SYS_ERXMISC0_EL1),
398-
HOST_HANDLED(SYS_ERXMISC1_EL1),
402+
RAZ_WI(SYS_ERRIDR_EL1),
403+
RAZ_WI(SYS_ERRSELR_EL1),
404+
RAZ_WI(SYS_ERXFR_EL1),
405+
RAZ_WI(SYS_ERXCTLR_EL1),
406+
RAZ_WI(SYS_ERXSTATUS_EL1),
407+
RAZ_WI(SYS_ERXADDR_EL1),
408+
RAZ_WI(SYS_ERXMISC0_EL1),
409+
RAZ_WI(SYS_ERXMISC1_EL1),
399410

400411
HOST_HANDLED(SYS_TFSR_EL1),
401412
HOST_HANDLED(SYS_TFSRE0_EL1),

0 commit comments

Comments
 (0)