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

Re: [PATCH v6 4/4] xen/x86: switch x86 to use generic implemetation of bug.h


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 8 Mar 2023 16:33:29 +0100
  • 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=AbTH5ihj9fE82nYPxXaOPTdgIc408R/VMWPSRt+vudY=; b=e+Sh5RNmHST95GZo0o4XqdG+TPag1lwr2boj3T3p3m4aGNp22KzqcOX9FAGe3VLgEnzVX52o78bX9y6VOqnF53VHSjPadXu26XH8qw9H3XYEH19lUVwI41EN+BtPA+Eui96+JDV7SJkgcm6My647Hc1qmWbjAMwMG3AHzocPqKporIhZb7mHNrI+mrqix8GKpawun64XkfDPslulobzDvdkcaozWzRORYPy/aDZ9duDZsrFpqdwQpPMOLO8MaUrErypxzwNzxq9RAe1xLvoQrXBXe0hr60mpct+ty/n0d752W55AkbXnjbxCmmI3/0AseNpSCbkRPvlNcQ3/gp5aGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UkVlGKdiG+iomTuSe/I0CaEdkk3ngOSLeoy+1nCXLchLnYrEfDo9k59rG77oTHS+hWNsik9n/HNxJjcRlVz2JomrdwuS3MgDZ2etDkrVyhjLk7IaR5Ct2mOt2CU4PKGFSaxImRN23zH9utJ5zqAQV5AEQfcEyQcqHPboM8j1PBs+2EF/2I2DMwZCwHv6F0aNs5ZYqFDD346Kb3sXEfgQbtKDexCAC3dzlqSX9b2Itcvw/DX1a5LPf6s8iopLxFozpWmbpgI7LW9ECc02NnJv8NsVEy91+1ga6bNosgjrWL7U9JE7JqKkVUHAgAEdBilPy1KkeX5ZxFTaLPyMHER0HQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Julien Grall <julien@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Gianluca Guida <gianluca@xxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 08 Mar 2023 15:33:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 07.03.2023 16:50, Oleksii Kurochko wrote:
> @@ -1166,12 +1167,9 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, 
> uint32_t leaf,
>  
>  void do_invalid_op(struct cpu_user_regs *regs)
>  {
> -    const struct bug_frame *bug = NULL;
>      u8 bug_insn[2];
> -    const char *prefix = "", *filename, *predicate, *eip = (char *)regs->rip;
> -    unsigned long fixup;
> -    int id = -1, lineno;
> -    const struct virtual_region *region;
> +    void *eip = (void *)regs->rip;

As said elsewhere already: "const" please whenever possible. The more that
the variable was pointer-to-const before.

> @@ -1185,83 +1183,20 @@ void do_invalid_op(struct cpu_user_regs *regs)
>           memcmp(bug_insn, "\xf\xb", sizeof(bug_insn)) )
>          goto die;
>  
> -    region = find_text_region(regs->rip);
> -    if ( region )
> -    {
> -        for ( id = 0; id < BUGFRAME_NR; id++ )
> -        {
> -            const struct bug_frame *b;
> -            unsigned int i;
> -
> -            for ( i = 0, b = region->frame[id].bugs;
> -                  i < region->frame[id].n_bugs; b++, i++ )
> -            {
> -                if ( bug_loc(b) == eip )
> -                {
> -                    bug = b;
> -                    goto found;
> -                }
> -            }
> -        }
> -    }
> -
> - found:
> -    if ( !bug )
> +    id = do_bug_frame(regs, regs->rip);
> +    if ( id < 0 )
>          goto die;
> -    eip += sizeof(bug_insn);
> -    if ( id == BUGFRAME_run_fn )
> -    {
> -        void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
> -
> -        fn(regs);
> -        fixup_exception_return(regs, (unsigned long)eip);
> -        return;
> -    }
>  
> -    /* WARN, BUG or ASSERT: decode the filename pointer and line number. */
> -    filename = bug_ptr(bug);
> -    if ( !is_kernel(filename) && !is_patch(filename) )
> -        goto die;
> -    fixup = strlen(filename);
> -    if ( fixup > 50 )
> -    {
> -        filename += fixup - 47;
> -        prefix = "...";
> -    }
> -    lineno = bug_line(bug);
> +    eip = (unsigned char *)eip + sizeof(bug_insn);

Why don't you keep the original

    eip += sizeof(bug_insn);

? As also said before we use the GNU extension of arithmetic on pointers
to void pretty extensively elsewhere; there's no reason at all to
introduce an unnecessary and questionable cast here.

With these adjustments and with the re-basing over the changes requested
to patch 2
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Jan



 


Rackspace

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