|
2 | 2 | # SPDX-License-Identifier: Apache-2.0
|
3 | 3 | """Basic tests scenarios for snapshot save/restore."""
|
4 | 4 |
|
| 5 | +import platform |
5 | 6 | import filecmp
|
6 | 7 | import logging
|
7 | 8 | import os
|
|
11 | 12 | from pathlib import Path
|
12 | 13 |
|
13 | 14 | import pytest
|
| 15 | +from framework import utils |
14 | 16 |
|
| 17 | +import host_tools.cargo_build as host |
15 | 18 | import host_tools.drive as drive_tools
|
16 | 19 | from framework.microvm import SnapshotType
|
17 | 20 | from framework.utils import check_filesystem, check_output
|
|
29 | 32 | # Kernel emits this message when it resumes from a snapshot with VMGenID device
|
30 | 33 | # present
|
31 | 34 | DMESG_VMGENID_RESUME = "random: crng reseeded due to virtual machine fork"
|
| 35 | +PLATFORM = platform.machine() |
32 | 36 |
|
33 | 37 |
|
34 | 38 | def check_vmgenid_update_count(vm, resume_count):
|
@@ -540,3 +544,41 @@ def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type)
|
540 | 544 |
|
541 | 545 | # Update the base for next iteration
|
542 | 546 | base_snapshot = snapshot
|
| 547 | + |
| 548 | + |
| 549 | +# @pytest.mark.skipif( |
| 550 | +# platform != "aarch64", |
| 551 | +# reason="This is aarch64 specific test.", |
| 552 | +# ) |
| 553 | +def test_physical_couter_reset_aarch64(uvm_nano, microvm_factory): |
| 554 | + """ |
| 555 | + Test that the CNTPCT_EL0 register is reset on VM boot. |
| 556 | + Because we cannot read the CNTVCT_EL0 (Virtual counter) |
| 557 | + from python, we assume the smallesd VM will not consume more than |
| 558 | + MAX_VALUE cycles to be created and snapshotted. |
| 559 | + """ |
| 560 | + vm = uvm_nano |
| 561 | + vm.add_net_iface() |
| 562 | + vm.start() |
| 563 | + |
| 564 | + snapshot = vm.snapshot_full() |
| 565 | + vm.kill() |
| 566 | + snap_editor = host.get_binary("snapshot-editor") |
| 567 | + |
| 568 | + CNTPCT_EL0 = hex(0x603000000013DF01) |
| 569 | + MAX_VALUE = 800_000_000 |
| 570 | + |
| 571 | + cmd = [ |
| 572 | + str(snap_editor), |
| 573 | + "info-vmstate", |
| 574 | + "vcpu-states", |
| 575 | + "--vmstate-path", |
| 576 | + str(snapshot.vmstate), |
| 577 | + ] |
| 578 | + _, stdout, _ = utils.check_output(cmd) |
| 579 | + for line in stdout.splitlines(): |
| 580 | + s = line.split(" ") |
| 581 | + if len(s) == 2: |
| 582 | + reg_id, reg_value = line.split(" ") |
| 583 | + if reg_id == CNTPCT_EL0: |
| 584 | + assert int(reg_value, 16) < MAX_VALUE |
0 commit comments