[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 08/13] libs/guest: introduce support for setting guest MSRs


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 6 Jul 2023 12:57:25 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qQOYFUOMHuj7uxPP7uf5chHqnNg/cVk5WHpGtOP6fbQ=; b=USFSeYSTwOrHxdM4VvL7MgHv9atqeZrr4JQ2zOJFZxUlN70I5Q4wENwEVa6Vo+DHUdFVBcM382yeJiu+brmAQy01UdzyvkHbSjMKIHM59BnX01QqetwBHx2Sj0IbiAclb6QAPOGHiXuN18tWDGvxykfbisfkQn2eKnlPO5eKj/Z7NzCpks1s3gcp3zL3BlTmlMrEqhc1b9N2Ta0MwQCw6Dm4p3Oc9N4lnHlkpzr3iYNkDOrd6LqjMZmDLX7+r6XpmtMDFxwwU6Wstw8dvP8YWffemuGbPN76xL2Wb5k5fowTDdy7ZCrqJBpmaLmId/KD1cTbTevrPcifo4Dchv2S3A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnlDXOYKZfqgmqctd4+SVKTTlmfbH/zL8xfZRMi2C34C9QI6LsQz75rzw48pFBQUZA9+11+VlFydGoW1Qj7aKeuR34MufOLioce7G3xlO2QeqFTn6EgZ8AyOOs8EQhQcC5d4o5gh92vaPFZjpuIzaTC7yy9KvupkfY9gAfm65rQqAJrJUAwmJN+JB5njRuW/Fd/3+O/haBBlGrEIHE5quKV2R6K5R/Jha0ooNzHPxZcpf+drdlf2/Xymj2E0JDArVSewXYDZN3CAaOl0tkcO3vC+yabK0+wcPfFSVkOav3Zx98RC1SsfnXaRxJRQ6aaxz7AWWFC7D1YF0LuOk2kKBw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 06 Jul 2023 10:57:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.