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

Re: [PATCH v2 12/14] xen/riscv: introduce an implementation of macros from <asm/bug.h>


  • To: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 27 Jan 2023 15:38:27 +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=QvJmfmMFfgX9QdUHG4DTivp1ERMM0wHykiRs3uyy0gc=; b=EZGUJTrdisPLHg1xXNgL8yYP3TY3oaE2xJBVbIwMKbPxE7tXVmLP1hjgg0eJdnz7Z7o+udAZCyZ2nRgvkpwV2fN+KnTjL0uXxZJDysvLWfgMPiRrwvq4tIU1IIPDXss+aZtwOvsm37E6WtDM4SdaJOXbnqVjuQAavAKXSiCiTaj/a2ffk5ut0eRYa5oHmSOE1S7A3TG+RasK/XP9roQpgp+UXIldueGPbhIBhXlAzYkL6lfFF3kr4Q4UFLtbKoKThLWM8+FmKhiC6RapZaHzIQJ7U77rx/vfWg3W17u644scFr9Ier5X3DQsnSygzPxBrF9UvqfqJqdpI/ifAYkKHw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wt0I0hi+jjNKJMCjnzU6WZUofTVJTzzLxEopDiKZrrM2DsVUqID+pojOoDQJM0juCRrlrz7Cd9PDaTUYByIuOCl0PBGeGHNR0qhmoK4/j/XC4o6LYWQfbxekrzxe6pOLvpa1P+Gxu7k47Y5/b1NJp+TWU7DIj+d51fvN7PPS1bLC9+jArL4BlDK3fp9KlUWnMgMVUSkN4vVw4pmGwc90lyq25o5qUJZkvTXfWxyv7JGO0bChmfP8EGQAhM/h3eRNInYDPfN6yjrsTGfU9yEBX/PlCRLGZee98cm/GaWjGdqrRshxn2+Y2TAfV4Y+L9vltDV74HLelAG3bPE0c2O5yw==
  • 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>, Bob Eshleman <bobbyeshleman@xxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Fri, 27 Jan 2023 14:38:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 27.01.2023 14:59, Oleksii Kurochko wrote:
> +int is_valid_bugaddr(uint32_t insn)
> +{
> +    if ((insn & INSN_LENGTH_MASK) == INSN_LENGTH_32)
> +        return (insn == BUG_INSN_32);
> +    else
> +        return ((insn & COMPRESSED_INSN_MASK) == BUG_INSN_16);
> +}
> +
>  void do_trap(struct cpu_user_regs *cpu_regs)
>  {
> +    register_t pc = cpu_regs->sepc;
> +    uint32_t instr = *(uint32_t *)pc;
> +
> +    if (is_valid_bugaddr(instr))
> +        if (!do_bug_frame(cpu_regs, pc)) return;
> +
>      do_unexpected_trap(cpu_regs);
>  }

One more remark, style related: Even if some of the additions you're making
are temporary, it'll be better if you have everything in Xen style. That'll
reduce the risk of someone copying bad style from adjacent code, and it'll
also avoid people like me thinking whether to comment and request an
adjustment, or whether to assume that it's temporary code and will get
changed again anyway.

Jan



 


Rackspace

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