From owner-freebsd-arch@FreeBSD.ORG Fri Aug 2 10:08:09 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 1977B919 for ; Fri, 2 Aug 2013 10:08:09 +0000 (UTC) (envelope-from piyuskedia@gmail.com) Received: from mail-pd0-x233.google.com (mail-pd0-x233.google.com [IPv6:2607:f8b0:400e:c02::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E77CF2F09 for ; Fri, 2 Aug 2013 10:08:08 +0000 (UTC) Received: by mail-pd0-f179.google.com with SMTP id v10so503282pde.10 for ; Fri, 02 Aug 2013 03:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=jl18ZPqEMuIGEcOhqTtWpNaO1mSPas9dWzzIOmaCFak=; b=nNgSsdeFJXqp2pNAYRa9Jgubz1KDJF2kQDjn4lQMbDLl/85T5AHSospWAYJ9+X/nzD 7XSVucEain7DYlLZBcjCV/4F01pYn0JbFTJtspXdeBH9mwz7cndw4BXxxD0lx7pBMBxs 7/ifK7lHjNpjSoUwrsjvEwU4XIhlShxKSgA3Cy03qAv7vS/Co/0gtOIknaIxKpjPH3A5 MS0U/BZvpnDXutiCNjXRR4Cilj+jaGxkMLaiRnssWufgLXSvvJ5NCDykHYAELgWJEgwd j9rfiz4uXIyl9BsxyzcflfVXlyO97KyOWXFFYqXUg8HDtKgz7djUzPw82rDckI6inKFS 6DPg== MIME-Version: 1.0 X-Received: by 10.68.255.1 with SMTP id am1mr6838441pbd.68.1375438088484; Fri, 02 Aug 2013 03:08:08 -0700 (PDT) Received: by 10.70.7.65 with HTTP; Fri, 2 Aug 2013 03:08:08 -0700 (PDT) In-Reply-To: References: Date: Fri, 2 Aug 2013 19:08:08 +0900 Message-ID: Subject: Fwd: Use of the PC value in interrupt/exception handlers From: Piyus Kedia To: freebsd-arch@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: Sorav Bansal X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Aug 2013 10:08:09 -0000 Dear all, We are working on developing a dynamic binary translator for the kernel. Towards this, we wanted to confirm if the interrupted PC value pushed on stack by an interrupt/exception is used by the interrupt/exception handlers? For example, is the PC value compared against a fixed address to determine the handler behaviour (like Linux's page fault handler compares the faulting PC against an exception table, to allow functions like copy_from_user to fault). Basically, we are wondering if it is safe to replace the pushed PC value on stack by another value. This would be safe if the PC value is only used for returning from interrupt, or for reading contents at that PC address (e.g., to decode the instruction at current PC). It would be unsafe if the value of the address itself is meaningful to the handler. We found that in FreeBSD segment-not-present exception handler checks the trapped PC value against some fixed kernel PC by looking at the code, except that it is only used for debugging purposes. It would be nice if somebody could also confirm this. Thanks, Piyus