All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Juergen Gross <jgross@suse.com>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Julien Grall" <julien@xen.org>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>, "Wei Liu" <wl@xen.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Christopher Clark" <christopher.w.clark@gmail.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH 03/12] xen: harmonize return types of hypercall handlers
Date: Mon, 18 Oct 2021 13:55:36 +0200	[thread overview]
Message-ID: <7bd0cff1-6e88-f8dd-d857-229e75dd2772@suse.com> (raw)
In-Reply-To: <20211015125152.25198-4-jgross@suse.com>

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



  reply	other threads:[~2021-10-18 11:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 12:51 [PATCH 00/12] xen: drop hypercall function tables Juergen Gross
2021-10-15 12:51 ` [PATCH 01/12] xen: limit number of hypercall parameters to 5 Juergen Gross
2021-10-15 12:51 ` [PATCH 02/12] xen: move do_vcpu_op() to arch specific code Juergen Gross
2021-10-15 12:51 ` [PATCH 03/12] xen: harmonize return types of hypercall handlers Juergen Gross
2021-10-18 11:55   ` Jan Beulich [this message]
2021-10-18 13:24     ` Juergen Gross
2021-10-18 14:25       ` Jan Beulich
2021-10-18 15:31         ` Juergen Gross
2021-10-15 12:51 ` [PATCH 04/12] xen/x86: modify hvm_memory_op() prototype Juergen Gross
2021-10-18 12:31   ` Jan Beulich
2021-10-18 13:27     ` Juergen Gross
2021-10-18 14:28       ` Jan Beulich
2021-10-18 15:34         ` Juergen Gross
2021-10-15 12:51 ` [PATCH 05/12] xen: don't include asm/hypercall.h from C sources Juergen Gross
2021-10-18 12:39   ` Jan Beulich
2021-10-18 15:20     ` Juergen Gross
2021-10-15 12:51 ` [PATCH 06/12] xen: generate hypercall interface related code Juergen Gross
2021-10-18 12:58   ` Jan Beulich
2021-10-18 15:28     ` Juergen Gross
2021-10-18 15:39       ` Jan Beulich
2021-10-20  7:02       ` Juergen Gross
2021-10-20  7:11         ` Jan Beulich
2021-10-20  7:18           ` Juergen Gross
2021-10-15 12:51 ` [PATCH 07/12] xen: use generated prototypes for hypercall handlers Juergen Gross
2021-10-18 13:01   ` Jan Beulich
2021-10-15 12:51 ` [PATCH 08/12] x86/pv-shim: don't modify hypercall table Juergen Gross
2021-10-15 13:57   ` Jan Beulich
2021-10-15 14:23     ` Juergen Gross
2021-10-15 12:51 ` [PATCH 09/12] xen/x86: don't use hypercall table for calling compat hypercalls Juergen Gross
2021-10-15 12:51 ` [PATCH 10/12] xen/x86: call hypercall handlers via switch statement Juergen Gross
2021-10-21 14:41   ` Jan Beulich
2021-10-28 14:32     ` Juergen Gross
2021-11-02  9:54       ` Jan Beulich
2021-11-02 10:04         ` Juergen Gross
2021-10-15 12:51 ` [PATCH 11/12] xen/arm: " Juergen Gross
2021-10-15 12:51 ` [PATCH 12/12] xen/x86: add hypercall performance counters for hvm, correct pv Juergen Gross
2021-10-21 15:19   ` Jan Beulich
2021-10-28 14:35     ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bd0cff1-6e88-f8dd-d857-229e75dd2772@suse.com \
    --to=jbeulich@suse.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=christopher.w.clark@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.