Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-09 Thread Tamas K Lengyel
On Mon, Sep 5, 2016 at 1:45 PM, Stefano Stabellini
 wrote:
> On Fri, 2 Sep 2016, Julien Grall wrote:
>> On 02/09/2016 18:45, Andrew Cooper wrote:
>> > On 02/09/16 18:37, Tamas K Lengyel wrote:
>> > > On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
>> > >  wrote:
>> > > > On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
>> > > > > Add support for getting/setting registers through vm_event on ARM.
>> > > > > Only
>> > > > > TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC 
>> > > > > is
>> > > > > set
>> > > > > as part of a response. The set of registers can be expanded in the
>> > > > > future to
>> > > > > include other registers as well if necessary.
>> > > > >
>> > > > > Signed-off-by: Tamas K Lengyel 
>> > > > > Reviewed-by: Andrew Cooper 
>> > > > Acked-by: Razvan Cojocaru 
>> > > Patch ping.
>> >
>> > Requires an ARM ack.
>>
>> I don't think it requires an ack from Stefano and I, it touches only the
>> vm_event subsystem.
>>
>> If you still want an ARM ack, then I will defer to Stefano.
>
> Acked-by: Stefano Stabellini 

Thanks! I think this is ready for merging.

Tamas

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-05 Thread Stefano Stabellini
On Fri, 2 Sep 2016, Julien Grall wrote:
> On 02/09/2016 18:45, Andrew Cooper wrote:
> > On 02/09/16 18:37, Tamas K Lengyel wrote:
> > > On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
> > >  wrote:
> > > > On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
> > > > > Add support for getting/setting registers through vm_event on ARM.
> > > > > Only
> > > > > TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is
> > > > > set
> > > > > as part of a response. The set of registers can be expanded in the
> > > > > future to
> > > > > include other registers as well if necessary.
> > > > > 
> > > > > Signed-off-by: Tamas K Lengyel 
> > > > > Reviewed-by: Andrew Cooper 
> > > > Acked-by: Razvan Cojocaru 
> > > Patch ping.
> > 
> > Requires an ARM ack.
> 
> I don't think it requires an ack from Stefano and I, it touches only the
> vm_event subsystem.
> 
> If you still want an ARM ack, then I will defer to Stefano.

Acked-by: Stefano Stabellini 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Tamas K Lengyel
On Fri, Sep 2, 2016 at 1:10 PM, Julien Grall  wrote:
>
>
> On 02/09/2016 19:47, Tamas K Lengyel wrote:
>>
>> On Fri, Sep 2, 2016 at 12:40 PM, Julien Grall 
>> wrote:
>>>
>>> On 02/09/2016 18:45, Andrew Cooper wrote:


 On 02/09/16 18:37, Tamas K Lengyel wrote:
>
>
> On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
>  wrote:
>>
>>
>> On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
>>>
>>>
>>> Add support for getting/setting registers through vm_event on ARM.
>>> Only
>>> TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC
>>> is
>>> set
>>> as part of a response. The set of registers can be expanded in the
>>> future to
>>> include other registers as well if necessary.
>>>
>>> Signed-off-by: Tamas K Lengyel 
>>> Reviewed-by: Andrew Cooper 
>>
>>
>> Acked-by: Razvan Cojocaru 
>
>
> Patch ping.



 Requires an ARM ack.
>>>
>>>
>>>
>>> I don't think it requires an ack from Stefano and I, it touches only the
>>> vm_event subsystem.
>>>
>>> If you still want an ARM ack, then I will defer to Stefano.
>>
>>
>> Indeed it only touches the vm_event system so just wanted to double
>> check it's OK from your side as we had lengthy discussion about it. If
>> there are no objections a formal ack should not be necessary and it's
>> good to go.
>
>
> My objections are still there. Hence why I said I will defer to Stefano.

Fair enough.

Thanks,
Tamas

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Julien Grall



On 02/09/2016 19:47, Tamas K Lengyel wrote:

On Fri, Sep 2, 2016 at 12:40 PM, Julien Grall  wrote:

On 02/09/2016 18:45, Andrew Cooper wrote:


On 02/09/16 18:37, Tamas K Lengyel wrote:


On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
 wrote:


On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:


Add support for getting/setting registers through vm_event on ARM. Only
TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is
set
as part of a response. The set of registers can be expanded in the
future to
include other registers as well if necessary.

Signed-off-by: Tamas K Lengyel 
Reviewed-by: Andrew Cooper 


Acked-by: Razvan Cojocaru 


Patch ping.



Requires an ARM ack.



I don't think it requires an ack from Stefano and I, it touches only the
vm_event subsystem.

If you still want an ARM ack, then I will defer to Stefano.


Indeed it only touches the vm_event system so just wanted to double
check it's OK from your side as we had lengthy discussion about it. If
there are no objections a formal ack should not be necessary and it's
good to go.


My objections are still there. Hence why I said I will defer to Stefano.

Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Tamas K Lengyel
On Fri, Sep 2, 2016 at 12:40 PM, Julien Grall  wrote:
> On 02/09/2016 18:45, Andrew Cooper wrote:
>>
>> On 02/09/16 18:37, Tamas K Lengyel wrote:
>>>
>>> On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
>>>  wrote:

 On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
>
> Add support for getting/setting registers through vm_event on ARM. Only
> TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is
> set
> as part of a response. The set of registers can be expanded in the
> future to
> include other registers as well if necessary.
>
> Signed-off-by: Tamas K Lengyel 
> Reviewed-by: Andrew Cooper 

 Acked-by: Razvan Cojocaru 
>>>
>>> Patch ping.
>>
>>
>> Requires an ARM ack.
>
>
> I don't think it requires an ack from Stefano and I, it touches only the
> vm_event subsystem.
>
> If you still want an ARM ack, then I will defer to Stefano.

Indeed it only touches the vm_event system so just wanted to double
check it's OK from your side as we had lengthy discussion about it. If
there are no objections a formal ack should not be necessary and it's
good to go.

Thanks,
Tamas

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Julien Grall

On 02/09/2016 18:45, Andrew Cooper wrote:

On 02/09/16 18:37, Tamas K Lengyel wrote:

On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
 wrote:

On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:

Add support for getting/setting registers through vm_event on ARM. Only
TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is set
as part of a response. The set of registers can be expanded in the future to
include other registers as well if necessary.

Signed-off-by: Tamas K Lengyel 
Reviewed-by: Andrew Cooper 

Acked-by: Razvan Cojocaru 

Patch ping.


Requires an ARM ack.


I don't think it requires an ack from Stefano and I, it touches only the 
vm_event subsystem.


If you still want an ARM ack, then I will defer to Stefano.

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Andrew Cooper
On 02/09/16 18:37, Tamas K Lengyel wrote:
> On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
>  wrote:
>> On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
>>> Add support for getting/setting registers through vm_event on ARM. Only
>>> TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is set
>>> as part of a response. The set of registers can be expanded in the future to
>>> include other registers as well if necessary.
>>>
>>> Signed-off-by: Tamas K Lengyel 
>>> Reviewed-by: Andrew Cooper 
>> Acked-by: Razvan Cojocaru 
> Patch ping.

Requires an ARM ack.

~Andrew

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-09-02 Thread Tamas K Lengyel
On Tue, Aug 2, 2016 at 2:10 AM, Razvan Cojocaru
 wrote:
> On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
>> Add support for getting/setting registers through vm_event on ARM. Only
>> TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is set
>> as part of a response. The set of registers can be expanded in the future to
>> include other registers as well if necessary.
>>
>> Signed-off-by: Tamas K Lengyel 
>> Reviewed-by: Andrew Cooper 
>
> Acked-by: Razvan Cojocaru 

Patch ping.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-08-02 Thread Razvan Cojocaru
On 08/01/2016 08:59 PM, Tamas K Lengyel wrote:
> Add support for getting/setting registers through vm_event on ARM. Only
> TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is set
> as part of a response. The set of registers can be expanded in the future to
> include other registers as well if necessary.
> 
> Signed-off-by: Tamas K Lengyel 
> Reviewed-by: Andrew Cooper 

Acked-by: Razvan Cojocaru 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2] arm/vm_event: get/set registers

2016-08-01 Thread Tamas K Lengyel
Add support for getting/setting registers through vm_event on ARM. Only
TTB/CR/R0/R1, PC and CPSR are sent as part of a request and only PC is set
as part of a response. The set of registers can be expanded in the future to
include other registers as well if necessary.

Signed-off-by: Tamas K Lengyel 
Reviewed-by: Andrew Cooper 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
Cc: Razvan Cojocaru 
Cc: Jan Beulich 

v2: Add assert for vCPU pause check
Use correct regs pointer on setting registers
Only set the register 'pc'
---
 xen/arch/arm/Makefile  |  1 +
 xen/arch/arm/vm_event.c| 52 ++
 xen/include/asm-arm/vm_event.h | 11 -
 xen/include/asm-x86/vm_event.h |  4 
 xen/include/public/vm_event.h  | 18 +--
 xen/include/xen/vm_event.h |  3 +++
 6 files changed, 72 insertions(+), 17 deletions(-)
 create mode 100644 xen/arch/arm/vm_event.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index b264ed4..5752830 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -41,6 +41,7 @@ obj-y += traps.o
 obj-y += vgic.o
 obj-y += vgic-v2.o
 obj-$(CONFIG_ARM_64) += vgic-v3.o
+obj-y += vm_event.o
 obj-y += vtimer.o
 obj-y += vpsci.o
 obj-y += vuart.o
diff --git a/xen/arch/arm/vm_event.c b/xen/arch/arm/vm_event.c
new file mode 100644
index 000..47312e9
--- /dev/null
+++ b/xen/arch/arm/vm_event.c
@@ -0,0 +1,52 @@
+/*
+ * arch/arm/vm_event.c
+ *
+ * Architecture-specific vm_event handling routines
+ *
+ * Copyright (c) 2016 Tamas K Lengyel (tamas.leng...@zentific.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 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 .
+ */
+
+#include 
+#include 
+
+void vm_event_fill_regs(vm_event_request_t *req)
+{
+const struct cpu_user_regs *regs = guest_cpu_user_regs();
+
+req->data.regs.arm.cpsr = regs->cpsr;
+req->data.regs.arm.pc = regs->pc;
+req->data.regs.arm.ttbcr = READ_SYSREG(TCR_EL1);
+req->data.regs.arm.ttbr0 = READ_SYSREG64(TTBR0_EL1);
+req->data.regs.arm.ttbr1 = READ_SYSREG64(TTBR1_EL1);
+}
+
+void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp)
+{
+struct cpu_user_regs *regs = >arch.cpu_info->guest_cpu_user_regs;
+
+/* vCPU should be paused */
+ASSERT(atomic_read(>vm_event_pause_count));
+
+regs->pc = rsp->data.regs.arm.pc;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-arm/vm_event.h b/xen/include/asm-arm/vm_event.h
index ccc4b60..9482636 100644
--- a/xen/include/asm-arm/vm_event.h
+++ b/xen/include/asm-arm/vm_event.h
@@ -45,15 +45,4 @@ void vm_event_register_write_resume(struct vcpu *v, 
vm_event_response_t *rsp)
 /* Not supported on ARM. */
 }
 
-static inline
-void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp)
-{
-/* Not supported on ARM. */
-}
-
-static inline void vm_event_fill_regs(vm_event_request_t *req)
-{
-/* Not supported on ARM. */
-}
-
 #endif /* __ASM_ARM_VM_EVENT_H__ */
diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h
index 7e6adff..294def6 100644
--- a/xen/include/asm-x86/vm_event.h
+++ b/xen/include/asm-x86/vm_event.h
@@ -39,8 +39,4 @@ void vm_event_toggle_singlestep(struct domain *d, struct vcpu 
*v);
 
 void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp);
 
-void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp);
-
-void vm_event_fill_regs(vm_event_request_t *req);
-
 #endif /* __ASM_X86_VM_EVENT_H__ */
diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h
index 64e6857..32cd4d7 100644
--- a/xen/include/public/vm_event.h
+++ b/xen/include/public/vm_event.h
@@ -132,8 +132,8 @@
 #define VM_EVENT_X86_XCR0   3
 
 /*
- * Using a custom struct (not hvm_hw_cpu) so as to not fill
- * the vm_event ring buffer too quickly.
+ * Using custom vCPU structs (i.e. not hvm_hw_cpu) for both x86 and ARM
+ * so as to not fill the vm_event ring buffer too quickly.
  */
 struct vm_event_regs_x86 {
 uint64_t rax;
@@ -172,6 +172,19 @@ struct vm_event_regs_x86 {
 };
 
 /*
+ * Only the register 'pc' can be set on a vm_event response using the
+ * VM_EVENT_FLAG_SET_REGISTERS flag.
+ */
+struct vm_event_regs_arm {
+uint64_t ttbr0;
+uint64_t ttbr1;
+