Re: [Xen-devel] [PATCH v2 11/15] tools: implement the new xl get hw info interface

2017-08-30 Thread Yi Sun
On 17-08-30 10:23:18, Roger Pau Monn� wrote:
> On Thu, Aug 24, 2017 at 09:14:45AM +0800, Yi Sun wrote:
> > +static int psr_mba_hwinfo(void)
> > +{
> > +int rc;
> > +unsigned int i, nr;
> > +libxl_psr_hw_info *info;
> > +
> > +rc = libxl_psr_get_hw_info(ctx, , ,
> > +   LIBXL_PSR_FEAT_TYPE_MBA, 0);
> > +if (rc)
> > +return rc;
> > +
> > +printf("Memory Bandwidth Allocation (MBA):\n");
> > +
> > +for (i = 0; i < nr; i++) {
> > +printf("%-16s: %u\n", "Socket ID", info[i].id);
> > +printf("%-16s: %s\n", "Linear Mode",
> > +   info[i].u.mba.linear ? "Enabled" : "Disabled");
> > +printf("%-16s: %u\n", "Maximum COS", info[i].u.mba.cos_max);
> > +printf("%-16s: %u\n", "Maximum Throttling Value",
> > +   info[i].u.mba.thrtl_max);
> > +printf("%-16s: %u\n", "Default Throttling Value", 0);
> 
> If you really want to left-justify, shouldn't you choose a value that
> aligns everything nicely (strlen("Default Throttling Valu") is
> already greater than 16).
> 
Sorry for missing this.

> In fact you can do the alignment manually in the format string, and
> avoid passing the name as the first parameter.
> 
DYM a sentence like below?
  printf("%-*s: %u\n", 23, "Default Throttling Value", 0);

> > +}
> > +
> > +libxl_psr_hw_info_list_free(info, nr);
> > +return rc;
> > +}
> > +
> >  int main_psr_cat_cbm_set(int argc, char **argv)
> >  {
> >  uint32_t domid;
> > @@ -597,20 +624,24 @@ int main_psr_cat_show(int argc, char **argv)
> >  int main_psr_hwinfo(int argc, char **argv)
> >  {
> >  int opt, ret = 0;
> > -bool all = true, cmt = false, cat = false;
> > +bool all = true, cmt = false, cat = false, mba = false;
> >  static struct option opts[] = {
> 
> const?
> 
Ok, thanks!

> Roger.

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


[Xen-devel] linux-next: build failure after merge of the xen-tip tree

2017-08-30 Thread Stephen Rothwell
Hi all,

After merging the xen-tip tree, today's linux-next build (x86_64
allmodconfig) failed like this:

arch/x86/xen/xen-asm_64.o: In function `xen_trace_page_fault':
(.text+0x174): undefined reference to `trace_page_fault'

Caused by commit

  ad5b8c4ba323 ("xen: get rid of paravirt op adjust_exception_frame")

interacting with commit

  11a7ffb01703 ("x86/traps: Simplify pagefault tracing logic")

from the tip tree.

I am not sure how to fix up this, so I have just applied the following
patch for today.  A better solution would be appreciated.

From: Stephen Rothwell 
Date: Thu, 31 Aug 2017 15:06:10 +1000
Subject: [PATCH] xen: fix for "x86/traps: Simplify pagefault tracing logic"

Signed-off-by: Stephen Rothwell 
---
 arch/x86/xen/enlighten_pv.c | 2 +-
 arch/x86/xen/xen-asm_64.S   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index b18d9b9f84c2..6ea983a9016d 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -618,7 +618,7 @@ static struct {
{ alignment_check, xen_alignment_check, false },
{ simd_coprocessor_error, xen_simd_coprocessor_error, false },
 #ifdef CONFIG_TRACING
-   { trace_page_fault, xen_trace_page_fault, false },
+// { trace_page_fault, xen_trace_page_fault, false },
 #endif
 };
 
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 4ebac091a0e8..1c7a3df3e5a5 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -52,7 +52,7 @@ xen_pv_trap simd_coprocessor_error
 xen_pv_trap entry_INT80_compat
 #endif
 #ifdef CONFIG_TRACING
-xen_pv_trap trace_page_fault
+/* xen_pv_trap trace_page_fault */
 #endif
 xen_pv_trap hypervisor_callback
 
-- 
2.13.2

-- 
Cheers,
Stephen Rothwell

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


Re: [Xen-devel] [PATCH v10] VT-d: use correct BDF for VF to search VT-d unit

2017-08-30 Thread Crawford, Eric R
Sorry for the delay, it looks like this patch resolves the issue.

Tested-by: Crawford, Eric R 

-Eric

-Original Message-
From: Gao, Chao 
Sent: Monday, August 28, 2017 12:27 AM
To: Crawford, Eric R 
Cc: Andrew Cooper ; Roger Pau Monné 
; Wei Liu ; George Dunlap 
; Ian Jackson ; 
Crawford, Eric R ; Tian, Kevin 
; Stefano Stabellini ; 
xen-devel@lists.xen.org; Konrad Rzeszutek Wilk ; Tim 
Deegan ; Jan Beulich 
Subject: Re: [PATCH v10] VT-d: use correct BDF for VF to search VT-d unit

On Mon, Aug 28, 2017 at 02:16:18AM -0600, Jan Beulich wrote:
 On 28.08.17 at 04:42,  wrote:
>> When SR-IOV is enabled, 'Virtual Functions' of a 'Physical Function'
>> are under the scope of the same VT-d unit as the 'Physical Function'.
>> A 'Physical Function' can be a 'Traditional Function' or an ARI 
>> 'Extended Function'. And furthermore, 'Extended Functions' on an 
>> endpoint are under the scope of the same VT-d unit as the 
>> 'Traditional Functions' on the endpoint. To search VT-d unit for a 
>> VF, if its PF isn't an extended function, the BDF of PF should be 
>> used. Otherwise the BDF of a traditional function in the same device 
>> with the PF should be used.
>> 
>> Current code uses PCI_SLOT() to recognize an ARI 'Extended Funcion'.
>> But it is conceptually wrong w/o checking whether PF is an extended 
>> function and would lead to match VFs of a RC integrated PF to a wrong 
>> VT-d unit.
>> 
>> This patch overrides VF 'is_extfn' field and uses this field to 
>> indicate whether the PF of this VF is an extended function. The field 
>> helps to use correct BDF to search VT-d unit.
>> 
>> Reported-by: Crawford, Eric R 
>> Signed-off-by: Chao Gao 
>
>Acked-by: Jan Beulich  albeit ...
>
>> --- a/xen/drivers/passthrough/vtd/dmar.c
>> +++ b/xen/drivers/passthrough/vtd/dmar.c
>> @@ -211,15 +211,15 @@ struct acpi_drhd_unit 
>> *acpi_find_matched_drhd_unit(const struct pci_dev *pdev)
>>  if ( pdev == NULL )
>>  return NULL;
>>  
>> -if ( pdev->info.is_extfn )
>> +if ( pdev->info.is_virtfn )
>>  {
>> -bus = pdev->bus;
>> -devfn = 0;
>> +bus = pdev->info.physfn.bus;
>> +devfn = (!pdev->info.is_extfn) ? pdev->info.physfn.devfn : 
>> + 0;
>
>... if I end up committing this and if I don't forget, I'll likely take 
>the liberty to remove the pointless parentheses here.
>

Hi, Eric.

Could you test this patch again and give your Tested-by if it fixes the problem 
you reported?

Thanks
Chao

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


[Xen-devel] [xen-unstable-smoke test] 112972: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112972 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112972/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which are failing intermittently (not blocking):
 test-amd64-amd64-libvirt  7 xen-boot   fail pass in 112969

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt13 migrate-support-check fail in 112969 never pass

version targeted for testing:
 xen  4be9a177e62eaa190b0f4721dd19153993511ee3
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Failing since112957  2017-08-30 12:02:17 Z0 days8 attempts
Testing same since   112962  2017-08-30 18:05:04 Z0 days5 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt fail



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 374 lines long.)

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


[Xen-devel] linux-next: manual merge of the xen-tip tree with the tip tree

2017-08-30 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the xen-tip tree got a conflict in:

  arch/x86/xen/enlighten_pv.c

between commit:

  64b163fab684 ("x86/idt: Unify gate_struct handling for 32/64-bit kernels")

from the tip tree and commit:

  ad5b8c4ba323 ("xen: get rid of paravirt op adjust_exception_frame")

from the xen-tip tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/xen/enlighten_pv.c
index c76f5ff4d0d7,148527c4e48a..
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@@ -596,42 -651,10 +658,10 @@@ static int cvt_gate_to_trap(int vector
  
info->vector = vector;
  
 -  addr = gate_offset(*val);
 +  addr = gate_offset(val);
  #ifdef CONFIG_X86_64
-   /*
-* Look for known traps using IST, and substitute them
-* appropriately.  The debugger ones are the only ones we care
-* about.  Xen will handle faults like double_fault,
-* so we should never see them.  Warn if
-* there's an unexpected IST-using fault handler.
-*/
-   if (addr == (unsigned long)debug)
-   addr = (unsigned long)xen_debug;
-   else if (addr == (unsigned long)int3)
-   addr = (unsigned long)xen_int3;
-   else if (addr == (unsigned long)stack_segment)
-   addr = (unsigned long)xen_stack_segment;
-   else if (addr == (unsigned long)double_fault) {
-   /* Don't need to handle these */
 -  if (!get_trap_addr(, val->ist))
++  if (!get_trap_addr(, val->bits.ist))
return 0;
- #ifdef CONFIG_X86_MCE
-   } else if (addr == (unsigned long)machine_check) {
-   /*
-* when xen hypervisor inject vMCE to guest,
-* use native mce handler to handle it
-*/
-   ;
- #endif
-   } else if (addr == (unsigned long)nmi)
-   /*
-* Use the native version as well.
-*/
-   ;
-   else {
-   /* Some other trap using IST? */
-   if (WARN_ON(val->bits.ist != 0))
-   return 0;
-   }
  #endif/* CONFIG_X86_64 */
info->address = addr;
  

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


[Xen-devel] linux-next: manual merge of the xen-tip tree with the tip tree

2017-08-30 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the xen-tip tree got a conflict in:

  arch/x86/include/asm/traps.h

between commit:

  11a7ffb01703 ("x86/traps: Simplify pagefault tracing logic")

from the tip tree and commit:

  ad5b8c4ba323 ("xen: get rid of paravirt op adjust_exception_frame")

from the xen-tip tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc arch/x86/include/asm/traps.h
index b4f322d6c95f,935709829a4e..
--- a/arch/x86/include/asm/traps.h
+++ b/arch/x86/include/asm/traps.h
@@@ -38,7 -35,34 +35,33 @@@ asmlinkage void machine_check(void)
  #endif /* CONFIG_X86_MCE */
  asmlinkage void simd_coprocessor_error(void);
  
+ #if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
+ asmlinkage void xen_divide_error(void);
+ asmlinkage void xen_xendebug(void);
+ asmlinkage void xen_xenint3(void);
+ asmlinkage void xen_nmi(void);
+ asmlinkage void xen_overflow(void);
+ asmlinkage void xen_bounds(void);
+ asmlinkage void xen_invalid_op(void);
+ asmlinkage void xen_device_not_available(void);
+ asmlinkage void xen_double_fault(void);
+ asmlinkage void xen_coprocessor_segment_overrun(void);
+ asmlinkage void xen_invalid_TSS(void);
+ asmlinkage void xen_segment_not_present(void);
+ asmlinkage void xen_stack_segment(void);
+ asmlinkage void xen_general_protection(void);
+ asmlinkage void xen_page_fault(void);
+ asmlinkage void xen_async_page_fault(void);
+ asmlinkage void xen_spurious_interrupt_bug(void);
+ asmlinkage void xen_coprocessor_error(void);
+ asmlinkage void xen_alignment_check(void);
+ #ifdef CONFIG_X86_MCE
+ asmlinkage void xen_machine_check(void);
+ #endif /* CONFIG_X86_MCE */
+ asmlinkage void xen_simd_coprocessor_error(void);
+ #endif
+ 
  #ifdef CONFIG_TRACING
 -asmlinkage void trace_page_fault(void);
  #define trace_stack_segment stack_segment
  #define trace_divide_error divide_error
  #define trace_bounds bounds
@@@ -53,7 -77,10 +76,11 @@@
  #define trace_alignment_check alignment_check
  #define trace_simd_coprocessor_error simd_coprocessor_error
  #define trace_async_page_fault async_page_fault
 +#define trace_page_fault page_fault
+ 
+ #if defined(CONFIG_X86_64) && defined(CONFIG_XEN_PV)
+ asmlinkage void xen_trace_page_fault(void);
+ #endif
  #endif
  
  dotraplinkage void do_divide_error(struct pt_regs *, long);

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


[Xen-devel] [ovmf baseline-only test] 72043: all pass

2017-08-30 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72043 ovmf real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72043/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf 5202e6c907e5769ac8ecb024b7a07509bdba6181
baseline version:
 ovmf c1d799b915096b79b5c5d035b134ffbccc6d1469

Last test of basis72041  2017-08-30 12:19:22 Z0 days
Testing same since72043  2017-08-31 01:49:04 Z0 days1 attempts


People who touched revisions under test:
  Ard Biesheuvel 
  Hao Wu 
  Huajing Li 
  Laszlo Ersek 
  Leif Lindholm 
  Long Qin 
  Qin Long 
  Ruiyu Ni 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.xs.citrite.net
logs: /home/osstest/logs
images: /home/osstest/images

Logs, config files, etc. are available at
http://osstest.xs.citrite.net/~osstest/testlogs/logs

Test harness code can be found at
http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary


Push not applicable.


commit 5202e6c907e5769ac8ecb024b7a07509bdba6181
Author: Leif Lindholm 
Date:   Wed Aug 30 12:26:42 2017 +0100

EmbeddedPkg/EmbeddedPkg.dsc: fix build for non-ARM architectures

EmbeddedPkg should be architecture agnostic, but a few issues were
preventing other architectures to build individual components directly
from the .dsc:

- The AndroidBoot/AndroidFastBoot support have a dependency on BdsLib,
  which only has resolutions for ARM/AARCH64. Move them to an
  arch-restricted Components section.
- The Isp1761UsbDxe driver is not 64-bit compatible. It should be
  converted to UEFI driver model, but for now just move it to a new
  Components.ARM section. (Also delete non-useful declaration for
  AARCH64 in EmbeddedPkg.dec.)
- Lan9118Dxe has an unused ArmLib entry. Drop it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leif Lindholm 
Reviewed-by: Ard Biesheuvel 

commit 7046a2739ae74f5d5c86ea18dc4bcc855e4916c6
Author: Hao Wu 
Date:   Tue Aug 29 19:33:09 2017 +0800

IntelSiliconPkg/PlatformVTdSample: Avoid using constant result 'if'

In this sample driver, if (0) {...} else {...} statements were used to
illustrate two different using scenarios.

This comment refines the coding style by substituting the 'if (0)'
statement with comments to select sample codes for different cases.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu 
Reviewed-by: Jiewen Yao 

commit db6f08a0eae66f5c8e9a91930d9bc78c7eb404bb
Author: Ard Biesheuvel 
Date:   Wed Aug 30 10:29:15 2017 +0100

ArmPlatformPkg/ArmJunoDxe: remove bogus DmaLib dependency

This driver does not rely on DmaLib at all, so don't declare it as a
dependency.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 

commit 3946497ff57074990a03a723b0a62ddecda1888d
Author: Ard Biesheuvel 
Date:   Wed Aug 30 08:25:51 2017 +0100

ArmVirtPkg: remove DmaLib library class resolution

The virt targets never use non-coherent DMA, so there is no point
in having a shared DmaLib library class resolution pointing to
ArmDmaLib. So drop it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Laszlo Ersek 

commit 1877b15e10d97d9f95582131eccc574593c3391f
Author: Ruiyu Ni 
Date:   Wed Aug 30 15:16:23 2017 +0800

ShellBinPkg: Ia32/X64 Shell binary update.

Contributed-under: TianoCore Contribution Agreement 

[Xen-devel] [xen-4.7-testing baseline-only test] 72042: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72042 xen-4.7-testing real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72042/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemut-debianhvm-amd64 21 leak-check/check fail REGR. vs. 
72014

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate   broken never pass
 build-arm64-xsm   2 hosts-allocate   broken never pass
 build-arm64   2 hosts-allocate   broken never pass
 build-arm64-xsm   3 capture-logs broken never pass
 build-arm64-pvops 3 capture-logs broken never pass
 build-arm64   3 capture-logs broken never pass
 test-amd64-amd64-qemuu-nested-intel 17 debian-hvm-install/l1/l2 fail like 72014
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-midway   13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-midway   14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 10 windows-install fail never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-pvh-amd  12 guest-start  fail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-pvh-intel 15 guest-saverestorefail  never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-intel 18 capture-logs/l1(18) fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop  fail never pass
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop  fail never pass
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 17 guest-stop fail never pass

version targeted for testing:
 xen  68dbba27ae09e93cdf97f36129b6f7f72f9b569c
baseline version:
 xen  30d50f8ead03d6524cbc4ed22075980090fbd2ed

Last test of basis72014  

Re: [Xen-devel] [PATCH v2 10/15] tools: implement the new libxl get hw info interface

2017-08-30 Thread Yi Sun
On 17-08-30 10:15:22, Roger Pau Monn� wrote:
> On Thu, Aug 24, 2017 at 09:14:44AM +0800, Yi Sun wrote:
> > diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
> > index b183305..d7da7d7 100644
> > --- a/tools/libxl/libxl_psr.c
> > +++ b/tools/libxl/libxl_psr.c
> > @@ -382,56 +382,51 @@ static inline xc_psr_feat_type 
> > libxl__psr_feat_type_to_libxc_psr_feat_type(
> >  return xc_type;
> >  }
> >  
> > +static inline int libxl__psr_hw_info_to_libxl_psr_cat_info(
> 
> No inline. Maybe you could try to shorter the name?
> 
Got it. Will remove the last '_psr'.

[...]

> >  int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
> > int *nr, unsigned int lvl)
> >  {
> >  GC_INIT(ctx);
> >  int rc;
> > -int i = 0, socketid, nr_sockets;
> > -libxl_bitmap socketmap;
> > +unsigned int i;
> > +libxl_psr_hw_info *hw_info;
> >  libxl_psr_cat_info *ptr;
> > -xc_psr_hw_info hw_info;
> > -xc_psr_feat_type xc_type;
> > -
> > -libxl_bitmap_init();
> > -
> > -rc = libxl__count_physical_sockets(gc, _sockets);
> > -if (rc) {
> > -LOGE(ERROR, "failed to get system socket count");
> > -goto out;
> > -}
> >  
> > -libxl_socket_bitmap_alloc(ctx, , nr_sockets);
> > -rc = libxl_get_online_socketmap(ctx, );
> > -if (rc < 0) {
> > -LOGE(ERROR, "failed to get available sockets");
> > +rc = libxl_psr_get_hw_info(ctx, _info, (unsigned int *)nr,
> 
> Is there any reason nr is int instead of unsigned int?
> 
> I would rather avoid casting things. Since this interface has not been
> present in a release yet, could you please send a separate patch to
> fix this if nr has no reason to be signed?
> 
This is a historical issue.

The first version of PSR introduced 'libxl_psr_cat_get_l3_info'. The input
parameter is 'int *nr'.

I think we cannot change the interface which has been merged and used by
others. Right?

> > +   LIBXL_PSR_FEAT_TYPE_CAT, lvl);

[...]

> >  
> > +static inline int libxc__psr_hw_info_to_libxl_psr_hw_info(
> 
> No inline. Again shorter names would be better (although I understand
> this might not be possible).
> 
> Also, why are you adding a libxc__ prefixed function to libxl?
> 
Because this function is to convert 'xc_psr_hw_info' to 'libxl_psr_hw_info'.
I think I may change the name to 'libxl__xc_psr_info_to_libxl_psr_info'.

> > +  libxl_psr_feat_type type, xc_psr_hw_info *xc_hw_info,
> > +  libxl_psr_hw_info *xl_hw_info)
> 
> you could drop the '_hw' in the parameter names, so all the
> assignments below would fit on a single line.
> 
Ok, thanks!

> > +{
> > +switch (type) {
> > +case LIBXL_PSR_FEAT_TYPE_CAT:
> > +xl_hw_info->u.cat.cos_max = xc_hw_info->u.xc_cat_info.cos_max;
> > +xl_hw_info->u.cat.cbm_len = xc_hw_info->u.xc_cat_info.cbm_len;
> > +xl_hw_info->u.cat.cdp_enabled =
> > +xc_hw_info->u.xc_cat_info.cdp_enabled;
> > +break;
> > +case LIBXL_PSR_FEAT_TYPE_MBA:
> > +xl_hw_info->u.mba.cos_max = xc_hw_info->u.xc_mba_info.cos_max;
> > +xl_hw_info->u.mba.thrtl_max = xc_hw_info->u.xc_mba_info.thrtl_max;
> > +xl_hw_info->u.mba.linear = xc_hw_info->u.xc_mba_info.linear;
> > +break;
> > +default:
> > +return ERROR_INVAL;
> > +}
> > +
> > +return 0;
> > +}
> > +
> >  int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info **info,
> >unsigned int *nr, libxl_psr_feat_type type,
> >unsigned int lvl)
> >  {
> > -return ERROR_FAIL;
> > +GC_INIT(ctx);
> > +int rc, nr_sockets;
> > +unsigned int i = 0, socketid;
> > +libxl_bitmap socketmap;
> > +libxl_psr_hw_info *ptr;
> > +xc_psr_feat_type xc_type;
> > +xc_psr_hw_info hw_info;
> > +
> > +libxl_bitmap_init();
> > +
> > +if (type == LIBXL_PSR_FEAT_TYPE_CAT && lvl != 3 && lvl != 2) {
> > +LOGE(ERROR, "input lvl %d is wrong!\n", lvl);
> 
> LOGE is used when errno is set, which I don't think it's the case
> here. Please use plain LOG.
> 
> > +rc = ERROR_FAIL;
> > +goto out;
> > +}
> > +
> > +xc_type = libxl__psr_feat_type_to_libxc_psr_feat_type(type, lvl);
> 
> Isn't the above function going to return and invalid type if the
> feature is CAT and the level is not correct? In which case you could
> remove the above if and just check that the returned type here is not
> invalid?
> 
Ok, will check remove the first check and check return value here.

> > +
> > +rc = libxl__count_physical_sockets(gc, _sockets);
> > +if (rc) {
> > +LOGE(ERROR, "failed to get system socket count");
> 
> Again, libxl__ functions don't set errno. In this case this might be
> fine, because libxl__count_physical_sockets calls into libxc which
> sets errno, but you should only use LOGE when reporting errors from
> system 

Re: [Xen-devel] [PATCH v2 09/15] tools: implement the new libxc get hw info interface

2017-08-30 Thread Yi Sun
On 17-08-30 09:58:03, Roger Pau Monn� wrote:
> On Thu, Aug 24, 2017 at 09:14:43AM +0800, Yi Sun wrote:
> > diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> > index c7710b8..81a6f48 100644
> > --- a/tools/libxc/include/xenctrl.h
> > +++ b/tools/libxc/include/xenctrl.h
> > @@ -2458,6 +2458,31 @@ enum xc_psr_cat_type {
> >  };
> >  typedef enum xc_psr_cat_type xc_psr_cat_type;
> >  
> > +enum xc_psr_feat_type {
> > +XC_PSR_FEAT_UNKNOWN,
> > +XC_PSR_FEAT_CAT_L3,
> > +XC_PSR_FEAT_CAT_L2,
> > +XC_PSR_FEAT_MBA,
> > +};
> > +typedef enum xc_psr_feat_type xc_psr_feat_type;
> > +
> > +struct xc_psr_hw_info {
> > +union {
> > +struct {
> > +uint32_t cos_max;
> > +uint32_t cbm_len;
> > +bool cdp_enabled;
> > +} xc_cat_info;
> > +
> > +struct {
> > +uint32_t cos_max;
> > +uint32_t thrtl_max;
> > +bool linear;
> > +} xc_mba_info;
> 
> No need for the _info suffix. The type itself already has info in it's
> name.
> 
Ok, got it.

> > +} u;
> > +};
> > +typedef struct xc_psr_hw_info xc_psr_hw_info;

[...]

> > diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
> > index 73d05f2..ba412e4 100644
> > --- a/tools/libxc/xc_psr.c
> > +++ b/tools/libxc/xc_psr.c
> > @@ -323,36 +323,58 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, 
> > uint32_t domid,
> >  return rc;
> >  }
> >  
> > -int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, unsigned int 
> > lvl,
> > -uint32_t *cos_max, uint32_t *cbm_len, bool 
> > *cdp_enabled)
> > +int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
> > +   xc_psr_feat_type type, xc_psr_hw_info *hw_info)
> >  {
> >  int rc = -1;
> >  DECLARE_SYSCTL;
> >  
> > +if ( !hw_info )
> > +return rc;
> 
> You should set errno = EINVAL here.
> 
Sorry for missing it. Thanks!

[...]

> > diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
> > index cf368ba..b183305 100644
> > --- a/tools/libxl/libxl_psr.c
> > +++ b/tools/libxl/libxl_psr.c
> > @@ -361,6 +361,27 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t 
> > domid,
> >  return rc;
> >  }
> >  
> > +static inline xc_psr_feat_type libxl__psr_feat_type_to_libxc_psr_feat_type(
> 
> No inline please. In any case this is not performance critical code, so
> let the compiler decide.
> 
Ok, will remove it.

> And the function name could be shorter, maybe:
> 
> libxl__psr_type_to_libxc_type
> 
> Or is this going to clash with some other translation function?
>
Yes, there is another similar function which name is:
  'libxl__psr_cbm_type_to_libxc_psr_val_type'

I think I can remove the last '_psr' to make the name be shorter.
 
[...]

> > @@ -385,16 +408,23 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, 
> > libxl_psr_cat_info **info,
> >  goto out;
> >  }
> >  
> > +xc_type = libxl__psr_feat_type_to_libxc_psr_feat_type(
> > +  LIBXL_PSR_FEAT_TYPE_CAT, lvl);
> 
> Shouldn't you check that xc_type != XC_PSR_FEAT_UNKNOWN here?
> 
Yes, I should. Thanks!

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

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


[Xen-devel] [linux-4.9 test] 112953: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112953 linux-4.9 real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112953/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail REGR. vs. 
112863

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-xsm   2 hosts-allocate  broken like 112863
 build-arm64   2 hosts-allocate  broken like 112863
 build-arm64-pvops 2 hosts-allocate  broken like 112863
 build-arm64   3 capture-logsbroken like 112863
 build-arm64-pvops 3 capture-logsbroken like 112863
 build-arm64-xsm   3 capture-logs broken never pass
 test-armhf-armhf-xl-rtds 12 guest-start  fail  like 112863
 test-amd64-amd64-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail like 112863
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail like 112863
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 112863
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112863
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass

version targeted for testing:
 linux0eed54bdbd1b922004fe05dc8bf3815f2e5723d7
baseline version:
 linux4b904b22bc906d5867933b8132ae4d7f31d7645d

Last test of basis   112863  2017-08-25 00:48:39 Z6 days
Testing same since   112953  2017-08-30 09:55:32 Z0 days1 attempts


People who touched revisions under test:
  Aaron 

Re: [Xen-devel] [PATCH v2 08/15] tools: create general interfaces to support psr allocation features

2017-08-30 Thread Yi Sun
On 17-08-30 09:42:56, Roger Pau Monn� wrote:
> On Thu, Aug 24, 2017 at 09:14:42AM +0800, Yi Sun wrote:
> > This patch creates general interfaces in libxl to support all psr
> > allocation features.
> > 
> > Add 'LIBXL_HAVE_PSR_MBA' to indicate interface change.
> 
> I'm not sure this is enough to cover the changes you are doing here:
> you are introducing some MBA stuff, plus a kind of generic interface
> for PSR.
> 
> I think this should be split into two patches, the first one adding
> the generic interface, and the second one adding the MBA stuff.
> 
This patch only introduces the generic interfaces without any MBA stuff.

The 'LIBXL_HAVE_PSR_MBA' is used to indicate the interfaces change here.
Per my understand, we should add a macro to indicate libxl interfaces
change, right?

> > --- a/tools/libxl/libxl.h
> > +++ b/tools/libxl/libxl.h
> > @@ -931,6 +931,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, 
> > const libxl_mac *src);
> >  #define LIBXL_HAVE_PSR_L2_CAT 1
> >  
> >  /*
> > + * LIBXL_HAVE_PSR_MBA
> > + *
> > + * If this is defined, the Memory Bandwidth Allocation feature is 
> > supported.
> > + */
> > +#define LIBXL_HAVE_PSR_MBA 1
> > +
> > +/*
> >   * LIBXL_HAVE_MCA_CAPS
> >   *
> >   * If this is defined, setting MCA capabilities for HVM domain is 
> > supported.
> > @@ -2219,7 +2226,33 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, 
> > libxl_psr_cat_info **info,
> >  int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
> >int *nr);
> >  void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
> > -#endif
> > +
> > +#ifdef LIBXL_HAVE_PSR_MBA
> 
> You don't need this, this is only for consumers of libxl. It is
> perfectly fine to have the prototypes of the functions, even if
> consumers don't use them.
> 
Oh, ok. So the interfaces declaration does not need be included by macro. I see
some other interfaces are done so. So, I follow the convention.

> > +/*
> > + * Function to set a domain's value. It operates on a single or multiple
> > + * target(s) defined in 'target_map'. 'target_map' specifies all the 
> > sockets
> > + * to be operated on.
> > + */
> > +int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
> > +  libxl_psr_cbm_type type, libxl_bitmap *target_map,
> > +  uint64_t val);
> > +/*
> > + * Function to get a domain's cbm. It operates on a single 'target'.
> > + * 'target' specifies which socket to be operated on.
> > + */
> > +int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
> > +  libxl_psr_cbm_type type, unsigned int target,
> > +  uint64_t *val);
> > +/*
> > + * On success, the function returns an array of elements in 'info',
> > + * and the length in 'nr'.
> > + */
> > +int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info **info,
> > +  unsigned int *nr, libxl_psr_feat_type type,
> > +  unsigned int lvl);
> > +void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
> > +#endif /* LIBXL_HAVE_PSR_MBA */
> > +#endif /* LIBXL_HAVE_PSR_CAT */
> 
> Please send a patch to remove the already existing ifdef PSR
> pollution.
> 
Ok, I will send a patch to remoev this '#ifdef LIBXL_HAVE_PSR_CAT' in this file.

[...]

> > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > index 6e80d36..ab847f8 100644
> > --- a/tools/libxl/libxl_types.idl
> > +++ b/tools/libxl/libxl_types.idl
> > @@ -977,6 +977,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
> >  (2, "L3_CBM_CODE"),
> >  (3, "L3_CBM_DATA"),
> >  (4, "L2_CBM"),
> > +(5, "MBA_THRTL"),
> 
> Is this really a CBM type?
> 
This is not CBM type. The 'libxl_psr_cbm_type' name is not good enough. But I
have to introduce a new generic interface here if we want to make the name be
generic. I think it is not so valuable. So, I reuse the 'libxl_psr_cbm_type'
to cover MBA. How do you think?

> Roger.

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


[Xen-devel] [xen-unstable-smoke test] 112969: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112969 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112969/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  4be9a177e62eaa190b0f4721dd19153993511ee3
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Failing since112957  2017-08-30 12:02:17 Z0 days7 attempts
Testing same since   112962  2017-08-30 18:05:04 Z0 days4 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 374 lines long.)

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


Re: [Xen-devel] [PATCH v2 07/15] x86: implement set value flow for MBA

2017-08-30 Thread Yi Sun
On 17-08-30 09:31:04, Roger Pau Monn� wrote:
> On Thu, Aug 24, 2017 at 09:14:41AM +0800, Yi Sun wrote:
> > It also changes the memebers in 'cos_write_info' to transfer the
> > feature array, feature properties array and value array. Then, we
> > can write all features values on the cos id into MSRs.
> > 
> > Because multiple features may co-exist, we need handle all features to write
> > values of them into a COS register with new COS ID. E.g:
> > 1. L3 CAT and MBA co-exist.
> > 2. Dom1 and Dom2 share a same COS ID (2). The L3 CAT CBM of Dom1 is 0x1ff,
> >the MBA Thrtle of Dom1 is 0xa.
> > 3. User wants to change MBA Thrtl of Dom1 to be 0x14. Because COS ID 2 is
> >used by Dom2 too, we have to pick a new COS ID 3. The original values of
> >Dom1 on COS ID 3 may be below:
> 
> What original values? You said you pick COS ID 3, because I think it's
> assumed to be empty? In which case there are no original values in COS
> ID 3.
> 
Sorry for confusion. The original value means the default value. For CAT, it is
0x7ff on my machine which is shown below.

> >-
> >| COS 3 |
> >-
> >L3 CAT  | 0x7ff |
> >-
> >MBA | 0x0   |
> >-
> > diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
> > index 4a0c982..ce82975 100644
> > --- a/xen/arch/x86/psr.c
> > +++ b/xen/arch/x86/psr.c
> > @@ -138,6 +138,12 @@ static const struct feat_props {
> >  
> >  /* write_msr is used to write out feature MSR register. */
> >  void (*write_msr)(unsigned int cos, uint32_t val, enum psr_val_type 
> > type);
> > +
> > +/*
> > + * check_val is used to check if input val fulfills SDM requirement.
> > + * Change it to valid value if SDM allows.
> 
> I'm not really sure it's a good idea to change the value to a valid
> one, IMHO you should just check and print an error if the value is
> invalid (and return false of course).
> 
Per SDM, the HW has ability to automatically change the input value to what it
wants. E.g:
  Linear mode: HW wants the input value be 10/20/30/.../90. But user inputs 15.
   Then, HW can automatically change it to 10.

Even user inputs a value that does not fulfill HW requirement, HW can handle it.
So, we do not need return error to user. Otherwise, user needs to know details
of MBA.

But the issue here is how we get the actual value and show it to user. There are
two ways to do that:
1. When setting value, check and change it to valid one and save it to our 
cache.
2. When getting value, call rdmsr to read the actual value back from HW.

I think option 1 has better performance and the code looks better.

> > + */
> > +bool (*check_val)(const struct feat_node *feat, unsigned long *val);
> >  } *feat_props[FEAT_TYPE_NUM];
> >  
[...]

> >  /* L3 CAT props */
> >  static void l3_cat_write_msr(unsigned int cos, uint32_t val,
> >   enum psr_val_type type)
> > @@ -446,6 +453,7 @@ static const struct feat_props l3_cat_props = {
> >  .alt_type = PSR_VAL_TYPE_UNKNOWN,
> >  .get_feat_info = cat_get_feat_info,
> >  .write_msr = l3_cat_write_msr,
> > +.check_val = cat_check_cbm,
> >  };
> 
> Maybe the introduction of check_val should be a separate patch? It's
> mostly code movement and some fixup.
> 
Ok, may consider it.

[...]

> > +static bool mba_check_thrtl(const struct feat_node *feat, unsigned long 
> > *thrtl)
> > +{
> > +if ( *thrtl > feat->mba_info.thrtl_max )
> > +return false;
> > +
> > +/*
> > + * Per SDM (chapter "Memory Bandwidth Allocation Configuration"):
> > + * 1. Linear mode: In the linear mode the input precision is defined
> > + *as 100-(MBA_MAX). For instance, if the MBA_MAX value is 90, the
> > + *input precision is 10%. Values not an even multiple of the
> > + *precision (e.g., 12%) will be rounded down (e.g., to 10% delay
> > + *applied).
> > + * 2. Non-linear mode: Input delay values are powers-of-two from zero
> > + *to the MBA_MAX value from CPUID. In this case any values not a
> > + *power of two will be rounded down the next nearest power of two.
> > + */
> > +if ( feat->mba_info.linear )
> > +{
> > +unsigned int mod;
> > +
> > +mod = *thrtl % (100 - feat->mba_info.thrtl_max);
> > +*thrtl -= mod;
> > +}
> > +else
> > +{
> > +/* Not power of 2. */
> > +if ( *thrtl && (*thrtl & (*thrtl - 1)) )
> 
> This can be joined with the else to avoid another indentation level:
> 
> else if ( *thrtl && (*thrtl & (*thrtl - 1)) )
> ...
> 
Thanks!

> > +*thrtl = *thrtl & (1 << (flsl(*thrtl) - 1));
> > +}
> > +
> > +return true;
> >  }
> >  
[...]

> >  static void do_write_psr_msrs(void *data)
> >  {
> >  const struct cos_write_info *info = data;
> > -struct feat_node *feat = info->feature;
> > -const struct feat_props *props = info->props;
> > -

[Xen-devel] [ovmf test] 112958: all pass - PUSHED

2017-08-30 Thread osstest service owner
flight 112958 ovmf real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112958/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf 5202e6c907e5769ac8ecb024b7a07509bdba6181
baseline version:
 ovmf c1d799b915096b79b5c5d035b134ffbccc6d1469

Last test of basis   112947  2017-08-29 20:47:07 Z1 days
Testing same since   112958  2017-08-30 12:17:39 Z0 days1 attempts


People who touched revisions under test:
  Ard Biesheuvel 
  Hao Wu 
  Huajing Li 
  Laszlo Ersek 
  Leif Lindholm 
  Long Qin 
  Qin Long 
  Ruiyu Ni 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary


Pushing revision :

+ branch=ovmf
+ revision=5202e6c907e5769ac8ecb024b7a07509bdba6181
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x '!=' x/home/osstest/repos/lock ']'
++ OSSTEST_REPOS_LOCK_LOCKED=/home/osstest/repos/lock
++ exec with-lock-ex -w /home/osstest/repos/lock ./ap-push ovmf 
5202e6c907e5769ac8ecb024b7a07509bdba6181
+ branch=ovmf
+ revision=5202e6c907e5769ac8ecb024b7a07509bdba6181
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x/home/osstest/repos/lock '!=' x/home/osstest/repos/lock ']'
+ . ./cri-common
++ . ./cri-getconfig
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=ovmf
+ xenbranch=xen-unstable
+ '[' xovmf = xlinux ']'
+ linuxbranch=
+ '[' x = x ']'
+ qemuubranch=qemu-upstream-unstable
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable
+ prevxenbranch=xen-4.9-testing
+ '[' x5202e6c907e5769ac8ecb024b7a07509bdba6181 = x ']'
+ : tested/2.6.39.x
+ . ./ap-common
++ : osst...@xenbits.xen.org
+++ getconfig OsstestUpstream
+++ perl -e '
use Osstest;
readglobalconfig();
print $c{"OsstestUpstream"} or die $!;
'
++ :
++ : git://xenbits.xen.org/xen.git
++ : osst...@xenbits.xen.org:/home/xen/git/xen.git
++ : git://xenbits.xen.org/qemu-xen-traditional.git
++ : git://git.kernel.org
++ : git://git.kernel.org/pub/scm/linux/kernel/git
++ : git
++ : git://xenbits.xen.org/xtf.git
++ : osst...@xenbits.xen.org:/home/xen/git/xtf.git
++ : git://xenbits.xen.org/xtf.git
++ : git://xenbits.xen.org/libvirt.git
++ : osst...@xenbits.xen.org:/home/xen/git/libvirt.git
++ : git://xenbits.xen.org/libvirt.git
++ : git://xenbits.xen.org/osstest/rumprun.git
++ : git
++ : git://xenbits.xen.org/osstest/rumprun.git
++ : osst...@xenbits.xen.org:/home/xen/git/osstest/rumprun.git
++ : git://git.seabios.org/seabios.git
++ : osst...@xenbits.xen.org:/home/xen/git/osstest/seabios.git
++ : git://xenbits.xen.org/osstest/seabios.git
++ : https://github.com/tianocore/edk2.git
++ : osst...@xenbits.xen.org:/home/xen/git/osstest/ovmf.git
++ : 

[Xen-devel] [linux-3.18 test] 112952: trouble: blocked/broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112952 linux-3.18 real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112952/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-arm64-pvops 3 capture-logs   broken REGR. vs. 112102

Tests which are failing intermittently (not blocking):
 test-armhf-armhf-xl-credit2 5 host-ping-check-native fail in 112942 pass in 
112952
 test-armhf-armhf-libvirt 16 guest-start/debian.repeat fail in 112942 pass in 
112952
 test-amd64-amd64-xl-qemuu-debianhvm-amd64 16 guest-localmigrate/x10 fail pass 
in 112942
 test-armhf-armhf-xl-rtds  7 xen-boot   fail pass in 112942

Regressions which are regarded as allowable (not blocking):
 build-arm64   2 hosts-allocate broken REGR. vs. 112102
 build-arm64-pvops 2 hosts-allocate broken REGR. vs. 112102
 build-arm64-xsm   2 hosts-allocate broken REGR. vs. 112102

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64   3 capture-logs  broken blocked in 112102
 build-arm64-xsm   3 capture-logs  broken blocked in 112102
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop fail in 112942 blocked in 
112102
 test-amd64-i386-xl-qemuu-win7-amd64 18 guest-start/win.repeat fail in 112942 
blocked in 112102
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail in 112942 blocked in 
112102
 test-armhf-armhf-xl-rtds13 migrate-support-check fail in 112942 never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-check fail in 112942 never pass
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 112085
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112102
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112102
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail like 112102
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail like 112102
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112102
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112102
 test-amd64-amd64-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail like 112102
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 

Re: [Xen-devel] [PATCH v5 1/4] VT-d PI: track the number of vcpus on pi blocking list

2017-08-30 Thread Chao Gao
On Wed, Aug 30, 2017 at 10:00:49AM -0600, Jan Beulich wrote:
 On 16.08.17 at 07:14,  wrote:
>> @@ -100,6 +101,24 @@ void vmx_pi_per_cpu_init(unsigned int cpu)
>>  spin_lock_init(_cpu(vmx_pi_blocking, cpu).lock);
>>  }
>>  
>> +static void vmx_pi_add_vcpu(struct pi_blocking_vcpu *pbv,
>> +struct vmx_pi_blocking_vcpu *vpbv)
>> +{
>> +ASSERT(spin_is_locked(>lock));
>
>You realize this is only a very weak check for a non-recursive lock?

I just thought the lock should be held when adding one entry to the
blocking list. Do you think we should remove this check or make it
stricter?

>
>> +add_sized(>counter, 1);
>> +ASSERT(read_atomic(>counter));
>
>Why add_sized() and read_atomic() when you hold the lock?
>

In patch 3, frequent reading the counter is used to find a suitable
vcpu and we can use add_sized() and read_atomic() to avoid acquiring the
lock. In one word, the lock doesn't protect the counter.

Thanks
Chao

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


[Xen-devel] [ovmf baseline-only test] 72041: all pass

2017-08-30 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72041 ovmf real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72041/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf c1d799b915096b79b5c5d035b134ffbccc6d1469
baseline version:
 ovmf 2f208e59e4b994978a1a24affc306eb694a00327

Last test of basis72036  2017-08-29 20:17:43 Z1 days
Testing same since72041  2017-08-30 12:19:22 Z0 days1 attempts


People who touched revisions under test:
  Ard Biesheuvel 
  Bi, Dandan 
  Dandan Bi 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.xs.citrite.net
logs: /home/osstest/logs
images: /home/osstest/images

Logs, config files, etc. are available at
http://osstest.xs.citrite.net/~osstest/testlogs/logs

Test harness code can be found at
http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary


Push not applicable.


commit c1d799b915096b79b5c5d035b134ffbccc6d1469
Author: Ard Biesheuvel 
Date:   Thu Aug 24 20:41:01 2017 +0100

Omap35xxPkg: remove bogus UncachedMemoryAllocationLib dependency

Remove a false dependency on UncachedMemoryAllocationLib, and fix the
broken build while we're at it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 

commit b56397ba9f67b246fcb42b082f1465b1455f7550
Author: Ard Biesheuvel 
Date:   Thu Aug 24 20:40:10 2017 +0100

BeagleBoardPkg: remove UncachedMemoryAllocationLib resolutions

ArmDmaLib no longer depends on UncachedMemoryAllocationLib, so we can
remove the library class resolutions for it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 

commit 4b4104d87e28a56a14d89289e960a92618ce5621
Author: Ard Biesheuvel 
Date:   Thu Aug 24 20:13:10 2017 +0100

ArmPkg/ArmDmaLib: implement DmaAllocateAlignedBuffer()

Implement the new DmaLib routine that returns DMA'able buffers
at a specified minimum alignment.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 

commit deef290f95e0df80549d2a6cbd7edae104c82709
Author: Ard Biesheuvel 
Date:   Thu Aug 24 20:05:48 2017 +0100

EmbeddedPkg/DmaLib: add routine to allocate aligned buffers

DmaLib's purpose is to manage memory that is shared between the host
and DMA capable devices. In some cases, this requires a larger alignment
than page size, and we currently don't cater for that in DmaLib. So add
a variant of DmaAllocateBuffer () that takes an alignment parameter.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel 
Reviewed-by: Leif Lindholm 

commit 1696b221b15e439162cfccd6bd04132e425dd2ff
Author: Bi, Dandan 
Date:   Tue Aug 29 14:44:37 2017 +0800

MdeModulePkg/UefiHiiLib: Fix incorrect check for string length

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=681

For string opcode,when checking the valid string length,
it should exclude the Null-terminated character.
And for string in NameValue storage, need to exclude
the varname and also need to convert the Config string
length to Unicode string length.

Cc: Eric Dong 
Cc: Liming Gao 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi 
Reviewed-by: Eric Dong 

___
Xen-devel mailing list
Xen-devel@lists.xen.org

[Xen-devel] [xen-unstable-smoke test] 112967: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112967 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112967/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  4be9a177e62eaa190b0f4721dd19153993511ee3
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Failing since112957  2017-08-30 12:02:17 Z0 days6 attempts
Testing same since   112962  2017-08-30 18:05:04 Z0 days3 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 374 lines long.)

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


[Xen-devel] [xen-4.8-testing baseline-only test] 72040: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72040 xen-4.8-testing real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72040/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemut-win10-i386 16 guest-localmigrate/x10 fail REGR. vs. 
72026
 test-amd64-amd64-xl-qemuu-debianhvm-amd64 21 leak-check/check fail REGR. vs. 
72026

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64   2 hosts-allocate   broken never pass
 build-arm64-pvops 2 hosts-allocate   broken never pass
 build-arm64-xsm   2 hosts-allocate   broken never pass
 build-arm64-pvops 3 capture-logs broken never pass
 build-arm64-xsm   3 capture-logs broken never pass
 build-arm64   3 capture-logs broken never pass
 test-amd64-amd64-qemuu-nested-intel 17 debian-hvm-install/l1/l2 fail like 72026
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop  fail like 72026
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop  fail like 72026
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail like 72026
 build-amd64-prev  7 xen-build/dist-test  fail   never pass
 build-i386-prev   7 xen-build/dist-test  fail   never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 10 windows-install fail never pass
 test-amd64-amd64-xl-pvh-intel 12 guest-start  fail  never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-midway   13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-midway   14 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-pvh-amd  12 guest-start  fail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-amd64-qemuu-nested-intel 18 capture-logs/l1(18) fail never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-i386-xl-qemut-win10-i386 17 guest-stop  fail never pass
 test-amd64-i386-xl-qemuu-win10-i386 17 guest-stop  fail never pass
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail never pass

version targeted for testing:
 xen

[Xen-devel] [xen-unstable-smoke test] 112963: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112963 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112963/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  4be9a177e62eaa190b0f4721dd19153993511ee3
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Failing since112957  2017-08-30 12:02:17 Z0 days5 attempts
Testing same since   112962  2017-08-30 18:05:04 Z0 days2 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 374 lines long.)

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


[Xen-devel] [seabios test] 112951: regressions - FAIL

2017-08-30 Thread osstest service owner
flight 112951 seabios real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112951/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail REGR. vs. 
112938
 test-amd64-i386-xl-qemuu-win7-amd64 18 guest-start/win.repeat fail REGR. vs. 
112938

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass

version targeted for testing:
 seabios  ef5fdc99b771349264b4ba0aac1c654c8789386f
baseline version:
 seabios  b404a5f417cbe5593f89c79954569b0e245fb80c

Last test of basis   112938  2017-08-29 10:18:13 Z1 days
Testing same since   112951  2017-08-30 04:29:33 Z0 days1 attempts


People who touched revisions under test:
  Kevin O'Connor 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm   pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsmpass
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsmpass
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm pass
 test-amd64-amd64-qemuu-nested-amdfail
 test-amd64-i386-qemuu-rhel6hvm-amd   pass
 test-amd64-amd64-xl-qemuu-debianhvm-amd64pass
 test-amd64-i386-xl-qemuu-debianhvm-amd64 pass
 test-amd64-amd64-xl-qemuu-win7-amd64 fail
 test-amd64-i386-xl-qemuu-win7-amd64  fail
 test-amd64-amd64-xl-qemuu-ws16-amd64 fail
 test-amd64-i386-xl-qemuu-ws16-amd64  fail
 test-amd64-amd64-xl-qemuu-win10-i386 fail
 test-amd64-i386-xl-qemuu-win10-i386  fail
 test-amd64-amd64-qemuu-nested-intel  pass
 test-amd64-i386-qemuu-rhel6hvm-intel pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary


Not pushing.


commit ef5fdc99b771349264b4ba0aac1c654c8789386f
Author: Kevin O'Connor 
Date:   Tue Aug 29 14:38:19 2017 -0400

vga: Fix bug in stdvga_get_linesize()

Add required GET_GLOBAL() macro to vmode_g access.

Signed-off-by: Kevin O'Connor 

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


[Xen-devel] [xen-unstable test] 112949: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112949 xen-unstable real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112949/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-xtf-amd64-amd64-17 xen-boot fail REGR. vs. 112809

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-xsm   2 hosts-allocate  broken like 112809
 build-arm64-xsm   3 capture-logsbroken like 112809
 build-arm64-pvops 2 hosts-allocate  broken like 112809
 build-arm64-pvops 3 capture-logsbroken like 112809
 build-arm64   2 hosts-allocate  broken like 112809
 build-arm64   3 capture-logsbroken like 112809
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop  fail blocked in 112809
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112809
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112809
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 112809
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail like 112809
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail  like 112809
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112809
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112809
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass

version targeted for testing:
 xen  2cfc5fca7d7380a954e01b1f3673fe28d5cc5347
baseline version:
 xen  9053a74c08fd6abf43bb45ff932b4386de7e8510

Last test of basis   112809  2017-08-22 04:57:01 Z8 days
Failing since112841  

[Xen-devel] [xen-unstable-smoke test] 112962: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112962 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112962/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  4be9a177e62eaa190b0f4721dd19153993511ee3
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Failing since112957  2017-08-30 12:02:17 Z0 days4 attempts
Testing same since   112962  2017-08-30 18:05:04 Z0 days1 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 374 lines long.)

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


Re: [Xen-devel] [PATCH 11/13] xen/gntdev: update to new mmu_notifier semantic

2017-08-30 Thread Boris Ostrovsky
On 08/29/2017 07:54 PM, Jérôme Glisse wrote:
> Call to mmu_notifier_invalidate_page() are replaced by call to
> mmu_notifier_invalidate_range() and thus call are bracketed by
> call to mmu_notifier_invalidate_range_start()/end()
>
> Remove now useless invalidate_page callback.
>
> Signed-off-by: Jérôme Glisse 
> Cc: Konrad Rzeszutek Wilk 
> Cc: Roger Pau Monné 
> Cc: Boris Ostrovsky 
> Cc: xen-de...@lists.xenproject.org
> Cc: Kirill A. Shutemov 
> Cc: Andrew Morton 
> Cc: Linus Torvalds 
> Cc: Andrea Arcangeli 
> ---
>  drivers/xen/gntdev.c | 8 
>  1 file changed, 8 deletions(-)

Reviewed-by: Boris Ostrovsky 

I also ran a bunch of tests (mostly bringing up/tearing down various Xen
guests). Haven't seen any issues.

-boris

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


Re: [Xen-devel] [PATCH v4 39/39] arm/xen-access: Add test of xc_altp2m_change_gfn

2017-08-30 Thread Sergej Proskurin
Hi Razvan,


[...]

>> +
>> +*gfn_new = ++(xenaccess->max_gpfn);
> Unnecessary parentheses.
>

Thanks.

>> +rc = xc_domain_populate_physmap_exact(xenaccess->xc_handle, domain_id, 
>> 1, 0, 0, gfn_new);
>> +if ( rc < 0 )
>> +goto err;
>> +
>> +/* Copy content of the old gfn into the newly allocated gfn */
>> +rc = xenaccess_copy_gfn(xenaccess, domain_id, *gfn_new, gfn_old);
>> +if ( rc < 0 )
>> +goto err;
>> +
>> +rc = xc_altp2m_change_gfn(xenaccess->xc_handle, domain_id, ap2m_idx, 
>> gfn_old, *gfn_new);
>> +if ( rc < 0 )
>> +goto err;
>> +
>> +return 0;
>> +
>> +err:
>> +xc_domain_decrease_reservation_exact(xenaccess->xc_handle, domain_id, 
>> 1, 0, gfn_new);
>> +
>> +(xenaccess->max_gpfn)--;
> Here too.
>
>> +
>> +return -1;
>> +}
>> +
>> +static int xenaccess_reset_gfn(xc_interface *xch,
>> +   domid_t domain_id,
>> +   unsigned int ap2m_idx,
>> +   xen_pfn_t gfn_old,
>> +   xen_pfn_t gfn_new)
>> +{
>> +int rc;
>> +
>> +/* Reset previous state */
>> +xc_altp2m_change_gfn(xch, domain_id, ap2m_idx, gfn_old, INVALID_GFN);
>> +
>> +/* Invalidate the new gfn */
>> +xc_altp2m_change_gfn(xch, domain_id, ap2m_idx, gfn_new, INVALID_GFN);
> Do these two xc_altp2m_change_gfn() calls not require error checking?
>
>> +
>> +rc = xc_domain_decrease_reservation_exact(xch, domain_id, 1, 0, 
>> _new);
>> +if ( rc < 0 )
>> +return -1;
>> +
>> +(xenaccess->max_gpfn)--;
> Again, please remove the parentheses.
>

Thanks again. I will adjust the implementation for v5.

Cheers,
~Sergej

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


Re: [Xen-devel] [PATCH v4 29/39] x86/altp2m: Move altp2m_check to altp2m.c

2017-08-30 Thread Sergej Proskurin
Hi Razvan,


On 08/30/2017 08:42 PM, Razvan Cojocaru wrote:
> On 08/30/2017 09:32 PM, Sergej Proskurin wrote:
>> diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
>> index 42e6f09029..66f1d83d84 100644
>> --- a/xen/common/vm_event.c
>> +++ b/xen/common/vm_event.c
>> @@ -29,6 +29,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
> Any reason why this include has not happened alphabetically (it belongs
> to the  group)?

I must have missed that, thank you. I am going to fix this in v5.

Cheers,
~Sergej

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


Re: [Xen-devel] [PATCH 2/2] x86/mm: Use mfn_t for make_cr3()

2017-08-30 Thread Tim Deegan
At 13:19 +0100 on 30 Aug (1504099173), Andrew Cooper wrote:
> No functional change.
> 
> Signed-off-by: Andrew Cooper 

Acked-by: Tim Deegan 

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


[Xen-devel] [PATCH v9 2/2] x86/monitor: Notify monitor if an emulation fails.

2017-08-30 Thread Petre Pircalabu
If case of a vm_event with the emulate_flags set, if the instruction
is not implemented by the emulator, the monitor should be notified instead
of directly injecting a hw exception.
This behavior can be used to re-execute an instruction not supported by
the emulator using the real processor (e.g. altp2m) instead of just
crashing.

Signed-off-by: Petre Pircalabu 
Acked-by: Tamas K Lengyel 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 tools/libxc/include/xenctrl.h |  2 ++
 tools/libxc/xc_monitor.c  | 14 ++
 xen/arch/x86/hvm/emulate.c|  4 
 xen/arch/x86/hvm/monitor.c| 17 +
 xen/arch/x86/monitor.c| 13 +
 xen/include/asm-x86/domain.h  |  1 +
 xen/include/asm-x86/hvm/monitor.h |  1 +
 xen/include/asm-x86/monitor.h |  3 ++-
 xen/include/public/domctl.h   |  1 +
 xen/include/public/vm_event.h |  2 ++
 10 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 43151cb..1a179d9 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2028,6 +2028,8 @@ int xc_monitor_debug_exceptions(xc_interface *xch, 
domid_t domain_id,
 int xc_monitor_cpuid(xc_interface *xch, domid_t domain_id, bool enable);
 int xc_monitor_privileged_call(xc_interface *xch, domid_t domain_id,
bool enable);
+int xc_monitor_emul_unimplemented(xc_interface *xch, domid_t domain_id,
+  bool enable);
 /**
  * This function enables / disables emulation for each REP for a
  * REP-compatible instruction.
diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c
index a677820..6046680 100644
--- a/tools/libxc/xc_monitor.c
+++ b/tools/libxc/xc_monitor.c
@@ -217,6 +217,20 @@ int xc_monitor_privileged_call(xc_interface *xch, domid_t 
domain_id,
 return do_domctl(xch, );
 }
 
+int xc_monitor_emul_unimplemented(xc_interface *xch, domid_t domain_id,
+  bool enable)
+{
+DECLARE_DOMCTL;
+
+domctl.cmd = XEN_DOMCTL_monitor_op;
+domctl.domain = domain_id;
+domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE
+: XEN_DOMCTL_MONITOR_OP_DISABLE;
+domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED;
+
+return do_domctl(xch, );
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index f9f8c25..c9066bb 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -14,12 +14,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2103,6 +2105,8 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, 
unsigned int trapnr,
  */
 return;
 case X86EMUL_UNIMPLEMENTED:
+if ( hvm_monitor_emul_unimplemented() )
+return;
 /* fall-through */
 case X86EMUL_UNHANDLEABLE:
 hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", );
diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
index a7ccfc4..3551463 100644
--- a/xen/arch/x86/hvm/monitor.c
+++ b/xen/arch/x86/hvm/monitor.c
@@ -57,6 +57,23 @@ bool_t hvm_monitor_cr(unsigned int index, unsigned long 
value, unsigned long old
 return 0;
 }
 
+bool hvm_monitor_emul_unimplemented(void)
+{
+struct vcpu *curr = current;
+
+/*
+ * Send a vm_event to the monitor to signal that the current
+ * instruction couldn't be emulated.
+ */
+vm_event_request_t req = {
+.reason = VM_EVENT_REASON_EMUL_UNIMPLEMENTED,
+.vcpu_id  = curr->vcpu_id,
+};
+
+return curr->domain->arch.monitor.emul_unimplemented_enabled &&
+monitor_traps(curr, true, ) == 1;
+}
+
 void hvm_monitor_msr(unsigned int msr, uint64_t value)
 {
 struct vcpu *curr = current;
diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index 706454f..e59f1f5 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -283,6 +283,19 @@ int arch_monitor_domctl_event(struct domain *d,
 break;
 }
 
+case XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED:
+{
+bool old_status = ad->monitor.emul_unimplemented_enabled;
+
+if ( unlikely(old_status == requested_status) )
+return -EEXIST;
+
+domain_pause(d);
+ad->monitor.emul_unimplemented_enabled = requested_status;
+domain_unpause(d);
+break;
+}
+
 default:
 /*
  * Should not be reached unless arch_monitor_get_capabilities() is
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index fb8bf17..fcab8f8 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -406,6 +406,7 @@ struct arch_domain
 unsigned int 

[Xen-devel] [PATCH v9 0/2] Notify monitor when emulating an unimplemented instruction

2017-08-30 Thread Petre Pircalabu
This patchset implements a mechanism which allows XEN to send first an event
if the emulator encountered an unsupported instruction.
The monitor application can choose to mitigate the error, for example to 
singlestep
the instruction using the real processor and then resume execution of the normal
instruction flow.

This feature was tested using a modified version of XTF:
https://github.com/petrepircalabu/xen-test-framework/tree/emul_unimpl

---
Changed since v1:
  * Removed the emulation kind check when calling hvm_inject_hw_exception

Changed since v2:
  * Removed a file added by mistake

Changed since v3:
  * Removed extra stray line
  * Added the _enabled suffix to the emul_unhandleable monitor option

Changed since v4
  * Fixed return expression of hvm_monitor_emul_unhandleable handle
  monitor_traps failures.
  * Removed stray parantheses.

Changed since v5:
  * Removed unnecessary "else" when calling hvm_monitor_emul_unhandleable.
  * Added extra line in arch_monitor_domctl_event.

Changed since v6:
  * add the distinction between unimplemented instructions and emulation 
failures.
  * changed "emul_unhandleable" event name to "emul_unimplemented"

Changed since v7:
  * Add "fall-through" comments to the switch statements (coverity)
  * Added X86EMUL_UNIMPLEMENTED to X86EMUL_UNHANDLEABLE checks the in functions
  referencing x86_emulate.
  * Improved comment describing X86EMUL_UNIMPLEMENTED.

Changed since v8:
  * Removed unnecessary "fall-through" comments.
  * Added check for X86EMUL_UNIMPLEMENTED in hvm_ud_intercept.
  * add a new label 'unimplemented_insn' to accomodate the existing jumps to
  'cannot_emulate' (e.g. invoke_stub)

---

Occurences of X86EMUL_UNHANDLEABLE which were not extended to take into account 
X86EMUL_UNIMPLEMENTED:

./xen/arch/x86/x86_emulate/x86_emulate.c:898:rc = (p) ? 
X86EMUL_UNHANDLEABLE : X86EMUL_OKAY; \
Used in the fail_if macro. This macro is used to check if certain conditions 
are met while trying to emulate the instruction (e.g. fail_if(!ops->read_msr); 
).
This macro should not be modified as these conditions are not related to the 
instruction decoding and classification.

./xen/arch/x86/x86_emulate/x86_emulate.c:3429:rc = X86EMUL_UNHANDLEABLE;
./xen/arch/x86/x86_emulate/x86_emulate.c:3433:if ( rc != 
X86EMUL_UNHANDLEABLE )
./xen/arch/x86/x86_emulate/x86_emulate.c:3436:if ( (nr_reps > 1 || rc 
== X86EMUL_UNHANDLEABLE) && ops->rep_ins )
./xen/arch/x86/x86_emulate/x86_emulate.c:3439:if ( nr_reps >= 1 && rc 
== X86EMUL_UNHANDLEABLE )
./xen/arch/x86/x86_emulate/x86_emulate.c:3469:rc = X86EMUL_UNHANDLEABLE;
x86_emulate: while emulating ins %dx,%es:%edi the return code is initialized to 
X86EMUL_UNHANDLEABLE and is used to hold / check the result of various 
emulation ops (x86_emulate_ops) (read_id, rep_ins).
Should not be changed to X86EMUL_UNIMPLEMENTED as it’s not related to 
instruction decoding.

./xen/arch/x86/x86_emulate/x86_emulate.c:3474:if ( rc != 
X86EMUL_UNHANDLEABLE )
./xen/arch/x86/x86_emulate/x86_emulate.c:3477:if ( (nr_reps > 1 || rc 
== X86EMUL_UNHANDLEABLE) && ops->rep_outs )
./xen/arch/x86/x86_emulate/x86_emulate.c:3480:if ( nr_reps >= 1 && rc 
== X86EMUL_UNHANDLEABLE )
./xen/arch/x86/x86_emulate/x86_emulate.c:3756:  
_reps, ctxt)) == X86EMUL_UNHANDLEABLE) )
x86_emulate: while emulatings outs %esi,%dx the return code is initialized to 
X86EMUL_UNHANDLEABLE and is used to hold / check the result of various 
emulation ops (x86_emulate_ops) (rep_outs, write_io) and read_ulong.
Should not be changed to X86EMUL_UNIMPLEMENTED as it’s not related to 
instruction decoding.

./xen/arch/x86/x86_emulate/x86_emulate.c:3802:  
_reps, ctxt)) == X86EMUL_UNHANDLEABLE) )
x86_emulate: while emulating stos, if rep_stos returns X86EMUL_UNHANDLEABLE, 
the return value is reset to X86EMUL_OKAY. The emulation callbacks should not 
return X86EMUL_UNIMPLEMENTED as they are not used by the decoding logic of an 
instruction.
Should not be changed to X86EMUL_UNIMPLEMENTED as it’s not related to 
instruction decoding.

./xen/arch/x86/x86_emulate/x86_emulate.c:5082:else if ( rc != 
X86EMUL_UNHANDLEABLE )
x86_emulate: while emulating clzero the return value of rep_stos is check 
against X86EMUL_UNHANDLEABLE. The emulation callbacks should not return 
X86EMUL_UNIMPLEMENTED as they are not used by the decoding logic of an 
instruction.
Should not be changed to X86EMUL_UNIMPLEMENTED as it’s not related to 
instruction decoding.

./xen/arch/x86/hvm/emulate.c:170:return X86EMUL_UNHANDLEABLE;
./xen/arch/x86/hvm/emulate.c:175:return X86EMUL_UNHANDLEABLE;
hvmemul_do_io: returns X86EMUL_UNHANDLEABLE if the io_req state is invalid.
Should not be changed to X86EMUL_UNIMPLEMENTED as it’s not related to 
instruction decoding.

./xen/arch/x86/hvm/emulate.c:202:case X86EMUL_UNHANDLEABLE:
hvmemul_do_io:  The 

[Xen-devel] [PATCH v9 1/2] x86emul: New return code for unimplemented instruction

2017-08-30 Thread Petre Pircalabu
Enforce the distinction between an instruction not implemented by the
emulator and the failure to emulate that instruction by defining a new
return code, X86EMUL_UNIMPLEMENTED.

This value should only be used by the core emulator if it fails to decode
the current instruction, and not by any of the x86_emulate_ops
callbacks.

Signed-off-by: Petre Pircalabu 
Reviewed-by: Paul Durrant 
---
 xen/arch/x86/hvm/emulate.c |  3 +++
 xen/arch/x86/hvm/hvm.c |  1 +
 xen/arch/x86/hvm/io.c  |  1 +
 xen/arch/x86/hvm/vmx/realmode.c|  2 +-
 xen/arch/x86/mm/shadow/multi.c |  2 +-
 xen/arch/x86/x86_emulate/x86_emulate.c | 35 ++
 xen/arch/x86/x86_emulate/x86_emulate.h |  6 ++
 7 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 64454c7..f9f8c25 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2044,6 +2044,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long 
gla)
 switch ( rc )
 {
 case X86EMUL_UNHANDLEABLE:
+case X86EMUL_UNIMPLEMENTED:
 hvm_dump_emulation_state(XENLOG_G_WARNING, "MMCFG", );
 break;
 case X86EMUL_EXCEPTION:
@@ -2101,6 +2102,8 @@ void hvm_emulate_one_vm_event(enum emul_kind kind, 
unsigned int trapnr,
  * consistent with X86EMUL_RETRY.
  */
 return;
+case X86EMUL_UNIMPLEMENTED:
+/* fall-through */
 case X86EMUL_UNHANDLEABLE:
 hvm_dump_emulation_state(XENLOG_G_DEBUG, "Mem event", );
 hvm_inject_hw_exception(trapnr, errcode);
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 6cb903d..ea2812c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3695,6 +3695,7 @@ void hvm_ud_intercept(struct cpu_user_regs *regs)
 switch ( hvm_emulate_one() )
 {
 case X86EMUL_UNHANDLEABLE:
+case X86EMUL_UNIMPLEMENTED:
 hvm_inject_hw_exception(TRAP_invalid_op, X86_EVENT_NO_EC);
 break;
 case X86EMUL_EXCEPTION:
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index bf41954..984db21 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -96,6 +96,7 @@ bool hvm_emulate_one_insn(hvm_emulate_validate_t *validate, 
const char *descr)
 switch ( rc )
 {
 case X86EMUL_UNHANDLEABLE:
+case X86EMUL_UNIMPLEMENTED:
 hvm_dump_emulation_state(XENLOG_G_WARNING, descr, );
 return false;
 
diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c
index 11bde58..fdbbee2 100644
--- a/xen/arch/x86/hvm/vmx/realmode.c
+++ b/xen/arch/x86/hvm/vmx/realmode.c
@@ -106,7 +106,7 @@ void vmx_realmode_emulate_one(struct hvm_emulate_ctxt 
*hvmemul_ctxt)
 if ( hvm_vcpu_io_need_completion(vio) || vio->mmio_retry )
 vio->io_completion = HVMIO_realmode_completion;
 
-if ( rc == X86EMUL_UNHANDLEABLE )
+if ( rc == X86EMUL_UNHANDLEABLE || rc == X86EMUL_UNIMPLEMENTED )
 {
 gdprintk(XENLOG_ERR, "Failed to emulate insn.\n");
 goto fail;
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index c5c0af8..15727a2 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -3488,7 +3488,7 @@ static int sh_page_fault(struct vcpu *v,
  * would be a good unshadow hint. If we *do* decide to unshadow-on-fault
  * then it must be 'failable': we cannot require the unshadow to succeed.
  */
-if ( r == X86EMUL_UNHANDLEABLE )
+if ( r == X86EMUL_UNHANDLEABLE || r == X86EMUL_UNIMPLEMENTED )
 {
 perfc_incr(shadow_fault_emulate_failed);
 #if SHADOW_OPTIMIZATIONS & SHOPT_FAST_EMULATION
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c 
b/xen/arch/x86/x86_emulate/x86_emulate.c
index 2201852..242b0af 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -2577,7 +2577,7 @@ x86_decode(
 d = twobyte_table[0x3a].desc;
 break;
 default:
-rc = X86EMUL_UNHANDLEABLE;
+rc = X86EMUL_UNIMPLEMENTED;
 goto done;
 }
 }
@@ -2591,7 +2591,7 @@ x86_decode(
 }
 else
 {
-rc = X86EMUL_UNHANDLEABLE;
+rc = X86EMUL_UNIMPLEMENTED;
 goto done;
 }
 
@@ -2871,7 +2871,7 @@ x86_decode(
 
 default:
 ASSERT_UNREACHABLE();
-return X86EMUL_UNHANDLEABLE;
+return X86EMUL_UNIMPLEMENTED;
 }
 
 if ( ea.type == OP_MEM )
@@ -4183,7 +4183,7 @@ x86_emulate(
 break;
 case 4: /* fldenv - TODO */
 state->fpu_ctrl = true;
-goto cannot_emulate;
+goto unimplemented_insn;
 

Re: [Xen-devel] [PATCH v4 39/39] arm/xen-access: Add test of xc_altp2m_change_gfn

2017-08-30 Thread Razvan Cojocaru
On 08/30/2017 09:32 PM, Sergej Proskurin wrote:
> This commit extends xen-access by a simple test of the functionality
> provided by "xc_altp2m_change_gfn". The idea is to dynamically remap a
> trapping gfn to another mfn, which holds the same content as the
> original mfn. On success, the guest will continue to run. Subsequent
> altp2m access violations will trap into Xen and be forced by xen-access
> to switch to the default view (altp2m[0]) as before. The introduced test
> can be invoked by providing the argument "altp2m_remap".
> 
> Signed-off-by: Sergej Proskurin 
> ---
> Cc: Razvan Cojocaru 
> Cc: Tamas K Lengyel 
> Cc: Ian Jackson 
> Cc: Wei Liu 
> ---
> v3: Cosmetic fixes in "xenaccess_copy_gfn" and "xenaccess_change_gfn".
> 
> Added munmap in "copy_gfn" in the second error case.
> 
> Added option "altp2m_remap" selecting the altp2m-remap test.
> 
> v4: Dropped the COMPAT API for mapping foreign memory. Instead, we use the
> stable library xenforeignmemory.
> 
> Dropped the use of xc_domain_increase_reservation_exact as we do not
> need to increase the domain's physical memory. Otherwise, remapping
> a page via altp2m would become visible to the guest itself. As long
> as we have additional shadow-memory for the guest domain, we do not
> need to reserve any additional memory.
> ---
>  tools/tests/xen-access/Makefile |   2 +-
>  tools/tests/xen-access/xen-access.c | 182 
> +++-
>  2 files changed, 179 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile
> index e11f639ccf..ab195e233f 100644
> --- a/tools/tests/xen-access/Makefile
> +++ b/tools/tests/xen-access/Makefile
> @@ -26,6 +26,6 @@ clean:
>  distclean: clean
>  
>  xen-access: xen-access.o Makefile
> - $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(LDLIBS_libxenevtchn)
> + $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
> $(LDLIBS_libxenevtchn) $(LDLIBS_libxenforeignmemory)
>  
>  -include $(DEPS)
> diff --git a/tools/tests/xen-access/xen-access.c 
> b/tools/tests/xen-access/xen-access.c
> index 481337cacd..f9b9fb6bbf 100644
> --- a/tools/tests/xen-access/xen-access.c
> +++ b/tools/tests/xen-access/xen-access.c
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #if defined(__arm__) || defined(__aarch64__)
>  #include 
> @@ -49,6 +50,8 @@
>  #define START_PFN 0ULL
>  #endif
>  
> +#define INVALID_GFN ~(0UL)
> +
>  #define DPRINTF(a, b...) fprintf(stderr, a, ## b)
>  #define ERROR(a, b...) fprintf(stderr, a "\n", ## b)
>  #define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno))
> @@ -76,12 +79,19 @@ typedef struct vm_event {
>  typedef struct xenaccess {
>  xc_interface *xc_handle;
>  
> +xenforeignmemory_handle *fmem;
> +
>  xen_pfn_t max_gpfn;
>  
>  vm_event_t vm_event;
> +
> +unsigned int ap2m_idx;
> +xen_pfn_t gfn_old;
> +xen_pfn_t gfn_new;
>  } xenaccess_t;
>  
>  static int interrupted;
> +static int gfn_changed = 0;
>  bool evtchn_bind = 0, evtchn_open = 0, mem_access_enable = 0;
>  
>  static void close_handler(int sig)
> @@ -89,6 +99,104 @@ static void close_handler(int sig)
>  interrupted = sig;
>  }
>  
> +static int xenaccess_copy_gfn(xenaccess_t *xenaccess,
> +  domid_t domain_id,
> +  xen_pfn_t dst_gfn,
> +  xen_pfn_t src_gfn)
> +{
> +void *src_vaddr = NULL;
> +void *dst_vaddr = NULL;
> +
> +src_vaddr = xenforeignmemory_map(xenaccess->fmem, domain_id, PROT_READ,
> + 1, _gfn, NULL);
> +if ( src_vaddr == NULL )
> +return -1;
> +
> +dst_vaddr = xenforeignmemory_map(xenaccess->fmem, domain_id, PROT_WRITE,
> + 1, _gfn, NULL> +if ( dst_vaddr 
> == NULL )
> +{
> +munmap(src_vaddr, XC_PAGE_SIZE);
> +return -1;
> +}
> +
> +memcpy(dst_vaddr, src_vaddr, XC_PAGE_SIZE);
> +
> +xenforeignmemory_unmap(xenaccess->fmem, src_vaddr, 1);
> +xenforeignmemory_unmap(xenaccess->fmem, dst_vaddr, 1);
> +
> +return 0;
> +}
> +
> +/*
> + * This function allocates and populates a page in the guest's physmap that 
> is
> + * subsequently filled with contents of the trapping address. Finally, 
> through
> + * the invocation of xc_altp2m_change_gfn, the altp2m subsystem changes the 
> gfn
> + * to mfn mapping of the target altp2m view.
> + */
> +static int xenaccess_change_gfn(xenaccess_t *xenaccess,
> +domid_t domain_id,
> +unsigned int ap2m_idx,
> +xen_pfn_t gfn_old,
> +xen_pfn_t *gfn_new)
> +{
> +int rc;
> +
> +/*
> + 

Re: [Xen-devel] [PATCH v4 29/39] x86/altp2m: Move altp2m_check to altp2m.c

2017-08-30 Thread Razvan Cojocaru
On 08/30/2017 09:32 PM, Sergej Proskurin wrote:
> diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
> index 42e6f09029..66f1d83d84 100644
> --- a/xen/common/vm_event.c
> +++ b/xen/common/vm_event.c
> @@ -29,6 +29,7 @@
>  #include 
>  #include 
>  #include 
> +#include 

Any reason why this include has not happened alphabetically (it belongs
to the  group)?


Thanks,
Razvan

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


[Xen-devel] [PATCH v4 04/39] arm/p2m: Add HVMOP_altp2m_get_domain_state

2017-08-30 Thread Sergej Proskurin
This commit adopts the x86 HVMOP_altp2m_get_domain_state implementation.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Removed the "altp2m_enabled" check in HVMOP_altp2m_get_domain_state
case as it has been moved in front of the switch statement in
"do_altp2m_op".

Removed the macro "altp2m_enabled". Instead, check directly for the
HVM_PARAM_ALTP2M param in d->arch.hvm_domain.
---
 xen/arch/arm/hvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 6f5f9b41ac..43b8352cb7 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -85,7 +85,8 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 switch ( a.cmd )
 {
 case HVMOP_altp2m_get_domain_state:
-rc = -EOPNOTSUPP;
+a.u.domain_state.state = altp2m_active(d);
+rc = __copy_to_guest(arg, , 1) ? -EFAULT : 0;
 break;
 
 case HVMOP_altp2m_set_domain_state:
-- 
2.13.3


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


[Xen-devel] [PATCH v4 22/39] arm/p2m: Make p2m_mem_access_check ready for altp2m

2017-08-30 Thread Sergej Proskurin
This commit extends the function "p2m_mem_access_check" and
"p2m_mem_access_check_and_get_page" to consider altp2m. The function
"p2m_mem_access_check_and_get_page" needs to translate the gva upon the
hostp2m's vttbr, as it contains all valid mappings while the currently
active altp2m view might not have the required gva mapping yet.

Also, the new implementation fills the request buffer to hold
altp2m-related information.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Extended the function "p2m_mem_access_check_and_get_page" to
consider altp2m. Similar to "get_page_from_gva", the function
"p2m_mem_access_check_and_get_page" needs to translate the gva upon
the hostp2m's vttbr. Although, the function "gva_to_ipa" (called in
"p2m_mem_access_check_and_get_page") performs a stage 1 table walk,
it will access page tables residing in memory. Accesses to this
memory are controlled by the underlying 2nd stage translation table
and hence require the original mappings of the hostp2m.

v4: Cosmetic fixes.

Initialized the variable "ipa" in the function
"p2m_mem_access_check_and_get_page" to satisfy compiler warnings.
---
 xen/arch/arm/mem_access.c | 33 +
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
index 5bc28db8ff..ebc3a86af3 100644
--- a/xen/arch/arm/mem_access.c
+++ b/xen/arch/arm/mem_access.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -108,9 +109,31 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned 
long flag,
 xenmem_access_t xma;
 p2m_type_t t;
 struct page_info *page = NULL;
-struct p2m_domain *p2m = p2m_get_hostp2m(v->domain);
+struct domain *d = v->domain;
+struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+/*
+ * If altp2m is active, we need to translate the gva upon the hostp2m's
+ * vttbr, as it contains all valid mappings while the currently active
+ * altp2m view might not have the required gva mapping yet. Although, the
+ * function gva_to_ipa performs a stage 1 table walk, it will access page
+ * tables residing in memory. Accesses to this memory are controlled by the
+ * underlying 2nd stage translation table and hence require the original
+ * mappings of the hostp2m.
+ */
+if ( unlikely(altp2m_active(d)) )
+{
+unsigned long flags = 0;
+uint64_t ovttbr = READ_SYSREG64(VTTBR_EL2);
+
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
 
-rc = gva_to_ipa(gva, , flag);
+rc = gva_to_ipa(gva, , flag);
+
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
+}
+else
+rc = gva_to_ipa(gva, , flag);
 
 /*
  * In case mem_access is active, hardware-based gva_to_ipa translation
@@ -225,13 +248,15 @@ bool_t p2m_mem_access_check(paddr_t gpa, vaddr_t gla, 
const struct npfec npfec)
 xenmem_access_t xma;
 vm_event_request_t *req;
 struct vcpu *v = current;
-struct p2m_domain *p2m = p2m_get_hostp2m(v->domain);
+struct p2m_domain *p2m = p2m_get_active_p2m(v);
 
 /* Mem_access is not in use. */
 if ( !p2m->mem_access_enabled )
 return true;
 
-rc = p2m_get_mem_access(v->domain, gaddr_to_gfn(gpa), );
+p2m_read_lock(p2m);
+rc = __p2m_get_mem_access(p2m, _gfn(paddr_to_pfn(gpa)), );
+p2m_read_unlock(p2m);
 if ( rc )
 return true;
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 39/39] arm/xen-access: Add test of xc_altp2m_change_gfn

2017-08-30 Thread Sergej Proskurin
This commit extends xen-access by a simple test of the functionality
provided by "xc_altp2m_change_gfn". The idea is to dynamically remap a
trapping gfn to another mfn, which holds the same content as the
original mfn. On success, the guest will continue to run. Subsequent
altp2m access violations will trap into Xen and be forced by xen-access
to switch to the default view (altp2m[0]) as before. The introduced test
can be invoked by providing the argument "altp2m_remap".

Signed-off-by: Sergej Proskurin 
---
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
Cc: Ian Jackson 
Cc: Wei Liu 
---
v3: Cosmetic fixes in "xenaccess_copy_gfn" and "xenaccess_change_gfn".

Added munmap in "copy_gfn" in the second error case.

Added option "altp2m_remap" selecting the altp2m-remap test.

v4: Dropped the COMPAT API for mapping foreign memory. Instead, we use the
stable library xenforeignmemory.

Dropped the use of xc_domain_increase_reservation_exact as we do not
need to increase the domain's physical memory. Otherwise, remapping
a page via altp2m would become visible to the guest itself. As long
as we have additional shadow-memory for the guest domain, we do not
need to reserve any additional memory.
---
 tools/tests/xen-access/Makefile |   2 +-
 tools/tests/xen-access/xen-access.c | 182 +++-
 2 files changed, 179 insertions(+), 5 deletions(-)

diff --git a/tools/tests/xen-access/Makefile b/tools/tests/xen-access/Makefile
index e11f639ccf..ab195e233f 100644
--- a/tools/tests/xen-access/Makefile
+++ b/tools/tests/xen-access/Makefile
@@ -26,6 +26,6 @@ clean:
 distclean: clean
 
 xen-access: xen-access.o Makefile
-   $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
$(LDLIBS_libxenevtchn)
+   $(CC) -o $@ $< $(LDFLAGS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) 
$(LDLIBS_libxenevtchn) $(LDLIBS_libxenforeignmemory)
 
 -include $(DEPS)
diff --git a/tools/tests/xen-access/xen-access.c 
b/tools/tests/xen-access/xen-access.c
index 481337cacd..f9b9fb6bbf 100644
--- a/tools/tests/xen-access/xen-access.c
+++ b/tools/tests/xen-access/xen-access.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if defined(__arm__) || defined(__aarch64__)
 #include 
@@ -49,6 +50,8 @@
 #define START_PFN 0ULL
 #endif
 
+#define INVALID_GFN ~(0UL)
+
 #define DPRINTF(a, b...) fprintf(stderr, a, ## b)
 #define ERROR(a, b...) fprintf(stderr, a "\n", ## b)
 #define PERROR(a, b...) fprintf(stderr, a ": %s\n", ## b, strerror(errno))
@@ -76,12 +79,19 @@ typedef struct vm_event {
 typedef struct xenaccess {
 xc_interface *xc_handle;
 
+xenforeignmemory_handle *fmem;
+
 xen_pfn_t max_gpfn;
 
 vm_event_t vm_event;
+
+unsigned int ap2m_idx;
+xen_pfn_t gfn_old;
+xen_pfn_t gfn_new;
 } xenaccess_t;
 
 static int interrupted;
+static int gfn_changed = 0;
 bool evtchn_bind = 0, evtchn_open = 0, mem_access_enable = 0;
 
 static void close_handler(int sig)
@@ -89,6 +99,104 @@ static void close_handler(int sig)
 interrupted = sig;
 }
 
+static int xenaccess_copy_gfn(xenaccess_t *xenaccess,
+  domid_t domain_id,
+  xen_pfn_t dst_gfn,
+  xen_pfn_t src_gfn)
+{
+void *src_vaddr = NULL;
+void *dst_vaddr = NULL;
+
+src_vaddr = xenforeignmemory_map(xenaccess->fmem, domain_id, PROT_READ,
+ 1, _gfn, NULL);
+if ( src_vaddr == NULL )
+return -1;
+
+dst_vaddr = xenforeignmemory_map(xenaccess->fmem, domain_id, PROT_WRITE,
+ 1, _gfn, NULL);
+if ( dst_vaddr == NULL )
+{
+munmap(src_vaddr, XC_PAGE_SIZE);
+return -1;
+}
+
+memcpy(dst_vaddr, src_vaddr, XC_PAGE_SIZE);
+
+xenforeignmemory_unmap(xenaccess->fmem, src_vaddr, 1);
+xenforeignmemory_unmap(xenaccess->fmem, dst_vaddr, 1);
+
+return 0;
+}
+
+/*
+ * This function allocates and populates a page in the guest's physmap that is
+ * subsequently filled with contents of the trapping address. Finally, through
+ * the invocation of xc_altp2m_change_gfn, the altp2m subsystem changes the gfn
+ * to mfn mapping of the target altp2m view.
+ */
+static int xenaccess_change_gfn(xenaccess_t *xenaccess,
+domid_t domain_id,
+unsigned int ap2m_idx,
+xen_pfn_t gfn_old,
+xen_pfn_t *gfn_new)
+{
+int rc;
+
+/*
+ * We perform this function only once as it is intended to be used for
+ * testing and demonstration purposes. Thus, we signalize that further
+ * altp2m-related traps will not change trapping gfn's.
+ */
+gfn_changed = 1;
+
+*gfn_new = ++(xenaccess->max_gpfn);
+
+rc = 

[Xen-devel] [PATCH v4 07/39] arm/p2m: Move hostp2m init/teardown to individual functions

2017-08-30 Thread Sergej Proskurin
This commit pulls out generic init/teardown functionality out of
"p2m_init" and "p2m_teardown" into "p2m_init_one", "p2m_teardown_one",
and "p2m_flush_table" functions.  This allows our future implementation
to reuse existing code for the initialization/teardown of altp2m views.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Added the function p2m_flush_table to the previous version.

v3: Removed struct vttbr.

Moved define INVALID_VTTBR to p2m.h.

Exported function prototypes of "p2m_flush_table", "p2m_init_one",
and "p2m_teardown_one" in p2m.h.

Extended the function "p2m_flush_table" by additionally resetting
the fields lowest_mapped_gfn and max_mapped_gfn.

Added a "p2m_flush_tlb" call in "p2m_flush_table". On altp2m reset
in function "altp2m_reset", it is important to flush the TLBs after
clearing the root table pages and before clearing the intermediate
altp2m page tables to prevent illegal access to stalled TLB entries
on currently active VCPUs.

Added a check checking whether p2m->root is NULL in p2m_flush_table.

Renamed the function "p2m_free_one" to "p2m_teardown_one".

Removed resetting p2m->vttbr in "p2m_teardown_one", as it the p2m
will be destroyed afterwards.

Moved call to "p2m_alloc_table" back to "p2m_init_one".

Moved the introduction of the type p2m_class_t out of this patch.

Moved the backpointer to the struct domain out of the struct
p2m_domain.

v4: Replaced the former use of clear_and_clean_page in p2m_flush_table
by a routine that invalidates every p2m entry atomically. This
avoids inconsistencies on CPUs that continue to use the views that
are to be flushed (e.g., see altp2m_reset).

Removed unnecessary initializations in the functions "p2m_init_one"
and "p2m_teardown_one".

Removed the define INVALID_VTTBR as it is not used any more.

Cosmetic fixes.
---
 xen/arch/arm/p2m.c| 74 +++
 xen/include/asm-arm/p2m.h |  9 ++
 2 files changed, 78 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 5e86368010..3a1a38e7af 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1203,27 +1203,65 @@ static void p2m_free_vmid(struct domain *d)
 spin_unlock(_alloc_lock);
 }
 
-void p2m_teardown(struct domain *d)
+/* Reset this p2m table to be empty. */
+void p2m_flush_table(struct p2m_domain *p2m)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 struct page_info *pg;
+unsigned int i, j;
+lpae_t *table;
+
+if ( p2m->root )
+{
+/* Clear all concatenated root level pages. */
+for ( i = 0; i < P2M_ROOT_PAGES; i++ )
+{
+table = __map_domain_page(p2m->root + i);
+
+for ( j = 0; j < LPAE_ENTRIES; j++ )
+{
+lpae_t *entry = table + j;
+
+/*
+ * Individual altp2m views can be flushed, whilst altp2m is
+ * active. To avoid inconsistencies on CPUs that continue to
+ * use the views to be flushed (e.g., see altp2m_reset), we
+ * must remove every p2m entry atomically.
+ */
+p2m_remove_pte(entry, p2m->clean_pte);
+}
+}
+}
+
+/*
+ * Flush TLBs before releasing remaining intermediate p2m page tables to
+ * prevent illegal access to stalled TLB entries.
+ */
+p2m_flush_tlb(p2m);
 
+/* Free the rest of the trie pages back to the paging pool. */
 while ( (pg = page_list_remove_head(>pages)) )
 free_domheap_page(pg);
 
+p2m->lowest_mapped_gfn = INVALID_GFN;
+p2m->max_mapped_gfn = _gfn(0);
+}
+
+void p2m_teardown_one(struct p2m_domain *p2m)
+{
+p2m_flush_table(p2m);
+
 if ( p2m->root )
 free_domheap_pages(p2m->root, P2M_ROOT_ORDER);
 
 p2m->root = NULL;
 
-p2m_free_vmid(d);
+p2m_free_vmid(p2m->domain);
 
 radix_tree_destroy(>mem_access_settings, NULL);
 }
 
-int p2m_init(struct domain *d)
+int p2m_init_one(struct domain *d, struct p2m_domain *p2m)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 int rc = 0;
 unsigned int cpu;
 
@@ -1268,6 +1306,32 @@ int p2m_init(struct domain *d)
 return rc;
 }
 
+static void p2m_teardown_hostp2m(struct domain *d)
+{
+struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+p2m_teardown_one(p2m);
+}
+
+void p2m_teardown(struct domain *d)
+{
+p2m_teardown_hostp2m(d);
+}
+
+static int p2m_init_hostp2m(struct domain *d)
+{
+struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+p2m->p2m_class = p2m_host;
+
+return p2m_init_one(d, p2m);
+}
+
+int p2m_init(struct domain *d)
+{
+return p2m_init_hostp2m(d);
+}
+
 /*
  * The function will go through the p2m and remove page reference when it
  * is required. The mapping will be removed from the 

[Xen-devel] [PATCH v4 27/39] arm/p2m: Add altp2m_propagate_change

2017-08-30 Thread Sergej Proskurin
This commit introduces the function "altp2m_propagate_change" that is
responsible to propagate changes applied to the host's p2m to a specific
or even all altp2m views. In this way, Xen can in-/decrease the guest's
physmem at run-time without leaving the altp2m views with
stalled/invalid entries.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Cosmetic fixes.

Changed the locking mechanism to "p2m_write_lock" inside the
function "altp2m_reset".

Removed TLB flushing and resetting of the max_mapped_gfn
lowest_mapped_gfn fields within the function "altp2m_reset". These
operations are performed in the function "p2m_flush_table".

Protected altp2m_active(d) check in "altp2m_propagate_change".

The function "altp2m_propagate_change" now decides whether an entry
needs to be dropped out of the altp2m view only if the smfn value
equals INVALID_MFN.

Extended the function "altp2m_propagate_change" so that it returns
an int value to the caller. Also, the function "apply_p2m_changes"
checks the return value and fails the entire operation on error.

Moved the funtion "modify_altp2m_range" out of this commit.

v4: Use the functions "p2m_(set|get)_entry" instead of the helpers
"p2m_lookup_attr" and "modify_altp2m_entry".
---
 xen/arch/arm/altp2m.c| 84 
 xen/arch/arm/p2m.c   |  4 +++
 xen/include/asm-arm/altp2m.h |  8 +
 3 files changed, 96 insertions(+)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 8c3212780a..4883b1323b 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -123,6 +123,90 @@ int altp2m_set_mem_access(struct domain *d,
 return rc;
 }
 
+static inline void altp2m_reset(struct p2m_domain *p2m)
+{
+p2m_write_lock(p2m);
+p2m_flush_table(p2m);
+p2m_write_unlock(p2m);
+}
+
+int altp2m_propagate_change(struct domain *d,
+gfn_t sgfn,
+unsigned int page_order,
+mfn_t smfn,
+p2m_type_t p2mt,
+p2m_access_t p2ma)
+{
+int rc = 0;
+unsigned int i;
+unsigned int reset_count = 0;
+unsigned int last_reset_idx = ~0;
+struct p2m_domain *p2m;
+mfn_t m;
+
+altp2m_lock(d);
+
+if ( !altp2m_active(d) )
+goto out;
+
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+p2m = d->arch.altp2m_p2m[i];
+
+if ( p2m == NULL )
+continue;
+
+/*
+ * Get the altp2m mapping. If the smfn has not been dropped, a valid
+ * altp2m mapping needs to be changed/modified accordingly.
+ */
+p2m_read_lock(p2m);
+m = p2m_get_entry(p2m, sgfn, NULL, NULL, NULL);
+p2m_read_unlock(p2m);
+
+/* Check for a dropped page that may impact this altp2m. */
+if ( mfn_eq(smfn, INVALID_MFN) &&
+ (gfn_x(sgfn) >= gfn_x(p2m->lowest_mapped_gfn)) &&
+ (gfn_x(sgfn) <= gfn_x(p2m->max_mapped_gfn)) )
+{
+if ( !reset_count++ )
+{
+altp2m_reset(p2m);
+last_reset_idx = i;
+}
+else
+{
+/* At least 2 altp2m's impacted, so reset everything. */
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+p2m = d->arch.altp2m_p2m[i];
+
+if ( i == last_reset_idx || p2m == NULL )
+continue;
+
+altp2m_reset(p2m);
+}
+goto out;
+}
+}
+else if ( !mfn_eq(m, INVALID_MFN) )
+{
+/* Align the gfn and mfn to the given pager order. */
+sgfn = _gfn(gfn_x(sgfn) & ~((1UL << page_order) - 1));
+smfn = _mfn(mfn_x(smfn) & ~((1UL << page_order) - 1));
+
+p2m_write_lock(p2m);
+rc = p2m_set_entry(p2m, sgfn, (1UL << page_order), smfn, p2mt, 
p2ma);
+p2m_write_unlock(p2m);
+}
+}
+
+out:
+altp2m_unlock(d);
+
+return rc;
+}
+
 static void altp2m_vcpu_reset(struct vcpu *v)
 {
 v->arch.ap2m_idx = INVALID_ALTP2M;
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index e9274c74a8..dcf7be6439 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -958,6 +958,10 @@ static int __p2m_set_entry(struct p2m_domain *p2m,
 else
 rc = 0;
 
+/* Update all affected altp2m views if necessary. */
+if ( p2m_is_hostp2m(p2m) )
+rc = altp2m_propagate_change(p2m->domain, sgfn, page_order, smfn, t, 
a);
+
 out:
 unmap_domain_page(table);
 
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index f8e772f120..3e418cb0f0 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -80,4 +80,12 @@ int 

[Xen-devel] [PATCH v4 17/39] arm/p2m: Add HVMOP_altp2m_switch_p2m

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Extended the function "altp2m_switch_domain_altp2m_by_id" so that if
the guest domain indirectly calles this function, the current vcpu also
changes the altp2m view without performing an explicit context switch.

Exchanged the check "altp2m_vttbr[idx] == INVALID_VTTBR" for
"altp2m_p2m[idx] == NULL" in "altp2m_switch_domain_altp2m_by_id".

v4: ARM supports an external-only interface to the altp2m subsystem,
i.e, the guest does not have access to altp2m. Thus, we don't have
to consider that the current vcpu will not switch its context in the
function "p2m_restore_state". For this reason, we do not check for
whether we are working on the current vcpu in the function
altp2m_switch_domain_altp2m_by_id. If the current guest access
restriction to the altp2m subsystem should change in the future, we
have to update VTTBR_EL2 directly.

Cosmetic fixes.
---
 xen/arch/arm/altp2m.c| 45 
 xen/arch/arm/hvm.c   |  2 +-
 xen/include/asm-arm/altp2m.h |  4 
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 1128e1af16..9a2cf5a018 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -32,6 +32,51 @@ struct p2m_domain *altp2m_get_altp2m(struct vcpu *v)
 return v->domain->arch.altp2m_p2m[idx];
 }
 
+int altp2m_switch_domain_altp2m_by_id(struct domain *d, unsigned int idx)
+{
+struct vcpu *v;
+int rc = -EINVAL;
+
+if ( idx >= MAX_ALTP2M )
+return rc;
+
+domain_pause_except_self(d);
+
+altp2m_lock(d);
+
+if ( d->arch.altp2m_p2m[idx] != NULL )
+{
+for_each_vcpu( d, v )
+{
+if ( idx == v->arch.ap2m_idx )
+continue;
+
+atomic_dec(_get_altp2m(v)->active_vcpus);
+v->arch.ap2m_idx = idx;
+atomic_inc(_get_altp2m(v)->active_vcpus);
+
+/*
+ * ARM supports an external-only interface to the altp2m subsystem,
+ * i.e, the guest does not have access to altp2m. Thus, we don't
+ * have to consider that the current vcpu will not switch its
+ * context in the function "p2m_restore_state".
+ *
+ * XXX: If the current guest access restriction to the altp2m
+ * subsystem should change in the future, we have to update
+ * VTTBR_EL2 directly.
+ */
+}
+
+rc = 0;
+}
+
+altp2m_unlock(d);
+
+domain_unpause_except_self(d);
+
+return rc;
+}
+
 static void altp2m_vcpu_reset(struct vcpu *v)
 {
 v->arch.ap2m_idx = INVALID_ALTP2M;
diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 4bf2f28a1a..9bddc7e17e 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -135,7 +135,7 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 break;
 
 case HVMOP_altp2m_switch_p2m:
-rc = -EOPNOTSUPP;
+rc = altp2m_switch_domain_altp2m_by_id(d, a.u.view.view);
 break;
 
 case HVMOP_altp2m_set_mem_access:
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 778c6c4f12..d59f704489 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -49,6 +49,10 @@ void altp2m_vcpu_destroy(struct vcpu *v);
 /* Get current alternate p2m table. */
 struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
 
+/* Switch alternate p2m for entire domain */
+int altp2m_switch_domain_altp2m_by_id(struct domain *d,
+  unsigned int idx);
+
 /* Make a specific alternate p2m valid. */
 int altp2m_init_by_id(struct domain *d,
   unsigned int idx);
-- 
2.13.3


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


[Xen-devel] [PATCH v4 28/39] altp2m: Rename p2m_altp2m_check to altp2m_check

2017-08-30 Thread Sergej Proskurin
In this commit, we rename the function "p2m_altp2m_check" to
"altp2m_check".  This is a preparation measure for the following commit
which moves the renamed function "altp2m_check" from p2m.c to altp2m.c
in order to group all altp2m-related functions to one spot (which is
altp2m.c). The reason for modifying the function's name is due the
association of the function with the associated .c file.

Signed-off-by: Sergej Proskurin 
---
Cc: Jan Beulich 
Cc: Andrew Cooper 
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v4: In this commit, we have pulled the renaming of the function
"p2m_altp2m_check" out of the previous commit "altp2m: Introduce
altp2m_switch_vcpu_altp2m_by_id"
---
 xen/arch/x86/mm/p2m.c | 2 +-
 xen/common/vm_event.c | 2 +-
 xen/include/asm-arm/p2m.h | 2 +-
 xen/include/asm-x86/p2m.h | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index e8a57d118c..d5038ed66b 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1687,7 +1687,7 @@ void p2m_mem_paging_resume(struct domain *d, 
vm_event_response_t *rsp)
 }
 }
 
-void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
+void altp2m_check(struct vcpu *v, uint16_t idx)
 {
 if ( altp2m_active(v->domain) )
 p2m_switch_vcpu_altp2m_by_id(v, idx);
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 9291db61c5..42e6f09029 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -418,7 +418,7 @@ void vm_event_resume(struct domain *d, struct 
vm_event_domain *ved)
 
 /* Check for altp2m switch */
 if ( rsp.flags & VM_EVENT_FLAG_ALTERNATE_P2M )
-p2m_altp2m_check(v, rsp.altp2m_idx);
+altp2m_check(v, rsp.altp2m_idx);
 
 if ( rsp.flags & VM_EVENT_FLAG_SET_REGISTERS )
 vm_event_set_registers(v, );
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index d3467daacf..5564473e26 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -186,7 +186,7 @@ typedef enum {
  p2m_to_mask(p2m_map_foreign)))
 
 static inline
-void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
+void altp2m_check(struct vcpu *v, uint16_t idx)
 {
 /* Not supported on ARM. */
 }
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 6395e8fd1d..d1cc65f86d 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -804,7 +804,7 @@ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu 
*v)
 bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx);
 
 /* Check to see if vcpu should be switched to a different p2m. */
-void p2m_altp2m_check(struct vcpu *v, uint16_t idx);
+void altp2m_check(struct vcpu *v, uint16_t idx);
 
 /* Flush all the alternate p2m's for a domain */
 void p2m_flush_altp2m(struct domain *d);
-- 
2.13.3


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


[Xen-devel] [PATCH v4 30/39] arm/altp2m: Move altp2m_check to altp2m.h

2017-08-30 Thread Sergej Proskurin
In this commit, we move the function "altp2m_check" from p2m.h to altp2m.h in
order to group all altp2m-related functions in one point, namely in
altp2m.{c|h}. This commit moves solely the arm code.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v4: This commit has been pulled out of the previous commit "altp2m: Introduce
altp2m_switch_vcpu_altp2m_by_id".
---
 xen/include/asm-arm/altp2m.h | 7 +++
 xen/include/asm-arm/p2m.h| 6 --
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 3e418cb0f0..5a2444e8f8 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -49,6 +49,13 @@ void altp2m_vcpu_destroy(struct vcpu *v);
 /* Get current alternate p2m table. */
 struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
 
+/* Check to see if vcpu should be switched to a different p2m. */
+static inline
+void altp2m_check(struct vcpu *v, uint16_t idx)
+{
+/* Not supported on ARM. */
+}
+
 /* Switch alternate p2m for entire domain */
 int altp2m_switch_domain_altp2m_by_id(struct domain *d,
   unsigned int idx);
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 5564473e26..5a000d2f67 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -185,12 +185,6 @@ typedef enum {
 (P2M_RAM_TYPES | P2M_GRANT_TYPES |  \
  p2m_to_mask(p2m_map_foreign)))
 
-static inline
-void altp2m_check(struct vcpu *v, uint16_t idx)
-{
-/* Not supported on ARM. */
-}
-
 /* Second stage paging setup, to be called on all CPUs */
 void setup_virt_paging(void);
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 25/39] arm/p2m: Modify reference count only if hostp2m active

2017-08-30 Thread Sergej Proskurin
This commit makes sure that the page reference count is updated through
the function "p2m_put_l3_page" only when the entries have been freed
from the host's p2m.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 

v4: Moved the check for the host's p2m from "p2m_free_entry" to
"p2m_put_l3_page".
---
 xen/arch/arm/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 246250d8c6..e9274c74a8 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -617,7 +617,7 @@ static void p2m_put_l3_page(struct p2m_domain *p2m, const 
lpae_t pte)
  * flush the TLBs if the page is reallocated before the end of
  * this loop.
  */
-if ( p2m_is_foreign(pte.p2m.type) )
+if ( p2m_is_foreign(pte.p2m.type) && p2m_is_hostp2m(p2m) )
 {
 mfn_t mfn = _mfn(pte.p2m.base);
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 08/39] arm/p2m: Cosmetic fix - function prototype of p2m_alloc_table

2017-08-30 Thread Sergej Proskurin
The function "p2m_alloc_table" should be able to allocate 2nd stage
translation tables not only for the host's p2m but also for alternate
p2m's.

Signed-off-by: Sergej Proskurin 
Acked-by: Julien Grall 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Removed altp2m table initialization from "p2m_table_init".

v3: Removed initialization of the field d->arch.altp2m_active in
"p2m_table_init" to avoid altp2m initialization throughout different
files.

Merged the function "p2m_alloc_table" and "p2m_table_init".
---
 xen/arch/arm/p2m.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 3a1a38e7af..65dd2772bf 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1112,9 +1112,8 @@ int guest_physmap_remove_page(struct domain *d, gfn_t 
gfn, mfn_t mfn,
 return p2m_remove_mapping(d, gfn, (1 << page_order), mfn);
 }
 
-static int p2m_alloc_table(struct domain *d)
+static int p2m_alloc_table(struct p2m_domain *p2m)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 struct page_info *page;
 unsigned int i;
 
@@ -1290,7 +1289,7 @@ int p2m_init_one(struct domain *d, struct p2m_domain *p2m)
 p2m->clean_pte = iommu_enabled &&
 !iommu_has_feature(d, IOMMU_FEAT_COHERENT_WALK);
 
-rc = p2m_alloc_table(d);
+rc = p2m_alloc_table(p2m);
 
 /*
  * Make sure that the type chosen to is able to store the an vCPU ID
-- 
2.13.3


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


[Xen-devel] [PATCH v4 10/39] arm/p2m: Change func prototype and impl of p2m_(alloc|free)_vmid

2017-08-30 Thread Sergej Proskurin
This commit changes the prototype and implementation of the functions
"p2m_alloc_vmid" and "p2m_free_vmid". The function "p2m_alloc_vmid" does
not expect the struct domain as argument anymore and returns an
allocated vmid. The function "p2m_free_vmid" takes only the vmid that is
to be freed as argument.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Changed function prototypes and implementation of the functions
"p2m_alloc_vmid" and "p2m_free_vmid".

Changes in "p2m_alloc_vmid":
This function does not expect any arguments. Also, in this commit,
the function "p2m_alloc_vmid" returns either the successfully
allocated vmid or the value INVALID_VMID. Thus, it is now the
responsibility of the caller to set the returned vmid in the
associated fields.

Changes in "p2m_free_vmid":
This function expects now only the vmid of type uint8_t.
---
 xen/arch/arm/p2m.c | 33 -
 1 file changed, 12 insertions(+), 21 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 808d99e1e9..ec855341b9 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1162,11 +1162,9 @@ static void p2m_vmid_allocator_init(void)
 set_bit(INVALID_VMID, vmid_mask);
 }
 
-static int p2m_alloc_vmid(struct domain *d)
+static uint8_t p2m_alloc_vmid(void)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
-
-int rc, vmid;
+uint8_t vmid;
 
 spin_lock(_alloc_lock);
 
@@ -1176,28 +1174,23 @@ static int p2m_alloc_vmid(struct domain *d)
 
 if ( vmid == MAX_VMID )
 {
-rc = -EBUSY;
-printk(XENLOG_ERR "p2m.c: dom%d: VMID pool exhausted\n", d->domain_id);
+vmid = INVALID_VMID;
+printk(XENLOG_ERR "p2m.c: VMID pool exhausted\n");
 goto out;
 }
 
 set_bit(vmid, vmid_mask);
 
-p2m->vmid = vmid;
-
-rc = 0;
-
 out:
 spin_unlock(_alloc_lock);
-return rc;
+return vmid;
 }
 
-static void p2m_free_vmid(struct domain *d)
+static void p2m_free_vmid(uint8_t vmid)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 spin_lock(_alloc_lock);
-if ( p2m->vmid != INVALID_VMID )
-clear_bit(p2m->vmid, vmid_mask);
+if ( vmid != INVALID_VMID )
+clear_bit(vmid, vmid_mask);
 
 spin_unlock(_alloc_lock);
 }
@@ -1254,7 +1247,7 @@ void p2m_teardown_one(struct p2m_domain *p2m)
 
 p2m->root = NULL;
 
-p2m_free_vmid(p2m->domain);
+p2m_free_vmid(p2m->vmid);
 
 radix_tree_destroy(>mem_access_settings, NULL);
 }
@@ -1267,11 +1260,9 @@ int p2m_init_one(struct domain *d, struct p2m_domain 
*p2m)
 rwlock_init(>lock);
 INIT_PAGE_LIST_HEAD(>pages);
 
-p2m->vmid = INVALID_VMID;
-
-rc = p2m_alloc_vmid(d);
-if ( rc != 0 )
-return rc;
+p2m->vmid = p2m_alloc_vmid();
+if ( p2m->vmid == INVALID_VMID )
+return -EBUSY;
 
 p2m->domain = d;
 p2m->max_mapped_gfn = _gfn(0);
-- 
2.13.3


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


[Xen-devel] [PATCH v4 35/39] arm/p2m: Adjust debug information to altp2m

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Dump p2m information of the hostp2m and all altp2m views.

v4: Adjust printk format.
---
 xen/arch/arm/p2m.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index dcf7be6439..db213bea20 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -103,6 +103,26 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr)
 
 dump_pt_walk(page_to_maddr(p2m->root), addr,
  P2M_ROOT_LEVEL, P2M_ROOT_PAGES);
+printk("\n");
+
+if ( altp2m_active(d) )
+{
+unsigned int i;
+
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+if ( d->arch.altp2m_p2m[i] == NULL )
+continue;
+
+p2m = d->arch.altp2m_p2m[i];
+
+printk("AP2M[%u] @ %p mfn:%lx\n",
+i, p2m->root, __page_to_mfn(p2m->root));
+
+dump_pt_walk(page_to_maddr(p2m->root), addr, P2M_ROOT_LEVEL, 
P2M_ROOT_PAGES);
+printk("\n");
+}
+}
 }
 
 void p2m_save_state(struct vcpu *p)
-- 
2.13.3


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


[Xen-devel] [PATCH v4 32/39] arm/altp2m: Make altp2m_vcpu_idx ready for altp2m

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/include/asm-arm/altp2m.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index f9e14ab1dc..eff6bd5a38 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -35,9 +35,7 @@ static inline bool_t altp2m_active(const struct domain *d)
 /* Alternate p2m VCPU */
 static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
 {
-/* Not implemented on ARM, should not be reached. */
-BUG();
-return 0;
+return v->arch.ap2m_idx;
 }
 
 int altp2m_init(struct domain *d);
-- 
2.13.3


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


[Xen-devel] [PATCH v4 11/39] altp2m: Move (MAX|INVALID)_ALTP2M to xen/p2m-common.h

2017-08-30 Thread Sergej Proskurin
We move the macros (MAX|INVALID)_ALTP2M out of x86-related code to
common code, as the following patches will make use of them on ARM.

Signed-off-by: Sergej Proskurin 
---
Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Cc: Julien Grall 
---
v4: We have introduced this patch to our patch series.
---
 xen/include/asm-arm/altp2m.h| 1 +
 xen/include/asm-x86/domain.h| 3 +--
 xen/include/xen/altp2m-common.h | 8 
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 xen/include/xen/altp2m-common.h

diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 0711796123..66afa959f6 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -20,6 +20,7 @@
 #ifndef __ASM_ARM_ALTP2M_H
 #define __ASM_ARM_ALTP2M_H
 
+#include 
 #include 
 
 /* Alternate p2m on/off per domain */
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index fb8bf17458..1d10f4b59f 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -1,6 +1,7 @@
 #ifndef __ASM_DOMAIN_H__
 #define __ASM_DOMAIN_H__
 
+#include 
 #include 
 #include 
 #include 
@@ -234,8 +235,6 @@ struct paging_vcpu {
 
 #define MAX_NESTEDP2M 10
 
-#define MAX_ALTP2M  10 /* arbitrary */
-#define INVALID_ALTP2M  0x
 #define MAX_EPTP(PAGE_SIZE / sizeof(uint64_t))
 struct p2m_domain;
 struct time_scale {
diff --git a/xen/include/xen/altp2m-common.h b/xen/include/xen/altp2m-common.h
new file mode 100644
index 00..670fb42292
--- /dev/null
+++ b/xen/include/xen/altp2m-common.h
@@ -0,0 +1,8 @@
+#ifndef __XEN_ALTP2M_COMMON_H__
+#define __XEN_ALTP2M_COMMON_H__
+
+#define MAX_ALTP2M  10  /* The system may contain an arbitrary number
+   of altp2m views. */
+#define INVALID_ALTP2M  0x
+
+#endif /* __XEN_ALTP2M_COMMON_H__ */
-- 
2.13.3


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


[Xen-devel] [PATCH v4 20/39] arm/p2m: Make get_page_from_gva ready for altp2m

2017-08-30 Thread Sergej Proskurin
The function get_page_from_gva uses ARM's hardware support to translate
gva's to machine addresses. This function is used, among others, for
memory regulation purposes, e.g, within the context of memory ballooning.
To ensure correct behavior while altp2m is in use, we use the host's p2m
table for the associated gva to ma translation. This is required at this
point, as altp2m lazily copies pages from the host's p2m and even might
be flushed because of changes to the host's p2m (as it is done within
the context of memory ballooning).

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Cosmetic fixes.

Make use of the p2m_(switch|restore)_vttbr_and_(g|s)et_flags macros
to avoid code duplication.

v4: Remove initialization of the old vttbr outside of the macro
"p2m_switch_vttbr_and_get_flags".
---
 xen/arch/arm/p2m.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 16c7585ffa..20d7784708 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1470,7 +1470,24 @@ struct page_info *get_page_from_gva(struct vcpu *v, 
vaddr_t va,
 
 p2m_read_lock(p2m);
 
-rc = gvirt_to_maddr(va, , flags);
+/*
+ * If altp2m is active, we need to translate the gva upon the hostp2m's
+ * vttbr, as it contains all valid mappings while the currently active
+ * altp2m view might not have the required gva mapping yet.
+ */
+if ( unlikely(altp2m_active(d)) )
+{
+unsigned long flags = 0;
+uint64_t ovttbr;
+
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
+
+rc = gvirt_to_maddr(va, , flags);
+
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
+}
+else
+rc = gvirt_to_maddr(va, , flags);
 
 if ( rc )
 goto err;
-- 
2.13.3


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


[Xen-devel] [PATCH v4 16/39] arm/p2m: Add HVMOP_altp2m_destroy_p2m

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Substituted the call to tlb_flush for p2m_flush_table.
Added comments.
Cosmetic fixes.

v3: Changed the locking mechanism to "p2m_write_lock" inside the
function "altp2m_destroy_by_id".

Do not flush but rather teardown the altp2m in the function
"altp2m_destroy_by_id".

Exchanged the check "altp2m_vttbr[idx] == INVALID_VTTBR" for
"altp2m_p2m[idx] == NULL" in "altp2m_destroy_by_id".

v4: Removed locking the p2m in "altp2m_destroy_by_id" as the p2m is not
used by anyone else at this point.
---
 xen/arch/arm/altp2m.c| 39 +++
 xen/arch/arm/hvm.c   |  2 +-
 xen/include/asm-arm/altp2m.h |  4 
 3 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 6b1e34709f..1128e1af16 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -180,6 +180,45 @@ void altp2m_flush_complete(struct domain *d)
 altp2m_unlock(d);
 }
 
+int altp2m_destroy_by_id(struct domain *d, unsigned int idx)
+{
+struct p2m_domain *p2m;
+int rc = -EBUSY;
+
+/*
+ * The altp2m[0] is considered as the hostp2m and is used as a safe harbor
+ * to which you can switch as long as altp2m is active. After deactivating
+ * altp2m, the system switches back to the original hostp2m view. That is,
+ * altp2m[0] should only be destroyed/flushed/freed, when altp2m is
+ * deactivated.
+ */
+if ( !idx || idx >= MAX_ALTP2M )
+return rc;
+
+domain_pause_except_self(d);
+
+altp2m_lock(d);
+
+if ( d->arch.altp2m_p2m[idx] != NULL )
+{
+p2m = d->arch.altp2m_p2m[idx];
+
+if ( !_atomic_read(p2m->active_vcpus) )
+{
+p2m_teardown_one(p2m);
+xfree(p2m);
+d->arch.altp2m_p2m[idx] = NULL;
+rc = 0;
+}
+}
+
+altp2m_unlock(d);
+
+domain_unpause_except_self(d);
+
+return rc;
+}
+
 void altp2m_teardown(struct domain *d)
 {
 unsigned int i;
diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index caa2e1b516..4bf2f28a1a 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -131,7 +131,7 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 break;
 
 case HVMOP_altp2m_destroy_p2m:
-rc = -EOPNOTSUPP;
+rc = altp2m_destroy_by_id(d, a.u.view.view);
 break;
 
 case HVMOP_altp2m_switch_p2m:
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index b9719f9d5b..778c6c4f12 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -60,4 +60,8 @@ int altp2m_init_next_available(struct domain *d,
 /* Flush all the alternate p2m's for a domain. */
 void altp2m_flush_complete(struct domain *d);
 
+/* Make a specific alternate p2m invalid */
+int altp2m_destroy_by_id(struct domain *d,
+ unsigned int idx);
+
 #endif /* __ASM_ARM_ALTP2M_H */
-- 
2.13.3


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


[Xen-devel] [PATCH v4 19/39] arm/p2m: Make p2m_restore_state ready for altp2m

2017-08-30 Thread Sergej Proskurin
This commit adapts the function "p2m_restore_state" in a way that the
currently active altp2m table is considered during state restoration.

Signed-off-by: Sergej Proskurin 
Acked-by: Julien Grall 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Moved declaration of "altp2m_switch_domain_altp2m_by_id" out of this
patch.

v4: Moved the variable "p2m", as to satisfy compiler warnings, prohibiting
mixing declarations and code.
---
 xen/arch/arm/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index e017e2972e..16c7585ffa 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -112,8 +112,8 @@ void p2m_save_state(struct vcpu *p)
 
 void p2m_restore_state(struct vcpu *n)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(n->domain);
 uint8_t *last_vcpu_ran;
+struct p2m_domain *p2m = p2m_get_active_p2m(n);
 
 if ( is_idle_vcpu(n) )
 return;
-- 
2.13.3


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


[Xen-devel] [PATCH v4 29/39] x86/altp2m: Move altp2m_check to altp2m.c

2017-08-30 Thread Sergej Proskurin
In this commit, we move the function "altp2m_check" from p2m.c to altp2m.c in
order to group all altp2m-related functions in one point, namely in
altp2m.{c|h}. This commit moves solely the x86 code.

Signed-off-by: Sergej Proskurin 
---
Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
---
v4: This commit has been pulled out of the previous commit "altp2m: Introduce
altp2m_switch_vcpu_altp2m_by_id".
---
 xen/arch/x86/mm/altp2m.c | 6 ++
 xen/arch/x86/mm/p2m.c| 6 --
 xen/common/vm_event.c| 1 +
 xen/include/asm-x86/altp2m.h | 3 +++
 xen/include/asm-x86/p2m.h| 3 ---
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 930bdc2669..00abb5a5bb 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -65,6 +65,12 @@ altp2m_vcpu_destroy(struct vcpu *v)
 vcpu_unpause(v);
 }
 
+void altp2m_check(struct vcpu *v, uint16_t idx)
+{
+if ( altp2m_active(v->domain) )
+p2m_switch_vcpu_altp2m_by_id(v, idx);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index d5038ed66b..3feb6315c2 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1687,12 +1687,6 @@ void p2m_mem_paging_resume(struct domain *d, 
vm_event_response_t *rsp)
 }
 }
 
-void altp2m_check(struct vcpu *v, uint16_t idx)
-{
-if ( altp2m_active(v->domain) )
-p2m_switch_vcpu_altp2m_by_id(v, idx);
-}
-
 static struct p2m_domain *
 p2m_getlru_nestedp2m(struct domain *d, struct p2m_domain *p2m)
 {
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 42e6f09029..66f1d83d84 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* for public/io/ring.h macros */
 #define xen_mb()   smp_mb()
diff --git a/xen/include/asm-x86/altp2m.h b/xen/include/asm-x86/altp2m.h
index 64c761873e..67d0205612 100644
--- a/xen/include/asm-x86/altp2m.h
+++ b/xen/include/asm-x86/altp2m.h
@@ -38,4 +38,7 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
 return vcpu_altp2m(v).p2midx;
 }
 
+/* Check to see if vcpu should be switched to a different p2m. */
+void altp2m_check(struct vcpu *v, uint16_t idx);
+
 #endif /* __ASM_X86_ALTP2M_H */
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index d1cc65f86d..863d7559cb 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -803,9 +803,6 @@ static inline struct p2m_domain *p2m_get_altp2m(struct vcpu 
*v)
 /* Switch alternate p2m for a single vcpu */
 bool_t p2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx);
 
-/* Check to see if vcpu should be switched to a different p2m. */
-void altp2m_check(struct vcpu *v, uint16_t idx);
-
 /* Flush all the alternate p2m's for a domain */
 void p2m_flush_altp2m(struct domain *d);
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 26/39] arm/p2m: Add HVMOP_altp2m_set_mem_access

2017-08-30 Thread Sergej Proskurin
The HVMOP_altp2m_set_mem_access allows to set gfn permissions of
(currently one page at a time) of a specific altp2m view. In case the
view does not hold the requested gfn entry, it will be first copied from
the host's p2m table and then modified as requested.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
---
v2: Prevent the page reference count from being falsely updated on
altp2m modification. Therefore, we add a check determining whether
the target p2m is a hostp2m before p2m_put_l3_page is called.

v3: Cosmetic fixes.

Added the functionality to set/get the default_access also in/from
the requested altp2m view.

Read-locked hp2m in "altp2m_set_mem_access".

Moved the functions "p2m_is_(hostp2m|altp2m)" out of this commit.

Moved the funtion "modify_altp2m_entry" out of this commit.

Moved the function "p2m_lookup_attr" out of this commit.

Moved guards for "p2m_put_l3_page" out of this commit.

v4: Cosmetic fixes.

Removed locking altp2m_lock, as it unnecessarily serializes accesses
to "altp2m_set_mem_access".

Use the functions "p2m_(set|get)_entry" instead of the helpers
"p2m_lookup_attr" and "modify_altp2m_entry".

Removes the restriction enforcing changing the memory access of
p2m_ram_(rw|ro). Instead, we allow to set memory permissions of all
pages of the particular altp2m view.

Move the functionality locking ap2m and hp2m out of "altp2m_set_mem_access"
into "p2m_set_mem_access".

Comment the need for the default access in altp2m views.
---
 xen/arch/arm/altp2m.c| 46 
 xen/arch/arm/hvm.c   |  7 -
 xen/arch/arm/mem_access.c| 72 +++-
 xen/include/asm-arm/altp2m.h | 12 
 4 files changed, 122 insertions(+), 15 deletions(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 9a2cf5a018..8c3212780a 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -77,6 +77,52 @@ int altp2m_switch_domain_altp2m_by_id(struct domain *d, 
unsigned int idx)
 return rc;
 }
 
+int altp2m_set_mem_access(struct domain *d,
+  struct p2m_domain *hp2m,
+  struct p2m_domain *ap2m,
+  p2m_access_t a,
+  gfn_t gfn)
+{
+p2m_type_t p2mt;
+p2m_access_t old_a;
+mfn_t mfn, mfn_sp;
+gfn_t gfn_sp;
+unsigned int order;
+int rc;
+
+/* Check if entry is part of the altp2m view. */
+mfn = p2m_get_entry(ap2m, gfn, , NULL, );
+
+/* Check host p2m if no valid entry in ap2m. */
+if ( mfn_eq(mfn, INVALID_MFN) )
+{
+/* Check if entry is part of the host p2m view. */
+mfn = p2m_get_entry(hp2m, gfn, , _a, );
+if ( mfn_eq(mfn, INVALID_MFN) )
+return -ESRCH;
+
+/* If this is a superpage, copy that first. */
+if ( order != THIRD_ORDER )
+{
+/* Align the gfn and mfn to the given pager order. */
+gfn_sp = _gfn(gfn_x(gfn) & ~((1UL << order) - 1));
+mfn_sp = _mfn(mfn_x(mfn) & ~((1UL << order) - 1));
+
+rc = p2m_set_entry(ap2m, gfn_sp, (1UL << order), mfn_sp, p2mt, 
old_a);
+if ( rc )
+return rc;
+}
+}
+
+/* Align the gfn and mfn to the given pager order. */
+gfn = _gfn(gfn_x(gfn) & ~((1UL << THIRD_ORDER) - 1));
+mfn = _mfn(mfn_x(mfn) & ~((1UL << THIRD_ORDER) - 1));
+
+rc = p2m_set_entry(ap2m, gfn, (1UL << THIRD_ORDER), mfn, p2mt, a);
+
+return rc;
+}
+
 static void altp2m_vcpu_reset(struct vcpu *v)
 {
 v->arch.ap2m_idx = INVALID_ALTP2M;
diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 9bddc7e17e..7e91f2436d 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -139,7 +139,12 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 break;
 
 case HVMOP_altp2m_set_mem_access:
-rc = -EOPNOTSUPP;
+if ( a.u.set_mem_access.pad )
+rc = -EINVAL;
+else
+rc = p2m_set_mem_access(d, _gfn(a.u.set_mem_access.gfn), 1, 0, 0,
+a.u.set_mem_access.hvmmem_access,
+a.u.set_mem_access.view);
 break;
 
 case HVMOP_altp2m_change_gfn:
diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
index ebc3a86af3..ee2a43fc6e 100644
--- a/xen/arch/arm/mem_access.c
+++ b/xen/arch/arm/mem_access.c
@@ -374,7 +374,7 @@ long p2m_set_mem_access(struct domain *d, gfn_t gfn, 
uint32_t nr,
 uint32_t start, uint32_t mask, xenmem_access_t access,
 unsigned int altp2m_idx)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
+struct p2m_domain *hp2m = p2m_get_hostp2m(d), 

[Xen-devel] [PATCH v4 13/39] arm/p2m: Add altp2m table flushing routine

2017-08-30 Thread Sergej Proskurin
The current implementation differentiates between flushing and
destroying altp2m views. This commit adds the function altp2m_flush,
which allows to release all of the alternate p2m views. To make sure
that we flush alternate p2m's only if they are not used by any vCPU, we
introduce a counter that tracks the vCPUs that are currently using the
particular p2m.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Pages in p2m->pages are not cleared in p2m_flush_table anymore.
VMID is freed in p2m_free_one.
Cosmetic fixes.

v3: Changed the locking mechanism to "p2m_write_lock" inside the
function "altp2m_flush".

Do not flush but rather teardown the altp2m in the function
"altp2m_flush".

Exchanged the check "altp2m_vttbr[idx] == INVALID_VTTBR" for
"altp2m_p2m[idx] == NULL" in "altp2m_flush".

v4: Removed the p2m locking instructions in "altp2m_flush", as they are
not needed at this point. At this point, altp2m should be inactive and
thus the particular p2m should not be used by a vCPU. Therefore, we
added an ASSERT statement to ensure this.

We introduce the counter active_vcpus as part of this patch.

Rename the function altp2m_flush to altp2m_flush_complete.
---
 xen/arch/arm/altp2m.c| 32 
 xen/include/asm-arm/altp2m.h |  3 +++
 xen/include/asm-arm/p2m.h|  5 +
 3 files changed, 40 insertions(+)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index e73b69d99d..9c06055a94 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -28,6 +28,38 @@ int altp2m_init(struct domain *d)
 return 0;
 }
 
+void altp2m_flush_complete(struct domain *d)
+{
+unsigned int i;
+struct p2m_domain *p2m;
+
+/*
+ * If altp2m is active, we are not allowed to flush altp2m[0]. This special
+ * view is considered as the hostp2m as long as altp2m is active.
+ */
+ASSERT(!altp2m_active(d));
+
+altp2m_lock(d);
+
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+p2m = d->arch.altp2m_p2m[i];
+
+if ( p2m == NULL )
+continue;
+
+ASSERT(!atomic_read(>active_vcpus));
+
+/* We do not need to lock the p2m, as altp2m is inactive. */
+p2m_teardown_one(p2m);
+
+xfree(p2m);
+d->arch.altp2m_p2m[i] = NULL;
+}
+
+altp2m_unlock(d);
+}
+
 void altp2m_teardown(struct domain *d)
 {
 unsigned int i;
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 1706f61f0c..e116cce25f 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -43,4 +43,7 @@ static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
 int altp2m_init(struct domain *d);
 void altp2m_teardown(struct domain *d);
 
+/* Flush all the alternate p2m's for a domain. */
+void altp2m_flush_complete(struct domain *d);
+
 #endif /* __ASM_ARM_ALTP2M_H */
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 9bb38e689a..e8a2116081 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -10,6 +10,8 @@
 #include 
 #include 
 
+#include 
+
 #define paddr_bits PADDR_BITS
 
 #define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
@@ -132,6 +134,9 @@ struct p2m_domain {
 /* Keeping track on which CPU this p2m was used and for which vCPU */
 uint8_t last_vcpu_ran[NR_CPUS];
 
+/* Alternate p2m: count of vcpu's currently using this p2m. */
+atomic_t active_vcpus;
+
 /* Choose between: host/alternate. */
 p2m_class_t p2m_class;
 };
-- 
2.13.3


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


[Xen-devel] [PATCH v4 01/39] arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags

2017-08-30 Thread Sergej Proskurin
This commit introduces macros for switching and restoring the vttbr
considering the currently set irq flags. We define these macros, as the
following commits will use the associated functionality multiple times
throughout different files.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v4: Save the content of VTTBR_EL2 inside of the introduced macro
"p2m_switch_vttbr_and_get_flags".

Move the introduced macros into ./xen/include/asm-arm/p2m.h, as they will
be used by different files in the future commits.
---
 xen/arch/arm/p2m.c| 15 ++-
 xen/include/asm-arm/p2m.h | 21 +
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c484469e6c..4334e3bc81 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -147,22 +147,11 @@ static void p2m_flush_tlb(struct p2m_domain *p2m)
  * ARM only provides an instruction to flush TLBs for the current
  * VMID. So switch to the VTTBR of a given P2M if different.
  */
-ovttbr = READ_SYSREG64(VTTBR_EL2);
-if ( ovttbr != p2m->vttbr )
-{
-local_irq_save(flags);
-WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
-isb();
-}
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
 
 flush_tlb();
 
-if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )
-{
-WRITE_SYSREG64(ovttbr, VTTBR_EL2);
-isb();
-local_irq_restore(flags);
-}
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
 }
 
 /*
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index aa0d60ae3a..500dc88fbc 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -12,6 +12,27 @@
 
 #define paddr_bits PADDR_BITS
 
+#define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
+({  \
+ ovttbr = READ_SYSREG64(VTTBR_EL2); \
+ if ( ovttbr != nvttbr )\
+ {  \
+local_irq_save(flags);  \
+WRITE_SYSREG64(nvttbr, VTTBR_EL2);  \
+isb();  \
+ }  \
+})
+
+#define p2m_restore_vttbr_and_set_flags(ovttbr, flags)  \
+({  \
+ if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )  \
+ {  \
+WRITE_SYSREG64(ovttbr, VTTBR_EL2);  \
+isb();  \
+local_irq_restore(flags);   \
+ }  \
+})
+
 /* Holds the bit size of IPAs in p2m tables.  */
 extern unsigned int p2m_ipa_bits;
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 12/39] arm/p2m: Add altp2m init/teardown routines

2017-08-30 Thread Sergej Proskurin
The p2m initialization now invokes initialization routines responsible
for the allocation and initialization of altp2m structures. The same
applies to teardown routines. The functionality has been adopted from
the x86 altp2m implementation.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Shared code between host/altp2m init/teardown functions.
Added conditional init/teardown of altp2m.
Altp2m related functions are moved to altp2m.c

v3: Removed locking the altp2m_lock in altp2m_teardown. Locking this
lock at this point is unnecessary.

Removed re-setting altp2m_vttbr, altp2m_p2m, and altp2m_active
values in the function "altp2m_teardown". Re-setting these values is
unnecessary as the entire domain will be destroyed right afterwards.

Removed check for "altp2m_enabled" in "p2m_init" as altp2m has not yet
been enabled by libxl at this point.

Removed check for "altp2m_enabled" before tearing down altp2m within
the function "p2m_teardown" so that altp2m gets destroyed even if
the HVM_PARAM_ALTP2M gets reset before "p2m_teardown" is called.

Added initialization of the field d->arch.altp2m_active in
"altp2m_init".

Removed check for already initialized vmid's in "altp2m_init_one",
as "altp2m_init_one" is now called always with an uninitialized p2m.

Removed the array altp2m_vttbr[] in struct arch_domain.

v4: Removed initialization of altp2m_p2m[] to NULL in altp2m_init, as
the "struct arch_domain" is already initialized to zero.

We moved the definition of the macro MAX_ALTP2M to a common place in
a separate commit.
---
 xen/arch/arm/Makefile|  1 +
 xen/arch/arm/altp2m.c| 56 
 xen/arch/arm/p2m.c   | 15 +++-
 xen/include/asm-arm/altp2m.h |  6 +
 xen/include/asm-arm/domain.h | 11 -
 5 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 xen/arch/arm/altp2m.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 282d2c2949..a08683335d 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -5,6 +5,7 @@ subdir-$(CONFIG_ARM_64) += efi
 subdir-$(CONFIG_ACPI) += acpi
 
 obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o
+obj-y += altp2m.o
 obj-y += bootfdt.init.o
 obj-y += cpu.o
 obj-y += cpuerrata.o
diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
new file mode 100644
index 00..e73b69d99d
--- /dev/null
+++ b/xen/arch/arm/altp2m.c
@@ -0,0 +1,56 @@
+/*
+ * arch/arm/altp2m.c
+ *
+ * Alternate p2m
+ * Copyright (c) 2016 Sergej Proskurin 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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 
+
+int altp2m_init(struct domain *d)
+{
+spin_lock_init(>arch.altp2m_lock);
+d->arch.altp2m_active = false;
+
+return 0;
+}
+
+void altp2m_teardown(struct domain *d)
+{
+unsigned int i;
+struct p2m_domain *p2m;
+
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+p2m = d->arch.altp2m_p2m[i];
+
+if ( !p2m )
+continue;
+
+p2m_teardown_one(p2m);
+xfree(p2m);
+}
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index ec855341b9..e017e2972e 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define MAX_VMID_8_BIT  (1UL << 8)
 #define MAX_VMID_16_BIT (1UL << 16)
@@ -1305,6 +1306,12 @@ static void p2m_teardown_hostp2m(struct domain *d)
 
 void p2m_teardown(struct domain *d)
 {
+/*
+ * Teardown altp2m unconditionally so that altp2m gets always destroyed --
+ * even if HVM_PARAM_ALTP2M gets reset before teardown.
+ */
+altp2m_teardown(d);
+
 p2m_teardown_hostp2m(d);
 }
 
@@ -1319,7 +1326,13 @@ static int p2m_init_hostp2m(struct domain *d)
 
 int p2m_init(struct domain *d)
 {
-return p2m_init_hostp2m(d);
+int rc;
+
+rc = p2m_init_hostp2m(d);
+if ( rc )
+return rc;
+
+return altp2m_init(d);
 }
 
 /*
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 66afa959f6..1706f61f0c 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -23,6 +23,9 @@
 

[Xen-devel] [PATCH v4 15/39] arm/p2m: Add HVMOP_altp2m_create_p2m

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
Acked-by: Julien Grall 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Cosmetic fixes.

v3: Cosmetic fixes.

Renamed the function "altp2m_init_next" to
"altp2m_init_next_available".

Exchanged the check "altp2m_vttbr[idx] == INVALID_VTTBR" for
"altp2m_p2m[idx] == NULL" in "altp2m_init_next_available".
---
 xen/arch/arm/altp2m.c| 23 +++
 xen/arch/arm/hvm.c   |  3 ++-
 xen/include/asm-arm/altp2m.h |  4 
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 43e95c5681..6b1e34709f 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -117,6 +117,29 @@ int altp2m_init_by_id(struct domain *d, unsigned int idx)
 return rc;
 }
 
+int altp2m_init_next_available(struct domain *d, uint16_t *idx)
+{
+int rc = -EINVAL;
+uint16_t i;
+
+altp2m_lock(d);
+
+for ( i = 0; i < MAX_ALTP2M; i++ )
+{
+if ( d->arch.altp2m_p2m[i] != NULL )
+continue;
+
+rc = altp2m_init_helper(d, i);
+*idx = i;
+
+break;
+}
+
+altp2m_unlock(d);
+
+return rc;
+}
+
 int altp2m_init(struct domain *d)
 {
 spin_lock_init(>arch.altp2m_lock);
diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index ec8e259797..caa2e1b516 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -126,7 +126,8 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 break;
 
 case HVMOP_altp2m_create_p2m:
-rc = -EOPNOTSUPP;
+if ( !(rc = altp2m_init_next_available(d, )) )
+rc = __copy_to_guest(arg, , 1) ? -EFAULT : 0;
 break;
 
 case HVMOP_altp2m_destroy_p2m:
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 2ef88cec35..b9719f9d5b 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -53,6 +53,10 @@ struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
 int altp2m_init_by_id(struct domain *d,
   unsigned int idx);
 
+/* Find and initialize the next available alternate p2m. */
+int altp2m_init_next_available(struct domain *d,
+   uint16_t *idx);
+
 /* Flush all the alternate p2m's for a domain. */
 void altp2m_flush_complete(struct domain *d);
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 14/39] arm/p2m: Add HVMOP_altp2m_set_domain_state

2017-08-30 Thread Sergej Proskurin
The HVMOP_altp2m_set_domain_state allows to activate altp2m on a
specific domain. This commit adopts the x86
HVMOP_altp2m_set_domain_state implementation.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Dynamically allocate memory for altp2m views only when needed.
Move altp2m related helpers to altp2m.c.
p2m_flush_tlb is made publicly accessible.

v3: Cosmetic fixes.

Removed call to "p2m_alloc_table" in "altp2m_init_helper" as the
entire p2m allocation is now done within the function
"p2m_init_one". The same applies to the call of the function
"p2m_flush_tlb" from "p2m_init_one".

Removed the "altp2m_enabled" check in HVMOP_altp2m_set_domain_state
case as it has been moved in front of the switch statement in
"do_altp2m_op".

Changed the order of setting the new altp2m state (depending on
setting/resetting the state) in HVMOP_altp2m_set_domain_state case.

Removed the call to altp2m_vcpu_reset from altp2m_vcpu_initialize,
as the p2midx is set right after the call to 0, representing the
default view.

Moved the define "vcpu_altp2m" from domain.h to altp2m.h to avoid
defining altp2m-related functionality in multiple files. Also renamed
"vcpu_altp2m" to "altp2m_vcpu".

Declared the function "p2m_flush_tlb" as static, as it is not called
from altp2m.h anymore.

Exported the function "altp2m_get_altp2m" in altp2m.h.

Exchanged the check "altp2m_vttbr[idx] == INVALID_VTTBR" for
"altp2m_p2m[idx] == NULL" in "altp2m_init_by_id".

Set the field p2m->access_required to false by default.

v4: Removed unnecessary initialization in "altp2m_init_helper".

Move the field "active_vcpus" in "struct p2m_domain" out of this
commit.

Set "d->arch.altp2m_active" to the provided new state only once instead of
for each vCPU.

Move the definition of the macro INVALID_ALTP2M to a common place in
a separate commit.

ARM supports an external-only interface to the altp2m subsystem,
i.e., the guest does not have access to the altp2m subsystem. Thus,
we remove the check for the current vcpu in the function
altp2m_vcpu_initialize; there is no scenario in which a guest is
allowed to initialize the altp2m subsystem for itself.

Cosmetic fixes.
---
 xen/arch/arm/altp2m.c| 97 
 xen/arch/arm/hvm.c   | 30 +-
 xen/include/asm-arm/altp2m.h | 10 +
 xen/include/asm-arm/domain.h |  3 ++
 4 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 9c06055a94..43e95c5681 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -20,6 +20,103 @@
 #include 
 #include 
 
+struct p2m_domain *altp2m_get_altp2m(struct vcpu *v)
+{
+unsigned int idx = v->arch.ap2m_idx;
+
+if ( idx == INVALID_ALTP2M )
+return NULL;
+
+BUG_ON(idx >= MAX_ALTP2M);
+
+return v->domain->arch.altp2m_p2m[idx];
+}
+
+static void altp2m_vcpu_reset(struct vcpu *v)
+{
+v->arch.ap2m_idx = INVALID_ALTP2M;
+}
+
+void altp2m_vcpu_initialize(struct vcpu *v)
+{
+/*
+ * ARM supports an external-only interface to the altp2m subsystem, i.e.,
+ * the guest does not have access to the altp2m subsystem. Thus, we can
+ * simply pause the vcpu, as there is no scenario in which we initialize
+ * altp2m on the current vcpu. That is, the vcpu must be paused every time
+ * we initialize altp2m.
+ */
+vcpu_pause(v);
+
+v->arch.ap2m_idx = 0;
+atomic_inc(_get_altp2m(v)->active_vcpus);
+
+vcpu_unpause(v);
+}
+
+void altp2m_vcpu_destroy(struct vcpu *v)
+{
+struct p2m_domain *p2m;
+
+if ( v != current )
+vcpu_pause(v);
+
+if ( (p2m = altp2m_get_altp2m(v)) )
+atomic_dec(>active_vcpus);
+
+altp2m_vcpu_reset(v);
+
+if ( v != current )
+vcpu_unpause(v);
+}
+
+static int altp2m_init_helper(struct domain *d, unsigned int idx)
+{
+int rc;
+struct p2m_domain *p2m = d->arch.altp2m_p2m[idx];
+
+ASSERT(p2m == NULL);
+
+/* Allocate a new, zeroed altp2m view. */
+p2m = xzalloc(struct p2m_domain);
+if ( p2m == NULL)
+return -ENOMEM;
+
+p2m->p2m_class = p2m_alternate;
+
+/* Initialize the new altp2m view. */
+rc = p2m_init_one(d, p2m);
+if ( rc )
+goto err;
+
+d->arch.altp2m_p2m[idx] = p2m;
+
+return rc;
+
+err:
+xfree(p2m);
+d->arch.altp2m_p2m[idx] = NULL;
+
+return rc;
+}
+
+int altp2m_init_by_id(struct domain *d, unsigned int idx)
+{
+int rc = -EINVAL;
+
+if ( idx >= MAX_ALTP2M )
+return rc;
+
+altp2m_lock(d);
+
+if ( d->arch.altp2m_p2m[idx] == NULL )
+rc = altp2m_init_helper(d, idx);
+
+altp2m_unlock(d);
+
+return rc;
+}
+
 int altp2m_init(struct domain *d)
 {
 spin_lock_init(>arch.altp2m_lock);
diff 

[Xen-devel] [PATCH v4 02/39] arm/p2m: Add first altp2m HVMOP stubs

2017-08-30 Thread Sergej Proskurin
This commit copies and extends the altp2m-related code from x86 to ARM.
Functions that are no yet supported notify the caller or print a BUG
message stating their absence.

Currently, we prohibit concurrent access of the altp2m interface by
locking the entire domain. As stated in the provided TODO statement,
future implementation should determine, which HVMOPs can be executed
concurrently.

Also, the struct arch_domain is extended with the altp2m_active
attribute, representing the current altp2m activity configuration of the
domain.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Removed altp2m command-line option: Guard through HVM_PARAM_ALTP2M.
Removed not used altp2m helper stubs in altp2m.h.

v3: Cosmetic fixes.

Added domain lock in "do_altp2m_op" to avoid concurrent execution of
altp2m-related HVMOPs.

Added check making sure that HVM_PARAM_ALTP2M is set before
execution of altp2m-related HVMOPs.

v4: Cosmetic fixes.

Added a TODO proposing to determine, which HVMOPs can be executed
concurrently instead of locking the entire domain and hence
prohibiting concurrent access of the altp2m interface.

Adjust to the current code base by explicitly checking whether
altp2m is disabled.

Change the type bool_t to bool of the field altp2m_active in struct
arch_domain.
---
 xen/arch/arm/hvm.c   | 97 
 xen/include/asm-arm/altp2m.h |  4 +-
 xen/include/asm-arm/domain.h |  3 ++
 3 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index a56b3fe3fb..042bdda979 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -31,6 +31,99 @@
 
 #include 
 
+#include 
+
+static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
+{
+struct xen_hvm_altp2m_op a;
+struct domain *d = NULL;
+uint64_t mode;
+int rc = 0;
+
+if ( copy_from_guest(, arg, 1) )
+return -EFAULT;
+
+if ( a.pad1 || a.pad2 ||
+ (a.version != HVMOP_ALTP2M_INTERFACE_VERSION) ||
+ (a.cmd < HVMOP_altp2m_get_domain_state) ||
+ (a.cmd > HVMOP_altp2m_change_gfn) )
+return -EINVAL;
+
+d = (a.cmd != HVMOP_altp2m_vcpu_enable_notify) ?
+rcu_lock_domain_by_any_id(a.domain) : rcu_lock_current_domain();
+
+if ( d == NULL )
+return -ESRCH;
+
+/*
+ * TODO: We prohibit concurrent access of the altp2m interface by locking
+ * the entire domain. Determine which HVMOPs can be executed concurrently.
+ */
+
+/* Prevent concurrent execution of the following HVMOPs. */
+domain_lock(d);
+
+if ( (a.cmd != HVMOP_altp2m_get_domain_state) &&
+ (a.cmd != HVMOP_altp2m_set_domain_state) &&
+ !altp2m_active(d) )
+{
+rc = -EOPNOTSUPP;
+goto out;
+}
+
+mode = d->arch.hvm_domain.params[HVM_PARAM_ALTP2M];
+
+if ( XEN_ALTP2M_disabled == mode )
+{
+rc = -EINVAL;
+goto out;
+}
+
+if ( (rc = xsm_hvm_altp2mhvm_op(XSM_OTHER, d, mode, a.cmd)) )
+goto out;
+
+switch ( a.cmd )
+{
+case HVMOP_altp2m_get_domain_state:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_set_domain_state:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_vcpu_enable_notify:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_create_p2m:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_destroy_p2m:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_switch_p2m:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_set_mem_access:
+rc = -EOPNOTSUPP;
+break;
+
+case HVMOP_altp2m_change_gfn:
+rc = -EOPNOTSUPP;
+break;
+}
+
+out:
+domain_unlock(d);
+rcu_unlock_domain(d);
+
+return rc;
+}
+
 long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
 long rc = 0;
@@ -79,6 +172,10 @@ long do_hvm_op(unsigned long op, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 rc = -EINVAL;
 break;
 
+case HVMOP_altp2m:
+rc = do_altp2m_op(arg);
+break;
+
 default:
 {
 gdprintk(XENLOG_DEBUG, "HVMOP op=%lu: not implemented\n", op);
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index a87747a291..0711796123 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -2,6 +2,7 @@
  * Alternate p2m
  *
  * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2016, Sergej Proskurin .
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -24,8 +25,7 @@
 /* Alternate p2m on/off per domain */
 static inline bool_t altp2m_active(const struct domain *d)
 {
-/* Not implemented on ARM. */
-return 0;
+

[Xen-devel] [PATCH v4 18/39] arm/p2m: Add p2m_get_active_p2m macro

2017-08-30 Thread Sergej Proskurin
This commit introduces the macro "p2m_get_active_p2m" returning the
currently active (alt)p2m. The need for this macro will be shown in the
following commits.

Signed-off-by: Sergej Proskurin 
Acked-by: Julien Grall 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v4: Moved the introduced macro from ./xen/arch/arm/p2m.c to
./xen/include/asm-arm/p2m.h as it will be used in multiple files in the
following commits.
---
 xen/include/asm-arm/p2m.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index e8a2116081..d3467daacf 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -14,6 +14,9 @@
 
 #define paddr_bits PADDR_BITS
 
+#define p2m_get_active_p2m(v) unlikely(altp2m_active(v->domain)) ?  \
+  altp2m_get_altp2m(v) : 
p2m_get_hostp2m(v->domain);
+
 #define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags)   \
 ({  \
  ovttbr = READ_SYSREG64(VTTBR_EL2); \
-- 
2.13.3


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


[Xen-devel] [PATCH v4 21/39] arm/p2m: Cosmetic fix - __p2m_get_mem_access

2017-08-30 Thread Sergej Proskurin
In this commit, we extend the function prototype of "__p2m_get_mem_access" to
hold an argument of type "struct p2m_domain*", as we need to distinguish
between the host's p2m and different altp2m views.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Changed the parameter of "p2m_mem_access_check_and_get_page"
from "struct p2m_domain*" to "struct vcpu*".

v4: We don't need to adjust the function "p2m_mem_access_check_and_get_page"
any more, as its change is already part of another patch.
---
 xen/arch/arm/mem_access.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
index 3e2bb4088a..5bc28db8ff 100644
--- a/xen/arch/arm/mem_access.c
+++ b/xen/arch/arm/mem_access.c
@@ -24,10 +24,9 @@
 #include 
 #include 
 
-static int __p2m_get_mem_access(struct domain *d, gfn_t gfn,
+static int __p2m_get_mem_access(struct p2m_domain *p2m, gfn_t gfn,
 xenmem_access_t *access)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 void *i;
 unsigned int index;
 
@@ -148,7 +147,7 @@ p2m_mem_access_check_and_get_page(vaddr_t gva, unsigned 
long flag,
  * We do this first as this is faster in the default case when no
  * permission is set on the page.
  */
-rc = __p2m_get_mem_access(v->domain, gfn, );
+rc = __p2m_get_mem_access(p2m, gfn, );
 if ( rc < 0 )
 goto err;
 
@@ -443,7 +442,7 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn,
 struct p2m_domain *p2m = p2m_get_hostp2m(d);
 
 p2m_read_lock(p2m);
-ret = __p2m_get_mem_access(d, gfn, access);
+ret = __p2m_get_mem_access(p2m, gfn, access);
 p2m_read_unlock(p2m);
 
 return ret;
-- 
2.13.3


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


[Xen-devel] [PATCH v4 38/39] arm/xen-access: Extend xen-access for altp2m on ARM

2017-08-30 Thread Sergej Proskurin
Signed-off-by: Sergej Proskurin 
Acked-by: Razvan Cojocaru 
---
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
Cc: Ian Jackson 
Cc: Wei Liu 
---
 tools/tests/xen-access/xen-access.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/tools/tests/xen-access/xen-access.c 
b/tools/tests/xen-access/xen-access.c
index 1e69e25a16..481337cacd 100644
--- a/tools/tests/xen-access/xen-access.c
+++ b/tools/tests/xen-access/xen-access.c
@@ -362,10 +362,11 @@ void usage(char* progname)
 {
 fprintf(stderr, "Usage: %s [-m]  write|exec", progname);
 #if defined(__i386__) || defined(__x86_64__)
-fprintf(stderr, 
"|breakpoint|altp2m_write|altp2m_exec|debug|cpuid|desc_access|write_ctrlreg_cr4");
+fprintf(stderr, 
"|breakpoint|debug|cpuid|desc_access|write_ctrlreg_cr4");
 #elif defined(__arm__) || defined(__aarch64__)
 fprintf(stderr, "|privcall");
 #endif
+fprintf(stderr, "|altp2m_write|altp2m_exec");
 fprintf(stderr,
 "\n"
 "Logs first page writes, execs, or breakpoint traps that occur on 
the domain.\n"
@@ -441,18 +442,6 @@ int main(int argc, char *argv[])
 {
 breakpoint = 1;
 }
-else if ( !strcmp(argv[0], "altp2m_write") )
-{
-default_access = XENMEM_access_rx;
-altp2m = 1;
-memaccess = 1;
-}
-else if ( !strcmp(argv[0], "altp2m_exec") )
-{
-default_access = XENMEM_access_rw;
-altp2m = 1;
-memaccess = 1;
-}
 else if ( !strcmp(argv[0], "debug") )
 {
 debug = 1;
@@ -475,6 +464,18 @@ int main(int argc, char *argv[])
 privcall = 1;
 }
 #endif
+else if ( !strcmp(argv[0], "altp2m_write") )
+{
+default_access = XENMEM_access_rx;
+altp2m = 1;
+memaccess = 1;
+}
+else if ( !strcmp(argv[0], "altp2m_exec") )
+{
+default_access = XENMEM_access_rw;
+altp2m = 1;
+memaccess = 1;
+}
 else
 {
 usage(argv[0]);
@@ -547,12 +548,14 @@ int main(int argc, char *argv[])
 goto exit;
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 rc = xc_monitor_singlestep( xch, domain_id, 1 );
 if ( rc < 0 )
 {
 ERROR("Error %d failed to enable singlestep monitoring!\n", rc);
 goto exit;
 }
+#endif
 }
 
 if ( memaccess && !altp2m )
@@ -663,7 +666,9 @@ int main(int argc, char *argv[])
 rc = xc_altp2m_switch_to_view( xch, domain_id, 0 );
 rc = xc_altp2m_destroy_view(xch, domain_id, altp2m_view_id);
 rc = xc_altp2m_set_domain_state(xch, domain_id, 0);
+#if defined(__i386__) || defined(__x86_64__)
 rc = xc_monitor_singlestep(xch, domain_id, 0);
+#endif
 } else {
 rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 
~0ull, 0);
 rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 
START_PFN,
@@ -883,9 +888,11 @@ int main(int argc, char *argv[])
 exit:
 if ( altp2m )
 {
+#if defined(__i386__) || defined(__x86_64__)
 uint32_t vcpu_id;
 for ( vcpu_id = 0; vcpu_id

[Xen-devel] [PATCH v4 09/39] arm/p2m: Rename parameter in p2m_alloc_vmid

2017-08-30 Thread Sergej Proskurin
This commit does not change or introduce any additional functionality
but rather is a part of the following commit that alters the
functionality of the function "p2m_alloc_vmid".

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/p2m.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 65dd2772bf..808d99e1e9 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1166,24 +1166,24 @@ static int p2m_alloc_vmid(struct domain *d)
 {
 struct p2m_domain *p2m = p2m_get_hostp2m(d);
 
-int rc, nr;
+int rc, vmid;
 
 spin_lock(_alloc_lock);
 
-nr = find_first_zero_bit(vmid_mask, MAX_VMID);
+vmid = find_first_zero_bit(vmid_mask, MAX_VMID);
 
-ASSERT(nr != INVALID_VMID);
+ASSERT(vmid != INVALID_VMID);
 
-if ( nr == MAX_VMID )
+if ( vmid == MAX_VMID )
 {
 rc = -EBUSY;
 printk(XENLOG_ERR "p2m.c: dom%d: VMID pool exhausted\n", d->domain_id);
 goto out;
 }
 
-set_bit(nr, vmid_mask);
+set_bit(vmid, vmid_mask);
 
-p2m->vmid = nr;
+p2m->vmid = vmid;
 
 rc = 0;
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 34/39] arm/p2m: Add HVMOP_altp2m_change_gfn

2017-08-30 Thread Sergej Proskurin
This commit adds the functionality to change mfn mappings for specified
gfn's in altp2m views. This mechanism can be used within the context of
VMI, e.g., to establish stealthy debugging.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Moved the altp2m_lock to guard access to d->arch.altp2m_vttbr[idx]
in altp2m_change_gfn.

Locked hp2m to prevent hp2m entries from being modified while the
function "altp2m_change_gfn" is active.

Removed setting ap2m->mem_access_enabled in "altp2m_change_gfn", as
we do not need explicitly splitting pages at this point.

Extended checks allowing to change gfn's in p2m_ram_(rw|ro) memory
only.

Moved the funtion "remove_altp2m_entry" out of this commit.

v4: Cosmetic fixes.

Moved the initialization of the ap2m pointer after having checked
that the altp2m index and the associated altp2m view are valid.

Use the functions "p2m_(set|get)_entry" instead of the helpers
"p2m_lookup_attr", "remove_altp2m_entry", and "modify_altp2m_entry".

Removed the call to altp2m_lock in "altp2m_change_gfn" as it is
sufficient to read lock the host's p2m and write lock the indexed
altp2m.

We make sure that we do not remove a superpage by mistake if the
user requests a specific gfn.

Removed memaccess-related comment as (i) memaccess is handled by
"p2m_set_entry" and (ii) we map always only one page and
"p2m_set_entry" can handle splitting superpages if required.
---
 xen/arch/arm/altp2m.c| 81 
 xen/arch/arm/hvm.c   |  7 +++-
 xen/include/asm-arm/altp2m.h |  6 
 3 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index fd455bdbfc..37820e7b2a 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -305,6 +305,87 @@ out:
 return rc;
 }
 
+int altp2m_change_gfn(struct domain *d,
+  unsigned int idx,
+  gfn_t old_gfn,
+  gfn_t new_gfn)
+{
+struct p2m_domain *hp2m, *ap2m;
+mfn_t mfn;
+p2m_access_t p2ma;
+p2m_type_t p2mt;
+unsigned int page_order;
+int rc = -EINVAL;
+
+hp2m = p2m_get_hostp2m(d);
+
+if ( idx >= MAX_ALTP2M || d->arch.altp2m_p2m[idx] == NULL )
+return rc;
+
+ap2m = d->arch.altp2m_p2m[idx];
+
+p2m_read_lock(hp2m);
+p2m_write_lock(ap2m);
+
+mfn = p2m_get_entry(ap2m, old_gfn, , NULL, NULL);
+
+/* Check whether the page needs to be reset. */
+if ( gfn_eq(new_gfn, INVALID_GFN) )
+{
+/* If mfn is mapped by old_gfn, remove old_gfn from the altp2m table. 
*/
+if ( !mfn_eq(mfn, INVALID_MFN) )
+rc = p2m_set_entry(ap2m, old_gfn, (1UL << THIRD_ORDER), 
INVALID_MFN,
+   p2m_invalid, p2m_access_rwx);
+
+goto out;
+}
+
+/* Check hostp2m if no valid entry in altp2m present. */
+if ( mfn_eq(mfn, INVALID_MFN) )
+{
+mfn = p2m_get_entry(hp2m, old_gfn, , , _order);
+
+if ( mfn_eq(mfn, INVALID_MFN) ||
+ /* Allow changing gfn's in p2m_ram_(rw|ro) memory only. */
+ ((p2mt != p2m_ram_rw) && (p2mt != p2m_ram_ro)) )
+goto out;
+
+/* If this is a superpage, copy that first. */
+if ( page_order != THIRD_ORDER )
+{
+/* Align the old_gfn and mfn to the given pager order. */
+old_gfn = _gfn(gfn_x(old_gfn) & ~((1UL << page_order) - 1));
+mfn = _mfn(mfn_x(mfn) & ~((1UL << page_order) - 1));
+
+if ( p2m_set_entry(ap2m, old_gfn, (1UL << page_order), mfn, p2mt, 
p2ma) )
+goto out;
+}
+}
+
+mfn = p2m_get_entry(ap2m, new_gfn, , , NULL);
+
+/* If new_gfn is not part of altp2m, get the mapping information from hp2m 
*/
+if ( mfn_eq(mfn, INVALID_MFN) )
+mfn = p2m_get_entry(hp2m, new_gfn, , , NULL);
+
+if ( mfn_eq(mfn, INVALID_MFN) ||
+ /* Allow changing gfn's in p2m_ram_(rw|ro) memory only. */
+ ((p2mt != p2m_ram_rw) && (p2mt != p2m_ram_ro)) )
+goto out;
+
+if ( p2m_set_entry(ap2m, old_gfn, (1UL << THIRD_ORDER), mfn, p2mt, p2ma) )
+goto out;
+
+rc = 0;
+
+out:
+p2m_write_unlock(ap2m);
+p2m_read_unlock(hp2m);
+
+return rc;
+}
+
+
 static void altp2m_vcpu_reset(struct vcpu *v)
 {
 v->arch.ap2m_idx = INVALID_ALTP2M;
diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 7e91f2436d..8cf6db24a6 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -148,7 +148,12 @@ static int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg)
 break;
 
 case HVMOP_altp2m_change_gfn:
-rc = -EOPNOTSUPP;
+if ( a.u.change_gfn.pad1 || a.u.change_gfn.pad2 )
+rc = -EINVAL;
+else
+rc = altp2m_change_gfn(d, a.u.change_gfn.view,
+  

[Xen-devel] [PATCH v4 24/39] arm/p2m: Make p2m_put_l3_page ready for altp2m

2017-08-30 Thread Sergej Proskurin
This commit extends the prototype of the function "p2m_put_l3_page" by
an additional function parameter of type "struct p2m_domain*". This is
needed as a future commit will extend the function "p2m_put_l3_page" so
that we can call "put_page" only if the p2m being modified is the
hostp2m.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/p2m.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c5bf64aee0..246250d8c6 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -606,7 +606,7 @@ static int p2m_mem_access_radix_set(struct p2m_domain *p2m, 
gfn_t gfn,
  * TODO: Handle superpages, for now we only take special references for leaf
  * pages (specifically foreign ones, which can't be super mapped today).
  */
-static void p2m_put_l3_page(const lpae_t pte)
+static void p2m_put_l3_page(struct p2m_domain *p2m, const lpae_t pte)
 {
 ASSERT(lpae_valid(pte));
 
@@ -649,7 +649,7 @@ static void p2m_free_entry(struct p2m_domain *p2m,
 if ( level == 3 )
 {
 p2m->stats.mappings[level]--;
-p2m_put_l3_page(entry);
+p2m_put_l3_page(p2m, entry);
 return;
 }
 
-- 
2.13.3


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


[Xen-devel] [PATCH v4 37/39] altp2m: Allow activating altp2m on ARM domains

2017-08-30 Thread Sergej Proskurin
The previous libxl implemention limited the use of altp2m to x86 HVM domains.
This commit extends libxl by introducing the altp2m switch to ARM domains.

Additionally, we introduce the macro LIBXL_HAVE_ARM_ALTP2M in parallel to the
former LIBXL_HAVE_ALTP2M to differentiate between altp2m for x86 and and altp2m
for ARM architectures. We also extend the documentation of the option "altp2m"
in ./docs/man/xl.cfg.pod.5.in.

Signed-off-by: Sergej Proskurin 
---
Cc: Ian Jackson 
Cc: Wei Liu 
---
 tools/libxl/libxl.h | 10 +-
 tools/libxl/libxl_dom.c | 16 ++--
 tools/libxl/libxl_types.idl |  2 +-
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 17045253ab..e7af15bc45 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -872,11 +872,19 @@ typedef struct libxl__ctx libxl_ctx;
 
 /*
  * LIBXL_HAVE_ALTP2M
- * If this is defined, then libxl supports alternate p2m functionality.
+ * If this is defined, then libxl supports alternate p2m functionality for
+ * x86 HVM guests.
  */
 #define LIBXL_HAVE_ALTP2M 1
 
 /*
+ * LIBXL_HAVE_ARM_ALTP2M
+ * If this is defined, then libxl supports alternate p2m functionality for
+ * ARM guests.
+ */
+#define LIBXL_HAVE_ARM_ALTP2M 1
+
+/*
  * LIBXL_HAVE_REMUS
  * If this is defined, then libxl supports remus.
  */
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index f54fd49a73..db77c95a7e 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -314,6 +314,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
 libxl_domain_build_info *const info = _config->b_info;
 libxl_ctx *ctx = libxl__gc_owner(gc);
 char *xs_domid, *con_domid;
+bool altp2m_support = false;
 int rc;
 uint64_t size;
 
@@ -458,18 +459,29 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
 #endif
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 /* Alternate p2m support on x86 is available only for HVM guests. */
-if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
+if (info->type == LIBXL_DOMAIN_TYPE_HVM)
+altp2m_support = true;
+#elif defined(__arm__) || defined(__aarch64__)
+/* Alternate p2m support on ARM is available for all guests. */
+altp2m_support = true;
+#endif
+
+if (altp2m_support) {
 /* The config parameter "altp2m" replaces the parameter "altp2mhvm". 
For
- * legacy reasons, both parameters are accepted on x86 HVM guests.
+ * legacy reasons, both parameters are accepted on x86 HVM guests (only
+ * "altp2m" is accepted on ARM guests).
  *
  * If the legacy field info->u.hvm.altp2m is set, activate altp2m.
  * Otherwise set altp2m based on the field info->altp2m. */
+#if defined(__i386__) || defined(__x86_64__)
 if (info->altp2m == LIBXL_ALTP2M_MODE_DISABLED &&
 libxl_defbool_val(info->u.hvm.altp2m))
 xc_hvm_param_set(ctx->xch, domid, HVM_PARAM_ALTP2M,
  libxl_defbool_val(info->u.hvm.altp2m));
 else
+#endif
 xc_hvm_param_set(ctx->xch, domid, HVM_PARAM_ALTP2M,
  info->altp2m);
 }
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 6e80d36256..412a0b6129 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -583,7 +583,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
 ("arch_arm", Struct(None, [("gic_version", libxl_gic_version),
   ])),
 # Alternate p2m is not bound to any architecture or guest type, as it is
-# supported by x86 HVM and ARM support is planned.
+# supported by x86 HVM and ARM domains.
 ("altp2m", libxl_altp2m_mode),
 
 ], dir=DIR_IN
-- 
2.13.3


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


[Xen-devel] [PATCH v4 36/39] altp2m: Document external-only use on ARM

2017-08-30 Thread Sergej Proskurin
From: Tamas K Lengyel 

Currently, the altp2m feature has been used and thus documented for the
x86 architecture. As we aim to introduce altp2m to ARM, in this commit,
we adjust the documentation by pointing out x86 only parts and thus make
clear that the modes XEN_ALTP2M_external and XEN_ALTP2M_disabled are
also valid for the ARM architecture.

Signed-off-by: Sergej Proskurin 
Signed-off-by: Tamas K Lengyel 
---
Cc: Ian Jackson 
Cc: Wei Liu 
---
v4: We added this patch to our patch series.
---
 docs/man/xl.cfg.pod.5.in | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 79cb2eaea7..259cf18ea6 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1380,7 +1380,7 @@ guest Operating Systems.
 
 =item 

[Xen-devel] [PATCH v4 03/39] arm/p2m: Add hvm_allow_(set|get)_param

2017-08-30 Thread Sergej Proskurin
This commit introduces the functions hvm_allow_(set|get)_param. These
can be used as a filter controlling access to HVM params. This
functionality has been inspired by the x86 implementation.

The introduced filter ensures that the HVM param HVM_PARAM_ALTP2M is set
once and not altered by guest domains.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/hvm.c | 65 ++
 1 file changed, 56 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/hvm.c b/xen/arch/arm/hvm.c
index 042bdda979..6f5f9b41ac 100644
--- a/xen/arch/arm/hvm.c
+++ b/xen/arch/arm/hvm.c
@@ -124,6 +124,48 @@ out:
 return rc;
 }
 
+static int hvm_allow_set_param(struct domain *d, const struct xen_hvm_param *a)
+{
+uint64_t value = d->arch.hvm_domain.params[a->index];
+int rc;
+
+rc = xsm_hvm_param(XSM_TARGET, d, HVMOP_set_param);
+if ( rc )
+return rc;
+
+switch ( a->index )
+{
+/* The following parameters should only be changed once. */
+case HVM_PARAM_ALTP2M:
+if ( value != 0 && a->value != value )
+rc = -EEXIST;
+break;
+default:
+break;
+}
+
+return rc;
+}
+
+static int hvm_allow_get_param(struct domain *d, const struct xen_hvm_param *a)
+{
+int rc;
+
+rc = xsm_hvm_param(XSM_TARGET, d, HVMOP_get_param);
+if ( rc )
+return rc;
+
+switch ( a->index )
+{
+/* This switch statement can be used to control/limit guest access to
+ * certain HVM params. */
+default:
+break;
+}
+
+return rc;
+}
+
 long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
 long rc = 0;
@@ -146,21 +188,26 @@ long do_hvm_op(unsigned long op, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 if ( d == NULL )
 return -ESRCH;
 
-rc = xsm_hvm_param(XSM_TARGET, d, op);
-if ( rc )
-goto param_fail;
-
-if ( op == HVMOP_set_param )
+switch ( op )
 {
+case HVMOP_set_param:
+rc = hvm_allow_set_param(d, );
+if ( rc )
+break;
+
 d->arch.hvm_domain.params[a.index] = a.value;
-}
-else
-{
+break;
+
+case HVMOP_get_param:
+rc = hvm_allow_get_param(d, );
+if ( rc )
+break;
+
 a.value = d->arch.hvm_domain.params[a.index];
 rc = copy_to_guest(arg, , 1) ? -EFAULT : 0;
+break;
 }
 
-param_fail:
 rcu_unlock_domain(d);
 break;
 }
-- 
2.13.3


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


[Xen-devel] [PATCH v4 05/39] arm/p2m: Introduce p2m_is_(hostp2m|altp2m)

2017-08-30 Thread Sergej Proskurin
This commit adds a p2m class to the struct p2m_domain to distinguish
between the host's original p2m and alternate p2m's. The need for this
functionality will be shown in the following commits.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v4: Change return type of p2m_is_(hostp2m|altp2m) from bool_t to bool.
---
 xen/include/asm-arm/p2m.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 500dc88fbc..332d74f11c 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -40,6 +40,11 @@ struct domain;
 
 extern void memory_type_changed(struct domain *);
 
+typedef enum {
+p2m_host,
+p2m_alternate,
+} p2m_class_t;
+
 /* Per-p2m-table state */
 struct p2m_domain {
 /*
@@ -126,6 +131,9 @@ struct p2m_domain {
 
 /* Keeping track on which CPU this p2m was used and for which vCPU */
 uint8_t last_vcpu_ran[NR_CPUS];
+
+/* Choose between: host/alternate. */
+p2m_class_t p2m_class;
 };
 
 /*
@@ -359,6 +367,16 @@ static inline int get_page_and_type(struct page_info *page,
 /* get host p2m table */
 #define p2m_get_hostp2m(d) (&(d)->arch.p2m)
 
+static inline bool p2m_is_hostp2m(const struct p2m_domain *p2m)
+{
+return p2m->p2m_class == p2m_host;
+}
+
+static inline bool p2m_is_altp2m(const struct p2m_domain *p2m)
+{
+return p2m->p2m_class == p2m_alternate;
+}
+
 static inline bool_t p2m_vm_event_sanity_check(struct domain *d)
 {
 return 1;
-- 
2.13.3


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


[Xen-devel] [PATCH v4 00/39] arm/altp2m: Introducing altp2m to ARM

2017-08-30 Thread Sergej Proskurin
Hi all,

The following patch series can be found on Github[0] and is part of my
contribution to last year's Google Summer of Code (GSoC)[1]. My project is
managed by the organization The Honeynet Project. As part of GSoC, I was being
supervised by the Xen maintainer Tamas K. Lengyel , George
D. Webster, and Steven Maresca.

In this patch series, we provide an implementation of the altp2m subsystem for
ARM. Our implementation is based on the altp2m subsystem for x86, providing
additional --alternate-- views on the guest's physical memory by means of the
ARM 2nd stage translation mechanism. The patches introduce new HVMOPs and
extend the p2m subsystem. Also, we extend libxl to support altp2m on ARM and
modify xen-access to test the suggested functionality.

To be more precise, altp2m allows to create and switch to additional p2m views
(i.e. gfn to mfn mappings). These views can be manipulated and activated as
will through the provided HVMOPs. In this way, the active guest instance in
question can seamlessly proceed execution without noticing that anything has
changed. The prime scope of application of altp2m is Virtual Machine
Introspection, where guest systems are analyzed from the outside of the VM.

Altp2m can be activated by means of the guest control parameter "altp2m" on x86
and ARM architectures. For use-cases requiring purely external access to
altp2m, this patch allows to specify if the altp2m interface should be external
only.

This version is a revised version of v3 that has been submitted in 2016. It
incorporates the comments of the previous patch series. Although the previous
version has been submitted last year, I have kept the comments of the
individual patches. Both the purpose and changes from v3 to v4 are stated
inside the individual commits.

Best regards,
~Sergej

[0] https://github.com/sergej-proskurin/xen (branch arm-altp2m-v4)
[1] https://summerofcode.withgoogle.com/projects/#4970052843470848

Sergej Proskurin (38):
  arm/p2m: Introduce p2m_(switch|restore)_vttbr_and_(g|s)et_flags
  arm/p2m: Add first altp2m HVMOP stubs
  arm/p2m: Add hvm_allow_(set|get)_param
  arm/p2m: Add HVMOP_altp2m_get_domain_state
  arm/p2m: Introduce p2m_is_(hostp2m|altp2m)
  arm/p2m: Cosmetic fix - substitute _gfn(ULONG_MAX) for INVALID_GFN
  arm/p2m: Move hostp2m init/teardown to individual functions
  arm/p2m: Cosmetic fix - function prototype of p2m_alloc_table
  arm/p2m: Rename parameter in p2m_alloc_vmid
  arm/p2m: Change func prototype and impl of p2m_(alloc|free)_vmid
  altp2m: Move (MAX|INVALID)_ALTP2M to xen/p2m-common.h
  arm/p2m: Add altp2m init/teardown routines
  arm/p2m: Add altp2m table flushing routine
  arm/p2m: Add HVMOP_altp2m_set_domain_state
  arm/p2m: Add HVMOP_altp2m_create_p2m
  arm/p2m: Add HVMOP_altp2m_destroy_p2m
  arm/p2m: Add HVMOP_altp2m_switch_p2m
  arm/p2m: Add p2m_get_active_p2m macro
  arm/p2m: Make p2m_restore_state ready for altp2m
  arm/p2m: Make get_page_from_gva ready for altp2m
  arm/p2m: Cosmetic fix - __p2m_get_mem_access
  arm/p2m: Make p2m_mem_access_check ready for altp2m
  arm/p2m: Cosmetic fix - function prototypes
  arm/p2m: Make p2m_put_l3_page ready for altp2m
  arm/p2m: Modify reference count only if hostp2m active
  arm/p2m: Add HVMOP_altp2m_set_mem_access
  arm/p2m: Add altp2m_propagate_change
  altp2m: Rename p2m_altp2m_check to altp2m_check
  x86/altp2m: Move altp2m_check to altp2m.c
  arm/altp2m: Move altp2m_check to altp2m.h
  arm/altp2m: Introduce altp2m_switch_vcpu_altp2m_by_id
  arm/altp2m: Make altp2m_vcpu_idx ready for altp2m
  arm/p2m: Add altp2m paging mechanism
  arm/p2m: Add HVMOP_altp2m_change_gfn
  arm/p2m: Adjust debug information to altp2m
  altp2m: Allow activating altp2m on ARM domains
  arm/xen-access: Extend xen-access for altp2m on ARM
  arm/xen-access: Add test of xc_altp2m_change_gfn

Tamas K Lengyel (1):
  altp2m: Document external-only use on ARM

 docs/man/xl.cfg.pod.5.in|   8 +-
 tools/libxl/libxl.h |  10 +-
 tools/libxl/libxl_dom.c |  16 +-
 tools/libxl/libxl_types.idl |   2 +-
 tools/tests/xen-access/Makefile |   2 +-
 tools/tests/xen-access/xen-access.c | 213 -
 xen/arch/arm/Makefile   |   1 +
 xen/arch/arm/altp2m.c   | 601 
 xen/arch/arm/hvm.c  | 202 +++-
 xen/arch/arm/mem_access.c   | 112 +--
 xen/arch/arm/p2m.c  | 219 +
 xen/arch/arm/traps.c|  17 +
 xen/arch/x86/mm/altp2m.c|   6 +
 xen/arch/x86/mm/p2m.c   |   6 -
 xen/common/vm_event.c   |   3 +-
 xen/include/asm-arm/altp2m.h|  73 -
 xen/include/asm-arm/domain.h|  15 +
 xen/include/asm-arm/p2m.h   |  62 +++-
 xen/include/asm-x86/altp2m.h|   3 +
 xen/include/asm-x86/domain.h|   3 +-
 xen/include/asm-x86/p2m.h   |   3 -
 xen/include/xen/altp2m-common.h |   8 +
 22 

[Xen-devel] [PATCH v4 33/39] arm/p2m: Add altp2m paging mechanism

2017-08-30 Thread Sergej Proskurin
This commit adds the function "altp2m_lazy_copy" implementing the altp2m
paging mechanism. The function "altp2m_lazy_copy" lazily copies the
hostp2m's mapping into the currently active altp2m view on 2nd stage
translation faults on instruction or data access.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: Cosmetic fixes.

Locked hostp2m in the function "altp2m_lazy_copy" to avoid a mapping
being changed in hostp2m before it has been inserted into the
valtp2m view.

Removed unnecessary calls to "p2m_mem_access_check" in the functions
"do_trap_instr_abort_guest" and "do_trap_data_abort_guest" after a
translation fault has been handled by the function
"altp2m_lazy_copy".

Adapted "altp2m_lazy_copy" to return the value "true" if the
encountered translation fault encounters a valid entry inside of the
currently active altp2m view. If multiple vcpus are using the same
altp2m, it is likely that both generate a translation fault, whereas
the first one will be already handled by "altp2m_lazy_copy". With
this change the 2nd vcpu will retry accessing the faulting address.

Changed order of altp2m checking and MMIO emulation within the
function "do_trap_data_abort_guest".  Now, altp2m is checked and
handled only if the MMIO does not have to be emulated.

Changed the function prototype of "altp2m_lazy_copy".  This commit
removes the unnecessary struct p2m_domain* from the previous
function prototype.  Also, this commit removes the unnecessary
argument gva.  Finally, this commit changes the address of the
function parameter gpa from paddr_t to gfn_t and renames it to gfn.

Moved the altp2m handling mechanism into a separate function
"try_handle_altp2m".

Moved the functions "p2m_altp2m_check" and
"altp2m_switch_vcpu_altp2m_by_id" out of this patch.

Moved applied code movement into a separate patch.

v4: Cosmetic fixes.

Changed the function prototype of "altp2m_lazy_copy" and
"try_handle_altp2m" by removing the unused function parameter of
type "struct npfec".

Removed the function "try_handle_altp2m".

Please note that we cannot reorder the calls to "altp2m_lazy_copy"
and "gfn_to_mfn" as to deprioritize altp2m. If the call to
"gfn_to_mfn" would be performed before "altp2m_lazy_copy", the
system would likely stall if altp2m was active. This is because the
"p2m_lookup" routine in "gfn_to_mfn" considers only the host's p2m,
which will most likely return a mfn != INVALID_MFN and thus entirely
skip the call to "altp2m_lazy_copy".

Use the functions "p2m_(set|get)_entry" instead of the helpers
"p2m_lookup_attr" and "modify_altp2m_entry" in the function
"altp2m_lazy_copy". Therefore, we write-lock the altp2m view
throughout the entire function.

Moved read-locking of hp2m to the beginning of the function
"altp2m_lazy_copy".
---
 xen/arch/arm/altp2m.c| 66 
 xen/arch/arm/traps.c | 17 
 xen/include/asm-arm/altp2m.h |  4 +++
 3 files changed, 87 insertions(+)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 9c9876c932..fd455bdbfc 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -155,6 +155,72 @@ int altp2m_set_mem_access(struct domain *d,
 return rc;
 }
 
+/*
+ * The function altp2m_lazy_copy returns "false" on error.  The return value
+ * "true" signals that either the mapping has been successfully lazy-copied
+ * from the hostp2m to the currently active altp2m view or that the altp2m view
+ * holds already a valid mapping. The latter is the case if multiple vcpus
+ * using the same altp2m view generate a translation fault that is led back in
+ * both cases to the same mapping and the first fault has been already handled.
+ */
+bool altp2m_lazy_copy(struct vcpu *v, gfn_t gfn)
+{
+struct domain *d = v->domain;
+struct p2m_domain *hp2m = p2m_get_hostp2m(d), *ap2m = NULL;
+p2m_type_t p2mt;
+p2m_access_t p2ma;
+mfn_t mfn;
+unsigned int page_order;
+int rc;
+
+ap2m = altp2m_get_altp2m(v);
+if ( unlikely(!ap2m) )
+return false;
+
+/*
+ * Lock hp2m to prevent the hostp2m to change a mapping before it is added
+ * to the altp2m view.
+ */
+p2m_read_lock(hp2m);
+p2m_write_lock(ap2m);
+
+/* Check if entry is part of the altp2m view. */
+mfn = p2m_get_entry(ap2m, gfn, NULL, NULL, NULL);
+
+/*
+ * If multiple vcpus are using the same altp2m, it is likely that both
+ * generate a translation fault, whereas the first one will be handled
+ * successfully and the second will encounter a valid mapping that has
+ * already been added as a result of the previous translation fault. In
+ * this case, the 2nd vcpu needs to retry accessing the faulting address.
+   

[Xen-devel] [PATCH v4 06/39] arm/p2m: Cosmetic fix - substitute _gfn(ULONG_MAX) for INVALID_GFN

2017-08-30 Thread Sergej Proskurin
In ./xen/arch/arm/p2m.c, we compare the gfn's with INVALID_GFN
throughout the code. Thus it makes sense to use the macro INVALID_GFN
instead of a hard coded value to initialize "p2m->lowest_mapped_gfn".

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
 xen/arch/arm/p2m.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 4334e3bc81..5e86368010 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1238,7 +1238,7 @@ int p2m_init(struct domain *d)
 
 p2m->domain = d;
 p2m->max_mapped_gfn = _gfn(0);
-p2m->lowest_mapped_gfn = _gfn(ULONG_MAX);
+p2m->lowest_mapped_gfn = INVALID_GFN;
 
 p2m->default_access = p2m_access_rwx;
 p2m->mem_access_enabled = false;
-- 
2.13.3


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


[Xen-devel] [PATCH v4 23/39] arm/p2m: Cosmetic fix - function prototypes

2017-08-30 Thread Sergej Proskurin
This commit changes the prototypes of the following functions:
- p2m_insert_mapping
- p2m_remove_mapping

These changes are required as our implementation reuses most of the
existing ARM p2m implementation to set page table attributes of the
individual altp2m views. Therefore, exiting function prototypes have
been extended to hold another argument (of type struct p2m_domain *).
This allows to specify the p2m/altp2m domain that should be processed by
the individual function -- instead of accessing the host's default p2m
domain.

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v2: Adoption of the functions "__p2m_lookup" and "__p2m_get_mem_access"
have been moved out of this commit.
---
 xen/arch/arm/p2m.c | 20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 20d7784708..c5bf64aee0 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1012,13 +1012,12 @@ int p2m_set_entry(struct p2m_domain *p2m,
 return rc;
 }
 
-static inline int p2m_insert_mapping(struct domain *d,
+static inline int p2m_insert_mapping(struct p2m_domain *p2m,
  gfn_t start_gfn,
  unsigned long nr,
  mfn_t mfn,
  p2m_type_t t)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 int rc;
 
 p2m_write_lock(p2m);
@@ -1028,12 +1027,11 @@ static inline int p2m_insert_mapping(struct domain *d,
 return rc;
 }
 
-static inline int p2m_remove_mapping(struct domain *d,
+static inline int p2m_remove_mapping(struct p2m_domain *p2m,
  gfn_t start_gfn,
  unsigned long nr,
  mfn_t mfn)
 {
-struct p2m_domain *p2m = p2m_get_hostp2m(d);
 int rc;
 
 p2m_write_lock(p2m);
@@ -1050,7 +1048,7 @@ int map_regions_p2mt(struct domain *d,
  mfn_t mfn,
  p2m_type_t p2mt)
 {
-return p2m_insert_mapping(d, gfn, nr, mfn, p2mt);
+return p2m_insert_mapping(p2m_get_hostp2m(d), gfn, nr, mfn, p2mt);
 }
 
 int unmap_regions_p2mt(struct domain *d,
@@ -1058,7 +1056,7 @@ int unmap_regions_p2mt(struct domain *d,
unsigned long nr,
mfn_t mfn)
 {
-return p2m_remove_mapping(d, gfn, nr, mfn);
+return p2m_remove_mapping(p2m_get_hostp2m(d), gfn, nr, mfn);
 }
 
 int map_mmio_regions(struct domain *d,
@@ -1066,7 +1064,7 @@ int map_mmio_regions(struct domain *d,
  unsigned long nr,
  mfn_t mfn)
 {
-return p2m_insert_mapping(d, start_gfn, nr, mfn, p2m_mmio_direct_dev);
+return p2m_insert_mapping(p2m_get_hostp2m(d), start_gfn, nr, mfn, 
p2m_mmio_direct_dev);
 }
 
 int unmap_mmio_regions(struct domain *d,
@@ -1074,7 +1072,7 @@ int unmap_mmio_regions(struct domain *d,
unsigned long nr,
mfn_t mfn)
 {
-return p2m_remove_mapping(d, start_gfn, nr, mfn);
+return p2m_remove_mapping(p2m_get_hostp2m(d), start_gfn, nr, mfn);
 }
 
 int map_dev_mmio_region(struct domain *d,
@@ -1087,7 +1085,7 @@ int map_dev_mmio_region(struct domain *d,
 if ( !(nr && iomem_access_permitted(d, mfn_x(mfn), mfn_x(mfn) + nr - 1)) )
 return 0;
 
-res = p2m_insert_mapping(d, gfn, nr, mfn, p2m_mmio_direct_c);
+res = p2m_insert_mapping(p2m_get_hostp2m(d), gfn, nr, mfn, 
p2m_mmio_direct_c);
 if ( res < 0 )
 {
 printk(XENLOG_G_ERR "Unable to map MFNs [%#"PRI_mfn" - %#"PRI_mfn" in 
Dom%d\n",
@@ -1104,13 +1102,13 @@ int guest_physmap_add_entry(struct domain *d,
 unsigned long page_order,
 p2m_type_t t)
 {
-return p2m_insert_mapping(d, gfn, (1 << page_order), mfn, t);
+return p2m_insert_mapping(p2m_get_hostp2m(d), gfn, (1 << page_order), mfn, 
t);
 }
 
 int guest_physmap_remove_page(struct domain *d, gfn_t gfn, mfn_t mfn,
   unsigned int page_order)
 {
-return p2m_remove_mapping(d, gfn, (1 << page_order), mfn);
+return p2m_remove_mapping(p2m_get_hostp2m(d), gfn, (1 << page_order), mfn);
 }
 
 static int p2m_alloc_table(struct p2m_domain *p2m)
-- 
2.13.3


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


[Xen-devel] [PATCH v4 31/39] arm/altp2m: Introduce altp2m_switch_vcpu_altp2m_by_id

2017-08-30 Thread Sergej Proskurin
This commit adds the function "altp2m_switch_vcpu_altp2m_by_id" that is
executed after checking whether the vcpu should be switched to a different
altp2m within the function "altp2m_check".

Signed-off-by: Sergej Proskurin 
---
Cc: Stefano Stabellini 
Cc: Julien Grall 
---
v3: This commit has been moved out of the commit "arm/p2m: Add altp2m
paging mechanism".

Moved the function "p2m_altp2m_check" from p2m.c to altp2m.c and
renamed it to "altp2m_check". This change required the adoption of
the complementary function in the x86 architecture.

v4: Moved code renaming and movement of ARM and x86 related code out of
this commit.

While parts of this commit have been Acked-by Razvan Cojocaru and
George Dunlap in v3, we have removed the Acks as the previous patch
has been distributed across multiple smaller patches and now needs
to be reviewed again.
---
 xen/arch/arm/altp2m.c| 32 
 xen/include/asm-arm/altp2m.h |  6 +-
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 4883b1323b..9c9876c932 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -32,6 +32,38 @@ struct p2m_domain *altp2m_get_altp2m(struct vcpu *v)
 return v->domain->arch.altp2m_p2m[idx];
 }
 
+static bool altp2m_switch_vcpu_altp2m_by_id(struct vcpu *v, unsigned int idx)
+{
+struct domain *d = v->domain;
+bool rc = false;
+
+if ( unlikely(idx >= MAX_ALTP2M) )
+return rc;
+
+altp2m_lock(d);
+
+if ( d->arch.altp2m_p2m[idx] != NULL )
+{
+if ( idx != v->arch.ap2m_idx )
+{
+atomic_dec(_get_altp2m(v)->active_vcpus);
+v->arch.ap2m_idx = idx;
+atomic_inc(_get_altp2m(v)->active_vcpus);
+}
+rc = true;
+}
+
+altp2m_unlock(d);
+
+return rc;
+}
+
+void altp2m_check(struct vcpu *v, uint16_t idx)
+{
+if ( altp2m_active(v->domain) )
+altp2m_switch_vcpu_altp2m_by_id(v, idx);
+}
+
 int altp2m_switch_domain_altp2m_by_id(struct domain *d, unsigned int idx)
 {
 struct vcpu *v;
diff --git a/xen/include/asm-arm/altp2m.h b/xen/include/asm-arm/altp2m.h
index 5a2444e8f8..f9e14ab1dc 100644
--- a/xen/include/asm-arm/altp2m.h
+++ b/xen/include/asm-arm/altp2m.h
@@ -50,11 +50,7 @@ void altp2m_vcpu_destroy(struct vcpu *v);
 struct p2m_domain *altp2m_get_altp2m(struct vcpu *v);
 
 /* Check to see if vcpu should be switched to a different p2m. */
-static inline
-void altp2m_check(struct vcpu *v, uint16_t idx)
-{
-/* Not supported on ARM. */
-}
+void altp2m_check(struct vcpu *v, uint16_t idx);
 
 /* Switch alternate p2m for entire domain */
 int altp2m_switch_domain_altp2m_by_id(struct domain *d,
-- 
2.13.3


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


[Xen-devel] [libvirt test] 112950: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112950 libvirt real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112950/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 10 debian-hvm-install fail 
REGR. vs. 112918

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-libvirt-qcow2  1 build-check(1)   blocked  n/a
 test-arm64-arm64-libvirt  1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112918
 build-arm64-xsm   2 hosts-allocate  broken like 112918
 build-arm64   2 hosts-allocate  broken like 112918
 build-arm64-pvops 3 capture-logsbroken like 112918
 build-arm64-xsm   3 capture-logsbroken like 112918
 build-arm64   3 capture-logsbroken like 112918
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112918
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112918
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112918
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass

version targeted for testing:
 libvirt  e4cb8500810a310a10a6cb359e1b53fac03ed597
baseline version:
 libvirt  5aaa304f8dbc5ddf0b0ca56f7551bdb9e554db0a

Last test of basis   112918  2017-08-29 04:20:17 Z1 days
Testing same since   112950  2017-08-30 04:20:16 Z0 days1 attempts


People who touched revisions under test:
  Daniel P. Berrange 
  Kothapally Madhu Pavan 
  Martin Kletzander 
  Michal Privoznik 
  Pavel Hrdina 

jobs:
 build-amd64-xsm  pass
 build-arm64-xsm  broken  
 build-armhf-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-arm64-libvirt  blocked 
 build-armhf-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-arm64-pvopsbroken  
 build-armhf-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm   pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsmfail
 test-amd64-amd64-libvirt-xsm pass
 test-arm64-arm64-libvirt-xsm blocked 
 test-armhf-armhf-libvirt-xsm pass
 test-amd64-i386-libvirt-xsm  pass
 test-amd64-amd64-libvirt pass
 test-arm64-arm64-libvirt blocked 
 test-armhf-armhf-libvirt pass
 test-amd64-i386-libvirt  pass
 test-amd64-amd64-libvirt-pairpass
 test-amd64-i386-libvirt-pair pass
 test-arm64-arm64-libvirt-qcow2   blocked 
 test-armhf-armhf-libvirt-raw pass
 test-amd64-amd64-libvirt-vhd pass




[Xen-devel] [PATCH 1/6] example/vhost_xen: remove

2017-08-30 Thread Jianfeng Tan
Signed-off-by: Jianfeng Tan 
---
 MAINTAINERS |1 -
 examples/Makefile   |1 -
 examples/vhost_xen/Makefile |   52 --
 examples/vhost_xen/main.c   | 1522 ---
 examples/vhost_xen/main.h   |   66 --
 examples/vhost_xen/vhost_monitor.c  |  595 --
 examples/vhost_xen/virtio-net.h |  113 ---
 examples/vhost_xen/xen_vhost.h  |  148 
 examples/vhost_xen/xenstore_parse.c |  775 --
 9 files changed, 3273 deletions(-)
 delete mode 100644 examples/vhost_xen/Makefile
 delete mode 100644 examples/vhost_xen/main.c
 delete mode 100644 examples/vhost_xen/main.h
 delete mode 100644 examples/vhost_xen/vhost_monitor.c
 delete mode 100644 examples/vhost_xen/virtio-net.h
 delete mode 100644 examples/vhost_xen/xen_vhost.h
 delete mode 100644 examples/vhost_xen/xenstore_parse.c

diff --git a/MAINTAINERS b/MAINTAINERS
index a0cd75e..fe6c6db 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -196,7 +196,6 @@ F: lib/librte_eal/linuxapp/eal/*xen*
 F: lib/librte_eal/linuxapp/eal/include/exec-env/rte_dom0_common.h
 F: drivers/net/xenvirt/
 F: doc/guides/xen/
-F: examples/vhost_xen/
 F: doc/guides/nics/features/xenvirt.ini
 
 FreeBSD EAL (with overlaps)
diff --git a/examples/Makefile b/examples/Makefile
index 28354ff..d27eddd 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -89,7 +89,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += tep_termination
 endif
 DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += timer
 DIRS-$(CONFIG_RTE_LIBRTE_VHOST) += vhost vhost_scsi
-DIRS-$(CONFIG_RTE_LIBRTE_XEN_DOM0) += vhost_xen
 DIRS-y += vmdq
 DIRS-y += vmdq_dcb
 ifeq ($(CONFIG_RTE_LIBRTE_POWER), y)
diff --git a/examples/vhost_xen/Makefile b/examples/vhost_xen/Makefile
deleted file mode 100644
index ad2466a..000
--- a/examples/vhost_xen/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#   BSD LICENSE
-#
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
-#   All rights reserved.
-#
-#   Redistribution and use in source and binary forms, with or without
-#   modification, are permitted provided that the following conditions
-#   are met:
-#
-# * Redistributions of source code must retain the above copyright
-#   notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in
-#   the documentation and/or other materials provided with the
-#   distribution.
-# * Neither the name of Intel Corporation nor the names of its
-#   contributors may be used to endorse or promote products derived
-#   from this software without specific prior written permission.
-#
-#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-ifeq ($(RTE_SDK),)
-$(error "Please define RTE_SDK environment variable")
-endif
-
-# Default target, can be overridden by command line or environment
-RTE_TARGET ?= x86_64-native-linuxapp-gcc
-
-include $(RTE_SDK)/mk/rte.vars.mk
-
-# binary name
-APP = vhost-switch
-
-# all source are stored in SRCS-y
-SRCS-y := main.c vhost_monitor.c xenstore_parse.c
-
-CFLAGS += -O2 -I/usr/local/include -D_FILE_OFFSET_BITS=64 -Wno-unused-parameter
-CFLAGS += $(WERROR_FLAGS)
-CFLAGS += -D_GNU_SOURCE
-LDFLAGS += -lxenstore
-
-include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/vhost_xen/main.c b/examples/vhost_xen/main.c
deleted file mode 100644
index eba4d35..000
--- a/examples/vhost_xen/main.c
+++ /dev/null
@@ -1,1522 +0,0 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
- *   All rights reserved.
- *
- *   Redistribution and use in source and binary forms, with or without
- *   modification, are permitted provided that the following conditions
- *   are met:
- *
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in
- *   the documentation and/or other materials provided with the
- *   

[Xen-devel] [PATCH 0/6] remove xen dom0 support in DPDK

2017-08-30 Thread Jianfeng Tan
Following the calls on the mailing list:
http://dpdk.org/ml/archives/dev/2017-June/068151.html
The Technical Board decided to drop Xen dom0 support from EAL:
http://dpdk.org/ml/archives/dev/2017-June/068615.html

This series remove xen dom0 support in DPDK, as well as xenvirt PMD and
vhost_xen example.

What are effected?

After these patches, users cannot run DPDK applications inside xen dom0.

What are not effected?

Users can still run DPDK applications inside xen domU on pass-throughed
physical devices and virtio devices; on the host, users still can run
DPDK applications same as before.

Jianfeng Tan (6):
  example/vhost_xen: remove
  net/xenvirt: remove
  xen: remove xen dependency in app, examples, test
  xen: remove xen dependency in drivers, ether, mempool
  eal: remove xen dom0 support
  eal: remove API rte_mem_phy2mch

 MAINTAINERS|   10 -
 app/test-pmd/Makefile  |4 -
 app/test-pmd/testpmd.c |   14 +-
 config/common_base |   10 -
 config/defconfig_arm-armv7a-linuxapp-gcc   |1 -
 doc/guides/index.rst   |1 -
 doc/guides/linux_gsg/build_sample_apps.rst |5 +-
 doc/guides/linux_gsg/sys_reqs.rst  |   53 -
 doc/guides/nics/features/xenvirt.ini   |6 -
 doc/guides/prog_guide/source_org.rst   |1 -
 doc/guides/rel_notes/deprecation.rst   |3 -
 doc/guides/rel_notes/release_17_11.rst |   14 +
 doc/guides/testpmd_app_ug/run_app.rst  |4 -
 doc/guides/xen/img/dpdk_xen_pkt_switch.png |  Bin 163842 -> 0 bytes
 doc/guides/xen/img/grant_refs.png  |  Bin 6405 -> 0 bytes
 doc/guides/xen/img/grant_table.png |  Bin 96762 -> 0 bytes
 doc/guides/xen/index.rst   |   38 -
 doc/guides/xen/pkt_switch.rst  |  470 --
 drivers/crypto/qat/qat_qp.c|7 +-
 drivers/net/Makefile   |2 -
 drivers/net/e1000/em_rxtx.c|4 +-
 drivers/net/e1000/igb_rxtx.c   |4 +-
 drivers/net/fm10k/fm10k_ethdev.c   |4 +-
 drivers/net/i40e/i40e_ethdev.c |2 +-
 drivers/net/i40e/i40e_fdir.c   |2 +-
 drivers/net/i40e/i40e_rxtx.c   |   16 +-
 drivers/net/ixgbe/ixgbe_rxtx.c |4 +-
 drivers/net/sfc/sfc.c  |2 +-
 drivers/net/xenvirt/Makefile   |   57 -
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  766 --
 drivers/net/xenvirt/rte_eth_xenvirt.h  |   61 -
 drivers/net/xenvirt/rte_eth_xenvirt_version.map|7 -
 drivers/net/xenvirt/rte_mempool_gntalloc.c |  295 
 drivers/net/xenvirt/rte_xen_lib.c  |  454 --
 drivers/net/xenvirt/rte_xen_lib.h  |  116 --
 drivers/net/xenvirt/virtio_logs.h  |   70 -
 drivers/net/xenvirt/virtqueue.h|  273 
 examples/Makefile  |1 -
 examples/ip_pipeline/app.h |4 -
 examples/ip_pipeline/config_parse.c|   19 -
 examples/ip_pipeline/init.c|5 -
 examples/kni/main.c|3 -
 examples/vhost_xen/Makefile|   52 -
 examples/vhost_xen/main.c  | 1522 
 examples/vhost_xen/main.h  |   66 -
 examples/vhost_xen/vhost_monitor.c |  595 
 examples/vhost_xen/virtio-net.h|  113 --
 examples/vhost_xen/xen_vhost.h |  148 --
 examples/vhost_xen/xenstore_parse.c|  775 --
 .../bsdapp/eal/include/exec-env/rte_dom0_common.h  |  107 --
 lib/librte_eal/common/eal_common_options.c |3 -
 lib/librte_eal/common/eal_internal_cfg.h   |1 -
 lib/librte_eal/common/eal_options.h|2 -
 lib/librte_eal/common/include/rte_memory.h |   71 -
 lib/librte_eal/linuxapp/Makefile   |2 -
 lib/librte_eal/linuxapp/eal/Makefile   |5 +-
 lib/librte_eal/linuxapp/eal/eal.c  |   24 -
 lib/librte_eal/linuxapp/eal/eal_memory.c   |   56 -
 lib/librte_eal/linuxapp/eal/eal_xen_memory.c   |  381 -
 .../eal/include/exec-env/rte_dom0_common.h |  108 --
 lib/librte_eal/linuxapp/igb_uio/igb_uio.c  |   54 -
 lib/librte_eal/linuxapp/xen_dom0/Makefile  |   53 -
 lib/librte_eal/linuxapp/xen_dom0/compat.h  |   15 -
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_dev.h |  107 --
 lib/librte_eal/linuxapp/xen_dom0/dom0_mm_misc.c|  780 --
 lib/librte_ether/rte_ethdev.c  

[Xen-devel] [PATCH 2/6] net/xenvirt: remove

2017-08-30 Thread Jianfeng Tan
Signed-off-by: Jianfeng Tan 
---
 MAINTAINERS |   2 -
 app/test-pmd/Makefile   |   4 -
 app/test-pmd/testpmd.c  |  12 -
 config/common_base  |   5 -
 config/defconfig_arm-armv7a-linuxapp-gcc|   1 -
 doc/guides/nics/features/xenvirt.ini|   6 -
 drivers/net/Makefile|   2 -
 drivers/net/xenvirt/Makefile|  57 --
 drivers/net/xenvirt/rte_eth_xenvirt.c   | 766 
 drivers/net/xenvirt/rte_eth_xenvirt.h   |  61 --
 drivers/net/xenvirt/rte_eth_xenvirt_version.map |   7 -
 drivers/net/xenvirt/rte_mempool_gntalloc.c  | 295 -
 drivers/net/xenvirt/rte_xen_lib.c   | 454 --
 drivers/net/xenvirt/rte_xen_lib.h   | 116 
 drivers/net/xenvirt/virtio_logs.h   |  70 ---
 drivers/net/xenvirt/virtqueue.h | 273 -
 mk/rte.app.mk   |   1 -
 pkg/dpdk.spec   |   3 -
 18 files changed, 2135 deletions(-)
 delete mode 100644 doc/guides/nics/features/xenvirt.ini
 delete mode 100644 drivers/net/xenvirt/Makefile
 delete mode 100644 drivers/net/xenvirt/rte_eth_xenvirt.c
 delete mode 100644 drivers/net/xenvirt/rte_eth_xenvirt.h
 delete mode 100644 drivers/net/xenvirt/rte_eth_xenvirt_version.map
 delete mode 100644 drivers/net/xenvirt/rte_mempool_gntalloc.c
 delete mode 100644 drivers/net/xenvirt/rte_xen_lib.c
 delete mode 100644 drivers/net/xenvirt/rte_xen_lib.h
 delete mode 100644 drivers/net/xenvirt/virtio_logs.h
 delete mode 100644 drivers/net/xenvirt/virtqueue.h

diff --git a/MAINTAINERS b/MAINTAINERS
index fe6c6db..003e72e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -194,9 +194,7 @@ M: Jianfeng Tan 
 F: lib/librte_eal/linuxapp/xen_dom0/
 F: lib/librte_eal/linuxapp/eal/*xen*
 F: lib/librte_eal/linuxapp/eal/include/exec-env/rte_dom0_common.h
-F: drivers/net/xenvirt/
 F: doc/guides/xen/
-F: doc/guides/nics/features/xenvirt.ini
 
 FreeBSD EAL (with overlaps)
 M: Bruce Richardson 
diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index c36be19..b6e80dd 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -77,10 +77,6 @@ ifeq ($(CONFIG_RTE_LIBRTE_BNXT_PMD),y)
 LDLIBS += -lrte_pmd_bnxt
 endif
 
-ifeq ($(CONFIG_RTE_LIBRTE_PMD_XENVIRT),y)
-LDLIBS += -lrte_pmd_xenvirt
-endif
-
 endif
 
 CFLAGS_cmdline.o := -D_GNU_SOURCE
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 7d40139..f8d02ae 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -76,9 +76,6 @@
 #ifdef RTE_LIBRTE_IXGBE_PMD
 #include 
 #endif
-#ifdef RTE_LIBRTE_PMD_XENVIRT
-#include 
-#endif
 #ifdef RTE_LIBRTE_PDUMP
 #include 
 #endif
@@ -497,15 +494,6 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
"create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n",
pool_name, nb_mbuf, mbuf_seg_size, socket_id);
 
-#ifdef RTE_LIBRTE_PMD_XENVIRT
-   rte_mp = rte_mempool_gntalloc_create(pool_name, nb_mbuf, mb_size,
-   (unsigned) mb_mempool_cache,
-   sizeof(struct rte_pktmbuf_pool_private),
-   rte_pktmbuf_pool_init, NULL,
-   rte_pktmbuf_init, NULL,
-   socket_id, 0);
-#endif
-
/* if the former XEN allocation failed fall back to normal allocation */
if (rte_mp == NULL) {
if (mp_anon != 0) {
diff --git a/config/common_base b/config/common_base
index 5e97a08..93928b6 100644
--- a/config/common_base
+++ b/config/common_base
@@ -411,11 +411,6 @@ CONFIG_RTE_LIBRTE_AVP_DEBUG_BUFFERS=n
 CONFIG_RTE_LIBRTE_PMD_TAP=n
 
 #
-# Compile Xen PMD
-#
-CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
-
-#
 # Compile null PMD
 #
 CONFIG_RTE_LIBRTE_PMD_NULL=y
diff --git a/config/defconfig_arm-armv7a-linuxapp-gcc 
b/config/defconfig_arm-armv7a-linuxapp-gcc
index 00bc2ab..6628567 100644
--- a/config/defconfig_arm-armv7a-linuxapp-gcc
+++ b/config/defconfig_arm-armv7a-linuxapp-gcc
@@ -76,7 +76,6 @@ CONFIG_RTE_LIBRTE_I40E_PMD=n
 CONFIG_RTE_LIBRTE_IXGBE_PMD=n
 CONFIG_RTE_LIBRTE_MLX4_PMD=n
 CONFIG_RTE_LIBRTE_VMXNET3_PMD=n
-CONFIG_RTE_LIBRTE_PMD_XENVIRT=n
 CONFIG_RTE_LIBRTE_PMD_BNX2X=n
 CONFIG_RTE_LIBRTE_QEDE_PMD=n
 CONFIG_RTE_LIBRTE_SFC_EFX_PMD=n
diff --git a/doc/guides/nics/features/xenvirt.ini 
b/doc/guides/nics/features/xenvirt.ini
deleted file mode 100644
index 8ab5f46..000
--- a/doc/guides/nics/features/xenvirt.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-;
-; Supported features of the 'xenvirt' network poll mode driver.
-;
-; Refer to default.ini for the full list of available PMD features.
-;
-[Features]
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index d33c959..0e00cd1 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -97,8 +97,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 

[Xen-devel] [PATCH 4/6] xen: remove xen dependency in drivers, ether, mempool

2017-08-30 Thread Jianfeng Tan
Signed-off-by: Jianfeng Tan 
---
 drivers/crypto/qat/qat_qp.c  | 7 +--
 drivers/net/i40e/i40e_rxtx.c | 8 ++--
 lib/librte_ether/rte_ethdev.c| 7 +--
 lib/librte_mempool/rte_mempool.c | 8 ++--
 4 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/drivers/crypto/qat/qat_qp.c b/drivers/crypto/qat/qat_qp.c
index 5048d21..34f75ca 100644
--- a/drivers/crypto/qat/qat_qp.c
+++ b/drivers/crypto/qat/qat_qp.c
@@ -122,14 +122,9 @@ queue_dma_zone_reserve(const char *queue_name, uint32_t 
queue_size,
break;
default:
memzone_flags = RTE_MEMZONE_SIZE_HINT_ONLY;
-}
-#ifdef RTE_LIBRTE_XEN_DOM0
-   return rte_memzone_reserve_bounded(queue_name, queue_size,
-   socket_id, 0, RTE_CACHE_LINE_SIZE, RTE_PGSIZE_2M);
-#else
+   }
return rte_memzone_reserve_aligned(queue_name, queue_size, socket_id,
memzone_flags, queue_size);
-#endif
 }
 
 int qat_crypto_sym_qp_setup(struct rte_cryptodev *dev, uint16_t queue_pair_id,
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index d42c23c..f571e79 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2221,12 +2221,8 @@ i40e_memzone_reserve(const char *name, uint32_t len, int 
socket_id)
if (mz)
return mz;
 
-   if (rte_xen_dom0_supported())
-   mz = rte_memzone_reserve_bounded(name, len,
-   socket_id, 0, I40E_RING_BASE_ALIGN, 
RTE_PGSIZE_2M);
-   else
-   mz = rte_memzone_reserve_aligned(name, len,
-   socket_id, 0, I40E_RING_BASE_ALIGN);
+   mz = rte_memzone_reserve_aligned(name, len,
+socket_id, 0, I40E_RING_BASE_ALIGN);
return mz;
 }
 
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 0597641..cb0bde7 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2818,12 +2818,7 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, 
const char *ring_name,
if (mz)
return mz;
 
-   if (rte_xen_dom0_supported())
-   return rte_memzone_reserve_bounded(z_name, size, socket_id,
-  0, align, RTE_PGSIZE_2M);
-   else
-   return rte_memzone_reserve_aligned(z_name, size, socket_id,
-  0, align);
+   return rte_memzone_reserve_aligned(z_name, size, socket_id, 0, align);
 }
 
 int
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 6fc3c9c..6d726ae 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -527,11 +527,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)
if (mp->nb_mem_chunks != 0)
return -EEXIST;
 
-   if (rte_xen_dom0_supported()) {
-   pg_sz = RTE_PGSIZE_2M;
-   pg_shift = rte_bsf32(pg_sz);
-   align = pg_sz;
-   } else if (rte_eal_has_hugepages()) {
+   if (rte_eal_has_hugepages()) {
pg_shift = 0; /* not needed, zone is physically contiguous */
pg_sz = 0;
align = RTE_CACHE_LINE_SIZE;
@@ -568,7 +564,7 @@ rte_mempool_populate_default(struct rte_mempool *mp)
else
paddr = mz->phys_addr;
 
-   if (rte_eal_has_hugepages() && !rte_xen_dom0_supported())
+   if (rte_eal_has_hugepages())
ret = rte_mempool_populate_phys(mp, mz->addr,
paddr, mz->len,
rte_mempool_memchunk_mz_free,
-- 
2.7.4


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


[Xen-devel] [PATCH 6/6] eal: remove API rte_mem_phy2mch

2017-08-30 Thread Jianfeng Tan
Previously, to get MFN address in dom0, this API is a wrapper to
obtain the "physical address".

As we removed xen dom0 support, this API is not necessary.

Signed-off-by: Jianfeng Tan 
---
 doc/guides/rel_notes/release_17_11.rst | 2 ++
 drivers/net/e1000/em_rxtx.c| 4 ++--
 drivers/net/e1000/igb_rxtx.c   | 4 ++--
 drivers/net/fm10k/fm10k_ethdev.c   | 4 ++--
 drivers/net/i40e/i40e_ethdev.c | 2 +-
 drivers/net/i40e/i40e_fdir.c   | 2 +-
 drivers/net/i40e/i40e_rxtx.c   | 8 
 drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++--
 drivers/net/sfc/sfc.c  | 2 +-
 lib/librte_eal/common/include/rte_memory.h | 5 -
 lib/librte_mempool/rte_mempool.c   | 3 ---
 11 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/doc/guides/rel_notes/release_17_11.rst 
b/doc/guides/rel_notes/release_17_11.rst
index d211084..06c334b 100644
--- a/doc/guides/rel_notes/release_17_11.rst
+++ b/doc/guides/rel_notes/release_17_11.rst
@@ -110,6 +110,8 @@ API Changes
Also, make sure to start the actual text at the margin.
=
 
+   * ``rte_mem_phy2mch`` was used in xen dom0 to obtain the physical address;
+ remove this API as xen dom0 support was removed.
 
 ABI Changes
 ---
diff --git a/drivers/net/e1000/em_rxtx.c b/drivers/net/e1000/em_rxtx.c
index 31819c5..a0f63a7 100644
--- a/drivers/net/e1000/em_rxtx.c
+++ b/drivers/net/e1000/em_rxtx.c
@@ -1289,7 +1289,7 @@ eth_em_tx_queue_setup(struct rte_eth_dev *dev,
txq->port_id = dev->data->port_id;
 
txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(queue_idx));
-   txq->tx_ring_phys_addr = rte_mem_phy2mch(tz->memseg_id, tz->phys_addr);
+   txq->tx_ring_phys_addr = tz->phys_addr;
txq->tx_ring = (struct e1000_data_desc *) tz->addr;
 
PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
@@ -1416,7 +1416,7 @@ eth_em_rx_queue_setup(struct rte_eth_dev *dev,
 
rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(queue_idx));
rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(queue_idx));
-   rxq->rx_ring_phys_addr = rte_mem_phy2mch(rz->memseg_id, rz->phys_addr);
+   rxq->rx_ring_phys_addr = rz->phys_addr;
rxq->rx_ring = (struct e1000_rx_desc *) rz->addr;
 
PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
diff --git a/drivers/net/e1000/igb_rxtx.c b/drivers/net/e1000/igb_rxtx.c
index 1c80a2a..0fccb5d 100644
--- a/drivers/net/e1000/igb_rxtx.c
+++ b/drivers/net/e1000/igb_rxtx.c
@@ -1530,7 +1530,7 @@ eth_igb_tx_queue_setup(struct rte_eth_dev *dev,
txq->port_id = dev->data->port_id;
 
txq->tdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_TDT(txq->reg_idx));
-   txq->tx_ring_phys_addr = rte_mem_phy2mch(tz->memseg_id, tz->phys_addr);
+   txq->tx_ring_phys_addr = tz->phys_addr;
 
txq->tx_ring = (union e1000_adv_tx_desc *) tz->addr;
/* Allocate software ring */
@@ -1667,7 +1667,7 @@ eth_igb_rx_queue_setup(struct rte_eth_dev *dev,
}
rxq->rdt_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDT(rxq->reg_idx));
rxq->rdh_reg_addr = E1000_PCI_REG_ADDR(hw, E1000_RDH(rxq->reg_idx));
-   rxq->rx_ring_phys_addr = rte_mem_phy2mch(rz->memseg_id, rz->phys_addr);
+   rxq->rx_ring_phys_addr = rz->phys_addr;
rxq->rx_ring = (union e1000_adv_rx_desc *) rz->addr;
 
/* Allocate software ring. */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index e60d3a3..15ea2a5 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1887,7 +1887,7 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
return -ENOMEM;
}
q->hw_ring = mz->addr;
-   q->hw_ring_phys_addr = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
+   q->hw_ring_phys_addr = mz->phys_addr;
 
/* Check if number of descs satisfied Vector requirement */
if (!rte_is_power_of_2(nb_desc)) {
@@ -2047,7 +2047,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
return -ENOMEM;
}
q->hw_ring = mz->addr;
-   q->hw_ring_phys_addr = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
+   q->hw_ring_phys_addr = mz->phys_addr;
 
/*
 * allocate memory for the RS bit tracker. Enough slots to hold the
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 5f26e24..dc5458d 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -3741,7 +3741,7 @@ i40e_allocate_dma_mem_d(__attribute__((unused)) struct 
i40e_hw *hw,
 
mem->size = size;
mem->va = mz->addr;
-   mem->pa = rte_mem_phy2mch(mz->memseg_id, mz->phys_addr);
+   mem->pa = mz->phys_addr;
mem->zone = (const void *)mz;
PMD_DRV_LOG(DEBUG,
  

[Xen-devel] [PATCH 3/6] xen: remove xen dependency in app, examples, test

2017-08-30 Thread Jianfeng Tan
Signed-off-by: Jianfeng Tan 
---
 app/test-pmd/testpmd.c  |  2 +-
 examples/ip_pipeline/app.h  |  4 --
 examples/ip_pipeline/config_parse.c | 19 -
 examples/ip_pipeline/init.c |  5 ---
 examples/kni/main.c |  3 --
 test/test/process.h | 10 -
 test/test/test.c|  4 --
 test/test/test_eal_flags.c  | 81 -
 8 files changed, 1 insertion(+), 127 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index f8d02ae..d9c785c 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -494,7 +494,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf,
"create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n",
pool_name, nb_mbuf, mbuf_seg_size, socket_id);
 
-   /* if the former XEN allocation failed fall back to normal allocation */
+   /* if the former allocation failed fall back to normal allocation */
if (rte_mp == NULL) {
if (mp_anon != 0) {
rte_mp = rte_mempool_create_empty(pool_name, nb_mbuf,
diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
index e41290e..94e7a6d 100644
--- a/examples/ip_pipeline/app.h
+++ b/examples/ip_pipeline/app.h
@@ -428,10 +428,6 @@ struct app_eal_params {
/* Interrupt mode for VFIO (legacy|msi|msix) */
char *vfio_intr;
 
-   /* Support running on Xen dom0 without hugetlbfs */
-   uint32_t xen_dom0_present;
-   int xen_dom0;
-
uint32_t parsed;
 };
 
diff --git a/examples/ip_pipeline/config_parse.c 
b/examples/ip_pipeline/config_parse.c
index 0b76134..3211c6a 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -809,21 +809,6 @@ parse_eal(struct app_params *app,
continue;
}
 
-   /* xen_dom0 */
-   if (strcmp(entry->name, "xen_dom0") == 0) {
-   int val;
-
-   PARSE_ERROR_DUPLICATE((p->xen_dom0_present == 0),
-   section_name,
-   entry->name);
-   p->xen_dom0_present = 1;
-
-   val = parser_read_arg_bool(entry->value);
-   PARSE_ERROR((val >= 0), section_name, entry->name);
-   p->xen_dom0 = val;
-   continue;
-   }
-
/* unrecognized */
PARSE_ERROR_INVALID(0, section_name, entry->name);
}
@@ -2643,10 +2628,6 @@ save_eal_params(struct app_params *app, FILE *f)
if (p->vfio_intr)
fprintf(f, "%s = %s\n", "vfio_intr", p->vfio_intr);
 
-   if (p->xen_dom0_present)
-   fprintf(f, "%s = %s\n", "xen_dom0",
-   (p->xen_dom0) ? "yes" : "no");
-
fputc('\n', f);
 }
 
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 7cde49a..034c238 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -296,11 +296,6 @@ app_init_eal(struct app_params *app)
app->eal_argv[n_args++] = strdup(buffer);
}
 
-   if ((p->xen_dom0_present) && (p->xen_dom0)) {
-   snprintf(buffer, sizeof(buffer), "--xen-dom0");
-   app->eal_argv[n_args++] = strdup(buffer);
-   }
-
snprintf(buffer, sizeof(buffer), "--");
app->eal_argv[n_args++] = strdup(buffer);
 
diff --git a/examples/kni/main.c b/examples/kni/main.c
index e3bc2fb..9f9d227 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -919,9 +919,6 @@ main(int argc, char** argv)
continue;
kni_free_kni(port);
}
-#ifdef RTE_LIBRTE_XEN_DOM0
-   rte_kni_close();
-#endif
for (i = 0; i < RTE_MAX_ETHPORTS; i++)
if (kni_port_params_array[i]) {
rte_free(kni_port_params_array[i]);
diff --git a/test/test/process.h b/test/test/process.h
index 4f8d121..51ced12 100644
--- a/test/test/process.h
+++ b/test/test/process.h
@@ -52,11 +52,7 @@ static inline int
 process_dup(const char *const argv[], int numargs, const char *env_value)
 {
int num;
-#ifdef RTE_LIBRTE_XEN_DOM0
-   char *argv_cpy[numargs + 2];
-#else
char *argv_cpy[numargs + 1];
-#endif
int i, fd, status;
char path[32];
 
@@ -67,14 +63,8 @@ process_dup(const char *const argv[], int numargs, const 
char *env_value)
/* make a copy of the arguments to be passed to exec */
for (i = 0; i < numargs; i++)
argv_cpy[i] = strdup(argv[i]);
-#ifdef RTE_LIBRTE_XEN_DOM0
-   argv_cpy[i] = strdup("--xen-dom0");
-   argv_cpy[i + 1] = NULL;
-   num = numargs + 1;
-#else
argv_cpy[i] = NULL;
num = numargs;
-#endif
 

Re: [Xen-devel] [PATCH 3/3] x86/mm: merge ptwr and mmio_ro page fault handlers

2017-08-30 Thread Andrew Cooper
On 30/08/17 18:11, Wei Liu wrote:
> Provide a unified entry to avoid going through pte look-up, decode and
> emulation cycle more than necessary. The path taken is determined by
> the faulting address.
>
> Note that the order of checks is changed in the new function, but the
> order of the checks is performed shouldn't matter.
>
> The sole caller is changed to use the new function.
>
> No functional change.
>
> Signed-off-by: Wei Liu 
> ---
> Cc: Jan Beulich 
> Cc: Andrew Cooper 
>
> xtf is happy with this change. Let me know if more tests can be done.

Booting dom0 is probably the best easy test going.

> diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
> index ec7ce3c8c8..85adafdfa2 100644
> --- a/xen/include/asm-x86/mm.h
> +++ b/xen/include/asm-x86/mm.h
> @@ -511,10 +511,8 @@ extern int mmcfg_intercept_write(enum x86_segment seg,
>  int pv_emul_cpuid(uint32_t leaf, uint32_t subleaf,
>struct cpuid_leaf *res, struct x86_emulate_ctxt *ctxt);
>  
> -int  ptwr_do_page_fault(struct vcpu *, unsigned long,
> -struct cpu_user_regs *);
> -int  mmio_ro_do_page_fault(struct vcpu *, unsigned long,
> -   struct cpu_user_regs *);
> +int ptwr_or_mmio_ro_do_page_fault(struct vcpu *, unsigned long,
> +  struct cpu_user_regs *);

pv_ro_page_fault() ?

>  
>  int audit_adjust_pgtables(struct domain *d, int dir, int noisy);
>  

I was thinking something more like this extra delta (only compile
tested) which drops rather more code.

~Andrew

>From 5c9d0935e2079935aaf980d972a00d8d5e8197e3 Mon Sep 17 00:00:00 2001
From: Andrew Cooper 
Date: Wed, 30 Aug 2017 18:50:47 +0100
Subject: [PATCH] extra

---
 xen/arch/x86/mm.c | 129 --
 1 file changed, 47 insertions(+), 82 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 3879d4a..753a775 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -6277,7 +6277,6 @@ static int mmio_ro_do_page_fault(struct x86_emulate_ctxt *ctxt,
 {
 struct mmio_ro_emulate_ctxt mmio_ro_ctxt = { .cr2 = addr };
 mfn_t mfn = l1e_get_mfn(pte);
-int rc;
 
 if ( mfn_valid(mfn) )
 {
@@ -6287,46 +6286,14 @@ static int mmio_ro_do_page_fault(struct x86_emulate_ctxt *ctxt,
 if ( owner )
 put_page(page);
 if ( owner != dom_io )
-goto bail;
+return X86EMUL_UNHANDLEABLE;
 }
 
 ctxt->data = _ro_ctxt;
 if ( pci_ro_mmcfg_decode(mfn_x(mfn), _ro_ctxt.seg, _ro_ctxt.bdf) )
-rc = x86_emulate(ctxt, _intercept_ops);
+return x86_emulate(ctxt, _intercept_ops);
 else
-rc = x86_emulate(ctxt, _ro_emulate_ops);
-
-switch ( rc )
-{
-case X86EMUL_EXCEPTION:
-/*
- * This emulation only covers writes to MMCFG space or read-only MFNs.
- * We tolerate #PF (from hitting an adjacent page or a successful
- * concurrent pagetable update).  Anything else is an emulation bug,
- * or a guest playing with the instruction stream under Xen's feet.
- */
-if ( ctxt->event.type == X86_EVENTTYPE_HW_EXCEPTION &&
- ctxt->event.vector == TRAP_page_fault )
-pv_inject_event(>event);
-else
-gdprintk(XENLOG_WARNING,
- "Unexpected event (type %u, vector %#x) from emulation\n",
- ctxt->event.type, ctxt->event.vector);
-
-/* Fallthrough */
-case X86EMUL_OKAY:
-
-if ( ctxt->retire.singlestep )
-pv_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
-
-/* Fallthrough */
-case X86EMUL_RETRY:
-perfc_incr(mmio_ro_emulations);
-return EXCRET_fault_fixed;
-}
-
- bail:
-return 0;
+return x86_emulate(ctxt, _ro_emulate_ops);
 }
 
 /* Write page fault handler: check if guest is trying to modify a PTE. */
@@ -6336,66 +6303,31 @@ static int ptwr_do_page_fault(struct x86_emulate_ctxt *ctxt, struct domain *d,
 struct ptwr_emulate_ctxt ptwr_ctxt = {
 .cr2 = addr,
 .pte = pte,
-.ctxt = ctxt
+.ctxt = ctxt,
 };
 struct page_info *page;
-int rc;
+int rc = X86EMUL_UNHANDLEABLE;
 
 if ( !get_page_from_mfn(l1e_get_mfn(pte), d) )
-goto bail;
+goto out;
 
 page = l1e_get_page(pte);
 if ( !page_lock(page) )
-{
-put_page(page);
-goto bail;
-}
+goto put;
 
 if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table )
-{
-page_unlock(page);
-put_page(page);
-goto bail;
-}
+goto unlock;
 
 ctxt->data = _ctxt;
 rc = x86_emulate(ctxt, _emulate_ops);
 
+ unlock:
 page_unlock(page);
+ put:
 put_page(page);
+ out:
 
-switch ( rc )
-{
-case X86EMUL_EXCEPTION:
-/*
- * This emulation 

[Xen-devel] [xen-unstable-smoke test] 112960: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112960 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112960/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  2b936ea7b716dc1a13c98550f81752ab053e95c0
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Testing same since   112957  2017-08-30 12:02:17 Z0 days3 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 334 lines long.)

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


Re: [Xen-devel] [PATCH] libxc: increase maximum migration stream record length

2017-08-30 Thread Juergen Gross
On 10/08/17 14:26, Andrew Cooper wrote:
> On 10/08/17 12:24, Juergen Gross wrote:
>> Today the maximum record lenth in a migration stream is 8MB. This
>> limits the size of a PV domain to a little bit less than 1TB in the
>> migration case, as the P2M frame list will exceed 8MB in this case.
>>
>> Raising the record size limit by a factor of 16 allows for domain
>> sizes of nearly 16TB to be migrated. This ought to be enough.
>>
>> Signed-off-by: Juergen Gross 
> 
> Hmm - Changing this isn't something I've considered when it comes to ABI
> compatibility.  I also see that there is no mention of the maximum
> record length in the stream spec, which is an oversight.
> 
> Worse still, there is no record length check in the python utilities,
> but both sides of the C code perform the check.
> 
> Let me ponder the implications.

Any result yet?


Juergen

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


Re: [Xen-devel] [PATCH 2/3] x86/mm: don't wrap x86_emulate_ctxt in ptwr_emulate_ctxt

2017-08-30 Thread Andrew Cooper
On 30/08/17 18:11, Wei Liu wrote:
> diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
> index ed80df02fa..5b840cc603 100644
> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -4956,9 +4956,9 @@ long arch_memory_op(unsigned long cmd, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>   */
>  
>  struct ptwr_emulate_ctxt {
> -struct x86_emulate_ctxt ctxt;
>  unsigned long cr2;
>  l1_pgentry_t  pte;
> +struct x86_emulate_ctxt *ctxt;

You can do away with this pointer entirely if you modify
ptwr_emulated_update() to take the full x86_emulate_ctxt.  Locally, you
can just declare

struct ptwr_emulate_ctxt *ptwr_ctxt = ctxt->data;

Otherwise, LGTM.

~Andrew

>  };
>  
>  static int ptwr_emulated_read(
>


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


[Xen-devel] [PATCH 0/3] x86/mm: merge ptwr and mmio_ro page fault handlers

2017-08-30 Thread Wei Liu
Wei Liu (3):
  x86/mm: introduce trace point for mmio_ro emulation
  x86/mm: don't wrap x86_emulate_ctxt in ptwr_emulate_ctxt
  x86/mm: merge ptwr and mmio_ro page fault handlers

 xen/arch/x86/mm.c| 325 +++
 xen/arch/x86/traps.c |  20 +--
 xen/include/asm-x86/mm.h |   6 +-
 xen/include/asm-x86/perfc_defn.h |   1 +
 4 files changed, 171 insertions(+), 181 deletions(-)

-- 
2.11.0


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


[Xen-devel] [PATCH 3/3] x86/mm: merge ptwr and mmio_ro page fault handlers

2017-08-30 Thread Wei Liu
Provide a unified entry to avoid going through pte look-up, decode and
emulation cycle more than necessary. The path taken is determined by
the faulting address.

Note that the order of checks is changed in the new function, but the
order of the checks is performed shouldn't matter.

The sole caller is changed to use the new function.

No functional change.

Signed-off-by: Wei Liu 
---
Cc: Jan Beulich 
Cc: Andrew Cooper 

xtf is happy with this change. Let me know if more tests can be done.
---
 xen/arch/x86/mm.c| 316 +++
 xen/arch/x86/traps.c |  20 +--
 xen/include/asm-x86/mm.h |   6 +-
 3 files changed, 166 insertions(+), 176 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 5b840cc603..3879d4a54d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5168,92 +5168,6 @@ static const struct x86_emulate_ops ptwr_emulate_ops = {
 .cpuid  = pv_emul_cpuid,
 };
 
-/* Write page fault handler: check if guest is trying to modify a PTE. */
-int ptwr_do_page_fault(struct vcpu *v, unsigned long addr,
-   struct cpu_user_regs *regs)
-{
-struct domain *d = v->domain;
-struct page_info *page;
-l1_pgentry_t  pte;
-struct ptwr_emulate_ctxt ptwr_ctxt;
-struct x86_emulate_ctxt ctxt = {
-   .regs = regs,
-   .vendor = d->arch.cpuid->x86_vendor,
-   .addr_size = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
-   .sp_size   = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
-   .lma   = !is_pv_32bit_domain(d),
-   .data  = _ctxt,
-};
-int rc;
-
-/* Attempt to read the PTE that maps the VA being accessed. */
-guest_get_eff_l1e(addr, );
-
-/* We are looking only for read-only mappings of p.t. pages. */
-if ( ((l1e_get_flags(pte) & (_PAGE_PRESENT|_PAGE_RW)) != _PAGE_PRESENT) ||
- rangeset_contains_singleton(mmio_ro_ranges, l1e_get_pfn(pte)) ||
- !get_page_from_mfn(l1e_get_mfn(pte), d) )
-goto bail;
-
-page = l1e_get_page(pte);
-if ( !page_lock(page) )
-{
-put_page(page);
-goto bail;
-}
-
-if ( (page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table )
-{
-page_unlock(page);
-put_page(page);
-goto bail;
-}
-
-ptwr_ctxt = (struct ptwr_emulate_ctxt) {
-.cr2 = addr,
-.pte = pte,
-.ctxt = 
-};
-
-rc = x86_emulate(, _emulate_ops);
-
-page_unlock(page);
-put_page(page);
-
-switch ( rc )
-{
-case X86EMUL_EXCEPTION:
-/*
- * This emulation only covers writes to pagetables which are marked
- * read-only by Xen.  We tolerate #PF (in case a concurrent pagetable
- * update has succeeded on a different vcpu).  Anything else is an
- * emulation bug, or a guest playing with the instruction stream under
- * Xen's feet.
- */
-if ( ctxt.event.type == X86_EVENTTYPE_HW_EXCEPTION &&
- ctxt.event.vector == TRAP_page_fault )
-pv_inject_event();
-else
-gdprintk(XENLOG_WARNING,
- "Unexpected event (type %u, vector %#x) from emulation\n",
- ctxt.event.type, ctxt.event.vector);
-
-/* Fallthrough */
-case X86EMUL_OKAY:
-
-if ( ctxt.retire.singlestep )
-pv_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
-
-/* Fallthrough */
-case X86EMUL_RETRY:
-perfc_incr(ptwr_emulations);
-return EXCRET_fault_fixed;
-}
-
- bail:
-return 0;
-}
-
 /*
  * fault handling for read-only MMIO pages
  */
@@ -5326,83 +5240,6 @@ static const struct x86_emulate_ops mmcfg_intercept_ops 
= {
 .cpuid  = pv_emul_cpuid,
 };
 
-/* Check if guest is trying to modify a r/o MMIO page. */
-int mmio_ro_do_page_fault(struct vcpu *v, unsigned long addr,
-  struct cpu_user_regs *regs)
-{
-l1_pgentry_t pte;
-unsigned long mfn;
-unsigned int addr_size = is_pv_32bit_vcpu(v) ? 32 : BITS_PER_LONG;
-struct mmio_ro_emulate_ctxt mmio_ro_ctxt = { .cr2 = addr };
-struct x86_emulate_ctxt ctxt = {
-.regs = regs,
-.vendor = v->domain->arch.cpuid->x86_vendor,
-.addr_size = addr_size,
-.sp_size = addr_size,
-.lma = !is_pv_32bit_vcpu(v),
-.data = _ro_ctxt,
-};
-int rc;
-
-/* Attempt to read the PTE that maps the VA being accessed. */
-guest_get_eff_l1e(addr, );
-
-/* We are looking only for read-only mappings of MMIO pages. */
-if ( ((l1e_get_flags(pte) & (_PAGE_PRESENT|_PAGE_RW)) != _PAGE_PRESENT) )
-return 0;
-
-mfn = l1e_get_pfn(pte);
-if ( mfn_valid(_mfn(mfn)) )
-{
-struct page_info *page = mfn_to_page(_mfn(mfn));
-struct domain *owner = page_get_owner_and_reference(page);
-
-if ( owner )
-

[Xen-devel] [PATCH 1/3] x86/mm: introduce trace point for mmio_ro emulation

2017-08-30 Thread Wei Liu
Using ptrw_emulation trace point is wrong.

Signed-off-by: Wei Liu 
---
 xen/arch/x86/mm.c| 2 +-
 xen/include/asm-x86/perfc_defn.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 1f23470cef..ed80df02fa 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5397,7 +5397,7 @@ int mmio_ro_do_page_fault(struct vcpu *v, unsigned long 
addr,
 
 /* Fallthrough */
 case X86EMUL_RETRY:
-perfc_incr(ptwr_emulations);
+perfc_incr(mmio_ro_emulations);
 return EXCRET_fault_fixed;
 }
 
diff --git a/xen/include/asm-x86/perfc_defn.h b/xen/include/asm-x86/perfc_defn.h
index aac9331843..6db8746906 100644
--- a/xen/include/asm-x86/perfc_defn.h
+++ b/xen/include/asm-x86/perfc_defn.h
@@ -30,6 +30,7 @@ PERFCOUNTER(copy_user_faults,   "copy_user faults")
 
 PERFCOUNTER(map_domain_page_count,  "map_domain_page count")
 PERFCOUNTER(ptwr_emulations,"writable pt emulations")
+PERFCOUNTER(mmio_ro_emulations, "mmio ro emulations")
 
 PERFCOUNTER(exception_fixed,"pre-exception fixed")
 
-- 
2.11.0


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


[Xen-devel] [PATCH 2/3] x86/mm: don't wrap x86_emulate_ctxt in ptwr_emulate_ctxt

2017-08-30 Thread Wei Liu
Rewrite the code so that it has the same structure as
mmio_ro_emualte_ctxt. The new code doesn't contain x86_emulate_ctxt
anymore but a pointer to the x86_emulate_ctxt; x86_emulate_ctxt now
also points to ptwr_emulate_ctxt via its data pointer.

This patch will help unify mmio_ro and ptwr code paths later.

Signed-off-by: Wei Liu 
---
 xen/arch/x86/mm.c | 47 +++
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ed80df02fa..5b840cc603 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4956,9 +4956,9 @@ long arch_memory_op(unsigned long cmd, 
XEN_GUEST_HANDLE_PARAM(void) arg)
  */
 
 struct ptwr_emulate_ctxt {
-struct x86_emulate_ctxt ctxt;
 unsigned long cr2;
 l1_pgentry_t  pte;
+struct x86_emulate_ctxt *ctxt;
 };
 
 static int ptwr_emulated_read(
@@ -5018,7 +5018,7 @@ static int ptwr_emulated_update(
 {
 x86_emul_pagefault(0, /* Read fault. */
addr + sizeof(paddr_t) - rc,
-   _ctxt->ctxt);
+   ptwr_ctxt->ctxt);
 return X86EMUL_EXCEPTION;
 }
 /* Mask out bits provided by caller. */
@@ -5133,9 +5133,7 @@ static int ptwr_emulated_write(
 
 memcpy(, p_data, bytes);
 
-return ptwr_emulated_update(
-offset, 0, val, bytes, 0,
-container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
+return ptwr_emulated_update(offset, 0, val, bytes, 0, ctxt->data);
 }
 
 static int ptwr_emulated_cmpxchg(
@@ -5158,9 +5156,7 @@ static int ptwr_emulated_cmpxchg(
 memcpy(, p_old, bytes);
 memcpy(, p_new, bytes);
 
-return ptwr_emulated_update(
-offset, old, new, bytes, 1,
-container_of(ctxt, struct ptwr_emulate_ctxt, ctxt));
+return ptwr_emulated_update(offset, old, new, bytes, 1, ctxt->data);
 }
 
 static const struct x86_emulate_ops ptwr_emulate_ops = {
@@ -5179,14 +5175,14 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long 
addr,
 struct domain *d = v->domain;
 struct page_info *page;
 l1_pgentry_t  pte;
-struct ptwr_emulate_ctxt ptwr_ctxt = {
-.ctxt = {
-.regs = regs,
-.vendor = d->arch.cpuid->x86_vendor,
-.addr_size = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
-.sp_size   = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
-.lma   = !is_pv_32bit_domain(d),
-},
+struct ptwr_emulate_ctxt ptwr_ctxt;
+struct x86_emulate_ctxt ctxt = {
+   .regs = regs,
+   .vendor = d->arch.cpuid->x86_vendor,
+   .addr_size = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
+   .sp_size   = is_pv_32bit_domain(d) ? 32 : BITS_PER_LONG,
+   .lma   = !is_pv_32bit_domain(d),
+   .data  = _ctxt,
 };
 int rc;
 
@@ -5213,10 +5209,13 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long 
addr,
 goto bail;
 }
 
-ptwr_ctxt.cr2 = addr;
-ptwr_ctxt.pte = pte;
+ptwr_ctxt = (struct ptwr_emulate_ctxt) {
+.cr2 = addr,
+.pte = pte,
+.ctxt = 
+};
 
-rc = x86_emulate(_ctxt.ctxt, _emulate_ops);
+rc = x86_emulate(, _emulate_ops);
 
 page_unlock(page);
 put_page(page);
@@ -5231,18 +5230,18 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long 
addr,
  * emulation bug, or a guest playing with the instruction stream under
  * Xen's feet.
  */
-if ( ptwr_ctxt.ctxt.event.type == X86_EVENTTYPE_HW_EXCEPTION &&
- ptwr_ctxt.ctxt.event.vector == TRAP_page_fault )
-pv_inject_event(_ctxt.ctxt.event);
+if ( ctxt.event.type == X86_EVENTTYPE_HW_EXCEPTION &&
+ ctxt.event.vector == TRAP_page_fault )
+pv_inject_event();
 else
 gdprintk(XENLOG_WARNING,
  "Unexpected event (type %u, vector %#x) from emulation\n",
- ptwr_ctxt.ctxt.event.type, ptwr_ctxt.ctxt.event.vector);
+ ctxt.event.type, ctxt.event.vector);
 
 /* Fallthrough */
 case X86EMUL_OKAY:
 
-if ( ptwr_ctxt.ctxt.retire.singlestep )
+if ( ctxt.retire.singlestep )
 pv_inject_hw_exception(TRAP_debug, X86_EVENT_NO_EC);
 
 /* Fallthrough */
-- 
2.11.0


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


Re: [Xen-devel] [PATCH v8 1/2] x86emul: New return code for unimplemented instruction

2017-08-30 Thread Petre Ovidiu PIRCALABU
Hi Jan,


The main use-case for the new return code is to have a clear distinction 
between an instruction not implemented by the emulator (e.g. ?fldenv or 
fnstenv) and the failure to emulate .


- hvm_process_io_incercept returns X86EMUL_UNHANDLEABLE if one of the 
hvm_io_ops (read/write) failed or one of the hvm_copy_to(_from)_guest_phys 
returned an error code which is not handled in their correspondent switch 
statement. In either cases this is not caused by an unimplemented instruction.

- hvm_do_io / hvm_do_io_buffer call hvm_process_io_incercept which cannot 
return unimplemented.

- Thank-you very much for pointing out the invoke_stub issue. I have added a 
new label "unimplemented_insn" and updated the patch.


I will re-send a new patchset with the changes and a more detailed description 
of the places where the new return value was not handled.


Many thanks,

Petre



From: Jan Beulich 
Sent: Tuesday, August 22, 2017 11:09 AM
To: Petre Ovidiu PIRCALABU
Cc: rcojoc...@bitdefender.com; andrew.coop...@citrix.com; 
paul.durr...@citrix.com; wei.l...@citrix.com; george.dun...@eu.citrix.com; 
ian.jack...@eu.citrix.com; jun.nakaj...@intel.com; kevin.t...@intel.com; 
sstabell...@kernel.org; xen-devel@lists.xen.org; konrad.w...@oracle.com; 
ta...@tklengyel.com; t...@xen.org
Subject: Re: [PATCH v8 1/2] x86emul: New return code for unimplemented 
instruction

>>> On 08.08.17 at 20:06,  wrote:
> --- a/xen/arch/x86/hvm/emulate.c
> +++ b/xen/arch/x86/hvm/emulate.c

What about the use in a switch() statement in hvmemul_do_io()
in this file? And the use in hvmemul_do_io_buffer()?

> @@ -2044,6 +2044,8 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned 
> long gla)
>  switch ( rc )
>  {
>  case X86EMUL_UNHANDLEABLE:
> +/* fall-through */
> +case X86EMUL_UNIMPLEMENTED:

The fall-through comment is pointless in such a case.

hvm/intercept.c has a use in hvm_process_io_intercept() which
looks like it needs dealing with too. And there are more. Any
places you perhaps leave alone intentionally should be reasoned
about in the description.

> @@ -7717,7 +7717,7 @@ x86_emulate(
>
>  default:
>  cannot_emulate:
> -rc = X86EMUL_UNHANDLEABLE;
> +rc = X86EMUL_UNIMPLEMENTED;

There's at least one goto to the label here which can't stay as is
(in invoke_stub()). Did you really audit them all?

Jan



This email was scanned by Bitdefender
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [linux-linus test] 112948: tolerable trouble: blocked/broken/fail/pass - PUSHED

2017-08-30 Thread osstest service owner
flight 112948 linux-linus real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112948/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112920
 build-arm64-pvops 3 capture-logsbroken like 112920
 build-arm64-xsm   2 hosts-allocate  broken like 112920
 build-arm64-xsm   3 capture-logsbroken like 112920
 build-arm64   2 hosts-allocate  broken like 112920
 build-arm64   3 capture-logsbroken like 112920
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112920
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stopfail like 112920
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail  like 112920
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stopfail like 112920
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112920
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112920
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112920
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass

version targeted for testing:
 linux36fde05f3fb51edea879636db590d70e11f16c82
baseline version:
 linux9c3a815f471a84811cf8021cf64aae3b8081dfde

Last test of basis   112920  2017-08-29 06:03:36 Z1 days
Testing same since   112948  2017-08-29 23:51:46 Z0 days1 attempts


People who touched revisions under test:
  Christoph Hellwig 
  Christophe JAILLET 

[Xen-devel] [xen-4.9-testing baseline-only test] 72039: regressions - trouble: blocked/broken/fail/pass

2017-08-30 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72039 xen-4.9-testing real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72039/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-i386-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail REGR. vs. 
72028

Regressions which are regarded as allowable (not blocking):
 test-amd64-amd64-xl-rtds  7 xen-boot  fail REGR. vs. 72028

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64   2 hosts-allocate   broken never pass
 build-arm64-pvops 2 hosts-allocate   broken never pass
 build-arm64-xsm   2 hosts-allocate   broken never pass
 build-arm64   3 capture-logs broken never pass
 build-arm64-xsm   3 capture-logs broken never pass
 build-arm64-pvops 3 capture-logs broken never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail like 72028
 test-amd64-amd64-qemuu-nested-intel 17 debian-hvm-install/l1/l2 fail like 72028
 test-amd64-amd64-xl-qemut-win7-amd64 18 guest-start/win.repeat fail like 72028
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-localmigrate/x10  fail like 72028
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail like 72028
 test-amd64-amd64-xl-qemuu-win10-i386 17 guest-stop fail like 72028
 test-amd64-i386-xl-qemuu-ws16-amd64 10 windows-install fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-midway   13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-midway   14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass

version targeted for testing:
 xen  d23bcc5ae7342a6c369200cda46cf95bcf854dd0
baseline version:
 xen  5ff1de3e4f56b2dd7c5c7dae8b008f6ee6dc2081

Last test of basis72028  2017-08-26 10:47:52 Z4 days
Testing same since72039  2017-08-30 09:44:54 Z0 days1 attempts


People 

Re: [Xen-devel] [PATCH v4 03/11] public: xen.h: add definitions for UUID handling

2017-08-30 Thread Volodymyr Babchuk

Hi Jan,

On 23.08.17 14:29, Jan Beulich wrote:

On 23.08.17 at 13:08,  wrote:

On 23.08.17 11:10, Jan Beulich wrote:

On 22.08.17 at 16:37,  wrote:

I can't see why you want to map UUID to a certain structure.


This is so that the type cannot mistakenly be passed to a function
taking unsigned char *, or be assigned to a variable of that type.

Right, I see the point there.


Please see our TYPE_SAFE() macro which we use to specifically
enclose certain scalar types in a structure to that they won't be
compatible with other types deriving from the same scalar base type.

I see. So what about

struct xen_uuid_t
{
   uint8_t a[16];
};

then?


Yes, that's what I had asked for as the minimal solution. That
would be in line with (but better than) xen_domain_handle_t,
which I've just realized we also have.


One can convert it to union with different representations (array,
RFC4122 struct, etc) later if there will be need for this.


Well, why don't you make it a union but stick to just the array
for now if you dislike making it similar to the EFI one? That way
we can add further representations if needed/desired without
breaking existing consumers.
My first intention was to declare union with all possible 
representations, so it would be possible to access the same UUID as an 
array of bytes or, for example, as Microsoft GUID. Like this:


typedef union {
/* UUID represented as a 128-bit object */
uint8_t obj[16];

/* Representation according to RFC 4122 */
struct {
__be32  time_low;
__be16  time_mid;
__be16  time_hi_and_version;
__u8clock_seq_hi_and_reserved;
__u8clock_seq_low;
__u8node[6];
} rfc4122;

/* Microsoft/Intel style GUID representation */
struct {
__le32  Data1;
__le16  Data2;
__le16  Data3;
__u8Data4[8];
} guid;

/* SMCCC compatible format */
struct {
__le32 r0;
__le32 r1;
__le32 r2;
__le32 r3;
} smccc;
} xen_uuid_t;


But looks like we can't use something like __packed or 
__attribute__((__packed__)) in the public header. This means that we 
can't rely on right overlapping and users of this union should take care 
to read and write only to one chosen substructure. I think, this is 
error-prone, so it is better to stick to


typedef struct
{
   uint8_t a[16];
} xen_uuid_t;

BTW, I'm very interested how it can be guaranteed that structures 
defined in xen.h will have the same size and alignment on both sides of 
communication channel, taking into account, then we rely only on C89 
standard.


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


Re: [Xen-devel] [Xen-users] UEFI Secure Boot Xen 4.9

2017-08-30 Thread Tamas K Lengyel
On Tue, Aug 29, 2017 at 2:01 PM, Daniel Kiper  wrote:
> Hey Tamas,
>
> Sorry for late reply. I was on vacation.
>
> On Tue, Aug 22, 2017 at 09:01:06PM -0600, Tamas K Lengyel wrote:
>> On Tue, May 16, 2017 at 5:04 AM, Daniel Kiper  
>> wrote:
>
> [...]
>
>> > UEFI will verify shim secure boot signature then shim will verify GRUB2
>> > signature then GRUB2 will verify (with shim protocol) Xen signature and
>> > finally Xen will verify (with shim protocol) Linux kernel signature. Then
>> > your kernel can verify modules using whatever you want.
>> >
>> >> I would be happy to work to help achieve this.
>> >
>> > There is a chance that I will have something very raw at the beginning
>> > of June. If you wish to do tests drop me a line.
>>
>> Hi Daniel,
>> is there any news on this? I would be interested in giving this a shot too.
>
> Please look at
>
>   https://lists.xen.org/archives/html/xen-devel/2017-07/msg00982.html
>
> and at
>
>   https://lists.xen.org/archives/html/xen-devel/2017-07/msg00985.html
>
> Attachments contain the same patches as above but rebased on latest
> GRUB2 and Xen git repositories.
>
> Due to some travel I am going to restart work on this in the second
> half of September.
>
> If you have any questions please drop me a line.
>

Hi Daniel,
thanks for the update, I'll give it a shot today to set it up. In a
somewhat related note, are you aware of any work on getting secure
boot + UEFI working in a guest? There is a PoC patch on OpenXT
(https://github.com/OpenXT/xenclient-oe/pull/729) but was wondering if
there are any parallel efforts ongoing.

Thanks,
Tamas

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


Re: [Xen-devel] [PATCH 1/2] x86/mm: Use mfn_t for new_guest_cr3()

2017-08-30 Thread Jan Beulich
>>> On 30.08.17 at 17:57,  wrote:
> On 30/08/17 16:45, Jan Beulich wrote:
> On 30.08.17 at 14:19,  wrote:
>>> @@ -2772,23 +2772,23 @@ int vcpu_destroy_pagetables(struct vcpu *v)
>>>  return rc != -EINTR ? rc : -ERESTART;
>>>  }
>>>  
>>> -int new_guest_cr3(unsigned long mfn)
>>> +int new_guest_cr3(mfn_t mfn)
>>>  {
>>>  struct vcpu *curr = current;
>>>  struct domain *d = curr->domain;
>>>  int rc;
>>> -unsigned long old_base_mfn;
>>> +mfn_t old_base_mfn;
>>>  
>>>  if ( is_pv_32bit_domain(d) )
>>>  {
>>> -unsigned long gt_mfn = pagetable_get_pfn(curr->arch.guest_table);
>>> -l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
>>> +mfn_t mmfn = pagetable_get_mfn(curr->arch.guest_table);
>>> +l4_pgentry_t *pl4e = map_domain_page(mmfn);
>> What was wrong with "gt_mfn" for "guest table MFN"? I can't help
>> thinking mmfn is a typo, where you've hit the m key one too many
>> times. What is that first m supposed to stand for?
> 
> mmfn is the shadow code nomenclature for the monitor mfn.  I can move
> back to gt_mfn if you think thats clearer.

I'm not going to insist, but I'd appreciate keeping the original name.

Acked-by: Jan Beulich 

Jan


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


Re: [Xen-devel] [PATCH v5 1/4] VT-d PI: track the number of vcpus on pi blocking list

2017-08-30 Thread Jan Beulich
>>> On 16.08.17 at 07:14,  wrote:
> @@ -100,6 +101,24 @@ void vmx_pi_per_cpu_init(unsigned int cpu)
>  spin_lock_init(_cpu(vmx_pi_blocking, cpu).lock);
>  }
>  
> +static void vmx_pi_add_vcpu(struct pi_blocking_vcpu *pbv,
> +struct vmx_pi_blocking_vcpu *vpbv)
> +{
> +ASSERT(spin_is_locked(>lock));

You realize this is only a very weak check for a non-recursive lock?

> +add_sized(>counter, 1);
> +ASSERT(read_atomic(>counter));

Why add_sized() and read_atomic() when you hold the lock?

Jan


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


Re: [Xen-devel] [PATCH 1/2] x86/mm: Use mfn_t for new_guest_cr3()

2017-08-30 Thread Andrew Cooper
On 30/08/17 16:45, Jan Beulich wrote:
 On 30.08.17 at 14:19,  wrote:
>> @@ -2772,23 +2772,23 @@ int vcpu_destroy_pagetables(struct vcpu *v)
>>  return rc != -EINTR ? rc : -ERESTART;
>>  }
>>  
>> -int new_guest_cr3(unsigned long mfn)
>> +int new_guest_cr3(mfn_t mfn)
>>  {
>>  struct vcpu *curr = current;
>>  struct domain *d = curr->domain;
>>  int rc;
>> -unsigned long old_base_mfn;
>> +mfn_t old_base_mfn;
>>  
>>  if ( is_pv_32bit_domain(d) )
>>  {
>> -unsigned long gt_mfn = pagetable_get_pfn(curr->arch.guest_table);
>> -l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
>> +mfn_t mmfn = pagetable_get_mfn(curr->arch.guest_table);
>> +l4_pgentry_t *pl4e = map_domain_page(mmfn);
> What was wrong with "gt_mfn" for "guest table MFN"? I can't help
> thinking mmfn is a typo, where you've hit the m key one too many
> times. What is that first m supposed to stand for?

mmfn is the shadow code nomenclature for the monitor mfn.  I can move
back to gt_mfn if you think thats clearer.

~Andrew

>
> Other than this the patch is certainly fine.
>
> Jan
>


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


[Xen-devel] [xen-unstable-smoke test] 112959: regressions - trouble: broken/fail/pass

2017-08-30 Thread osstest service owner
flight 112959 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112959/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl  12 guest-start  fail REGR. vs. 112956

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112956
 build-arm64-pvops 3 capture-logsbroken like 112956
 build-arm64   2 hosts-allocate  broken like 112956
 build-arm64   3 capture-logsbroken like 112956
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass

version targeted for testing:
 xen  2b936ea7b716dc1a13c98550f81752ab053e95c0
baseline version:
 xen  dab6a84aadab11f31332030a1e9f0b9282d76156

Last test of basis   112956  2017-08-30 09:56:56 Z0 days
Testing same since   112957  2017-08-30 12:02:17 Z0 days2 attempts


People who touched revisions under test:
  Andrew Cooper 
  Dario Faggioli 
  George Dunlap 
  Jan Beulich 
  Tim Deegan 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  fail
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 hosts-allocate
broken-step build-arm64 capture-logs

Not pushing.

(No revision log; it would be 334 lines long.)

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


Re: [Xen-devel] [PATCH v6 3/3] tools/libxc: use superpages during restore of HVM guest

2017-08-30 Thread Olaf Hering
On Wed, Aug 30, Wei Liu wrote:

> > Can this actually happen with the available senders? If not, this is
> > again the missing memory map.
> Probably not now, but as said, you shouldn't rely on the structure of
> the stream unless it is stated in the spec.

Well, what can happen with todays implementation on the sender side is
the case of a ballooned guest with enough holes within a batch. These
will trigger 1G allocations before the releasing of memory happens. To
solve this, the releasing of memory has to happen more often, probably
after crossing each 2M boundary.


Olaf


signature.asc
Description: PGP signature
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v4 00/13] libxl: add PV display device driver interface

2017-08-30 Thread Ian Jackson
Oleksandr Grytsov writes ("Re: [PATCH v4 00/13] libxl: add PV display device 
driver interface"):
> On Thu, Aug 17, 2017 at 2:11 PM, Wei Liu  wrote:
> > I'm still waiting for the outcome from the other thread in which I
> > proposed to change p9 to p9s. Ian is out of office at the moment.
> 
> ping

Sorry, I thought the previous mails were clear.  I think changing the
name is fine now, despite it being an API break, because we think
there are very few out-of-tree callers.

Ian.

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


Re: [Xen-devel] [PATCH] x86/mm: Rearrange guest_get_eff_{, kern_}l1e() not be void

2017-08-30 Thread Jan Beulich
>>> On 30.08.17 at 15:29,  wrote:
> On Wed, Aug 30, 2017 at 02:22:05PM +0100, Andrew Cooper wrote:
>> Coverity complains that gl1e.l1 may be used while uninitialised in
>> map_ldt_shadow_page().  This isn't actually accurate as guest_get_eff_l1e()
>> will always write to its parameter.
>> 
>> However, having a void function which returns a 64bit value via pointer is
>> rather silly.  Rearrange the functions to return l1_pgentry_t.
>> 
>> No functional change, but hopefully should help Coverity not to come to the
>> wrong conclusion.
>> 
>> Bloat-o-meter also reports a modest improvement:
>>   add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-71 (-71)
>>   function old new   delta
>>   guest_get_eff_l1e 82  75  -7
>>   mmio_ro_do_page_fault530 514 -16
>>   map_ldt_shadow_page  501 485 -16
>>   ptwr_do_page_fault   615 583 -32
>> 
>> Signed-off-by: Andrew Cooper 
> 
> Reviewed-by: Wei Liu 

Acked-by: Jan Beulich 



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


  1   2   >