KVM: arm64: clean up redundant 'kvm_run' parameters

In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu'
structure. For historical reasons, many kvm-related function parameters
retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This
patch does a unified cleanup of these remaining redundant parameters.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20200623131418.31473-3-tianjia.zhang@linux.alibaba.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Tianjia Zhang 2020-06-23 21:14:15 +08:00 committed by Paolo Bonzini
parent 2f0a83bece
commit 74cc7e0c35
8 changed files with 46 additions and 50 deletions

View File

@ -27,12 +27,12 @@ struct kvm_sys_reg_target_table {
void kvm_register_target_sys_reg_table(unsigned int target, void kvm_register_target_sys_reg_table(unsigned int target,
struct kvm_sys_reg_target_table *table); struct kvm_sys_reg_target_table *table);
int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu);
int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_cp14_32(struct kvm_vcpu *vcpu);
int kvm_handle_cp14_64(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_cp14_64(struct kvm_vcpu *vcpu);
int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_cp15_32(struct kvm_vcpu *vcpu);
int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_cp15_64(struct kvm_vcpu *vcpu);
int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_sys_reg(struct kvm_vcpu *vcpu);
#define kvm_coproc_table_init kvm_sys_reg_table_init #define kvm_coproc_table_init kvm_sys_reg_table_init
void kvm_sys_reg_table_init(void); void kvm_sys_reg_table_init(void);

View File

@ -470,18 +470,15 @@ u64 __kvm_call_hyp(void *hypfn, ...);
void force_vm_exit(const cpumask_t *mask); void force_vm_exit(const cpumask_t *mask);
void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, int handle_exit(struct kvm_vcpu *vcpu, int exception_index);
int exception_index); void handle_exit_early(struct kvm_vcpu *vcpu, int exception_index);
void handle_exit_early(struct kvm_vcpu *vcpu, struct kvm_run *run,
int exception_index);
/* MMIO helpers */ /* MMIO helpers */
void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data); void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data);
unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len); unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len);
int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_mmio_return(struct kvm_vcpu *vcpu);
int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa);
phys_addr_t fault_ipa);
int kvm_perf_init(void); int kvm_perf_init(void);
int kvm_perf_teardown(void); int kvm_perf_teardown(void);

View File

@ -139,7 +139,7 @@ void kvm_free_stage2_pgd(struct kvm *kvm);
int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa, int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
phys_addr_t pa, unsigned long size, bool writable); phys_addr_t pa, unsigned long size, bool writable);
int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run); int kvm_handle_guest_abort(struct kvm_vcpu *vcpu);
void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu); void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu);

View File

@ -660,7 +660,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
return ret; return ret;
if (run->exit_reason == KVM_EXIT_MMIO) { if (run->exit_reason == KVM_EXIT_MMIO) {
ret = kvm_handle_mmio_return(vcpu, run); ret = kvm_handle_mmio_return(vcpu);
if (ret) if (ret)
return ret; return ret;
} }
@ -812,11 +812,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu)); trace_kvm_exit(ret, kvm_vcpu_trap_get_class(vcpu), *vcpu_pc(vcpu));
/* Exit types that need handling before we can be preempted */ /* Exit types that need handling before we can be preempted */
handle_exit_early(vcpu, run, ret); handle_exit_early(vcpu, ret);
preempt_enable(); preempt_enable();
ret = handle_exit(vcpu, run, ret); ret = handle_exit(vcpu, ret);
} }
/* Tell userspace about in-kernel device output levels */ /* Tell userspace about in-kernel device output levels */

View File

@ -25,7 +25,7 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include "trace_handle_exit.h" #include "trace_handle_exit.h"
typedef int (*exit_handle_fn)(struct kvm_vcpu *, struct kvm_run *); typedef int (*exit_handle_fn)(struct kvm_vcpu *);
static void kvm_handle_guest_serror(struct kvm_vcpu *vcpu, u32 esr) static void kvm_handle_guest_serror(struct kvm_vcpu *vcpu, u32 esr)
{ {
@ -33,7 +33,7 @@ static void kvm_handle_guest_serror(struct kvm_vcpu *vcpu, u32 esr)
kvm_inject_vabt(vcpu); kvm_inject_vabt(vcpu);
} }
static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_hvc(struct kvm_vcpu *vcpu)
{ {
int ret; int ret;
@ -50,7 +50,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)
return ret; return ret;
} }
static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_smc(struct kvm_vcpu *vcpu)
{ {
/* /*
* "If an SMC instruction executed at Non-secure EL1 is * "If an SMC instruction executed at Non-secure EL1 is
@ -69,7 +69,7 @@ static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run)
* Guest access to FP/ASIMD registers are routed to this handler only * Guest access to FP/ASIMD registers are routed to this handler only
* when the system doesn't support FP/ASIMD. * when the system doesn't support FP/ASIMD.
*/ */
static int handle_no_fpsimd(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_no_fpsimd(struct kvm_vcpu *vcpu)
{ {
kvm_inject_undefined(vcpu); kvm_inject_undefined(vcpu);
return 1; return 1;
@ -87,7 +87,7 @@ static int handle_no_fpsimd(struct kvm_vcpu *vcpu, struct kvm_run *run)
* world-switches and schedule other host processes until there is an * world-switches and schedule other host processes until there is an
* incoming IRQ or FIQ to the VM. * incoming IRQ or FIQ to the VM.
*/ */
static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) static int kvm_handle_wfx(struct kvm_vcpu *vcpu)
{ {
if (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE) { if (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE) {
trace_kvm_wfx_arm64(*vcpu_pc(vcpu), true); trace_kvm_wfx_arm64(*vcpu_pc(vcpu), true);
@ -109,16 +109,16 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)
* kvm_handle_guest_debug - handle a debug exception instruction * kvm_handle_guest_debug - handle a debug exception instruction
* *
* @vcpu: the vcpu pointer * @vcpu: the vcpu pointer
* @run: access to the kvm_run structure for results
* *
* We route all debug exceptions through the same handler. If both the * We route all debug exceptions through the same handler. If both the
* guest and host are using the same debug facilities it will be up to * guest and host are using the same debug facilities it will be up to
* userspace to re-inject the correct exception for guest delivery. * userspace to re-inject the correct exception for guest delivery.
* *
* @return: 0 (while setting run->exit_reason), -1 for error * @return: 0 (while setting vcpu->run->exit_reason), -1 for error
*/ */
static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu, struct kvm_run *run) static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
{ {
struct kvm_run *run = vcpu->run;
u32 hsr = kvm_vcpu_get_hsr(vcpu); u32 hsr = kvm_vcpu_get_hsr(vcpu);
int ret = 0; int ret = 0;
@ -144,7 +144,7 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu, struct kvm_run *run)
return ret; return ret;
} }
static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run) static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu)
{ {
u32 hsr = kvm_vcpu_get_hsr(vcpu); u32 hsr = kvm_vcpu_get_hsr(vcpu);
@ -155,7 +155,7 @@ static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run)
return 1; return 1;
} }
static int handle_sve(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_sve(struct kvm_vcpu *vcpu)
{ {
/* Until SVE is supported for guests: */ /* Until SVE is supported for guests: */
kvm_inject_undefined(vcpu); kvm_inject_undefined(vcpu);
@ -167,7 +167,7 @@ static int handle_sve(struct kvm_vcpu *vcpu, struct kvm_run *run)
* a NOP). If we get here, it is that we didn't fixup ptrauth on exit, and all * a NOP). If we get here, it is that we didn't fixup ptrauth on exit, and all
* that we can do is give the guest an UNDEF. * that we can do is give the guest an UNDEF.
*/ */
static int kvm_handle_ptrauth(struct kvm_vcpu *vcpu, struct kvm_run *run) static int kvm_handle_ptrauth(struct kvm_vcpu *vcpu)
{ {
kvm_inject_undefined(vcpu); kvm_inject_undefined(vcpu);
return 1; return 1;
@ -212,7 +212,7 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu)
* KVM_EXIT_DEBUG, otherwise userspace needs to complete its * KVM_EXIT_DEBUG, otherwise userspace needs to complete its
* emulation first. * emulation first.
*/ */
static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_trap_exceptions(struct kvm_vcpu *vcpu)
{ {
int handled; int handled;
@ -227,7 +227,7 @@ static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run)
exit_handle_fn exit_handler; exit_handle_fn exit_handler;
exit_handler = kvm_get_exit_handler(vcpu); exit_handler = kvm_get_exit_handler(vcpu);
handled = exit_handler(vcpu, run); handled = exit_handler(vcpu);
} }
return handled; return handled;
@ -237,9 +237,10 @@ static int handle_trap_exceptions(struct kvm_vcpu *vcpu, struct kvm_run *run)
* Return > 0 to return to guest, < 0 on error, 0 (and set exit_reason) on * Return > 0 to return to guest, < 0 on error, 0 (and set exit_reason) on
* proper exit to userspace. * proper exit to userspace.
*/ */
int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, int handle_exit(struct kvm_vcpu *vcpu, int exception_index)
int exception_index)
{ {
struct kvm_run *run = vcpu->run;
if (ARM_SERROR_PENDING(exception_index)) { if (ARM_SERROR_PENDING(exception_index)) {
u8 hsr_ec = ESR_ELx_EC(kvm_vcpu_get_hsr(vcpu)); u8 hsr_ec = ESR_ELx_EC(kvm_vcpu_get_hsr(vcpu));
@ -265,7 +266,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
case ARM_EXCEPTION_EL1_SERROR: case ARM_EXCEPTION_EL1_SERROR:
return 1; return 1;
case ARM_EXCEPTION_TRAP: case ARM_EXCEPTION_TRAP:
return handle_trap_exceptions(vcpu, run); return handle_trap_exceptions(vcpu);
case ARM_EXCEPTION_HYP_GONE: case ARM_EXCEPTION_HYP_GONE:
/* /*
* EL2 has been reset to the hyp-stub. This happens when a guest * EL2 has been reset to the hyp-stub. This happens when a guest
@ -289,8 +290,7 @@ int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
} }
/* For exit types that need handling before we can be preempted */ /* For exit types that need handling before we can be preempted */
void handle_exit_early(struct kvm_vcpu *vcpu, struct kvm_run *run, void handle_exit_early(struct kvm_vcpu *vcpu, int exception_index)
int exception_index)
{ {
if (ARM_SERROR_PENDING(exception_index)) { if (ARM_SERROR_PENDING(exception_index)) {
if (this_cpu_has_cap(ARM64_HAS_RAS_EXTN)) { if (this_cpu_has_cap(ARM64_HAS_RAS_EXTN)) {

View File

@ -77,9 +77,8 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len)
* or in-kernel IO emulation * or in-kernel IO emulation
* *
* @vcpu: The VCPU pointer * @vcpu: The VCPU pointer
* @run: The VCPU run struct containing the mmio data
*/ */
int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_mmio_return(struct kvm_vcpu *vcpu)
{ {
unsigned long data; unsigned long data;
unsigned int len; unsigned int len;
@ -92,6 +91,8 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
vcpu->mmio_needed = 0; vcpu->mmio_needed = 0;
if (!kvm_vcpu_dabt_iswrite(vcpu)) { if (!kvm_vcpu_dabt_iswrite(vcpu)) {
struct kvm_run *run = vcpu->run;
len = kvm_vcpu_dabt_get_as(vcpu); len = kvm_vcpu_dabt_get_as(vcpu);
data = kvm_mmio_read_buf(run->mmio.data, len); data = kvm_mmio_read_buf(run->mmio.data, len);
@ -119,9 +120,9 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
return 0; return 0;
} }
int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
phys_addr_t fault_ipa)
{ {
struct kvm_run *run = vcpu->run;
unsigned long data; unsigned long data;
unsigned long rt; unsigned long rt;
int ret; int ret;
@ -188,7 +189,7 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
if (!is_write) if (!is_write)
memcpy(run->mmio.data, data_buf, len); memcpy(run->mmio.data, data_buf, len);
vcpu->stat.mmio_exit_kernel++; vcpu->stat.mmio_exit_kernel++;
kvm_handle_mmio_return(vcpu, run); kvm_handle_mmio_return(vcpu);
return 1; return 1;
} }

View File

@ -2015,7 +2015,6 @@ out:
/** /**
* kvm_handle_guest_abort - handles all 2nd stage aborts * kvm_handle_guest_abort - handles all 2nd stage aborts
* @vcpu: the VCPU pointer * @vcpu: the VCPU pointer
* @run: the kvm_run structure
* *
* Any abort that gets to the host is almost guaranteed to be caused by a * Any abort that gets to the host is almost guaranteed to be caused by a
* missing second stage translation table entry, which can mean that either the * missing second stage translation table entry, which can mean that either the
@ -2024,7 +2023,7 @@ out:
* space. The distinction is based on the IPA causing the fault and whether this * space. The distinction is based on the IPA causing the fault and whether this
* memory region has been registered as standard RAM by user space. * memory region has been registered as standard RAM by user space.
*/ */
int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_guest_abort(struct kvm_vcpu *vcpu)
{ {
unsigned long fault_status; unsigned long fault_status;
phys_addr_t fault_ipa; phys_addr_t fault_ipa;
@ -2103,7 +2102,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
* of the page size. * of the page size.
*/ */
fault_ipa |= kvm_vcpu_get_hfar(vcpu) & ((1 << 12) - 1); fault_ipa |= kvm_vcpu_get_hfar(vcpu) & ((1 << 12) - 1);
ret = io_mem_abort(vcpu, run, fault_ipa); ret = io_mem_abort(vcpu, fault_ipa);
goto out_unlock; goto out_unlock;
} }

View File

@ -2156,7 +2156,7 @@ static const struct sys_reg_desc *find_reg(const struct sys_reg_params *params,
return bsearch((void *)pval, table, num, sizeof(table[0]), match_sys_reg); return bsearch((void *)pval, table, num, sizeof(table[0]), match_sys_reg);
} }
int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu)
{ {
kvm_inject_undefined(vcpu); kvm_inject_undefined(vcpu);
return 1; return 1;
@ -2335,7 +2335,7 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,
return 1; return 1;
} }
int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_cp15_64(struct kvm_vcpu *vcpu)
{ {
const struct sys_reg_desc *target_specific; const struct sys_reg_desc *target_specific;
size_t num; size_t num;
@ -2346,7 +2346,7 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run)
target_specific, num); target_specific, num);
} }
int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_cp15_32(struct kvm_vcpu *vcpu)
{ {
const struct sys_reg_desc *target_specific; const struct sys_reg_desc *target_specific;
size_t num; size_t num;
@ -2357,14 +2357,14 @@ int kvm_handle_cp15_32(struct kvm_vcpu *vcpu, struct kvm_run *run)
target_specific, num); target_specific, num);
} }
int kvm_handle_cp14_64(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_cp14_64(struct kvm_vcpu *vcpu)
{ {
return kvm_handle_cp_64(vcpu, return kvm_handle_cp_64(vcpu,
cp14_64_regs, ARRAY_SIZE(cp14_64_regs), cp14_64_regs, ARRAY_SIZE(cp14_64_regs),
NULL, 0); NULL, 0);
} }
int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_cp14_32(struct kvm_vcpu *vcpu)
{ {
return kvm_handle_cp_32(vcpu, return kvm_handle_cp_32(vcpu,
cp14_regs, ARRAY_SIZE(cp14_regs), cp14_regs, ARRAY_SIZE(cp14_regs),
@ -2416,9 +2416,8 @@ static void reset_sys_reg_descs(struct kvm_vcpu *vcpu,
/** /**
* kvm_handle_sys_reg -- handles a mrs/msr trap on a guest sys_reg access * kvm_handle_sys_reg -- handles a mrs/msr trap on a guest sys_reg access
* @vcpu: The VCPU pointer * @vcpu: The VCPU pointer
* @run: The kvm_run struct
*/ */
int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run) int kvm_handle_sys_reg(struct kvm_vcpu *vcpu)
{ {
struct sys_reg_params params; struct sys_reg_params params;
unsigned long esr = kvm_vcpu_get_hsr(vcpu); unsigned long esr = kvm_vcpu_get_hsr(vcpu);