From owner-freebsd-arm@freebsd.org Thu Jan 28 21:26:33 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 37B08A71839 for ; Thu, 28 Jan 2016 21:26:33 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: from mail-ob0-x22c.google.com (mail-ob0-x22c.google.com [IPv6:2607:f8b0:4003:c01::22c]) (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 F07EB1CD8; Thu, 28 Jan 2016 21:26:32 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: by mail-ob0-x22c.google.com with SMTP id ba1so47040486obb.3; Thu, 28 Jan 2016 13:26:32 -0800 (PST) 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=H2eZshVX9UQZwoGX2pxzZExFVx7eXRlViFl6HKpHXJk=; b=a065b1uKfEYsqqkyqbU3aMqqUEKBaALHYf/IHA29mQ17bLKEo+dDB9c4CsY9Z1QB7p IGK9Nyj0SgijH3d0kwQ+yTtTPs9JIvdp0PDQHCwwW93cHgqSS2upgrQV1GmqvbfmbFYx MQ0dx2E2dkQM2VvnRUnuFdHpT84qAqDtMNWCXoG1+MumuBvdzyE5TUUaU4vpWlbZitQL yfm5KYJoefYmXv0ayWvkVWOjufuN2CxsRov4auyvxYlobUbFgekYSecTpk13OmGPWBgU r9Y6HaL/YEY0mp+izf+s2YYOgoqXK/HSPLYbsyIJIDcj08SRy4YBQf8Wa+M1RAAa7dFi 2uGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=H2eZshVX9UQZwoGX2pxzZExFVx7eXRlViFl6HKpHXJk=; b=eFma8PcBVCxv8NimXJOilwgUyetaHCyjUiyoCsFGQmys9hnJ+mIVibJ9WnX0waqspB 0M8fE2VUCUBpnBZHT7jhNWhZRRVq0pqIBf0qEP2EDO9rq/7BknUwSyq8DNacHugtgb5G +fSEzbapgkjWKbHdyQrZNKLxRAADtZ2Aslg+JzGDuiCCEqtG1OtoxxnUBAwzfg/qMoFT vqgN6LeosohJO03Qwztxaw24bKI8TVh2rqQftI2S8++tsWMn6VY9oHjU3L2bZ8pd4fsY xl2bl6+11LVdBxPmoHqM+S36pPWfz6iZMhKeeE7FeY0oKZn5z0VfA0rgzm+8Llzob2Eu dfcw== X-Gm-Message-State: AG10YOSHQ9AlPZaOgBCajhhq7Hg6rqY2taVV8PgJJwNqHszabeorEAUkQ4LnDq9yMsH6YKt06XXhzXUO32HGxw== MIME-Version: 1.0 X-Received: by 10.182.106.13 with SMTP id gq13mr4104620obb.38.1454016392281; Thu, 28 Jan 2016 13:26:32 -0800 (PST) Received: by 10.76.34.202 with HTTP; Thu, 28 Jan 2016 13:26:32 -0800 (PST) In-Reply-To: References: <1453862939.42081.25.camel@freebsd.org> <1453867724.42081.28.camel@freebsd.org> <1453903433.42081.30.camel@freebsd.org> Date: Thu, 28 Jan 2016 23:26:32 +0200 Message-ID: Subject: Re: [Bug 206658] Bus error for pfctl -sa on rpi2 r294499 snap From: Guy Yur To: Jov Cc: Ian Lepore , freebsd-arm Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2016 21:26:33 -0000 Hi, On Thu, Jan 28, 2016 at 2:06 PM, Jov wrote: > bus error at the similar position: > > Program received signal SIGBUS, Bus error. > 0x00021614 in print_host (addr=0x2065111a, port=15268, af=2 '\002', > opts=1024) at /usr/src/sbin/pfctl/pf_print_state.c:178 > warning: Source file is more recent than executable. > > 178 memcpy(&aw.v.a.addr, addr, sizeof(aw.v.a.addr)); > Current language: auto; currently minimal > (gdb) p addr > $1 = (struct pf_addr *) 0x2065111a > ... > > Jov The compiler optimizes the memcpy to a series of ldr and str instructions and since addr is unaligned you still get SIGBUS. I encountered the same problem on a BeagleBone Black. https://lists.freebsd.org/pipermail/freebsd-arm/2014-January/007237.html non-intrustive patch with changes only in print_state() pfsync_state is __packed so the keys can be copied safely to stack variables which will be aligned (and addr inside it). https://github.com/guyyur/freebsd-src_patches/blob/master/pfctl_arm_segbus__ver1_part1.patch Bug report with patch to separate pfsync and pfioc state structures but breaks backward compatibility: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=185617 -- Guy