Commit f2885e0
David Hildenbrand
virtio-mem: kdump mode to sanitize /proc/vmcore access
Although virtio-mem currently supports reading unplugged memory in the
hypervisor, this will change in the future, indicated to the device via
a new feature flag. We similarly sanitized /proc/kcore access recently. [1]
Let's register a vmcore callback, to allow vmcore code to check if a PFN
belonging to a virtio-mem device is either currently plugged and should
be dumped or is currently unplugged and should not be accessed, instead
mapping the shared zeropage or returning zeroes when reading.
This is important when not capturing /proc/vmcore via tools like
"makedumpfile" that can identify logically unplugged virtio-mem memory via
PG_offline in the memmap, but simply by e.g., copying the file.
Distributions that support virtio-mem+kdump have to make sure that the
virtio_mem module will be part of the kdump kernel or the kdump initrd;
dracut was recently [2] extended to include virtio-mem in the generated
initrd. As long as no special kdump kernels are used, this will
automatically make sure that virtio-mem will be around in the kdump initrd
and sanitize /proc/vmcore access -- with dracut.
With this series, we'll send one virtio-mem state request for every
~2 MiB chunk of virtio-mem memory indicated in the vmcore that we intend
to read/map.
In the future, we might want to allow building virtio-mem for kdump
mode only, even without CONFIG_MEMORY_HOTPLUG and friends: this way,
we could support special stripped-down kdump kernels that have many
other config options disabled; we'll tackle that once required. Further,
we might want to try sensing bigger blocks (e.g., memory sections)
first before falling back to device blocks on demand.
Tested with Fedora rawhide, which contains a recent kexec-tools version
(considering "System RAM (virtio_mem)" when creating the vmcore header) and
a recent dracut version (including the virtio_mem module in the kdump
initrd).
[1] https://lkml.kernel.org/r/20210526093041.8800-1-david@redhat.com
[2] dracutdevs/dracut#1157
Signed-off-by: David Hildenbrand <david@redhat.com>1 parent 1799820 commit f2885e0
1 file changed
Lines changed: 124 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
232 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
233 | 239 | | |
234 | 240 | | |
235 | 241 | | |
| |||
243 | 249 | | |
244 | 250 | | |
245 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
| |||
2293 | 2306 | | |
2294 | 2307 | | |
2295 | 2308 | | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
2296 | 2315 | | |
2297 | 2316 | | |
2298 | 2317 | | |
| |||
2521 | 2540 | | |
2522 | 2541 | | |
2523 | 2542 | | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
2524 | 2623 | | |
2525 | 2624 | | |
2526 | 2625 | | |
| |||
2530 | 2629 | | |
2531 | 2630 | | |
2532 | 2631 | | |
2533 | | - | |
2534 | | - | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
2541 | | - | |
2542 | 2632 | | |
2543 | 2633 | | |
2544 | 2634 | | |
| |||
2562 | 2652 | | |
2563 | 2653 | | |
2564 | 2654 | | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
2565 | 2661 | | |
2566 | 2662 | | |
2567 | 2663 | | |
| |||
2640 | 2736 | | |
2641 | 2737 | | |
2642 | 2738 | | |
| 2739 | + | |
2643 | 2740 | | |
2644 | 2741 | | |
2645 | 2742 | | |
| |||
2654 | 2751 | | |
2655 | 2752 | | |
2656 | 2753 | | |
2657 | | - | |
2658 | | - | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
2659 | 2758 | | |
2660 | 2759 | | |
2661 | 2760 | | |
| |||
2732 | 2831 | | |
2733 | 2832 | | |
2734 | 2833 | | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
2735 | 2841 | | |
2736 | 2842 | | |
2737 | 2843 | | |
2738 | 2844 | | |
2739 | | - | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
2740 | 2849 | | |
2741 | 2850 | | |
2742 | 2851 | | |
| |||
2750 | 2859 | | |
2751 | 2860 | | |
2752 | 2861 | | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
2753 | 2865 | | |
2754 | 2866 | | |
2755 | 2867 | | |
| |||
0 commit comments