please set /proc/cpu/alignment=4 on Launchpad ARM buildd kernels

Bug #1516331 reported by Steve Langasek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
launchpad-buildd
Fix Released
Undecided
Unassigned

Bug Description

Bug #1512323 reveals that whereas our buildds use the default /proc/cpu/alignment setting of 2 (fixup), our Ubuntu phones, due to their inheritance from android, are overriding the kernel default and setting this to 4 (raise). This mean that unaligned accesses that work fine on the buildds may fail on the phone.

I consider it a bug that the android chroots are using this non-default setting and am proposing that we fix this. However, I also consider it a bug that the builders use the default setting, because this means that they allow code through (passing build-time test suites, etc.) that will fail on any systems where the end user has also changed their system away from the default.

And because ARM doesn't have support for prctl(PR_SET_UNALIGNED), there is no way for a package to reliably proof itself against this at build time. Whereas if the autobuilders were using /proc/cpu/alignment=4, there's a good chance (75%) the previous systemd upload would have already FTBFS due to a SIGBUS in the test.

Please change the config of the armhf autobuilders to set /proc/cpu/alignment=4.

Revision history for this message
Adam Conrad (adconrad) wrote :

This probably should be changed in canonical-is-puppet for arch=armhf, not in launchpad-buildd, but I couldn't sort out how to reassign the bug successfully. :P

information type: Public → Private
information type: Private → Public
affects: launchpad → launchpad-buildd
Colin Watson (cjwatson)
description: updated
Revision history for this message
Colin Watson (cjwatson) wrote :

Well: we could do it in canonical-is-puppet, but I don't think there's a convenient init script already in place that we could tweak, so we'd need to spit out a new one, and that would then end up in a place that is pretty obscure to most people and invisible to anyone who doesn't work for Canonical. It might be more transparent to just do it in launchpad-buildd's init script, and that isn't *completely* logically wrong. It would certainly be easier.

I believe that we don't need to do this for the scalingstack case, because arm64 doesn't have the alignment trap feature at all. Please correct me if I'm wrong here.

Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 1516331] Re: please set /proc/cpu/alignment=4 on Launchpad ARM buildd kernels

> I believe that we don't need to do this for the scalingstack case,
> because arm64 doesn't have the alignment trap feature at all. Please
> correct me if I'm wrong here.

There is no CONFIG_ALIGNMENT_TRAP visible in the arm64 kernel config, so it
appears there's no need to configure it on arm64 hosts. I'm not sure if
that means that these unaligned accesses /will/ or /won't/ be trapped on an
arm64 kernel, but if they are trapped I guess that's not a problem you can
fix.

Revision history for this message
Colin Watson (cjwatson) wrote :

A quick test on the arm64 porter box suggests that they're trapped and
fixed up:

  (wily-arm64)cjwatson@rugby:~$ cat t.c
  #include <inttypes.h>
  #include <stdint.h>
  #include <stdio.h>

  void unaligned(uint64_t *x) { printf("x: %" PRIx64 "\n", *x); }

  int main(int argc, char **argv) {
          uint64_t a, b;
          a = 0x0123456789abcdef;
          b = 0xfedcba9876543210;
          unaligned((uint64_t *)((char *)&a + 1));
          return 0;
  }
  (wily-arm64)cjwatson@rugby:~$ gcc -O0 -g t.c -o t
  (wily-arm64)cjwatson@rugby:~$ ./t
  x: 100123456789abcd

So, I suppose we can do this, but it's going to cease being effective as
soon as we switch armhf to scalingstack, since this will be running on
top of arm64 kernels. My question is therefore: is it worth it given
that there would probably be some kind of cost and that the benefit
would be fairly short-term? If so, maybe somebody should look into how
an alignment trap that forces a signal on arm64 might work in more
detail.

Revision history for this message
Steve Langasek (vorlon) wrote :

On Mon, Nov 16, 2015 at 10:43:48PM -0000, Colin Watson wrote:
> A quick test on the arm64 porter box suggests that they're trapped and
> fixed up:

<snip>

> So, I suppose we can do this, but it's going to cease being effective as
> soon as we switch armhf to scalingstack, since this will be running on
> top of arm64 kernels. My question is therefore: is it worth it given
> that there would probably be some kind of cost and that the benefit
> would be fairly short-term? If so, maybe somebody should look into how
> an alignment trap that forces a signal on arm64 might work in more
> detail.

Talking with the hyperscale folks, it sounds like there's no straightforward
way to force SIGBUS to be raised on arm64.

So if ScalingStack is going to be running on arm64 kernels, then feel free
to consider this wontfix.

I do recall other issues where it seemed like it would be beneficial to run
armhf guest kernels in scalingstack instead of arm64 kernel + armhf
userspace. If that happened (which I know is currently not practical
because of the lack of sane armhf guest boot handling), it might be worth
revisiting this.

Revision history for this message
Adam Conrad (adconrad) wrote :

Looks like when running armv7 code on armv8, fixups do NOT occur, so this is Fix Released By Accident, IMO.

We definitely have alignment-related FTBFS and test failures in Ubuntu that don't reproduce in Debian, where they do fixups.

Changed in launchpad-buildd:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.