Skip to contentSkip to conversation

Xen 4.0.0x allows for data corruption in Dom0

DISCUSSION Jeremy Fitzhardinge 4 participants 10 messages Mar 8, 2010 – Mar 9, 2010 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 69 lines · Joanna Rutkowska

There is a nasty data corruption problem most likely allowed by a bug in the Xen 4.0.0-x hypervisors.

The problem occurs with a frequency of "a few chunks per 10 GB of data copied", and only when running a VM (PV domU) with a specific kernel. The problem, however, affects not only the VM but also the Dom0, which is of significant importance.

How to reproduce:

1) Start at least one Xen PV VM with a pvops0 kernel. One kernel known to demonstrate the problem is the one built by Michael Young, based on xen/master git from Dec 23. It has recently been replaced by a newer kernel, which doesn't always show the problem, but I uploaded the previous one at the URL below, so people can use it for testing:

http://invisiblethingslab.com/pub/kernel-2.6.31.9-1.2.82.xendom0.fc12.x86_64.rpm

Now you can start a dummy VM with this kernel, e.g.:

# xm create -c /dev/null memory=400 kernel=<path/to/kernel>
extra="rootdelay=1000"

2) Now, in Dom0, after having started this dummy VM, create a big test file, filled all with zeros. Make sure to choose a size bigger than your DRAM size, to avoid fs caching effect, e.g.:

$ dd if=/dev/zero of=test bs=1M count=10000

That should create a 10GB file. Make sure to use /dev/zero and not /dev/null!

3) Once the test file got created, check if it really consists of zeros only:

$ xxd test.bin | grep -v "0000 0000 0000 0000 0000 0000 0000 0000"

Normally you should not get any output. However, I consistently get something like this:

4593a000:940d 0000 0000 0000 2d40 d6fc c803 0000  ........-@......
4593a010:00f6 1f52 b301 0000 b620 dcd5 ff00 0000  ...R..... ......
a5df0000:e542 712c 77da c9f9 a429 4b85 ecc4 9395  .Bq,w....)K.....
a5df0010:d9d6 971f 0d58 5c70 aba6 387d 805f 09e2  .....X\p..8}._..
ceecb000:f80d 0000 0000 0000 096e 1cdc e403 0000  .........n......
ceecb010:2460 7ef6 be01 0000 b620 dcd5 ff00 0000  $`~...... ......
148432000580e 0000 0000 0000 5665 ed9d ff03 0000  X.......Ve......
1484320107bcc a023 ca01 0000 b620 dcd5 ff00 0000  {..#..... ......
1c548b000bc0e 0000 0000 0000 6942 387d 1b04 0000  ........iB8}....
1c548b010872b 01c8 d501 0000 b620 dcd5 ff00 0000  .+....... ......
225d450004448 27cd b966 b37e 1f0c e9e3 c2db b6ee  DH'..f.~........
225d45010d2b2 55b8 9ef1 e818 a7e3 364d 2322 dc75  ..U.......6M#".u
242056000140f 0000 0000 0000 0bb0 3704 3404 0000  ..........7.4...
2420560109601 b606 e001 0000 b620 dcd5 ff00 0000  ......... ......

The actual data vary between tests, however, the "dcd5 ff00 0000" pattern seems to be repeatable on a given system with a given hypervisor binary (the above numbers are for Xen-4.0.0-rc5 built from Michael Young's SRPM). The errors always occur in chunks of 32-bytes.

We have tested this in our lab on three different machines, with various Dom0 kernels -- based on xen/master (AKA xen/stable-2.6.31) and xen/stable (AKA xen/stable-2.6.32) -- and with a few Xen 4 hypervisors (rc2, rc4, rc5). Not every kernel allows for reproducing the error with such a simple "dummy" VM as the one given above -- e.g. the 2.6.32-based kernels required some more regular VMs to be started for the problem to be noticeable. However, with the previously mentioned kernel (M. Young Dec23), the problem has been 100% reproducible us.

Quoted 6 lines

When downgraded to Xen 3.4.2 the problem went away.

Of course this problem cannot be attributed to a buggy VM kernel, as the hypervisor should be resistant to any kind of "wrong" software (buggy or malicious) that executes in a VM.

Why "of course"? You report looks to me like a bug in dom0 which is causing data corruption when there's another domain running. I don't see anything that specifically implicates Xen. The fact that the symptoms change with a different Xen version could mean kernel bug is effected by the Xen version (different memory layout, for example, or different paths in the kernel caused by different feature availability).

J

#2 lore raw
Quoted 73 lines · Jeremy Fitzhardinge
Quoted 72 lines · Joanna Rutkowska

There is a nasty data corruption problem most likely allowed by a bug in the Xen 4.0.0-x hypervisors.

The problem occurs with a frequency of "a few chunks per 10 GB of data copied", and only when running a VM (PV domU) with a specific kernel. The problem, however, affects not only the VM but also the Dom0, which is of significant importance.

How to reproduce:

1) Start at least one Xen PV VM with a pvops0 kernel. One kernel known to demonstrate the problem is the one built by Michael Young, based on xen/master git from Dec 23. It has recently been replaced by a newer kernel, which doesn't always show the problem, but I uploaded the previous one at the URL below, so people can use it for testing:

http://invisiblethingslab.com/pub/kernel-2.6.31.9-1.2.82.xendom0.fc12.x86_64.rpm

Now you can start a dummy VM with this kernel, e.g.:

# xm create -c /dev/null memory=400 kernel=<path/to/kernel>
extra="rootdelay=1000"

2) Now, in Dom0, after having started this dummy VM, create a big test file, filled all with zeros. Make sure to choose a size bigger than your DRAM size, to avoid fs caching effect, e.g.:

$ dd if=/dev/zero of=test bs=1M count=10000

That should create a 10GB file. Make sure to use /dev/zero and not /dev/null!

3) Once the test file got created, check if it really consists of zeros only:

$ xxd test.bin | grep -v "0000 0000 0000 0000 0000 0000 0000 0000"

Normally you should not get any output. However, I consistently get something like this:

4593a000:940d 0000 0000 0000 2d40 d6fc c803 0000  ........-@......
4593a010:00f6 1f52 b301 0000 b620 dcd5 ff00 0000  ...R..... ......
a5df0000:e542 712c 77da c9f9 a429 4b85 ecc4 9395  .Bq,w....)K.....
a5df0010:d9d6 971f 0d58 5c70 aba6 387d 805f 09e2  .....X\p..8}._..
ceecb000:f80d 0000 0000 0000 096e 1cdc e403 0000  .........n......
ceecb010:2460 7ef6 be01 0000 b620 dcd5 ff00 0000  $`~...... ......
148432000580e 0000 0000 0000 5665 ed9d ff03 0000  X.......Ve......
1484320107bcc a023 ca01 0000 b620 dcd5 ff00 0000  {..#..... ......
1c548b000bc0e 0000 0000 0000 6942 387d 1b04 0000  ........iB8}....
1c548b010872b 01c8 d501 0000 b620 dcd5 ff00 0000  .+....... ......
225d450004448 27cd b966 b37e 1f0c e9e3 c2db b6ee  DH'..f.~........
225d45010d2b2 55b8 9ef1 e818 a7e3 364d 2322 dc75  ..U.......6M#".u
242056000140f 0000 0000 0000 0bb0 3704 3404 0000  ..........7.4...
2420560109601 b606 e001 0000 b620 dcd5 ff00 0000  ......... ......

The actual data vary between tests, however, the "dcd5 ff00 0000" pattern seems to be repeatable on a given system with a given hypervisor binary (the above numbers are for Xen-4.0.0-rc5 built from Michael Young's SRPM). The errors always occur in chunks of 32-bytes.

We have tested this in our lab on three different machines, with various Dom0 kernels -- based on xen/master (AKA xen/stable-2.6.31) and xen/stable (AKA xen/stable-2.6.32) -- and with a few Xen 4 hypervisors (rc2, rc4, rc5). Not every kernel allows for reproducing the error with such a simple "dummy" VM as the one given above -- e.g. the 2.6.32-based kernels required some more regular VMs to be started for the problem to be noticeable. However, with the previously mentioned kernel (M. Young Dec23), the problem has been 100% reproducible us.

When downgraded to Xen 3.4.2 the problem went away.

Quoted 7 lines
Quoted 4 lines

Of course this problem cannot be attributed to a buggy VM kernel, as the hypervisor should be resistant to any kind of "wrong" software (buggy or malicious) that executes in a VM.

Why "of course"? You report looks to me like a bug in dom0 which is causing data corruption when there's another domain running.

Please note that the "of course" sentence refers to *VM* kernel not Dom0.

Quoted 6 lines

I don't see anything that specifically implicates Xen. The fact that the symptoms change with a different Xen version could mean kernel bug is effected by the Xen version (different memory layout, for example, or different paths in the kernel caused by different feature availability).

Sure, it can theoretically be anything, perhaps even a generic bug in IA32 just accidentally triggered by some magic value in a register ;) As I said in the first sentence it seems (to me) "most likely" to be a bug in the hypervisor, but there is only one way to find out where it is for sure... (to nail it down (and I'm very sorry that I cannot help with the quest right now))

joanna.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 81 lines · Joanna Rutkowska
Quoted 79 lines · Jeremy Fitzhardinge
Quoted 77 lines · Joanna Rutkowska

There is a nasty data corruption problem most likely allowed by a bug in the Xen 4.0.0-x hypervisors.

The problem occurs with a frequency of "a few chunks per 10 GB of data copied", and only when running a VM (PV domU) with a specific kernel. The problem, however, affects not only the VM but also the Dom0, which is of significant importance.

How to reproduce:

1) Start at least one Xen PV VM with a pvops0 kernel. One kernel known to demonstrate the problem is the one built by Michael Young, based on xen/master git from Dec 23. It has recently been replaced by a newer kernel, which doesn't always show the problem, but I uploaded the previous one at the URL below, so people can use it for testing:

http://invisiblethingslab.com/pub/kernel-2.6.31.9-1.2.82.xendom0.fc12.x86_64.rpm

Now you can start a dummy VM with this kernel, e.g.:

# xm create -c /dev/null memory=400 kernel=<path/to/kernel>
extra="rootdelay=1000"

2) Now, in Dom0, after having started this dummy VM, create a big test file, filled all with zeros. Make sure to choose a size bigger than your DRAM size, to avoid fs caching effect, e.g.:

$ dd if=/dev/zero of=test bs=1M count=10000

That should create a 10GB file. Make sure to use /dev/zero and not /dev/null!

3) Once the test file got created, check if it really consists of zeros only:

$ xxd test.bin | grep -v "0000 0000 0000 0000 0000 0000 0000 0000"

Normally you should not get any output. However, I consistently get something like this:

4593a000:940d 0000 0000 0000 2d40 d6fc c803 0000  ........-@......
4593a010:00f6 1f52 b301 0000 b620 dcd5 ff00 0000  ...R..... ......
a5df0000:e542 712c 77da c9f9 a429 4b85 ecc4 9395  .Bq,w....)K.....
a5df0010:d9d6 971f 0d58 5c70 aba6 387d 805f 09e2  .....X\p..8}._..
ceecb000:f80d 0000 0000 0000 096e 1cdc e403 0000  .........n......
ceecb010:2460 7ef6 be01 0000 b620 dcd5 ff00 0000  $`~...... ......
148432000580e 0000 0000 0000 5665 ed9d ff03 0000  X.......Ve......
1484320107bcc a023 ca01 0000 b620 dcd5 ff00 0000  {..#..... ......
1c548b000bc0e 0000 0000 0000 6942 387d 1b04 0000  ........iB8}....
1c548b010872b 01c8 d501 0000 b620 dcd5 ff00 0000  .+....... ......
225d450004448 27cd b966 b37e 1f0c e9e3 c2db b6ee  DH'..f.~........
225d45010d2b2 55b8 9ef1 e818 a7e3 364d 2322 dc75  ..U.......6M#".u
242056000140f 0000 0000 0000 0bb0 3704 3404 0000  ..........7.4...
2420560109601 b606 e001 0000 b620 dcd5 ff00 0000  ......... ......

The actual data vary between tests, however, the "dcd5 ff00 0000" pattern seems to be repeatable on a given system with a given hypervisor binary (the above numbers are for Xen-4.0.0-rc5 built from Michael Young's SRPM). The errors always occur in chunks of 32-bytes.

We have tested this in our lab on three different machines, with various Dom0 kernels -- based on xen/master (AKA xen/stable-2.6.31) and xen/stable (AKA xen/stable-2.6.32) -- and with a few Xen 4 hypervisors (rc2, rc4, rc5). Not every kernel allows for reproducing the error with such a simple "dummy" VM as the one given above -- e.g. the 2.6.32-based kernels required some more regular VMs to be started for the problem to be noticeable. However, with the previously mentioned kernel (M. Young Dec23), the problem has been 100% reproducible us.

When downgraded to Xen 3.4.2 the problem went away.

Of course this problem cannot be attributed to a buggy VM kernel, as the hypervisor should be resistant to any kind of "wrong" software (buggy or malicious) that executes in a VM.

Quoted 5 lines
Quoted 3 lines

Why "of course"? You report looks to me like a bug in dom0 which is causing data corruption when there's another domain running.

Please note that the "of course" sentence refers to *VM* kernel not Dom0.

OK, but your terminology is imprecise, since dom0 is a "VM" as well. Yes, the domU kernel must be blameless.

Quoted 7 lines
Quoted 7 lines

I don't see anything that specifically implicates Xen. The fact that the symptoms change with a different Xen version could mean kernel bug is effected by the Xen version (different memory layout, for example, or different paths in the kernel caused by different feature availability).

Quoted 6 lines

Sure, it can theoretically be anything, perhaps even a generic bug in IA32 just accidentally triggered by some magic value in a register ;) As I said in the first sentence it seems (to me) "most likely" to be a bug in the hypervisor, but there is only one way to find out where it is for sure...

I think its most likely to be a dom0 bug, specifically a bug in one of the backend drivers. The common failure mode which causes symtoms like this is when a granted page (=a domU page mapped into dom0) is released back into dom0's heap and reused as general memory while still being under the control of the domU.

However, given that the domU hasn't got any devices assigned to it aside from the console, none of the backend should be coming into play. It might be a more general problem with the privcmd interface.

Alternatively, I suppose, the domain builder could end up using some of dom0 pages to construct the domU without properly freeing them, which would suggest a bug in the balloon driver.

I can't think of a Xen failure-mode which would cause these symptoms without also being massively obvious in other cases. (But "I can't think of..." is where all the best bugs hide.)

J

#4 lore raw
Quoted 10 lines · Jeremy Fitzhardinge

I think its most likely to be a dom0 bug, specifically a bug in one of the backend drivers. The common failure mode which causes symtoms like this is when a granted page (=a domU page mapped into dom0) is released back into dom0's heap and reused as general memory while still being under the control of the domU.

However, given that the domU hasn't got any devices assigned to it aside from the console, none of the backend should be coming into play. It might be a more general problem with the privcmd interface.

Quoted 8 lines

Alternatively, I suppose, the domain builder could end up using some of dom0 pages to construct the domU without properly freeing them, which would suggest a bug in the balloon driver.

I can't think of a Xen failure-mode which would cause these symptoms without also being massively obvious in other cases. (But "I can't think of..." is where all the best bugs hide.)

But the corruptions always happen in 32-bytes chunks, which might suggest it's not a page-related problem (e.g. wrongly re-used page), as in that case we would be observing (at least sometimes) much bigger chunks of corrupted data, I think.

The reason why I still believe it's a hypervisor related thing, it that I'm currently using the very *same* Dom0 kernel (very recent xen/stable-2.6.31) with Xen 3.4.2 and the system is damn stable. And I really mean extensive use with 5-7 VMs running all the time doing various things from Web browsing to kernel building.

If I was to make an educated guess I would say it's something related to some interrupt handling, i.e. Xen mishandling it, e.g. the handler is writing out-of-buffer somewhere and it just happens to land in the Dom0 fs buffer used by e.g. dd operation.

joanna.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
Quoted 5 lines · Joanna Rutkowska

But the corruptions always happen in 32-bytes chunks, which might suggest it's not a page-related problem (e.g. wrongly re-used page), as in that case we would be observing (at least sometimes) much bigger chunks of corrupted data, I think.

Given that the domU doesn't have any devices or much going on, it could easily be corrupting memory in only small amounts.

Quoted 6 lines

The reason why I still believe it's a hypervisor related thing, it that I'm currently using the very *same* Dom0 kernel (very recent xen/stable-2.6.31) with Xen 3.4.2 and the system is damn stable. And I really mean extensive use with 5-7 VMs running all the time doing various things from Web browsing to kernel building.

OK, it's always good to get some positive feedback.

Quoted 5 lines

If I was to make an educated guess I would say it's something related to some interrupt handling, i.e. Xen mishandling it, e.g. the handler is writing out-of-buffer somewhere and it just happens to land in the Dom0 fs buffer used by e.g. dd operation.

It would be interesting to see what happens if you write the file with the test domain paused (xm pause ...). If the corruption continues, then it is almost certainly Xen. If it stops, then it either means the corruption was caused by pages inappropriately shared between dom0 and domU, or something like vcpu context switch is corrupting memory (which would be very sad).

J

#6 lore raw
Quoted 10 lines · Jeremy Fitzhardinge
Quoted 5 lines · Joanna Rutkowska

But the corruptions always happen in 32-bytes chunks, which might suggest it's not a page-related problem (e.g. wrongly re-used page), as in that case we would be observing (at least sometimes) much bigger chunks of corrupted data, I think.

Given that the domU doesn't have any devices or much going on, it could easily be corrupting memory in only small amounts.

But see, before I tried this with such a small dummy do-nothing DomU (which I did for the purpose of reporting to xen-devel), I experienced very similar corruption when running regular VMs, i.e. with normal linux and all the usual apps inside them. Same pattern of corruption.

Quoted 9 lines
Quoted 6 lines

The reason why I still believe it's a hypervisor related thing, it that I'm currently using the very *same* Dom0 kernel (very recent xen/stable-2.6.31) with Xen 3.4.2 and the system is damn stable. And I really mean extensive use with 5-7 VMs running all the time doing various things from Web browsing to kernel building.

OK, it's always good to get some positive feedback.

At least one full-time user of the pvops kernel ;)

Quoted 10 lines
Quoted 5 lines

If I was to make an educated guess I would say it's something related to some interrupt handling, i.e. Xen mishandling it, e.g. the handler is writing out-of-buffer somewhere and it just happens to land in the Dom0 fs buffer used by e.g. dd operation.

It would be interesting to see what happens if you write the file with the test domain paused (xm pause ...). If the corruption continues, then it is almost certainly Xen.

Right.

Quoted 5 lines

If it stops, then it either means the
corruption was caused by pages inappropriately shared between dom0 and domU, or something like vcpu context switch is corrupting memory (which would be very sad).

Unfortunately, I cannot do any more tests. We have downgraded all our test machines to Xen 3.4.2 and are using them for other things now. Sorry.

joanna.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#7 lore raw
In reply to Joanna Rutkowska
Quoted 7 lines
Quoted 4 lines

I can't think of a Xen failure-mode which would cause these symptoms without also being massively obvious in other cases. (But "I can't think of..." is where all the best bugs hide.)

But the corruptions always happen in 32-bytes chunks, which might suggest it's not a page-related problem (e.g. wrongly re-used page),

as

Quoted 2 lines

in that case we would be observing (at least sometimes) much bigger chunks of corrupted data, I think.

Based on your hex dump output, it appears to be the first 32 bytes of a page, which does lend itself to the idea that it's a page allocated for something with only the first 32 bytes used.

You've stated that you are no longer set up to reproduce it, which is unfortunate. If you find yourself in a position to try it again there are bunch of things you could try to figure out on which end of the copy the problem lies.

James

#8 lore raw
Quoted 11 lines · James Harper
Quoted 7 lines
Quoted 4 lines

I can't think of a Xen failure-mode which would cause these symptoms without also being massively obvious in other cases. (But "I can't think of..." is where all the best bugs hide.)

But the corruptions always happen in 32-bytes chunks, which might suggest it's not a page-related problem (e.g. wrongly re-used page),

as

Quoted 2 lines

in that case we would be observing (at least sometimes) much bigger chunks of corrupted data, I think.

Quoted 9 lines

Based on your hex dump output, it appears to be the first 32 bytes of a page, which does lend itself to the idea that it's a page allocated for something with only the first 32 bytes used.

You've stated that you are no longer set up to reproduce it, which is unfortunate. If you find yourself in a position to try it again there are bunch of things you could try to figure out on which end of the copy the problem lies.

But everybody can try it with the kernels I provided, right? I'm not the only one person, who can do this...

j.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 10 lines · Joanna Rutkowska
Quoted 6 lines · Daniel Stodden
Quoted 2 lines · Joanna Rutkowska

There is a nasty data corruption problem most likely allowed by a bug in the Xen 4.0.0-x hypervisors.

Joanna, Pasi, which storage backend is hosting your fs's /tmp?

What exactly do you mean? I run the tests in Dom0. Are you asking about the fs?

Uh, oh, I missed the part in your description where you switched back to dom0 after the domU thing.

Daniel