Commit e4ee544
committed
KVM: guest_memfd: let kvm_gmem_populate() operate only on private gfns
This check is currently performed by sev_gmem_post_populate(), but it
applies to all callers of kvm_gmem_populate(): the point of the function
is that the memory is being encrypted and some work has to be done
on all the gfns in order to encrypt them.
Therefore, check the KVM_MEMORY_ATTRIBUTE_PRIVATE attribute prior
to invoking the callback, and stop the operation if a shared page
is encountered. Because CONFIG_KVM_PRIVATE_MEM in principle does
not require attributes, this makes kvm_gmem_populate() depend on
CONFIG_KVM_GENERIC_PRIVATE_MEM (which does require them).
Reviewed-by: Michael Roth <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>1 parent 4b5f671 commit e4ee544
File tree
3 files changed
+14
-7
lines changed- arch/x86/kvm/svm
- include/linux
- virt/kvm
3 files changed
+14
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2279 | 2279 | | |
2280 | 2280 | | |
2281 | 2281 | | |
2282 | | - | |
2283 | | - | |
2284 | | - | |
2285 | | - | |
2286 | | - | |
2287 | | - | |
2288 | | - | |
2289 | 2282 | | |
2290 | 2283 | | |
2291 | 2284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2449 | 2449 | | |
2450 | 2450 | | |
2451 | 2451 | | |
| 2452 | + | |
2452 | 2453 | | |
2453 | 2454 | | |
2454 | 2455 | | |
| |||
2475 | 2476 | | |
2476 | 2477 | | |
2477 | 2478 | | |
| 2479 | + | |
2478 | 2480 | | |
2479 | 2481 | | |
2480 | 2482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
615 | 616 | | |
616 | 617 | | |
617 | 618 | | |
| |||
665 | 666 | | |
666 | 667 | | |
667 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
668 | 678 | | |
669 | 679 | | |
670 | 680 | | |
671 | 681 | | |
672 | 682 | | |
| 683 | + | |
673 | 684 | | |
674 | 685 | | |
675 | 686 | | |
| |||
681 | 692 | | |
682 | 693 | | |
683 | 694 | | |
| 695 | + | |
0 commit comments