23 Commits

Author SHA1 Message Date
Michael Vogt
54a319444f arch: fix incorrect architecture name in arch.Endian() (#13036)
The go and Debian/Ubuntu architecture names are extremly close and
there was a typo in one of them (i386->386). In addition to fixing
the typo this commit also includes a list of known architectures
from the go source directly to ensure this change is correct.

There is no exported list of available architectures so it had to
be copied. There is `go tool dist list` which will list all
supported combinations of os/arch but the downside of using this
is that when architecture support gets dropped in the future the
test would start failing for no good reason.
2023-07-31 08:59:47 -03:00
Michael Vogt
9c72433ef0 arch: add new arch.Endian() helper and use it in seccomp (#13028)
* arch: add new `arch.Endian()` helper and use it in seccomp

Go has no good way to get the native endianness of a system.
However for certain use-cases (like seccomp) this is quite
important. We already have a (hackish) `isBigEndian()` helper
in our code. However this will also be needed in snap-seccomp
for PR#13014 this will also be needed so moving the helper
to the `arch` package seems to be prudent.

* arch: fix usage of runtimeGOARCH

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>

---------

Co-authored-by: Miguel Pires <miguelpires94@gmail.com>
2023-07-31 09:44:11 +02:00
Alfonso Sánchez-Beato
db816dfecf arch: add mock function for architecture 2022-02-15 19:09:28 +01:00
Dimitri John Ledkov
614a1594d1 arch: add riscv64
Also sort arches alphabetically, and drop duplicate ppc64 test.
2020-06-03 13:50:05 +01:00
Arda Güçlü
108d96985d test: rename dpkg architecture in snap-seccomp 2019-08-27 21:07:08 +03:00
Arda Güçlü
174bd05417 fixme: rename ubuntu*architectures to dpkg*architectures 2019-08-26 22:20:59 +03:00
Arda Güçlü
42e967517e Add new cases into arch_test 2019-08-20 22:40:57 +03:00
John R. Lenton
c15d1d41b7 many: move Uname to osutil, for more DRY and easier porting.
Before this there was an Uname implementation in arch and one in
release (the implementation is slightly tricky because
syscall.Utsname's internals are arch-dependent). This drops both in
favour of a new one in osutil, in order to keep syscalls limited to
this package as much as possible.
2018-08-20 16:13:13 +01:00
Michael Vogt
2c3e1b9686 arch: add "armv8l" to ubuntuArchFromKernelArch table
We have a build failure currently in the armhf build. It is caused
by the unknown kernel utsname value "armv8l". By adding this to
the arch table things work again.
2018-01-23 08:22:18 +01:00
Simon Fels
2b6a3dd3f3 arch,release: map armv6 correctly
We used GOARCH so far to map out a device we're running on as an ARM
device but that ignores the revision and doesn't detect armv6 devices
properly which we don't have a core snap for at the moment. This lead
to the armhf core snap being pulled on an armv6 device which doesn't
make any sense. This change now uses utsname to get the correct
machine type from the kernel and adjusts the detect architecture if
we're running on an armv6 based device.
2017-07-18 16:08:12 +02:00
Michael Vogt
fcdd496318 the kernel architecutre name is armv7l instead of armv7 2017-06-23 13:13:32 +02:00
Michael Vogt
3b359969a1 avoid using unsafe.Pointer() when working with syscall.Utsname{} 2017-06-22 15:58:55 +02:00
Michael Vogt
1d04d77f88 address review comments (thanks to Gustavo) 2017-06-22 13:35:10 +02:00
Michael Vogt
0c7f5fab35 address review feedback (thanks to jdstrand) 2017-06-21 08:05:48 +02:00
Michael Vogt
2d80225d7c more review feedback 2017-06-19 21:21:58 +02:00
Michael Vogt
205c52a44f Add support for kernel != userland snapd in seccomp
The old C code supported the following cases for compat syscalls:

1. kernel and userspace are both 32 bit (no compat)
2. kernel and userspace are both 64 bit (need to load 32 bit arch for
   32 bit compat)
3. kernel is 64 bit and userspace is 32 bit (need to load 64 bit arch
   for native syscalls)

This commit ensures case (3) is now also supported with the new
go based seccomp code.

Note that (3) in the context of snaps is very strange. When snapd
runs as a 32bit app it will only request 32bit snaps from the
store. So there has to be 32bit snaps that contain 64bit code and
logic that can auto-detect if 64 bit code can be run and that then
makes use of this 64bit code.
2017-06-19 14:40:57 +02:00
Michael Vogt
937fbf8c35 fix missing go -> ubuntu mapping for powerpc 2016-02-25 20:28:46 +01:00
Michael Vogt
9572a882d2 fix build failure on s390x 2016-02-23 11:47:28 +01:00
Michael Vogt
d6b0291726 The goarch ppc64el is the ubuntu ppc64le arch
Yes, this is confusing!
2015-11-27 12:45:46 +01:00
Michael Vogt
50029f11ad go fmt (silly me!) 2015-11-17 15:58:46 +01:00
Michael Vogt
13d9c5893e address review comments (thanks!) 2015-11-17 13:00:16 +01:00
Michael Vogt
343e52b25c Add missing test 2015-11-17 12:49:29 +01:00
Michael Vogt
a003e95d1e Move architecture handling into its own package
The architecture handling used to be partly in the helpers and
partly in the snappy package. By moving it into a common package
subsequent branches (feature/snapfs-mount2) will become simpler.
2015-11-17 09:06:26 +01:00