Commit db281766 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull ARM KVM fixes from Paolo Bonzini:

 - a series of fixes to deal with the aliasing between the sp and xzr
   register

 - a fix for the cache flush fix that went in -rc3

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  ARM/arm64: KVM: correct PTE uncachedness check
  arm64: KVM: Get rid of old vcpu_reg()
  arm64: KVM: Correctly handle zero register in system register accesses
  arm64: KVM: Remove const from struct sys_reg_params
  arm64: KVM: Correctly handle zero register during MMIO
parents 8cdef969 09922076
...@@ -28,6 +28,18 @@ ...@@ -28,6 +28,18 @@
unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num);
unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu); unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu);
static inline unsigned long vcpu_get_reg(struct kvm_vcpu *vcpu,
u8 reg_num)
{
return *vcpu_reg(vcpu, reg_num);
}
static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, u8 reg_num,
unsigned long val)
{
*vcpu_reg(vcpu, reg_num) = val;
}
bool kvm_condition_valid(struct kvm_vcpu *vcpu); bool kvm_condition_valid(struct kvm_vcpu *vcpu);
void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr); void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr);
void kvm_inject_undefined(struct kvm_vcpu *vcpu); void kvm_inject_undefined(struct kvm_vcpu *vcpu);
......
...@@ -115,7 +115,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) ...@@ -115,7 +115,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
trace_kvm_mmio(KVM_TRACE_MMIO_READ, len, run->mmio.phys_addr, trace_kvm_mmio(KVM_TRACE_MMIO_READ, len, run->mmio.phys_addr,
data); data);
data = vcpu_data_host_to_guest(vcpu, data, len); data = vcpu_data_host_to_guest(vcpu, data, len);
*vcpu_reg(vcpu, vcpu->arch.mmio_decode.rt) = data; vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data);
} }
return 0; return 0;
...@@ -186,7 +186,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, ...@@ -186,7 +186,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
rt = vcpu->arch.mmio_decode.rt; rt = vcpu->arch.mmio_decode.rt;
if (is_write) { if (is_write) {
data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt), len); data = vcpu_data_guest_to_host(vcpu, vcpu_get_reg(vcpu, rt),
len);
trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, len, fault_ipa, data); trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, len, fault_ipa, data);
mmio_write_buf(data_buf, len, data); mmio_write_buf(data_buf, len, data);
......
...@@ -218,7 +218,7 @@ static void unmap_ptes(struct kvm *kvm, pmd_t *pmd, ...@@ -218,7 +218,7 @@ static void unmap_ptes(struct kvm *kvm, pmd_t *pmd,
kvm_tlb_flush_vmid_ipa(kvm, addr); kvm_tlb_flush_vmid_ipa(kvm, addr);
/* No need to invalidate the cache for device mappings */ /* No need to invalidate the cache for device mappings */
if (!kvm_is_device_pfn(__phys_to_pfn(addr))) if (!kvm_is_device_pfn(pte_pfn(old_pte)))
kvm_flush_dcache_pte(old_pte); kvm_flush_dcache_pte(old_pte);
put_page(virt_to_page(pte)); put_page(virt_to_page(pte));
...@@ -310,7 +310,7 @@ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd, ...@@ -310,7 +310,7 @@ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd,
pte = pte_offset_kernel(pmd, addr); pte = pte_offset_kernel(pmd, addr);
do { do {
if (!pte_none(*pte) && !kvm_is_device_pfn(__phys_to_pfn(addr))) if (!pte_none(*pte) && !kvm_is_device_pfn(pte_pfn(*pte)))
kvm_flush_dcache_pte(*pte); kvm_flush_dcache_pte(*pte);
} while (pte++, addr += PAGE_SIZE, addr != end); } while (pte++, addr += PAGE_SIZE, addr != end);
} }
......
...@@ -75,7 +75,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) ...@@ -75,7 +75,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
unsigned long context_id; unsigned long context_id;
phys_addr_t target_pc; phys_addr_t target_pc;
cpu_id = *vcpu_reg(source_vcpu, 1) & MPIDR_HWID_BITMASK; cpu_id = vcpu_get_reg(source_vcpu, 1) & MPIDR_HWID_BITMASK;
if (vcpu_mode_is_32bit(source_vcpu)) if (vcpu_mode_is_32bit(source_vcpu))
cpu_id &= ~((u32) 0); cpu_id &= ~((u32) 0);
...@@ -94,8 +94,8 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) ...@@ -94,8 +94,8 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
return PSCI_RET_INVALID_PARAMS; return PSCI_RET_INVALID_PARAMS;
} }
target_pc = *vcpu_reg(source_vcpu, 2); target_pc = vcpu_get_reg(source_vcpu, 2);
context_id = *vcpu_reg(source_vcpu, 3); context_id = vcpu_get_reg(source_vcpu, 3);
kvm_reset_vcpu(vcpu); kvm_reset_vcpu(vcpu);
...@@ -114,7 +114,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) ...@@ -114,7 +114,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
* NOTE: We always update r0 (or x0) because for PSCI v0.1 * NOTE: We always update r0 (or x0) because for PSCI v0.1
* the general puspose registers are undefined upon CPU_ON. * the general puspose registers are undefined upon CPU_ON.
*/ */
*vcpu_reg(vcpu, 0) = context_id; vcpu_set_reg(vcpu, 0, context_id);
vcpu->arch.power_off = false; vcpu->arch.power_off = false;
smp_mb(); /* Make sure the above is visible */ smp_mb(); /* Make sure the above is visible */
...@@ -134,8 +134,8 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) ...@@ -134,8 +134,8 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
struct kvm *kvm = vcpu->kvm; struct kvm *kvm = vcpu->kvm;
struct kvm_vcpu *tmp; struct kvm_vcpu *tmp;
target_affinity = *vcpu_reg(vcpu, 1); target_affinity = vcpu_get_reg(vcpu, 1);
lowest_affinity_level = *vcpu_reg(vcpu, 2); lowest_affinity_level = vcpu_get_reg(vcpu, 2);
/* Determine target affinity mask */ /* Determine target affinity mask */
target_affinity_mask = psci_affinity_mask(lowest_affinity_level); target_affinity_mask = psci_affinity_mask(lowest_affinity_level);
...@@ -209,7 +209,7 @@ int kvm_psci_version(struct kvm_vcpu *vcpu) ...@@ -209,7 +209,7 @@ int kvm_psci_version(struct kvm_vcpu *vcpu)
static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
{ {
int ret = 1; int ret = 1;
unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0); unsigned long psci_fn = vcpu_get_reg(vcpu, 0) & ~((u32) 0);
unsigned long val; unsigned long val;
switch (psci_fn) { switch (psci_fn) {
...@@ -273,13 +273,13 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) ...@@ -273,13 +273,13 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
break; break;
} }
*vcpu_reg(vcpu, 0) = val; vcpu_set_reg(vcpu, 0, val);
return ret; return ret;
} }
static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
{ {
unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0); unsigned long psci_fn = vcpu_get_reg(vcpu, 0) & ~((u32) 0);
unsigned long val; unsigned long val;
switch (psci_fn) { switch (psci_fn) {
...@@ -295,7 +295,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) ...@@ -295,7 +295,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
break; break;
} }
*vcpu_reg(vcpu, 0) = val; vcpu_set_reg(vcpu, 0, val);
return 1; return 1;
} }
......
...@@ -100,13 +100,21 @@ static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu) ...@@ -100,13 +100,21 @@ static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu)
} }
/* /*
* vcpu_reg should always be passed a register number coming from a * vcpu_get_reg and vcpu_set_reg should always be passed a register number
* read of ESR_EL2. Otherwise, it may give the wrong result on AArch32 * coming from a read of ESR_EL2. Otherwise, it may give the wrong result on
* with banked registers. * AArch32 with banked registers.
*/ */
static inline unsigned long *vcpu_reg(const struct kvm_vcpu *vcpu, u8 reg_num) static inline unsigned long vcpu_get_reg(const struct kvm_vcpu *vcpu,
u8 reg_num)
{ {
return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.regs[reg_num]; return (reg_num == 31) ? 0 : vcpu_gp_regs(vcpu)->regs.regs[reg_num];
}
static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, u8 reg_num,
unsigned long val)
{
if (reg_num != 31)
vcpu_gp_regs(vcpu)->regs.regs[reg_num] = val;
} }
/* Get vcpu SPSR for current mode */ /* Get vcpu SPSR for current mode */
......
...@@ -37,7 +37,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) ...@@ -37,7 +37,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)
{ {
int ret; int ret;
trace_kvm_hvc_arm64(*vcpu_pc(vcpu), *vcpu_reg(vcpu, 0), trace_kvm_hvc_arm64(*vcpu_pc(vcpu), vcpu_get_reg(vcpu, 0),
kvm_vcpu_hvc_get_imm(vcpu)); kvm_vcpu_hvc_get_imm(vcpu));
ret = kvm_psci_call(vcpu); ret = kvm_psci_call(vcpu);
......
This diff is collapsed.
...@@ -28,7 +28,7 @@ struct sys_reg_params { ...@@ -28,7 +28,7 @@ struct sys_reg_params {
u8 CRn; u8 CRn;
u8 CRm; u8 CRm;
u8 Op2; u8 Op2;
u8 Rt; u64 regval;
bool is_write; bool is_write;
bool is_aarch32; bool is_aarch32;
bool is_32bit; /* Only valid if is_aarch32 is true */ bool is_32bit; /* Only valid if is_aarch32 is true */
...@@ -44,7 +44,7 @@ struct sys_reg_desc { ...@@ -44,7 +44,7 @@ struct sys_reg_desc {
/* Trapped access from guest, if non-NULL. */ /* Trapped access from guest, if non-NULL. */
bool (*access)(struct kvm_vcpu *, bool (*access)(struct kvm_vcpu *,
const struct sys_reg_params *, struct sys_reg_params *,
const struct sys_reg_desc *); const struct sys_reg_desc *);
/* Initialization for vcpu. */ /* Initialization for vcpu. */
...@@ -77,9 +77,9 @@ static inline bool ignore_write(struct kvm_vcpu *vcpu, ...@@ -77,9 +77,9 @@ static inline bool ignore_write(struct kvm_vcpu *vcpu,
} }
static inline bool read_zero(struct kvm_vcpu *vcpu, static inline bool read_zero(struct kvm_vcpu *vcpu,
const struct sys_reg_params *p) struct sys_reg_params *p)
{ {
*vcpu_reg(vcpu, p->Rt) = 0; p->regval = 0;
return true; return true;
} }
......
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
#include "sys_regs.h" #include "sys_regs.h"
static bool access_actlr(struct kvm_vcpu *vcpu, static bool access_actlr(struct kvm_vcpu *vcpu,
const struct sys_reg_params *p, struct sys_reg_params *p,
const struct sys_reg_desc *r) const struct sys_reg_desc *r)
{ {
if (p->is_write) if (p->is_write)
return ignore_write(vcpu, p); return ignore_write(vcpu, p);
*vcpu_reg(vcpu, p->Rt) = vcpu_sys_reg(vcpu, ACTLR_EL1); p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment