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

Re: [PATCH 03/12] xen: harmonize return types of hypercall handlers


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 18 Oct 2021 13:55:36 +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=i8zk3t+dfpxnXB7FJdCT7izv/1Zlgb6vKX4NvXTFIA4=; b=XP2XJbwKynnh4Wkq6w4rWJhO2SKtPiOBOcDGd1YoTlZDGGw9O+UNewTNRVX948lE8LnRj2fhEv1LfI/uNWDXLMOrZFs8+l5yfwrHe3MzqM42YS4jroM3p7hGtTDsLeOmIOujnkH//EYTFtCba2oPMN6yA0rVawyWWT905LpEo005RPsOEjEhTVwemOBaAm0Vwllv2mqBtC7SD+AhvyTqJI8f8FMPZD6smplZBQZYnGbLMS1hJZMGX2xdZA8g+uIz4Zgoq8Ea67yVk4ui7EpDV6b7P7LPjwKdI7RmXpdYNODYFs+InZ7tl1WSl2UHg6xn5pD+pEc5nRk4kYpwqVfaMA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hH696DlPey0fEbPTv5DKlbHuj+OJfDzrfcGIZ3lzEeQrETmS4Su7k5va3aXj3MmL6QNdsiTy9tTE7sU3PkuQYpXziBBC7Hdpn/sU0bDgmwiORT7ePjIM2nbHIEM1cJM2uBE+7KGwFN9LBwUWtMfMxp2d4AwJCZ5SaoctiJEysDaXAFjx+2fSegjQl/ETGFE6raKqEuNgCdg7z39p0dnRdpRL3qAxmMYhdnmle0v4xXlTIemGQdlQb9om98PVxwL7wP4eHMTfnoZz2r/Iw8KhhoQguIgpVoB3t8uuWyqi3cEIzULUEo6loG3BCMtC/5rpWRDTGN35e/6bnHrmAuRRQg==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=suse.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Christopher Clark <christopher.w.clark@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 18 Oct 2021 11:55:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.10.2021 14:51, Juergen Gross wrote:
> Today most hypercall handlers have a return type of long, while the
> compat ones return an int. There are a few exceptions from that rule,
> however.
> 
> Get rid of the exceptions by letting compat handlers always return int
> and others always return long.
> 
> For the compat hvm case use eax instead of rax for the stored result as
> it should have been from the beginning.
> 
> Additionally move some prototypes to include/asm-x86/hypercall.h
> as they are x86 specific. Move the do_physdev_op() prototype from both
> architecture dependant headers to the common one. Move the
> compat_platform_op() prototype to the common header.
> 
> Switch some non style compliant types (u32, s32, s64) to style compliant
> ones.
> 
> Rename paging_domctl_continuation() to do_paging_domctl_cont() and add
> a matching define for the associated hypercall.
> 
> Make do_callback_op() and compat_callback_op() more similar by adding
> the const attribute to compat_callback_op()'s 2nd parameter.
> 
> The do_platform_op() prototype needs to be modified in order to better
> match its compat variant.

"Better" in what direction? So far both have been using typed handles,
which I consider better than void ones. You also don't seem to have
had a reason to switch e.g. multicall or dm_op, where (different)
typed handles are also in use. So I wonder what the reason for this
change is.

> Change the type of the cmd parameter for [do|compat]_kexec_op() to
> unsigned int, as this is more appropriate for the compat case.

The change for the compat case is fine, but for native you change
behavior for callers passing values equaling valid KEXEC_CMD_*
modulo 2³².

> --- a/xen/arch/x86/pv/misc-hypercalls.c
> +++ b/xen/arch/x86/pv/misc-hypercalls.c
> @@ -28,12 +28,16 @@ long do_set_debugreg(int reg, unsigned long value)
>      return set_debugreg(current, reg, value);
>  }
>  
> -unsigned long do_get_debugreg(int reg)
> +long do_get_debugreg(int reg)
>  {
> -    unsigned long val;
> -    int res = x86emul_read_dr(reg, &val, NULL);
> -
> -    return res == X86EMUL_OKAY ? val : -ENODEV;
> +    /* Avoid undefined behavior due to casting an unsigned long to long. */

Nit: unsigned -> signed conversion is implementation-defined, not
undefined.

> --- a/xen/common/argo.c
> +++ b/xen/common/argo.c
> @@ -2207,13 +2207,13 @@ do_argo_op(unsigned int cmd, 
> XEN_GUEST_HANDLE_PARAM(void) arg1,
>  }
>  
>  #ifdef CONFIG_COMPAT
> -long
> -compat_argo_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) arg1,
> -               XEN_GUEST_HANDLE_PARAM(void) arg2, unsigned long arg3,
> -               unsigned long arg4)
> +int compat_argo_op(unsigned int cmd,
> +                   XEN_GUEST_HANDLE_PARAM(void) arg1,
> +                   XEN_GUEST_HANDLE_PARAM(void) arg2,
> +                   unsigned long arg3, unsigned long arg4)

Strictly speaking arg3 and arg4 also ought to be unsigned int here.
But that's perhaps for a separate patch at another time.

Jan




 


Rackspace

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