From owner-freebsd-mips@freebsd.org Thu Apr 26 15:51:34 2018 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBCDDFB10FE for ; Thu, 26 Apr 2018 15:51:33 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x230.google.com (mail-io0-x230.google.com [IPv6:2607:f8b0:4001:c06::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 79D2A82859 for ; Thu, 26 Apr 2018 15:51:33 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x230.google.com with SMTP id f3-v6so31578703iob.13 for ; Thu, 26 Apr 2018 08:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=XkFZutIOXCdmXI+VVRGcud1lXagbLoSfV0nm14X0jPg=; b=OinQF4p1BCjneO3Zk3yVs4l9/ARyZ8tT29Qx9F25IICs/6EHYoS2jfa4DLFowAwSDW 80BEpdJ5gITkgM+1LAur+xWsUx7MaeHYloJirkdtneHHhky7z/65C4yUEw8RaQDicxkL Z18fjJJCdY+bQKhV8ibkIqya9heuJ42pvVzncV5vmTPS3yuicRZCuI5as+9EIXGlKXI9 WPtyQraC7iyLBBd0h3kpkdfwkRMq2Pw9f/M5OiWHTpyMHffOstFnxwUo5WiGdbBF1M3l lAsgMGi5SmkJqSKKZXgoiepxfHUqVKuLFa0ecwYJzZr7+mBexc7Pjgjllqe4yITmOyXJ TBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=XkFZutIOXCdmXI+VVRGcud1lXagbLoSfV0nm14X0jPg=; b=uYOSOYHAjzNe6C1h0RorIG4MLFPsIvc4p3y4UHtZKOlF+NdrvBKtjmGOVmCccBGVlJ ZnjVi0r91muTj8Gq5JFkAixV7IXqyfCWnc0PsuFB63d57WfaleITw4EYSC5nePhezfWV V0BhY+Nb/FaBEyoY9Wg3AuWtbyN4aFPjOPPqnEBuXoLki+Pxm5r19Z0mPDPjH39Xhvi2 bWBycEx7tQfyyRGKLOZUJtfMoQFLql3Y4Echn1EkiMAbCH3pHXHDtKKxQQPCbpKVy588 193EAb3yGXnWSNkh9X0HJNhZgMQikqmEg9BpIfwO95bgRGgUVBK01hsWHqpUhe2i9K2L Qudg== X-Gm-Message-State: ALQs6tCEioGdJGAjkuS4c28shrIWeKVBRvs/wi9kvtrGsOvEvG0tLGSb xLnX30SY4zqlXzsgTn0r22Q+2Dt8RqUUckVKRlWBFg== X-Google-Smtp-Source: AB8JxZrh2EcEY1/t73o5VR/NBjvT7lQihl1p7YpPyhvusOSjjmXezo5njwBW/Ixikl8L0QkpqHwNPpgjq52YTLaxOKg= X-Received: by 2002:a6b:3846:: with SMTP id f67-v6mr35560980ioa.117.1524757892370; Thu, 26 Apr 2018 08:51:32 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:a65a:0:0:0:0:0 with HTTP; Thu, 26 Apr 2018 08:51:31 -0700 (PDT) X-Originating-IP: [192.55.54.60] In-Reply-To: References: From: Warner Losh Date: Thu, 26 Apr 2018 09:51:31 -0600 X-Google-Sender-Auth: sOzacaI47kPtVoUEPPYm-tg3OF8 Message-ID: Subject: Re: What is the purpose of MipsEmulateBranch function? To: Jan Mazur Cc: "freebsd-mips@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2018 15:51:34 -0000 On Thu, Apr 26, 2018 at 4:01 AM, Jan Mazur wrote: > Hi > > I'm wondering why FreeBSD has to simulate branches when the faulting > instruction is in the branch delay slot. > I'm curious about MipsEmulateBranch function, which is defined in > http://bxr.su/FreeBSD/sys/mips/mips/trap.c#MipsEmulateBranch > > Why can't you just restart execution from the branch instruction? > You can't restart a branch in the delay slot, so you have to emulate the branch. It's used in various places to adjust the return PC of the trap frame data when an instruction in the delay slot causes a fault. Warner