This repository was archived by the owner on Nov 6, 2024. It is now read-only.
Commit 6f3b013
committed
Support treating kvm_xsave as a FamStruct
In linux 5.17, kvm_xsave got turned into a FamStruct by adding the
flexible "extra" member to its definition. However, unlike all other
such structs, it does not contain a "length" field. Instead, the length
of the flexible array member has to be determined by querying the
`KVM_CAP_XSAVE2` capability. This requires access to a VM file
descriptor, and thus cannot happen in the `FamStruct::len` trait method.
To work around this, define a wrapper struct that caches the length of a
previous `KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)` call, and implement
`FamStruct` for this wrapper. Then in kvm-ioctls, we can expose a
function that first query `KVM_CAP_XSAVE2`, then invokes
`KVM_GET_XSAVE2` to retrives the `kvm_xsave` structure, and then combine
them into the below `kvm_xsave2` structure to be managed as a
`FamStruct`.
Signed-off-by: Patrick Roy <[email protected]>1 parent 95dd264 commit 6f3b013
1 file changed
+58
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
97 | 155 | | |
98 | 156 | | |
99 | 157 | | |
| |||
0 commit comments