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

Re: [XEN v8 2/2] xen/arm64: io: Support instructions (for which ISS is not valid) on emulated MMIO region using MMIO/ioreq handler


  • To: Julien Grall <julien@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxxxxx>
  • Date: Mon, 21 Feb 2022 21:10:58 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=xen.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); 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=gyMlo1JhMjgqSNxGOR52Qwwlj25T+FEOQ6sZi1F/wSE=; b=NLpEnWzAy3OW8NCu9WgDV/RAIjIP+VRWjQr7O3PkVOJjxkLrRvN2cZ6FZNaDbbC7mxmPW0qqZMQhmdUe5b8i/MqulCQ12+x0lKcZzku1+54i4TlbF0YT88H1+VvCIPKkbMhr4YIDLT0mMJO5PgIiejmvFpZTPIH/fNzlZAdoIgiLN+/hniQ71cXupmXHmmKpaUkW7TFdofXukKikNFGOKY4WDoR93RF4vK4m84ut6YDjJVsnQur5eFXkyLDX/jsQ1X6x3hnWulgccHorcWseuTdTU5gjj2XIMwfpKdH3FKyewc/upqLrVGgsCRcW9kUrVZIFsXT0CACZmSM8e9bDng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DJLpS6Yp5u5MhjWcSevWaMXOO8CU4DWH2VrnvGcs3XjPfhcBNmCRNIToFS5tLTiFr4w1+NIumVM0L4RWzecMThhQaUvyAai3TD2hdQFa56TA+LO8odMR6BZ0quKYGsDvIIo5ETR8RdVugA8ONkgFqHxbWL2GSNpgr/BzThH62IHIp1wjPtLlMD9Y7akkpB7D7reP2Sd9y2dc8QFa2n6oatWXhZETA0CmdmzafyKBuefVeQiVRMr76XTP7W9+ydOYL2d+eLb1QsstYb03oNF1Jh91bB8MkOnsPuYGSb5J2uynyEkU7DszZZ/AyVLsDr8c1fL8lbVURbcU8QII4c68VA==
  • Cc: <sstabellini@xxxxxxxxxx>, <stefanos@xxxxxxxxxx>, <Volodymyr_Babchuk@xxxxxxxx>, <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 21 Feb 2022 21:11:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 21/02/2022 19:13, Julien Grall wrote:


On 21/02/2022 19:05, Ayan Kumar Halder wrote:
If we (ie Xen) didn't decode the instruction manually, then check_p2m() has not been invoked yet.  This is because of the following (info.dabt.valid == True) :-

         if ( !is_data || !info.dabt.valid )
         {

                 ...

                 if ( check_p2m(is_data, gpa) )
                     return;

                 ...

         }

So, in this scenario ( !info.dabt.valid), it would not be necessary to invoke check_p2m() after try_handle_mmio().

However, if we havenot decoded the instruction manually (ie info.dabt.valid == True), and try_handle_mmio() returns IO_UNHANDLED, then it will be necessary to invoke "check_p2m(is_data, gpa)"

Hmmm you are right. But this doesn't seem to match the code you wrote below. What did I miss?

My code was not correct.  I have rectified it as below. Please let me know if it looks sane.

<snip>

    case FSC_FLT_TRANS:
    {
        info.gpa = gpa;
        info.dabt = hsr.dabt;

        /*
         * Assumption :- Most of the times when we get a data abort and the ISS          * is invalid or an instruction abort, the underlying cause is that the
         * page tables have not been set up correctly.
         */
        if ( !is_data || !info.dabt.valid )
        {
            if ( check_p2m(is_data, gpa) )
                return;

            /*
             * If the instruction abort could not be resolved by setting the
             * appropriate bits in the translation table, then Xen should
             * forward the abort to the guest.
             */
            if ( !is_data )
                goto inject_abt;

            try_decode_instruction(regs, &info);

            /*
             * If Xen could not decode the instruction or encountered an error              * while decoding, then it should forward the abort to the guest.
             */
            if ( info.dabt_instr.state == INSTR_ERROR )
                goto inject_abt;
        }

        state = try_handle_mmio(regs, &info);

        switch ( state )
        {
            case IO_ABORT:
                goto inject_abt;
            case IO_HANDLED:
                /*
                 * If the instruction was decoded and has executed successfully                  * on the MMIO region, then Xen should execute the next part of
                 * the instruction. (for eg increment the rn if it is a
                 * post-indexing instruction.
                 */
                post_increment_register(&info.dabt_instr);
                advance_pc(regs, hsr);
                return;
            case IO_RETRY:
                /* finish later */
                return;
            case IO_UNHANDLED:
                /* IO unhandled, try another way to handle it. */
                break;
        }

        /*
         * If the instruction was valid but Xen could not emulate the instruction          * then it should configure the page tables to set the correct page table          * entry corresponding to the faulting address. If it was successful, it          * should return to the guest to retry the instruction (hoping that the
         * instruction will not be trapped to Xen again).
         * However, if Xen was not successful in setting the page tables, then
         * it should forward the abort to the guest.
         */
        if ( info.dabt.valid && check_p2m(is_data, gpa) )
            return;

        break;
    }
    default:

<snip>

- Ayan


Cheers,




 


Rackspace

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