Re: [PATCH] KVM: arm64: add esr_el2 and far_el2 to sysreg

2017-08-08 Thread gengdongjiu
Hi James, On 2017/8/9 0:27, James Morse wrote: > Hi gengdongjiu, > > On 07/08/17 18:43, gengdongjiu wrote: >> Another question, For the SEI, I want to also use SIGBUS both for the KVM >> user and non-kvm user, >> if SEA and SEI Error all use the SIGBUS to notify user space(Qemu), > > User-space

Re: [PATCH 01/11] KVM: arm64: Store vcpu on the stack during __guest_enter()

2017-08-08 Thread James Morse
Hi Christoffer, On 06/06/17 20:59, Christoffer Dall wrote: > On Mon, May 15, 2017 at 06:43:49PM +0100, James Morse wrote: >> KVM uses tpidr_el2 as its private vcpu register, which makes sense for >> non-vhe world switch as only KVM can access this register. This means >> vhe Linux has to use tpidr

Re: [PATCH 07/11] firmware: arm_sdei: Add driver for Software Delegated Exceptions

2017-08-08 Thread James Morse
Hi Dave, On 19/07/17 14:52, Dave Martin wrote: > On Mon, May 15, 2017 at 06:43:55PM +0100, James Morse wrote: >> The Software Delegated Exception Interface (SDEI) is an ARM standard >> for registering callbacks from the platform firmware into the OS. >> This is typically used to implement RAS noti

[PATCH v2 11/11] KVM: arm64: Allow user-space to claim guest SMC-CC ranges for SDEI

2017-08-08 Thread James Morse
Instead of supporting SDEI in KVM, and providing a new API to control and configure the in-kernel support, allow user-space to request particular SMC-CC ranges from guest HVC calls to be handled by user-space. This requires two KVM capabilities, KVM_CAP_ARM_SDEI_1_0 advertises that KVM knows how m

[PATCH v2 10/11] firmware: arm_sdei: add support for CPU private events

2017-08-08 Thread James Morse
Private SDE events are per-cpu, and need to be registered and enabled on each CPU. Hide this detail from the caller by adapting our {,un}register and {en,dis}able calls to send an IPI to each CPU if the event is private. CPU private events are unregistered when the CPU is powered-off, and re-regi

[PATCH v2 07/11] firmware: arm_sdei: Add driver for Software Delegated Exceptions

2017-08-08 Thread James Morse
The Software Delegated Exception Interface (SDEI) is an ARM standard for registering callbacks from the platform firmware into the OS. This is typically used to implement firmware notifications (such as firmware-first RAS) or promote an IRQ that has been promoted to a firmware-assisted NMI. Add th

[PATCH v2 09/11] firmware: arm_sdei: Add support for CPU and system power states

2017-08-08 Thread James Morse
When a CPU enters an idle lower-power state or is powering off, we need to mask SDE events so that no events can be delivered while we are messing with the MMU as the registered entry points won't be valid. If the system reboots, we want to unregister all events and mask the CPUs. For kexec this a

[PATCH v2 08/11] arm64: kernel: Add arch-specific SDEI entry code and CPU masking

2017-08-08 Thread James Morse
The Software Delegated Exception Interface (SDEI) is an ARM standard for registering callbacks from the platform firmware into the OS. This is typically used to implement RAS notifications. Such notifications enter the kernel at the registered entry-point with the register values of the interrupte

[PATCH v2 01/11] KVM: arm64: Store vcpu on the stack during __guest_enter()

2017-08-08 Thread James Morse
KVM uses tpidr_el2 as its private vcpu register, which makes sense for non-vhe world switch as only KVM can access this register. This means vhe Linux has to use tpidr_el1, which KVM has to save/restore as part of the host context. __guest_enter() stores the host_ctxt on the stack, do the same wit

[PATCH v2 04/11] arm64: alternatives: use tpidr_el2 on VHE hosts

2017-08-08 Thread James Morse
Now that KVM uses tpidr_el2 in the same way as Linux's cpu_offset in tpidr_el1, merge the two. This saves KVM from save/restoring tpidr_el1 on VHE hosts, and allows future code to blindly access per-cpu variables without triggering world-switch. Signed-off-by: James Morse --- Changes since v1: *

[PATCH v2 05/11] KVM: arm64: Stop save/restoring host tpidr_el1 on VHE

2017-08-08 Thread James Morse
Now that a VHE host uses tpidr_el2 for the cpu offset we no longer need KVM to save/restore tpidr_el1. Move this from the 'common' code into the non-vhe code. While we're at it, on VHE we don't need to save the ELR or SPSR as kernel_entry in entry.S will have pushed these onto the kernel stack, and

[PATCH v2 06/11] Docs: dt: add devicetree binding for describing arm64 SDEI firmware

2017-08-08 Thread James Morse
The Software Delegated Exception Interface (SDEI) is an ARM standard for registering callbacks from the platform firmware into the OS. This is typically used to implement RAS notifications, or from an IRQ that has been promoted to a firmware-assisted NMI. Add a new devicetree binding to describe t

[PATCH v2 03/11] KVM: arm64: Change hyp_panic()s dependency on tpidr_el2

2017-08-08 Thread James Morse
Make tpidr_el2 a cpu-offset for per-cpu variables in the same way the host uses tpidr_el1. This lets tpidr_el{1,2} have the same value, and on VHE they can be the same register. KVM calls hyp_panic() when anything unexpected happens. This may occur while a guest owns the EL1 registers. KVM stashes

[PATCH v2 02/11] KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation

2017-08-08 Thread James Morse
kvm_host_cpu_state is a per-cpu allocation made from kvm_arch_init() used to store the host EL1 registers when KVM switches to a guest. Make it easier for ASM to generate pointers into this per-cpu memory by making it a static allocation. Signed-off-by: James Morse Acked-by: Christoffer Dall --

[PATCH v2 00/11] arm64/firmware: Software Delegated Exception Interface

2017-08-08 Thread James Morse
Hello! The Software Delegated Exception Interface (SDEI) is an ARM specification for registering callbacks from the platform firmware into the OS. This is intended to be used to implement firmware-first RAS notifications, but also supports vendor-defined events and binding IRQs as events. The doc

Re: [PATCH] KVM: arm64: add esr_el2 and far_el2 to sysreg

2017-08-08 Thread James Morse
Hi gengdongjiu, On 07/08/17 18:43, gengdongjiu wrote: > Another question, For the SEI, I want to also use SIGBUS both for the KVM > user and non-kvm user, > if SEA and SEI Error all use the SIGBUS to notify user space(Qemu), User-space shouldn't necessarily be notified about Synchronous External

Re: [PATCH 01/15] ARM: assembler: introduce adr_l, ldr_l and str_l macros

2017-08-08 Thread Nicolas Pitre
On Tue, 8 Aug 2017, Ard Biesheuvel wrote: > On 8 August 2017 at 16:10, Nicolas Pitre wrote: > > On Sat, 5 Aug 2017, Ard Biesheuvel wrote: > > > >> Like arm64, ARM supports position independent code sequences that > >> produce symbol references with a greater reach than the ordinary > >> adr/ldr i

Re: [PATCH 01/15] ARM: assembler: introduce adr_l, ldr_l and str_l macros

2017-08-08 Thread Ard Biesheuvel
On 8 August 2017 at 16:10, Nicolas Pitre wrote: > On Sat, 5 Aug 2017, Ard Biesheuvel wrote: > >> Like arm64, ARM supports position independent code sequences that >> produce symbol references with a greater reach than the ordinary >> adr/ldr instructions. >> >> Currently, we use open coded instruc

Re: [PATCH 01/15] ARM: assembler: introduce adr_l, ldr_l and str_l macros

2017-08-08 Thread Nicolas Pitre
On Sat, 5 Aug 2017, Ard Biesheuvel wrote: > Like arm64, ARM supports position independent code sequences that > produce symbol references with a greater reach than the ordinary > adr/ldr instructions. > > Currently, we use open coded instruction sequences involving literals > and arithmetic opera

Re: [PATCH v2 3/4] kvm: arm/arm64: vgic-v3: add ICH_AP[01]Rn accessors for GICv3

2017-08-08 Thread Marc Zyngier
On 08/08/17 14:01, wanghaibin wrote: > On 2017/7/25 19:25, Marc Zyngier wrote: > >> On Mon, Jul 17 2017 at 6:23:31 pm BST, wanghaibin >> wrote: >>> This patch is used for GICv2 on GICv3. >>> >>> About GICV_APRn hardware register access,the SPEC says: >>> When System register access is enabled f

Re: [PATCH v2 0/4] kvm: arm/arm64: vgic: APRn uaccess support.

2017-08-08 Thread wanghaibin
On 2017/7/21 21:27, Christoffer Dall wrote: > Hi Wanghaibin, > > On Mon, Jul 17, 2017 at 06:23:28PM +0800, wanghaibin wrote: >> v2: Split the patch again to make it easier for review >> some fixes were proposed by Marc >> >> v1: the problem describe: >> https://lists.cs.columbia.edu/pipermail

Re: [PATCH v2 3/4] kvm: arm/arm64: vgic-v3: add ICH_AP[01]Rn accessors for GICv3

2017-08-08 Thread wanghaibin
On 2017/7/25 19:25, Marc Zyngier wrote: > On Mon, Jul 17 2017 at 6:23:31 pm BST, wanghaibin > wrote: >> This patch is used for GICv2 on GICv3. >> >> About GICV_APRn hardware register access,the SPEC says: >> When System register access is enabled for EL2, these registers access >> ICH_AP1Rn_EL2

Re: [PATCH] arm64: KVM: Reject non-compliant HVC calls from guest kernel

2017-08-08 Thread Marc Zyngier
On 08/08/17 08:36, Christoffer Dall wrote: > Hi Shanker, > > On Mon, Aug 07, 2017 at 02:03:28PM -0500, Shanker Donthineni wrote: >> The SMC/HVC instructions with an immediate value non-zero are not compliant >> according to 'SMC calling convention system software document'. Add a >> validation che

Re: [PATCH] arm64: KVM: Reject non-compliant HVC calls from guest kernel

2017-08-08 Thread Christoffer Dall
Hi Shanker, On Mon, Aug 07, 2017 at 02:03:28PM -0500, Shanker Donthineni wrote: > The SMC/HVC instructions with an immediate value non-zero are not compliant > according to 'SMC calling convention system software document'. Add a > validation check in handle_hvc() to avoid malicious HVC calls from