* [PULL] KVM/arm64 fixes for 3.11
@ 2013-08-09 13:13 Marc Zyngier
2013-08-09 13:13 ` [PATCH 1/3] arm64: KVM: perform save/restore of PAR_EL1 Marc Zyngier
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Marc Zyngier @ 2013-08-09 13:13 UTC (permalink / raw)
To: pbonzini, gleb; +Cc: kvm, kvmarm, catalin.marinas, will.deacon
Paolo, Gleb,
Please consider pulling the following to get a new fixes for KVM/arm64.
Thanks,
M.
The following changes since commit c095ba7224d8edc71dcef0d655911399a8bd4a3f:
Linux 3.11-rc4 (2013-08-04 13:46:46 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git kvm-arm64/fixes-3.11-rc4
for you to fetch changes up to 6c8c0c4dc0e98ee2191211d66e9f876e95787073:
arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h. (2013-08-09 13:42:43 +0100)
----------------------------------------------------------------
Chen Gang (1):
arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h.
Marc Zyngier (2):
arm64: KVM: perform save/restore of PAR_EL1
arm64: KVM: add missing dsb before invalidating Stage-2 TLBs
arch/arm64/include/asm/kvm_asm.h | 17 ++++++++++-------
arch/arm64/include/asm/kvm_host.h | 2 +-
arch/arm64/kvm/hyp.S | 13 +++++++++++++
arch/arm64/kvm/sys_regs.c | 3 +++
4 files changed, 27 insertions(+), 8 deletions(-)
Chen Gang (1):
arm64: KVM: use 'int' instead of 'u32' for variable 'target' in
kvm_host.h.
Marc Zyngier (2):
arm64: KVM: perform save/restore of PAR_EL1
arm64: KVM: add missing dsb before invalidating Stage-2 TLBs
arch/arm64/include/asm/kvm_asm.h | 17 ++++++++++-------
arch/arm64/include/asm/kvm_host.h | 2 +-
arch/arm64/kvm/hyp.S | 13 +++++++++++++
arch/arm64/kvm/sys_regs.c | 3 +++
4 files changed, 27 insertions(+), 8 deletions(-)
--
1.8.2.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/3] arm64: KVM: perform save/restore of PAR_EL1 2013-08-09 13:13 [PULL] KVM/arm64 fixes for 3.11 Marc Zyngier @ 2013-08-09 13:13 ` Marc Zyngier 2013-08-09 13:13 ` [PATCH 2/3] arm64: KVM: add missing dsb before invalidating Stage-2 TLBs Marc Zyngier ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: Marc Zyngier @ 2013-08-09 13:13 UTC (permalink / raw) To: pbonzini, gleb; +Cc: kvm, kvmarm, catalin.marinas, will.deacon Not saving PAR_EL1 is an unfortunate oversight. If the guest performs an AT* operation and gets scheduled out before reading the result of the translation from PAREL1, it could become corrupted by another guest or the host. Saving this register is made slightly more complicated as KVM also uses it on the permission fault handling path, leading to an ugly "stash and restore" sequence. Fortunately, this is already a slow path so we don't really care. Also, Linux doesn't do any AT* operation, so Linux guests are not impacted by this bug. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/include/asm/kvm_asm.h | 17 ++++++++++------- arch/arm64/kvm/hyp.S | 10 ++++++++++ arch/arm64/kvm/sys_regs.c | 3 +++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index c92de41..b25763b 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -42,14 +42,15 @@ #define TPIDR_EL1 18 /* Thread ID, Privileged */ #define AMAIR_EL1 19 /* Aux Memory Attribute Indirection Register */ #define CNTKCTL_EL1 20 /* Timer Control Register (EL1) */ +#define PAR_EL1 21 /* Physical Address Register */ /* 32bit specific registers. Keep them at the end of the range */ -#define DACR32_EL2 21 /* Domain Access Control Register */ -#define IFSR32_EL2 22 /* Instruction Fault Status Register */ -#define FPEXC32_EL2 23 /* Floating-Point Exception Control Register */ -#define DBGVCR32_EL2 24 /* Debug Vector Catch Register */ -#define TEECR32_EL1 25 /* ThumbEE Configuration Register */ -#define TEEHBR32_EL1 26 /* ThumbEE Handler Base Register */ -#define NR_SYS_REGS 27 +#define DACR32_EL2 22 /* Domain Access Control Register */ +#define IFSR32_EL2 23 /* Instruction Fault Status Register */ +#define FPEXC32_EL2 24 /* Floating-Point Exception Control Register */ +#define DBGVCR32_EL2 25 /* Debug Vector Catch Register */ +#define TEECR32_EL1 26 /* ThumbEE Configuration Register */ +#define TEEHBR32_EL1 27 /* ThumbEE Handler Base Register */ +#define NR_SYS_REGS 28 /* 32bit mapping */ #define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */ @@ -69,6 +70,8 @@ #define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */ #define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */ #define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */ +#define c7_PAR (PAR_EL1 * 2) /* Physical Address Register */ +#define c7_PAR_high (c7_PAR + 1) /* PAR top 32 bits */ #define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */ #define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */ #define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */ diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S index ff985e3..218802f 100644 --- a/arch/arm64/kvm/hyp.S +++ b/arch/arm64/kvm/hyp.S @@ -214,6 +214,7 @@ __kvm_hyp_code_start: mrs x21, tpidr_el1 mrs x22, amair_el1 mrs x23, cntkctl_el1 + mrs x24, par_el1 stp x4, x5, [x3] stp x6, x7, [x3, #16] @@ -225,6 +226,7 @@ __kvm_hyp_code_start: stp x18, x19, [x3, #112] stp x20, x21, [x3, #128] stp x22, x23, [x3, #144] + str x24, [x3, #160] .endm .macro restore_sysregs @@ -243,6 +245,7 @@ __kvm_hyp_code_start: ldp x18, x19, [x3, #112] ldp x20, x21, [x3, #128] ldp x22, x23, [x3, #144] + ldr x24, [x3, #160] msr vmpidr_el2, x4 msr csselr_el1, x5 @@ -264,6 +267,7 @@ __kvm_hyp_code_start: msr tpidr_el1, x21 msr amair_el1, x22 msr cntkctl_el1, x23 + msr par_el1, x24 .endm .macro skip_32bit_state tmp, target @@ -753,6 +757,10 @@ el1_trap: */ tbnz x1, #7, 1f // S1PTW is set + /* Preserve PAR_EL1 */ + mrs x3, par_el1 + push x3, xzr + /* * Permission fault, HPFAR_EL2 is invalid. * Resolve the IPA the hard way using the guest VA. @@ -766,6 +774,8 @@ el1_trap: /* Read result */ mrs x3, par_el1 + pop x0, xzr // Restore PAR_EL1 from the stack + msr par_el1, x0 tbnz x3, #0, 3f // Bail out if we failed the translation ubfx x3, x3, #12, #36 // Extract IPA lsl x3, x3, #4 // and present it like HPFAR diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 9492360..02e9d09 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -211,6 +211,9 @@ static const struct sys_reg_desc sys_reg_descs[] = { /* FAR_EL1 */ { Op0(0b11), Op1(0b000), CRn(0b0110), CRm(0b0000), Op2(0b000), NULL, reset_unknown, FAR_EL1 }, + /* PAR_EL1 */ + { Op0(0b11), Op1(0b000), CRn(0b0111), CRm(0b0100), Op2(0b000), + NULL, reset_unknown, PAR_EL1 }, /* PMINTENSET_EL1 */ { Op0(0b11), Op1(0b000), CRn(0b1001), CRm(0b1110), Op2(0b001), -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] arm64: KVM: add missing dsb before invalidating Stage-2 TLBs 2013-08-09 13:13 [PULL] KVM/arm64 fixes for 3.11 Marc Zyngier 2013-08-09 13:13 ` [PATCH 1/3] arm64: KVM: perform save/restore of PAR_EL1 Marc Zyngier @ 2013-08-09 13:13 ` Marc Zyngier 2013-08-09 13:13 ` [PATCH 3/3] arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h Marc Zyngier 2013-08-19 20:55 ` [PULL] KVM/arm64 fixes for 3.11 Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Marc Zyngier @ 2013-08-09 13:13 UTC (permalink / raw) To: pbonzini, gleb; +Cc: kvm, kvmarm, catalin.marinas, will.deacon When performing a Stage-2 TLB invalidation, it is necessary to make sure the write to the page tables is observable by all CPUs. For this purpose, add dsb instructions to __kvm_tlb_flush_vmid_ipa and __kvm_flush_vm_context before doing the TLB invalidation itself. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/kvm/hyp.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kvm/hyp.S b/arch/arm64/kvm/hyp.S index 218802f..1ac0bbb 100644 --- a/arch/arm64/kvm/hyp.S +++ b/arch/arm64/kvm/hyp.S @@ -604,6 +604,8 @@ END(__kvm_vcpu_run) // void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); ENTRY(__kvm_tlb_flush_vmid_ipa) + dsb ishst + kern_hyp_va x0 ldr x2, [x0, #KVM_VTTBR] msr vttbr_el2, x2 @@ -625,6 +627,7 @@ ENTRY(__kvm_tlb_flush_vmid_ipa) ENDPROC(__kvm_tlb_flush_vmid_ipa) ENTRY(__kvm_flush_vm_context) + dsb ishst tlbi alle1is ic ialluis dsb sy -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h. 2013-08-09 13:13 [PULL] KVM/arm64 fixes for 3.11 Marc Zyngier 2013-08-09 13:13 ` [PATCH 1/3] arm64: KVM: perform save/restore of PAR_EL1 Marc Zyngier 2013-08-09 13:13 ` [PATCH 2/3] arm64: KVM: add missing dsb before invalidating Stage-2 TLBs Marc Zyngier @ 2013-08-09 13:13 ` Marc Zyngier 2013-08-19 20:55 ` [PULL] KVM/arm64 fixes for 3.11 Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Marc Zyngier @ 2013-08-09 13:13 UTC (permalink / raw) To: pbonzini, gleb; +Cc: kvm, kvmarm, catalin.marinas, will.deacon, Chen Gang From: Chen Gang <gang.chen@asianux.com> 'target' will be set to '-1' in kvm_arch_vcpu_init(), and it need check 'target' whether less than zero or not in kvm_vcpu_initialized(). So need define target as 'int' instead of 'u32', just like ARM has done. The related warning: arch/arm64/kvm/../../../arch/arm/kvm/arm.c:497:2: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] Signed-off-by: Chen Gang <gang.chen@asianux.com> [Marc: reformated the Subject line to fit the series] Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> --- arch/arm64/include/asm/kvm_host.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 644d739..0859a4d 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -129,7 +129,7 @@ struct kvm_vcpu_arch { struct kvm_mmu_memory_cache mmu_page_cache; /* Target CPU and feature flags */ - u32 target; + int target; DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES); /* Detect first run of a vcpu */ -- 1.8.2.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL] KVM/arm64 fixes for 3.11 2013-08-09 13:13 [PULL] KVM/arm64 fixes for 3.11 Marc Zyngier ` (2 preceding siblings ...) 2013-08-09 13:13 ` [PATCH 3/3] arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h Marc Zyngier @ 2013-08-19 20:55 ` Paolo Bonzini 3 siblings, 0 replies; 5+ messages in thread From: Paolo Bonzini @ 2013-08-19 20:55 UTC (permalink / raw) To: Marc Zyngier; +Cc: gleb, kvm, kvmarm, catalin.marinas, will.deacon Il 09/08/2013 15:13, Marc Zyngier ha scritto: > Paolo, Gleb, > > Please consider pulling the following to get a new fixes for KVM/arm64. > > Thanks, > > M. > > The following changes since commit c095ba7224d8edc71dcef0d655911399a8bd4a3f: > > Linux 3.11-rc4 (2013-08-04 13:46:46 -0700) > > are available in the git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git kvm-arm64/fixes-3.11-rc4 > > for you to fetch changes up to 6c8c0c4dc0e98ee2191211d66e9f876e95787073: > > arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h. (2013-08-09 13:42:43 +0100) > > ---------------------------------------------------------------- > Chen Gang (1): > arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h. > > Marc Zyngier (2): > arm64: KVM: perform save/restore of PAR_EL1 > arm64: KVM: add missing dsb before invalidating Stage-2 TLBs > > arch/arm64/include/asm/kvm_asm.h | 17 ++++++++++------- > arch/arm64/include/asm/kvm_host.h | 2 +- > arch/arm64/kvm/hyp.S | 13 +++++++++++++ > arch/arm64/kvm/sys_regs.c | 3 +++ > 4 files changed, 27 insertions(+), 8 deletions(-) > > Chen Gang (1): > arm64: KVM: use 'int' instead of 'u32' for variable 'target' in > kvm_host.h. > > Marc Zyngier (2): > arm64: KVM: perform save/restore of PAR_EL1 > arm64: KVM: add missing dsb before invalidating Stage-2 TLBs > > arch/arm64/include/asm/kvm_asm.h | 17 ++++++++++------- > arch/arm64/include/asm/kvm_host.h | 2 +- > arch/arm64/kvm/hyp.S | 13 +++++++++++++ > arch/arm64/kvm/sys_regs.c | 3 +++ > 4 files changed, 27 insertions(+), 8 deletions(-) > Thanks, pulled and sent to Linus. Paolo ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-19 20:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-08-09 13:13 [PULL] KVM/arm64 fixes for 3.11 Marc Zyngier 2013-08-09 13:13 ` [PATCH 1/3] arm64: KVM: perform save/restore of PAR_EL1 Marc Zyngier 2013-08-09 13:13 ` [PATCH 2/3] arm64: KVM: add missing dsb before invalidating Stage-2 TLBs Marc Zyngier 2013-08-09 13:13 ` [PATCH 3/3] arm64: KVM: use 'int' instead of 'u32' for variable 'target' in kvm_host.h Marc Zyngier 2013-08-19 20:55 ` [PULL] KVM/arm64 fixes for 3.11 Paolo Bonzini
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.