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

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

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

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf 9425b34925d0cf1b96aaf2c316d3299df9780252
baseline version:
 ovmf c46bced224b42d5a03bc8b207167829aa4e7bc5b

Last test of basis72181  2017-09-30 07:18:54 Z2 days
Testing same since72184  2017-10-03 02:47:49 Z0 days1 attempts


People who touched revisions under test:
  Yunhua Feng 

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 9425b34925d0cf1b96aaf2c316d3299df9780252
Author: Yunhua Feng 
Date:   Wed Sep 27 21:09:34 2017 +0800

BaseTools: PI 1.6 to support FV extended header contain FV used size

Per PI 1.6 we added an FV Extended Header entry that would contain the
size of the FV that was in use.

Cc: Liming Gao 
Cc: Yonghong Zhu 
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng 
Reviewed-by: Liming Gao 

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


[Xen-devel] [xen-unstable test] 113954: tolerable FAIL - PUSHED

2017-10-02 Thread osstest service owner
flight 113954 xen-unstable real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113954/

Failures :-/ but no regressions.

Regressions which are regarded as allowable (not blocking):
 test-armhf-armhf-xl-rtds 12 guest-start  fail REGR. vs. 113940

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stopfail like 113940
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop fail like 113940
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 113940
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 113940
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 113940
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 113940
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 113940
 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  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-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-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-cubietruck 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-amd64-i386-libvirt-qcow2 12 migrate-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-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-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-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-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass

version targeted for testing:
 xen  8c975cd44a4478f4cbe2710949ecda2dd7540c59
baseline version:
 xen  5414ba7f5e1ffc88ed2758b1e1b14bbfd3536a61

Last test of basis   113940  2017-10-02 01:59:21 Z1 days
Failing since113950  2017-10-02 13:18:04 Z0 days2 attempts
Testing same since   113954  2017-10-02 20:48:36 Z0 days1 attempts


People who touched revisions under test:
  Andrew Cooper 
  George Dunlap 
  Jan Beulich 
  Julien Grall 
  Petre Pircalabu 
  Roger Pau Monne 
  Roger Pau Monné 
  Tamas K Lengyel 
  Wei Liu 

jobs:
 build-amd64-xsm  pass
 build-armhf-xsm  pass
 build-i386-xsm   pass
 build-amd64-xtf  pass
 build-amd64  pass
 build-armhf  pass
 build-i386   pass
 

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

2017-10-02 Thread osstest service owner
flight 113958 ovmf real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113958/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf 9425b34925d0cf1b96aaf2c316d3299df9780252
baseline version:
 ovmf c46bced224b42d5a03bc8b207167829aa4e7bc5b

Last test of basis   113921  2017-09-30 04:28:22 Z2 days
Testing same since   113958  2017-10-03 00:49:06 Z0 days1 attempts


People who touched revisions under test:
  Yunhua Feng 

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=9425b34925d0cf1b96aaf2c316d3299df9780252
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.
 PERLLIB=.:.
+++ 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 
9425b34925d0cf1b96aaf2c316d3299df9780252
+ branch=ovmf
+ revision=9425b34925d0cf1b96aaf2c316d3299df9780252
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.:.
 PERLLIB=.:.:.
+++ 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
+++ export PERLLIB=.:.:.:.
+++ PERLLIB=.:.:.:.
++ 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
+ '[' x9425b34925d0cf1b96aaf2c316d3299df9780252 = 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
++ : git://xenbits.xen.org/osstest/ovmf.git
++ : git://xenbits.xen.org/osstest/linux-firmware.git
++ : 

Re: [Xen-devel] [PATCH v4 24/27] x86_32: assembly, add ENDs to some functions and relabel with SYM_CODE_*

2017-10-02 Thread Rafael J. Wysocki
On Mon, Oct 2, 2017 at 11:12 AM, Jiri Slaby  wrote:
> All these are functions which are invoked from elsewhere, but they are
> not typical C functions. So we annotate them (as global) using the new
> SYM_CODE_START. All these were not balanced with any END, so mark their
> ends by SYM_CODE_END, appropriatelly.
>
> Signed-off-by: Jiri Slaby 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: x...@kernel.org
> Cc: "Rafael J. Wysocki" 
> Cc: Len Brown 
> Cc: Pavel Machek 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: linux...@vger.kernel.org
> Cc: xen-de...@lists.xenproject.org

For the hibernate part:

Reviewed-by: Rafael J. Wysocki 

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


[Xen-devel] xen-pci-passthrough PCI Express support? (Re: [Qemu-devel] [PATCH v2 4/5] pci: Add INTERFACE_CONVENTIONAL_PCI_DEVICE to Conventional PCI devices)

2017-10-02 Thread Eduardo Habkost
On Thu, Sep 28, 2017 at 10:12:34AM -0300, Eduardo Habkost wrote:
> On Thu, Sep 28, 2017 at 02:33:57AM -0600, Jan Beulich wrote:
> > >>> On 27.09.17 at 21:56,  wrote:
> > > --- a/hw/xen/xen_pt.c
> > > +++ b/hw/xen/xen_pt.c
> > > @@ -964,6 +964,10 @@ static const TypeInfo xen_pci_passthrough_info = {
> > >  .instance_size = sizeof(XenPCIPassthroughState),
> > >  .instance_finalize = xen_pci_passthrough_finalize,
> > >  .class_init = xen_pci_passthrough_class_init,
> > > +.interfaces = (InterfaceInfo[]) {
> > > +{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
> > > +{ },
> > > +},
> > >  };
> > 
> > Passed through devices can be both PCI and PCIe, so following
> > the description of the patch I don't think these can be statically
> > given either property. Granted quite a bit of PCIe specific
> > functionality may be missing in the Xen code ...
> 
> This is just static data about what the device type supports, not
> about what a given device instance really is.  Deciding if the
> device is PCIe or Conventional at runtime is out of the scope of
> this series.
> 
> That said, if passed through PCI Express devices are really
> supported, it looks like this should be marked as hybrid.

Can anybody confirm if PCI Express devices are really supported
by xen-pci-passthrough?

I suggest we add only INTERFACE_CONVENTIONAL_PCI_DEVICE to the
class info until we confirm that.

(In other words, apply this patch as-is, and add
INTERFACE_PCIE_DEVICE later as a follow-up patch if appropriate.)

-- 
Eduardo

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


Re: [Xen-devel] [PATCH v3] xen/balloon: don't online new memory initially

2017-10-02 Thread HW42
Juergen Gross:
> When setting up the Xenstore watch for the memory target size the new
> watch will fire at once. Don't try to reach the configured target size
> by onlining new memory in this case, as the current memory size will
> be smaller in almost all cases due to e.g. BIOS reserved pages.
> 
> Onlining new memory will lead to more problems e.g. undesired conflicts
> with NVMe devices meant to be operated as block devices.
> 
> Instead remember the difference between target size and current size
> when the watch fires for the first time and apply it to any further
> size changes, too.
> 
> In order to avoid races between balloon.c and xen-balloon.c init calls
> do the xen-balloon.c initialization from balloon.c.
> 
> Signed-off-by: Juergen Gross 

This patch seems to introduce a regression. If I boot a HVM or PVH
domain with memory != maxmem then the kernel inside the domain reports
that it has maxmem available even though Xen reports only what is set as
memory. Sooner or later Xen logs "out of PoD memory!" and kills the
domain. If I revert the corresponding commit (96edd61d) then everything
works as expected.

Tested this with Xen 4.9.0 and Linux 4.13.4.



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


Re: [Xen-devel] [PATCH v5 3/4] x86/xen/time: setup vcpu 0 time info page

2017-10-02 Thread Joao Martins


On 10/02/2017 07:44 PM, Boris Ostrovsky wrote:
> 
>> +
>> +static void xen_setup_vsyscall_time_info(void)
>> +{
>> +struct vcpu_register_time_memory_area t;
>> +struct pvclock_vsyscall_time_info *ti;
>> +int ret;
> 
> 
> In the previous version you'd return immediately if
> PVCLOCK_TSC_STABLE_BIT was not set. Don't you still need to check this?
> Especially give...
> 
Yes, my mistake.

When moving the primary info check I changed the comment below, but should have
moved the call to xen_setup_vsyscall_time_info() into the newly added if ()
clause added in the previous patch. Let me move that inside the conditional and
respin in v6.

Joao

> 
>> +
>> +ti = (struct pvclock_vsyscall_time_info *)get_zeroed_page(GFP_KERNEL);
>> +if (!ti)
>> +return;
>> +
>> +t.addr.v = >pvti;
>> +
>> +ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, );
>> +if (ret) {
>> +pr_notice("xen: VCLOCK_PVCLOCK not supported (err %d)\n", ret);
>> +free_page((unsigned long)ti);
>> +return;
>> +}
>> +
>> +/*
>> + * If primary time info had this bit set, secondary should too since
> 
> ... this comment?
> 
> -boris

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


[Xen-devel] [xen-unstable-smoke test] 113952: tolerable all pass - PUSHED

2017-10-02 Thread osstest service owner
flight 113952 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113952/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  60823b39a1f3788b7ea98bdaf1eda987156f4c87
baseline version:
 xen  8c975cd44a4478f4cbe2710949ecda2dd7540c59

Last test of basis   113951  2017-10-02 16:02:58 Z0 days
Testing same since   113952  2017-10-02 19:01:00 Z0 days1 attempts


People who touched revisions under test:
  Andrew Cooper 
  Julien Grall 
  Razvan Cojocaru 
  Tamas K Lengyel 

jobs:
 build-amd64  pass
 build-armhf  pass
 build-amd64-libvirt  pass
 test-armhf-armhf-xl  pass
 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


Pushing revision :

+ branch=xen-unstable-smoke
+ revision=60823b39a1f3788b7ea98bdaf1eda987156f4c87
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.
 PERLLIB=.:.
+++ 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 xen-unstable-smoke 
60823b39a1f3788b7ea98bdaf1eda987156f4c87
+ branch=xen-unstable-smoke
+ revision=60823b39a1f3788b7ea98bdaf1eda987156f4c87
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.:.
 PERLLIB=.:.:.
+++ 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
+++ export PERLLIB=.:.:.:.
+++ PERLLIB=.:.:.:.
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=xen
+ xenbranch=xen-unstable-smoke
+ qemuubranch=qemu-upstream-unstable
+ '[' xxen = xlinux ']'
+ linuxbranch=
+ '[' xqemu-upstream-unstable = x ']'
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable-smoke
+ prevxenbranch=xen-4.9-testing
+ '[' x60823b39a1f3788b7ea98bdaf1eda987156f4c87 = 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
++ : 

Re: [Xen-devel] x86: PIE support and option to extend KASLR randomization

2017-10-02 Thread Thomas Garnier
On Sat, Sep 23, 2017 at 2:43 AM, Ingo Molnar  wrote:
>
> * Thomas Garnier  wrote:
>
>> >   2) we first implement the additional entropy bits that Linus suggested.
>> >
>> > does this work for you?
>>
>> Sure, I can look at how feasible that is. If it is, can I send
>> everything as part of the same patch set? The additional entropy would
>> be enabled for all KASLR but PIE will be off-by-default of course.
>
> Sure, can all be part of the same series.

I looked deeper in the change Linus proposed (moving the .text section
based on the cacheline). I think the complexity is too high for the
value of this change.

To move only the .text section would require at least the following changes:
 - Overall change on how relocations are processed, need to separate
relocations in and outside of the .text section.
 - Break assumptions on _text alignment while keeping calculation on
size accurate (for example _end - _text).

With a rough attempt at this, I managed to pass early boot and still
crash later on.

This change would be valuable if you leak the address of a section
other than .text and you want to know where .text is. Meaning the main
bug that you are trying to exploit only allow you to execute code (and
you are trying to ROP in .text). I would argue that a better
mitigation for this type of bugs is moving function pointer to
read-only sections and using stack cookies (for ret address). This
change won't prevent other type of attacks, like data corruption.

I think it would be more valuable to look at something like selfrando
/ pagerando [1] but maybe wait a bit for it to be more mature
(especially on the debugging side).

What do you think?

[1] http://lists.llvm.org/pipermail/llvm-dev/2017-June/113794.html

>
> Thanks,
>
> Ingo



-- 
Thomas

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


[Xen-devel] [xen-unstable test] 113950: regressions - FAIL

2017-10-02 Thread osstest service owner
flight 113950 xen-unstable real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113950/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemut-debianhvm-amd64  7 xen-bootfail REGR. vs. 113940
 test-amd64-amd64-xl-qcow210 debian-di-installfail REGR. vs. 113940

Regressions which are regarded as allowable (not blocking):
 test-armhf-armhf-xl-rtds 12 guest-start  fail REGR. vs. 113940

Tests which did not succeed, but are not blocking:
 test-armhf-armhf-xl-credit2  16 guest-start/debian.repeatfail  like 113933
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stopfail like 113940
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop fail like 113940
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 113940
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 113940
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 113940
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 113940
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 113940
 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  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-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-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-cubietruck 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-amd64-i386-libvirt-qcow2 12 migrate-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-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-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-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-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass

version targeted for testing:
 xen  ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae
baseline version:
 xen  5414ba7f5e1ffc88ed2758b1e1b14bbfd3536a61

Last test of basis   113940  2017-10-02 01:59:21 Z0 days
Testing same since   113950  2017-10-02 13:18:04 Z0 days1 attempts


People who touched revisions under test:
  Roger Pau Monne 
  Roger Pau Monné 
  Wei Liu 

jobs:
 build-amd64-xsm  pass
 build-armhf-xsm  pass
 build-i386-xsm   pass
 build-amd64-xtf  pass
 build-amd64  pass
 build-armhf  pass
 build-i386   pass
 build-amd64-libvirt 

Re: [Xen-devel] [PATCH] migration, xen: Fix block image lock issue on live migration

2017-10-02 Thread Dr. David Alan Gilbert
Adding in kwolf;  it looks sane to me; Kevin?
If I'm reading this right, this is just after the device state save.

Dave

* Anthony PERARD (anthony.per...@citrix.com) wrote:
> When doing a live migration of a Xen guest with libxl, the images for
> block devices are locked by the original QEMU process, and this prevent
> the QEMU at the destination to take the lock and the migration fail.
> 
> From QEMU point of view, once the RAM of a domain is migrated, there is
> two QMP commands, "stop" then "xen-save-devices-state", at which point a
> new QEMU is spawned at the destination.
> 
> Release locks in "xen-save-devices-state" so the destination can takes
> them.
> 
> Signed-off-by: Anthony PERARD 
> ---
> CCing libxl maintainers:
> CC: Ian Jackson 
> CC: Wei Liu 
> ---
>  migration/savevm.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 4a88228614..69d904c179 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2263,6 +2263,20 @@ void qmp_xen_save_devices_state(const char *filename, 
> Error **errp)
>  qemu_fclose(f);
>  if (ret < 0) {
>  error_setg(errp, QERR_IO_ERROR);
> +} else {
> +/* libxl calls the QMP command "stop" before calling
> + * "xen-save-devices-state" and in case of migration failure, libxl
> + * would call "cont".
> + * So call bdrv_inactivate_all (release locks) here to let the other
> + * side of the migration take controle of the images.
> + */
> +if (!saved_vm_running) {
> +ret = bdrv_inactivate_all();
> +if (ret) {
> +error_setg(errp, "%s: bdrv_inactivate_all() failed (%d)",
> +   __func__, ret);
> +}
> +}
>  }
>  
>   the_end:
> -- 
> Anthony PERARD
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK

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


Re: [Xen-devel] [PATCH v2 0/5] Towards work-conserving RTDS

2017-10-02 Thread Meng Xu
On Mon, Oct 2, 2017 at 1:04 PM, Dario Faggioli 
wrote:

> On Mon, 2017-10-02 at 17:38 +0300, Andrii Anisov wrote:
> > Hello Meng Xu and Dario,
> >
> Hi,
>
> > On 01.09.17 18:58, Meng Xu wrote:
> > > This series of patches make RTDS scheduler work-conserving
> > > without breaking real-time guarantees.
> > > VCPUs with extratime flag set can get extra time
> > > from the unreserved system resource.
> > > System administrators can decide which VCPUs have extratime flag
> > > set.
> >
> > As I understand from threads and the code, the work conserving
> > algorithm
> > is quite simplistic and will prefer a vcpu with greater utilization.
> >
> >  From our side we are looking for a bit different solution. I.e., in
> > the
> > same cpupool, running vcpus eager for RT characteristics under EDF
> > conditions, and share the rest of resources between non-rt vcpus
> > (i.e.
> > in a credit manner).
> > Possible use-case could be a system with a domain hunger for
> > resources,
> > but not critical (some infotainment system) and an RT domain
> > utilizing
> > at most 20% of a single CPU core. Having a SoC with 4 cores,
> > partitioning would be a significant resources wasting for described
> > scenario.
> >
> IMO, this is interesting, but I think the proper way to achieve
> something like this is not modify RTDS to also contain something like
> Credit, nor to modify Credit to also contain something like RTDS.
>
> The idea I have in mind to serve the use case you're describing is as
> follows. Right now, a cpupool can only have a scheduler. If it's RTDS,
> all the domains are scheduler with RTDS, if it's Credit, all the
> domains are scheduled with Credit, etc.
>
> My idea would be to allow a stack of schedulers in a cpupool.
> Basically, you'd configure a cpupool with sched="rtds,credit2" and then
> you specify, for each domain, what scheduler you want it to use.
>
> The end result would be that, in the example above, domains scheduler
> with Credit2 would run in the time left free by the domains scheduler
> by RTDS. E.g., if you have a cpupool with only 1 CPU, an RTDS domain
> with P=100,B=20, an RTDS domain with P=1000,B=40, and two Credit2
> domains, one with weight 256 and the other with weight 512. Then, the
> two RTDS domains will get 20% and 40% of the CPU, while the two Credit2
> domains will share the remaining 40% (the one with w=512 getting twice
> as much as the one with w=256).
>
> This is kind of similar with what Linux does with scheduling classes,
> but even more flexible.
>

​I was thinking about Linux scheduling class as well. :)
I think this is a great idea. :)​


> I am not working on implementing this right now, because I'm busy with
> other things, but I would like to do that at some point. And if you're
> up for helping, that would be great! :-)
>

​Right now, I'm with busy with a deadline. I will take care of the
work-conserving RTDS next week.
As to supporting different scheduling class on the same cpupool, I'm not
yet sure when I'm available for this. :(

Best,

Meng
-- 
Meng Xu
Ph.D. Candidate in Computer and Information Science
University of Pennsylvania
http://www.cis.upenn.edu/~mengxu/
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v5 3/4] x86/xen/time: setup vcpu 0 time info page

2017-10-02 Thread Boris Ostrovsky

> +
> +static void xen_setup_vsyscall_time_info(void)
> +{
> + struct vcpu_register_time_memory_area t;
> + struct pvclock_vsyscall_time_info *ti;
> + int ret;


In the previous version you'd return immediately if
PVCLOCK_TSC_STABLE_BIT was not set. Don't you still need to check this?
Especially give...


> +
> + ti = (struct pvclock_vsyscall_time_info *)get_zeroed_page(GFP_KERNEL);
> + if (!ti)
> + return;
> +
> + t.addr.v = >pvti;
> +
> + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, );
> + if (ret) {
> + pr_notice("xen: VCLOCK_PVCLOCK not supported (err %d)\n", ret);
> + free_page((unsigned long)ti);
> + return;
> + }
> +
> + /*
> +  * If primary time info had this bit set, secondary should too since

... this comment?

-boris

> +  * it's the same data on both just different memory regions. But we
> +  * still check it in case hypervisor is buggy.
> +  */
> + if (!(ti->pvti.flags & PVCLOCK_TSC_STABLE_BIT)) {
> + t.addr.v = NULL;
> + ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area,
> +  0, );
> + if (!ret)
> + free_page((unsigned long)ti);
> +
> + pr_notice("xen: VCLOCK_PVCLOCK not supported (tsc unstable)\n");
> + return;
> + }
> +
> + xen_clock = ti;
> + pvclock_set_pvti_cpu0_va(xen_clock);
> +
> + xen_clocksource.archdata.vclock_mode = VCLOCK_PVCLOCK;
> +}
> +
>  


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


Re: [Xen-devel] [PATCH v5 2/4] x86/xen/time: set pvclock flags on xen_time_init()

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 02:31 PM, Joao Martins wrote:
> Specifically check for PVCLOCK_TSC_STABLE_BIT and if this bit is set,
> then set it too on pvclock flags. This allows Xen clocksource to use it
> and thus speeding up xen_clocksource_read() callers (i.e. sched_clock())
>
> Signed-off-by: Joao Martins 

Reviewed-by: Boris Ostrovsky 



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


[Xen-devel] [PATCH v5 1/4] x86/pvclock: add setter for pvclock_pvti_cpu0_va

2017-10-02 Thread Joao Martins
Right now there is only a pvclock_pvti_cpu0_va() which is defined
on kvmclock since:

commit dac16fba6fc5
("x86/vdso: Get pvclock data from the vvar VMA instead of the fixmap")

The only user of this interface so far is kvm. This commit adds a
setter function for the pvti page and moves pvclock_pvti_cpu0_va
to pvclock, which is a more generic place to have it; and would
allow other PV clocksources to use it, such as Xen.

Signed-off-by: Joao Martins 
Acked-by: Andy Lutomirski 
---
Changes since v1:
 * Rebased: the only conflict was that I had move the export
 pvclock_pvti_cpu0_va() symbol as it is used by kvm PTP driver.
 * Do not initialize pvti_cpu0_va to NULL (checkpatch error)
 ( Comments from Andy Lutomirski )
 * Removed asm/pvclock.h 'pvclock_set_pvti_cpu0_va' definition
 for non !PARAVIRT_CLOCK to better track screwed Kconfig stuff.
 * Add his Acked-by (provided the previous adjustment was made)

Changes since RFC:
 (Comments from Andy Lutomirski)
 * Add __init to pvclock_set_pvti_cpu0_va
 * Add WARN_ON(vclock_was_used(VCLOCK_PVCLOCK)) to
 pvclock_set_pvti_cpu0_va
---
 arch/x86/include/asm/pvclock.h | 19 ++-
 arch/x86/kernel/kvmclock.c |  7 +--
 arch/x86/kernel/pvclock.c  | 14 ++
 3 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/pvclock.h b/arch/x86/include/asm/pvclock.h
index 448cfe1b48cf..6f228f90cdd7 100644
--- a/arch/x86/include/asm/pvclock.h
+++ b/arch/x86/include/asm/pvclock.h
@@ -4,15 +4,6 @@
 #include 
 #include 
 
-#ifdef CONFIG_KVM_GUEST
-extern struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void);
-#else
-static inline struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
-{
-   return NULL;
-}
-#endif
-
 /* some helper functions for xen and kvm pv clock sources */
 u64 pvclock_clocksource_read(struct pvclock_vcpu_time_info *src);
 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src);
@@ -101,4 +92,14 @@ struct pvclock_vsyscall_time_info {
 
 #define PVTI_SIZE sizeof(struct pvclock_vsyscall_time_info)
 
+#ifdef CONFIG_PARAVIRT_CLOCK
+void pvclock_set_pvti_cpu0_va(struct pvclock_vsyscall_time_info *pvti);
+struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void);
+#else
+static inline struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
+{
+   return NULL;
+}
+#endif
+
 #endif /* _ASM_X86_PVCLOCK_H */
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index d88967659098..538738047ff5 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -47,12 +47,6 @@ early_param("no-kvmclock", parse_no_kvmclock);
 static struct pvclock_vsyscall_time_info *hv_clock;
 static struct pvclock_wall_clock wall_clock;
 
-struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
-{
-   return hv_clock;
-}
-EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
-
 /*
  * The wallclock is the time of day when we booted. Since then, some time may
  * have elapsed since the hypervisor wrote the data. So we try to account for
@@ -334,6 +328,7 @@ int __init kvm_setup_vsyscall_timeinfo(void)
return 1;
}
 
+   pvclock_set_pvti_cpu0_va(hv_clock);
put_cpu();
 
kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
index 5c3f6d6a5078..cb7d6d9c9c2d 100644
--- a/arch/x86/kernel/pvclock.c
+++ b/arch/x86/kernel/pvclock.c
@@ -25,8 +25,10 @@
 
 #include 
 #include 
+#include 
 
 static u8 valid_flags __read_mostly = 0;
+static struct pvclock_vsyscall_time_info *pvti_cpu0_va __read_mostly;
 
 void pvclock_set_flags(u8 flags)
 {
@@ -144,3 +146,15 @@ void pvclock_read_wallclock(struct pvclock_wall_clock 
*wall_clock,
 
set_normalized_timespec(ts, now.tv_sec, now.tv_nsec);
 }
+
+void pvclock_set_pvti_cpu0_va(struct pvclock_vsyscall_time_info *pvti)
+{
+   WARN_ON(vclock_was_used(VCLOCK_PVCLOCK));
+   pvti_cpu0_va = pvti;
+}
+
+struct pvclock_vsyscall_time_info *pvclock_pvti_cpu0_va(void)
+{
+   return pvti_cpu0_va;
+}
+EXPORT_SYMBOL_GPL(pvclock_pvti_cpu0_va);
-- 
2.11.0


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


[Xen-devel] [PATCH v5 4/4] MAINTAINERS: xen, kvm: track pvclock-abi.h changes

2017-10-02 Thread Joao Martins
This file defines an ABI shared between guest and hypervisor(s)
(KVM, Xen) and as such there should be an correspondent entry in
MAINTAINERS file. Notice that there's already a text notice at the
top of the header file, hence this commit simply enforces it more
explicitly and have both peers noticed when such changes happen.

Signed-off-by: Joao Martins 
Acked-by: Juergen Gross 
Reviewed-by: Konrad Rzeszutek Wilk 
Acked-by: Paolo Bonzini 
---
Changes since v4:
 * Add Paolo's Acked-by
 * Add Konrad's Reviewed-by

Changes since v1:
 * Add Juergen's Gross Acked-by.
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6671f375f7fc..a4834c3c377a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7603,6 +7603,7 @@ S:Supported
 F: arch/x86/kvm/
 F: arch/x86/include/uapi/asm/kvm*
 F: arch/x86/include/asm/kvm*
+F: arch/x86/include/asm/pvclock-abi.h
 F: arch/x86/kernel/kvm.c
 F: arch/x86/kernel/kvmclock.c
 
@@ -14718,6 +14719,7 @@ F:  arch/x86/xen/
 F: drivers/*/xen-*front.c
 F: drivers/xen/
 F: arch/x86/include/asm/xen/
+F: arch/x86/include/asm/pvclock-abi.h
 F: include/xen/
 F: include/uapi/xen/
 F: Documentation/ABI/stable/sysfs-hypervisor-xen
-- 
2.11.0


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


[Xen-devel] [PATCH v5 3/4] x86/xen/time: setup vcpu 0 time info page

2017-10-02 Thread Joao Martins
In order to support pvclock vdso on xen we need to setup the time
info page for vcpu 0 and register the page with Xen using the
VCPUOP_register_vcpu_time_memory_area hypercall. This hypercall
will also forcefully update the pvti which will set some of the
necessary flags for vdso. Afterwards we check if it supports the
PVCLOCK_TSC_STABLE_BIT flag which is mandatory for having
vdso/vsyscall support. And if so, it will set the cpu 0 pvti that
will be later on used when mapping the vdso image.

The xen headers are also updated to include the new hypercall for
registering the secondary vcpu_time_info struct.

Signed-off-by: Joao Martins 
Reviewed-by: Juergen Gross 
---
Changes since v4:
 * Remove pvclock_set_flags since predecessor patch will set in
 xen_time_init. Consequently pvti local variable is not so useful
 and doesn't make things more clear - therefore remove it.
 * Adjust comment on xen_setup_vsyscall_time_info()
 * Add Juergen's Reviewed-by (Retained as there wasn't functional
 changes)

Changes since v3:
 (Comments from Juergen)
 * Remove _t added suffix from *GUEST_HANDLE* when sync vcpu.h
 with the latest

Changes since v2:
 (Comments from Juergen)
 * Omit the blank after the cast on all 3 occurrences.
 * Change last VCLOCK_PVCLOCK message to be more descriptive
 * Sync the complete vcpu.h header instead of just adding the
 needed one. (IOW adding VCPUOP_get_physid)

Changes since v1:
 * Check flags ahead to see if the  primary clock can use
 PVCLOCK_TSC_STABLE_BIT even if secondary registration fails.
 (Comments from Boris)
 * Remove addr, addr variables;
 * Change first pr_debug to pr_warn;
 * Change last pr_debug to pr_notice;
 * Add routine to solely register secondary time info.
 * Move xen_clock to outside xen_setup_vsyscall_time_info to allow
 restore path to simply re-register secondary time info. Let us
 handle the restore path more gracefully without re-allocating a
 page.
 * Removed cpu argument from xen_setup_vsyscall_time_info()
 * Adjustment failed registration error messages/loglevel to be the same
 * Also teardown secondary time info on suspend

Changes since RFC:
 (Comments from Boris and David)
 * Remove Kconfig option
 * Use get_zeroed_page/free/page
 * Remove the hypercall availability check
 * Unregister pvti with arg.addr.v = NULL if stable bit isn't supported.
 (New)
 * Set secondary copy on restore such that it works on migration.
 * Drop global xen_clock variable and stash it locally on
 xen_setup_vsyscall_time_info.
 * WARN_ON(ret) if we fail to unregister the pvti.
---
 arch/x86/xen/suspend.c   |  4 ++
 arch/x86/xen/time.c  | 87 
 arch/x86/xen/xen-ops.h   |  2 +
 include/xen/interface/vcpu.h | 42 +
 4 files changed, 135 insertions(+)

diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c
index d6b1680693a9..800ed36ecfba 100644
--- a/arch/x86/xen/suspend.c
+++ b/arch/x86/xen/suspend.c
@@ -16,6 +16,8 @@
 
 void xen_arch_pre_suspend(void)
 {
+   xen_save_time_memory_area();
+
if (xen_pv_domain())
xen_pv_pre_suspend();
 }
@@ -26,6 +28,8 @@ void xen_arch_post_suspend(int cancelled)
xen_pv_post_suspend(cancelled);
else
xen_hvm_post_suspend(cancelled);
+
+   xen_restore_time_memory_area();
 }
 
 static void xen_vcpu_notify_restore(void *data)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index fc0148d3a70d..aa8bb87601f3 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -370,6 +370,92 @@ static const struct pv_time_ops xen_time_ops __initconst = 
{
.steal_clock = xen_steal_clock,
 };
 
+static struct pvclock_vsyscall_time_info *xen_clock __read_mostly;
+
+void xen_save_time_memory_area(void)
+{
+   struct vcpu_register_time_memory_area t;
+   int ret;
+
+   if (!xen_clock)
+   return;
+
+   t.addr.v = NULL;
+
+   ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, );
+   if (ret != 0)
+   pr_notice("Cannot save secondary vcpu_time_info (err %d)",
+ ret);
+   else
+   clear_page(xen_clock);
+}
+
+void xen_restore_time_memory_area(void)
+{
+   struct vcpu_register_time_memory_area t;
+   int ret;
+
+   if (!xen_clock)
+   return;
+
+   t.addr.v = _clock->pvti;
+
+   ret = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_time_memory_area, 0, );
+
+   /*
+* We don't disable VCLOCK_PVCLOCK entirely if it fails to register the
+* secondary time info with Xen or if we migrated to a host without the
+* necessary flags. On both of these cases what happens is either
+* process seeing a zeroed out pvti or seeing no PVCLOCK_TSC_STABLE_BIT
+* bit set. Userspace checks the latter and if 0, it discards the data
+* in pvti and fallbacks to a system call for a reliable timestamp.
+*/

[Xen-devel] [PATCH v5 2/4] x86/xen/time: set pvclock flags on xen_time_init()

2017-10-02 Thread Joao Martins
Specifically check for PVCLOCK_TSC_STABLE_BIT and if this bit is set,
then set it too on pvclock flags. This allows Xen clocksource to use it
and thus speeding up xen_clocksource_read() callers (i.e. sched_clock())

Signed-off-by: Joao Martins 
---
New in v5
---
 arch/x86/xen/time.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 1ecb05db3632..fc0148d3a70d 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -372,6 +372,7 @@ static const struct pv_time_ops xen_time_ops __initconst = {
 
 static void __init xen_time_init(void)
 {
+   struct pvclock_vcpu_time_info *pvti;
int cpu = smp_processor_id();
struct timespec tp;
 
@@ -395,6 +396,14 @@ static void __init xen_time_init(void)
 
setup_force_cpu_cap(X86_FEATURE_TSC);
 
+   /*
+* We check ahead on the primary time info if this
+* bit is supported hence speeding up Xen clocksource.
+*/
+   pvti = &__this_cpu_read(xen_vcpu)->time;
+   if (pvti->flags & PVCLOCK_TSC_STABLE_BIT)
+   pvclock_set_flags(PVCLOCK_TSC_STABLE_BIT);
+
xen_setup_runstate_info(cpu);
xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
-- 
2.11.0


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


[Xen-devel] [PATCH v5 0/4] x86/xen: pvclock vdso support

2017-10-02 Thread Joao Martins
Hey,

This is take 5 for vdso for Xen. PVCLOCK_TSC_STABLE_BIT can be set starting Xen
 4.8 which is required for vdso time related calls. In order to have it on, you
need to have the hypervisor clocksource be TSC e.g. with the following boot
params "clocksource=tsc tsc=stable:socket".

Series is structured as following:

Patch 1 streamlines pvti page get/set in pvclock for both of its users
Patch 2,3 registers the pvti page on Xen and sets it in pvclock accordingly
Patch 4 adds a file to KVM/Xen maintainers for tracking pvclock ABI changes.
[ The last one is already Acked. ]

Changelog is in individual patches.

Thanks,
Joao

Joao Martins (4):
  x86/pvclock: add setter for pvclock_pvti_cpu0_va
  x86/xen/time: set pvclock flags on xen_time_init()
  x86/xen/time: setup vcpu 0 time info page
  MAINTAINERS: xen, kvm: track pvclock-abi.h changes

 MAINTAINERS|  2 +
 arch/x86/include/asm/pvclock.h | 19 +
 arch/x86/kernel/kvmclock.c |  7 +--
 arch/x86/kernel/pvclock.c  | 14 ++
 arch/x86/xen/suspend.c |  4 ++
 arch/x86/xen/time.c| 96 ++
 arch/x86/xen/xen-ops.h |  2 +
 include/xen/interface/vcpu.h   | 42 ++
 8 files changed, 171 insertions(+), 15 deletions(-)

-- 
2.11.0


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


Re: [Xen-devel] [PATCH v4 24/27] x86_32: assembly, add ENDs to some functions and relabel with SYM_CODE_*

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> All these are functions which are invoked from elsewhere, but they are
> not typical C functions. So we annotate them (as global) using the new
> SYM_CODE_START. All these were not balanced with any END, so mark their
> ends by SYM_CODE_END, appropriatelly.
>
> Signed-off-by: Jiri Slaby 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: x...@kernel.org
> Cc: "Rafael J. Wysocki" 
> Cc: Len Brown 
> Cc: Pavel Machek 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: linux...@vger.kernel.org
> Cc: xen-de...@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky 


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


Re: [Xen-devel] [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> These are all functions which are invoked from elsewhere, so we annotate
> them as global using the new SYM_FUNC_START. And their ENDPROC's by
> SYM_FUNC_END.
>
> And make sure ENTRY/ENDPROC is not defined on X86_64, given these were
> the last users.
>
> Signed-off-by: Jiri Slaby 
> Cc: "H. Peter Anvin" 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: x...@kernel.org
> Cc: Herbert Xu 
> Cc: "David S. Miller" 
> Cc: "Rafael J. Wysocki" 
> Cc: Len Brown 
> Cc: Pavel Machek 
> Cc: Matt Fleming 
> Cc: Ard Biesheuvel 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: linux-cry...@vger.kernel.org
> Cc: linux...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: xen-de...@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky 



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


Re: [Xen-devel] [PATCH v3 9/9] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one

2017-10-02 Thread Konrad Rzeszutek Wilk
On Mon, Oct 02, 2017 at 06:31:50PM +0100, Julien Grall wrote:
> This will help to consolidate the page-table code and avoid different
> path depending on the action to perform.
> 
> Signed-off-by: Julien Grall 
> Reviewed-by: Andre Przywara 
> Reviewed-by: Stefano Stabellini 
> 
> ---
> 

Reviewed-by: Konrad Rzeszutek Wilk 

> Cc: Ross Lagerwall 
> 
> arch_livepatch_secure is now the same as on x86. It might be
> possible to combine both, but I left that alone for now.
> 
> Changes in v3:
> - Add Stefano's reviewed-by
> 
> Changes in v2:
> - Add Andre's reviewed-by
> ---
>  xen/arch/arm/livepatch.c   |  6 +++---
>  xen/arch/arm/mm.c  |  5 ++---
>  xen/include/asm-arm/page.h | 11 ---
>  3 files changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c
> index 3e53524365..279d52cc6c 100644
> --- a/xen/arch/arm/livepatch.c
> +++ b/xen/arch/arm/livepatch.c
> @@ -146,15 +146,15 @@ int arch_livepatch_secure(const void *va, unsigned int 
> pages, enum va_type type)
>  switch ( type )
>  {
>  case LIVEPATCH_VA_RX:
> -flags = PTE_RO; /* R set, NX clear */
> +flags = PAGE_HYPERVISOR_RX;
>  break;
>  
>  case LIVEPATCH_VA_RW:
> -flags = PTE_NX; /* R clear, NX set */
> +flags = PAGE_HYPERVISOR_RW;
>  break;
>  
>  case LIVEPATCH_VA_RO:
> -flags = PTE_NX | PTE_RO; /* R set, NX set */
> +flags = PAGE_HYPERVISOR_RO;
>  break;
>  
>  default:
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 57afedf0be..705bdd9cce 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -1041,8 +1041,8 @@ static int create_xen_entries(enum xenmap_operation op,
>  else
>  {
>  pte = *entry;
> -pte.pt.ro = PTE_RO_MASK(flags);
> -pte.pt.xn = PTE_NX_MASK(flags);
> +pte.pt.ro = PAGE_RO_MASK(flags);
> +pte.pt.xn = PAGE_XN_MASK(flags);
>  if ( !pte.pt.ro && !pte.pt.xn )
>  {
>  printk("%s: Incorrect combination for addr=%lx\n",
> @@ -1085,7 +1085,6 @@ int destroy_xen_mappings(unsigned long v, unsigned long 
> e)
>  
>  int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
>  {
> -ASSERT((flags & (PTE_NX | PTE_RO)) == flags);
>  return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT,
>flags);
>  }
> diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
> index e2b3e402d0..e4be83a7bc 100644
> --- a/xen/include/asm-arm/page.h
> +++ b/xen/include/asm-arm/page.h
> @@ -96,17 +96,6 @@
>  #define PAGE_HYPERVISOR_WC  (_PAGE_DEVICE|MT_NORMAL_NC)
>  
>  /*
> - * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to 
> be
> - * used with modify_xen_mappings.
> - */
> -#define _PTE_NX_BIT 0U
> -#define _PTE_RO_BIT 1U
> -#define PTE_NX  (1U << _PTE_NX_BIT)
> -#define PTE_RO  (1U << _PTE_RO_BIT)
> -#define PTE_NX_MASK(x)  (((x) >> _PTE_NX_BIT) & 0x1U)
> -#define PTE_RO_MASK(x)  (((x) >> _PTE_RO_BIT) & 0x1U)
> -
> -/*
>   * Stage 2 Memory Type.
>   *
>   * These are valid in the MemAttr[3:0] field of an LPAE stage 2 page
> -- 
> 2.11.0
> 
> 
> ___
> 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


Re: [Xen-devel] [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_*

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> Here, we change all code which is not marked as functions. In other
> words, this code has been using END, not ENDPROC. So switch all of this
> to appropriate new markings SYM_CODE_START and SYM_CODE_END.
>
> Signed-off-by: Jiri Slaby 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: x...@kernel.org
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: xen-de...@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky 


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


[Xen-devel] [xen-unstable-smoke test] 113951: tolerable all pass - PUSHED

2017-10-02 Thread osstest service owner
flight 113951 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113951/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  8c975cd44a4478f4cbe2710949ecda2dd7540c59
baseline version:
 xen  3164f2f9db1e63ea64c3f9520d40cb09920d2b35

Last test of basis   113949  2017-10-02 13:01:50 Z0 days
Testing same since   113951  2017-10-02 16:02:58 Z0 days1 attempts


People who touched revisions under test:
  Andrew Cooper 
  George Dunlap 
  Jan Beulich 
  Julien Grall 
  Petre Pircalabu 
  Tamas K Lengyel 
  Wei Liu 

jobs:
 build-amd64  pass
 build-armhf  pass
 build-amd64-libvirt  pass
 test-armhf-armhf-xl  pass
 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


Pushing revision :

+ branch=xen-unstable-smoke
+ revision=8c975cd44a4478f4cbe2710949ecda2dd7540c59
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.
 PERLLIB=.:.
+++ 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 xen-unstable-smoke 
8c975cd44a4478f4cbe2710949ecda2dd7540c59
+ branch=xen-unstable-smoke
+ revision=8c975cd44a4478f4cbe2710949ecda2dd7540c59
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.:.
 PERLLIB=.:.:.
+++ 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
+++ export PERLLIB=.:.:.:.
+++ PERLLIB=.:.:.:.
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=xen
+ xenbranch=xen-unstable-smoke
+ qemuubranch=qemu-upstream-unstable
+ '[' xxen = xlinux ']'
+ linuxbranch=
+ '[' xqemu-upstream-unstable = x ']'
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable-smoke
+ prevxenbranch=xen-4.9-testing
+ '[' x8c975cd44a4478f4cbe2710949ecda2dd7540c59 = 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
++ : 

Re: [Xen-devel] [PATCH 2/3 v4] xenfb: Use Input Handlers directly

2017-10-02 Thread Anthony PERARD
On Tue, Sep 26, 2017 at 02:43:38PM +, Owen Smith wrote:
> Avoid the unneccessary calls through the input-legacy.c file by
> using the qemu_input_handler_*() calls directly. This did require
> reworking the event and sync handlers to use the reverse mapping
> from qcode to linux using qemu_input_qcode_to_linux().
> Removes the scancode2linux mapping, and supporting documention.
> 
> Signed-off-by: Owen Smith 

There is a call to trace_xenfb_key_event() that have been added
upstream, just before the call to xenfb_send_key(), that should probably
be added to this patch, otherwise, the patch does not apply. With that
fix, you can add my:
Acked-by: Anthony PERARD 

Thanks,

-- 
Anthony PERARD

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


[Xen-devel] [PATCH v3 9/9] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one

2017-10-02 Thread Julien Grall
This will help to consolidate the page-table code and avoid different
path depending on the action to perform.

Signed-off-by: Julien Grall 
Reviewed-by: Andre Przywara 
Reviewed-by: Stefano Stabellini 

---

Cc: Konrad Rzeszutek Wilk 
Cc: Ross Lagerwall 

arch_livepatch_secure is now the same as on x86. It might be
possible to combine both, but I left that alone for now.

Changes in v3:
- Add Stefano's reviewed-by

Changes in v2:
- Add Andre's reviewed-by
---
 xen/arch/arm/livepatch.c   |  6 +++---
 xen/arch/arm/mm.c  |  5 ++---
 xen/include/asm-arm/page.h | 11 ---
 3 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c
index 3e53524365..279d52cc6c 100644
--- a/xen/arch/arm/livepatch.c
+++ b/xen/arch/arm/livepatch.c
@@ -146,15 +146,15 @@ int arch_livepatch_secure(const void *va, unsigned int 
pages, enum va_type type)
 switch ( type )
 {
 case LIVEPATCH_VA_RX:
-flags = PTE_RO; /* R set, NX clear */
+flags = PAGE_HYPERVISOR_RX;
 break;
 
 case LIVEPATCH_VA_RW:
-flags = PTE_NX; /* R clear, NX set */
+flags = PAGE_HYPERVISOR_RW;
 break;
 
 case LIVEPATCH_VA_RO:
-flags = PTE_NX | PTE_RO; /* R set, NX set */
+flags = PAGE_HYPERVISOR_RO;
 break;
 
 default:
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 57afedf0be..705bdd9cce 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1041,8 +1041,8 @@ static int create_xen_entries(enum xenmap_operation op,
 else
 {
 pte = *entry;
-pte.pt.ro = PTE_RO_MASK(flags);
-pte.pt.xn = PTE_NX_MASK(flags);
+pte.pt.ro = PAGE_RO_MASK(flags);
+pte.pt.xn = PAGE_XN_MASK(flags);
 if ( !pte.pt.ro && !pte.pt.xn )
 {
 printk("%s: Incorrect combination for addr=%lx\n",
@@ -1085,7 +1085,6 @@ int destroy_xen_mappings(unsigned long v, unsigned long e)
 
 int modify_xen_mappings(unsigned long s, unsigned long e, unsigned int flags)
 {
-ASSERT((flags & (PTE_NX | PTE_RO)) == flags);
 return create_xen_entries(MODIFY, s, INVALID_MFN, (e - s) >> PAGE_SHIFT,
   flags);
 }
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index e2b3e402d0..e4be83a7bc 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -96,17 +96,6 @@
 #define PAGE_HYPERVISOR_WC  (_PAGE_DEVICE|MT_NORMAL_NC)
 
 /*
- * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be
- * used with modify_xen_mappings.
- */
-#define _PTE_NX_BIT 0U
-#define _PTE_RO_BIT 1U
-#define PTE_NX  (1U << _PTE_NX_BIT)
-#define PTE_RO  (1U << _PTE_RO_BIT)
-#define PTE_NX_MASK(x)  (((x) >> _PTE_NX_BIT) & 0x1U)
-#define PTE_RO_MASK(x)  (((x) >> _PTE_RO_BIT) & 0x1U)
-
-/*
  * Stage 2 Memory Type.
  *
  * These are valid in the MemAttr[3:0] field of an LPAE stage 2 page
-- 
2.11.0


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


[Xen-devel] [PATCH v3 3/9] xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table

2017-10-02 Thread Julien Grall
The description of AP[1] in Xen is based on testing rather than the ARM
ARM.

Per the ARM ARM, on EL2 stage-1 page table, AP[1] is RES1 as the
translation regime applies to only one exception level (see D4.4.4 and
G4.6.1 in ARM DDI 0487B.a).

Update the comment and also rename the field to match the description in
the ARM ARM.

Signed-off-by: Julien Grall 
Reviewed-by: Andre Przywara 
Acked-by: Stefano Stabellini 

---
Changes in v3:
- Add Stefano's acked-by

Changes in v2:
- Add Andre's reviewed-by
---
 xen/arch/arm/mm.c  | 10 +-
 xen/include/asm-arm/lpae.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index f41c6ce6f1..73677902d4 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -273,7 +273,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned 
attr)
 .table = 0,   /* Set to 1 for links and 4k maps */
 .ai = attr,
 .ns = 1,  /* Hyp mode is in the non-secure world */
-.user = 1,/* See below */
+.up = 1,  /* See below */
 .ro = 0,  /* Assume read-write */
 .af = 1,  /* No need for access tracking */
 .ng = 1,  /* Makes TLB flushes easier */
@@ -282,10 +282,10 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned 
attr)
 .avail = 0,   /* Reference count for domheap mapping */
 }};
 /*
- * Setting the User bit is strange, but the ATS1H[RW] instructions
- * don't seem to work otherwise, and since we never run on Xen
- * pagetables in User mode it's OK.  If this changes, remember
- * to update the hard-coded values in head.S too.
+ * For EL2 stage-1 page table, up (aka AP[1]) is RES1 as the translation
+ * regime applies to only one exception level (see D4.4.4 and G4.6.1
+ * in ARM DDI 0487B.a). If this changes, remember to update the
+ * hard-coded values in head.S too.
  */
 
 switch ( attr )
diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h
index 118ee5ae1a..b30853e79d 100644
--- a/xen/include/asm-arm/lpae.h
+++ b/xen/include/asm-arm/lpae.h
@@ -35,7 +35,7 @@ typedef struct __packed {
  */
 unsigned long ai:3; /* Attribute Index */
 unsigned long ns:1; /* Not-Secure */
-unsigned long user:1;   /* User-visible */
+unsigned long up:1; /* Unpriviledged access */
 unsigned long ro:1; /* Read-Only */
 unsigned long sh:2; /* Shareability */
 unsigned long af:1; /* Access Flag */
-- 
2.11.0


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


[Xen-devel] [PATCH v3 5/9] xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries

2017-10-02 Thread Julien Grall
The parameter 'ai' is used either for attribute index or for
permissions. Follow-up patch will rework that parameters to carry more
information. So rename the parameter to 'flags'.

Signed-off-by: Julien Grall 
Reviewed-by: Andre Przywara 
Reviewed-by: Stefano Stabellini 

---
Changes in v3:
- Add Stefano's reviewed-by

Changes in v2:
- Add Andre's reviewed-by
---
 xen/arch/arm/mm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 73677902d4..39bade63f5 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -986,7 +986,7 @@ static int create_xen_entries(enum xenmap_operation op,
   unsigned long virt,
   mfn_t mfn,
   unsigned long nr_mfns,
-  unsigned int ai)
+  unsigned int flags)
 {
 int rc;
 unsigned long addr = virt, addr_end = addr + nr_mfns * PAGE_SIZE;
@@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op,
 }
 if ( op == RESERVE )
 break;
-pte = mfn_to_xen_entry(mfn, ai);
+pte = mfn_to_xen_entry(mfn, flags);
 pte.pt.table = 1;
 write_pte(entry, pte);
 break;
@@ -1038,8 +1038,8 @@ static int create_xen_entries(enum xenmap_operation op,
 else
 {
 pte = *entry;
-pte.pt.ro = PTE_RO_MASK(ai);
-pte.pt.xn = PTE_NX_MASK(ai);
+pte.pt.ro = PTE_RO_MASK(flags);
+pte.pt.xn = PTE_NX_MASK(flags);
 if ( !pte.pt.ro && !pte.pt.xn )
 {
 printk("%s: Incorrect combination for addr=%lx\n",
-- 
2.11.0


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


[Xen-devel] [PATCH v3 0/9] xen/arm: Memory subsystem clean-up

2017-10-02 Thread Julien Grall
Hi all,

This patch series contains clean-up for the ARM memory subsystem in preparation
of reworking the page tables handling.

For all changes, see in each patch.

Cheers,

Julien Grall (9):
  xen/arm: page: Use ARMv8 naming to improve readability
  xen/arm: page: Clean-up the definition of MAIRVAL
  xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table
  xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator()
  xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries
  xen/arm: page: Describe the layout of flags used to update page tables
  xen/arm: mm: Embed permission in the flags
  xen/arm: mm: Handle permission flags when adding a new mapping
  xen/arm: mm: Use memory flags for modify_xen_mappings rather than
custom one

 xen/arch/arm/kernel.c |  2 +-
 xen/arch/arm/livepatch.c  |  6 +--
 xen/arch/arm/mm.c | 50 +++---
 xen/arch/arm/platforms/vexpress.c |  2 +-
 xen/arch/arm/setup.c  |  8 +++-
 xen/drivers/video/arm_hdlcd.c |  2 +-
 xen/include/asm-arm/lpae.h|  2 +-
 xen/include/asm-arm/page.h| 88 +--
 8 files changed, 96 insertions(+), 64 deletions(-)

-- 
2.11.0


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


[Xen-devel] [PATCH v3 8/9] xen/arm: mm: Handle permission flags when adding a new mapping

2017-10-02 Thread Julien Grall
Currently, all the new mappings will be read-write non-executable. Allow the
caller to use other permissions.

Signed-off-by: Julien Grall 

---
Changes in v2:
- Switch the runtime check to a BUG_ON()
---
 xen/arch/arm/mm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 117f05a1d6..57afedf0be 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1022,6 +1022,9 @@ static int create_xen_entries(enum xenmap_operation op,
 if ( op == RESERVE )
 break;
 pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags));
+pte.pt.ro = PAGE_RO_MASK(flags);
+pte.pt.xn = PAGE_XN_MASK(flags);
+BUG_ON(!pte.pt.ro && !pte.pt.xn);
 pte.pt.table = 1;
 write_pte(entry, pte);
 break;
-- 
2.11.0


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


[Xen-devel] [PATCH v3 4/9] xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator()

2017-10-02 Thread Julien Grall
We should consider the early boot period to end when we stop using the
boot allocator. This is inline with x86 and will be helpful to know
whether we should allocate memory from the boot allocator or xenheap.

Signed-off-by: Julien Grall 
Reviewed-by: Andre Przywara 
Reviewed-by: Stefano Stabellini 

---
Changes in v3:
- Add Stefano's reviewed-by

Changes in v2:
- Add Andre's reviewed-by
---
 xen/arch/arm/setup.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 3df451ae6f..16a3b1be8e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -757,6 +757,12 @@ void __init start_xen(unsigned long boot_phys_offset,
 
 end_boot_allocator();
 
+/*
+ * The memory subsystem has been initialized, we can now switch from
+ * early_boot -> boot.
+ */
+system_state = SYS_STATE_boot;
+
 vm_init();
 
 if ( acpi_disabled )
@@ -779,8 +785,6 @@ void __init start_xen(unsigned long boot_phys_offset,
 console_init_preirq();
 console_init_ring();
 
-system_state = SYS_STATE_boot;
-
 processor_id();
 
 smp_init_cpus();
-- 
2.11.0


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


[Xen-devel] [PATCH v3 7/9] xen/arm: mm: Embed permission in the flags

2017-10-02 Thread Julien Grall
Currently, it is not possible to specify the permission of a new
mapping. It would be necessary to use the function modify_xen_mappings
with a different set of flags.

Introduce a couple of new flags for the permissions (Non-eXecutable,
Read-Only) and also provides definition that combine the memory attribute
and permission for common combinations.

PAGE_HYPERVISOR is now an alias to PAGE_HYPERVISOR_RW (read-write,
non-executable mappings). This does not affect the current mapping using
PAGE_HYPERVISOR because Xen is currently forcing all the mapping to be
non-executable by default (see mfn_to_xen_entry).

A follow-up patch will change modify_xen_mappings to use the new flags.

Signed-off-by: Julien Grall 

---

Changes in v3:
- Add a comment about _PAGE_DEVICE and _PAGE_NORMAL

Changes in v2:
- Update the commit message
---
 xen/include/asm-arm/page.h | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index aa3e83f5b4..e2b3e402d0 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -69,12 +69,31 @@
  * Layout of the flags used for updating the hypervisor page tables
  *
  * [0:2] Memory Attribute Index
+ * [3:4] Permission flags
  */
 #define PAGE_AI_MASK(x) ((x) & 0x7U)
 
-#define PAGE_HYPERVISOR (MT_NORMAL)
-#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)
-#define PAGE_HYPERVISOR_WC  (MT_NORMAL_NC)
+#define _PAGE_XN_BIT3
+#define _PAGE_RO_BIT4
+#define _PAGE_XN(1U << _PAGE_XN_BIT)
+#define _PAGE_RO(1U << _PAGE_RO_BIT)
+#define PAGE_XN_MASK(x) (((x) >> _PAGE_XN_BIT) & 0x1U)
+#define PAGE_RO_MASK(x) (((x) >> _PAGE_RO_BIT) & 0x1U)
+
+/*
+ * _PAGE_DEVICE and _PAGE_NORMAL are conveniences defines. They are not
+ * meant to be used outside of the headers.
+ */
+#define _PAGE_DEVICE_PAGE_XN
+#define _PAGE_NORMALMT_NORMAL
+
+#define PAGE_HYPERVISOR_RO  (_PAGE_NORMAL|_PAGE_RO|_PAGE_XN)
+#define PAGE_HYPERVISOR_RX  (_PAGE_NORMAL|_PAGE_RO)
+#define PAGE_HYPERVISOR_RW  (_PAGE_NORMAL|_PAGE_XN)
+
+#define PAGE_HYPERVISOR PAGE_HYPERVISOR_RW
+#define PAGE_HYPERVISOR_NOCACHE (_PAGE_DEVICE|MT_DEVICE_nGnRE)
+#define PAGE_HYPERVISOR_WC  (_PAGE_DEVICE|MT_NORMAL_NC)
 
 /*
  * Defines for changing the hypervisor PTE .ro and .nx bits. This is only to be
-- 
2.11.0


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


[Xen-devel] [PATCH v3 2/9] xen/arm: page: Clean-up the definition of MAIRVAL

2017-10-02 Thread Julien Grall
Currently MAIRVAL is defined in term of MAIR0VAL and MAIR1VAL which are
both hardcoded value. This makes quite difficult to understand the value
written in both registers.

Rework the definition by using value of each attribute shifted by their
associated index.

Signed-off-by: Julien Grall 
Reviewed-by: Stefano Stabellini 

---
Changes in v3:
- s/above/below/ in the comment
- Add Stefano's reviewed-by

Changes in v2:
- Move this patch after "xen/arm: page: Use ARMv8 naming to
improve readability"
---
 xen/include/asm-arm/page.h | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 3d0bc6db81..0ae1a2587b 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -22,6 +22,21 @@
 #define LPAE_SH_INNER 0x3
 
 /*
+ * Attribute Indexes.
+ *
+ * These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page
+ * table entry. They are indexes into the bytes of the MAIR*
+ * registers, as defined below.
+ *
+ */
+#define MT_DEVICE_nGnRnE 0x0
+#define MT_NORMAL_NC 0x1
+#define MT_NORMAL_WT 0x2
+#define MT_NORMAL_WB 0x3
+#define MT_DEVICE_nGnRE  0x4
+#define MT_NORMAL0x7
+
+/*
  * LPAE Memory region attributes. Indexed by the AttrIndex bits of a
  * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1.
  *
@@ -38,24 +53,17 @@
  *   reserved 110
  *   MT_NORMAL111      -- Write-back write-allocate
  */
-#define MAIR0VAL 0xeeaa4400
-#define MAIR1VAL 0xff04
-#define MAIRVAL (MAIR0VAL|MAIR1VAL<<32)
+#define MAIR(attr, mt) (_AC(attr, ULL) << ((mt) * 8))
 
-/*
- * Attribute Indexes.
- *
- * These are valid in the AttrIndx[2:0] field of an LPAE stage 1 page
- * table entry. They are indexes into the bytes of the MAIR*
- * registers, as defined above.
- *
- */
-#define MT_DEVICE_nGnRnE 0x0
-#define MT_NORMAL_NC 0x1
-#define MT_NORMAL_WT 0x2
-#define MT_NORMAL_WB 0x3
-#define MT_DEVICE_nGnRE  0x4
-#define MT_NORMAL0x7
+#define MAIRVAL (MAIR(0x00, MT_DEVICE_nGnRnE)| \
+ MAIR(0x44, MT_NORMAL_NC)| \
+ MAIR(0xaa, MT_NORMAL_WT)| \
+ MAIR(0xee, MT_NORMAL_WB)| \
+ MAIR(0x04, MT_DEVICE_nGnRE) | \
+ MAIR(0xff, MT_NORMAL))
+
+#define MAIR0VAL (MAIRVAL & 0x)
+#define MAIR1VAL (MAIRVAL >> 32)
 
 #define PAGE_HYPERVISOR (MT_NORMAL)
 #define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)
-- 
2.11.0


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


[Xen-devel] [PATCH v3 1/9] xen/arm: page: Use ARMv8 naming to improve readability

2017-10-02 Thread Julien Grall
This is based on the Linux ARMv8 naming scheme (see arch/arm64/mm/proc.S). Each
type will contain "NORMAL" or "DEVICE" to make clear whether each attribute
targets device or normal memory.

Signed-off-by: Julien Grall 

---

Changes in v3:
- The ai '000' is named MT_DEVICE_nGnRnE and not
MT_DEVICE_nGnRE. The definition is still valid.
- Expand the comment to point to "Device Memory" section in the
ARM ARM.

Changes in v2:
* Move the patch before "xen/arm: page: Clean-up the definition
of MAIRVAL"
---
 xen/arch/arm/kernel.c |  2 +-
 xen/arch/arm/mm.c | 28 ++--
 xen/arch/arm/platforms/vexpress.c |  2 +-
 xen/drivers/video/arm_hdlcd.c |  2 +-
 xen/include/asm-arm/page.h| 35 +++
 5 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index 9c183f96da..a12baa86e7 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -54,7 +54,7 @@ void copy_from_paddr(void *dst, paddr_t paddr, unsigned long 
len)
 s = paddr & (PAGE_SIZE-1);
 l = min(PAGE_SIZE - s, len);
 
-set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), MT_BUFFERABLE);
+set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), MT_NORMAL_NC);
 memcpy(dst, src + s, l);
 clean_dcache_va_range(dst, l);
 
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 9a37f29ce6..f41c6ce6f1 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -290,7 +290,7 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned 
attr)
 
 switch ( attr )
 {
-case MT_BUFFERABLE:
+case MT_NORMAL_NC:
 /*
  * ARM ARM: Overlaying the shareability attribute (DDI
  * 0406C.b B3-1376 to 1377)
@@ -305,8 +305,8 @@ static inline lpae_t mfn_to_xen_entry(mfn_t mfn, unsigned 
attr)
  */
 e.pt.sh = LPAE_SH_OUTER;
 break;
-case MT_UNCACHED:
-case MT_DEV_SHARED:
+case MT_DEVICE_nGnRnE:
+case MT_DEVICE_nGnRE:
 /*
  * Shareability is ignored for non-Normal memory, Outer is as
  * good as anything.
@@ -369,7 +369,7 @@ static void __init create_mappings(lpae_t *second,
 
 count = nr_mfns / LPAE_ENTRIES;
 p = second + second_linear_offset(virt_offset);
-pte = mfn_to_xen_entry(_mfn(base_mfn), MT_WRITEALLOC);
+pte = mfn_to_xen_entry(_mfn(base_mfn), MT_NORMAL);
 if ( granularity == 16 * LPAE_ENTRIES )
 pte.pt.contig = 1;  /* These maps are in 16-entry contiguous chunks. */
 for ( i = 0; i < count; i++ )
@@ -422,7 +422,7 @@ void *map_domain_page(mfn_t mfn)
 else if ( map[slot].pt.avail == 0 )
 {
 /* Commandeer this 2MB slot */
-pte = mfn_to_xen_entry(_mfn(slot_mfn), MT_WRITEALLOC);
+pte = mfn_to_xen_entry(_mfn(slot_mfn), MT_NORMAL);
 pte.pt.avail = 1;
 write_pte(map + slot, pte);
 break;
@@ -543,7 +543,7 @@ static inline lpae_t pte_of_xenaddr(vaddr_t va)
 {
 paddr_t ma = va + phys_offset;
 
-return mfn_to_xen_entry(maddr_to_mfn(ma), MT_WRITEALLOC);
+return mfn_to_xen_entry(maddr_to_mfn(ma), MT_NORMAL);
 }
 
 /* Map the FDT in the early boot page table */
@@ -652,7 +652,7 @@ void __init setup_pagetables(unsigned long 
boot_phys_offset, paddr_t xen_paddr)
 /* Initialise xen second level entries ... */
 /* ... Xen's text etc */
 
-pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_WRITEALLOC);
+pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_NORMAL);
 pte.pt.xn = 0;/* Contains our text mapping! */
 xen_second[second_table_offset(XEN_VIRT_START)] = pte;
 
@@ -669,7 +669,7 @@ void __init setup_pagetables(unsigned long 
boot_phys_offset, paddr_t xen_paddr)
 
 /* ... Boot Misc area for xen relocation */
 dest_va = BOOT_RELOC_VIRT_START;
-pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_WRITEALLOC);
+pte = mfn_to_xen_entry(maddr_to_mfn(xen_paddr), MT_NORMAL);
 /* Map the destination in xen_second. */
 xen_second[second_table_offset(dest_va)] = pte;
 /* Map the destination in boot_second. */
@@ -700,7 +700,7 @@ void __init setup_pagetables(unsigned long 
boot_phys_offset, paddr_t xen_paddr)
 unsigned long va = XEN_VIRT_START + (i << PAGE_SHIFT);
 if ( !is_kernel(va) )
 break;
-pte = mfn_to_xen_entry(mfn, MT_WRITEALLOC);
+pte = mfn_to_xen_entry(mfn, MT_NORMAL);
 pte.pt.table = 1; /* 4k mappings always have this bit set */
 if ( is_kernel_text(va) || is_kernel_inittext(va) )
 {
@@ -771,7 +771,7 @@ int init_secondary_pagetables(int cpu)
 for ( i = 0; i < DOMHEAP_SECOND_PAGES; i++ )
 {
 pte = mfn_to_xen_entry(virt_to_mfn(domheap+i*LPAE_ENTRIES),
-   MT_WRITEALLOC);
+   MT_NORMAL);
 pte.pt.table = 1;
 

[Xen-devel] [PATCH v3 6/9] xen/arm: page: Describe the layout of flags used to update page tables

2017-10-02 Thread Julien Grall
Currently, the flags used to update page tables (i.e PAGE_HYPERVISOR_*)
only contains the memory attribute index. Follow-up patches will add
more information in it. So document the current layout.

At the same time introduce PAGE_AI_MASK to get the memory attribute
index easily.

Signed-off-by: Julien Grall 
Reviewed-by: Andre Przywara 
Reviewed-by: Stefano Stabellini 

---
Changes in v3:
- Add Stefano's reviewed-by

Changes in v2:
- Slightly update the commit message to specify we describe the
current layout.
- Add Andre's reviewed-by
---
 xen/arch/arm/mm.c  | 2 +-
 xen/include/asm-arm/page.h | 7 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 39bade63f5..117f05a1d6 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1021,7 +1021,7 @@ static int create_xen_entries(enum xenmap_operation op,
 }
 if ( op == RESERVE )
 break;
-pte = mfn_to_xen_entry(mfn, flags);
+pte = mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags));
 pte.pt.table = 1;
 write_pte(entry, pte);
 break;
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index 0ae1a2587b..aa3e83f5b4 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -65,6 +65,13 @@
 #define MAIR0VAL (MAIRVAL & 0x)
 #define MAIR1VAL (MAIRVAL >> 32)
 
+/*
+ * Layout of the flags used for updating the hypervisor page tables
+ *
+ * [0:2] Memory Attribute Index
+ */
+#define PAGE_AI_MASK(x) ((x) & 0x7U)
+
 #define PAGE_HYPERVISOR (MT_NORMAL)
 #define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)
 #define PAGE_HYPERVISOR_WC  (MT_NORMAL_NC)
-- 
2.11.0


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


Re: [Xen-devel] [PATCH v3 00/15] xen/x86: Clean-up the PoD code

2017-10-02 Thread Julien Grall

Hi George,

On 10/02/2017 05:30 PM, George Dunlap wrote:

On 10/02/2017 01:59 PM, Julien Grall wrote:

Hi all,

I have been attempting to use the PoD code on Arm (it will be sent in a
separate series) and spent sometimes to clean-up and switch to typesafe gfn
the current code.

The PoD code has been tested on Arm (the version is slightly different,
mostly renaming) and the x86 part has only been built test it.


At the end of this series there are still an awful lot of duplicate
"gfn_l" and "gfn" variables in p2m.c.  Are you planning on working to
remove them in the future?


It is not in my plan for now. I was mostly doing to get some prototypes 
inline with the Arm code (more prototype are using typesafe), and I was 
hoping someone could step up to push further down the unboxing.


Cheers,

--
Julien Grall

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


Re: [Xen-devel] [PATCH v2 0/5] Towards work-conserving RTDS

2017-10-02 Thread Dario Faggioli
On Mon, 2017-10-02 at 17:38 +0300, Andrii Anisov wrote:
> Hello Meng Xu and Dario,
> 
Hi,

> On 01.09.17 18:58, Meng Xu wrote:
> > This series of patches make RTDS scheduler work-conserving
> > without breaking real-time guarantees.
> > VCPUs with extratime flag set can get extra time
> > from the unreserved system resource.
> > System administrators can decide which VCPUs have extratime flag
> > set.
> 
> As I understand from threads and the code, the work conserving
> algorithm 
> is quite simplistic and will prefer a vcpu with greater utilization.
> 
>  From our side we are looking for a bit different solution. I.e., in
> the 
> same cpupool, running vcpus eager for RT characteristics under EDF 
> conditions, and share the rest of resources between non-rt vcpus
> (i.e. 
> in a credit manner).
> Possible use-case could be a system with a domain hunger for
> resources, 
> but not critical (some infotainment system) and an RT domain
> utilizing 
> at most 20% of a single CPU core. Having a SoC with 4 cores, 
> partitioning would be a significant resources wasting for described 
> scenario.
> 
IMO, this is interesting, but I think the proper way to achieve
something like this is not modify RTDS to also contain something like
Credit, nor to modify Credit to also contain something like RTDS.

The idea I have in mind to serve the use case you're describing is as
follows. Right now, a cpupool can only have a scheduler. If it's RTDS,
all the domains are scheduler with RTDS, if it's Credit, all the
domains are scheduled with Credit, etc.

My idea would be to allow a stack of schedulers in a cpupool.
Basically, you'd configure a cpupool with sched="rtds,credit2" and then
you specify, for each domain, what scheduler you want it to use.

The end result would be that, in the example above, domains scheduler
with Credit2 would run in the time left free by the domains scheduler
by RTDS. E.g., if you have a cpupool with only 1 CPU, an RTDS domain
with P=100,B=20, an RTDS domain with P=1000,B=40, and two Credit2
domains, one with weight 256 and the other with weight 512. Then, the
two RTDS domains will get 20% and 40% of the CPU, while the two Credit2
domains will share the remaining 40% (the one with w=512 getting twice
as much as the one with w=256).

This is kind of similar with what Linux does with scheduling classes,
but even more flexible.

I am not working on implementing this right now, because I'm busy with
other things, but I would like to do that at some point. And if you're
up for helping, that would be great! :-)

Dario
-- 
<> (Raistlin Majere)
-
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R Ltd., Cambridge (UK)

signature.asc
Description: This is a digitally signed message part
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 3/3 v4] xenfb: Add [feature|request]-raw-pointer

2017-10-02 Thread Anthony PERARD
On Tue, Sep 26, 2017 at 02:43:39PM +, Owen Smith wrote:
> Writes "feature-raw-pointer" during init to indicate the backend
> can pass raw unscaled values for absolute axes to the frontend.
> Frontends set "request-raw-pointer" to indicate the backend should
> not attempt to scale absolute values to console size.
> "request-raw-pointer" is only valid if "request-abs-pointer" is
> also set. Raw unscaled pointer values are in the range [0, 0x7fff]
> 
> Signed-off-by: Owen Smith 

Hi Owen,

Why did you remove the following from the commit description?
> "feature-raw-pointer" and "request-raw-pointer" added to Xen
> header in commit 7868654ff7fe5e4a2eeae2b277644fa884a5031e

I think that with it, you could have kept stefano's reviewed-by tag.

Thanks,

-- 
Anthony PERARD

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


Re: [Xen-devel] [PATCH v4 21/27] x86_64: assembly, add ENDs to some functions and relabel with SYM_CODE_*

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> All these are functions which are invoked from elsewhere, but they are
> not typical C functions. So we annotate them (as global) using the new
> SYM_CODE_START. All these were not balanced with any END, so mark their
> ends by SYM_CODE_END, appropriatelly.
>
> Signed-off-by: Jiri Slaby 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: x...@kernel.org
> Cc: xen-de...@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky 



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


Re: [Xen-devel] [PATCH v4 13/27] x86: xen-pvh, annotate data appropriatelly

2017-10-02 Thread Boris Ostrovsky
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> Use the new SYM_DATA_START_LOCAL, and SYM_DATA_END* macros:
>    8 OBJECT  LOCAL  DEFAULT6 gdt
>   000832 OBJECT  LOCAL  DEFAULT6 gdt_start
>   0028 0 OBJECT  LOCAL  DEFAULT6 gdt_end
>   0028   256 OBJECT  LOCAL  DEFAULT6 early_stack
>   0128 0 OBJECT  LOCAL  DEFAULT6 early_stack
>
> Signed-off-by: Jiri Slaby 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: "H. Peter Anvin" 
> Cc: x...@kernel.org
> Cc: xen-de...@lists.xenproject.org
> ---

Reviewed-by: Boris Ostrovsky 


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


[Xen-devel] high CPU stolen time after live migrate

2017-10-02 Thread Olivier Bonvalet
Hi,

with Xen 4.8.2, migrated domains have wrong stats for stolen time.

For example :

root! laussor:/proc# cat stat 
cpu  87957976 32463 6483874 361169794 3075806 0 937004 183086986113 0 0
cpu0 2828867 2434 226580 43754152 786651 0 42766 1778722573131 0 0
cpu1 2611496 3545 232529 42364047 594846 0 2441 1598822754769 0 0
cpu2 21958330 14923 1338283 40315990 424045 0 127421 1086605305497 0 0
cpu3 2725745 339 271471 42426113 319132 0 1408 41756798508 0 0
cpu4 21738600 3858 1099222 39528759 508996 0 682044 321900840424 0 0
cpu5 9543155 1668 1165194 53274011 231727 0 8130 1652751948052 0 0
cpu6 14223984 4014 970888 48826880 126790 0 67909 254194505219 0 0
cpu7 12327794 1680 1179702 50679764 83618 0 4883 827029885923 0 0
intr 7866132625 99868037 0 434116966 617 0 363800 0 94983174 425603035 1016 0 
390335 0 0 122245733 369053953 1041 0 358301 0 0 77267482 422334777 1015 0 
371084 0 0 96031342 218747945 993 0 331440 0 0 77622794 333046334 1139 0 444912 
0 0 57536561 237035283 1126 0 407725 0 0 41162673 306795645 1196 0 431960 0 0 
775 0 0 0 0 479 0 0 0 952 0 0 0 17046 30405 15526 94781 14025 3849 16848 4485 
16352 1801 17611 2104 14016 1807 16868 2235 3680 0 0 0 0 0 0 0 110370 107659 
101208 355716 107895 62726 105345 70387 112823 62653 103888 70642 109312 63799 
103388 65918 0 0 0 5619 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0
ctxt 6178259009
btime 1506309567
processes 6457002
procs_running 2
procs_blocked 0
softirq 2893820956 8 574619811 808518311 848843354 0 0 12041195 205459383 0 
444338894


root! laussor:/proc# cat /proc/uptime 
652005.23 2631328.82


Values for "stolen time" in /proc/stat seems impossible with only 7 days of 
uptime.


Is it a known bug ?

thanks,

Olivier

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


[Xen-devel] [PATCH] migration, xen: Fix block image lock issue on live migration

2017-10-02 Thread Anthony PERARD
When doing a live migration of a Xen guest with libxl, the images for
block devices are locked by the original QEMU process, and this prevent
the QEMU at the destination to take the lock and the migration fail.

From QEMU point of view, once the RAM of a domain is migrated, there is
two QMP commands, "stop" then "xen-save-devices-state", at which point a
new QEMU is spawned at the destination.

Release locks in "xen-save-devices-state" so the destination can takes
them.

Signed-off-by: Anthony PERARD 
---
CCing libxl maintainers:
CC: Ian Jackson 
CC: Wei Liu 
---
 migration/savevm.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index 4a88228614..69d904c179 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2263,6 +2263,20 @@ void qmp_xen_save_devices_state(const char *filename, 
Error **errp)
 qemu_fclose(f);
 if (ret < 0) {
 error_setg(errp, QERR_IO_ERROR);
+} else {
+/* libxl calls the QMP command "stop" before calling
+ * "xen-save-devices-state" and in case of migration failure, libxl
+ * would call "cont".
+ * So call bdrv_inactivate_all (release locks) here to let the other
+ * side of the migration take controle of the images.
+ */
+if (!saved_vm_running) {
+ret = bdrv_inactivate_all();
+if (ret) {
+error_setg(errp, "%s: bdrv_inactivate_all() failed (%d)",
+   __func__, ret);
+}
+}
 }
 
  the_end:
-- 
Anthony PERARD


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


Re: [Xen-devel] [PATCH v3 00/15] xen/x86: Clean-up the PoD code

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Hi all,
> 
> I have been attempting to use the PoD code on Arm (it will be sent in a
> separate series) and spent sometimes to clean-up and switch to typesafe gfn
> the current code.
> 
> The PoD code has been tested on Arm (the version is slightly different,
> mostly renaming) and the x86 part has only been built test it.

At the end of this series there are still an awful lot of duplicate
"gfn_l" and "gfn" variables in p2m.c.  Are you planning on working to
remove them in the future?

 -George


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


Re: [Xen-devel] [PATCH v3 15/15] xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> - Switch the return type to bool
> - Remove the parameter p2m_query_t q as it is not used
> 
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 12/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> At the same time make the array gfns const has it is not modified within
> the function.
> 
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


[Xen-devel] [PATCH for-next 2/3] xen/x86: Introduce static inline wrappers for l{idt, gdt, ldt, tr}()

2017-10-02 Thread Andrew Cooper
This avoids indirection and parameter constraint issues.  Doing so relaxes the
load_LDT() constraints from %ax to any general purpose register.

The triple-fault reboot method stays as is, to avoid the int3 possibly getting
moved relative to the lidt.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
CC: George Dunlap 
---
 xen/arch/x86/cpu/common.c  |  8 
 xen/arch/x86/domain.c  |  6 --
 xen/common/efi/runtime.c   |  4 ++--
 xen/include/asm-x86/desc.h | 20 
 xen/include/asm-x86/ldt.h  |  6 ++
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 78f5667..9c50ec6 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -697,10 +697,10 @@ void load_system_tables(void)
offsetof(struct tss_struct, __cacheline_filler) - 1,
SYS_DESC_tss_busy);
 
-   asm volatile ("lgdt %0"  : : "m"  (gdtr) );
-   asm volatile ("lidt %0"  : : "m"  (idtr) );
-   asm volatile ("ltr  %w0" : : "rm" (TSS_ENTRY << 3) );
-   asm volatile ("lldt %w0" : : "rm" (0) );
+   lgdt();
+   lidt();
+   ltr(TSS_ENTRY << 3);
+   lldt(0);
 
/*
 * Bottom-of-stack must be 16-byte aligned!
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 466a1a2..dfe905f 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1625,7 +1625,8 @@ static void __context_switch(void)
 {
 gdt_desc.limit = LAST_RESERVED_GDT_BYTE;
 gdt_desc.base  = (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY);
-asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+
+lgdt(_desc);
 }
 
 write_ptbase(n);
@@ -1635,7 +1636,8 @@ static void __context_switch(void)
 {
 gdt_desc.limit = LAST_RESERVED_GDT_BYTE;
 gdt_desc.base = GDT_VIRT_START(n);
-asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+
+lgdt(_desc);
 }
 
 if ( pd != nd )
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index c38f00a..3dbc2e8 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -108,7 +108,7 @@ struct efi_rs_state efi_rs_enter(void)
  FIRST_RESERVED_GDT_ENTRY)
 };
 
-asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+lgdt(_desc);
 }
 
 write_cr3(virt_to_maddr(efi_l4_pgtable));
@@ -128,7 +128,7 @@ void efi_rs_leave(struct efi_rs_state *state)
 .base  = GDT_VIRT_START(current)
 };
 
-asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
+lgdt(_desc);
 }
 irq_exit();
 efi_rs_on_cpu = NR_CPUS;
diff --git a/xen/include/asm-x86/desc.h b/xen/include/asm-x86/desc.h
index da924bf..1ec320e 100644
--- a/xen/include/asm-x86/desc.h
+++ b/xen/include/asm-x86/desc.h
@@ -197,6 +197,26 @@ DECLARE_PER_CPU(struct desc_struct *, compat_gdt_table);
 
 extern void load_TR(void);
 
+static inline void lgdt(const struct desc_ptr *gdtr)
+{
+asm volatile ("lgdt %0" :: "m" (*gdtr));
+}
+
+static inline void lidt(const struct desc_ptr *idtr)
+{
+asm volatile ("lidt %0" :: "m" (*idtr));
+}
+
+static inline void lldt(unsigned int sel)
+{
+asm volatile ("lldt %w0" :: "rm" (sel));
+}
+
+static inline void ltr(unsigned int sel)
+{
+asm volatile ("ltr %w0" :: "rm" (sel));
+}
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __ARCH_DESC_H */
diff --git a/xen/include/asm-x86/ldt.h b/xen/include/asm-x86/ldt.h
index 289ae19..589daf8 100644
--- a/xen/include/asm-x86/ldt.h
+++ b/xen/include/asm-x86/ldt.h
@@ -10,16 +10,14 @@ static inline void load_LDT(struct vcpu *v)
 unsigned long ents;
 
 if ( (ents = v->arch.pv_vcpu.ldt_ents) == 0 )
-{
-__asm__ __volatile__ ( "lldt %%ax" : : "a" (0) );
-}
+lldt(0);
 else
 {
 desc = (!is_pv_32bit_vcpu(v)
 ? this_cpu(gdt_table) : this_cpu(compat_gdt_table))
+ LDT_ENTRY - FIRST_RESERVED_GDT_ENTRY;
 _set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, SYS_DESC_ldt);
-__asm__ __volatile__ ( "lldt %%ax" : : "a" (LDT_ENTRY << 3) );
+lldt(LDT_ENTRY << 3);
 }
 }
 
-- 
2.1.4


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


[Xen-devel] [PATCH for-next 0/3] xen/x86: Misc improvements

2017-10-02 Thread Andrew Cooper
Andrew Cooper (3):
  x86/smp: Rework cpu_smpboot_alloc() to cope with more than just
-ENOMEM
  xen/x86: Introduce static inline wrappers for l{idt,gdt,ldt,tr}()
  x86/ldt: Alter how invalidate_shadow_ldt() deals with TLB flushes

 xen/arch/x86/cpu/common.c  |  8 
 xen/arch/x86/domain.c  |  6 --
 xen/arch/x86/mm.c  | 39 +--
 xen/arch/x86/smpboot.c | 31 ++-
 xen/common/efi/runtime.c   |  4 ++--
 xen/include/asm-x86/desc.h | 20 
 xen/include/asm-x86/ldt.h  |  6 ++
 7 files changed, 75 insertions(+), 39 deletions(-)

-- 
2.1.4


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


[Xen-devel] [PATCH for-next 1/3] x86/smp: Rework cpu_smpboot_alloc() to cope with more than just -ENOMEM

2017-10-02 Thread Andrew Cooper
No functional change.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
CC: George Dunlap 
---
 xen/arch/x86/smpboot.c | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 3ca716c..a3c42ea 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -696,33 +696,34 @@ static int cpu_smpboot_alloc(unsigned int cpu)
 nodeid_t node = cpu_to_node(cpu);
 struct desc_struct *gdt;
 unsigned long stub_page;
+int rc = -ENOMEM;
 
 if ( node != NUMA_NO_NODE )
 memflags = MEMF_node(node);
 
 stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, memflags);
 if ( stack_base[cpu] == NULL )
-goto oom;
+goto out;
 memguard_guard_stack(stack_base[cpu]);
 
 order = get_order_from_pages(NR_RESERVED_GDT_PAGES);
 per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order, memflags);
 if ( gdt == NULL )
-goto oom;
+goto out;
 memcpy(gdt, boot_cpu_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE);
 BUILD_BUG_ON(NR_CPUS > 0x1);
 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu;
 
 per_cpu(compat_gdt_table, cpu) = gdt = alloc_xenheap_pages(order, 
memflags);
 if ( gdt == NULL )
-goto oom;
+goto out;
 memcpy(gdt, boot_cpu_compat_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE);
 gdt[PER_CPU_GDT_ENTRY - FIRST_RESERVED_GDT_ENTRY].a = cpu;
 
 order = get_order_from_bytes(IDT_ENTRIES * sizeof(idt_entry_t));
 idt_tables[cpu] = alloc_xenheap_pages(order, memflags);
 if ( idt_tables[cpu] == NULL )
-goto oom;
+goto out;
 memcpy(idt_tables[cpu], idt_table, IDT_ENTRIES * sizeof(idt_entry_t));
 
 for ( stub_page = 0, i = cpu & ~(STUBS_PER_PAGE - 1);
@@ -735,21 +736,25 @@ static int cpu_smpboot_alloc(unsigned int cpu)
 BUG_ON(i == cpu);
 stub_page = alloc_stub_page(cpu, _cpu(stubs.mfn, cpu));
 if ( !stub_page )
-goto oom;
+goto out;
 per_cpu(stubs.addr, cpu) = stub_page + STUB_BUF_CPU_OFFS(cpu);
 
 if ( secondary_socket_cpumask == NULL &&
  (secondary_socket_cpumask = xzalloc(cpumask_t)) == NULL )
-goto oom;
+goto out;
 
-if ( zalloc_cpumask_var(_cpu(cpu_sibling_mask, cpu)) &&
- zalloc_cpumask_var(_cpu(cpu_core_mask, cpu)) &&
- alloc_cpumask_var(_cpu(scratch_cpumask, cpu)) )
-return 0;
+if ( !(zalloc_cpumask_var(_cpu(cpu_sibling_mask, cpu)) &&
+   zalloc_cpumask_var(_cpu(cpu_core_mask, cpu)) &&
+   alloc_cpumask_var(_cpu(scratch_cpumask, cpu))) )
+goto out;
+
+rc = 0;
+
+ out:
+if ( rc )
+cpu_smpboot_free(cpu);
 
- oom:
-cpu_smpboot_free(cpu);
-return -ENOMEM;
+return rc;
 }
 
 static int cpu_smpboot_callback(
-- 
2.1.4


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


[Xen-devel] [PATCH for-next 3/3] x86/ldt: Alter how invalidate_shadow_ldt() deals with TLB flushes

2017-10-02 Thread Andrew Cooper
Modify invalidate_shadow_ldt() to return a boolean indicating whether mappings
have been dropped, rather than taking a flush parameter.  Tweak the internal
logic to be able to ASSERT() that v->arch.pv_vcpu.shadow_ldt_mapcnt matches
the number of PTEs removed.

This allows MMUEXTOP_SET_LDT to avoid a local TLB flush if no LDT entries had
been faulted in to begin with.

Finally, correct a comment in __get_page_type().  Under no circumstance is it
safe to forgo the TLB shootdown for GDT/LDT pages, as that would allow one
vcpu to gain a writeable mapping to a frame still mapped as a GDT/LDT by
another vcpu.

Signed-off-by: Andrew Cooper 
---
 xen/arch/x86/mm.c | 39 +--
 1 file changed, 25 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index d9df5ca..37de4ff 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -505,10 +505,14 @@ static inline void page_set_tlbflush_timestamp(struct 
page_info *page)
 const char __section(".bss.page_aligned.const") __aligned(PAGE_SIZE)
 zero_page[PAGE_SIZE];
 
-static void invalidate_shadow_ldt(struct vcpu *v, int flush)
+/*
+ * Flush the LDT, dropping any typerefs.  Returns a boolean indicating whether
+ * mappings have been removed (i.e. a TLB flush is needed).
+ */
+static bool invalidate_shadow_ldt(struct vcpu *v)
 {
 l1_pgentry_t *pl1e;
-unsigned int i;
+unsigned int i, mappings_dropped = 0;
 struct page_info *page;
 
 BUG_ON(unlikely(in_irq()));
@@ -518,26 +522,29 @@ static void invalidate_shadow_ldt(struct vcpu *v, int 
flush)
 if ( v->arch.pv_vcpu.shadow_ldt_mapcnt == 0 )
 goto out;
 
-v->arch.pv_vcpu.shadow_ldt_mapcnt = 0;
 pl1e = pv_ldt_ptes(v);
 
 for ( i = 0; i < 16; i++ )
 {
 if ( !(l1e_get_flags(pl1e[i]) & _PAGE_PRESENT) )
 continue;
+
 page = l1e_get_page(pl1e[i]);
 l1e_write([i], l1e_empty());
+mappings_dropped++;
+
 ASSERT_PAGE_IS_TYPE(page, PGT_seg_desc_page);
 ASSERT_PAGE_IS_DOMAIN(page, v->domain);
 put_page_and_type(page);
 }
 
-/* Rid TLBs of stale mappings (guest mappings and shadow mappings). */
-if ( flush )
-flush_tlb_mask(v->vcpu_dirty_cpumask);
+ASSERT(v->arch.pv_vcpu.shadow_ldt_mapcnt == mappings_dropped);
+v->arch.pv_vcpu.shadow_ldt_mapcnt = 0;
 
  out:
 spin_unlock(>arch.pv_vcpu.shadow_ldt_lock);
+
+return !!mappings_dropped;
 }
 
 
@@ -1087,7 +1094,10 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain 
*l1e_owner)
  (l1e_owner == pg_owner) )
 {
 for_each_vcpu ( pg_owner, v )
-invalidate_shadow_ldt(v, 1);
+{
+if ( invalidate_shadow_ldt(v) )
+flush_tlb_mask(v->vcpu_dirty_cpumask);
+}
 }
 put_page(page);
 }
@@ -2237,9 +2247,9 @@ static int __get_page_type(struct page_info *page, 
unsigned long type,
 if ( (x & PGT_type_mask) != type )
 {
 /*
- * On type change we check to flush stale TLB entries. This
- * may be unnecessary (e.g., page was GDT/LDT) but those
- * circumstances should be very rare.
+ * On type change we check to flush stale TLB entries. It is
+ * vital that no other CPUs are left with mappings of a frame
+ * which is about to become writeable to the guest.
  */
 cpumask_t *mask = this_cpu(scratch_cpumask);
 
@@ -2486,7 +2496,7 @@ int new_guest_cr3(mfn_t mfn)
 return rc;
 }
 
-invalidate_shadow_ldt(curr, 0);
+invalidate_shadow_ldt(curr); /* Unconditional TLB flush later. */
 write_ptbase(curr);
 
 return 0;
@@ -2524,7 +2534,7 @@ int new_guest_cr3(mfn_t mfn)
 return rc;
 }
 
-invalidate_shadow_ldt(curr, 0);
+invalidate_shadow_ldt(curr); /* Unconditional TLB flush later. */
 
 if ( !VM_ASSIST(d, m2p_strict) && !paging_mode_refcounts(d) )
 fill_ro_mpt(mfn);
@@ -3025,8 +3035,9 @@ long do_mmuext_op(
 else if ( (curr->arch.pv_vcpu.ldt_ents != ents) ||
   (curr->arch.pv_vcpu.ldt_base != ptr) )
 {
-invalidate_shadow_ldt(curr, 0);
-flush_tlb_local();
+if ( invalidate_shadow_ldt(curr) )
+flush_tlb_local();
+
 curr->arch.pv_vcpu.ldt_base = ptr;
 curr->arch.pv_vcpu.ldt_ents = ents;
 load_LDT(curr);
-- 
2.1.4


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


Re: [Xen-devel] [PATCH v3 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 10/15] xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 09/15] xen/x86: p2m: Use typesafe GFN in p2m_set_entry

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Acked-by: Tamas K Lengyel 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v3 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry

2017-10-02 Thread Tamas K Lengyel
On Mon, Oct 2, 2017 at 6:59 AM, Julien Grall  wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Kevin Tian 
> Acked-by: Razvan Cojocaru 
> Reviewed-by: Wei Liu 

Acked-by: Tamas K Lengyel 

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


Re: [Xen-devel] [PATCH v3 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry

2017-10-02 Thread George Dunlap
On 10/02/2017 01:59 PM, Julien Grall wrote:
> Signed-off-by: Julien Grall 
> Acked-by: Andrew Cooper 
> Reviewed-by: Kevin Tian 
> Acked-by: Razvan Cojocaru 
> Reviewed-by: Wei Liu 

Reviewed-by: George Dunlap 

> 
> ---
> 
> Cc: Jan Beulich 
> Cc: Andrew Cooper 
> Cc: Razvan Cojocaru 
> Cc: Tamas K Lengyel 
> Cc: George Dunlap 
> Cc: Jun Nakajima 
> Cc: Kevin Tian 
> 
> Changes in v3:
> - Add Razvan's acked-by
> - Add Wei's reviewed-by
> 
> Changes in v2:
> - Add Andre's acked
> - Add Kevin's reviewed (EPT part)
> ---
>  xen/arch/x86/hvm/hvm.c|  2 +-
>  xen/arch/x86/mm/mem_access.c  | 19 +--
>  xen/arch/x86/mm/mem_sharing.c |  4 +--
>  xen/arch/x86/mm/p2m-ept.c |  6 ++--
>  xen/arch/x86/mm/p2m-pod.c | 15 +
>  xen/arch/x86/mm/p2m-pt.c  |  6 ++--
>  xen/arch/x86/mm/p2m.c | 77 
> +++
>  xen/include/asm-x86/p2m.h |  4 +--
>  8 files changed, 73 insertions(+), 60 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 887f0e556c..6b8c4cbdda 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -1787,7 +1787,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned 
> long gla,
>  {
>  bool_t sve;
>  
> -p2m->get_entry(p2m, gfn, , , 0, NULL, );
> +p2m->get_entry(p2m, _gfn(gfn), , , 0, NULL, );
>  
>  if ( !sve && altp2m_vcpu_emulate_ve(curr) )
>  {
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index 33a77c9f1d..c0cd0174cf 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -66,7 +66,7 @@ static int _p2m_get_mem_access(struct p2m_domain *p2m, 
> gfn_t gfn,
>  }
>  
>  gfn_lock(p2m, gfn, 0);
> -mfn = p2m->get_entry(p2m, gfn_x(gfn), , , 0, NULL, NULL);
> +mfn = p2m->get_entry(p2m, gfn, , , 0, NULL, NULL);
>  gfn_unlock(p2m, gfn, 0);
>  
>  if ( mfn_eq(mfn, INVALID_MFN) )
> @@ -142,7 +142,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
>vm_event_request_t **req_ptr)
>  {
>  struct vcpu *v = current;
> -unsigned long gfn = gpa >> PAGE_SHIFT;
> +gfn_t gfn = gaddr_to_gfn(gpa);
>  struct domain *d = v->domain;
>  struct p2m_domain *p2m = NULL;
>  mfn_t mfn;
> @@ -215,7 +215,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
>  *req_ptr = req;
>  
>  req->reason = VM_EVENT_REASON_MEM_ACCESS;
> -req->u.mem_access.gfn = gfn;
> +req->u.mem_access.gfn = gfn_x(gfn);
>  req->u.mem_access.offset = gpa & ((1 << PAGE_SHIFT) - 1);
>  if ( npfec.gla_valid )
>  {
> @@ -247,7 +247,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct 
> p2m_domain *hp2m,
>  unsigned long gfn_l = gfn_x(gfn);
>  int rc;
>  
> -mfn = ap2m->get_entry(ap2m, gfn_l, , _a, 0, NULL, NULL);
> +mfn = ap2m->get_entry(ap2m, gfn, , _a, 0, NULL, NULL);
>  
>  /* Check host p2m if no valid entry in alternate */
>  if ( !mfn_valid(mfn) )
> @@ -264,16 +264,16 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct 
> p2m_domain *hp2m,
>  if ( page_order != PAGE_ORDER_4K )
>  {
>  unsigned long mask = ~((1UL << page_order) - 1);
> -unsigned long gfn2_l = gfn_l & mask;
> +gfn_t gfn2 = _gfn(gfn_l & mask);
>  mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
>  
> -rc = ap2m->set_entry(ap2m, gfn2_l, mfn2, page_order, t, old_a, 
> 1);
> +rc = ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t, old_a, 1);
>  if ( rc )
>  return rc;
>  }
>  }
>  
> -return ap2m->set_entry(ap2m, gfn_l, mfn, PAGE_ORDER_4K, t, a,
> +return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a,
> current->domain != d);
>  }
>  
> @@ -295,10 +295,9 @@ static int set_mem_access(struct domain *d, struct 
> p2m_domain *p2m,
>  mfn_t mfn;
>  p2m_access_t _a;
>  p2m_type_t t;
> -unsigned long gfn_l = gfn_x(gfn);
>  
> -mfn = p2m->get_entry(p2m, gfn_l, , &_a, 0, NULL, NULL);
> -rc = p2m->set_entry(p2m, gfn_l, mfn, PAGE_ORDER_4K, t, a, -1);
> +mfn = p2m->get_entry(p2m, gfn, , &_a, 0, NULL, NULL);
> +rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
>  }
>  
>  return rc;
> diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
> index 3ab119cef2..62a3899089 100644
> --- a/xen/arch/x86/mm/mem_sharing.c
> +++ 

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

2017-10-02 Thread George Dunlap
On 10/02/2017 03:42 PM, Petre Ovidiu PIRCALABU wrote:
> On Lu, 2017-10-02 at 15:09 +0100, George Dunlap wrote:
>> On 10/02/2017 02:43 PM, George Dunlap wrote:
>>>
>>> On 09/25/2017 01:03 PM, Petre Pircalabu wrote:

 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 returned by the core emulator only if
 it fails to
 properly decode the current instruction's opcode, and not by any
 of other
 functions, such as the x86_emulate_ops or the hvm_io_ops
 callbacks.
>>> Oh, minor comment:  Should this paragraph be changed to match the
>>> comment in the patch itself?  I.e.:
>>>
>>> "This value should only be returned by the core emulator when a
>>> valid
>>> opcode is found but the execution logic for that instruction is
>>> missing.
>>> It should NOT be returned by any of the x86_emulate_ops callbacks."
> I've changed the comment from the definition multiple times and I
> forgot to update the patch comment. Indeed, the newest description
> better reflects the current usage of X86EMUL_UNIMPLEMENTED.

No worries, it happens. :-) Thanks again for all your effort with this,
and sorry for the late review.

 -George

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


[Xen-devel] [xen-unstable-smoke test] 113949: tolerable all pass - PUSHED

2017-10-02 Thread osstest service owner
flight 113949 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113949/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  3164f2f9db1e63ea64c3f9520d40cb09920d2b35
baseline version:
 xen  ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae

Last test of basis   113948  2017-10-02 11:03:42 Z0 days
Testing same since   113949  2017-10-02 13:01:50 Z0 days1 attempts


People who touched revisions under test:
  Andrew Cooper 

jobs:
 build-amd64  pass
 build-armhf  pass
 build-amd64-libvirt  pass
 test-armhf-armhf-xl  pass
 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


Pushing revision :

+ branch=xen-unstable-smoke
+ revision=3164f2f9db1e63ea64c3f9520d40cb09920d2b35
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.
 PERLLIB=.:.
+++ 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 xen-unstable-smoke 
3164f2f9db1e63ea64c3f9520d40cb09920d2b35
+ branch=xen-unstable-smoke
+ revision=3164f2f9db1e63ea64c3f9520d40cb09920d2b35
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.:.
 PERLLIB=.:.:.
+++ 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
+++ export PERLLIB=.:.:.:.
+++ PERLLIB=.:.:.:.
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=xen
+ xenbranch=xen-unstable-smoke
+ qemuubranch=qemu-upstream-unstable
+ '[' xxen = xlinux ']'
+ linuxbranch=
+ '[' xqemu-upstream-unstable = x ']'
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable-smoke
+ prevxenbranch=xen-4.9-testing
+ '[' x3164f2f9db1e63ea64c3f9520d40cb09920d2b35 = 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
++ : git://xenbits.xen.org/osstest/ovmf.git
++ : 

[Xen-devel] [linux-next test] 113947: regressions - FAIL

2017-10-02 Thread osstest service owner
flight 113947 linux-next real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113947/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-i386-pvops  6 kernel-build fail REGR. vs. 113902

Tests which did not succeed, but are not blocking:
 test-amd64-i386-libvirt-qcow2  1 build-check(1)   blocked  n/a
 test-amd64-i386-freebsd10-i386  1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemut-win10-i386  1 build-check(1)  blocked n/a
 test-amd64-i386-xl-qemuu-win10-i386  1 build-check(1)  blocked n/a
 test-amd64-i386-libvirt-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-examine   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-ws16-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-qemut-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-i386-freebsd10-amd64  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-ws16-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt-pair  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-xsm1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-ovmf-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-xl-raw1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-i386-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-pair  1 build-check(1)   blocked  n/a
 test-amd64-i386-rumprun-i386  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-stubdom-debianhvm-amd64-xsm 1 build-check(1) blocked 
n/a
 test-amd64-i386-xl-qemut-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-qemut-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stopfail like 113896
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 113902
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 113902
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stopfail like 113902
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 113902
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail  like 113902
 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 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-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-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 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-libvirt-raw 12 migrate-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-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
 test-armhf-armhf-xl-vhd  13 saverestore-support-check

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

2017-10-02 Thread Petre Ovidiu PIRCALABU
On Lu, 2017-10-02 at 15:09 +0100, George Dunlap wrote:
> On 10/02/2017 02:43 PM, George Dunlap wrote:
> > 
> > On 09/25/2017 01:03 PM, Petre Pircalabu wrote:
> > > 
> > > 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 returned by the core emulator only if
> > > it fails to
> > > properly decode the current instruction's opcode, and not by any
> > > of other
> > > functions, such as the x86_emulate_ops or the hvm_io_ops
> > > callbacks.
> > Oh, minor comment:  Should this paragraph be changed to match the
> > comment in the patch itself?  I.e.:
> > 
> > "This value should only be returned by the core emulator when a
> > valid
> > opcode is found but the execution logic for that instruction is
> > missing.
> > It should NOT be returned by any of the x86_emulate_ops callbacks."
I've changed the comment from the definition multiple times and I
forgot to update the patch comment. Indeed, the newest description
better reflects the current usage of X86EMUL_UNIMPLEMENTED.
> I'll do this on check-in if I don't hear any objections by tomorrow.
> 
>  -George
Many thanks for your support,
Petre
> 
> 
> This email was scanned by Bitdefender
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] Release-ack before the code freeze

2017-10-02 Thread Julien Grall

Hi all,

To simplify things, I will forgo the requirement of release-ack until 
the code freeze and leave the call to the committers.


Cheers,

--
Julien Grall

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


Re: [Xen-devel] [PATCH v2 0/5] Towards work-conserving RTDS

2017-10-02 Thread Andrii Anisov

Hello Meng Xu and Dario,

On 01.09.17 18:58, Meng Xu wrote:

This series of patches make RTDS scheduler work-conserving
without breaking real-time guarantees.
VCPUs with extratime flag set can get extra time
from the unreserved system resource.
System administrators can decide which VCPUs have extratime flag set.
As I understand from threads and the code, the work conserving algorithm 
is quite simplistic and will prefer a vcpu with greater utilization.


From our side we are looking for a bit different solution. I.e., in the 
same cpupool, running vcpus eager for RT characteristics under EDF 
conditions, and share the rest of resources between non-rt vcpus (i.e. 
in a credit manner).
Possible use-case could be a system with a domain hunger for resources, 
but not critical (some infotainment system) and an RT domain utilizing 
at most 20% of a single CPU core. Having a SoC with 4 cores, 
partitioning would be a significant resources wasting for described 
scenario.


How feasible is it from your point of view?

BTW, are you targeting XEN 4.10 with this patch series?

--

*Andrii Anisov*



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


Re: [Xen-devel] [PATCH v3 0/2] guard virt_spin_lock() with a static key

2017-10-02 Thread Peter Zijlstra
On Wed, Sep 06, 2017 at 07:36:23PM +0200, Juergen Gross wrote:
> With virt_spin_lock() being guarded by a static key the bare metal case
> can be optimized by patching the call away completely. In case a kernel
> running as a guest it can decide whether to use paravitualized
> spinlocks, the current fallback to the unfair test-and-set scheme, or
> to mimic the bare metal behavior.
> 
> V3:
> - remove test for hypervisor environment from virt_spin_lock(9 as
>   suggested by Waiman Long
> 
> V2:
> - use static key instead of making virt_spin_lock() a pvops function
> 
> Juergen Gross (2):
>   paravirt/locks: use new static key for controlling call of
> virt_spin_lock()
>   paravirt,xen: correct xen_nopvspin case
> 
>  arch/x86/include/asm/qspinlock.h | 11 ++-
>  arch/x86/kernel/paravirt-spinlocks.c |  6 ++
>  arch/x86/kernel/smpboot.c|  2 ++
>  arch/x86/xen/spinlock.c  |  2 ++
>  kernel/locking/qspinlock.c   |  4 
>  5 files changed, 24 insertions(+), 1 deletion(-)

Sorry for the delay, picked it up now.

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


Re: [Xen-devel] [RFC] removing proc-xen.mount due to systemd change

2017-10-02 Thread Franck Bui
On 10/02/2017 03:55 PM, Franck Bui wrote:
> 
> I think it would be better to continue the discussion here [1], as a
> solution might require some changes on systemd side.
> 

Actually I continued the discussion here:
https://github.com/systemd/systemd/pull/6662

Feel free to join !

Thanks.

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


Re: [Xen-devel] [PATCH v2 01/47] Replace all occurances of __FUNCTION__ with __func__

2017-10-02 Thread Stefan Hajnoczi
On Fri, Sep 29, 2017 at 05:14:58PM -0700, Alistair Francis wrote:
> Replace all occurs of __FUNCTION__ except for the check in checkpatch
> with the non GCC specific __func__.
> 
> One line in hcd-musb.c was manually tweaked to pass checkpatch.
> 
> Signed-off-by: Alistair Francis 
> Cc: Gerd Hoffmann 
> Cc: Andrzej Zaborowski 
> Cc: Stefano Stabellini 
> Cc: Anthony Perard 
> Cc: John Snow 
> Cc: Aurelien Jarno 
> Cc: Yongbok Kim 
> Cc: Peter Crosthwaite 
> Cc: Stefan Hajnoczi 
> Cc: Fam Zheng 
> Cc: Juan Quintela 
> Cc: "Dr. David Alan Gilbert" 
> Cc: qemu-...@nongnu.org
> Cc: qemu-bl...@nongnu.org
> Cc: xen-de...@lists.xenproject.org
> Reviewed-by: Eric Blake 
> ---
> 
>  audio/audio_int.h  |  2 +-
>  hw/arm/nseries.c   |  2 +-
>  hw/arm/omap1.c | 42 +-
>  hw/arm/omap2.c | 12 ++--
>  hw/arm/palm.c  | 14 +++---
>  hw/arm/pxa2xx.c| 46 
> +++---
>  hw/arm/pxa2xx_gpio.c   |  6 +++---
>  hw/arm/pxa2xx_pic.c|  4 ++--
>  hw/arm/tosa.c  | 10 +-
>  hw/audio/hda-codec.c   | 10 +-
>  hw/audio/intel-hda.c   | 28 ++--
>  hw/audio/wm8750.c  |  4 ++--
>  hw/block/nand.c|  4 ++--
>  hw/block/onenand.c |  8 
>  hw/bt/core.c   | 10 +-
>  hw/bt/hci-csr.c| 14 +++---
>  hw/bt/hci.c| 26 +-
>  hw/bt/hid.c|  2 +-
>  hw/bt/l2cap.c  | 22 +++---
>  hw/bt/sdp.c|  6 +++---
>  hw/display/blizzard.c  | 18 +-
>  hw/display/omap_dss.c  |  6 +++---
>  hw/display/pxa2xx_lcd.c| 14 +++---
>  hw/display/qxl-render.c|  6 +++---
>  hw/display/qxl.h   |  2 +-
>  hw/display/tc6393xb.c  |  2 +-
>  hw/display/xenfb.c |  2 +-
>  hw/dma/omap_dma.c  | 26 +-
>  hw/dma/pxa2xx_dma.c| 14 +++---
>  hw/gpio/max7310.c  |  8 
>  hw/gpio/omap_gpio.c|  2 +-
>  hw/i2c/omap_i2c.c  |  6 +++---
>  hw/ide/ahci.c  |  2 +-
>  hw/ide/microdrive.c|  4 ++--
>  hw/input/lm832x.c  |  6 +++---
>  hw/input/pxa2xx_keypad.c   |  6 +++---
>  hw/input/tsc2005.c |  8 
>  hw/input/tsc210x.c |  4 ++--
>  hw/intc/omap_intc.c|  2 +-
>  hw/isa/vt82c686.c  |  2 +-
>  hw/mips/gt64xxx_pci.c  |  2 +-
>  hw/misc/cbus.c | 12 ++--
>  hw/misc/omap_clk.c |  4 ++--
>  hw/misc/omap_gpmc.c|  6 +++---
>  hw/misc/omap_l4.c  |  4 ++--
>  hw/misc/omap_sdrc.c|  2 +-
>  hw/misc/omap_tap.c |  6 +++---
>  hw/misc/tmp105.c   |  2 +-
>  hw/pci-host/bonito.c   |  2 +-
>  hw/sd/pxa2xx_mmci.c|  6 +++---
>  hw/ssi/omap_spi.c  |  6 +++---
>  hw/timer/omap_gptimer.c|  6 +++---
>  hw/timer/twl92230.c|  6 +++---
>  hw/usb/desc.c  |  2 +-
>  hw/usb/dev-bluetooth.c |  4 ++--
>  hw/usb/hcd-musb.c  |  4 ++--
>  hw/usb/tusb6010.c  | 14 +++---
>  hw/xenpv/xen_domainbuild.c | 16 
>  hw/xenpv/xen_machine_pv.c  |  2 +-
>  include/hw/arm/omap.h  | 10 +-
>  include/hw/arm/sharpsl.h   |  2 +-
>  memory_mapping.c   |  2 +-
>  migration/block.c  |  4 ++--
>  ui/cursor.c|  6 +++---
>  ui/spice-display.c |  4 ++--
>  65 files changed, 273 insertions(+), 273 deletions(-)

Reviewed-by: Stefan Hajnoczi 

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


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

2017-10-02 Thread George Dunlap
On 10/02/2017 02:43 PM, George Dunlap wrote:
> On 09/25/2017 01:03 PM, Petre Pircalabu wrote:
>> 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 returned by the core emulator only if it fails to
>> properly decode the current instruction's opcode, and not by any of other
>> functions, such as the x86_emulate_ops or the hvm_io_ops callbacks.
> 
> Oh, minor comment:  Should this paragraph be changed to match the
> comment in the patch itself?  I.e.:
> 
> "This value should only be returned by the core emulator when a valid
> opcode is found but the execution logic for that instruction is missing.
> It should NOT be returned by any of the x86_emulate_ops callbacks."

I'll do this on check-in if I don't hear any objections by tomorrow.

 -George

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


Re: [Xen-devel] [RFC] removing proc-xen.mount due to systemd change

2017-10-02 Thread Franck Bui
On 10/02/2017 12:35 PM, Wei Liu wrote:
> On Mon, Oct 02, 2017 at 12:26:24PM +0200, Vasilis Liaskovitis wrote:
>> - any other options?
> 
> Can we just make the unit not fail? I.e. when it detects xenfs is
> already mounted, it does nothing but reports success.
> 

Unfortunately that's currently not possible as systemd fails when
*loading* the mount unit.

Therefore whatever the conditions you put in the mount unit (to avoid
systemd starting it) won't be considered at all as systemd will refuse
to load a mount unit whose target path is part of the API file systems.

An indirection could be added, that is adding a simple service that
would require the mount unit and contains the conditions that would
prevent its starting if /proc/xen is already mounted but that doesn't
look pretty...

I think it would be better to continue the discussion here [1], as a
solution might require some changes on systemd side.

Thanks.


[1] https://github.com/systemd/systemd/issues/6442

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


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

2017-10-02 Thread George Dunlap
On 09/25/2017 01:03 PM, Petre Pircalabu wrote:
> 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 returned by the core emulator only if it fails to
> properly decode the current instruction's opcode, and not by any of other
> functions, such as the x86_emulate_ops or the hvm_io_ops callbacks.

Oh, minor comment:  Should this paragraph be changed to match the
comment in the patch itself?  I.e.:

"This value should only be returned by the core emulator when a valid
opcode is found but the execution logic for that instruction is missing.
It should NOT be returned by any of the x86_emulate_ops callbacks."

 -George

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


Re: [Xen-devel] [PATCH v13 2/3] x86emul: Add return code information to error messages

2017-10-02 Thread George Dunlap
On 09/25/2017 01:03 PM, Petre Pircalabu wrote:
> - print the return code of the last failed emulator operation
> in hvm_dump_emulation_state.
> - print the return code in sh_page_fault (SHADOW_PRINTK) to make the
> distiction between X86EMUL_UNHANDLEABLE and X86EMUL_UNIMPLEMENTED.
> 
> Signed-off-by: Petre Pircalabu 
> Reviewed-by: Jan Beulich 

Reviewed-by: George Dunlap 

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


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

2017-10-02 Thread George Dunlap
On 09/25/2017 01:03 PM, Petre Pircalabu wrote:
> 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 returned by the core emulator only if it fails to
> properly decode the current instruction's opcode, and not by any of other
> functions, such as the x86_emulate_ops or the hvm_io_ops callbacks.
> 
> e.g. hvm_process_io_intercept should not return X86EMUL_UNIMPLEMENTED.
> The return value of this function depends on either the return code of
> one of the hvm_io_ops handlers (read/write) or the value returned by
> hvm_copy_guest_from_phys / hvm_copy_to_guest_phys.
> 
> Similary, none of this functions should return X86EMUL_UNIMPLEMENTED.
>  - hvm_io_intercept
>  - hvmemul_do_io
>  - hvm_send_buffered_ioreq
>  - hvm_send_ioreq
>  - hvm_broadcast_ioreq
>  - hvmemul_do_io_buffer
>  - hvmemul_validate
> 
> Also the behavior of hvm_emulate_one_insn and vmx_realmode_emulate_one
> was modified to generate an Invalid Opcode trap when X86EMUL_UNRECOGNIZED
> is returned by the emulator instead of just crash the domain.
> 
> Signed-off-by: Petre Pircalabu 

Looks good, thanks:

Reviewed-by: George Dunlap 

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


Re: [Xen-devel] [PATCH v2 23/24] xen/arm: mm: Handle permission flags when adding a new mapping

2017-10-02 Thread Julien Grall

Hi Stefano,

On 20/09/17 00:17, Stefano Stabellini wrote:

On Tue, 12 Sep 2017, Julien Grall wrote:

Currently, all the new mappings will be read-write non-executable. Allow the
caller to use other permissions.

Signed-off-by: Julien Grall 

---
 Changes in v2:
 - Switch the runtime check to a BUG_ON()


Since you are at it, could you please also turn the other runtime check
few lines below into another BUG_ON (under MODIFY)?


I would prefer to keep the runtime check in MODIFY for now. It is not 
really critical and I plan to ditch create_xen_entries fairly soon.


This series is actually a preparatory for what's coming up.

Cheers,

--
Julien Grall

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


Re: [Xen-devel] [PATCH] libxl: fix generating array of enums in getypes.py

2017-10-02 Thread Oleksandr Grytsov
On Mon, Oct 2, 2017 at 3:02 PM, Wei Liu  wrote:
> On Fri, Sep 29, 2017 at 04:49:23PM +0300, Oleksandr Grytsov wrote:
>> From: Oleksandr Grytsov 
>>
>> Enum always uses "x" value as input argument. In
>> case of enum array "t" argument should be passed.
>>
>> Signed-off-by: Oleksandr Grytsov 
>
> Checking parent doesn't seem to be necessary. We already have "w" which
> is passed by the higher level.
>
> Can you try the following patch?
>
> From c451e88dc64febbbea835563eb3347cbc24874ce Mon Sep 17 00:00:00 2001
> From: Wei Liu 
> Date: Mon, 2 Oct 2017 12:48:28 +0100
> Subject: [PATCH] libxl/gentypes: fix generating array of enums
>
> There is no reason to hardcode "x" in code. Use "w" which is passed
> by the higher level.
>
> This change requires us to allow "x" to be unused so that the
> top-level enum parse_json functions continue to compile.
>
> Signed-off-by: Wei Liu 
> ---
>  tools/libxl/gentypes.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
> index 76aca76aaa..88e5c5f30e 100644
> --- a/tools/libxl/gentypes.py
> +++ b/tools/libxl/gentypes.py
> @@ -432,7 +432,7 @@ def libxl_C_type_parse_json(ty, w, v, indent = "", 
> parent = None, discrimina
>  s = ""
>  if parent is None:
>  s += "int rc = 0;\n"
> -s += "const libxl__json_object *x = o;\n"
> +s += "const libxl__json_object *x __attribute__((__unused__)) = o;\n"
>
>  if isinstance(ty, idl.Array):
>  if parent is None:
> @@ -467,11 +467,11 @@ def libxl_C_type_parse_json(ty, w, v, indent = "", 
> parent = None, discrimina
>  raise Exception("Only KeyedUnion can have discriminator")
>  s += "{\n"
>  s += "const char *enum_str;\n"
> -s += "if (!libxl__json_object_is_string(x)) {\n"
> +s += "if (!libxl__json_object_is_string(%s)) {\n" % w
>  s += "rc = -1;\n"
>  s += "goto out;\n"
>  s += "}\n"
> -s += "enum_str = libxl__json_object_get_string(x);\n"
> +s += "enum_str = libxl__json_object_get_string(%s);\n" % w
>  s += "rc = %s_from_string(enum_str, %s);\n" % (ty.typename, 
> ty.pass_arg(v, parent is None, idl.PASS_BY_REFERENCE))
>  s += "if (rc)\n"
>  s += "goto out;\n"
> --
> 2.11.0
>

Checked this patch. It works.

-- 
Best Regards,
Oleksandr Grytsov.

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


[Xen-devel] [PATCH v3 00/15] xen/x86: Clean-up the PoD code

2017-10-02 Thread Julien Grall
Hi all,

I have been attempting to use the PoD code on Arm (it will be sent in a
separate series) and spent sometimes to clean-up and switch to typesafe gfn
the current code.

The PoD code has been tested on Arm (the version is slightly different,
mostly renaming) and the x86 part has only been built test it.

Cheers,

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Jun Nakajima 
Cc: Kevin Tian 
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 

Julien Grall (15):
  xen/x86: p2m-pod: Clean-up includes
  xen/x86: p2m-pod: Remove trailing whitespaces
  xen/x86: p2m-pod: Fix coding style for comments
  xen/x86: p2m-pod: Fix coding style
  xen/x86: p2m-pod: Avoid redundant assignments in
p2m_pod_demand_populate
  xen/x86: p2m-pod: Clean-up use of typesafe MFN
  xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_decrease_reservation
  xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and
set_entry
  xen/x86: p2m: Use typesafe GFN in p2m_set_entry
  xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record
  xen/x86: p2m-pod: Clean-up p2m_pod_zero_check
  xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check
  xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate
  xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and
max_guest
  xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate

 xen/arch/arm/p2m.c   |   3 +-
 xen/arch/x86/hvm/hvm.c   |   2 +-
 xen/arch/x86/mm/hap/nested_hap.c |   2 +-
 xen/arch/x86/mm/mem_access.c |  19 +-
 xen/arch/x86/mm/mem_sharing.c|   7 +-
 xen/arch/x86/mm/p2m-ept.c|  11 +-
 xen/arch/x86/mm/p2m-pod.c| 435 +--
 xen/arch/x86/mm/p2m-pt.c |  12 +-
 xen/arch/x86/mm/p2m.c| 139 +++--
 xen/common/memory.c  |   3 +-
 xen/include/asm-arm/p2m.h|  13 --
 xen/include/asm-x86/p2m.h|  23 +--
 xen/include/xen/p2m-common.h |  13 ++
 13 files changed, 370 insertions(+), 312 deletions(-)

-- 
2.11.0


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


[Xen-devel] [PATCH v3 09/15] xen/x86: p2m: Use typesafe GFN in p2m_set_entry

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Acked-by: Tamas K Lengyel 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Cc: Tamas K Lengyel 

Changes in v3:
- Add Wei's reviewed-by

Changes in v2:
- Add Andrew & Tamas' acked-by
- Rename the variable gfn_t to gfn_ to avoid shadowing the type
gfn_t
---
 xen/arch/x86/mm/hap/nested_hap.c |   2 +-
 xen/arch/x86/mm/mem_sharing.c|   3 +-
 xen/arch/x86/mm/p2m-pod.c|  36 +++--
 xen/arch/x86/mm/p2m.c| 112 ++-
 xen/include/asm-x86/p2m.h|   2 +-
 5 files changed, 85 insertions(+), 70 deletions(-)

diff --git a/xen/arch/x86/mm/hap/nested_hap.c b/xen/arch/x86/mm/hap/nested_hap.c
index 162afed46b..346fcb53e5 100644
--- a/xen/arch/x86/mm/hap/nested_hap.c
+++ b/xen/arch/x86/mm/hap/nested_hap.c
@@ -121,7 +121,7 @@ nestedhap_fix_p2m(struct vcpu *v, struct p2m_domain *p2m,
 gfn = (L2_gpa >> PAGE_SHIFT) & mask;
 mfn = _mfn((L0_gpa >> PAGE_SHIFT) & mask);
 
-rc = p2m_set_entry(p2m, gfn, mfn, page_order, p2mt, p2ma);
+rc = p2m_set_entry(p2m, _gfn(gfn), mfn, page_order, p2mt, p2ma);
 }
 
 p2m_unlock(p2m);
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 62a3899089..b856028c02 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1052,7 +1052,8 @@ int mem_sharing_add_to_physmap(struct domain *sd, 
unsigned long sgfn, shr_handle
 goto err_unlock;
 }
 
-ret = p2m_set_entry(p2m, cgfn, smfn, PAGE_ORDER_4K, p2m_ram_shared, a);
+ret = p2m_set_entry(p2m, _gfn(cgfn), smfn, PAGE_ORDER_4K,
+p2m_ram_shared, a);
 
 /* Tempted to turn this into an assert */
 if ( ret )
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index c8c8cff014..b8a51cf12a 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -565,7 +565,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, 
unsigned int order)
  * All PoD: Mark the whole region invalid and tell caller
  * we're done.
  */
-p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, order, p2m_invalid,
+p2m_set_entry(p2m, gfn, INVALID_MFN, order, p2m_invalid,
   p2m->default_access);
 p2m->pod.entry_count -= 1UL << order;
 BUG_ON(p2m->pod.entry_count < 0);
@@ -609,7 +609,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, 
unsigned int order)
 n = 1UL << cur_order;
 if ( t == p2m_populate_on_demand )
 {
-p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
+p2m_set_entry(p2m, gfn_add(gfn, i), INVALID_MFN, cur_order,
   p2m_invalid, p2m->default_access);
 p2m->pod.entry_count -= n;
 BUG_ON(p2m->pod.entry_count < 0);
@@ -631,7 +631,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, 
unsigned int order)
 
 page = mfn_to_page(mfn);
 
-p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
+p2m_set_entry(p2m, gfn_add(gfn, i), INVALID_MFN, cur_order,
   p2m_invalid, p2m->default_access);
 p2m_tlb_flush_sync(p2m);
 for ( j = 0; j < n; ++j )
@@ -680,9 +680,10 @@ void p2m_pod_dump_data(struct domain *d)
  * in the p2m.
  */
 static int
-p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn)
+p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l)
 {
 mfn_t mfn, mfn0 = INVALID_MFN;
+gfn_t gfn = _gfn(gfn_l);
 p2m_type_t type, type0 = 0;
 unsigned long * map = NULL;
 int ret=0, reset = 0;
@@ -693,7 +694,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 
 ASSERT(pod_locked_by_me(p2m));
 
-if ( !superpage_aligned(gfn) )
+if ( !superpage_aligned(gfn_l) )
 goto out;
 
 /* Allow an extra refcount for one shadow pt mapping in shadowed domains */
@@ -717,7 +718,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 unsigned long k;
 const struct page_info *page;
 
-mfn = p2m->get_entry(p2m, _gfn(gfn +  i), , , 0,
+mfn = p2m->get_entry(p2m, gfn_add(gfn, i), , , 0,
  _order, NULL);
 
 /*
@@ -815,7 +816,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 int d:16,order:16;
 } t;
 
-t.gfn = gfn;
+t.gfn = gfn_l;
 t.mfn = mfn_x(mfn);
 t.d = d->domain_id;
 t.order = 9;
@@ -898,7 +899,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 }
 
 /* Try 

[Xen-devel] [PATCH v3 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Replace (foo == 0) by !foo
- Remove uneeded parentheses

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 176d06cb42..6581f8d82f 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -861,17 +861,19 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 for ( i = 0; i < count; i++ )
 {
 p2m_access_t a;
+struct page_info *pg;
 
 mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, ,
  0, NULL, NULL);
+pg = mfn_to_page(mfns[i]);
+
 /*
  * If this is ram, and not a pagetable or from the xen heap, and
  * probably not mapped elsewhere, map it; otherwise, skip.
  */
-if ( p2m_is_ram(types[i])
- && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 )
- && ( (mfn_to_page(mfns[i])->count_info & 
(PGC_page_table|PGC_xen_heap)) == 0 )
- && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= 
max_ref ) )
+if ( p2m_is_ram(types[i]) && (pg->count_info & PGC_allocated) &&
+ !(pg->count_info & (PGC_page_table | PGC_xen_heap)) &&
+ ((pg->count_info & PGC_count_mask) <= max_ref) )
 map[i] = map_domain_page(mfns[i]);
 else
 map[i] = NULL;
-- 
2.11.0


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


[Xen-devel] [PATCH v3 06/15] xen/x86: p2m-pod: Clean-up use of typesafe MFN

2017-10-02 Thread Julien Grall
Some unboxing/boxing can be avoided by using mfn_add(...) instead.

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: George Dunlap 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add George's and Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index bcc87aee03..34f5239b6d 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -101,7 +101,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
  * promise to provide zero pages. So we scrub pages before using.
  */
 for ( i = 0; i < (1UL << order); i++ )
-clear_domain_page(_mfn(mfn_x(page_to_mfn(page)) + i));
+clear_domain_page(mfn_add(page_to_mfn(page), i));
 
 /* First, take all pages off the domain list */
 lock_page_alloc(p2m);
@@ -743,7 +743,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 mfn0 = mfn;
 type0 = type;
 }
-else if ( type != type0 || mfn_x(mfn) != (mfn_x(mfn0) + i) )
+else if ( type != type0 || !mfn_eq(mfn, mfn_add(mfn0, i)) )
 goto out;
 
 n = 1UL << min(cur_order, SUPERPAGE_ORDER + 0U);
@@ -758,7 +758,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 for ( i = 0; i < SUPERPAGE_PAGES; i++ )
 {
 /* Quick zero-check */
-map = map_domain_page(_mfn(mfn_x(mfn0) + i));
+map = map_domain_page(mfn_add(mfn0, i));
 
 for ( j = 0; j < 16; j++ )
 if ( *(map + j) != 0 )
@@ -783,7 +783,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
  */
 for ( i = 0; i < SUPERPAGE_PAGES; i++ )
 {
-mfn = _mfn(mfn_x(mfn0) + i);
+mfn = mfn_add(mfn0, i);
 if ( (mfn_to_page(mfn)->count_info & PGC_count_mask) > 1 )
 {
 reset = 1;
@@ -794,7 +794,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 /* Finally, do a full zero-check */
 for ( i = 0; i < SUPERPAGE_PAGES; i++ )
 {
-map = map_domain_page(_mfn(mfn_x(mfn0) + i));
+map = map_domain_page(mfn_add(mfn0, i));
 
 for ( j = 0; j < (PAGE_SIZE / sizeof(*map)); j++ )
 if ( *(map+j) != 0 )
-- 
2.11.0


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


[Xen-devel] [PATCH v3 04/15] xen/x86: p2m-pod: Fix coding style

2017-10-02 Thread Julien Grall
Also take the opportunity to:
- move from 1 << * to 1UL << *.
- use unsigned when possible
- move from unsigned int -> unsigned long for some induction
variables

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: George Dunlap 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Move some 1 << * to 1UL << * changes from previous to this
patch
- Add George's and Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 106 +++---
 1 file changed, 54 insertions(+), 52 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 6beb26b00a..f04d6e03e2 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -60,7 +60,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
   struct page_info *page,
   unsigned int order)
 {
-int i;
+unsigned long i;
 struct page_info *p;
 struct domain *d = p2m->domain;
 
@@ -70,23 +70,24 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
 mfn = page_to_mfn(page);
 
 /* Check to make sure this is a contiguous region */
-if( mfn_x(mfn) & ((1 << order) - 1) )
+if ( mfn_x(mfn) & ((1UL << order) - 1) )
 {
 printk("%s: mfn %lx not aligned order %u! (mask %lx)\n",
__func__, mfn_x(mfn), order, ((1UL << order) - 1));
 return -1;
 }
 
-for(i=0; i < 1 << order ; i++) {
+for ( i = 0; i < 1UL << order ; i++)
+{
 struct domain * od;
 
 p = mfn_to_page(_mfn(mfn_x(mfn) + i));
 od = page_get_owner(p);
-if(od != d)
+if ( od != d )
 {
 printk("%s: mfn %lx expected owner d%d, got owner d%d!\n",
__func__, mfn_x(mfn), d->domain_id,
-   od?od->domain_id:-1);
+   od ? od->domain_id : -1);
 return -1;
 }
 }
@@ -99,12 +100,12 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
  * guaranteed to be zero; but by reclaiming zero pages, we implicitly
  * promise to provide zero pages. So we scrub pages before using.
  */
-for ( i = 0; i < (1 << order); i++ )
+for ( i = 0; i < (1UL << order); i++ )
 clear_domain_page(_mfn(mfn_x(page_to_mfn(page)) + i));
 
 /* First, take all pages off the domain list */
 lock_page_alloc(p2m);
-for(i=0; i < 1 << order ; i++)
+for ( i = 0; i < 1UL << order ; i++ )
 {
 p = page + i;
 page_list_del(p, >page_list);
@@ -128,7 +129,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
 default:
 BUG();
 }
-p2m->pod.count += 1L << order;
+p2m->pod.count += 1UL << order;
 
 return 0;
 }
@@ -140,7 +141,7 @@ static struct page_info * p2m_pod_cache_get(struct 
p2m_domain *p2m,
 unsigned int order)
 {
 struct page_info *p = NULL;
-int i;
+unsigned long i;
 
 ASSERT(pod_locked_by_me(p2m));
 
@@ -162,7 +163,7 @@ static struct page_info * p2m_pod_cache_get(struct 
p2m_domain *p2m,
 p = page_list_remove_head(>pod.super);
 mfn = mfn_x(page_to_mfn(p));
 
-for ( i=0; ipod.single);
@@ -174,12 +175,12 @@ static struct page_info * p2m_pod_cache_get(struct 
p2m_domain *p2m,
 case PAGE_ORDER_2M:
 BUG_ON( page_list_empty(>pod.super) );
 p = page_list_remove_head(>pod.super);
-p2m->pod.count -= 1 << order;
+p2m->pod.count -= 1UL << order;
 break;
 case PAGE_ORDER_4K:
 BUG_ON( page_list_empty(>pod.single) );
 p = page_list_remove_head(>pod.single);
-p2m->pod.count -= 1;
+p2m->pod.count -= 1UL;
 break;
 default:
 BUG();
@@ -187,7 +188,7 @@ static struct page_info * p2m_pod_cache_get(struct 
p2m_domain *p2m,
 
 /* Put the pages back on the domain page_list */
 lock_page_alloc(p2m);
-for ( i = 0 ; i < (1 << order); i++ )
+for ( i = 0 ; i < (1UL << order); i++ )
 {
 BUG_ON(page_get_owner(p + i) != p2m->domain);
 page_list_add_tail(p + i, >domain->page_list);
@@ -251,7 +252,8 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned 
long pod_target, int p
 while ( pod_target < p2m->pod.count )
 {
 struct page_info * page;
-int order, i;
+unsigned int order;
+unsigned long i;
 
 if ( (p2m->pod.count - pod_target) > SUPERPAGE_PAGES
  && !page_list_empty(>pod.super) )
@@ -264,10 +266,10 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned 
long 

[Xen-devel] [PATCH v3 02/15] xen/x86: p2m-pod: Remove trailing whitespaces

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: George Dunlap 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add George's and Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 46 +++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index fec87e5224..1f07441259 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -1,7 +1,7 @@
 /**
  * arch/x86/mm/p2m-pod.c
  *
- * Populate-on-demand p2m entries. 
+ * Populate-on-demand p2m entries.
  *
  * Copyright (c) 2009-2011 Citrix Systems, Inc.
  *
@@ -76,7 +76,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
__func__, mfn_x(mfn), order, ((1UL << order) - 1));
 return -1;
 }
-
+
 for(i=0; i < 1 << order ; i++) {
 struct domain * od;
 
@@ -223,8 +223,8 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned 
long pod_target, int p
 /* If we can't allocate a superpage, try singleton pages */
 order = PAGE_ORDER_4K;
 goto retry;
-}   
-
+}
+
 printk("%s: Unable to allocate page for PoD cache (target=%lu 
cache=%ld)\n",
__func__, pod_target, p2m->pod.count);
 ret = -ENOMEM;
@@ -272,7 +272,7 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned 
long pod_target, int p
 
 if ( test_and_clear_bit(_PGT_pinned, &(page+i)->u.inuse.type_info) 
)
 put_page_and_type(page+i);
-
+
 if ( test_and_clear_bit(_PGC_allocated, &(page+i)->count_info) )
 put_page(page+i);
 
@@ -296,7 +296,7 @@ out:
  * definitions:
  * + M: static_max
  * + B: number of pages the balloon driver has ballooned down to.
- * + P: Number of populated pages. 
+ * + P: Number of populated pages.
  * + T: Old target
  * + T': New target
  *
@@ -311,10 +311,10 @@ out:
  *   the remainder of the ram to the guest OS.
  *  T count_info & PGC_allocated) != 0 ) 
- && ( (mfn_to_page(mfns[i])->count_info & 
(PGC_page_table|PGC_xen_heap)) == 0 ) 
+ && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 )
+ && ( (mfn_to_page(mfns[i])->count_info & 
(PGC_page_table|PGC_xen_heap)) == 0 )
  && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= 
max_ref ) )
 map[i] = map_domain_page(mfns[i]);
 else
@@ -915,7 +915,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 t.mfn = mfn_x(mfns[i]);
 t.d = d->domain_id;
 t.order = 0;
-
+
 __trace_var(TRC_MEM_POD_ZERO_RECLAIM, 0, sizeof(t), );
 }
 
@@ -924,7 +924,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 p2m->pod.entry_count++;
 }
 }
-
+
 }
 
 #define POD_SWEEP_LIMIT 1024
@@ -1046,12 +1046,12 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, 
unsigned long gfn,
 pod_lock(p2m);
 
 /* This check is done with the pod lock held.  This will make sure that
- * even if d->is_dying changes under our feet, p2m_pod_empty_cache() 
+ * even if d->is_dying changes under our feet, p2m_pod_empty_cache()
  * won't start until we're done. */
 if ( unlikely(d->is_dying) )
 goto out_fail;
 
-
+
 /* Because PoD does not have cache list for 1GB pages, it has to remap
  * 1GB region to 2MB chunks for a retry. */
 if ( order == PAGE_ORDER_1G )
@@ -1107,7 +1107,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_aligned + i);
 paging_mark_dirty(d, mfn_add(mfn, i));
 }
-
+
 p2m->pod.entry_count -= (1 << order);
 BUG_ON(p2m->pod.entry_count < 0);
 
@@ -1124,7 +1124,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 t.mfn = mfn_x(mfn);
 t.d = d->domain_id;
 t.order = order;
-
+
 __trace_var(TRC_MEM_POD_POPULATE, 0, sizeof(t), );
 }
 
@@ -1161,7 +1161,7 @@ remap_and_retry:
 
 t.gfn = gfn;

[Xen-devel] [PATCH v3 14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 11 +--
 xen/include/asm-x86/p2m.h |  4 ++--
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 55f2fa4f18..8d50a0db85 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -977,10 +977,10 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m)
 p2m_type_t t;
 
 
-if ( p2m->pod.reclaim_single == 0 )
+if ( gfn_eq(p2m->pod.reclaim_single, _gfn(0)) )
 p2m->pod.reclaim_single = p2m->pod.max_guest;
 
-start = p2m->pod.reclaim_single;
+start = gfn_x(p2m->pod.reclaim_single);
 limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0;
 
 /* FIXME: Figure out how to avoid superpages */
@@ -990,7 +990,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m)
  * careful about spinlock recursion limits and POD_SWEEP_STRIDE.
  */
 p2m_lock(p2m);
-for ( i = p2m->pod.reclaim_single; i > 0 ; i-- )
+for ( i = gfn_x(p2m->pod.reclaim_single); i > 0 ; i-- )
 {
 p2m_access_t a;
 (void)p2m->get_entry(p2m, _gfn(i), , , 0, NULL, NULL);
@@ -1020,7 +1020,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m)
 p2m_pod_zero_check(p2m, gfns, j);
 
 p2m_unlock(p2m);
-p2m->pod.reclaim_single = i ? i - 1 : i;
+p2m->pod.reclaim_single = _gfn(i ? i - 1 : i);
 
 }
 
@@ -1135,8 +1135,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
 goto out_of_memory;
 
 /* Keep track of the highest gfn demand-populated by a guest fault */
-if ( gfn_x(gfn) > p2m->pod.max_guest )
-p2m->pod.max_guest = gfn_x(gfn);
+p2m->pod.max_guest = gfn_max(gfn, p2m->pod.max_guest);
 
 /*
  * Get a page f/ the cache.  A NULL return value indicates that the
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 1ae9216404..e8a9dca480 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -316,8 +316,8 @@ struct p2m_domain {
  single;   /* Non-super lists   */
 long count,/* # of pages in cache lists */
  entry_count;  /* # of pages in p2m marked pod  */
-unsigned longreclaim_single; /* Last gpfn of a scan */
-unsigned longmax_guest;/* gpfn of max guest demand-populate */
+gfn_treclaim_single; /* Last gfn of a scan */
+gfn_tmax_guest;/* gfn of max guest demand-populate */
 
 /*
  * Tracking of the most recently populated PoD pages, for eager
-- 
2.11.0


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


[Xen-devel] [PATCH v3 15/15] xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate

2017-10-02 Thread Julien Grall
- Switch the return type to bool
- Remove the parameter p2m_query_t q as it is not used

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-ept.c |  4 ++--
 xen/arch/x86/mm/p2m-pod.c | 15 +++
 xen/arch/x86/mm/p2m-pt.c  |  6 +++---
 xen/include/asm-x86/p2m.h |  6 ++
 4 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index bc25582c5a..054827aa88 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -965,7 +965,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m,
 index = gfn_remainder >> ( i * EPT_TABLE_ORDER);
 ept_entry = table + index;
 
-if ( !p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER, q) )
+if ( p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER) )
 goto retry;
 else
 goto out;
@@ -987,7 +987,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m,
 
 ASSERT(i == 0);
 
-if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) )
+if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K) )
 goto out;
 }
 
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 8d50a0db85..0a811ccf28 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -1075,10 +1075,9 @@ static void pod_eager_record(struct p2m_domain *p2m, 
gfn_t gfn,
 mrp->idx %= ARRAY_SIZE(mrp->list);
 }
 
-int
+bool
 p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
-unsigned int order,
-p2m_query_t q)
+unsigned int order)
 {
 struct domain *d = p2m->domain;
 struct page_info *p = NULL; /* Compiler warnings */
@@ -1116,7 +1115,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
  */
 p2m_set_entry(p2m, gfn_aligned, INVALID_MFN, PAGE_ORDER_2M,
   p2m_populate_on_demand, p2m->default_access);
-return 0;
+return true;
 }
 
 /* Only reclaim if we're in actual need of more cache. */
@@ -1178,7 +1177,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
 }
 
 pod_unlock(p2m);
-return 0;
+return true;
 out_of_memory:
 pod_unlock(p2m);
 
@@ -1186,10 +1185,10 @@ out_of_memory:
__func__, d->domain_id, d->tot_pages, p2m->pod.entry_count,
current->domain->domain_id);
 domain_crash(d);
-return -1;
+return false;
 out_fail:
 pod_unlock(p2m);
-return -1;
+return false;
 remap_and_retry:
 BUG_ON(order != PAGE_ORDER_2M);
 pod_unlock(p2m);
@@ -1215,7 +1214,7 @@ remap_and_retry:
 __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), );
 }
 
-return 0;
+return true;
 }
 
 
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index a639a00e9c..50637083f4 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -802,7 +802,7 @@ pod_retry_l3:
 {
 if ( q & P2M_ALLOC )
 {
-if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G, q) 
)
+if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G) )
 goto pod_retry_l3;
 gdprintk(XENLOG_ERR, "%s: Allocate 1GB failed!\n", 
__func__);
 }
@@ -844,7 +844,7 @@ pod_retry_l2:
 if ( p2m_flags_to_type(flags) == p2m_populate_on_demand )
 {
 if ( q & P2M_ALLOC ) {
-if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M, q) )
+if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M) )
 goto pod_retry_l2;
 } else
 *t = p2m_populate_on_demand;
@@ -883,7 +883,7 @@ pod_retry_l1:
 if ( l1t == p2m_populate_on_demand )
 {
 if ( q & P2M_ALLOC ) {
-if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) )
+if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K) )
 goto pod_retry_l1;
 } else
 *t = p2m_populate_on_demand;
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index e8a9dca480..70f00c332f 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -719,10 +719,8 @@ extern void audit_p2m(struct domain *d,
 #endif
 
 /* Called by p2m code when demand-populating a PoD page */
-int
-p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
-unsigned int order,
-

[Xen-devel] [PATCH v3 01/15] xen/x86: p2m-pod: Clean-up includes

2017-10-02 Thread Julien Grall
A lot of the headers are not necessary. At the same time, order them in the
alphabetical order.

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 
Acked-by: George Dunlap 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Wei's reviewed-by
- Add George's acked-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 4085b7f752..fec87e5224 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -19,18 +19,13 @@
  * along with this program; If not, see .
  */
 
-#include 
-#include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
-#include  /* ept_p2m_init() */
-#include 
-#include 
-#include 
 
 #include "mm-locks.h"
 
-- 
2.11.0


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


[Xen-devel] [PATCH v3 10/15] xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index b8a51cf12a..176d06cb42 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -1062,15 +1062,15 @@ static void pod_eager_reclaim(struct p2m_domain *p2m)
 } while ( (p2m->pod.count == 0) && (i < ARRAY_SIZE(mrp->list)) );
 }
 
-static void pod_eager_record(struct p2m_domain *p2m,
- unsigned long gfn, unsigned int order)
+static void pod_eager_record(struct p2m_domain *p2m, gfn_t gfn,
+ unsigned int order)
 {
 struct pod_mrp_list *mrp = >pod.mrp;
 
-ASSERT(gfn != gfn_x(INVALID_GFN));
+ASSERT(!gfn_eq(gfn, INVALID_GFN));
 
 mrp->list[mrp->idx++] =
-gfn | (order == PAGE_ORDER_2M ? POD_LAST_SUPERPAGE : 0);
+gfn_x(gfn) | (order == PAGE_ORDER_2M ? POD_LAST_SUPERPAGE : 0);
 mrp->idx %= ARRAY_SIZE(mrp->list);
 }
 
@@ -1160,7 +1160,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 p2m->pod.entry_count -= (1UL << order);
 BUG_ON(p2m->pod.entry_count < 0);
 
-pod_eager_record(p2m, gfn_x(gfn_aligned), order);
+pod_eager_record(p2m, gfn_aligned, order);
 
 if ( tb_init_done )
 {
-- 
2.11.0


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


[Xen-devel] [PATCH v3 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Kevin Tian 
Acked-by: Razvan Cojocaru 
Reviewed-by: Wei Liu 

---

Cc: Jan Beulich 
Cc: Andrew Cooper 
Cc: Razvan Cojocaru 
Cc: Tamas K Lengyel 
Cc: George Dunlap 
Cc: Jun Nakajima 
Cc: Kevin Tian 

Changes in v3:
- Add Razvan's acked-by
- Add Wei's reviewed-by

Changes in v2:
- Add Andre's acked
- Add Kevin's reviewed (EPT part)
---
 xen/arch/x86/hvm/hvm.c|  2 +-
 xen/arch/x86/mm/mem_access.c  | 19 +--
 xen/arch/x86/mm/mem_sharing.c |  4 +--
 xen/arch/x86/mm/p2m-ept.c |  6 ++--
 xen/arch/x86/mm/p2m-pod.c | 15 +
 xen/arch/x86/mm/p2m-pt.c  |  6 ++--
 xen/arch/x86/mm/p2m.c | 77 +++
 xen/include/asm-x86/p2m.h |  4 +--
 8 files changed, 73 insertions(+), 60 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 887f0e556c..6b8c4cbdda 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1787,7 +1787,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long 
gla,
 {
 bool_t sve;
 
-p2m->get_entry(p2m, gfn, , , 0, NULL, );
+p2m->get_entry(p2m, _gfn(gfn), , , 0, NULL, );
 
 if ( !sve && altp2m_vcpu_emulate_ve(curr) )
 {
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index 33a77c9f1d..c0cd0174cf 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -66,7 +66,7 @@ static int _p2m_get_mem_access(struct p2m_domain *p2m, gfn_t 
gfn,
 }
 
 gfn_lock(p2m, gfn, 0);
-mfn = p2m->get_entry(p2m, gfn_x(gfn), , , 0, NULL, NULL);
+mfn = p2m->get_entry(p2m, gfn, , , 0, NULL, NULL);
 gfn_unlock(p2m, gfn, 0);
 
 if ( mfn_eq(mfn, INVALID_MFN) )
@@ -142,7 +142,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
   vm_event_request_t **req_ptr)
 {
 struct vcpu *v = current;
-unsigned long gfn = gpa >> PAGE_SHIFT;
+gfn_t gfn = gaddr_to_gfn(gpa);
 struct domain *d = v->domain;
 struct p2m_domain *p2m = NULL;
 mfn_t mfn;
@@ -215,7 +215,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla,
 *req_ptr = req;
 
 req->reason = VM_EVENT_REASON_MEM_ACCESS;
-req->u.mem_access.gfn = gfn;
+req->u.mem_access.gfn = gfn_x(gfn);
 req->u.mem_access.offset = gpa & ((1 << PAGE_SHIFT) - 1);
 if ( npfec.gla_valid )
 {
@@ -247,7 +247,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct 
p2m_domain *hp2m,
 unsigned long gfn_l = gfn_x(gfn);
 int rc;
 
-mfn = ap2m->get_entry(ap2m, gfn_l, , _a, 0, NULL, NULL);
+mfn = ap2m->get_entry(ap2m, gfn, , _a, 0, NULL, NULL);
 
 /* Check host p2m if no valid entry in alternate */
 if ( !mfn_valid(mfn) )
@@ -264,16 +264,16 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct 
p2m_domain *hp2m,
 if ( page_order != PAGE_ORDER_4K )
 {
 unsigned long mask = ~((1UL << page_order) - 1);
-unsigned long gfn2_l = gfn_l & mask;
+gfn_t gfn2 = _gfn(gfn_l & mask);
 mfn_t mfn2 = _mfn(mfn_x(mfn) & mask);
 
-rc = ap2m->set_entry(ap2m, gfn2_l, mfn2, page_order, t, old_a, 1);
+rc = ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t, old_a, 1);
 if ( rc )
 return rc;
 }
 }
 
-return ap2m->set_entry(ap2m, gfn_l, mfn, PAGE_ORDER_4K, t, a,
+return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a,
current->domain != d);
 }
 
@@ -295,10 +295,9 @@ static int set_mem_access(struct domain *d, struct 
p2m_domain *p2m,
 mfn_t mfn;
 p2m_access_t _a;
 p2m_type_t t;
-unsigned long gfn_l = gfn_x(gfn);
 
-mfn = p2m->get_entry(p2m, gfn_l, , &_a, 0, NULL, NULL);
-rc = p2m->set_entry(p2m, gfn_l, mfn, PAGE_ORDER_4K, t, a, -1);
+mfn = p2m->get_entry(p2m, gfn, , &_a, 0, NULL, NULL);
+rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
 }
 
 return rc;
diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 3ab119cef2..62a3899089 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1234,7 +1234,7 @@ int relinquish_shared_pages(struct domain *d)
 
 if ( atomic_read(>shr_pages) == 0 )
 break;
-mfn = p2m->get_entry(p2m, gfn, , , 0, NULL, NULL);
+mfn = p2m->get_entry(p2m, _gfn(gfn), , , 0, NULL, NULL);
 if ( mfn_valid(mfn) && (t == p2m_ram_shared) )
 {
 /* Does not fail 

[Xen-devel] [PATCH v3 12/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check

2017-10-02 Thread Julien Grall
At the same time make the array gfns const has it is not modified within
the function.

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 37 ++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 6581f8d82f..668c484a75 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -498,7 +498,7 @@ p2m_pod_offline_or_broken_replace(struct page_info *p)
 }
 
 static int
-p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn);
+p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gfn_t gfn);
 
 
 /*
@@ -582,7 +582,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, 
unsigned int order)
  * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER)
  */
 if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) &&
- p2m_pod_zero_check_superpage(p2m, gfn_x(gfn) & ~(SUPERPAGE_PAGES - 
1)) )
+ p2m_pod_zero_check_superpage(p2m, _gfn(gfn_x(gfn) & ~(SUPERPAGE_PAGES 
- 1))) )
 {
 pod = 1UL << order;
 ram = nonpod = 0;
@@ -680,10 +680,9 @@ void p2m_pod_dump_data(struct domain *d)
  * in the p2m.
  */
 static int
-p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l)
+p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gfn_t gfn)
 {
 mfn_t mfn, mfn0 = INVALID_MFN;
-gfn_t gfn = _gfn(gfn_l);
 p2m_type_t type, type0 = 0;
 unsigned long * map = NULL;
 int ret=0, reset = 0;
@@ -694,7 +693,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn_l)
 
 ASSERT(pod_locked_by_me(p2m));
 
-if ( !superpage_aligned(gfn_l) )
+if ( !superpage_aligned(gfn_x(gfn)) )
 goto out;
 
 /* Allow an extra refcount for one shadow pt mapping in shadowed domains */
@@ -816,7 +815,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn_l)
 int d:16,order:16;
 } t;
 
-t.gfn = gfn_l;
+t.gfn = gfn_x(gfn);
 t.mfn = mfn_x(mfn);
 t.d = d->domain_id;
 t.order = 9;
@@ -843,7 +842,7 @@ out:
 }
 
 static void
-p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count)
+p2m_pod_zero_check(struct p2m_domain *p2m, const gfn_t *gfns, int count)
 {
 mfn_t mfns[count];
 p2m_type_t types[count];
@@ -863,7 +862,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 p2m_access_t a;
 struct page_info *pg;
 
-mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, ,
+mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, ,
  0, NULL, NULL);
 pg = mfn_to_page(mfns[i]);
 
@@ -901,7 +900,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 }
 
 /* Try to remove the page, restoring old mapping if it fails. */
-p2m_set_entry(p2m, _gfn(gfns[i]), INVALID_MFN, PAGE_ORDER_4K,
+p2m_set_entry(p2m, gfns[i], INVALID_MFN, PAGE_ORDER_4K,
   p2m_populate_on_demand, p2m->default_access);
 
 /*
@@ -913,7 +912,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 unmap_domain_page(map[i]);
 map[i] = NULL;
 
-p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K,
+p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K,
 types[i], p2m->default_access);
 
 continue;
@@ -940,7 +939,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
  */
 if ( j < (PAGE_SIZE / sizeof(*map[i])) )
 {
-p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K,
+p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K,
   types[i], p2m->default_access);
 }
 else
@@ -952,7 +951,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 int d:16,order:16;
 } t;
 
-t.gfn = gfns[i];
+t.gfn = gfn_x(gfns[i]);
 t.mfn = mfn_x(mfns[i]);
 t.d = d->domain_id;
 t.order = 0;
@@ -973,7 +972,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
 static void
 p2m_pod_emergency_sweep(struct p2m_domain *p2m)
 {
-unsigned long gfns[POD_SWEEP_STRIDE];
+gfn_t gfns[POD_SWEEP_STRIDE];
 unsigned long i, j = 0, start, limit;
 p2m_type_t t;
 
@@ -997,7 +996,7 @@ p2m_pod_emergency_sweep(struct p2m_domain 

[Xen-devel] [PATCH v3 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add Stefano's reviewed-by

Changes in v2:
- Add Andrew's acked-by
- Variable gfn_t was renamed to gfn_ in a previous patch. So use
the new name
---
 xen/arch/x86/mm/p2m-ept.c |  5 ++---
 xen/arch/x86/mm/p2m-pod.c | 12 ++--
 xen/arch/x86/mm/p2m-pt.c  |  6 +++---
 xen/include/asm-x86/p2m.h |  2 +-
 4 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index f14d1686b7..bc25582c5a 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -965,7 +965,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m,
 index = gfn_remainder >> ( i * EPT_TABLE_ORDER);
 ept_entry = table + index;
 
-if ( !p2m_pod_demand_populate(p2m, gfn, i * EPT_TABLE_ORDER, q) )
+if ( !p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER, q) )
 goto retry;
 else
 goto out;
@@ -987,8 +987,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m,
 
 ASSERT(i == 0);
 
-if ( p2m_pod_demand_populate(p2m, gfn, 
-PAGE_ORDER_4K, q) )
+if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) )
 goto out;
 }
 
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 668c484a75..55f2fa4f18 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -1076,13 +1076,13 @@ static void pod_eager_record(struct p2m_domain *p2m, 
gfn_t gfn,
 }
 
 int
-p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn,
+p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn,
 unsigned int order,
 p2m_query_t q)
 {
 struct domain *d = p2m->domain;
 struct page_info *p = NULL; /* Compiler warnings */
-gfn_t gfn_aligned = _gfn((gfn >> order) << order);
+gfn_t gfn_aligned = _gfn((gfn_x(gfn) >> order) << order);
 mfn_t mfn;
 unsigned long i;
 
@@ -1135,8 +1135,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 goto out_of_memory;
 
 /* Keep track of the highest gfn demand-populated by a guest fault */
-if ( gfn > p2m->pod.max_guest )
-p2m->pod.max_guest = gfn;
+if ( gfn_x(gfn) > p2m->pod.max_guest )
+p2m->pod.max_guest = gfn_x(gfn);
 
 /*
  * Get a page f/ the cache.  A NULL return value indicates that the
@@ -1170,7 +1170,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 int d:16,order:16;
 } t;
 
-t.gfn = gfn;
+t.gfn = gfn_x(gfn);
 t.mfn = mfn_x(mfn);
 t.d = d->domain_id;
 t.order = order;
@@ -1210,7 +1210,7 @@ remap_and_retry:
 int d:16;
 } t;
 
-t.gfn = gfn;
+t.gfn = gfn_x(gfn);
 t.d = d->domain_id;
 
 __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), );
diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index 4bfec4f5f0..a639a00e9c 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -802,7 +802,7 @@ pod_retry_l3:
 {
 if ( q & P2M_ALLOC )
 {
-if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_1G, q) )
+if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G, q) 
)
 goto pod_retry_l3;
 gdprintk(XENLOG_ERR, "%s: Allocate 1GB failed!\n", 
__func__);
 }
@@ -844,7 +844,7 @@ pod_retry_l2:
 if ( p2m_flags_to_type(flags) == p2m_populate_on_demand )
 {
 if ( q & P2M_ALLOC ) {
-if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_2M, q) )
+if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M, q) )
 goto pod_retry_l2;
 } else
 *t = p2m_populate_on_demand;
@@ -883,7 +883,7 @@ pod_retry_l1:
 if ( l1t == p2m_populate_on_demand )
 {
 if ( q & P2M_ALLOC ) {
-if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) )
+if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) )
 goto pod_retry_l1;
 } else
 *t = p2m_populate_on_demand;
diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h
index 07ca02a173..1ae9216404 100644
--- a/xen/include/asm-x86/p2m.h
+++ b/xen/include/asm-x86/p2m.h
@@ -720,7 +720,7 @@ extern void audit_p2m(struct domain *d,
 
 /* Called by p2m code when demand-populating a PoD page */
 int
-p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 

[Xen-devel] [PATCH v3 05/15] xen/x86: p2m-pod: Avoid redundant assignments in p2m_pod_demand_populate

2017-10-02 Thread Julien Grall
gfn_aligned is assigned 3 times with the exact same formula. All the
variables used are not modified, so consolidate in a single assignment
at the beginning of the function.

Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: George Dunlap 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Add George's and Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index f04d6e03e2..bcc87aee03 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -1079,7 +1079,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 {
 struct domain *d = p2m->domain;
 struct page_info *p = NULL; /* Compiler warnings */
-unsigned long gfn_aligned;
+unsigned long gfn_aligned = (gfn >> order) << order;
 mfn_t mfn;
 unsigned long i;
 
@@ -1102,7 +1102,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 if ( order == PAGE_ORDER_1G )
 {
 pod_unlock(p2m);
-gfn_aligned = (gfn >> order) << order;
 /*
  * Note that we are supposed to call p2m_set_entry() 512 times to
  * split 1GB into 512 2MB pages here. But We only do once here because
@@ -1147,8 +1146,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned 
long gfn,
 
 BUG_ON((mfn_x(mfn) & ((1UL << order) - 1)) != 0);
 
-gfn_aligned = (gfn >> order) << order;
-
 p2m_set_entry(p2m, gfn_aligned, mfn, order, p2m_ram_rw,
   p2m->default_access);
 
@@ -1200,7 +1197,6 @@ remap_and_retry:
  * NOTE: In a p2m fine-grained lock scenario this might
  * need promoting the gfn lock from gfn->2M superpage.
  */
-gfn_aligned = (gfn >> order) << order;
 for ( i = 0; i < (1UL << order); i++ )
 p2m_set_entry(p2m, gfn_aligned + i, INVALID_MFN, PAGE_ORDER_4K,
   p2m_populate_on_demand, p2m->default_access);
-- 
2.11.0


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


[Xen-devel] [PATCH v3 07/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_decrease_reservation

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: Wei Liu 
Acked-by: George Dunlap 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/arm/p2m.c   |  3 +--
 xen/arch/x86/mm/p2m-pod.c| 20 +---
 xen/common/memory.c  |  3 ++-
 xen/include/asm-arm/p2m.h| 13 -
 xen/include/asm-x86/p2m.h|  7 ---
 xen/include/xen/p2m-common.h | 13 +
 6 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 192a1c329d..0410b1e86b 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -393,8 +393,7 @@ int guest_physmap_mark_populate_on_demand(struct domain *d,
 return -ENOSYS;
 }
 
-int p2m_pod_decrease_reservation(struct domain *d,
- xen_pfn_t gpfn,
+int p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn,
  unsigned int order)
 {
 return -ENOSYS;
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 34f5239b6d..eb74e5c01f 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -511,9 +511,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn);
  * allow decrease_reservation() to handle everything else.
  */
 int
-p2m_pod_decrease_reservation(struct domain *d,
- xen_pfn_t gpfn,
- unsigned int order)
+p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order)
 {
 int ret = 0;
 unsigned long i, n;
@@ -521,7 +519,7 @@ p2m_pod_decrease_reservation(struct domain *d,
 bool_t steal_for_cache;
 long pod, nonpod, ram;
 
-gfn_lock(p2m, gpfn, order);
+gfn_lock(p2m, gfn, order);
 pod_lock(p2m);
 
 /*
@@ -545,7 +543,7 @@ p2m_pod_decrease_reservation(struct domain *d,
 p2m_type_t t;
 unsigned int cur_order;
 
-p2m->get_entry(p2m, gpfn + i, , , 0, _order, NULL);
+p2m->get_entry(p2m, gfn_x(gfn) + i, , , 0, _order, NULL);
 n = 1UL << min(order, cur_order);
 if ( t == p2m_populate_on_demand )
 pod += n;
@@ -567,7 +565,7 @@ p2m_pod_decrease_reservation(struct domain *d,
  * All PoD: Mark the whole region invalid and tell caller
  * we're done.
  */
-p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid,
+p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, order, p2m_invalid,
   p2m->default_access);
 p2m->pod.entry_count -= 1UL << order;
 BUG_ON(p2m->pod.entry_count < 0);
@@ -584,7 +582,7 @@ p2m_pod_decrease_reservation(struct domain *d,
  * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER)
  */
 if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) &&
- p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES - 1)) )
+ p2m_pod_zero_check_superpage(p2m, gfn_x(gfn) & ~(SUPERPAGE_PAGES - 
1)) )
 {
 pod = 1UL << order;
 ram = nonpod = 0;
@@ -605,13 +603,13 @@ p2m_pod_decrease_reservation(struct domain *d,
 p2m_access_t a;
 unsigned int cur_order;
 
-mfn = p2m->get_entry(p2m, gpfn + i, , , 0, _order, NULL);
+mfn = p2m->get_entry(p2m, gfn_x(gfn) + i, , , 0, _order, NULL);
 if ( order < cur_order )
 cur_order = order;
 n = 1UL << cur_order;
 if ( t == p2m_populate_on_demand )
 {
-p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order,
+p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
   p2m_invalid, p2m->default_access);
 p2m->pod.entry_count -= n;
 BUG_ON(p2m->pod.entry_count < 0);
@@ -633,7 +631,7 @@ p2m_pod_decrease_reservation(struct domain *d,
 
 page = mfn_to_page(mfn);
 
-p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order,
+p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order,
   p2m_invalid, p2m->default_access);
 p2m_tlb_flush_sync(p2m);
 for ( j = 0; j < n; ++j )
@@ -663,7 +661,7 @@ out_entry_check:
 
 out_unlock:
 pod_unlock(p2m);
-gfn_unlock(p2m, gpfn, order);
+gfn_unlock(p2m, gfn, order);
 return ret;
 }
 
diff --git a/xen/common/memory.c b/xen/common/memory.c
index a2abf554e3..ad987e0f29 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -417,7 +417,8 @@ static void decrease_reservation(struct memop_args *a)
 
 /* See if populate-on-demand wants to handle this */
 if ( is_hvm_domain(a->domain)
- && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) 
)
+ && 

[Xen-devel] [PATCH v3 03/15] xen/x86: p2m-pod: Fix coding style for comments

2017-10-02 Thread Julien Grall
Signed-off-by: Julien Grall 
Acked-by: Andrew Cooper 
Reviewed-by: George Dunlap 
Reviewed-by: Wei Liu 

---

Cc: George Dunlap 
Cc: Jan Beulich 
Cc: Andrew Cooper 

Changes in v3:
- Move the 1UL << changes in the next patch
- Add George's and Wei's reviewed-by

Changes in v2:
- Add Andrew's acked-by
---
 xen/arch/x86/mm/p2m-pod.c | 150 ++
 1 file changed, 100 insertions(+), 50 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 1f07441259..6beb26b00a 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -155,8 +155,10 @@ static struct page_info * p2m_pod_cache_get(struct 
p2m_domain *p2m,
 
 BUG_ON( page_list_empty(>pod.super) );
 
-/* Break up a superpage to make single pages. NB count doesn't
- * need to be adjusted. */
+/*
+ * Break up a superpage to make single pages. NB count doesn't
+ * need to be adjusted.
+ */
 p = page_list_remove_head(>pod.super);
 mfn = mfn_x(page_to_mfn(p));
 
@@ -242,8 +244,10 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned 
long pod_target, int p
 }
 
 /* Decreasing the target */
-/* We hold the pod lock here, so we don't need to worry about
- * cache disappearing under our feet. */
+/*
+ * We hold the pod lock here, so we don't need to worry about
+ * cache disappearing under our feet.
+ */
 while ( pod_target < p2m->pod.count )
 {
 struct page_info * page;
@@ -345,15 +349,19 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long 
target)
 if ( d->is_dying )
 goto out;
 
-/* T' < B: Don't reduce the cache size; let the balloon driver
- * take care of it. */
+/*
+ * T' < B: Don't reduce the cache size; let the balloon driver
+ * take care of it.
+ */
 if ( target < d->tot_pages )
 goto out;
 
 pod_target = target - populated;
 
-/* B < T': Set the cache size equal to # of outstanding entries,
- * let the balloon driver fill in the rest. */
+/*
+ * B < T': Set the cache size equal to # of outstanding entries,
+ * let the balloon driver fill in the rest.
+ */
 if ( populated > 0 && pod_target > p2m->pod.entry_count )
 pod_target = p2m->pod.entry_count;
 
@@ -491,7 +499,8 @@ static int
 p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn);
 
 
-/* This function is needed for two reasons:
+/*
+ * This function is needed for two reasons:
  * + To properly handle clearing of PoD entries
  * + To "steal back" memory being freed for the PoD cache, rather than
  *   releasing it.
@@ -513,8 +522,10 @@ p2m_pod_decrease_reservation(struct domain *d,
 gfn_lock(p2m, gpfn, order);
 pod_lock(p2m);
 
-/* If we don't have any outstanding PoD entries, let things take their
- * course */
+/*
+ * If we don't have any outstanding PoD entries, let things take their
+ * course.
+ */
 if ( p2m->pod.entry_count == 0 )
 goto out_unlock;
 
@@ -550,8 +561,10 @@ p2m_pod_decrease_reservation(struct domain *d,
 
 if ( !nonpod )
 {
-/* All PoD: Mark the whole region invalid and tell caller
- * we're done. */
+/*
+ * All PoD: Mark the whole region invalid and tell caller
+ * we're done.
+ */
 p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid,
   p2m->default_access);
 p2m->pod.entry_count-=(1<pod.entry_count > p2m->pod.count));
 }
 
-/* Process as long as:
+/*
+ * Process as long as:
  * + There are PoD entries to handle, or
  * + There is ram left, and we want to steal it
  */
@@ -631,8 +645,10 @@ p2m_pod_decrease_reservation(struct domain *d,
 }
 }
 
-/* If there are no more non-PoD entries, tell decrease_reservation() that
- * there's nothing left to do. */
+/*
+ * If there are no more non-PoD entries, tell decrease_reservation() that
+ * there's nothing left to do.
+ */
 if ( nonpod == 0 )
 ret = 1;
 
@@ -658,9 +674,11 @@ void p2m_pod_dump_data(struct domain *d)
 }
 
 
-/* Search for all-zero superpages to be reclaimed as superpages for the
+/*
+ * Search for all-zero superpages to be reclaimed as superpages for the
  * PoD cache. Must be called w/ pod lock held, must lock the superpage
- * in the p2m */
+ * in the p2m.
+ */
 static int
 p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn)
 {
@@ -682,12 +700,16 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, 
unsigned long gfn)
 if ( paging_mode_shadow(d) )
  

Re: [Xen-devel] [PATCH v4 19/27] x86: assembly, make some functions local

2017-10-02 Thread Ard Biesheuvel
On 2 October 2017 at 10:12, Jiri Slaby  wrote:
> There is a couple of assembly functions, which are invoked only locally
> in the file they are defined. In C, we mark them "static". In assembly,
> annotate them using SYM_{FUNC,CODE}_START_LOCAL (and switch their
> ENDPROC to SYM_{FUNC,CODE}_END too). Whether FUNC or CODE depends on
> ENDPROC/END for a particular function (C or non-C).
>

I wasn't cc'ed on the cover letter, so I am missing the rationale of
replacing ENTRY/ENDPROC with other macros.


> Signed-off-by: Jiri Slaby 
> Cc: "H. Peter Anvin" 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: x...@kernel.org
> Cc: Matt Fleming 
> Cc: Ard Biesheuvel 
> Cc: linux-...@vger.kernel.org
> Cc: xen-de...@lists.xenproject.org
> ---
>  arch/x86/boot/compressed/efi_thunk_64.S |  8 
>  arch/x86/entry/entry_64.S   | 25 +
>  arch/x86/lib/copy_page_64.S |  4 ++--
>  arch/x86/lib/memcpy_64.S| 12 ++--
>  arch/x86/lib/memset_64.S|  8 
>  arch/x86/platform/efi/efi_thunk_64.S| 12 ++--
>  arch/x86/xen/xen-pvh.S  |  4 ++--
>  7 files changed, 37 insertions(+), 36 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/efi_thunk_64.S 
> b/arch/x86/boot/compressed/efi_thunk_64.S
> index 86528f120962..c072711d8d62 100644
> --- a/arch/x86/boot/compressed/efi_thunk_64.S
> +++ b/arch/x86/boot/compressed/efi_thunk_64.S
> @@ -98,12 +98,12 @@ ENTRY(efi64_thunk)
> ret
>  ENDPROC(efi64_thunk)
>
> -ENTRY(efi_exit32)
> +SYM_FUNC_START_LOCAL(efi_exit32)
> movqfunc_rt_ptr(%rip), %rax
> push%rax
> mov %rdi, %rax
> ret
> -ENDPROC(efi_exit32)
> +SYM_FUNC_END(efi_exit32)
>
> .code32
>  /*
> @@ -111,7 +111,7 @@ ENDPROC(efi_exit32)
>   *
>   * The stack should represent the 32-bit calling convention.
>   */
> -ENTRY(efi_enter32)
> +SYM_FUNC_START_LOCAL(efi_enter32)
> movl$__KERNEL_DS, %eax
> movl%eax, %ds
> movl%eax, %es
> @@ -171,7 +171,7 @@ ENTRY(efi_enter32)
> btsl$X86_CR0_PG_BIT, %eax
> movl%eax, %cr0
> lret
> -ENDPROC(efi_enter32)
> +SYM_FUNC_END(efi_enter32)
>
> .data
> .balign 8
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 509504db0e2a..ff4964dac2dc 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -324,7 +324,7 @@ opportunistic_sysret_failed:
> jmp restore_c_regs_and_iret
>  END(entry_SYSCALL_64)
>
> -ENTRY(stub_ptregs_64)
> +SYM_CODE_START_LOCAL(stub_ptregs_64)
> /*
>  * Syscalls marked as needing ptregs land here.
>  * If we are on the fast path, we need to save the extra regs,
> @@ -349,7 +349,7 @@ ENTRY(stub_ptregs_64)
>
>  1:
> jmp *%rax   /* Called from C */
> -END(stub_ptregs_64)
> +SYM_CODE_END(stub_ptregs_64)
>
>  .macro ptregs_stub func
>  ENTRY(ptregs_\func)
> @@ -976,7 +976,8 @@ idtentry hypervisor_callback xen_do_hypervisor_callback 
> has_error_code=0
>   * existing activation in its critical region -- if so, we pop the current
>   * activation and restart the handler using the previous one.
>   */
> -ENTRY(xen_do_hypervisor_callback)  /* 
> do_hypervisor_callback(struct *pt_regs) */
> +/* do_hypervisor_callback(struct *pt_regs) */
> +SYM_CODE_START_LOCAL(xen_do_hypervisor_callback)
>
>  /*
>   * Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
> @@ -994,7 +995,7 @@ ENTRY(xen_do_hypervisor_callback)   /* 
> do_hypervisor_callback(struct *pt_regs) */
> callxen_maybe_preempt_hcall
>  #endif
> jmp error_exit
> -END(xen_do_hypervisor_callback)
> +SYM_CODE_END(xen_do_hypervisor_callback)
>
>  /*
>   * Hypervisor uses this for application faults while it executes.
> @@ -1078,7 +1079,7 @@ idtentry machine_check  
>   has_error_code=0paranoid=1 do_sym=*machine_check_vec
>   * Use slow, but surefire "are we in kernel?" check.
>   * Return: ebx=0: need swapgs on exit, ebx=1: otherwise
>   */
> -ENTRY(paranoid_entry)
> +SYM_CODE_START_LOCAL(paranoid_entry)
> UNWIND_HINT_FUNC
> cld
> SAVE_C_REGS 8
> @@ -1092,7 +1093,7 @@ ENTRY(paranoid_entry)
> SWAPGS
> xorl%ebx, %ebx
>  1: ret
> -END(paranoid_entry)
> +SYM_CODE_END(paranoid_entry)
>
>  /*
>   * "Paranoid" exit path from exception stack.  This is invoked
> @@ -1106,7 +1107,7 @@ END(paranoid_entry)
>   *
>   * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
>   */
> -ENTRY(paranoid_exit)
> +SYM_CODE_START_LOCAL(paranoid_exit)
> UNWIND_HINT_REGS
> DISABLE_INTERRUPTS(CLBR_ANY)
> TRACE_IRQS_OFF_DEBUG
> @@ -1122,13 +1123,13 @@ paranoid_exit_restore:
> 

[Xen-devel] [xen-unstable-smoke test] 113948: tolerable all pass - PUSHED

2017-10-02 Thread osstest service owner
flight 113948 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113948/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae
baseline version:
 xen  5414ba7f5e1ffc88ed2758b1e1b14bbfd3536a61

Last test of basis   113914  2017-09-29 21:02:32 Z2 days
Testing same since   113948  2017-10-02 11:03:42 Z0 days1 attempts


People who touched revisions under test:
  Roger Pau Monne 
  Roger Pau Monné 
  Wei Liu 

jobs:
 build-amd64  pass
 build-armhf  pass
 build-amd64-libvirt  pass
 test-armhf-armhf-xl  pass
 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


Pushing revision :

+ branch=xen-unstable-smoke
+ revision=ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.
 PERLLIB=.:.
+++ 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 xen-unstable-smoke 
ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae
+ branch=xen-unstable-smoke
+ revision=ceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
 export PERLLIB=.:.:.
 PERLLIB=.:.:.
+++ 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
+++ export PERLLIB=.:.:.:.
+++ PERLLIB=.:.:.:.
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=xen
+ xenbranch=xen-unstable-smoke
+ qemuubranch=qemu-upstream-unstable
+ '[' xxen = xlinux ']'
+ linuxbranch=
+ '[' xqemu-upstream-unstable = x ']'
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable-smoke
+ prevxenbranch=xen-4.9-testing
+ '[' xceb6ad8850ba6c3ae39fb540cd99f0d7f1311aae = 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
++ : 

Re: [Xen-devel] [PATCH v2 11/16] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check

2017-10-02 Thread Julien Grall

Hi Jan,

On 22/09/17 10:26, Jan Beulich wrote:

On 21.09.17 at 14:40,  wrote:

--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -861,17 +861,19 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long 
*gfns, int count)
  for ( i = 0; i < count; i++ )
  {
  p2m_access_t a;
+struct page_info *pg;
  
  mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, ,

   0, NULL, NULL);
+pg = mfn_to_page(mfns[i]);
+
  /*
   * If this is ram, and not a pagetable or from the xen heap, and
   * probably not mapped elsewhere, map it; otherwise, skip.
   */
-if ( p2m_is_ram(types[i])
- && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 )
- && ( (mfn_to_page(mfns[i])->count_info & 
(PGC_page_table|PGC_xen_heap)) == 0 )
- && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= 
max_ref ) )
+if ( p2m_is_ram(types[i]) && (pg->count_info & PGC_allocated) &&


If you omit the != 0 here (which I appreciate) ...


+ ((pg->count_info & (PGC_page_table | PGC_xen_heap)) == 0) &&


... you should also use ! instead of == 0 here.


Good point. I will do that.




+ ((pg->count_info & (PGC_count_mask)) <= max_ref) )


Stray innermost parentheses left?


I will drop the parentheses around PGC_count_mask.

Cheers,

--
Julien Grall

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


Re: [Xen-devel] [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*

2017-10-02 Thread Rafael J. Wysocki
On Monday, October 2, 2017 11:12:42 AM CEST Jiri Slaby wrote:
> These are all functions which are invoked from elsewhere, so we annotate
> them as global using the new SYM_FUNC_START. And their ENDPROC's by
> SYM_FUNC_END.
> 
> And make sure ENTRY/ENDPROC is not defined on X86_64, given these were
> the last users.
> 
> Signed-off-by: Jiri Slaby 
> Cc: "H. Peter Anvin" 
> Cc: Thomas Gleixner 
> Cc: Ingo Molnar 
> Cc: x...@kernel.org
> Cc: Herbert Xu 
> Cc: "David S. Miller" 
> Cc: "Rafael J. Wysocki" 
> Cc: Len Brown 
> Cc: Pavel Machek 
> Cc: Matt Fleming 
> Cc: Ard Biesheuvel 
> Cc: Boris Ostrovsky 
> Cc: Juergen Gross 
> Cc: linux-cry...@vger.kernel.org
> Cc: linux...@vger.kernel.org
> Cc: linux-...@vger.kernel.org
> Cc: xen-de...@lists.xenproject.org
> ---
>  arch/x86/boot/compressed/efi_thunk_64.S|  4 +-
>  arch/x86/boot/compressed/head_64.S | 16 
>  arch/x86/crypto/aes-i586-asm_32.S  |  8 ++--
>  arch/x86/crypto/aes-x86_64-asm_64.S|  4 +-
>  arch/x86/crypto/aes_ctrby8_avx-x86_64.S| 12 +++---
>  arch/x86/crypto/aesni-intel_asm.S  | 44 
> +++---
>  arch/x86/crypto/aesni-intel_avx-x86_64.S   | 24 ++--
>  arch/x86/crypto/blowfish-x86_64-asm_64.S   | 16 
>  arch/x86/crypto/camellia-aesni-avx-asm_64.S| 24 ++--
>  arch/x86/crypto/camellia-aesni-avx2-asm_64.S   | 24 ++--
>  arch/x86/crypto/camellia-x86_64-asm_64.S   | 16 
>  arch/x86/crypto/cast5-avx-x86_64-asm_64.S  | 16 
>  arch/x86/crypto/cast6-avx-x86_64-asm_64.S  | 24 ++--
>  arch/x86/crypto/chacha20-avx2-x86_64.S |  4 +-
>  arch/x86/crypto/chacha20-ssse3-x86_64.S|  8 ++--
>  arch/x86/crypto/crc32-pclmul_asm.S |  4 +-
>  arch/x86/crypto/crc32c-pcl-intel-asm_64.S  |  4 +-
>  arch/x86/crypto/crct10dif-pcl-asm_64.S |  4 +-
>  arch/x86/crypto/des3_ede-asm_64.S  |  8 ++--
>  arch/x86/crypto/ghash-clmulni-intel_asm.S  |  8 ++--
>  arch/x86/crypto/poly1305-avx2-x86_64.S |  4 +-
>  arch/x86/crypto/poly1305-sse2-x86_64.S |  8 ++--
>  arch/x86/crypto/salsa20-x86_64-asm_64.S| 12 +++---
>  arch/x86/crypto/serpent-avx-x86_64-asm_64.S| 24 ++--
>  arch/x86/crypto/serpent-avx2-asm_64.S  | 24 ++--
>  arch/x86/crypto/serpent-sse2-x86_64-asm_64.S   |  8 ++--
>  arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S   |  8 ++--
>  arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S  |  4 +-
>  arch/x86/crypto/sha1-mb/sha1_x8_avx2.S |  4 +-
>  arch/x86/crypto/sha1_avx2_x86_64_asm.S |  4 +-
>  arch/x86/crypto/sha1_ni_asm.S  |  4 +-
>  arch/x86/crypto/sha1_ssse3_asm.S   |  4 +-
>  arch/x86/crypto/sha256-avx-asm.S   |  4 +-
>  arch/x86/crypto/sha256-avx2-asm.S  |  4 +-
>  .../crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S|  8 ++--
>  .../crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S   |  4 +-
>  arch/x86/crypto/sha256-mb/sha256_x8_avx2.S |  4 +-
>  arch/x86/crypto/sha256-ssse3-asm.S |  4 +-
>  arch/x86/crypto/sha256_ni_asm.S|  4 +-
>  arch/x86/crypto/sha512-avx-asm.S   |  4 +-
>  arch/x86/crypto/sha512-avx2-asm.S  |  4 +-
>  .../crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S|  8 ++--
>  .../crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S   |  4 +-
>  arch/x86/crypto/sha512-mb/sha512_x4_avx2.S |  4 +-
>  arch/x86/crypto/sha512-ssse3-asm.S |  4 +-
>  arch/x86/crypto/twofish-avx-x86_64-asm_64.S| 24 ++--
>  arch/x86/crypto/twofish-x86_64-asm_64-3way.S   |  8 ++--
>  arch/x86/crypto/twofish-x86_64-asm_64.S|  8 ++--
>  arch/x86/entry/entry_64.S  | 10 ++---
>  arch/x86/entry/entry_64_compat.S   |  8 ++--
>  arch/x86/kernel/acpi/wakeup_64.S   |  8 ++--
>  arch/x86/kernel/head_64.S  | 12 +++---
>  arch/x86/lib/checksum_32.S |  8 ++--
>  arch/x86/lib/clear_page_64.S   | 12 +++---
>  arch/x86/lib/cmpxchg16b_emu.S  |  4 +-
>  arch/x86/lib/cmpxchg8b_emu.S   |  4 +-
>  arch/x86/lib/copy_page_64.S|  4 +-
>  arch/x86/lib/copy_user_64.S| 16 
>  arch/x86/lib/csum-copy_64.S|  4 +-
>  arch/x86/lib/getuser.S | 16 
>  arch/x86/lib/hweight.S |  8 

[Xen-devel] [linux-linus test] 113945: tolerable FAIL - PUSHED

2017-10-02 Thread osstest service owner
flight 113945 linux-linus real [real]
http://logs.test-lab.xenproject.org/osstest/logs/113945/

Failures :-/ but no regressions.

Tests which are failing intermittently (not blocking):
 test-armhf-armhf-xl-credit2  12 guest-start  fail in 113939 pass in 113945
 test-amd64-i386-freebsd10-i386 16 guest-saverestore.2  fail pass in 113939

Tests which did not succeed, but are not blocking:
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 113935
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 113935
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 113935
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 113935
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 113935
 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-amd64-libvirt 13 migrate-support-checkfail   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-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-libvirt-qcow2 12 migrate-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-armhf-armhf-libvirt 13 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-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-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   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-libvirt-xsm 13 migrate-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-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-amd64-i386-xl-qemuu-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-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:
 linux9e66317d3c92ddaab330c125dfe9d06eee268aff
baseline version:
 linuxa8c964eacb21288b2dbfa9d80cee5968a3b8fb21

Last test of basis   113935  2017-10-01 05:25:19 Z1 days
Testing same since   113939  2017-10-01 22:19:44 Z0 days2 attempts


People who touched revisions under test:
  Akemi Yagi 
  Akemi Yagi 
  Alexander Shishkin 
  Alexandru Moise <00moses.alexande...@gmail.com>
  Andrey Ryabinin 
  Arnaldo Carvalho de Melo 
  Bhumika Goyal 
  Borislav Petkov 
  Ethan Zhao 
  Ingo Molnar 
  Jeffy Chen 
  Jiri Olsa 
  Josh Poimboeuf 
  Kan Liang 
  Kees Cook 
  Laurent Dufour 
  Linus Torvalds 
  Masahiro Yamada 
  max.byungchul.p...@gmail.com
  Mengting Zhang 
  Paul Burton 
  Peter Zijlstra (Intel) 

[Xen-devel] [PATCH v8] x86/hvm: Implement hvmemul_write() using real mappings

2017-10-02 Thread Alexandru Isaila
From: Andrew Cooper 

An access which crosses a page boundary is performed atomically by x86
hardware, albeit with a severe performance penalty.  An important corner case
is when a straddled access hits two pages which differ in whether a
translation exists, or in net access rights.

The use of hvm_copy*() in hvmemul_write() is problematic, because it performs
a translation then completes the partial write, before moving onto the next
translation.

If an individual emulated write straddles two pages, the first of which is
writable, and the second of which is not, the first half of the write will
complete before #PF is raised from the second half.

This results in guest state corruption as a side effect of emulation, which
has been observed to cause windows to crash while under introspection.

Introduce the hvmemul_{,un}map_linear_addr() helpers, which translate an
entire contents of a linear access, and vmap() the underlying frames to
provide a contiguous virtual mapping for the emulator to use.  This is the
same mechanism as used by the shadow emulation code.

This will catch any translation issues and abort the emulation before any
modifications occur.

Signed-off-by: Andrew Cooper 
Signed-off-by: Alexandru Isaila 

---
Changes since V7:
- Removed blank lines
- Moved the caluculation onf frame and addr in the for loop
- Changed the if condition to nr_frames == 1
- Converted the while loop to for in the unmap func.

Note: Tested with win32/64 and ubuntu64 guests.
---
 xen/arch/x86/hvm/emulate.c| 182 ++
 xen/include/asm-x86/hvm/emulate.h |   7 ++
 2 files changed, 173 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index cc874ce..1ba9a1b 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -498,6 +498,163 @@ static int hvmemul_do_mmio_addr(paddr_t mmio_gpa,
 }
 
 /*
+ * Map the frame(s) covering an individual linear access, for writeable
+ * access.  May return NULL for MMIO, or ERR_PTR(~X86EMUL_*) for other errors
+ * including ERR_PTR(~X86EMUL_OKAY) for write-discard mappings.
+ *
+ * In debug builds, map() checks that each slot in hvmemul_ctxt->mfn[] is
+ * clean before use, and poisions unused slots with INVALID_MFN.
+ */
+static void *hvmemul_map_linear_addr(
+unsigned long linear, unsigned int bytes, uint32_t pfec,
+struct hvm_emulate_ctxt *hvmemul_ctxt)
+{
+struct vcpu *curr = current;
+void *err, *mapping;
+
+/* First and final gfns which need mapping. */
+unsigned int nr_frames = ((linear + bytes - !!bytes) >> PAGE_SHIFT) -
+(linear >> PAGE_SHIFT) + 1;
+unsigned int i;
+
+/*
+ * mfn points to the next free slot.  All used slots have a page reference
+ * held on them.
+ */
+mfn_t *mfn = _ctxt->mfn[0];
+
+/*
+ * The caller has no legitimate reason for trying a zero-byte write, but
+ * final is calculate to fail safe in release builds.
+ *
+ * The maximum write size depends on the number of adjacent mfns[] which
+ * can be vmap()'d, accouting for possible misalignment within the region.
+ * The higher level emulation callers are responsible for ensuring that
+ * mfns[] is large enough for the requested write size.
+ */
+if ( bytes == 0 ||
+ nr_frames > ARRAY_SIZE(hvmemul_ctxt->mfn) )
+{
+ASSERT_UNREACHABLE();
+printk("goto unhandle ERROR~!~~\n");
+goto unhandleable;
+}
+
+for( i = 0; i < nr_frames; i++ )
+{
+enum hvm_translation_result res;
+struct page_info *page;
+pagefault_info_t pfinfo;
+p2m_type_t p2mt;
+unsigned long frame = (linear >> PAGE_SHIFT) + i;
+unsigned long addr = frame << PAGE_SHIFT;
+
+if ( hvmemul_ctxt->ctxt.addr_size < 64 )
+addr = (uint32_t)addr;
+
+/* Error checking.  Confirm that the current slot is clean. */
+ASSERT(mfn_x(*mfn) == 0);
+
+res = hvm_translate_get_page(curr, addr, true, pfec,
+ , , NULL, );
+
+switch ( res )
+{
+case HVMTRANS_okay:
+break;
+
+case HVMTRANS_bad_linear_to_gfn:
+x86_emul_pagefault(pfinfo.ec, pfinfo.linear, _ctxt->ctxt);
+err = ERR_PTR(~X86EMUL_EXCEPTION);
+goto out;
+
+case HVMTRANS_bad_gfn_to_mfn:
+err = NULL;
+goto out;
+
+case HVMTRANS_gfn_paged_out:
+case HVMTRANS_gfn_shared:
+err = ERR_PTR(~X86EMUL_RETRY);
+goto out;
+
+default:
+goto unhandleable;
+}
+
+*mfn++ = _mfn(page_to_mfn(page));
+
+if ( p2m_is_discard_write(p2mt) )
+{
+err = ERR_PTR(~X86EMUL_OKAY);
+goto out;
+}
+}
+
+/* Entire access within a single 

Re: [Xen-devel] KVM PV

2017-10-02 Thread Paolo Bonzini
On 02/10/2017 12:36, George Dunlap wrote:
>>> Although I'm not business man, I don't think the top cloud provider[s]
>>> would allow nested virtualization, however mature nested virtualization
>>> is. Even xen-pv is unable to be nested in the aws and azure.
>>
>> Check the contributors to KVM nested virtualization, you might be surprised.
>>
>> Nested Xen PV is not possible because the Xen hypervisor cannot run as a PV 
>> guest.>> It's a technical limitation.
> 
> Minor correction: Xen can't run on AWS as a PV guest, but it can run
> as an L1 hypervisor inside any "fully virtualized" VM (as both AWS and
> Azure provide), and provide PV L2 guests.

Yes, that's what I meant.

Thanks George!

Paolo

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


Re: [Xen-devel] [PATCH] libxl: fix generating array of enums in getypes.py

2017-10-02 Thread Wei Liu
On Fri, Sep 29, 2017 at 04:49:23PM +0300, Oleksandr Grytsov wrote:
> From: Oleksandr Grytsov 
> 
> Enum always uses "x" value as input argument. In
> case of enum array "t" argument should be passed.
> 
> Signed-off-by: Oleksandr Grytsov 

Checking parent doesn't seem to be necessary. We already have "w" which
is passed by the higher level.

Can you try the following patch?

From c451e88dc64febbbea835563eb3347cbc24874ce Mon Sep 17 00:00:00 2001
From: Wei Liu 
Date: Mon, 2 Oct 2017 12:48:28 +0100
Subject: [PATCH] libxl/gentypes: fix generating array of enums

There is no reason to hardcode "x" in code. Use "w" which is passed
by the higher level.

This change requires us to allow "x" to be unused so that the
top-level enum parse_json functions continue to compile.

Signed-off-by: Wei Liu 
---
 tools/libxl/gentypes.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 76aca76aaa..88e5c5f30e 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -432,7 +432,7 @@ def libxl_C_type_parse_json(ty, w, v, indent = "", 
parent = None, discrimina
 s = ""
 if parent is None:
 s += "int rc = 0;\n"
-s += "const libxl__json_object *x = o;\n"
+s += "const libxl__json_object *x __attribute__((__unused__)) = o;\n"
 
 if isinstance(ty, idl.Array):
 if parent is None:
@@ -467,11 +467,11 @@ def libxl_C_type_parse_json(ty, w, v, indent = "", 
parent = None, discrimina
 raise Exception("Only KeyedUnion can have discriminator")
 s += "{\n"
 s += "const char *enum_str;\n"
-s += "if (!libxl__json_object_is_string(x)) {\n"
+s += "if (!libxl__json_object_is_string(%s)) {\n" % w
 s += "rc = -1;\n"
 s += "goto out;\n"
 s += "}\n"
-s += "enum_str = libxl__json_object_get_string(x);\n"
+s += "enum_str = libxl__json_object_get_string(%s);\n" % w
 s += "rc = %s_from_string(enum_str, %s);\n" % (ty.typename, 
ty.pass_arg(v, parent is None, idl.PASS_BY_REFERENCE))
 s += "if (rc)\n"
 s += "goto out;\n"
-- 
2.11.0


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


Re: [Xen-devel] [RFC] removing proc-xen.mount due to systemd change

2017-10-02 Thread Wei Liu
On Mon, Oct 02, 2017 at 12:26:24PM +0200, Vasilis Liaskovitis wrote:
> Apologies for formatting. Here is my question in plain text:
> 
> There are systemd services that check for dom0 detection before xenfs
> gets mounted by proc-xen.mount. See this systemd bug report for an
> example:
> https://github.com/systemd/systemd/issues/6442
> 
> Upstream systemd has accepted the patch for this: https://github.com/sy
> stemd/systemd/pull/6662,
> which mounts xenfs at systemd init time i.e. making /proc/xen an API
> file.
> 
> However the issue now is that proc-xen.mount will refuse to mount
> /proc/xen as it an API file system, and the service will fail. This
> breaks xen, as other services depending on proc-xen.mount also
> fail.
> 
> What is the preferred way to deal with this in xen?
> 
> - We can remove proc-xen.mount completely, for systems using systemd.
> 

That would break Xen system using an older version of systemd, right?
I'm against such action.

> - any other options?

Can we just make the unit not fail? I.e. when it detects xenfs is
already mounted, it does nothing but reports success.

> 
> thank you,
> 
> - Vasilis
> 
> 
> On Mon, 2017-10-02 at 11:21 +0200, Vasilis Liaskovitis wrote:
> > ___
> > 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 mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] KVM PV (was: Re: [PATCH v2 2/2] x86/lguest: remove lguest support)

2017-10-02 Thread George Dunlap
On Sat, Sep 30, 2017 at 4:39 AM, Paolo Bonzini  wrote:
>
> - Lai Jiangshan  ha scritto:
>> On Sat, Sep 30, 2017 at 12:39 AM, Paolo Bonzini  wrote:
>> > On 29/09/2017 17:47, Lai Jiangshan wrote:
>> >> Hello, all
>> >>
>> >> An interesting (at least to me) thinking came up to me when I found
>> >> that the lguest was removed. But I don't have enough knowledge
>> >> to find out the answer nor energy to implement it in some time.
>> >>
>> >> Is it possible to implement kvm-pv which allows kvm to run on
>> >> the boxes without hardware virtualization support, so that
>> >> qemu/kvm can be used on clouds such as aws, azure?
>> >
>> > No, please don't. :)  Even Xen is moving from PV to PVH (paravirtualized
>> > hardware with event channels, grant tables and the like, but still using
>> > hardware extensions for MMU).
>> >
>> > Rather, cloud providers should help getting nested virtualization ready
>> > for production use.  At least for KVM it's not that far.
>> >
>>
>> Although I'm not business man, I don't think the top cloud provider[s]
>> would allow nested virtualization, however mature nested virtualization
>> is. Even xen-pv is unable to be nested in the aws and azure.

A lot of new Windows features, like Credential Guard and Device Guard
require hardware virtualization support, as do security products like
Bromium.  So it's not surprising that cloud providers are becoming
more interested in nested hardware support.

> Check the contributors to KVM nested virtualization, you might be surprised.
>
> Nested Xen PV is not possible because the Xen hypervisor cannot run as a PV 
> guest. It's a technical limitation.

Minor correction: Xen can't run on AWS as a PV guest, but it can run
as an L1 hypervisor inside any "fully virtualized" VM (as both AWS and
Azure provide), and provide PV L2 guests.

 -George

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


Re: [Xen-devel] [PATCH] libxl: remove dead code in libxl__domain_build_info_setdefault

2017-10-02 Thread Wei Liu
On Fri, Sep 29, 2017 at 10:53:07AM +0100, Roger Pau Monne wrote:
> Spotted by Coverity.
> 

This now has a Coverity ID 1418831.

I will add that to commit message.

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


Re: [Xen-devel] [RFC] removing proc-xen.mount due to systemd change

2017-10-02 Thread Vasilis Liaskovitis
Apologies for formatting. Here is my question in plain text:

There are systemd services that check for dom0 detection before xenfs
gets mounted by proc-xen.mount. See this systemd bug report for an
example:
https://github.com/systemd/systemd/issues/6442

Upstream systemd has accepted the patch for this: https://github.com/sy
stemd/systemd/pull/6662,
which mounts xenfs at systemd init time i.e. making /proc/xen an API
file.

However the issue now is that proc-xen.mount will refuse to mount
/proc/xen as it an API file system, and the service will fail. This
breaks xen, as other services depending on proc-xen.mount also
fail.

What is the preferred way to deal with this in xen?

- We can remove proc-xen.mount completely, for systems using systemd.

- any other options?

thank you,

- Vasilis


On Mon, 2017-10-02 at 11:21 +0200, Vasilis Liaskovitis wrote:
> ___
> 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


  1   2   >