|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 08/13] libs/guest: introduce support for setting guest MSRs
On 16.06.2023 15:10, Roger Pau Monne wrote:
> --- a/tools/libs/guest/xg_cpuid_x86.c
> +++ b/tools/libs/guest/xg_cpuid_x86.c
> @@ -331,10 +331,74 @@ int xc_cpu_policy_apply_cpuid(xc_interface *xch,
> xc_cpu_policy_t *policy,
> return 0;
> }
>
> +int xc_cpu_policy_apply_msr(xc_interface *xch, xc_cpu_policy_t *policy,
> + const struct xc_msr *msr,
> + const xc_cpu_policy_t *host)
> +{
> + for ( ; msr->index != XC_MSR_INPUT_UNUSED; ++msr )
> + {
> + xen_msr_entry_t cur_msr, host_msr;
> + int rc;
> +
> + rc = xc_cpu_policy_get_msr(xch, policy, msr->index, &cur_msr);
> + if ( rc )
> + {
> + ERROR("Failed to get current MSR %#x", msr->index);
> + return rc;
> + }
> + rc = xc_cpu_policy_get_msr(xch, host, msr->index, &host_msr);
> + if ( rc )
> + {
> + ERROR("Failed to get host policy MSR %#x", msr->index);
> + return rc;
> + }
> +
> + for ( unsigned int i = 0; i < ARRAY_SIZE(msr->policy) - 1; i++ )
While correct, the "- 1" struck me as odd. Could we deviate a little from
the CPUID side and permit an early nul in the string, implying all 'x' in
subsequent slots? Then you could drop the -1 here and simply bail from the
loop when finding a nul char.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |