Repository navigation
[DO NOT REVIEW] cpu_profile: add NVIDIA N1X WHP profile - #5096
Thans (QThans) wants to merge 376 commits into
Conversation
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
|
@microsoft-github-policy-service agree company="MECHREVO" |
Follow-up on the unsafe-code review noticeI checked the Unsafe Check run and the commit boundaries. The workflow completed successfully; its warning marks files for additional review rather than reporting a failed safety test. The workflow scanned 43 Rust files in the full dependent PR and reported:
Both files are inherited from the prerequisite ARM implementation in #5045. They are unchanged between For context, the prerequisite's changes in these two files remove the x86-only conditional on The N1X-specific commit adds the CPU profile, catalog registration, focused tests and hardware notes. It introduces no unsafe blocks or unsafe functions, and does not change the existing WHP FFI implementation or bypass CPU feature validation. I am retaining the Separately, the corporate CLA declaration has been submitted with |
fe61f9c to
1b25c5b
Compare
|
Following Pedro's direction in #5045 (comment), the N1X-only follow-up is now open at ahuja-gautam#1, targeting The new draft retains This original PR remains open as a draft for continuity and tracking; its branch history has not been rewritten. Please review the focused follow-up rather than the prerequisite-inclusive diff here. |
6e5303f to
85c3698
Compare
Add the shared types that the time ABI backends, the CPU profiles, and the core restore path build on, with no behavior change: - virt::time_abi: stable failure codes and errors, declared rates, test hooks, the TSC rate policy and LAPIC tick rule, downtime selection and the restore TSC target, host time samples and identities, the identity CPUID leaves and CPU time bits with a capabilities view that keeps hv1 and kvm_clock false, the identity MSR handler, and the TimeAbiBackend trait. - ProtoPartitionConfig::time_abi, always None for now, and Partition::time_abi, None by default and forwarded by the microVM partition trait. - An empty virt::x86::cpu_profile module for the CPU profile model. - openvmm_defs::time_abi: the manifest time contract and CPU profile record, and the capture and restore payloads. - chipset_resources::microvm_time: the restore packet v4 and time sample codec, with golden vectors. The contract is specified in microsoft/nvx doc/design/time-abi.md. It also includes these changes: - virt: program explicit zero time ABI identity leaves - vmm_tests: give the backend contract tests the chain's partition options - microVM: fix the macOS clippy build Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When ProtoPartitionConfig::time_abi is set (--x-time-abi-v1), the KVM partition implements the time ABI's KVM backend obligations and returns itself from Partition::time_abi: - CPUID: the time ABI CPUID applies after every other source and every KVM hypervisor-range leaf is removed; no frequency leaves are added. Capabilities come from the CPUID with the hypervisor range masked, and KVM_CAP_ENFORCE_PV_FEATURE_CPUID makes KVM's paravirtual MSRs #GP. - Identity MSRs: an MSR filter denies 0x40000000..=0x400001ff and IA32_TSC_ADJUST, and filtered accesses exit to TimeAbiMsrs (or #GP for IA32_TSC_ADJUST, which KVM serves even with its CPUID bit clear). - HV_X64_MSR_TSC_INVARIANT_CONTROL is mirrored into KVM with host-initiated writes after each guest write and before a VP runs, so KVM (6.3+) stops hiding invariant TSC, also after restore and reset. - TimeAbiBackend: native rate from KVM_GET_TSC_KHZ, 1 GHz LAPIC, preflight (offset attribute, equal rates, unscaled TSC), effective CPUID, a capture anchor that pairs VP 0's offset with a host TSC bracket around the host time sample, and a synchronized set that writes one KVM_VCPU_TSC_OFFSET to every vCPU and reads it back. The set supersedes the saved IA32_TSC values, which Linux 6.6 discards for snapshots taken in the guest's first second. The legacy path is unchanged while time_abi is None; with it set, the legacy KVM_SET_TSC_KHZ and KVM_SET_CLOCK entry points fail. It also includes these changes: - kvm: add MSR filter and vCPU attribute helpers Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement virt::time_abi::TimeAbiBackend for MSHV partitions built with ProtoPartitionConfig::time_abi. The backend stays inert until the worker passes a configuration, and every legacy path is unchanged. A time ABI partition: - sets no synthetic processor features, and installs MSR-index intercepts for VP_INDEX, TSC_FREQUENCY, APIC_FREQUENCY, and TSC_INVARIANT_CONTROL, whose exits the shared TimeAbiMsrs handler serves. With synthetic features, the hypervisor serves the first three natively, never delivers their intercepts, and reports this host's TSC rate instead of the declared one; - registers the configured CPUID over its own and drops its own hypervisor-range leaves. Without synthetic features, the hypervisor reports no hypervisor leaf of its own, which preflight checks; - keeps the invariant TSC and hides the TSC-deadline timer, TSC_ADJUST, and APERF/MPERF in processor feature bank 1; and - derives its capabilities with the hypervisor CPUID range masked, so hv1 and kvm_clock stay false. The backend reads F_d from ProcessorClockFrequency and L from ApicFrequency. Preflight checks the identity CPUID that VP 0 reads, and that partition time can be frozen. The capture anchor pairs VP 0's TSC with the midpoint of the tightest of up to 64 bracketing host samples. The synchronized TSC set seals the VP set, freezes partition time, takes the restore anchor, writes the target to every created VP, and reads it back. The first VP run thaws time, and creating a VP afterwards fails with E_VP_LATE_CREATION. Ignored hardware tests exercise every primitive on /dev/mshv and report whether the feature banks can expose BHI_CTRL. It also includes these changes: - virt_mshv: adapt the microVM partition to partition scrub - virt_mshv: adapt the chain to upstream's nested virtualization Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the hidden --x-time-abi-v1 development switch, which selects the NVX time ABI v1 for a microVM cold boot. It exists only on the integration branch: the flip commit removes it with the old path. Under the switch the worker passes the time ABI CPUID and the identity MSR handler to the backend instead of the versioned CPU contract, requires the backend to implement TimeAbiBackend (E_TSC_SYNC_UNSUPPORTED otherwise), applies the rate policy and declares the native TSC rate and the backend LAPIC rate, registers the time-abi state unit that saves HV_X64_MSR_TSC_INVARIANT_CONTROL, and rejects kernel clock tokens instead of injecting them. Snapshot capture and restore under the switch are rejected until the time ABI restore path lands. Also add virt::time_abi::negotiate_rates, which applies the rate policy to a backend for cold boot and restore, and a command-line check for the forbidden clock tokens that follows the kernel's parsing rules. It also includes these changes: - virt: export the time ABI capture-anchor bound - virt_mshv: use the shared capture-anchor bound - virt_kvm: fail loose time ABI anchors and hide IA32_TSC_DEADLINE Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Manifest version 6 (format magic OPENVMM_SNAPSHOT_V6) carries the NVX time ABI records in the machine contract: the time contract (field 31) and the CPU profile record (field 32). It leaves the retired clock fields 11 to 15, 17, and 20 empty and forbids kernel clock tokens. A version 6 contract is validated by the time ABI rules instead of exact clock equality with the destination. Until the time ABI becomes the only microVM path, versions 2 to 5 keep their existing rules and cannot carry the new records, and check_time_abi_manifest_version pairs version 6 with --x-time-abi-v1 (E_SNAPSHOT_VERSION otherwise). Nothing writes version 6 yet. Upstream's decode_manifest_without_snapshot_id checks that an unsupported manifest version fails with a clear error, so it now decodes version 7 rather than version 6. It also includes these changes: - openvmm_helpers: accept dotted CPU profile IDs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Under the NVX time ABI, the microVM portb device serves restore packet version 4 instead of the entropy packets, and a time-sample window: - Selector 0xa5 encodes the packet at its first selection, latching host UTC then; the worker seals the time fields (downtime, its source, the rate deviation, and the test-hook flag) through a oneshot before the first restored VP runs. Status bits 2 to 4 follow the packet. - Selector 0xa7 latches a 16-byte time sample (generation and host UTC) into a window read at the new port 0xeb; status bit 6 advertises it. The window is not saved state. - Selected records and the window accept 1-, 2-, and 4-byte reads, so the guest reads a packet in a quarter of the port exits. Console reads stay one byte. Without the time ABI the device is unchanged. The CLI path enables the time ABI configuration under --x-time-abi-v1 (cold boot only for now); the ttrpc path and petri keep the legacy packets until the flip. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds the CPU surface fingerprint of each backend, the capability queries and probe hook that it needs, and pinned CPU profiles that a time ABI partition selects, verifies, and restores. MSHV records the effective CPUID of VP 0 at reset. Profile checks report every violation, reject ambiguous generations, and pin a generic brand string for each generation. It combines these changes: - kvm, whp: add the capability queries the CPU fingerprint needs - cpu_profile: fingerprint the supported CPU surface of each backend - hypervisor_resources, openvmm_hypervisors: let a probe fingerprint its backend - cpu_profile: pin CPU profiles, and select, verify, and restore them - virt_mshv: record the effective CPUID of VP 0 at reset - cpu_profile: report every violation, and reject ambiguous generations - cpu_profile: pin the generic brand of each generation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Behind --x-time-abi-v1, a restore runs the time ABI preflight, and capture and restore carry the time ABI clocks. The guest resume and repair phases are profiled, restores drop saved per-VP TSC values, and both capture anchors are re-sampled within a bound raised to 100 us. KVM restores write no saved TSC, MSHV resumes partition time right after the TSC read-back, and the fatal error message leads with the time ABI code. It combines these changes: - openvmm: add the time ABI restore preflight behind --x-time-abi-v1 - openvmm_core: gate the microVM's x86_64-only items for aarch64 guests - openvmm: capture and restore the time ABI clocks behind --x-time-abi-v1 - openvmm: profile the time ABI guest resume and repair phases - virt: document bounded re-sampling for both time ABI anchors - openvmm: drop saved per-VP TSC values in time ABI restores - virt_kvm: document that time ABI restores write no saved TSC - virt_mshv: resume partition time right after the TSC read-back - openvmm_helpers: test a time ABI platform snapshot without clock tokens - virt: raise the time ABI anchor bound to 100 us - openvmm_entry: lead the fatal error message with the time ABI code - openvmm_entry: make the fatal error message test backtrace-independent Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement virt::time_abi::TimeAbiBackend for WHP partitions built with ProtoPartitionConfig::time_abi. The backend stays inert until the worker passes a configuration, and every legacy path is unchanged. A time ABI partition: - rejects the Hyper-V guest interface, isolation, nested virtualization, and the user-mode APIC, so WHP sets no synthetic processor features and reports no hypervisor CPUID leaf or synthetic MSR of its own; - sets both processor feature banks explicitly to everything WHP offers minus the TSC-deadline timer, TSC_ADJUST, and APERF/MPERF. WHP's default banks omit SPEC_CTRL, STIBP, SSBD, and PSFD where the host offers them, so they are never used; - exits the topology leaves and every time ABI CPUID leaf except the explicit zero leaves, which WHP answers with zeros natively, and applies the time ABI CPUID after every other source. The build checks that every programmed result exits and that no other result shadows the time ABI's; - routes unhandled MSRs to OpenVMM with the offloaded APIC and serves the identity range from TimeAbiMsrs ahead of every other MSR handler. IA32_TSC_ADJUST, IA32_TSC_DEADLINE, and the legacy L2-cache MSRs that the backend stubs for the PCAT BIOS raise #GP, as on MSHV; - never sets ProcessorClockFrequency, so the guest TSC runs at the host rate, and derives its capabilities with the hypervisor range masked, so hv1 and kvm_clock stay false. F_d is WHvCapabilityCodeProcessorClockFrequency and L is the partition's InterruptClockFrequency (200 MHz on every measured host). Preflight checks the exits, samples the hypervisor range natively, checks that the banks hide the timer features, checks the effective identity and time bits, probes time suspension, and compares the partition TSC rate with the host rate. The effective CPUID is VP 0's view of every programmed leaf (the topology, time ABI, and identity leaves) and of the maximum leaves, with guest CR4, XCR0, and XSS state cleared, computed once. The capture anchor pairs VP 0's TSC with the midpoint of the tightest of up to 64 bracketing host samples. The synchronized TSC set suspends partition time, writes the target to every VP, reads it back while frozen, and resumes partition time before any VP runs. The legacy restored-TSC path is refused on a time ABI partition. Ignored hardware tests exercise the configuration, the native zero leaves, time suspension, the frozen write, and the anchor bracket on WHP. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add --cpu-fingerprint <PATH>, which writes a CPU fingerprint of the host for the backend selected by --hypervisor, or to stdout for "-", and exits without starting a VM. It then checks the fingerprint against the pinned CPU profile of the host's generation, prints one NVX-CPU-PROFILE: line to stderr, and fails with E_PROFILE_HOST_UNKNOWN or E_PROFILE_UNSUPPORTED when no profile serves the host or the backend does not support it, so host qualification can run the check before a CI job. The fingerprint is written first, so hosts of new generations can still be fingerprinted to derive their profiles. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The time ABI configuration carries the selected CPU profile. WHP derives the partition's processor features from it and programs its CPUID leaves with CpuidResultList2. KVM raises #GP for the legacy L2-cache MSRs under the time ABI, and the virt crate documents the order in which the platform calls a backend. It combines these changes: - virt_whp: derive time ABI processor features from a CPU profile - virt: document the time ABI backend call order - virt_kvm: raise #GP for the legacy L2-cache MSRs under the time ABI - openvmm: carry the selected CPU profile in the time ABI configuration - virt_whp: derive processor features from the partition's CPU profile - virt_whp: program the CPU profile's CPUID leaves with CpuidResultList2 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FUSE_LINK to a node whose names the guest had all removed, by FUSE_UNLINK or by a FUSE_RENAME over the last one, linked whatever object had since appeared at the node's former path (microsoft/nvx#1608). It recorded the new name for the node and replied with the node's ID and inode number but that object's attributes, so two nodes stood for one object. The object could be a read-only file, which a link through its own node refuses with EXDEV, since a name in a writable path would make the file writable: through the stale node, the guest could give it one. VirtioFsInode::remove_alias_prefix keeps an inode's path when it removes the last alias, since other requests about the node still use it, and VirtioFsInode::link linked the target at that path without checking that it still names the target's object. VirtioFsInode::object_path returns an inode's path only while the guest still knows a name for its object, and fails with ENOENT once the guest has removed them all. VirtioFsInode::link takes the target's path from it, so FUSE_LINK to such a node fails with ENOENT, as Linux's linkat does for an unlinked file, before it changes the host or the node. The check sits where the path is used rather than in the FUSE_LINK handler, so that the other requests about such a node, which still use its former path (microsoft/nvx#1623), can share it. a_link_to_a_node_whose_names_are_gone_links_nothing removes the last name of a file's node on a microVM share, either by unlinking the file and creating another at its name, or by renaming a host hard link of a read-only file over it, and then links the node. Without the fix, at 2b90ba3, microsoft/nvx#1599's fix on feature/microvm/dev b51f915, on Windows and on a Linux KVM host, both links succeed; with it, both fail with ENOENT, create no host entry, and leave the node without names, and the package's tests pass on both hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM aggregate's file child whose host path was a bare file name, as `seed.txt`, or a symbolic link to a regular file passed MicroVmAggregateChild::validate_root_path, but attaching it failed (microsoft/nvx#1618): for the bare name, with ENOENT on Linux or EINVAL on Windows, and for the link, with EACCES. The child's identity, which microvm_file_identity computes and validate_root_path checks, is that of the file that the path resolves to, from the current directory and through symbolic links, since both canonicalize the path. open_microvm_volume split the path as given instead: it opened the path's parent, which is empty for a bare name, and exposed the path's last name, which names a link rather than its target, so the lstat of the child's root found a symbolic link, which a file child's volume refuses. open_microvm_volume now resolves a symbolic link at the end of a file child's path to its final target, as the identity does, and makes any other path absolute, which keeps the name that the path gives: on Windows, canonicalization would turn a path to the default stream of a file, `file::$DATA`, into the file's, which the name check of microsoft/nvx#1614 would then accept. That check applies to the name that the volume uses, which for a link is its target's, so a link whose own name has a colon attaches, and a link to a file whose name has one is refused. The OpenVMM command line passes canonical paths and refuses links, so it is unchanged, as are directory shares and children, whose volumes open the directories that their paths resolve to. The saved state is unchanged. Tests, in virtiofs' microVM aggregate tests: a file child given by a bare name in the current directory, by `./` and the name, or on Windows by its drive and the name, attaches, and the guest reads it; one given by an absolute, a relative, or a chained link attaches as the link's target, which the guest reads and writes; and a link to a file that the volume cannot name is refused, on Windows a link to a stream, while on Linux a link with a colon in its own name attaches. Without the fix, on top of that of microsoft/nvx#1614, the bare name fails to attach, with EINVAL on Windows and ENOENT on Linux (Azure Linux 3.0, nvx-kvm-test), the links fail with EACCES, and on Linux the link with a colon in its own name is refused for that name. With it, the new tests and the package's other tests pass on Windows, with native symbolic links allowed for the tests that need them, and on Linux. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
FUSE_GETATTR and FUSE_STATX of a microVM aggregate's synthetic root reported a link count of two plus one per child, file children included, so the count disagreed with the root's listing (microsoft/nvx#1632): two file children and a directory child gave 5, where a directory with one subdirectory has 3. A directory's link count is two, for its `.` and the entry that names it, plus one for the `..` of each subdirectory, which find and other fts-based tools use to tell how many subdirectories a directory holds. VirtioFs::synthetic_root_nlink counted every entry of the aggregate's registry, while a read of the root, in VirtioFs::write_child_entry, lists a child that exposes a regular file, a microVM file child, as DT_REG, and every other child as DT_DIR. Count only the children that expose no file, which a read of the root lists as directories. An aggregate without file children, such as any aggregate outside a microVM, reports the same count as before. microvm::aggregate_fs_tests:: synthetic_root_links_only_its_child_directories checks FUSE_GETATTR and FUSE_STATX of the roots of three microVM aggregates, of two file children and a directory child, of the two file children alone, and of two directory children, against two plus the directories that FUSE_READDIR lists: 3, 2, and 4. Without the fix, the test fails on Windows and on Linux (Azure Linux 3.0, nvx-kvm-test), where the first root reports 5; with it, the test and the rest of cargo nextest -p virtiofs pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
In a user namespace whose setgroups file says "allow", as one that newgidmap maps from a subordinate GID range does, a thread with CAP_SETGID there may drop its supplementary groups. getgroups reports each group that the namespace does not map as the kernel's overflow GID, 65534 by default, and setgroups refuses a GID that the namespace does not map, so a thread can never regain such a group once it drops it. with_fs_identity's switch saved the list that getgroups reported, dropped the groups, and restored the list afterwards: with the overflow GID unmapped, the restore failed with EINVAL and the panic of SwitchedCredentials::drop aborted OpenVMM, and with it mapped, the restore replaced the thread's unmapped groups with the one group that the overflow GID maps to. Position 158's switch dropped groups whenever one differed from the target GID, and the overflow GID change for microsoft/nvx#1600 also drops them when the target GID is the overflow GID. A group that may be unmapped can be neither kept, since it may be any group, nor dropped, since the thread could not regain it. The switch therefore takes the groups from mapped_groups, which fails with EPERM before anything changes whenever a supplementary group reads as the overflow GID in a namespace that may not map every group. That refusal covers the case that the overflow GID change drops groups for, so it replaces may_report_other_groups_as and that drop. mapped_groups reads /proc/self/gid_map, about 3.4 us on an Azure Linux 3 test VM, for a thread with supplementary groups, and the initial user namespace, which maps every ID, needs nothing more. In another namespace, it reads the groups again between two reads of the overflow GID, which the administrator may change at any time, and fails unless it can read the overflow GID, both reads agree, and no group has that GID. The virtio-fs Guide says that such a namespace fails every request that runs as its caller. unmapped_groups_fail_closed_with_privilege, which requires CAP_SETGID, gives a child process a group, maps the child's new user namespace without denying setgroups and without that group, and runs the test again as the namespace's root. There, a switch to the child's own identity must fail with EPERM without running the operation, and the child must keep the unmapped group, as chmod's handling of S_ISGID on a file of that group shows, whether the namespace leaves the overflow GID unmapped, maps it to another group, or maps it to the child's own GID; the test reports every layout that fails. Run as root on an Azure Linux 3 VM with kernel 6.18.57 and the default overflow GID, it failed in all three layouts without this change: the first panicked with "failed to restore the thread's supplementary groups: Error(EINVAL (22))", and the others returned Ok(()) rather than EPERM. With the change, it passes. The unprivileged overflow GID test of microsoft/nvx#1600 now fails at the refusal rather than at setgroups. Fold into position 158 at the next reorganization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fsync and fdatasync of a descriptor of an aggregate's synthetic root, as `sync` calls for a directory that it is given, failed with EBADF, which POSIX reserves for a descriptor that is not open (microsoft/nvx#1624). The Linux FUSE client sends both as FUSE_FSYNCDIR, with the node of the directory and the handle that FUSE_OPENDIR returned. FUSE_OPENDIR of the synthetic root returns SYNTHETIC_ROOT_FH, which names no open file, and READDIR, READDIRPLUS, and RELEASEDIR, and GETATTR and STATX through a handle, recognize it with the root's node before they look a handle up. VirtioFs::fsync_dir looked it up in the handle map, found nothing, and failed with EBADF. fsync_dir now succeeds for the synthetic root's handle with the root's node, as release_dir does, before it looks a handle up: the root keeps its entries only in memory, so it has nothing to write back. ENOSYS would not do, since the Linux client takes it for the whole mount and stops syncing the children's directories too. Any other handle or node reaches get_file as before. aggregate::tests::synthetic_root_handle_accepts_fsyncdir checks that FUSE_FSYNCDIR through an aggregate root's handle succeeds with and without FUSE_FSYNC_FDATASYNC, and that the handle with a child's node, and another handle with the root's node, still fail with EBADF. At its parent, 655bc31, the change for microsoft/nvx#1606 on the stack of changes above feature/microvm/dev 3288834, the test fails with EBADF on Windows and on a Linux KVM host; with the fix, it and the rest of cargo nextest -p virtiofs pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM guest could rename a writable directory that holds a denied path, such as logs under --mount-deny logs/secret, and so move the hidden entries to a visible path (microsoft/nvx#1601). There the guest could list and remove them, and open an object that the host had created at the denied path after attaching the share, which HostFs had not pinned. A RENAME_EXCHANGE on a Linux host did the same with the directory as either name. Conversely, once the host had removed such a directory, the guest could rename one of its own onto that name and so put its entries at the denied path, where it cannot create them itself. VirtioFs::rename checked only that the guest may modify the two names that it renames, but a rename also moves everything below its source to its destination, or for an exchange swaps everything below both, and the access policy can hide a path below a writable one. A rename now also requires that the guest may modify every path below both names, and otherwise fails with EROFS before the host changes anything, as the other writes that the policy refuses do. SubtreePolicy::is_subtree_writable decides it: below a writable path, only a denied path hides or protects anything, since an allowed path lies inside a denied one, and a writable path that contains a path contains everything below it. A rename of a name onto itself with a denied path below it fails as well, as any rename does on a read-only share. The Guide describes the restriction. renames_never_move_a_denied_path, in virtiofs' microVM policy tests, renames a directory that holds a denied path, and exchanges it as either name, and renames a directory that holds a denied path inside an allowed path. It checks that each fails with EROFS and changes nothing, and that renames that move no denied path still succeed. renames_never_move_entries_into_a_denied_path renames a guest directory onto the name of a directory that holds a denied path, after the host removed it. A unit test of SubtreePolicy covers nested denied and allowed paths, writable paths, and names that only share a prefix with a denied path's ancestor. Without the fix, both microVM tests fail on Windows and on Linux, where the renames succeed. A scratch test then found the hidden secret listed under each new name, including after either exchange on Linux, and the guest's file at logs/secret; on Windows, the guest also read and removed a secret that the host had recreated after attaching the share. With the fix, the tests and the package's other tests pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Windows reaches a directory entry not only by its own name, but also by that name in another case, unless the directory is case sensitive, and by the 8.3 short name of a long name. A caller that checks host paths against names, such as the access policy of a microVM virtio-fs share, cannot tell from a path alone which entry it reaches or what that entry's own name is. Add LxVolume::stored_path on Windows. It opens the entry that a path reaches without access, exactly as the other operations resolve the path, so the open neither conflicts with other opens nor breaks their oplocks, and queries its FileNormalizedNameInformation: the path from the volume's root with the long name of each component as the file system stores it. The final components of that path are the stored names of the given path's components, and a missing entry yields None. The query grows its buffer when Windows reports a longer name. Tests, in lxutil on Windows: a path reaches its entry's stored names through a name in another case and through a hard link's own name, a missing entry or ancestor yields None, and on a volume that generates 8.3 short names, as this host's temporary directory does, a short name in either case yields the long name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A Windows host resolves a name in another case to the entry of that name, unless the directory is case sensitive, but a microVM share's SubtreePolicy matched the guest's names against its denied, allowed, and writable paths byte for byte (microsoft/nvx#1603). A name that differed from a protected path only in case therefore passed every policy check and reached the protected entry. With denied_paths = ["marker"] on a read-write share, FUSE_UNLINK of "MARKER" deleted the host's marker; FUSE_RENAME of "LOGS", a traverse-only directory, moved it to a visible name that exposed its hidden entries; and once the host had removed marker, FUSE_CREATE of "MARKER" created the file that the host then opens as marker. A rename also escaped the check that no denied path lies below its source or its destination: with denied_paths = ["logs/secret"], FUSE_RENAME of "LOGS" moved logs, with its hidden secret, to a visible name. Pinned identities could not help: they reject only objects that existed at attach time, and only at lookup. On Windows, SubtreePolicy::visibility, and with it is_writable and every check of VirtioFsVolume, now also matches the policy's paths ignoring case and keeps the more restrictive result. A name that matches a denied path in another case is hidden as the path is, and one that matches a traverse-only directory is traverse-only, so it fails before the host operation as the path's own name does. And is_subtree_writable, which the source and the destination of a rename must pass, also finds the denied paths below a name in another case. Grants never follow another case: such a name exposes no allowed path and makes no writable path writable, so a case-sensitive directory can only hide more. Names match ignoring case when Unicode's full upper-case mappings agree, which equates every pair that a Windows upcase table of simple mappings does, and a few more, which only hide more. The validation of a policy and the identities pinned at attach time still compare the canonical paths exactly, and Linux hosts, which resolve names exactly, keep matching them exactly. Tests: SubtreePolicy unit tests of both name matchings, including non-ASCII letters, a denied and an allowed path that differ only in case, and a denied path below a name in another case; and, in the microVM policy tests on Windows, a denied file in another case fails like its own name for FUSE_UNLINK, FUSE_RENAME of and onto it, FUSE_CREATE, and FUSE_LOOKUP; a denied file that the host removes and recreates cannot be planted, made, or linked in another case, nor looked up or probed by an exclusive create; a traverse-only directory in another case, at the root or inside a writable path, can be neither renamed nor removed; and a directory that holds a denied path can be neither renamed in another case nor, once the host has moved it away, replaced by a guest directory renamed onto its name in another case. Without the fix, on Windows, FUSE_UNLINK of "MARKER" deletes the denied file, FUSE_CREATE of "MARKER" plants a file at the denied path, and FUSE_RENAME of "LOGS" moves both the traverse-only directory and a directory that holds the denied logs/secret; with it, these tests and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A Windows host also resolves the 8.3 short name of a long name, and a name in another case, to the entry. A microVM share's access policy and the names that the guest knows for an object are exact names, so such a name reached an entry that the policy protects under its own name (microsoft/nvx#1603). With denied_paths = ["credentials.json"], whose short name is CREDEN~1.JSO, FUSE_UNLINK and FUSE_RENAME of CREDEN~1.JSO deleted or moved the denied file, FUSE_RENAME onto it replaced it, and once the host had recreated the file, so that no pinned identity covered it, FUSE_LOOKUP and FUSE_CREATE with O_TRUNC of CREDEN~1.JSO exposed and truncated it; at attach time, the pinned identity answered EACCES where a missing name answers ENOENT. A node also kept reaching whatever its name came to reach: after the guest removed its own file named CREDEN~1.JSO and the host recreated the denied file, which took that short name, the guest's node of the removed file opened the denied file. And a name in another case became a name of the object that the policy checks writes through: after FUSE_LOOKUP of "OUT" inside a share whose writable path is out, the guest could no longer create in out. On a strict volume on Windows, the guest now reaches an existing entry only by the names that Windows stores for it, as on Linux. LxVolume::stored_path gives the stored names of the entry that a path reaches. Lookup, unlink, rmdir, and the source of a rename of a guest-supplied name that reaches an entry by other names fail with ENOENT, as for a missing name, and a create that may open an existing entry, without O_EXCL, and the target of a rename, which it would replace, fail with EACCES. A rename of an entry to its own name in another case changes the case of that name. Every operation on a node also checks its names before it reaches the host, and fails with ENOENT once they reach an entry by other names, as after the host changes the case of one; this also holds for the names of a restored node. Lookup checks a name only after the host finds an entry, so a missing name costs nothing more, and before it checks the object against the pinned identities, so a short name of a denied file answers ENOENT whether or not the file exists. An exclusive create, mkdir, mknod, symlink, or link under another name of an existing entry already fails with EEXIST, as Windows refuses it, and READDIRPLUS looks its children up by the names that the host lists, which are their own names, and revalidates their identities, so neither checks a name. Other hosts resolve names exactly, so nothing changes there. A file that denies the VMM's user SYNCHRONIZE access, which every other operation on the file already needs, can no longer be looked up, since the check opens it. Tests, in the microVM policy tests on Windows: names in another case reach no entry, neither remove, move, nor replace one, and no longer make a writable directory read-only, while a rename to an entry's own name in another case renames it; and, on a volume that generates 8.3 short names, as this host's temporary directory does, a short name of a denied file or of a visible one reaches no entry, before and after the host recreates the denied file, a node whose name became the recreated file's short name can neither open nor inspect it, and the file is unchanged. Without the fix, on Windows, FUSE_UNLINK of CREDEN~1.JSO deletes the denied file and FUSE_LOOKUP of "OUT" succeeds, and without the check of a node's names, the node opens the recreated file; with it, these tests and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An aggregate's file child exposes the file that its host path names by the path's last name, which the device keeps as given rather than canonicalizing it (microsoft/nvx#1618), and which the child's identity accepts, since it canonicalizes the path. On Windows, that name may be the file's own name in another case or its 8.3 short name, which Windows resolves to the file. Since every operation on a microVM node checks that its names are the ones under which Windows stores its entry (microsoft/nvx#1603), every operation on such a child failed with ENOENT, although the guest never chose the name. A volume that exposes a file reaches nothing else, so the guest names nothing in it, and only the host chose the name by which it reaches the file. The check of stored names now skips such a volume. OpenVMM's command line and NVX canonicalize a file child's path, which gives the stored names, so they were unaffected. Tests, in the aggregate tests on Windows: a file child attached by its file's name in another case, and, on a volume that generates 8.3 short names, by its short name, reads and writes the file. Without the fix, on Windows, reading the child fails with ENOENT; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On a strict volume on Windows, the check of a rename's names checked its target only when its source existed: without a source, it passed the rename on to the host, which fails it. But the guest's requests run concurrently, so the guest could create the source between the check and the host's rename, which then replaced whatever another name of the target reached, such as a denied file through its 8.3 short name (microsoft/nvx#1603): on the host, a replacing rename of staging onto CREDEN~1.JSO leaves credentials.json with the content of staging. The check now fails a rename without a source itself, with ENOENT, as the host would, so no rename reaches the host with its target unchecked. Whether a volume checks the names at all is now asked of checks_stored_names, rather than inferred from a missing stored path, which also stands for a missing entry. Tests, in the microVM policy tests on Windows: the check of a rename from a missing source, onto a denied file's short name or onto another name, fails with ENOENT. Without the fix, on Windows, it passes; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
READDIRPLUS reads a directory's entries from the snapshot that its first read takes, and the third commit had it look the listed names up without checking that each is the name under which Windows stores its entry, since the host had listed it. But a later read can list a name whose case has changed since the snapshot, which Windows still resolves to the entry (microsoft/nvx#1603). After a rename of new to NEW, the read handed the guest a node of new, whose every request then failed with ENOENT; and once the host had replaced old with another file named OLD, the read failed at old with EIO, since the name reached another object than the one listed, and so did every later read, which starts there. READDIRPLUS looks the names up with the checked lookup_child again, so such a name fails with ENOENT, and the read skips it, as it skips a name that is gone. The unchecked lookup_listed_child goes. On a Windows host, each listed entry costs another open, which queries its stored name. A Copilot review of microsoft/nvx#1963 found this. Tests, in the microVM policy tests on Windows: READDIRPLUS reads after the host renamed new to NEW and replaced old with OLD list none of them. Without the fix, on Windows, the reads fail with EIO; with it, the test and the package's others pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A handle map handed out u64::MAX as its last handle (microsoft/nvx#1627). An aggregate's synthetic root uses u64::MAX as its directory handle, SYNTHETIC_ROOT_FH, on the documented assumption that no real handle takes it, so a child's file or directory that got it shared its handle with the root: a RELEASE that names the root's node and handle, which a client sends for a file rather than a directory, closed the child's descriptor, since closing a handle does not check its node. A map that handed out u64::MAX also wrapped its next handle to 0, which a microVM save then recorded and every restore rejects as an invalid allocation state, so the VM could no longer be restored, for node IDs as for file handles. HandleMap::can_insert, which insert and reserve check, refused only a next handle of 0, the wrapped one. Live requests would take some 2^64 allocations to reach u64::MAX, but a microVM restore accepts any next handle or node ID above the saved ones, u64::MAX included, and the next OPEN, OPENDIR, or CREATE, or LOOKUP of a new object, then got u64::MAX. Refuse a next handle of u64::MAX too, so that a map whose next handle reaches it is full: the request that needs another handle or node fails with ENOSPC, as at any other exhaustion, and the map's next handle stays u64::MAX, which a save records and a restore accepts. No restored handle or node can hold u64::MAX, since a restore requires every saved ID below the next one, so the saved state and its schema are unchanged. handle_map_stops_after_max_handle now checks that a map hands out u64::MAX - 1 as its last handle and that a map that starts at u64::MAX, as a restored one can, is full; the reservation tests that started at the last handle start at u64::MAX - 1. In microvm::aggregate_fs_tests, children_never_get_the_synthetic_root_handle restores an aggregate whose next handle ID is u64::MAX and checks that OPEN, OPENDIR, and CREATE in a child fail with ENOSPC and leave the host unchanged, that the root's handle still lists the root, and that the state saves and restores again; in microvm::fs_tests, largest_restored_next_node_id_is_never_handed_out does the same for a LOOKUP with the largest next node ID. On 7671411, where microsoft#5224 (microsoft/nvx#1603) landed, with the fix reverted, the HandleMap test gets u64::MAX, the aggregate test gets handle u64::MAX for the child's file, the node test gets node u64::MAX, and unused_reservations_release_on_drop reserves u64::MAX; a probe there also showed that the save that followed recorded a next handle ID of 0, which the restore rejected, and that a RELEASE of the root's handle closed the child's. With the fix, they and the rest of cargo nextest -p virtiofs pass on Windows and on a Linux KVM host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A reset or FUSE_DESTROY of a restored microVM filesystem numbered its handles from the saved next handle ID again, rather than from 1 as a new filesystem does, so the handle IDs that the saved state had used stayed used after the guest remounted (microsoft/nvx#1627). With the largest next handle ID, u64::MAX, which the previous commit leaves a full table, every OPEN, OPENDIR, and CREATE of the remounted guest failed with ENOSPC. VirtioFs::restore_microvm_state built the handle table with HandleMap::starting_at(next_handle_id), which also made that ID the table's first handle, to which HandleMap::clear returns. The node table keeps a new table's first ID and takes only the saved next one. Build the handle table the same way: a new table whose next handle is the saved one. Restored handles and the handles that follow them are numbered as before, and the saved state is unchanged. microvm::fs_tests::destroy_restarts_restored_ids_from_the_start restores an initialized session whose next node and handle IDs are u64::MAX, checks that an OPEN fails with ENOSPC, ends the session as a device reset or FUSE_DESTROY does, and checks that a LOOKUP then gets node 2 and an OPEN handle 1. On 7671411 under the previous commit, the OPEN after the reset fails with ENOSPC; with the fix, the test and the rest of cargo nextest -p virtiofs pass on Windows and on a Linux KVM host. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Windows, LxVolume::open asked for FILE_WRITE_DATA whenever the open flags held O_TRUNC, since Windows truncates only through a handle with write access, and the LxFile then kept that handle, and recorded that access, for its lifetime. So the file that an O_RDONLY | O_TRUNC or O_NOACCESS | O_TRUNC open returned could be written with pwrite and truncated with set_attr, unlike a Linux descriptor with the same flags, which fails such a write with EBADF and such a truncation with EINVAL; and O_APPEND | O_TRUNC got FILE_WRITE_DATA back, so its writes went to their offsets rather than to the end of the file. A virtio-fs guest could thus keep writing a file through a handle that it had opened read-only (microsoft/nvx#1609), and a microVM restore, which reopens the handle without O_TRUNC, silently took that access away. open_flags_to_access_mask now derives the access of the open file from its access mode and O_APPEND alone. LxVolume::open truncates an existing file through the file's handle when that access includes FILE_WRITE_DATA, and otherwise through a handle reopened with FILE_WRITE_DATA for the truncation alone, which it then closes. The open still needs write access to truncate, as on Linux, and fails with EACCES without it. truncating_open_keeps_the_access_mode opens an existing file with O_RDONLY | O_TRUNC and with O_NOACCESS | O_TRUNC, and creates one with O_RDONLY | O_CREAT | O_TRUNC, and checks that each open leaves the file empty but that a pwrite through it fails with EBADF and a truncate with EINVAL. truncating_append_open_stays_append_only checks that two writes at offset 0 through O_WRONLY | O_APPEND, with and without O_TRUNC, both append. Without the fix, at feature/microvm/dev b51f915 on Windows, the pwrite through the O_RDONLY | O_TRUNC file succeeds, and the writes through the O_WRONLY | O_APPEND | O_TRUNC one overwrite each other; with it, both tests and the package's others pass there. Both pass on Linux (Azure Linux 3.0, nvx-kvm-test) with and without the fix, since the host kernel gives a descriptor these semantics. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
VirtioFs::write checked whether the guest may write the handle's file, which fails with EROFS on a read-only share or outside a microVM's writable paths, and then wrote through the handle, leaving it to the host to refuse a handle that the guest had not opened for writing. So a FUSE_WRITE through an O_RDONLY handle of a file that the guest may not write failed with EROFS on every host, where Linux's write(2) fails with EBADF first (microsoft/nvx#1609), and whether a write through such a handle of a writable file failed depended on the host's handle, which a Windows host opened with write access for O_RDONLY | O_TRUNC until the previous commit. write now fails with EBADF before it checks whether the guest may write the file, unless the access mode of the guest's open flags, which the handle records and a microVM snapshot saves, is O_WRONLY or O_RDWR. A guest kernel writes only through handles that it opened for writing, so only a guest that drives the queue itself can see the change. writes_need_a_handle_open_for_writing, in a microVM share whose only writable path is out, writes through handles of out/existing that FUSE_OPEN opened O_RDONLY and O_RDONLY | O_TRUNC, of a new file that FUSE_CREATE opened O_RDONLY | O_CREAT | O_TRUNC, and of build.log that FUSE_OPEN opened O_RDONLY, and checks that each write fails with EBADF and changes nothing, while a write through an O_WRONLY handle succeeds. Without the fix, at feature/microvm/dev b51f915, the write through the O_RDONLY | O_TRUNC handle succeeds on Windows, and the write through build.log fails with EROFS on Linux (Azure Linux 3.0, nvx-kvm-test) and, once the previous commit refuses the first, on Windows; with it, the test and the package's others pass on both. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A request about a node whose names the guest had all removed, by FUSE_UNLINK, FUSE_RMDIR, or a FUSE_RENAME over the last one, acted on whatever object had since appeared at the node's former path (microsoft/nvx#1623). Through such a file node, GETATTR and STATX reported that object's attributes under the node's inode number, OPEN opened it, SETATTR truncated it or changed its mode, and the extended attribute requests read and changed its attributes. Through such a directory node, OPENDIR listed that directory, and LOOKUP, CREATE, MKDIR, MKNOD, SYMLINK, LINK, UNLINK, RMDIR, and RENAME looked up, created, moved, and removed its entries. The object could be a read-only file whose host hard link inside a writable path the guest had renamed over the node's name: the node, writable through its former name, then truncated the file, which a request through the file's own node refuses with EROFS. VirtioFsInode::remove_alias_prefix keeps an inode's path when it removes the last alias, and every path-based operation of VirtioFsInode used that path, except VirtioFsInode::link, which microsoft/nvx#1608's fix made take its target's path from VirtioFsInode::object_path, which fails with ENOENT once the guest knows no name for the object. Every other operation of VirtioFsInode that reaches its object by its path now takes the path from object_path too: object_stat, get_attr, get_statx, set_attr, open, read_link, stat_fs, get_xattr, set_xattr, list_xattr, remove_xattr, and check_directory_handle; and so does child_path, through which lookup_child, create, mkdir, mknod, symlink, link, unlink, and rename reach a directory's entries. A request about such a node that names no handle thus fails with ENOENT, as one through an unlinked file's former name does, and as Linux refuses to look up, create, or list entries of a removed directory, while requests through the node's open handles, which VirtioFs::get_file serves without a path, still reach its object. object_path now checks that the path is one of the names that the guest knows, rather than that there is one. VirtioFsInode::add_alias, which records a FUSE_LINK's name after the host link, makes that name the path when the path no longer is one, as when a FUSE_UNLINK of the node's other name on another request queue records its removal first; object_path would otherwise use the removed name, or now fail. The microVM profile's confinement check, which validated the former name as well because operations used it, thus validates only the names, so the former name no longer decides whether a request about the node fails, or with which error. a_file_whose_names_are_gone_is_reached_only_through_its_handles and a_directory_whose_names_are_gone_reaches_no_entry remove the last name of a file's and a directory's node, on a share with and without the microVM profile, either by unlinking or removing it and creating another at its name, or by renaming another entry over it, and send every request about the node that names no handle. a_link_that_an_unlink_of_the_other_name_overtakes_keeps_the_new_name records the removal of a node's other name before a link's new name. Without the fix, at e3b20ae, microsoft/nvx#1609's fix, which stacks on microsoft/nvx#1608's, on Windows and on a Linux KVM host, every request of the first two tests but FUSE_LINK reaches the new object: READLINK and GETXATTR fail with its errors, EINVAL and ENODATA, and the others succeed, so the file node truncates the file renamed over its name, which the microVM share makes read-only; and the third test's node keeps the removed name. With the fix, each request fails with ENOENT and changes nothing, the node's handle still reads and stats its file, the linked node reaches its object through the new name, and the package's tests pass on both hosts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM directory handle numbers each entry of its snapshot as the host lists it, by d_ino, and READDIRPLUS failed with EIO at an entry on the directory's own device whose lookup reported another number, as at a name that a rename replaced since the listing. But the host lists some entries on a directory's own device by another number than a lookup reports (microsoft/nvx#1605). A btrfs snapshot of a subvolume that holds a nested subvolume holds an empty placeholder for it, which the snapshot lists by the nested subvolume's ID while a lookup reaches a directory numbered 2 on the snapshot's device; and a directory lists a mount point of its own filesystem, such as a bind mount of one of its directories, by the number of what the mount covers. A guest therefore could not list such a directory with READDIRPLUS, which the microVM profile negotiates and the guest uses for ls, find, and the like. The root of a btrfs subvolume, which lies on a device of its own, has listed since microsoft/nvx#1619. When the lookup of an entry on the directory's device reports another number than the snapshot's, READDIRPLUS now checks that the inode's path, at which the lookup resolved the name, still reaches the handle's directory, and lists that directory again as a snapshot lists it, within the same bounds, at most once per read. It lists the entry, as its lookup reports it, if the host still lists the entry by the snapshot's number. It still fails with EIO if the host lists the entry by another number, as after a rename over it, or by the number 0, which identifies nothing, or if another directory took the listed one's path. An entry that the host no longer lists is gone, so READDIRPLUS skips it, as it skips one whose lookup fails with ENOENT. As at a mount point of another device, a lookup of a mount point reaches whatever is mounted on it then. Tests, in virtiofs' microVM tests: on Linux, a READDIRPLUS of a directory that holds a bind mount of another of its directories, made in user and mount namespaces of the test's own, lists the mount point with the number that its lookup reports; and a READDIRPLUS still fails with EIO at an entry that a rename replaced since the listing, and at an entry of a directory that took the listed one's path. No test host has btrfs, so the bind mount, which the host lists and looks up as it does a placeholder, stands in for one. Without the fix, at eff41b1 (the microsoft/nvx#1623 fix) on Linux (Azure Linux 3.0, kernel 6.18), the first fails with EIO; with it, the three and the package's other tests pass on Windows and on Linux, with TMPDIR on tmpfs and on ext4. Without the check of the inode's path, the third fails, and without any check, as the issue proposes, the last two fail. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A microVM READDIRPLUS looks each name of its directory listing other than . and .. up, and a lookup that reaches the object of a node returns that node, with one more lookup reference and with the name's path as the node's path. A listed name can reach the object of the very node whose handle the guest lists (microsoft/nvx#1634): a bind mount of a directory on one of its own subdirectories does, and so does the node's directory once the host moves it into a new directory at the node's path, since a handle that the guest then opens on the node lists that new directory. READDIRPLUS then handed the guest the listed node as an entry below itself, which the guest cannot hold, and moved the node to the name's path, at which it looked the rest of the listing up: in the moved directory, which lacks the listed names, so READDIRPLUS dropped them as gone, or through the bind mount, so that the node, even the share's root, stayed at a path that names another directory once the host unmounts the bind mount. write_microvm_entry_plus now checks, after the lookup and the check that the name still reaches the listed object, whether the lookup reached the object of the handle's node, by the dedup key and file type by which the inode map would alias it. Such an entry hands the guest no node, which FUSE allows for a READDIRPLUS entry, as for . and .., so it takes no lookup reference and leaves the node as it was, and it lists the name as READDIR does, by the listed number and type. The issue proposes to forget the entry's reference and stop the listing, with EIO if the entry is the first of a read; but the lookup has moved the node by then, and since each later read starts at the entry, the guest could never list the rest of the directory. Tests, in virtiofs' microVM tests: a READDIRPLUS of the directory that the host made at a node's path, which lists the node's moved directory before a file, lists both, the moved directory without a node, and leaves the node's path, aliases, and lookup count as they were; and, on Linux, a READDIRPLUS of a share whose root is bind mounted on one of its own subdirectories, in user and mount namespaces of the test's own, lists the mount point without a node, by its READDIR number and type, and leaves the root at its path. Without the fix, on top of the microsoft/nvx#1605 fix, the first lists no file on Windows and on Linux (Azure Linux 3, kernel 6.18, tmpfs and ext4), and on Windows it hands the moved directory the listed node and moves the node to listed\moved with two lookups; the second hands the mount point the root's node and moves the root to loop. With the fix, both and the package's other tests pass there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add the profile-owned ARM64 microVM boot, fixed device and platform-control integration using the existing loaders, device tree and shared device abstractions. Add governed ARM CPU/time admission with native WHP programming and readback, retaining the legacy fingerprint API and x86 behavior. Keep the qualified PA36 contract and cold-boot-only boundary; ARM snapshot capture and restore remain unavailable. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Extend the existing --x-time-abi-verify lifecycle to ARM64 using one shared TimeAbiReport and the existing native admission checks. Report the selected profile, effective register checks and actual WHP address, feature-bank and counter-frequency readbacks without executing the guest. Keep x86 output compatible, reject unsupported ARM fault-injection hooks, and fail closed on missing evidence. This does not establish UTC synchronization or clock authority. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the shared CPU/time report and sample-field conversion within the architecture-selected adapter. Restore native type and clock-status import ownership so target-branch clock changes merge without conflict, retaining one shared report and unchanged field conversion and runtime behavior. No target commits or time-policy changes are incorporated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Admit the two observed N1X CPU part numbers through a pinned ARM64 profile while retaining the existing WHP feature and state checks. A single-part profile fails when a retained VP exposes the other core type on this heterogeneous host. Validate the configured ID-register surface on all 20 logical CPUs of a MECHREVO N1X Spark with NVIDIA N1X, and document the hardware observations and cold-boot qualification limits. Test both MIDRs, exclude every other part number, and verify the WHP feature-bank translation and unavailable-feature rejection. Depends on the ARM cold-boot implementation in microsoft#5045.
Pin the expected canonical digest and model mask, reject a different implementer or architecture, and use the measured 39-bit native WHP GPA limit in the backend test fixture. The guest address contract remains 36 bits. This changes tests only.
9e138af to
f11368e
Compare
09524b7 to
899dcd6
Compare
ee66d23 to
10fc4d8
Compare
Refs #5045 and microsoft/nvx#1516.
This draft tracks the focused N1X PR against the ARM branch from #5045. Both PRs share head
f11368e37. Relative toc3089ff90, the N1X contribution is two commits and four files. This draft also shows the ARM prerequisite relative to the Microsoft target. The prerequisite retains its original authorship and MIT license notices.What and why
Add a pinned
nvidia.n1x.v1ARM64 CPU profile for NVIDIA N1X, validated on a MECHREVO N1X Spark running Windows with Windows Hypervisor Platform (WHP).The existing ARM catalog does not admit this host. A profile restricted to the first observed MIDR also fails when a later virtual processor exposes the other core type:
ARM model mismatch: VP 0 MIDR=0x410fd871.A thread-affinity scan of all 20 logical processors observed ten instances each of
0x410fd851and0x410fd871. After applying the same restricted WHP feature banks and 36-bit address contract, all 15 configured architectural ID registers matched across the scan. The new model mask admits exactly Arm parts0xd85and0xd87for implementer0x41, architecture0xf, while ignoring variant/revision. An exhaustive test excludes the other 4,094 part numbers.The change adds the profile, registers it for
autoand explicit selection, and tests its model bounds, fixed canonical digest, digest/state validation, WHP feature translation and missing-feature rejection. The backend test records the measured 39-bit native WHP GPA limit while retaining the 36-bit guest contract. It retains the existing backend checks and state policy; it neither spoofs MIDR nor bypasses feature verification. Hardware observations and qualification limits are documented next to the profile.The focused PR records validation of the November 23 replay. The hardware and boot results below describe the original November 14 qualification.
Tested hardware
NVIDIA RTX Spark N1X10.0.28000.3231Validation
Executed on the native Windows ARM64 host with Rust 1.97.1:
All commands completed successfully. The check, Clippy, rustdoc, test and formatting commands were rerun for the test-only follow-up
229ecb91b. The release build and runtime results apply to the original adaptation; the follow-up changes no production code. Package tests: 135 CPU-profile tests and 11 WHP tests passed; two existing explicitly ignored native diagnostic tests were not run. MSVC emitted linker/unused delay-load diagnostics; no Clippy code lint failures were reported. Formatting ran last, including repository lints, fuzzer verification and Flowey verification, without unrelated file changes.Hardware execution completed 18 successful boots, each ending with guest exit status zero:
auto: 128/256 MiB with 1 vCPU; 512 MiB with 2/4/8 vCPUs.autobatches of 4 and 8 guests, each 256 MiB / 1 vCPU, held at a common barrier before workload execution.Each of the 17
autoruns checked a private temporary-file marker, 16 MiB file I/O with SHA-256, synchronized time status and clean shutdown. These are short functional smoke tests, not adversarial isolation or maximum-capacity tests.Remaining qualification
Full upstream CI, other host architectures/backends, managed sandbox lifecycle, snapshot/restore, long-duration load, and production reliability are not established by this patch. E2B API compatibility is outside its scope. Native
hostprofile derivation has not been extended for N1X; useautoornvidia.n1x.v1. The product name identifies the tested machine, not a vendor certification or an SMBIOS admission rule.