[Xen-devel] [RFC PATCH 00/15] RFC: SGX virtualization design and draft patches

2017-07-09 Thread Kai Huang
napshot SGX guest by either: - Suspend guest before snapshot (s3-s5). This works for all guests but requires user to manually susppend guest. - Issue an hypercall to destroy guest's EPC in save_vm. This only works for Linux and Windows but doesn't require user interve

[Xen-devel] [PATCH 01/15] xen: x86: expose SGX to HVM domain in CPU featureset

2017-07-09 Thread Kai Huang
, or by PV ENCLS but it is really not necessary at this stage. And currently SGX is only exposed to HAP HVM domain (we can add for shadow in the future). SGX Launch Control is also exposed in CPU featureset for HVM domain. SGX Launch Control depends on SGX. Signed-off-by: Kai Huang --- xen/include

[Xen-devel] [PATCH 06/15] xen: x86: add SGX basic EPC management

2017-07-09 Thread Kai Huang
ll 'struct epc_page' will be in an array which is allocated during SGX initialization. Entire EPC is also mapped to Xen's virtual address so that each EPC page's virtual address can be calculated by base virtual address + offset. Signed-off-by: Kai Huang

[Xen-devel] [PATCH 09/15] xen: vmx: handle SGX related MSRs

2017-07-09 Thread Kai Huang
in guest, vcpu's virtual IA32_SGXLEPUBKEYHASHn will be update to physical MSRs when vcpu is scheduled in. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/sgx.c | 194 + xen/arch/x86/hvm/vmx/vmx.c | 24 + xen/include/asm-x86/cpuf

[Xen-devel] [PATCH 12/15] xen: x86: reset EPC when guest got suspended.

2017-07-09 Thread Kai Huang
EPC is destroyed when power state goes to S3-S5. Emulate this behavior. A new function s3_suspend is added to hvm_function_table for this purpose. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/hvm.c| 3 +++ xen/arch/x86/hvm/vmx/vmx.c| 7 +++ xen/include/asm-x86/hvm/hvm.h | 3

[Xen-devel] [PATCH 03/15] xen: x86: add early stage SGX feature detection

2017-07-09 Thread Kai Huang
scheduling, etc, as well), so currently only one EPC is supported. Dedicated files sgx.c and sgx.h are added (under vmx directory as SGX is Intel specific) for bulk of above SGX detection code detection code, and for further SGX code as well. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vm

[Xen-devel] [PATCH 10/15] xen: vmx: handle ENCLS VMEXIT

2017-07-09 Thread Kai Huang
om L2 guest, we simply inject it to L1, otherwise the ENCLS VMEXIT is unexpected in L0 and we simply crash the domain. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 10 ++ xen/arch/x86/hvm/vmx/vvmx.c| 11 +++ xen/include/asm-x86/hvm/vmx/vmcs.h | 1 + xen/in

[Xen-devel] [PATCH 11/15] xen: vmx: handle VMEXIT from SGX enclave

2017-07-09 Thread Kai Huang
VMX adds new bit to both exit_reason and GUEST_INTERRUPT_STATE to indicate whether VMEXIT happens in Enclave. Several instructions are also invalid or behave differently in enclave according to SDM. This patch handles those cases. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c

[Xen-devel] [PATCH 07/15] xen: x86: add functions to populate and destroy EPC for domain

2017-07-09 Thread Kai Huang
lid. Used when domain goes to S3-S5, or being destroyed. - hvm_destroy_epc # destroy and free domain's EPC. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/sgx.c | 315 + xen/arch/x86/hvm/vmx/vmx.c | 3 + xen/

[Xen-devel] [PATCH 02/15] xen: vmx: detect ENCLS VMEXIT

2017-07-09 Thread Kai Huang
If ENCLS VMEXIT is not present then we cannot support SGX virtualization. This patch detects presence of ENCLS VMEXIT. A Xen boot boolean parameter 'sgx' is also added to manually enable/disable SGX. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 17

[Xen-devel] [PATCH 08/15] xen: x86: add SGX cpuid handling support.

2017-07-09 Thread Kai Huang
e from toolstack via XEN_DOMCTL_set_cpuid, so domain's EPC pages are also populated in XEN_DOMCTL_set_cpuid, after receiving valid EPC base and size. Failure to populate EPC (such as there's no enough free EPC pages) results in domain creation failure by making XEN_DOMCTL_set_cpuid return er

[Xen-devel] [PATCH 04/15] xen: mm: add ioremap_cache

2017-07-09 Thread Kai Huang
Currently Xen only has non-cacheable version of ioremap. Although EPC is reported as reserved memory in e820 but it can be mapped as cacheable. This patch adds ioremap_cache (cacheable version of ioremap). Signed-off-by: Kai Huang --- xen/arch/x86/mm.c | 15 +-- xen/include/xen

[Xen-devel] [PATCH 05/15] xen: p2m: new 'p2m_epc' type for EPC mapping

2017-07-09 Thread Kai Huang
A new 'p2m_epc' type is added for EPC mapping type. Two wrapper functions set_epc_p2m_entry and clear_epc_p2m_entry are also added for further use. Signed-off-by: Kai Huang --- xen/arch/x86/mm/p2m-ept.c | 3 +++ xen/arch/x86/mm/p2m.c | 41

[Xen-devel] [PATCH 14/15] xen: tools: add SGX to applying CPUID policy

2017-07-09 Thread Kai Huang
assed to xc_cpuid_apply_policy. xc_cpuid_apply_policy is extended to support SGX CPUID. If hypervisor doesn't report SGX feature in host type cpufeatureset, then using 'epc' parameter results in domain creation failure as SGX cannot be supported. Signed-off-by: Kai Huang --- tools/libxc/inc

[Xen-devel] [PATCH 13/15] xen: tools: add new 'epc' parameter support

2017-07-09 Thread Kai Huang
fo. EPC base and size are also added to 'xc_dom_image' in order to add EPC to e820 table. EPC base is calculated internally. Signed-off-by: Kai Huang --- tools/libxc/include/xc_dom.h | 4 tools/libxl/libxl_create.c | 9 + tools/libxl/libxl_dom.c | 30

[Xen-devel] [PATCH 15/15] xen: tools: expose EPC in ACPI table

2017-07-09 Thread Kai Huang
On physical machine EPC is exposed in ACPI table via "INT0E0C". Although EPC can be discovered by CPUID but Windows driver requires EPC to be exposed in ACPI table as well. This patch exposes EPC in ACPI table. Signed-off-by: Kai Huang --- tools/firmware/hvmloader/ut

[Xen-devel] [PATCH] x86/vmx: enable PML by default

2015-11-27 Thread Kai Huang
Since PML series were merged (but disabled by default) we have conducted lots of PML tests (live migration, GUI display) and PML has been working fine, therefore turn it on by default. Signed-off-by: Kai Huang Tested-by: Robert Hu Tested-by: Xudong Hao --- In case you might want some specific

Re: [Xen-devel] [PATCH] x86/vmx: enable PML by default

2015-11-27 Thread Kai Huang
On 11/27/2015 04:35 PM, Jan Beulich wrote: On 27.11.15 at 08:57, wrote: Since PML series were merged (but disabled by default) we have conducted lots of PML tests (live migration, GUI display) and PML has been working fine, therefore turn it on by default. Well, I'm not really opposed, but i

[Xen-devel] [PATCH v2] x86/vmx: enable PML by default

2015-11-27 Thread Kai Huang
Since PML series were merged (but disabled by default) we have conducted lots of PML tests (live migration, GUI display) and PML has been working fine, therefore turn it on by default. Document of PML command line is adjusted accordingly as well. Signed-off-by: Kai Huang Tested-by: Robert Hu

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-12 Thread Kai Huang
, Kai Huang wrote: Design == - PML feature is used globally A new Xen boot parameter, say 'opt_enable_pml', will be introduced to control PML feature detection, and PML feature will only be detected if opt_enable_pml = 1. Once PML feature is detected, it will be used for dirty loggi

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-13 Thread Kai Huang
On Thu, Mar 12, 2015 at 7:19 PM, Andrew Cooper wrote: > On 12/03/15 07:36, Kai Huang wrote: >> >>>>> It might also be nice to be able to enable or disable this feature >>>>> with a sysctl call; but that's just a nice-to-have. >>>> This fea

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-23 Thread Kai Huang
On 02/17/2015 06:19 PM, Jan Beulich wrote: On 12.02.15 at 03:39, wrote: On 02/11/2015 07:52 PM, Andrew Cooper wrote: On 11/02/15 08:28, Kai Huang wrote: Design == - PML feature is used globally A new Xen boot parameter, say 'opt_enable_pml', will be introduced to control P

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-24 Thread Kai Huang
On 03/24/2015 03:53 PM, Jan Beulich wrote: On 24.03.15 at 07:42, wrote: On 02/17/2015 06:19 PM, Jan Beulich wrote: On 12.02.15 at 03:39, wrote: On 02/11/2015 07:52 PM, Andrew Cooper wrote: On 11/02/15 08:28, Kai Huang wrote: Design == - PML feature is used globally A new Xen boot

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-24 Thread Kai Huang
On 03/24/2015 04:14 PM, Jan Beulich wrote: On 24.03.15 at 09:06, wrote: On 03/24/2015 03:53 PM, Jan Beulich wrote: The command line option parsing is (and should be) independent of the chosen default anyway, i.e. overrides in either direction should be possible. While the parse_ept_param

[Xen-devel] [PATCH 00/10] PML (Paging Modification Logging) support

2015-03-26 Thread Kai Huang
54fdb3..88a10f1 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -335,7 +335,12 @@ static int analysis_phase(xc_interface *xch, uint32_t domid, struct save_ctx *ct start = llgettimeofday(); +#define PML_TEST +#ifdef PML_TEST +for ( j

[Xen-devel] [PATCH 02/10] VMX: New parameter to control PML enabling

2015-03-26 Thread Kai Huang
A top level EPT parameter "ept=" and a sub boolean "pml_enable" are added to control PML. Other booleans can be further added for any other EPT related features. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c | 32 1 file ch

[Xen-devel] [PATCH 01/10] VMX: Enable EPT A/D bit support

2015-03-26 Thread Kai Huang
PML requires A/D bit support so enable it for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 1 + xen/arch/x86/mm/p2m-ept.c | 8 +++- xen/include/asm-x86/hvm/vmx/vmcs.h | 4 +++- xen/include/asm-x86/hvm/vmx/vmx.h | 5 - 4 files changed, 15

[Xen-devel] [PATCH 03/10] VMX: Add PML definition and feature detection.

2015-03-26 Thread Kai Huang
The patch adds PML definition and feature detection. Note PML won't be detected if PML is disabled from boot parameter. PML is also disabled in construct_vmcs, as it will only be enabled when domain is switched to log dirty mode. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/v

[Xen-devel] [PATCH 07/10] VMX: handle PML enabling in vmx_vcpu_initialise

2015-03-26 Thread Kai Huang
It's possible domain has already been in log-dirty mode when creating vcpu, in which case we should enable PML for this vcpu if PML has been enabled for the domain. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 24 1 file changed, 24 insertions(+)

[Xen-devel] [PATCH 04/10] VMX: New data structure member to support PML

2015-03-26 Thread Kai Huang
;t have to be initialized to zero explicitly as both vcpu and domain structure are zero-ed when they are created. Signed-off-by: Kai Huang --- xen/include/asm-x86/hvm/vmx/vmcs.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm

[Xen-devel] [PATCH 08/10] VMX: disable PML in vmx_vcpu_destroy

2015-03-26 Thread Kai Huang
It's possible domain still remains in log-dirty mode when it is about to be destroyed, in which case we should manually disable PML for it. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 9 + 1 file changed, 9 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen

[Xen-devel] [PATCH 05/10] VMX: add help functions to support PML

2015-03-26 Thread Kai Huang
This patch adds help functions to enable/disable PML, and flush PML buffer for single vcpu and particular domain for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 190 + xen/include/asm-x86/hvm/vmx/vmcs.h | 9 ++ 2 files

[Xen-devel] [PATCH 06/10] VMX: handle PML buffer full VMEXIT

2015-03-26 Thread Kai Huang
We need to flush PML buffer when it's full. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 4 1 file changed, 4 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index e1c55ce..453bcc5 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arc

[Xen-devel] [PATCH 10/10] p2m/ept: Enable PML in p2m-ept for log-dirty.

2015-03-26 Thread Kai Huang
gging, as PML works globally at entire valid EPT table. Signed-off-by: Kai Huang --- xen/arch/x86/mm/hap/hap.c | 15 -- xen/arch/x86/mm/p2m-ept.c | 73 +++ 2 files changed, 80 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/hap/hap.c

[Xen-devel] [PATCH 09/10] log-dirty: Refine common code to support PML

2015-03-26 Thread Kai Huang
switching back to normal mode respectively. Flushing PML buffer callback will be called from paging layer when flushing PML buffer manually. Signed-off-by: Kai Huang --- xen/arch/x86/mm/hap/hap.c | 16 +++- xen/arch/x86/mm/p2m.c | 36

Re: [Xen-devel] [PATCH 00/10] PML (Paging Modification Logging) support

2015-03-29 Thread Kai Huang
On 03/28/2015 05:26 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: Hi all, This patch series adds PML support to Xen. Please kindly help to review it. Overall this looks like a very good series, and it is particularly helpful given the level of commenting. Which platforms is

Re: [Xen-devel] [PATCH 01/10] VMX: Enable EPT A/D bit support

2015-03-29 Thread Kai Huang
On 03/28/2015 04:38 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: PML requires A/D bit support so enable it for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 1 + xen/arch/x86/mm/p2m-ept.c | 8 +++- xen/include/asm-x86/hvm/vmx

Re: [Xen-devel] [PATCH 02/10] VMX: New parameter to control PML enabling

2015-03-29 Thread Kai Huang
On 03/28/2015 04:42 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: A top level EPT parameter "ept=" and a sub boolean "pml_enable" are added to control PML. Other booleans can be further added for any other EPT related features. Signed-off-by: Kai Huang Pl

Re: [Xen-devel] [PATCH 03/10] VMX: Add PML definition and feature detection.

2015-03-29 Thread Kai Huang
On 03/28/2015 04:46 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: The patch adds PML definition and feature detection. Note PML won't be detected if PML is disabled from boot parameter. PML is also disabled in construct_vmcs, as it will only be enabled when domain is swi

Re: [Xen-devel] [PATCH 04/10] VMX: New data structure member to support PML

2015-03-29 Thread Kai Huang
On 03/28/2015 04:48 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: A new 4K page pointer is added to arch_vmx_struct as PML buffer for vcpu. And a new 'status' field is added to vmx_domain to indicate whether PML is enabled for the domain or not. The 'status

Re: [Xen-devel] [PATCH 05/10] VMX: add help functions to support PML

2015-03-29 Thread Kai Huang
On 03/28/2015 05:09 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: This patch adds help functions to enable/disable PML, and flush PML buffer for single vcpu and particular domain for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 190

Re: [Xen-devel] [PATCH 07/10] VMX: handle PML enabling in vmx_vcpu_initialise

2015-03-30 Thread Kai Huang
On 03/28/2015 05:12 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: It's possible domain has already been in log-dirty mode when creating vcpu, in which case we should enable PML for this vcpu if PML has been enabled for the domain. Signed-off-by: Kai Huang --- xen/arc

Re: [Xen-devel] [PATCH 01/10] VMX: Enable EPT A/D bit support

2015-03-30 Thread Kai Huang
On Mon, Mar 30, 2015 at 5:36 PM, Andrew Cooper wrote: > On 30/03/15 07:11, Kai Huang wrote: >> >> >> On 03/28/2015 04:38 AM, Andrew Cooper wrote: >>> On 27/03/15 02:35, Kai Huang wrote: >>>> PML requires A/D bit support so enable it for furth

Re: [Xen-devel] [PATCH 05/10] VMX: add help functions to support PML

2015-03-30 Thread Kai Huang
On Mon, Mar 30, 2015 at 5:54 PM, Andrew Cooper wrote: > On 30/03/15 07:43, Kai Huang wrote: >> >> >> On 03/28/2015 05:09 AM, Andrew Cooper wrote: >>> On 27/03/15 02:35, Kai Huang wrote: >>> >>>> +} >>>> + >>>> +int vmx_vcp

Re: [Xen-devel] [PATCH 02/10] VMX: New parameter to control PML enabling

2015-04-01 Thread Kai Huang
On 03/28/2015 04:42 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: A top level EPT parameter "ept=" and a sub boolean "pml_enable" are added to control PML. Other booleans can be further added for any other EPT related features. Signed-off-by: Kai Huang Pl

Re: [Xen-devel] [PATCH 01/10] VMX: Enable EPT A/D bit support

2015-04-01 Thread Kai Huang
On 03/28/2015 04:38 AM, Andrew Cooper wrote: On 27/03/15 02:35, Kai Huang wrote: PML requires A/D bit support so enable it for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 1 + xen/arch/x86/mm/p2m-ept.c | 8 +++- xen/include/asm-x86/hvm/vmx

Re: [Xen-devel] [PATCH 02/10] VMX: New parameter to control PML enabling

2015-04-02 Thread Kai Huang
On Thu, Apr 2, 2015 at 5:58 PM, Andrew Cooper wrote: > On 02/04/15 06:46, Kai Huang wrote: >> >> >> On 03/28/2015 04:42 AM, Andrew Cooper wrote: >>> On 27/03/15 02:35, Kai Huang wrote: >>>> A top level EPT parameter "ept=" and a sub boolean &g

[Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
Hi all, PML (Page Modification Logging) is a new feature on Intel's Boardwell server platfrom targeted to reduce overhead of dirty logging mechanism. Below is the design for Xen. Would you help to review and give comments? Background == Currently, dirty logging is done via write prote

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/11/2015 09:13 PM, Jan Beulich wrote: On 11.02.15 at 12:52, wrote: On 11/02/15 08:28, Kai Huang wrote: With PML, we don't have to use write protection but just clear D-bit of EPT entry of guest memory to do dirty logging, with an additional PML buffer full VMEXIT for 512 dirty

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/11/2015 07:52 PM, Andrew Cooper wrote: On 11/02/15 08:28, Kai Huang wrote: Hi all, PML (Page Modification Logging) is a new feature on Intel's Boardwell server platfrom targeted to reduce overhead of dirty logging mechanism. Below is the design for Xen. Would you help to review and

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/11/2015 09:06 PM, Jan Beulich wrote: On 11.02.15 at 09:28, wrote: - PML enable/disable for particular Domain PML needs to be enabled (allocate PML buffer, initialize PML index, PML base address, turn PML on VMCS, etc) for all vcpus of the domain, as PML buffer and PML index are per-vcpu

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 10:49 AM, Kai Huang wrote: On 02/11/2015 09:06 PM, Jan Beulich wrote: On 11.02.15 at 09:28, wrote: - PML enable/disable for particular Domain PML needs to be enabled (allocate PML buffer, initialize PML index, PML base address, turn PML on VMCS, etc) for all vcpus of the

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 02:25 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 10:35 AM On 02/11/2015 09:13 PM, Jan Beulich wrote: On 11.02.15 at 12:52, wrote: On 11/02/15 08:28, Kai Huang wrote: With PML, we don't have to use

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 02:54 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 10:39 AM PML needs to be enabled (allocate PML buffer, initialize PML index, PML base address, turn PML on VMCS, etc) for all vcpus of the domain, as PML buffer and

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 03:02 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 10:50 AM - PML buffer flush There are two places we need to flush PML buffer. The first place is PML buffer full VMEXIT handler (apparently), and the second place

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 03:09 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 2:57 PM On 02/12/2015 02:54 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 10:39 AM PML needs to be

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-11 Thread Kai Huang
On 02/12/2015 03:08 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 2:46 PM On 02/12/2015 02:25 PM, Tian, Kevin wrote: From: Kai Huang [mailto:kai.hu...@linux.intel.com] Sent: Thursday, February 12, 2015 10:35 AM On 02/11/2015 09:13

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-12 Thread Kai Huang
On 02/12/2015 10:10 PM, Andrew Cooper wrote: On 12/02/15 06:54, Tian, Kevin wrote: which presumably means that the PML buffer flush needs to be aware of which gfns are mapped by superpages to be able to correctly set a block of bits in the logdirty bitmap. Unfortunately PML itself can't tell

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-12 Thread Kai Huang
On 02/12/2015 08:42 PM, Tim Deegan wrote: At 07:08 + on 12 Feb (1423721283), Tian, Kevin wrote: for general log dirty, ept_invalidate_emt is required because there is access permission change (dirtied page becomes rw after 1st fault, so need to change them back to ro again for the new dirty

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-12 Thread Kai Huang
On 02/12/2015 08:34 PM, Tim Deegan wrote: Hi, Thanks for posting this design! At 16:28 +0800 on 11 Feb (1423668493), Kai Huang wrote: Design == - PML feature is used globally A new Xen boot parameter, say 'opt_enable_pml', will be introduced to control PML feature detectio

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-13 Thread Kai Huang
On Fri, Feb 13, 2015 at 6:57 PM, Andrew Cooper wrote: > On 13/02/15 02:11, Kai Huang wrote: > > > On 02/12/2015 10:10 PM, Andrew Cooper wrote: > > On 12/02/15 06:54, Tian, Kevin wrote: > > which presumably > means that the PML buffer flush needs to be aware of

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-13 Thread Kai Huang
On Fri, Feb 13, 2015 at 11:28 PM, Andrew Cooper wrote: > On 13/02/15 14:32, Kai Huang wrote: >> On Fri, Feb 13, 2015 at 6:57 PM, Andrew Cooper >> wrote: >>> On 13/02/15 02:11, Kai Huang wrote: >>> >>> >>> On 02/12/2015 10:10 PM, Andrew Cooper

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-13 Thread Kai Huang
On Fri, Feb 13, 2015 at 11:52 PM, Kai Huang wrote: > On Fri, Feb 13, 2015 at 11:28 PM, Andrew Cooper > wrote: >> On 13/02/15 14:32, Kai Huang wrote: >>> On Fri, Feb 13, 2015 at 6:57 PM, Andrew Cooper >>> wrote: >>>> On 13/02/15 02:11, Kai Huang wr

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-16 Thread Kai Huang
On Fri, Feb 13, 2015 at 10:50 AM, Kai Huang wrote: > > On 02/12/2015 08:34 PM, Tim Deegan wrote: >> >> Hi, >> >> Thanks for posting this design! >> >> At 16:28 +0800 on 11 Feb (1423668493), Kai Huang wrote: >>> >>> Design >>>

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-02-16 Thread Kai Huang
On Mon, Feb 16, 2015 at 7:44 PM, Andrew Cooper wrote: > On 14/02/15 03:01, Kai Huang wrote: >>>> This will only function correctly if superpage shattering is used. >>>> >>>> As soon as a superpage D bit transitions from 0 to 1, the gfn is logged >>>

Re: [Xen-devel] PML (Page Modification Logging) design for Xen

2015-03-01 Thread Kai Huang
On 02/17/2015 06:23 PM, Jan Beulich wrote: On 12.02.15 at 03:49, wrote: On 02/11/2015 09:06 PM, Jan Beulich wrote: On 11.02.15 at 09:28, wrote: - PML buffer flush There are two places we need to flush PML buffer. The first place is PML buffer full VMEXIT handler (apparently), and the secon

Re: [Xen-devel] [PATCH for-4.6] p2m/ept: Set the A bit only if PML is enabled

2015-09-28 Thread Kai Huang
On 09/24/2015 05:10 PM, Tim Deegan wrote: At 01:02 -0600 on 24 Sep (1443056566), Jan Beulich wrote: On 23.09.15 at 17:46, wrote: At 16:18 +0100 on 23 Sep (1443025126), Wei Liu wrote: With the discussion still not finalised I'm a bit worried that this issue will block the release. I think w

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-09-30 Thread Kai Huang
setting the flag should be > sufficient - the domain is required to be paused for PML enabling > anyway, i.e. hardware will pick up the new setting the next time > each vCPU of the guest gets scheduled. > > Signed-off-by: Jan Beulich > Cc: Kai Huang > --- > VT-x maintainers, K

Re: [Xen-devel] [PATCHv2 for-4.6] p2m/ept: Work around hardware errata setting A bit

2015-09-30 Thread Kai Huang
On Mon, Sep 28, 2015 at 10:09 PM, Jan Beulich wrote: On 28.09.15 at 14:39, wrote: >> --- a/xen/arch/x86/mm/p2m-ept.c >> +++ b/xen/arch/x86/mm/p2m-ept.c >> @@ -34,6 +34,8 @@ >> >> #include "mm-locks.h" >> >> +static bool_t __read_mostly cpu_has_ept_ad; > > This should be > #define cpu_has_ep

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-09-30 Thread Kai Huang
gt; anyway, i.e. hardware will pick up the new setting the next time >>> each vCPU of the guest gets scheduled. >>> >>> Signed-off-by: Jan Beulich >>> Cc: Kai Huang >>> --- >>> VT-x maintainers, Kai: Me lacking the hardware to test this, may

[Xen-devel] XL doesn't work on latest upstream Xen?

2014-12-17 Thread Kai Huang
Hi, I built and installed Xen from latest upstream Xen source code, but XL always failed to work. Do you know what's going on here? My environment is Lubuntu 14.04. Thanks in advance. I always got "Permission denied" error. root@kai-haswell:~# xl list libxl: error: libxl.c:561:libxl_list_domain:

Re: [Xen-devel] [PATCH v3] x86/EPT: work around hardware erratum setting A bit

2015-10-13 Thread Kai Huang
On 10/02/2015 05:36 PM, Wei Liu wrote: On Wed, Sep 30, 2015 at 01:25:49PM +0100, Wei Liu wrote: On Wed, Sep 30, 2015 at 05:36:22AM -0600, Jan Beulich wrote: Since commit 191b3f3344ee ("p2m/ept: enable PML in p2m-ept for log-dirty"), the A and D bits of EPT paging entries are set unconditional

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-10-13 Thread Kai Huang
Hi Jan, Our QA tested this patch but this patch broke PML. Neither GUI display (video ram tracking also uses PML) nor live migration works. I'll investigate what's wrong and get back to you. Thanks, -Kai On 09/30/2015 08:45 PM, Kai Huang wrote: On Wed, Sep 30, 2015 at 5:54 PM, J

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-10-14 Thread Kai Huang
efer the latter, please provide comments. Thanks, -Kai On 10/14/2015 09:19 AM, Kai Huang wrote: Hi Jan, Our QA tested this patch but this patch broke PML. Neither GUI display (video ram tracking also uses PML) nor live migration works. I'll investigate what's wrong and get back to y

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-10-14 Thread Kai Huang
On 10/14/2015 05:26 PM, Jan Beulich wrote: On 14.10.15 at 11:08, wrote: After some thinking, just set/clear p2m->ept.ept_ad is not enough -- we also need to __vmwrite it to VMCS's EPTP, and then call ept_sync_domain. Ah, yes, this makes sense of course. I have verified attached patch can w

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-10-15 Thread Kai Huang
On 10/15/2015 03:11 PM, Jan Beulich wrote: On 15.10.15 at 08:42, wrote: Thanks for your comments Jan. Actually I am not happy with combining with EPT A/D bit update with PML enabling to single function. After thinking again, how about adding a separate vmx function (ex, vmx_domain_update_eptp

Re: [Xen-devel] [PATCH] x86/EPT: defer enabling of A/D maintenance until PML get enabled

2015-10-15 Thread Kai Huang
On 10/15/2015 03:35 PM, Kai Huang wrote: On 10/15/2015 03:11 PM, Jan Beulich wrote: On 15.10.15 at 08:42, wrote: Thanks for your comments Jan. Actually I am not happy with combining with EPT A/D bit update with PML enabling to single function. After thinking again, how about adding a

[Xen-devel] [PATCH] x86/ept: defer enabling of EPT A/D bit until PML get enabled.

2015-10-15 Thread Kai Huang
anity live migration and GUI display were tested on Broadwell Machine. Signed-off-by: Kai Huang Signed-off-by: Jan Beulich --- xen/arch/x86/hvm/vmx/vmcs.c| 24 xen/arch/x86/mm/p2m-ept.c | 24 xen/include/asm-x86/hvm/vmx/vmcs.h | 2 +

Re: [Xen-devel] [PATCH] x86/ept: defer enabling of EPT A/D bit until PML get enabled.

2015-10-16 Thread Kai Huang
extra feature for every domain when we're not meaning to use it (yet). Sanity live migration and GUI display were tested on Broadwell Machine. Signed-off-by: Kai Huang Signed-off-by: Jan Beulich There's so little in this patch that came from me that I don't think this is warranted; but

[Xen-devel] [PATCH 1/2] x86/ept: defer enabling of EPT A/D bit until PML get enabled.

2015-10-19 Thread Kai Huang
ded ASSERT of domain having been paused to ept_flush_pml_buffers to make it consistent with ept_enable{disable}_pml. Sanity live migration and GUI display were tested on Broadwell Machine. Signed-off-by: Kai Huang Suggested-by: Jan Beulich --- xen/arch/x86/hvm/vmx/vmcs.c

[Xen-devel] [PATCH 0/2] Deter enabling of EPT A/D bit plus coding style fix

2015-10-19 Thread Kai Huang
Patch 1 is the v2 of defering enabling of EPT A/D bit until PML get enabled, with comments from Jan in v1 addressed. Patch 2 is coding style fix of for_each_vcpu to existing PML functions according to Jan. Kai Huang (2): x86/ept: defer enabling of EPT A/D bit until PML get enabled. x86/vmx

[Xen-devel] [PATCH 2/2] x86/vmx: fix coding style of PML functions

2015-10-19 Thread Kai Huang
According to Jan's comments, also fix the coding style of for_each_vcpu in existing PML functions. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c

Re: [Xen-devel] [PATCH 0/2] Deter enabling of EPT A/D bit plus coding style fix

2015-10-20 Thread Kai Huang
Hi Kevin, Would you comment on the two patches? Thanks, -Kai On 10/20/2015 10:34 AM, Kai Huang wrote: Patch 1 is the v2 of defering enabling of EPT A/D bit until PML get enabled, with comments from Jan in v1 addressed. Patch 2 is coding style fix of for_each_vcpu to existing PML functions

Re: [Xen-devel] [PATCH 00/10] PML (Paging Modification Logging) support

2015-04-07 Thread Kai Huang
Hi Jan, Tim, other maintainers, Do you have comments? Or should I send out the v2 addressing Andrew's comments, as it's been more than a week since this patch series were sent out? Thanks, -Kai On 03/30/2015 01:50 PM, Kai Huang wrote: On 03/28/2015 05:26 AM, Andrew Cooper wro

Re: [Xen-devel] [PATCH 00/10] PML (Paging Modification Logging) support

2015-04-07 Thread Kai Huang
On 04/07/2015 05:24 PM, Tim Deegan wrote: Hi, At 16:30 +0800 on 07 Apr (1428424218), Kai Huang wrote: Hi Jan, Tim, other maintainers, Do you have comments? Or should I send out the v2 addressing Andrew's comments, as it's been more than a week since this patch series were sent

[Xen-devel] [v2 04/11] vmx: add PML definition and feature detection.

2015-04-15 Thread Kai Huang
The patch adds PML definition and feature detection. Note PML won't be detected if PML is disabled from boot parameter. PML is also disabled in construct_vmcs, as it will only be enabled when domain is switched to log dirty mode. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/v

[Xen-devel] [v2 00/11] PML (Paging Modification Logging) support

2015-04-15 Thread Kai Huang
72811 80257 80139 72486 80413 81127 avg 72959 80718 81151 100%110.63% 111.22% Kai Huang (11): vmx: add new boot parameter to control PML enabling doc: add description for new PML boot paramet

[Xen-devel] [v2 05/11] vmx: add new data structure member to support PML

2015-04-15 Thread Kai Huang
;t have to be initialized to zero explicitly as both vcpu and domain structure are zero-ed when they are created. Signed-off-by: Kai Huang --- xen/include/asm-x86/hvm/vmx/vmcs.h | 7 +++ 1 file changed, 7 insertions(+) diff --git a/xen/include/asm-x86/hvm/vmx/vmcs.h b/xen/include/asm-x86/hvm

[Xen-devel] [v2 07/11] vmx: handle PML buffer full VMEXIT

2015-04-15 Thread Kai Huang
We need to flush PML buffer when it's full. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 4 1 file changed, 4 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 2ac1492..279e745 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arc

[Xen-devel] [v2 03/11] log-dirty: add new paging_mark_gfn_dirty

2015-04-15 Thread Kai Huang
refore we introduce paging_mark_gfn_dirty which is bulk of paging_mark_dirty but takes guest pfn as parameter, and in flushing PML buffer we call paging_mark_gfn_dirty directly. Original paging_mark_dirty then simply is a wrapper of paging_mark_gfn_dirty. Signed-off-by: Kai Huang --- xen/arch/

[Xen-devel] [v2 02/11] doc: add description for new PML boot parameter

2015-04-15 Thread Kai Huang
This patch adds doc description for new boot parameter 'ept=pml'. Signed-off-by: Kai Huang --- docs/misc/xen-command-line.markdown | 14 ++ 1 file changed, 14 insertions(+) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown ind

[Xen-devel] [v2 01/11] vmx: add new boot parameter to control PML enabling

2015-04-15 Thread Kai Huang
A top level EPT parameter "ept=" and a sub boolean "opt_pml_enabled" are added to control PML. Other booleans can be further added for any other EPT related features. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c | 31 +++ 1 file ch

[Xen-devel] [v2 09/11] vmx: disable PML in vmx_vcpu_destroy

2015-04-15 Thread Kai Huang
It's possible domain still remains in log-dirty mode when it is about to be destroyed, in which case we should manually disable PML for it. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 8 1 file changed, 8 insertions(+) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen

[Xen-devel] [v2 08/11] vmx: handle PML enabling in vmx_vcpu_initialise

2015-04-15 Thread Kai Huang
It's possible domain has already been in log-dirty mode when creating vcpu, in which case we should enable PML for this vcpu if PML has been enabled for the domain. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmx.c | 23 +++ 1 file changed, 23 insertions(+) diff

[Xen-devel] [v2 10/11] log-dirty: refine common code to support PML

2015-04-15 Thread Kai Huang
nctions to enable/disable PML and flush PML buffers. The new functions are named to be generic to cover potential futher PML-like features for other platforms. Signed-off-by: Kai Huang --- xen/arch/x86/mm/hap/hap.c | 29 + xen/arch/x86/mm/p2m.

[Xen-devel] [v2 06/11] vmx: add help functions to support PML

2015-04-15 Thread Kai Huang
This patch adds help functions to enable/disable PML, and flush PML buffer for single vcpu and particular domain for further use. Signed-off-by: Kai Huang --- xen/arch/x86/hvm/vmx/vmcs.c| 178 + xen/include/asm-x86/hvm/vmx/vmcs.h | 9 ++ 2 files

[Xen-devel] [v2 11/11] p2m/ept: enable PML in p2m-ept for log-dirty

2015-04-15 Thread Kai Huang
in order to log that GFN. For superpages, we still need to set it to read-only as we need to split superpage to 4K pages in EPT violation. Signed-off-by: Kai Huang --- xen/arch/x86/mm/p2m-ept.c | 79 ++ xen/include/asm-x86/hvm/vmx/vmcs.h | 3 +- xen

Re: [Xen-devel] [v2 01/11] vmx: add new boot parameter to control PML enabling

2015-04-15 Thread Kai Huang
On Wed, Apr 15, 2015 at 8:20 PM, Jan Beulich wrote: On 15.04.15 at 09:03, wrote: >> +static void __init parse_ept_param(char *s) >> +{ >> +char *ss; >> +int val; > > bool_t, and would better move ... > >> + >> +do { >> +val = !!strncmp(s, "no-", 3); > > ... here (making t

Re: [Xen-devel] [v2 02/11] doc: add description for new PML boot parameter

2015-04-15 Thread Kai Huang
On 04/15/2015 06:15 PM, Andrew Cooper wrote: On 15/04/15 08:03, Kai Huang wrote: This patch adds doc description for new boot parameter 'ept=pml'. Signed-off-by: Kai Huang Personally, I would fold this patch into the previous so the documentation is in the same patch as intr

Re: [Xen-devel] [v2 00/11] PML (Paging Modification Logging) support

2015-04-16 Thread Kai Huang
Thanks Tim! I'll send out the v3 addressing minor comments from Andrew and Jan regarding to patch 1 & 2. Thanks, -Kai On Thu, Apr 16, 2015 at 10:41 PM, Tim Deegan wrote: > At 15:03 +0800 on 15 Apr (1429110222), Kai Huang wrote: >> This v2 patch series was rebased on la

  1   2   >