Skip to content

Commit af47382

Browse files
James MorseMarc Zyngier
authored andcommitted
KVM: arm64: Move ACTLR_EL1 emulation to the sys_reg_descs array
The only entry in the genericv8_sys_regs arrays is for emulation of ACTLR_EL1. As all targets emulate this in the same way, move it to sys_reg_descs[]. Signed-off-by: James Morse <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 04343ae commit af47382

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,25 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu,
242242
return true;
243243
}
244244

245+
static bool access_actlr(struct kvm_vcpu *vcpu,
246+
struct sys_reg_params *p,
247+
const struct sys_reg_desc *r)
248+
{
249+
if (p->is_write)
250+
return ignore_write(vcpu, p);
251+
252+
p->regval = vcpu_read_sys_reg(vcpu, ACTLR_EL1);
253+
254+
if (p->is_aarch32) {
255+
if (r->Op2 & 2)
256+
p->regval = upper_32_bits(p->regval);
257+
else
258+
p->regval = lower_32_bits(p->regval);
259+
}
260+
261+
return true;
262+
}
263+
245264
/*
246265
* Trap handler for the GICv3 SGI generation system register.
247266
* Forward the request to the VGIC emulation.
@@ -615,6 +634,12 @@ static void reset_amair_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
615634
vcpu_write_sys_reg(vcpu, amair, AMAIR_EL1);
616635
}
617636

637+
static void reset_actlr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
638+
{
639+
u64 actlr = read_sysreg(actlr_el1);
640+
vcpu_write_sys_reg(vcpu, actlr, ACTLR_EL1);
641+
}
642+
618643
static void reset_mpidr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
619644
{
620645
u64 mpidr;
@@ -1518,6 +1543,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
15181543
ID_UNALLOCATED(7,7),
15191544

15201545
{ SYS_DESC(SYS_SCTLR_EL1), access_vm_reg, reset_val, SCTLR_EL1, 0x00C50078 },
1546+
{ SYS_DESC(SYS_ACTLR_EL1), access_actlr, reset_actlr, ACTLR_EL1 },
15211547
{ SYS_DESC(SYS_CPACR_EL1), NULL, reset_val, CPACR_EL1, 0 },
15221548
{ SYS_DESC(SYS_ZCR_EL1), NULL, reset_val, ZCR_EL1, 0, .visibility = sve_visibility },
15231549
{ SYS_DESC(SYS_TTBR0_EL1), access_vm_reg, reset_unknown, TTBR0_EL1 },
@@ -1957,6 +1983,8 @@ static const struct sys_reg_desc cp14_64_regs[] = {
19571983
static const struct sys_reg_desc cp15_regs[] = {
19581984
{ Op1( 0), CRn( 0), CRm( 0), Op2( 1), access_ctr },
19591985
{ Op1( 0), CRn( 1), CRm( 0), Op2( 0), access_vm_reg, NULL, c1_SCTLR },
1986+
{ Op1( 0), CRn( 1), CRm( 0), Op2( 1), access_actlr },
1987+
{ Op1( 0), CRn( 1), CRm( 0), Op2( 3), access_actlr },
19601988
{ Op1( 0), CRn( 2), CRm( 0), Op2( 0), access_vm_reg, NULL, c2_TTBR0 },
19611989
{ Op1( 0), CRn( 2), CRm( 0), Op2( 1), access_vm_reg, NULL, c2_TTBR1 },
19621990
{ Op1( 0), CRn( 2), CRm( 0), Op2( 2), access_vm_reg, NULL, c2_TTBCR },

arch/arm64/kvm/sys_regs_generic_v8.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,14 @@
1919

2020
#include "sys_regs.h"
2121

22-
static bool access_actlr(struct kvm_vcpu *vcpu,
23-
struct sys_reg_params *p,
24-
const struct sys_reg_desc *r)
25-
{
26-
if (p->is_write)
27-
return ignore_write(vcpu, p);
28-
29-
p->regval = vcpu_read_sys_reg(vcpu, ACTLR_EL1);
30-
31-
if (p->is_aarch32) {
32-
if (r->Op2 & 2)
33-
p->regval = upper_32_bits(p->regval);
34-
else
35-
p->regval = lower_32_bits(p->regval);
36-
}
37-
38-
return true;
39-
}
40-
41-
static void reset_actlr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
42-
{
43-
__vcpu_sys_reg(vcpu, ACTLR_EL1) = read_sysreg(actlr_el1);
44-
}
45-
4622
/*
4723
* Implementation specific sys-reg registers.
4824
* Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2
4925
*/
5026
static const struct sys_reg_desc genericv8_sys_regs[] = {
51-
{ SYS_DESC(SYS_ACTLR_EL1), access_actlr, reset_actlr, ACTLR_EL1 },
5227
};
5328

5429
static const struct sys_reg_desc genericv8_cp15_regs[] = {
55-
/* ACTLR */
56-
{ Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b001),
57-
access_actlr },
58-
{ Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b011),
59-
access_actlr },
6030
};
6131

6232
struct kvm_sys_reg_target_table genericv8_target_table = {

0 commit comments

Comments
 (0)