[Xen-devel] [PATCH 3/3] Convert map_domain_page() to use the new mfn_t type

2015-07-01 Thread Ben Catterall
Reworked the internals and declaration, applying (un)boxing where needed. Converted calls to map_domain_page() to provide mfn_t types, boxing where needed. Signed-off-by: Ben Catterall ben.catter...@citrix.com --- xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/kernel.c

[Xen-devel] [PATCH 2/3] xen/domain_page: Convert copy/clear_domain_page() to using mfn_t

2015-07-01 Thread Ben Catterall
From: Andrew Cooper andrew.coop...@citrix.com Signed-off-by: Andrew Cooper andrew.coop...@citrix.com [Convert grant_table.c to pass mfn_t types and fix ARM compiling] Signed-off-by: Ben Catterall ben.catter...@citrix.com --- xen/arch/x86/mm.c | 7 --- xen/common/grant_table.c

[Xen-devel] [PATCH 1/3] xen/domain_page: Convert map_domain_page_global() to using mfn_t

2015-07-01 Thread Ben Catterall
From: Andrew Cooper andrew.coop...@citrix.com The sh_map/unmap wrappers can be dropped, and take the opportunity to turn some #define's into static inlines, for added type saftey. As part of adding the type safety, GCC highlights an problematic include cycle with arm/mm.h including domain_page.h

[Xen-devel] [PATCH 0/3]

2015-07-01 Thread Ben Catterall
Converting map_domain_page() to use the mfn_t type and (un)boxing where needed. This follows on from Andrew Cooper's similar work on copy/clear_domain_page(). ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel

[Xen-devel] [PATCH v2 1/3] xen/domain_page: Convert map_domain_page_global() to using mfn_t

2015-07-02 Thread Ben Catterall
From: Andrew Cooper andrew.coop...@citrix.com The sh_map/unmap wrappers can be dropped, and take the opportunity to turn some #define's into static inlines, for added type saftey. As part of adding the type safety, GCC highlights an problematic include cycle with arm/mm.h including domain_page.h

[Xen-devel] [PATCH] Remove sh_{un}map_domain_page() and hap_{un}map_domain_page()

2015-07-02 Thread Ben Catterall
Removed as they were wrappers around map_domain_page() to make it appear to take an mfn_t type. Signed-off-by: Ben Catterall ben.catter...@citrix.com --- xen/arch/x86/mm/hap/hap.c| 4 +- xen/arch/x86/mm/shadow/common.c | 22 +++--- xen/arch/x86/mm/shadow/multi.c | 152

[Xen-devel] [PATCH v2 3/3] Convert map_domain_page() to use the new mfn_t type

2015-07-02 Thread Ben Catterall
Reworked the internals and declaration, applying (un)boxing where needed. Converted calls to map_domain_page() to provide mfn_t types, boxing where needed. Signed-off-by: Ben Catterall ben.catter...@citrix.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com --- Changed since v1

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-18 Thread Ben Catterall
On 18/08/15 11:25, Ben Catterall wrote: On 17/08/15 16:17, Jan Beulich wrote: On 17.08.15 at 17:07, t...@xen.org wrote: At 14:53 +0100 on 17 Aug (1439823232), Ben Catterall wrote: So, have we arrived at a decision for this? Thanks! Seems to have stalled a bit. OK, I propose

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-18 Thread Ben Catterall
On 17/08/15 16:17, Jan Beulich wrote: On 17.08.15 at 17:07, t...@xen.org wrote: At 14:53 +0100 on 17 Aug (1439823232), Ben Catterall wrote: So, have we arrived at a decision for this? Thanks! Seems to have stalled a bit. OK, I propose that: - we use TR/IST to make Xen take interrupts

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-17 Thread Ben Catterall
On 12/08/15 14:33, Andrew Cooper wrote: On 12/08/15 14:29, Andrew Cooper wrote: On 11/08/15 19:29, Boris Ostrovsky wrote: On 08/11/2015 01:19 PM, Andrew Cooper wrote: On 11/08/15 18:05, Tim Deegan wrote: * Under this model, PV exception handlers should copy themselves onto the privileged

Re: [Xen-devel] [RFC 4/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-08-17 Thread Ben Catterall
On 11/08/15 11:33, Ben Catterall wrote: On 10/08/15 11:07, Tim Deegan wrote: Hi, @@ -685,8 +685,17 @@ static int hap_page_fault(struct vcpu *v, unsigned long va, { struct domain *d = v-domain; +/* If we get a page fault whilst in HVM security user mode */ +if( v-user_mode

[Xen-devel] HVM x86 deprivileged mode: AMD SVM TR problem

2015-08-19 Thread Ben Catterall
Hi all, I've hit a blocker on getting this working for AMD's SVM and would appreciate any thoughts. Hopefully I've missed a much simpler way of doing this or I've missed something! So, AMD and Intel differ in how they handle the TR on a VMEXIT and VMRUM. On a VMEXIT, Intel Save the guest's

Re: [Xen-devel] HVM x86 deprivileged mode: AMD SVM TR problem

2015-08-19 Thread Ben Catterall
On 19/08/15 16:43, Tim Deegan wrote: At 16:04 +0100 on 19 Aug (144260), Ben Catterall wrote: I've hit a blocker on getting this working for AMD's SVM and would appreciate any thoughts. Hopefully I've missed a much simpler way of doing this or I've missed something! So, AMD and Intel

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-19 Thread Ben Catterall
On 18/08/15 17:55, Andrew Cooper wrote: On 17/08/15 08:07, Tim Deegan wrote: At 14:53 +0100 on 17 Aug (1439823232), Ben Catterall wrote: On 12/08/15 14:33, Andrew Cooper wrote: On 12/08/15 14:29, Andrew Cooper wrote: On 11/08/15 19:29, Boris Ostrovsky wrote: Would switching TR only when

Re: [Xen-devel] HVM x86 deprivileged mode: AMD SVM TR problem

2015-08-20 Thread Ben Catterall
On 20/08/15 10:34, Tim Deegan wrote: At 17:36 +0100 on 19 Aug (1440005801), Ben Catterall wrote: On 19/08/15 16:43, Tim Deegan wrote: At 16:04 +0100 on 19 Aug (144260), Ben Catterall wrote: I've hit a blocker on getting this working for AMD's SVM and would appreciate any thoughts

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-20 Thread Ben Catterall
On 10/08/15 11:14, Andrew Cooper wrote: On 10/08/15 10:49, Tim Deegan wrote: Hi, At 17:45 +0100 on 06 Aug (1438883118), Ben Catterall wrote: The process to switch into and out of deprivileged mode can be likened to setjmp/longjmp. To enter deprivileged mode, we take a copy of the stack

Re: [Xen-devel] [RFC 2/4] HVM x86 deprivileged mode: Create deprivileged page tables

2015-08-07 Thread Ben Catterall
On 06/08/15 20:52, Andrew Cooper wrote: On 06/08/15 17:45, Ben Catterall wrote: The paging structure mappings for the deprivileged mode are added to the monitor page table for HVM guests. The entries are generated by walking the page tables and mapping in new pages. If a higher-level page

Re: [Xen-devel] [RFC 4/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-08-07 Thread Ben Catterall
On 07/08/15 14:19, Andrew Cooper wrote: On 07/08/15 13:32, Ben Catterall wrote: On 06/08/15 22:24, Andrew Cooper wrote: On 06/08/2015 17:45, Ben Catterall wrote: Added trap handlers to catch exceptions such as a page fault, general protection fault, etc. These handlers will crash

Re: [Xen-devel] [RFC 4/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-08-11 Thread Ben Catterall
On 10/08/15 11:07, Tim Deegan wrote: Hi, @@ -685,8 +685,17 @@ static int hap_page_fault(struct vcpu *v, unsigned long va, { struct domain *d = v-domain; +/* If we get a page fault whilst in HVM security user mode */ +if( v-user_mode == 1 ) +{ +printk(HVM: #PF

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-11 Thread Ben Catterall
On 10/08/15 10:49, Tim Deegan wrote: Hi, At 17:45 +0100 on 06 Aug (1438883118), Ben Catterall wrote: The process to switch into and out of deprivileged mode can be likened to setjmp/longjmp. To enter deprivileged mode, we take a copy of the stack from the guest's registers up to the current

Re: [Xen-devel] RFC: HVM de-privileged mode scheduling considerations

2015-08-11 Thread Ben Catterall
On 04/08/15 14:46, George Dunlap wrote: On Mon, Aug 3, 2015 at 3:34 PM, Ian Campbell ian.campb...@citrix.com wrote: On Mon, 2015-08-03 at 14:54 +0100, Andrew Cooper wrote: On 03/08/15 14:35, Ben Catterall wrote: Hi all, I am working on an x86 proof-of-concept to evaluate if it is feasible

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-11 Thread Ben Catterall
On 11/08/15 10:55, Tim Deegan wrote: At 11:14 +0100 on 10 Aug (1439205273), Andrew Cooper wrote: On 10/08/15 10:49, Tim Deegan wrote: Hi, At 17:45 +0100 on 06 Aug (1438883118), Ben Catterall wrote: The process to switch into and out of deprivileged mode can be likened to setjmp/longjmp

Re: [Xen-devel] [RFC 1/4] HVM x86 deprivileged mode: Page allocation helper

2015-08-07 Thread Ben Catterall
On 06/08/15 20:22, Andrew Cooper wrote: On 06/08/15 17:45, Ben Catterall wrote: This allocation function is used by the deprivileged mode initialisation code to allocate pages for the new page table mappings and page frames on the HAP page heap. Signed-off-by: Ben Catterall ben.catter

[Xen-devel] [RFC 0/4] HVM x86 enhancements to run Xen deprivileged mode operations

2015-08-06 Thread Ben Catterall
could count the number of quanta which have passed since we failed to migrate, then migrate when it becomes too high. - Add support for SVM and test on AMD processors. - We need to get the host MSRs for AMD SVM mode. Signed-off-by: Ben Catterall ben.catter...@citrix.com

[Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-06 Thread Ben Catterall
on the syscall handler in entry.S has also been added which handles returning from user mode and will support deprivileged mode system calls when these are needed. Signed-off-by: Ben Catterall ben.catter...@citrix.com --- xen/arch/x86/domain.c | 12 +++ xen/arch/x86/hvm/Makefile

[Xen-devel] [RFC 2/4] HVM x86 deprivileged mode: Create deprivileged page tables

2015-08-06 Thread Ben Catterall
accessible, with NX bits set for the data and stack regions and the code region is set to be executable and read-only. The needed pages are allocated on the HAP page heap and are deallocated when those heap pages are deallocated (on domain destruction). Signed-off-by: Ben Catterall ben.catter

[Xen-devel] [RFC 1/4] HVM x86 deprivileged mode: Page allocation helper

2015-08-06 Thread Ben Catterall
This allocation function is used by the deprivileged mode initialisation code to allocate pages for the new page table mappings and page frames on the HAP page heap. Signed-off-by: Ben Catterall ben.catter...@citrix.com --- xen/arch/x86/mm/hap/hap.c| 23 +++ xen/include

[Xen-devel] [RFC 4/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-08-06 Thread Ben Catterall
Added trap handlers to catch exceptions such as a page fault, general protection fault, etc. These handlers will crash the domain as such exceptions would indicate that either there is a bug in deprivileged mode or it has been compromised by an attacker. Signed-off-by: Ben Catterall ben.catter

Re: [Xen-devel] [RFC 4/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-08-07 Thread Ben Catterall
On 06/08/15 22:24, Andrew Cooper wrote: On 06/08/2015 17:45, Ben Catterall wrote: Added trap handlers to catch exceptions such as a page fault, general protection fault, etc. These handlers will crash the domain as such exceptions would indicate that either there is a bug in deprivileged mode

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-07 Thread Ben Catterall
On 06/08/15 21:55, Andrew Cooper wrote: On 06/08/15 17:45, Ben Catterall wrote: The process to switch into and out of deprivileged mode can be likened to setjmp/longjmp. To enter deprivileged mode, we take a copy of the stack from the guest's registers up to the current stack pointer

Re: [Xen-devel] [RFC 0/4] HVM x86 enhancements to run Xen deprivileged mode operations

2015-08-12 Thread Ben Catterall
On 12/08/15 10:50, Jan Beulich wrote: On 06.08.15 at 18:45, ben.catter...@citrix.com wrote: Performance testing --- Performance testing indicates that the overhead for this deprivileged mode is approximately 25%. This overhead is the cost of moving into deprivileged mode and

Re: [Xen-devel] [RFC 3/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-08-12 Thread Ben Catterall
On 11/08/15 18:05, Tim Deegan wrote: Hi, At 17:51 +0100 on 11 Aug (1439315508), Ben Catterall wrote: On 11/08/15 10:55, Tim Deegan wrote: At 11:14 +0100 on 10 Aug (1439205273), Andrew Cooper wrote: On 10/08/15 10:49, Tim Deegan wrote: Hi, At 17:45 +0100 on 06 Aug (1438883118), Ben

Re: [Xen-devel] RFC on deprivileged x86 hypervisor device models

2015-07-17 Thread Ben Catterall
On 17/07/15 15:20, Jan Beulich wrote: On 17.07.15 at 12:09, ben.catter...@citrix.com wrote: Moving between privilege levels The general process is to determine if we need to run a device model (or similar) and then, if so, switch into deprivileged mode. The

[Xen-devel] RFC on deprivileged x86 hypervisor device models

2015-07-17 Thread Ben Catterall
Hi all, I'm working on an x86 proof-of-concept series to evaluate if it is feasible to move device models currently running in the hypervisor and x86 emulation code for HVM guests into a deprivileged context. I've put together the following document as I have been considering several

Re: [Xen-devel] RFC on deprivileged x86 hypervisor device models

2015-07-20 Thread Ben Catterall
On 20/07/15 14:58, Jan Beulich wrote: On 20.07.15 at 15:43, andrew.coop...@citrix.com wrote: On 17/07/15 16:38, Jan Beulich wrote: On 17.07.15 at 17:19, ben.catter...@citrix.com wrote: On 17/07/15 15:20, Jan Beulich wrote: If not, then method 2 would seem quite a bit less troublesome than

[Xen-devel] [PATCH v3 3/4] Convert map_domain_page() to use the new mfn_t type

2015-07-09 Thread Ben Catterall
Reworked the internals and declaration, applying (un)boxing where needed. Converted calls to map_domain_page() to provide mfn_t types, boxing where needed. Signed-off-by: Ben Catterall ben.catter...@citrix.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com --- Changed since v1

[Xen-devel] [PATCH v3 1/4] xen/domain_page: Convert map_domain_page_global() to using mfn_t

2015-07-09 Thread Ben Catterall
From: Andrew Cooper andrew.coop...@citrix.com The sh_map/unmap wrappers can be dropped, and take the opportunity to turn some #define's into static inlines, for added type saftey. As part of adding the type safety, GCC highlights an problematic include cycle with arm/mm.h including domain_page.h

[Xen-devel] [PATCH v3 4/4] Remove sh_{un}map_domain_page() and hap_{un}map_domain_page()

2015-07-09 Thread Ben Catterall
Removed as they were wrappers around map_domain_page() to make it appear to take an mfn_t type. Signed-off-by: Ben Catterall ben.catter...@citrix.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com Reviewed-by: Tim Deegan t...@xen.org --- xen/arch/x86/mm/hap/hap.c| 4 +- xen/arch

[Xen-devel] [PATCH v3 2/4] xen/domain_page: Convert copy/clear_domain_page() to using mfn_t

2015-07-09 Thread Ben Catterall
From: Andrew Cooper andrew.coop...@citrix.com Signed-off-by: Andrew Cooper andrew.coop...@citrix.com [Convert grant_table.c to pass mfn_t types and fix ARM compiling] Signed-off-by: Ben Catterall ben.catter...@citrix.com Reviewed-by: Andrew Cooper andrew.coop...@citrix.com Acked-by: Jan Beulich

Re: [Xen-devel] [PATCH v2 3/3] Convert map_domain_page() to use the new mfn_t type

2015-07-09 Thread Ben Catterall
On 07/07/15 11:10, Jan Beulich wrote: On 02.07.15 at 14:04, ben.catter...@citrix.com wrote: Reworked the internals and declaration, applying (un)boxing where needed. Converted calls to map_domain_page() to provide mfn_t types, boxing where needed. Signed-off-by: Ben Catterall ben.catter

[Xen-devel] [PATCH RFC v2 4/4] HVM x86 deprivileged mode: Watchdog for DoS prevention

2015-09-03 Thread Ben Catterall
in future. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> --- xen/arch/x86/hvm/deprivileged.c| 17 + xen/arch/x86/nmi.c | 17 + xen/include/xen/hvm/deprivileged.h | 1 + 3 files changed, 31 insertions(+), 4 deletions(-) diff --git

[Xen-devel] [PATCH RFC v2 1/4] HVM x86 deprivileged mode: Create deprivileged page tables

2015-09-03 Thread Ben Catterall
are mapped in as user mode accessible, with NX bits set for the data and stack regions and the code region is set to be executable and read-only. The needed pages are allocated on the paging heap and are deallocated when those heap pages are deallocated (on domain destruction). Signed-off-by: Ben

[Xen-devel] [PATCH RFC v2 2/4] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-09-03 Thread Ben Catterall
will be transparent to callers. This should allow the feature to be more easily deployed to different parts of Xen. The switch to and from deprivileged mode is performed using sysret and syscall respectively. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> Changed since v1 *

[Xen-devel] [PATCH RFC v2 0/4] HVM x86 deprivileged mode operations

2015-09-03 Thread Ben Catterall
deprvileged mode. So approximately 178% overhead. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel

[Xen-devel] [PATCH RFC v2 3/4] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-09-03 Thread Ben Catterall
in deprivileged mode, we need to restore the host's context so that we do not have guest-defined registers and values in use after this point due to lazy loading of these values in the SVM and VMX implementations. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> Changed si

Re: [Xen-devel] [PATCH RFC v2 0/4] HVM x86 deprivileged mode operations

2015-09-07 Thread Ben Catterall
On 03/09/15 17:15, David Vrabel wrote: On 03/09/15 17:01, Ben Catterall wrote: Intel Intel 2.2GHz Xeon E5-2407 0 processor: 1.55e-06 seconds was the average time for performing the write without the deprivileged code running. 5.75e-06

Re: [Xen-devel] [PATCH RFC v2 0/4] HVM x86 deprivileged mode operations

2015-09-08 Thread Ben Catterall
-by: Ben Catterall <ben.catter...@citrix.com> ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel ___ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.o

[Xen-devel] [PATCH RFC v3 3/6] HVM x86 deprivileged mode: Trap handlers for deprivileged mode

2015-09-11 Thread Ben Catterall
in deprivileged mode, we need to restore the host's context so that we do not have guest-defined registers and values in use after this point due to lazy loading of these values in the SVM and VMX implementations. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> Changed si

[Xen-devel] [PATCH RFC v3 4/6] HVM x86 deprivileged mode: Watchdog for DoS prevention

2015-09-11 Thread Ben Catterall
in future. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> Changed since v2: * Coding style: Added space after if --- xen/arch/x86/hvm/deprivileged.c | 4 xen/arch/x86/nmi.c | 17 + 2 files changed, 21 insertions(+) diff --git a/xen/arch/x

[Xen-devel] [PATCH RFC v3 5/6] HVM x86 deprivileged mode: Syscall and deprivileged operation dispatcher

2015-09-11 Thread Ben Catterall
table to do this, so that, when aliasing, we just need to switch the mfn on the L1 page table, rather than allocating and mapping in a whole new paging hierarchy. Then, we only need to invalidate those L1 page table TLB entries when we exit the mode. Signed-off-by: Ben Catterall <ben.cat

[Xen-devel] [PATCH RFC v3 1/6] HVM x86 deprivileged mode: Create deprivileged page tables

2015-09-11 Thread Ben Catterall
are mapped in as user mode accessible, with NX bits set for the data and stack regions and the code region is set to be executable and read-only. The needed pages are allocated on the paging heap and are deallocated when those heap pages are deallocated (on domain destruction). Signed-off-by: Ben

[Xen-devel] [PATCH RFC v3 2/6] HVM x86 deprivileged mode: Code for switching into/out of deprivileged mode

2015-09-11 Thread Ben Catterall
will be transparent to callers. This should allow the feature to be more easily deployed to different parts of Xen. The switch to and from deprivileged mode is performed using sysret and syscall respectively. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> Changed since v1 *

[Xen-devel] [PATCH RFC v3 6/6] HVM x86 deprivileged mode: Move VPIC to deprivileged mode

2015-09-11 Thread Ben Catterall
when it is mapped in. Signed-off-by: Ben Catterall <ben.catter...@citrix.com> --- xen/arch/x86/hvm/deprivileged.c | 49 +++ xen/arch/x86/hvm/deprivileged_syscall.c | 4 +- xen/arch/x86/hvm/vpic.c | 151 xen/arch/x

[Xen-devel] [PATCH RFC v3 0/6] HVM x86 deprivileged mode summary

2015-09-11 Thread Ben Catterall
Hi all, I have now finished my internship at Citrix and am posting this final version of my RFC series. I would like to express my thanks to all of those who have taken the time to review, comment and discuss this series, as well as to my colleagues who have provided excellent guidance and help.

Re: [Xen-devel] [PATCH RFC v3 0/6] HVM x86 deprivileged mode summary

2015-09-11 Thread Ben Catterall
Hi all, Here are two Python scripts which I have used to collect performance benchmarks for this series. I am putting them here in case they are useful. Ben On 11/09/15 17:08, Ben Catterall wrote: Hi all, I have now finished my internship at Citrix and am posting this final version of my