Re: NetBSD dom0 PVH: hardware interrupts stalls

2020-11-29 Thread Manuel Bouyer
On Sat, Nov 28, 2020 at 06:14:30PM +0100, Manuel Bouyer wrote:
> On Sat, Nov 28, 2020 at 03:53:11PM +0100, Roger Pau Monné wrote:
> > > the trace is at
> > > http://www-soc.lip6.fr/~bouyer/xen-log13.txt
> > 
> > Thanks! I think I've found the issue and I'm attaching a possible fix
> > (fix.patch) to this email. In any case I've also attached a further
> > debug patch, in case the fix turns out to be wrong. Please test the
> > fix first, as the debug patch will end up triggering a panic when the
> > buffer is full.
> 
> Yes, fix.patch does make the system boot as expected !
> thanks !

FYI it also works with Xen 4.13

-- 
Manuel Bouyer 
 NetBSD: 26 ans d'experience feront toujours la difference
--



[xen-unstable test] 157082: tolerable FAIL

2020-11-29 Thread osstest service owner
flight 157082 xen-unstable real [real]
http://logs.test-lab.xenproject.org/osstest/logs/157082/

Failures :-/ but no regressions.

Tests which are failing intermittently (not blocking):
 test-amd64-amd64-xl-rtds 20 guest-localmigrate/x10 fail in 157072 pass in 
157082
 test-amd64-amd64-xl-qemut-debianhvm-i386-xsm 12 debian-hvm-install fail pass 
in 157072
 test-armhf-armhf-xl-rtds 18 guest-start/debian.repeat  fail pass in 157072

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-ws16-amd64 19 guest-stopfail like 157072
 test-amd64-amd64-xl-qemuu-win7-amd64 19 guest-stopfail like 157072
 test-amd64-i386-xl-qemut-ws16-amd64 19 guest-stop fail like 157072
 test-amd64-amd64-xl-qemut-win7-amd64 19 guest-stopfail like 157072
 test-amd64-i386-xl-qemut-win7-amd64 19 guest-stop fail like 157072
 test-armhf-armhf-libvirt-raw 15 saverestore-support-checkfail  like 157072
 test-armhf-armhf-libvirt 16 saverestore-support-checkfail  like 157072
 test-amd64-amd64-xl-qemut-ws16-amd64 19 guest-stopfail like 157072
 test-amd64-amd64-qemuu-nested-amd 20 debian-hvm-install/l1/l2 fail like 157072
 test-amd64-i386-xl-qemuu-ws16-amd64 19 guest-stop fail like 157072
 test-amd64-i386-xl-qemuu-win7-amd64 19 guest-stop fail like 157072
 test-amd64-i386-xl-pvshim14 guest-start  fail   never pass
 test-amd64-amd64-libvirt 15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-arm64-arm64-xl  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit1  15 migrate-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-credit1  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  16 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 15 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 16 saverestore-support-checkfail never pass
 test-armhf-armhf-xl-credit1  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit1  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 15 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 16 saverestore-support-checkfail  never pass
 test-arm64-arm64-xl-seattle  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-seattle  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  15 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  f7d7d53f6464cff94ead4c15d21e79ce4d9173f5
baseline version:
 xen  f7d7d53f6464cff94ead4c15d21e79ce4d9173f5

Last test of basis   157082  2020-11-29 01:51:28 Z0 days
Testing same since  (not found) 0 attempts

jobs:
 build-amd64-xsm  pass
 build-arm64

[xen-unstable-coverity test] 157090: all pass - PUSHED

2020-11-29 Thread osstest service owner
flight 157090 xen-unstable-coverity real [real]
http://logs.test-lab.xenproject.org/osstest/logs/157090/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 xen  f7d7d53f6464cff94ead4c15d21e79ce4d9173f5
baseline version:
 xen  9b156bcc3ffcc7949edd4460b718a241e87ae302

Last test of basis   157003  2020-11-25 09:18:28 Z4 days
Testing same since   157090  2020-11-29 09:18:25 Z0 days1 attempts


People who touched revisions under test:
  Bertrand Marquis 
  Jan Beulich 
  Julien Grall 
  Paul Durrant 
  Rahul Singh 

jobs:
 coverity-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 :

To xenbits.xen.org:/home/xen/git/xen.git
   9b156bcc3f..f7d7d53f64  f7d7d53f6464cff94ead4c15d21e79ce4d9173f5 -> 
coverity-tested/smoke



[linux-linus test] 157086: regressions - FAIL

2020-11-29 Thread osstest service owner
flight 157086 linux-linus real [real]
http://logs.test-lab.xenproject.org/osstest/logs/157086/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-i386-xl-qemuu-ws16-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-xsm7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-qemut-rhel6hvm-intel  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-amd64-shadow 7 xen-install fail REGR. vs. 
152332
 test-amd64-i386-xl-qemut-debianhvm-amd64  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-qemuu-rhel6hvm-intel  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-i386-xsm 7 xen-install fail REGR. vs. 152332
 test-amd64-i386-examine   6 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-ws16-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-libvirt-xsm   7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-libvirt   7 xen-install  fail REGR. vs. 152332
 test-amd64-coresched-i386-xl  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 7 xen-install fail REGR. vs. 
152332
 test-amd64-i386-qemuu-rhel6hvm-amd  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-amd64  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-pair 10 xen-install/src_host fail REGR. vs. 152332
 test-amd64-i386-pair 11 xen-install/dst_host fail REGR. vs. 152332
 test-amd64-i386-qemut-rhel6hvm-amd  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-xl-raw7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-freebsd10-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-pvshim 7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-debianhvm-i386-xsm 7 xen-install fail REGR. vs. 152332
 test-amd64-i386-xl-shadow 7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-freebsd10-i386  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-ovmf-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-win7-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-win7-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-stubdom-debianhvm-amd64-xsm 7 xen-install fail REGR. 
vs. 152332
 test-amd64-i386-libvirt-pair 10 xen-install/src_host fail REGR. vs. 152332
 test-amd64-i386-libvirt-pair 11 xen-install/dst_host fail REGR. vs. 152332
 test-arm64-arm64-libvirt-xsm 10 host-ping-check-xen  fail REGR. vs. 152332
 test-arm64-arm64-xl-credit1   8 xen-boot fail REGR. vs. 152332
 test-arm64-arm64-examine 13 examine-iommufail REGR. vs. 152332
 test-amd64-amd64-amd64-pvgrub 20 guest-stop  fail REGR. vs. 152332
 test-amd64-amd64-i386-pvgrub 20 guest-stop   fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-dmrestrict-amd64-dmrestrict 7 xen-install fail REGR. 
vs. 152332
 test-amd64-i386-xl7 xen-install  fail REGR. vs. 152332
 test-arm64-arm64-xl-xsm   8 xen-boot fail REGR. vs. 152332
 test-arm64-arm64-xl-credit2   8 xen-boot fail REGR. vs. 152332

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-seattle  11 leak-check/basis(11)fail blocked in 152332
 test-arm64-arm64-xl  11 leak-check/basis(11)fail blocked in 152332
 test-amd64-amd64-xl-qemut-win7-amd64 19 guest-stopfail like 152332
 test-armhf-armhf-libvirt 16 saverestore-support-checkfail  like 152332
 test-amd64-amd64-xl-qemuu-win7-amd64 19 guest-stopfail like 152332
 test-amd64-amd64-xl-qemut-ws16-amd64 19 guest-stopfail like 152332
 test-armhf-armhf-xl-rtds 18 guest-start/debian.repeatfail  like 152332
 test-armhf-armhf-libvirt-raw 15 saverestore-support-checkfail  like 152332
 test-amd64-amd64-xl-qemuu-ws16-amd64 19 guest-stopfail like 152332
 test-amd64-amd64-qemuu-nested-amd 20 debian-hvm-install/l1/l2 fail like 152332
 test-amd64-amd64-libvirt 15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 15 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 16 saverestore-support-checkfail never pass
 test-armhf-armhf-xl-multivcpu 15 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 16 saverestore-support-ch

HVM - 2nd bridge breaking DomU config

2020-11-29 Thread Oliver Linden
Hi all,

got the recommendation from the freenode xen IRC channel to open a
ticket here. Hoping that's ok.

Problem:

I want to provide a second bridge to a HVM Linux DomU. But as soon as I
add this to the DomU config file the DomU doesn't start and the qemu log
file does state

*qemu-system-i386: -device
rtl8139,id=nic1,netdev=net1,mac=00:16:3e:35:af:af: xen: failed to
populate ram at 1100c* (same with e1000)

Providing only one bridge does work fine. Since I couldn't find anything
meaningful to me on the Internet I'm asking here. Any help is highly
appreciated.

root@HAM-XEN1:/etc/xen# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

root@HAM-XEN1:/etc/xen# uname -a
Linux HAM-XEN1 5.4.0-54-generic #60-Ubuntu SMP Fri Nov 6 10:37:59 UTC
2020 x86_64 x86_64 x86_64 GNU/Linux

root@HAM-XEN1:/etc/xen# xl info
host   : HAM-XEN1
release    : 5.4.0-54-generic
version    : #60-Ubuntu SMP Fri Nov 6 10:37:59 UTC 2020
machine    : x86_64
nr_cpus    : 16
max_cpu_id : 31
nr_nodes   : 1
cores_per_socket   : 8
threads_per_core   : 2
cpu_mhz    : 3593.326
hw_caps    :
178bf3ff:f6d8320b:2e500800:244037ff:000f:219c91a9:0044:0500
virt_caps  : hvm hvm_directio
total_memory   : 32699
free_memory    : 7150
sharing_freed_memory   : 0
sharing_used_memory    : 0
outstanding_claims : 0
free_cpus  : 0
xen_major  : 4
xen_minor  : 11
xen_extra  : .4-pre
xen_version    : 4.11.4-pre
xen_caps   : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32
hvm-3.0-x86_32p hvm-3.0-x86_64
xen_scheduler  : credit
xen_pagesize   : 4096
platform_params    : virt_start=0x8000
xen_changeset  :
xen_commandline    : placeholder dom0_max_vcpus=2-3
dom0_mem=1024M,max:2048M iommu=amd-iommu-global-intremap loglvl=all
guest_loglvl=all quiet no-real-mode edd=off
cc_compiler    : gcc (Ubuntu 9.2.1-31ubuntu3) 9.2.1 20200306
cc_compile_by  : ubuntu-devel-di
cc_compile_domain  : lists.ubuntu.com
cc_compile_date    : Tue Mar 10 09:04:06 UTC 2020
build_id   : 70edf50fce444a706eb5c69735c35c1838e4eaee
xend_config_format : 4

Best, Oliver



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 2/8] net: xen-netback: xenbus: Demote nonconformant kernel-doc headers

2020-11-29 Thread Andrew Lunn
On Thu, Nov 26, 2020 at 01:38:47PM +, Lee Jones wrote:
> Fixes the following W=1 kernel build warning(s):
> 
>  drivers/net/xen-netback/xenbus.c:419: warning: Function parameter or member 
> 'dev' not described in 'frontend_changed'
>  drivers/net/xen-netback/xenbus.c:419: warning: Function parameter or member 
> 'frontend_state' not described in 'frontend_changed'
>  drivers/net/xen-netback/xenbus.c:1001: warning: Function parameter or member 
> 'dev' not described in 'netback_probe'
>  drivers/net/xen-netback/xenbus.c:1001: warning: Function parameter or member 
> 'id' not described in 'netback_probe'
> 
> Cc: Wei Liu 
> Cc: Paul Durrant 
> Cc: "David S. Miller" 
> Cc: Jakub Kicinski 
> Cc: Alexei Starovoitov 
> Cc: Daniel Borkmann 
> Cc: Jesper Dangaard Brouer 
> Cc: John Fastabend 
> Cc: Rusty Russell 
> Cc: xen-devel@lists.xenproject.org
> Cc: net...@vger.kernel.org
> Cc: b...@vger.kernel.org
> Signed-off-by: Lee Jones 

Reviewed-by: Andrew Lunn 

Andrew



[qemu-mainline test] 157088: regressions - FAIL

2020-11-29 Thread osstest service owner
flight 157088 qemu-mainline real [real]
flight 157095 qemu-mainline real-retest [real]
http://logs.test-lab.xenproject.org/osstest/logs/157088/
http://logs.test-lab.xenproject.org/osstest/logs/157095/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-libvirt-vhd 19 guest-start/debian.repeat fail REGR. vs. 152631
 test-amd64-amd64-xl-qcow2   21 guest-start/debian.repeat fail REGR. vs. 152631
 test-armhf-armhf-xl-vhd 17 guest-start/debian.repeat fail REGR. vs. 152631

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-win7-amd64 19 guest-stopfail like 152631
 test-amd64-i386-xl-qemuu-win7-amd64 19 guest-stop fail like 152631
 test-armhf-armhf-libvirt 16 saverestore-support-checkfail  like 152631
 test-amd64-amd64-xl-qemuu-ws16-amd64 19 guest-stopfail like 152631
 test-armhf-armhf-libvirt-raw 15 saverestore-support-checkfail  like 152631
 test-amd64-i386-xl-qemuu-ws16-amd64 19 guest-stop fail like 152631
 test-amd64-amd64-qemuu-nested-amd 20 debian-hvm-install/l1/l2 fail like 152631
 test-amd64-i386-xl-pvshim14 guest-start  fail   never pass
 test-arm64-arm64-xl-seattle  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-seattle  16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 14 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl  16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-arndale  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 15 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 16 saverestore-support-checkfail never pass
 test-armhf-armhf-xl  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 15 migrate-support-checkfail  never pass
 test-armhf-armhf-xl  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 16 saverestore-support-checkfail  never pass
 test-arm64-arm64-xl-credit1  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit1  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit1  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit1  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  15 saverestore-support-checkfail   never pass

version targeted for testing:
 qemuu944fdc5e27a5b5adbb765891e8e70e88ba9a00ec
baseline version:
 qemuu1d806cef0e38b5db8347a8e12f214d543204a314

Last test of basis   152631  2020-08-20 09:07:46 Z  101 days
Failing since152659  2020-08-21 14:07:39 Z  100 days  210 attempts
Testing same since   157069  2020-11-28 05:42:38 Z1 days3 attempts


People who touched revisions under test:
Aaron Lindsay 
  Alberto Garcia 
  Aleksandar Markovic 
  Alex Bennée 
  Alex Chen 
  Alex Williamson 
  Alexander Bulek

[linux-linus test] 157093: regressions - trouble: broken/fail/pass

2020-11-29 Thread osstest service owner
flight 157093 linux-linus real [real]
http://logs.test-lab.xenproject.org/osstest/logs/157093/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-arm64-arm64-xl  broken
 test-amd64-i386-xl-qemuu-ws16-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-xsm7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-qemut-rhel6hvm-intel  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-amd64-shadow 7 xen-install fail REGR. vs. 
152332
 test-amd64-i386-xl-qemut-debianhvm-amd64  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-qemuu-rhel6hvm-intel  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-i386-xsm 7 xen-install fail REGR. vs. 152332
 test-amd64-i386-examine   6 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-ws16-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-libvirt-xsm   7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-libvirt   7 xen-install  fail REGR. vs. 152332
 test-amd64-coresched-i386-xl  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 7 xen-install fail REGR. vs. 
152332
 test-amd64-i386-qemuu-rhel6hvm-amd  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-debianhvm-amd64  7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-pair 10 xen-install/src_host fail REGR. vs. 152332
 test-amd64-i386-pair 11 xen-install/dst_host fail REGR. vs. 152332
 test-amd64-i386-qemut-rhel6hvm-amd  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-freebsd10-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-raw7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-pvshim 7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-debianhvm-i386-xsm 7 xen-install fail REGR. vs. 152332
 test-amd64-i386-xl-shadow 7 xen-install  fail REGR. vs. 152332
 test-amd64-i386-freebsd10-i386  7 xen-installfail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-ovmf-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-win7-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-win7-amd64  7 xen-install   fail REGR. vs. 152332
 test-amd64-i386-xl-qemut-stubdom-debianhvm-amd64-xsm 7 xen-install fail REGR. 
vs. 152332
 test-amd64-i386-libvirt-pair 10 xen-install/src_host fail REGR. vs. 152332
 test-amd64-i386-libvirt-pair 11 xen-install/dst_host fail REGR. vs. 152332
 test-arm64-arm64-xl-credit1   8 xen-boot fail REGR. vs. 152332
 test-arm64-arm64-examine 13 examine-iommufail REGR. vs. 152332
 test-amd64-amd64-amd64-pvgrub 20 guest-stop  fail REGR. vs. 152332
 test-amd64-amd64-i386-pvgrub 20 guest-stop   fail REGR. vs. 152332
 test-amd64-i386-xl-qemuu-dmrestrict-amd64-dmrestrict 7 xen-install fail REGR. 
vs. 152332
 test-amd64-i386-xl7 xen-install  fail REGR. vs. 152332
 test-arm64-arm64-xl-xsm   8 xen-boot fail REGR. vs. 152332
 test-arm64-arm64-xl-credit2   8 xen-boot fail REGR. vs. 152332
 test-arm64-arm64-libvirt-xsm 10 host-ping-check-xen fail in 157086 REGR. vs. 
152332

Tests which are failing intermittently (not blocking):
 test-arm64-arm64-xl-seattle   8 xen-boot   fail pass in 157086
 test-arm64-arm64-libvirt-xsm  8 xen-boot   fail pass in 157086

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl   5 host-install(5)   broken blocked in 152332
 test-arm64-arm64-xl-seattle 11 leak-check/basis(11) fail in 157086 blocked in 
152332
 test-arm64-arm64-xl   11 leak-check/basis(11) fail in 157086 blocked in 152332
 test-amd64-amd64-xl-qemut-win7-amd64 19 guest-stopfail like 152332
 test-armhf-armhf-libvirt 16 saverestore-support-checkfail  like 152332
 test-amd64-amd64-xl-qemuu-win7-amd64 19 guest-stopfail like 152332
 test-amd64-amd64-xl-qemut-ws16-amd64 19 guest-stopfail like 152332
 test-armhf-armhf-xl-rtds 18 guest-start/debian.repeatfail  like 152332
 test-armhf-armhf-libvirt-raw 15 saverestore-support-checkfail  like 152332
 test-amd64-amd64-xl-qemuu-ws16-amd64 19 guest-stopfail like 152332
 test-amd64-amd64-qemuu-nested-amd 20 debian-hvm-install/l1/l2 fail like 152332
 test-amd64-amd64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-amd6

[qemu-mainline test] 157097: regressions - FAIL

2020-11-29 Thread osstest service owner
flight 157097 qemu-mainline real [real]
http://logs.test-lab.xenproject.org/osstest/logs/157097/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-libvirt-vhd 19 guest-start/debian.repeat fail REGR. vs. 152631
 test-amd64-amd64-xl-qcow2   21 guest-start/debian.repeat fail REGR. vs. 152631
 test-armhf-armhf-xl-vhd 17 guest-start/debian.repeat fail REGR. vs. 152631

Tests which are failing intermittently (not blocking):
 test-amd64-amd64-xl-qemuu-debianhvm-i386-xsm 12 debian-hvm-install fail pass 
in 157088

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-win7-amd64 19 guest-stopfail like 152631
 test-amd64-i386-xl-qemuu-win7-amd64 19 guest-stop fail like 152631
 test-armhf-armhf-libvirt 16 saverestore-support-checkfail  like 152631
 test-amd64-amd64-xl-qemuu-ws16-amd64 19 guest-stopfail like 152631
 test-armhf-armhf-libvirt-raw 15 saverestore-support-checkfail  like 152631
 test-amd64-i386-xl-qemuu-ws16-amd64 19 guest-stop fail like 152631
 test-amd64-amd64-qemuu-nested-amd 20 debian-hvm-install/l1/l2 fail like 152631
 test-amd64-i386-xl-pvshim14 guest-start  fail   never pass
 test-arm64-arm64-xl-seattle  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-seattle  16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  15 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  15 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 14 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-xsm  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 15 migrate-support-checkfail   never pass
 test-arm64-arm64-libvirt-xsm 16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit2  16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-thunderx 16 saverestore-support-checkfail   never pass
 test-arm64-arm64-xl  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl  16 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-arndale  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  16 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 13 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-cubietruck 15 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 16 saverestore-support-checkfail never pass
 test-armhf-armhf-xl  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 15 migrate-support-checkfail  never pass
 test-armhf-armhf-xl  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 16 saverestore-support-checkfail  never pass
 test-arm64-arm64-xl-credit1  15 migrate-support-checkfail   never pass
 test-arm64-arm64-xl-credit1  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit1  15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit1  16 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 15 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 16 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  14 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  15 saverestore-support-checkfail   never pass

version targeted for testing:
 qemuu944fdc5e27a5b5adbb765891e8e70e88ba9a00ec
baseline version:
 qemuu1d806cef0e38b5db8347a8e12f214d543204a314

Last test of basis   152631  2020-08-20 09:07:46 Z  101 days
Failing since152659  2020-08-21 14:07:39 Z  100 days  211 attempts
Testing same since   157069  2020-11-28 05:42:38 Z1 days4 attempts


People who touched revisions under test:
Aaron Lindsay 
  Alberto Garcia 
  Aleksandar Markovic 
  Alex Bennée 
  Alex C

RE: [PATCH v3 13/13] x86: replace open-coded occurrences of sizeof_field()...

2020-11-29 Thread Tian, Kevin
> From: Paul Durrant 
> Sent: Wednesday, November 25, 2020 3:08 AM
> 
> From: Paul Durrant 
> 
> ... with macro evaluations, now that it is available.
> 
> A recent patch imported the sizeof_field() macro from Linux. This patch
> makes
> use of it in places where the construct is currently open-coded.
> 
> Signed-off-by: Paul Durrant 

Reviewed-by: Kevin Tian 

> ---
> Cc: Jun Nakajima 
> Cc: Kevin Tian 
> Cc: Jan Beulich 
> Cc: Andrew Cooper 
> Cc: "Roger Pau Monné" 
> Cc: Wei Liu 
> ---
>  xen/arch/x86/cpu/vpmu_intel.c |  4 ++--
>  xen/arch/x86/setup.c  | 16 
>  2 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/xen/arch/x86/cpu/vpmu_intel.c
> b/xen/arch/x86/cpu/vpmu_intel.c
> index 75aa11c6adec..6e97ce790037 100644
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -90,8 +90,8 @@ static uint64_t __read_mostly global_ovf_ctrl_mask,
> global_ctrl_mask;
>  static unsigned int __read_mostly regs_sz;
>  /* Offset into context of the beginning of PMU register block */
>  static const unsigned int regs_off =
> -sizeof(((struct xen_pmu_intel_ctxt *)0)->fixed_counters) +
> -sizeof(((struct xen_pmu_intel_ctxt *)0)->arch_counters);
> +sizeof_field(struct xen_pmu_intel_ctxt, fixed_counters) +
> +sizeof_field(struct xen_pmu_intel_ctxt, arch_counters);
> 
>  /*
>   * QUIRK to workaround an issue on various family 6 cpus.
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 44c04e273537..30d6f375a3af 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -1617,19 +1617,19 @@ void __init noreturn __start_xen(unsigned long
> mbi_p)
>  total_pages = nr_pages;
> 
>  /* Sanity check for unwanted bloat of certain hypercall structures. */
> -BUILD_BUG_ON(sizeof(((struct xen_platform_op *)0)->u) !=
> - sizeof(((struct xen_platform_op *)0)->u.pad));
> -BUILD_BUG_ON(sizeof(((struct xen_domctl *)0)->u) !=
> - sizeof(((struct xen_domctl *)0)->u.pad));
> -BUILD_BUG_ON(sizeof(((struct xen_sysctl *)0)->u) !=
> - sizeof(((struct xen_sysctl *)0)->u.pad));
> +BUILD_BUG_ON(sizeof_field(struct xen_platform_op, u) !=
> + sizeof_field(struct xen_platform_op, u.pad));
> +BUILD_BUG_ON(sizeof_field(struct xen_domctl, u) !=
> + sizeof_field(struct xen_domctl, u.pad));
> +BUILD_BUG_ON(sizeof_field(struct xen_sysctl, u) !=
> + sizeof_field(struct xen_sysctl, u.pad));
> 
>  BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
>  BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
>  BUILD_BUG_ON(sizeof(struct vcpu_info) != 64);
> 
> -BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) !=
> - sizeof(((struct compat_platform_op *)0)->u.pad));
> +BUILD_BUG_ON(sizeof_field(struct compat_platform_op, u) !=
> + sizeof_field(struct compat_platform_op, u.pad));
>  BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE);
>  BUILD_BUG_ON(sizeof(struct compat_vcpu_info) != 64);
> 
> --
> 2.20.1



RE: [PATCH] xen/iommu: vtd: Fix undefined behavior pci_vtd_quirks()

2020-11-29 Thread Tian, Kevin
> From: Julien Grall 
> Sent: Thursday, November 19, 2020 10:52 PM
> 
> From: Julien Grall 
> 
> When booting Xen with CONFIG_USBAN=y on Sandy Bridge, UBSAN will
> throw
> the following splat:
> 
> (XEN)
> 
> 
> (XEN) UBSAN: Undefined behaviour in quirks.c:449:63
> (XEN) left shift of 1 by 31 places cannot be represented in type 'int'
> (XEN) [ Xen-4.11.4  x86_64  debug=y   Not tainted ]
> 
> [...]
> 
> (XEN) Xen call trace:
> (XEN)[] ubsan.c#ubsan_epilogue+0xa/0xad
> (XEN)[]
> __ubsan_handle_shift_out_of_bounds+0xb4/0x145
> (XEN)[] pci_vtd_quirk+0x3d3/0x74f
> (XEN)[]
> iommu.c#domain_context_mapping+0x45b/0x46f
> (XEN)[] iommu.c#setup_hwdom_device+0x22/0x3a
> (XEN)[] pci.c#setup_one_hwdom_device+0x8c/0x124
> (XEN)[] pci.c#_setup_hwdom_pci_devices+0xbb/0x2f7
> (XEN)[] pci.c#pci_segments_iterate+0x4c/0x8c
> (XEN)[] setup_hwdom_pci_devices+0x25/0x2c
> (XEN)[]
> iommu.c#intel_iommu_hwdom_init+0x52/0x2f3
> (XEN)[] iommu_hwdom_init+0x4e/0xa4
> (XEN)[] dom0_construct_pv+0x23c8/0x2476
> (XEN)[] construct_dom0+0x6c/0xa3
> (XEN)[] __start_xen+0x4651/0x4b55
> (XEN)[] __high_start+0x53/0x55
> 
> Note that splat is from 4.11.4 and not staging. Although, the problem is
> still present.
> 
> This can be solved by making the first operand unsigned int.
> 
> Signed-off-by: Julien Grall 

Reviewed-by: Kevin Tian 

> 
> CR: https://code.amazon.com/reviews/CR-38873112
> ---
>  xen/drivers/passthrough/vtd/quirks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/quirks.c
> b/xen/drivers/passthrough/vtd/quirks.c
> index a8330f17bc0c..8a81d9c9308b 100644
> --- a/xen/drivers/passthrough/vtd/quirks.c
> +++ b/xen/drivers/passthrough/vtd/quirks.c
> @@ -435,7 +435,7 @@ void pci_vtd_quirk(const struct pci_dev *pdev)
>  case 0x3728: /* Xeon C5500/C3500 (JasperForest) */
>  case 0x3c28: /* Sandybridge */
>  val = pci_conf_read32(pdev->sbdf, 0x1AC);
> -pci_conf_write32(pdev->sbdf, 0x1AC, val | (1 << 31));
> +pci_conf_write32(pdev->sbdf, 0x1AC, val | (1U << 31));
>  printk(XENLOG_INFO "Masked VT-d error signaling on %pp\n", &pdev-
> >sbdf);
>  break;
> 
> --
> 2.17.1




RE: [PATCH v10 5/7] vtd: use a bit field for root_entry

2020-11-29 Thread Tian, Kevin
> From: Paul Durrant 
> Sent: Friday, November 20, 2020 9:25 PM
> 
> From: Paul Durrant 
> 
> This makes the code a little easier to read and also makes it more consistent
> with iremap_entry.
> 
> Also take the opportunity to tidy up the implementation of
> device_in_domain().
> 
> Signed-off-by: Paul Durrant 

Reviewed-by: 

> ---
> Cc: Kevin Tian 
> 
> v10:
>  - Small tweaks requested by Jan
>  - Remove macros in favour of direct field access
>  - Add missing barrier
> 
> v4:
>  - New in v4
> ---
>  xen/drivers/passthrough/vtd/iommu.c   |  9 +
>  xen/drivers/passthrough/vtd/iommu.h   | 25 -
>  xen/drivers/passthrough/vtd/utils.c   |  6 +++---
>  xen/drivers/passthrough/vtd/x86/ats.c | 27 +++
>  4 files changed, 35 insertions(+), 32 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/iommu.c
> b/xen/drivers/passthrough/vtd/iommu.c
> index d136fe36883b..1a038541f0a3 100644
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -237,7 +237,7 @@ static u64 bus_to_context_maddr(struct vtd_iommu
> *iommu, u8 bus)
>  ASSERT(spin_is_locked(&iommu->lock));
>  root_entries = (struct root_entry *)map_vtd_domain_page(iommu-
> >root_maddr);
>  root = &root_entries[bus];
> -if ( !root_present(*root) )
> +if ( !root->p )
>  {
>  maddr = alloc_pgtable_maddr(1, iommu->node);
>  if ( maddr == 0 )
> @@ -245,11 +245,12 @@ static u64 bus_to_context_maddr(struct
> vtd_iommu *iommu, u8 bus)
>  unmap_vtd_domain_page(root_entries);
>  return 0;
>  }
> -set_root_value(*root, maddr);
> -set_root_present(*root);
> +root->ctp = paddr_to_pfn(maddr);
> +smp_wmb();
> +root->p = true;
>  iommu_sync_cache(root, sizeof(struct root_entry));
>  }
> -maddr = (u64) get_context_addr(*root);
> +maddr = pfn_to_paddr(root->ctp);
>  unmap_vtd_domain_page(root_entries);
>  return maddr;
>  }
> diff --git a/xen/drivers/passthrough/vtd/iommu.h
> b/xen/drivers/passthrough/vtd/iommu.h
> index 216791b3d634..b14628eec260 100644
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -184,21 +184,20 @@
>  #define dma_frcd_source_id(c) (c & 0x)
>  #define dma_frcd_page_addr(d) (d & (((u64)-1) << 12)) /* low 64 bit */
> 
> -/*
> - * 0: Present
> - * 1-11: Reserved
> - * 12-63: Context Ptr (12 - (haw-1))
> - * 64-127: Reserved
> - */
>  struct root_entry {
> -u64val;
> -u64rsvd1;
> +union {
> +struct { uint64_t lo, hi; };
> +struct {
> +/* 0 - 63 */
> +bool p:1;
> +unsigned int reserved0:11;
> +uint64_t ctp:52;
> +
> +/* 64 - 127 */
> +uint64_t reserved1;
> +};
> +};
>  };
> -#define root_present(root)((root).val & 1)
> -#define set_root_present(root) do {(root).val |= 1;} while(0)
> -#define get_context_addr(root) ((root).val & PAGE_MASK_4K)
> -#define set_root_value(root, value) \
> -do {(root).val |= ((value) & PAGE_MASK_4K);} while(0)
> 
>  struct context_entry {
>  u64 lo;
> diff --git a/xen/drivers/passthrough/vtd/utils.c
> b/xen/drivers/passthrough/vtd/utils.c
> index 4febcf506d8a..5f25a86a535c 100644
> --- a/xen/drivers/passthrough/vtd/utils.c
> +++ b/xen/drivers/passthrough/vtd/utils.c
> @@ -112,15 +112,15 @@ void print_vtd_entries(struct vtd_iommu *iommu,
> int bus, int devfn, u64 gmfn)
>  return;
>  }
> 
> -printk("root_entry[%02x] = %"PRIx64"\n", bus, root_entry[bus].val);
> -if ( !root_present(root_entry[bus]) )
> +printk("root_entry[%02x] = %"PRIx64"\n", bus, root_entry[bus].lo);
> +if ( !root_entry[bus].p )
>  {
>  unmap_vtd_domain_page(root_entry);
>  printk("root_entry[%02x] not present\n", bus);
>  return;
>  }
> 
> -val = root_entry[bus].val;
> +val = pfn_to_paddr(root_entry[bus].ctp);
>  unmap_vtd_domain_page(root_entry);
>  ctxt_entry = map_vtd_domain_page(val);
>  if ( ctxt_entry == NULL )
> diff --git a/xen/drivers/passthrough/vtd/x86/ats.c
> b/xen/drivers/passthrough/vtd/x86/ats.c
> index 04d702b1d6b1..fec969ef75bb 100644
> --- a/xen/drivers/passthrough/vtd/x86/ats.c
> +++ b/xen/drivers/passthrough/vtd/x86/ats.c
> @@ -74,8 +74,8 @@ int ats_device(const struct pci_dev *pdev, const struct
> acpi_drhd_unit *drhd)
>  static bool device_in_domain(const struct vtd_iommu *iommu,
>   const struct pci_dev *pdev, uint16_t did)
>  {
> -struct root_entry *root_entry;
> -struct context_entry *ctxt_entry = NULL;
> +struct root_entry *root_entry, *root_entries;
> +struct context_entry *context_entry, *context_entries = NULL;
>  unsigned int tt;
>  bool found = false;
> 
> @@ -85,25 +85,28 @@ static bool device_in_domain(const struct
> vtd_iommu *iommu,
>  return false;
>  }
> 
> -root_

RE: [PATCH v10 6/7] vtd: use a bit field for context_entry

2020-11-29 Thread Tian, Kevin
> From: Paul Durrant 
> Sent: Friday, November 20, 2020 9:25 PM
> 
> From: Paul Durrant 
> 
> This removes the need for much shifting, masking and several magic
> numbers.
> On the whole it makes the code quite a bit more readable.
> 
> Signed-off-by: Paul Durrant 

Reviewed-by: Kevin Tian 

> ---
> Cc: Kevin Tian 
> 
> v10:
>  - Remove macros in favour of direct field access
>  - Adjust field types
>  - Add missing barriers
> 
> v4:
>  - New in v4
> ---
>  xen/drivers/passthrough/vtd/iommu.c   | 36 +++--
>  xen/drivers/passthrough/vtd/iommu.h   | 45 +--
>  xen/drivers/passthrough/vtd/utils.c   | 10 +++---
>  xen/drivers/passthrough/vtd/x86/ats.c |  6 ++--
>  4 files changed, 47 insertions(+), 50 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/vtd/iommu.c
> b/xen/drivers/passthrough/vtd/iommu.c
> index 1a038541f0a3..fdb472ad6515 100644
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -86,8 +86,6 @@ static int domain_iommu_domid(struct domain *d,
>  return -1;
>  }
> 
> -#define DID_FIELD_WIDTH 16
> -#define DID_HIGH_OFFSET 8
>  static int context_set_domain_id(struct context_entry *context,
>   struct domain *d,
>   struct vtd_iommu *iommu)
> @@ -121,21 +119,22 @@ static int context_set_domain_id(struct
> context_entry *context,
>  }
> 
>  set_bit(i, iommu->domid_bitmap);
> -context->hi |= (i & ((1 << DID_FIELD_WIDTH) - 1)) << DID_HIGH_OFFSET;
> +context->did = i;
> +
>  return 0;
>  }
> 
>  static int context_get_domain_id(struct context_entry *context,
>   struct vtd_iommu *iommu)
>  {
> -unsigned long dom_index, nr_dom;
>  int domid = -1;
> 
>  if (iommu && context)
>  {
> -nr_dom = cap_ndoms(iommu->cap);
> +unsigned long dom_index, nr_dom;
> 
> -dom_index = context_domain_id(*context);
> +nr_dom = cap_ndoms(iommu->cap);
> +dom_index = context->did;
> 
>  if ( dom_index < nr_dom && iommu->domid_map )
>  domid = iommu->domid_map[dom_index];
> @@ -1338,7 +1337,7 @@ int domain_context_mapping_one(
>  context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
>  context = &context_entries[devfn];
> 
> -if ( context_present(*context) )
> +if ( context->p )
>  {
>  int res = 0;
> 
> @@ -1382,7 +1381,7 @@ int domain_context_mapping_one(
> 
>  if ( iommu_hwdom_passthrough && is_hardware_domain(domain) )
>  {
> -context_set_translation_type(*context, CONTEXT_TT_PASS_THRU);
> +context->tt = CONTEXT_TT_PASS_THRU;
>  }
>  else
>  {
> @@ -1397,11 +1396,11 @@ int domain_context_mapping_one(
>  return -ENOMEM;
>  }
> 
> -context_set_address_root(*context, pgd_maddr);
> +context->slptptr = paddr_to_pfn(pgd_maddr);
>  if ( ats_enabled && ecap_dev_iotlb(iommu->ecap) )
> -context_set_translation_type(*context, CONTEXT_TT_DEV_IOTLB);
> +context->tt = CONTEXT_TT_DEV_IOTLB;
>  else
> -context_set_translation_type(*context, CONTEXT_TT_MULTI_LEVEL);
> +context->tt = CONTEXT_TT_MULTI_LEVEL;
> 
>  spin_unlock(&hd->arch.mapping_lock);
>  }
> @@ -1413,9 +1412,10 @@ int domain_context_mapping_one(
>  return -EFAULT;
>  }
> 
> -context_set_address_width(*context, level_to_agaw(iommu-
> >nr_pt_levels));
> -context_set_fault_enable(*context);
> -context_set_present(*context);
> +context->aw = level_to_agaw(iommu->nr_pt_levels);
> +context->fpd = false;
> +smp_wmb();
> +context->p = true;
>  iommu_sync_cache(context, sizeof(struct context_entry));
>  spin_unlock(&iommu->lock);
> 
> @@ -1567,17 +1567,19 @@ int domain_context_unmap_one(
>  context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
>  context = &context_entries[devfn];
> 
> -if ( !context_present(*context) )
> +if ( !context->p )
>  {
>  spin_unlock(&iommu->lock);
>  unmap_vtd_domain_page(context_entries);
>  return 0;
>  }
> 
> -context_clear_present(*context);
> -context_clear_entry(*context);
> +context->p = false;
> +smp_wmb();
>  iommu_sync_cache(context, sizeof(struct context_entry));
> 
> +context->val = 0; /* No need to sync; present bit is already cleared */
> +
>  iommu_domid= domain_iommu_domid(domain, iommu);
>  if ( iommu_domid == -1 )
>  {
> diff --git a/xen/drivers/passthrough/vtd/iommu.h
> b/xen/drivers/passthrough/vtd/iommu.h
> index b14628eec260..33b1abf98526 100644
> --- a/xen/drivers/passthrough/vtd/iommu.h
> +++ b/xen/drivers/passthrough/vtd/iommu.h
> @@ -198,37 +198,34 @@ struct root_entry {
>  };
>  };
>  };
> +#define ROOT_ENTRY_NR (PAGE_SIZE_4K / sizeof(struct root_entry))
> 
>  struct context_entry {
> -u64 lo;
> -u64 hi;

RE: [PATCH v10 7/7] vtd: use a bit field for dma_pte

2020-11-29 Thread Tian, Kevin
> From: Beulich
> Sent: Saturday, November 28, 2020 12:02 AM
> 
> On 20.11.2020 14:24, Paul Durrant wrote:
> > @@ -709,20 +709,23 @@ static void dma_pte_clear_one(struct domain
> *domain, uint64_t addr,
> >  page = (struct dma_pte *)map_vtd_domain_page(pg_maddr);
> >  pte = page + address_level_offset(addr, 1);
> >
> > -if ( !dma_pte_present(*pte) )
> > +if ( !pte->r && !pte->w )
> 
> I think dma_pte_present() wants to stay, so we would have to touch
> only one place when adding support for x.
> 
> >  {
> >  spin_unlock(&hd->arch.mapping_lock);
> >  unmap_vtd_domain_page(page);
> >  return;
> >  }
> >
> > -dma_clear_pte(*pte);
> > -*flush_flags |= IOMMU_FLUSHF_modified;
> > +pte->r = pte->w = false;
> > +smp_wmb();
> > +pte->val = 0;
> >
> >  spin_unlock(&hd->arch.mapping_lock);
> >  iommu_sync_cache(pte, sizeof(struct dma_pte));
> 
> Just as an observation - in an earlier patch I think there was a
> code sequence having these the other way around. I think we want
> to settle one one way of doing this (flush then unlock, or unlock
> then flush). Kevin?
> 

Agree. Generally speaking 'unlock then flush' is preferred since
spinlock doesn't protect iommu anyway.

> > @@ -1775,15 +1778,12 @@ static int __must_check
> intel_iommu_map_page(struct domain *d, dfn_t dfn,
> >  page = (struct dma_pte *)map_vtd_domain_page(pg_maddr);
> >  pte = &page[dfn_x(dfn) & LEVEL_MASK];
> >  old = *pte;
> > -
> > -dma_set_pte_addr(new, mfn_to_maddr(mfn));
> > -dma_set_pte_prot(new,
> > - ((flags & IOMMUF_readable) ? DMA_PTE_READ  : 0) |
> > - ((flags & IOMMUF_writable) ? DMA_PTE_WRITE : 0));
> > -
> > -/* Set the SNP on leaf page table if Snoop Control available */
> > -if ( iommu_snoop )
> > -dma_set_pte_snp(new);
> > +new = (struct dma_pte){
> > +.r = flags & IOMMUF_readable,
> > +.w = flags & IOMMUF_writable,
> > +.snp = iommu_snoop,
> > +.addr = mfn_x(mfn),
> > +};
> 
> We still haven't settled on a newer gcc baseline, so this kind of
> initializer is still not allowed (as in: will break the build) for
> struct-s with unnamed sub-struct-s / sub-union-s.
> 
> > @@ -2611,18 +2611,18 @@ static void
> vtd_dump_page_table_level(paddr_t pt_maddr, int level, paddr_t gpa,
> >  process_pending_softirqs();
> >
> >  pte = &pt_vaddr[i];
> > -if ( !dma_pte_present(*pte) )
> > +if ( !pte->r && !pte->w )
> >  continue;
> >
> >  address = gpa + offset_level_address(i, level);
> >  if ( next_level >= 1 )
> > -vtd_dump_page_table_level(dma_pte_addr(*pte), next_level,
> > +vtd_dump_page_table_level(pfn_to_paddr(pte->addr), next_level,
> >address, indent + 1);
> >  else
> >  printk("%*sdfn: %08lx mfn: %08lx\n",
> > indent, "",
> > (unsigned long)(address >> PAGE_SHIFT_4K),
> > -   (unsigned long)(dma_pte_addr(*pte) >> PAGE_SHIFT_4K));
> > +   (unsigned long)(pte->addr));
> 
> Could you also drop the no longer needed pair of parentheses. I
> further suspect the cast isn't needed (anymore?). (Otoh I think
> I recall oddities with gcc's printf()-style format checking and
> direct passing of bitfields. But if that's a problem, I think
> one of the earlier ones already introduced such an issue. So
> perhaps we can wait until someone actually confirms there is an
> issue - quite likely this someone would be me anyway.)
> 
> > --- a/xen/drivers/passthrough/vtd/iommu.h
> > +++ b/xen/drivers/passthrough/vtd/iommu.h
> > @@ -244,38 +244,21 @@ struct context_entry {
> >  #define level_size(l) (1 << level_to_offset_bits(l))
> >  #define align_to_level(addr, l) ((addr + level_size(l) - 1) & 
> > level_mask(l))
> >
> > -/*
> > - * 0: readable
> > - * 1: writable
> > - * 2-6: reserved
> > - * 7: super page
> > - * 8-11: available
> > - * 12-63: Host physcial address
> > - */
> >  struct dma_pte {
> > -u64 val;
> > +union {
> > +uint64_t val;
> > +struct {
> > +bool r:1;
> > +bool w:1;
> > +unsigned int reserved0:1;

'X' bit is ignored instead of reserved when execute request is not
reported or disabled.

Thanks
Kevin

> > +unsigned int ignored0:4;
> > +bool ps:1;
> > +unsigned int ignored1:3;
> > +bool snp:1;
> > +uint64_t addr:52;
> 
> As per the doc I look at this extends only to bit 51 at most.
> Above are 11 ignored bits and (in leaf entries) the TM one.
> 
> Considering the differences between leaf and intermediate
> entries, perhaps leaf-only fields could gain a brief comment?
> 
> Jan



RE: [PATCH v4] IOMMU: make DMA containment of quarantined devices optional

2020-11-29 Thread Tian, Kevin
> From: Jan Beulich 
> Sent: Saturday, November 28, 2020 12:46 AM
> 
> Containing still in flight DMA was introduced to work around certain
> devices / systems hanging hard upon hitting a "not-present" IOMMU fault.
> Passing through (such) devices (on such systems) is inherently insecure
> (as guests could easily arrange for IOMMU faults of any kind to occur).
> Defaulting to a mode where admins may not even become aware of issues
> with devices can be considered undesirable. Therefore convert this mode
> of operation to an optional one, not one enabled by default.
> 
> This involves resurrecting code commit ea38867831da ("x86 / iommu: set
> up a scratch page in the quarantine domain") did remove, in a slightly
> extended and abstracted fashion. Here, instead of reintroducing a pretty
> pointless use of "goto" in domain_context_unmap(), and instead of making
> the function (at least temporarily) inconsistent, take the opportunity
> and replace the other similarly pointless "goto" as well.
> 
> In order to key the re-instated bypasses off of there (not) being a root
> page table this further requires moving the allocate_domain_resources()
> invocation from reassign_device() to amd_iommu_setup_domain_device()
> (or
> else reassign_device() would allocate a root page table anyway); this is
> benign to the second caller of the latter function.
> 
> Take the opportunity and also limit the control to builds supporting
> PCI.
> 
> Signed-off-by: Jan Beulich 

Hi, Jan,

Overall this is a nice improvement. Just one comment below...

> ---
> v4: "full" -> "scratch_page". Duplicate Kconfig help text into command
> line doc. Re-base.
> v3: IOMMU_quarantine_basic -> IOMMU_quarantine_fault,
> IOMMU_quarantine_full -> IOMMU_quarantine_write_fault. Kconfig
> option (choice) to select default. Limit to HAS_PCI.
> v2: Don't use true/false. Introduce QUARANTINE_SKIP() (albeit I'm not
> really convinced this is an improvement). Add comment.
> 
> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -1278,7 +1278,7 @@ detection of systems known to misbehave
>  > Default: `new` unless directed-EOI is supported
> 
>  ### iommu
> -= List of [ , verbose, debug, force, required, quarantine,
> += List of [ , verbose, debug, force, required, quarantine[=scratch-
> page],
>  sharept, intremap, intpost, crash-disable,
>  snoop, qinval, igfx, amd-iommu-perdev-intremap,
>  dom0-{passthrough,strict} ]
> @@ -1316,11 +1316,32 @@ boolean (e.g. `iommu=no`) can override t
>  will prevent Xen from booting if IOMMUs aren't discovered and enabled
>  successfully.
> 
> -*   The `quarantine` boolean can be used to control Xen's behavior when
> -de-assigning devices from guests.  If enabled (the default), Xen always
> +*   The `quarantine` option can be used to control Xen's behavior when
> +de-assigning devices from guests.
> +
> +When a PCI device is assigned to an untrusted domain, it is possible
> +for that domain to program the device to DMA to an arbitrary address.
> +The IOMMU is used to protect the host from malicious DMA by making
> +sure that the device addresses can only target memory assigned to the
> +guest.  However, when the guest domain is torn down, assigning the
> +device back to the hardware domain would allow any in-flight DMA to
> +potentially target critical host data.  To avoid this, quarantining
> +should be enabled.  Quarantining can be done in two ways: In its basic
> +form, all in-flight DMA will simply be forced to encounter IOMMU
> +faults.  Since there are systems where doing so can cause host lockup,
> +an alternative form is available where writes to memory will be made
> +fault, but reads will be directed to a dummy page.  The implication
> +here is that such reads will go unnoticed, i.e. an admin may not
> +become aware of the underlying problem.
> +
> +Therefore, if this option is set to true (the default), Xen always
>  quarantines such devices; they must be explicitly assigned back to Dom0
> -before they can be used there again.  If disabled, Xen will only
> -quarantine devices the toolstack hass arranged for getting quarantined.
> +before they can be used there again.  If set to "scratch-page", still
> +active DMA reads will additionally be directed to a "scratch" page.  If
> +set to false, Xen will only quarantine devices the toolstack has arranged
> +for getting quarantined.

Here let's be clear about the quarantine policy when the quarantine
devices are arranged by toolstack. Based on this patch it is the 'basic'
form i.e. always getting IOMMU faults for such devices.

One may further ask whether we should allow toolstack to specify 
the quarantine form for such devices. I don't have a strong opinion
here, as imo the users should be encouraged to always do quarantine
then the toolstack way is more like a

Re: [PATCH v4] IOMMU: make DMA containment of quarantined devices optional

2020-11-29 Thread Jan Beulich
On 30.11.2020 07:13, Tian, Kevin wrote:
>> From: Jan Beulich 
>> Sent: Saturday, November 28, 2020 12:46 AM
>>
>> @@ -1316,11 +1316,32 @@ boolean (e.g. `iommu=no`) can override t
>>  will prevent Xen from booting if IOMMUs aren't discovered and enabled
>>  successfully.
>>
>> -*   The `quarantine` boolean can be used to control Xen's behavior when
>> -de-assigning devices from guests.  If enabled (the default), Xen always
>> +*   The `quarantine` option can be used to control Xen's behavior when
>> +de-assigning devices from guests.
>> +
>> +When a PCI device is assigned to an untrusted domain, it is possible
>> +for that domain to program the device to DMA to an arbitrary address.
>> +The IOMMU is used to protect the host from malicious DMA by making
>> +sure that the device addresses can only target memory assigned to the
>> +guest.  However, when the guest domain is torn down, assigning the
>> +device back to the hardware domain would allow any in-flight DMA to
>> +potentially target critical host data.  To avoid this, quarantining
>> +should be enabled.  Quarantining can be done in two ways: In its basic
>> +form, all in-flight DMA will simply be forced to encounter IOMMU
>> +faults.  Since there are systems where doing so can cause host lockup,
>> +an alternative form is available where writes to memory will be made
>> +fault, but reads will be directed to a dummy page.  The implication
>> +here is that such reads will go unnoticed, i.e. an admin may not
>> +become aware of the underlying problem.
>> +
>> +Therefore, if this option is set to true (the default), Xen always
>>  quarantines such devices; they must be explicitly assigned back to Dom0
>> -before they can be used there again.  If disabled, Xen will only
>> -quarantine devices the toolstack hass arranged for getting quarantined.
>> +before they can be used there again.  If set to "scratch-page", still
>> +active DMA reads will additionally be directed to a "scratch" page.  If
>> +set to false, Xen will only quarantine devices the toolstack has 
>> arranged
>> +for getting quarantined.
> 
> Here let's be clear about the quarantine policy when the quarantine
> devices are arranged by toolstack. Based on this patch it is the 'basic'
> form i.e. always getting IOMMU faults for such devices.

Well, the policy is always as chosen via command line. Therefore do
you perhaps merely mean the default mode to be spelled out? This is
already the case at the beginning of the 2nd paragraph.

> One may further ask whether we should allow toolstack to specify 
> the quarantine form for such devices. I don't have a strong opinion
> here, as imo the users should be encouraged to always do quarantine
> then the toolstack way is more like a niche thing and could be kept
> simple like this patch.

That's certainly a further option, but none I'd like to pursue right
away.

Jan