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

Re: [PATCH v2 2/3] xen/pv: refactor msr access functions to support safe and unsafe accesses


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 4 Oct 2022 13:03:02 +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=IokFddPdV7HIrzpIUoByLj6n+3o3hsSxVbuMkS/m+g4=; b=HfqDQeoCpl8AbFX8rWV/W9HRHx036dV7Xl889BXTYp1M9MFPTH9YK+x7YWSt9bMmrYax5H9avYwfGH1UzUeY/nGhPciNjscwG87Len5c2tKlfd0Y43hnK7H9iWht31lNjud/v+9Uv1HJUN93ufTGutYkLZ7Jqo7DJQ2mJaJNmXDsmQhF4+RKnOizEtcHZ8rEdHVQ3yPU9ElxTRDBpVFA3a4X3HacESdZD60xkjVmuGcXuUiA/90oI/9z83s7EkPWIamFB1QPnnB+bICS5bvhkv8eyjiMDIzbABZuhFpnIhcMx1XV0eG6X4MMrrmvoD/eEyroz/rv2o19AJuaezRUIg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bC+7OlPu12qai4+pmkhDTqVckIhUvBHBQx8h7ZQvyaje7nflrQi7xRQbbEBMfGR88i6vkR1/QNaTYuISoKI3kZCGyAgrDBQsGTvJZ77pJeVagEb4ahlnYtXn8WJ7PJuKMBQvJMcrFIIDTVo0XEpTXTtuYFLSZnLyDa1eIb7incpMG1vLT06TS4nYQpTCFbOpcUmFAzSqeUnSI9uMzoZ4b9e9Q7zMu7ASEVw5aJU5waqxhAD2VDFE9VCc+4MdFVUzBktuT+TbRVojnsWMeQeA4W0qCDY6cBvYovRCL+WS+rnN+zfEb+aV4/Al3AZE1mpNHt88DcNRPgGSfCz+jtL7vA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx
  • Delivery-date: Tue, 04 Oct 2022 11:03:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 04.10.2022 10:43, Juergen Gross wrote:
> Refactor and rename xen_read_msr_safe() and xen_write_msr_safe() to
> support both cases of MSR accesses, safe ones and potentially GP-fault
> generating ones.
> 
> This will prepare to no longer swallow GPs silently in xen_read_msr()
> and xen_write_msr().
> 
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Albeit ...

> @@ -933,23 +937,39 @@ static u64 xen_read_msr_safe(unsigned int msr, int *err)
>       return val;
>  }
>  
> -static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
> +static void set_seg(unsigned int which, unsigned int low, unsigned int high,
> +                 int *err)
>  {
> -     int ret;
> -     unsigned int which;
> -     u64 base;
> +     u64 base = ((u64)high << 32) | low;
> +
> +     if (HYPERVISOR_set_segment_base(which, base) == 0)
> +             return;
>  
> -     ret = 0;
> +     if (err)
> +             *err = -EIO;

... I don't see a good reason to override the error code handed to us
by the hypervisor here; I do realize though that this ...

> +     else
> +             WARN(1, "Xen set_segment_base(%u, %llx) failed\n", which, base);
> +}
>  
> +/*
> + * Support write_msr_safe() and write_msr() semantics.
> + * With err == NULL write_msr() semantics are selected.
> + * Supplying an err pointer requires err to be pre-initialized with 0.
> + */
> +static void xen_do_write_msr(unsigned int msr, unsigned int low,
> +                          unsigned int high, int *err)
> +{
>       switch (msr) {
> -     case MSR_FS_BASE:               which = SEGBASE_FS; goto set;
> -     case MSR_KERNEL_GS_BASE:        which = SEGBASE_GS_USER; goto set;
> -     case MSR_GS_BASE:               which = SEGBASE_GS_KERNEL; goto set;
> -
> -     set:
> -             base = ((u64)high << 32) | low;
> -             if (HYPERVISOR_set_segment_base(which, base) != 0)
> -                     ret = -EIO;

... was this way before.

Jan



 


Rackspace

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