mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
libx86: Proactively initialise error pointers
This results in better behaviour for the caller. Suggested-by: Jan Beulich <JBeulich@suse.com> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Release-acked-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
1 parent
ff78e50084
commit
f001579288
5 files changed
+15
-7
No files matched your search
@@ -283,7 +283,7 @@ static void test_cpuid_deserialise_failure(void)
|
||||
for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
|
||||
{
|
||||
const struct test *t = &tests[i];
|
||||
uint32_t err_leaf = ~0u, err_subleaf = ~0u;
|
||||
uint32_t err_leaf, err_subleaf;
|
||||
int rc;
|
||||
|
||||
/* No writes should occur. Use NULL to catch errors. */
|
||||
@@ -336,7 +336,7 @@ static void test_msr_deserialise_failure(void)
|
||||
for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
|
||||
{
|
||||
const struct test *t = &tests[i];
|
||||
uint32_t err_msr = ~0u;
|
||||
uint32_t err_msr;
|
||||
int rc;
|
||||
|
||||
/* No writes should occur. Use NULL to catch errors. */
|
||||
|
||||
@@ -376,13 +376,13 @@ int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
|
||||
* @param policy The cpuid_policy to unserialise into.
|
||||
* @param leaves The array of leaves to unserialise from.
|
||||
* @param nr_entries The number of entries in 'leaves'.
|
||||
* @param err_leaf Optional hint filled on error.
|
||||
* @param err_subleaf Optional hint filled on error.
|
||||
* @param err_leaf Optional hint for error diagnostics.
|
||||
* @param err_subleaf Optional hint for error diagnostics.
|
||||
* @returns -errno
|
||||
*
|
||||
* Reads at most CPUID_MAX_SERIALISED_LEAVES. May return -ERANGE if an
|
||||
* incoming leaf is out of range of cpuid_policy, in which case the optional
|
||||
* err_* pointers are filled to aid diagnostics.
|
||||
* err_* pointers will identify the out-of-range indicies.
|
||||
*
|
||||
* No content validation of in-range leaves is performed. Synthesised data is
|
||||
* recalculated.
|
||||
|
||||
@@ -54,14 +54,14 @@ int x86_msr_copy_to_buffer(const struct msr_policy *policy,
|
||||
* @param policy The msr_policy object to unserialise into.
|
||||
* @param msrs The array of msrs to unserialise from.
|
||||
* @param nr_entries The number of entries in 'msrs'.
|
||||
* @param err_msr Optional hint filled on error.
|
||||
* @param err_msr Optional hint for error diagnostics.
|
||||
* @returns -errno
|
||||
*
|
||||
* Reads at most MSR_MAX_SERIALISED_ENTRIES. May fail for a number of reasons
|
||||
* based on the content in an individual 'msrs' entry, including the MSR index
|
||||
* not being valid in the policy, the flags field being nonzero, or if the
|
||||
* value provided would truncate when stored in the policy. In such cases,
|
||||
* the optional err_* pointer is filled in to aid diagnostics.
|
||||
* the optional err_* pointer will identify the problematic MSR.
|
||||
*
|
||||
* No content validation is performed on the data stored in the policy object.
|
||||
*/
|
||||
|
||||
@@ -381,6 +381,11 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *p,
|
||||
unsigned int i;
|
||||
xen_cpuid_leaf_t data;
|
||||
|
||||
if ( err_leaf )
|
||||
*err_leaf = -1;
|
||||
if ( err_subleaf )
|
||||
*err_subleaf = -1;
|
||||
|
||||
/*
|
||||
* A well formed caller is expected to pass an array with leaves in order,
|
||||
* and without any repetitions. However, due to per-vendor differences,
|
||||
|
||||
@@ -55,6 +55,9 @@ int x86_msr_copy_from_buffer(struct msr_policy *p,
|
||||
xen_msr_entry_t data;
|
||||
int rc;
|
||||
|
||||
if ( err_msr )
|
||||
*err_msr = -1;
|
||||
|
||||
/*
|
||||
* A well formed caller is expected to pass an array with entries in
|
||||
* order, and without any repetitions. However, due to per-vendor
|
||||
|
||||