mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 04:42:12 +00:00
8d404c4c24
Currently we access the system registers array via the vcpu_sys_reg() macro. However, we are about to change the behavior to some times modify the register file directly, so let's change this to two primitives: * Accessor macros vcpu_write_sys_reg() and vcpu_read_sys_reg() * Direct array access macro __vcpu_sys_reg() The accessor macros should be used in places where the code needs to access the currently loaded VCPU's state as observed by the guest. For example, when trapping on cache related registers, a write to a system register should go directly to the VCPU version of the register. The direct array access macro can be used in places where the VCPU is known to never be running (for example userspace access) or for registers which are never context switched (for example all the PMU system registers). This rewrites all users of vcpu_sys_regs to one of the macros described above. No functional change. Acked-by: Marc Zyngier <marc.zyngier@arm.com> Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Christoffer Dall <cdall@cs.columbia.edu> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
99 lines
2.9 KiB
C
99 lines
2.9 KiB
C
/*
|
|
* Copyright (C) 2012,2013 - ARM Ltd
|
|
* Author: Marc Zyngier <marc.zyngier@arm.com>
|
|
*
|
|
* Based on arch/arm/kvm/coproc_a15.c:
|
|
* Copyright (C) 2012 - Virtual Open Systems and Columbia University
|
|
* Authors: Rusty Russell <rusty@rustcorp.au>
|
|
* Christoffer Dall <c.dall@virtualopensystems.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License, version 2, as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <linux/kvm_host.h>
|
|
#include <asm/cputype.h>
|
|
#include <asm/kvm_arm.h>
|
|
#include <asm/kvm_asm.h>
|
|
#include <asm/kvm_host.h>
|
|
#include <asm/kvm_emulate.h>
|
|
#include <asm/kvm_coproc.h>
|
|
#include <asm/sysreg.h>
|
|
#include <linux/init.h>
|
|
|
|
#include "sys_regs.h"
|
|
|
|
static bool access_actlr(struct kvm_vcpu *vcpu,
|
|
struct sys_reg_params *p,
|
|
const struct sys_reg_desc *r)
|
|
{
|
|
if (p->is_write)
|
|
return ignore_write(vcpu, p);
|
|
|
|
p->regval = vcpu_read_sys_reg(vcpu, ACTLR_EL1);
|
|
return true;
|
|
}
|
|
|
|
static void reset_actlr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
|
|
{
|
|
__vcpu_sys_reg(vcpu, ACTLR_EL1) = read_sysreg(actlr_el1);
|
|
}
|
|
|
|
/*
|
|
* Implementation specific sys-reg registers.
|
|
* Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2
|
|
*/
|
|
static const struct sys_reg_desc genericv8_sys_regs[] = {
|
|
{ SYS_DESC(SYS_ACTLR_EL1), access_actlr, reset_actlr, ACTLR_EL1 },
|
|
};
|
|
|
|
static const struct sys_reg_desc genericv8_cp15_regs[] = {
|
|
/* ACTLR */
|
|
{ Op1(0b000), CRn(0b0001), CRm(0b0000), Op2(0b001),
|
|
access_actlr },
|
|
};
|
|
|
|
static struct kvm_sys_reg_target_table genericv8_target_table = {
|
|
.table64 = {
|
|
.table = genericv8_sys_regs,
|
|
.num = ARRAY_SIZE(genericv8_sys_regs),
|
|
},
|
|
.table32 = {
|
|
.table = genericv8_cp15_regs,
|
|
.num = ARRAY_SIZE(genericv8_cp15_regs),
|
|
},
|
|
};
|
|
|
|
static int __init sys_reg_genericv8_init(void)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 1; i < ARRAY_SIZE(genericv8_sys_regs); i++)
|
|
BUG_ON(cmp_sys_reg(&genericv8_sys_regs[i-1],
|
|
&genericv8_sys_regs[i]) >= 0);
|
|
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_AEM_V8,
|
|
&genericv8_target_table);
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_FOUNDATION_V8,
|
|
&genericv8_target_table);
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_CORTEX_A53,
|
|
&genericv8_target_table);
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_CORTEX_A57,
|
|
&genericv8_target_table);
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_XGENE_POTENZA,
|
|
&genericv8_target_table);
|
|
kvm_register_target_sys_reg_table(KVM_ARM_TARGET_GENERIC_V8,
|
|
&genericv8_target_table);
|
|
|
|
return 0;
|
|
}
|
|
late_initcall(sys_reg_genericv8_init);
|