All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] setarch: add arm and aarch64 architectures to transition
@ 2020-06-23 14:56 Alexey Gladkov
  2020-06-23 14:56 ` [PATCH 1/2] setarch: make verify_arch_domain extendable Alexey Gladkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexey Gladkov @ 2020-06-23 14:56 UTC (permalink / raw)
  To: util-linux; +Cc: Karel Zak, Dmitry V. Levin, Gleb Fotengauer-Malinovskiy

Since aarch64 kernel can be configured with compat 32-bit support
enabled, extend translation rules in a way similar to x86/x86_64.

Alexey Gladkov (2):
  setarch: make verify_arch_domain extendable
  setarch: add arm and aarch64 architectures to transition rules

 sys-utils/setarch.c | 43 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 11 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] setarch: make verify_arch_domain extendable
  2020-06-23 14:56 [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Alexey Gladkov
@ 2020-06-23 14:56 ` Alexey Gladkov
  2020-06-23 14:56 ` [PATCH 2/2] setarch: add arm and aarch64 architectures to transition rules Alexey Gladkov
  2020-06-24 13:09 ` [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Karel Zak
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Gladkov @ 2020-06-23 14:56 UTC (permalink / raw)
  To: util-linux; +Cc: Karel Zak, Dmitry V. Levin, Gleb Fotengauer-Malinovskiy

When other compatible architectures are introduced, they will also have
to be added to the verifier.

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
---
 sys-utils/setarch.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index cb4b08157..b057b4df8 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -254,22 +254,29 @@ static struct arch_domain *get_arch_domain(struct arch_domain *doms, const char
 	return !d || d->perval < 0 ? NULL : d;
 }
 
-static void verify_arch_domain(struct arch_domain *dom, const char *wanted)
+static void verify_arch_domain(struct arch_domain *doms, struct arch_domain *target, const char *wanted)
 {
 	struct utsname un;
 
-	if (!dom || !dom->result_arch)
+	if (!doms || !target || !target->result_arch)
 		return;
 
 	uname(&un);
-	if (strcmp(un.machine, dom->result_arch) != 0) {
-		if (strcmp(dom->result_arch, "i386") != 0
-		    || (strcmp(un.machine, "i486") != 0
-			&& strcmp(un.machine, "i586")
-			&& strcmp(un.machine, "i686") != 0
-			&& strcmp(un.machine, "athlon") != 0))
-			errx(EXIT_FAILURE, _("Kernel cannot set architecture to %s"), wanted);
+
+	if (!strcmp(un.machine, target->result_arch))
+		return;
+
+	if (!strcmp(target->result_arch, "i386")) {
+		struct arch_domain *dom;
+		for (dom = doms; dom->target_arch != NULL; dom++) {
+			if (!dom->result_arch || strcmp(dom->result_arch, target->result_arch))
+				continue;
+			if (!strcmp(dom->target_arch, un.machine))
+				return;
+		}
 	}
+
+	errx(EXIT_FAILURE, _("Kernel cannot set architecture to %s"), wanted);
 }
 
 int main(int argc, char *argv[])
@@ -279,7 +286,7 @@ int main(int argc, char *argv[])
 	int verbose = 0;
 	int archwrapper;
 	int c;
-	struct arch_domain *doms, *target = NULL;
+	struct arch_domain *doms = NULL, *target = NULL;
 	unsigned long pers_value = 0;
 	char *shell = NULL, *shell_arg = NULL;
 
@@ -434,7 +441,7 @@ set_arch:
 
 	/* make sure architecture is set as expected */
 	if (arch)
-		verify_arch_domain(target, arch);
+		verify_arch_domain(doms, target, arch);
 
 	if (!argc) {
 		shell = "/bin/sh";
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] setarch: add arm and aarch64 architectures to transition rules
  2020-06-23 14:56 [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Alexey Gladkov
  2020-06-23 14:56 ` [PATCH 1/2] setarch: make verify_arch_domain extendable Alexey Gladkov
@ 2020-06-23 14:56 ` Alexey Gladkov
  2020-06-24 13:09 ` [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Karel Zak
  2 siblings, 0 replies; 4+ messages in thread
From: Alexey Gladkov @ 2020-06-23 14:56 UTC (permalink / raw)
  To: util-linux; +Cc: Karel Zak, Dmitry V. Levin, Gleb Fotengauer-Malinovskiy

Since aarch64 kernel can be configured with compat 32-bit support
enabled, extend translation rules in a way similar to x86/x86_64.

Suggested-by: "Dmitry V. Levin" <ldv@altlinux.org>
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
---
 sys-utils/setarch.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
index b057b4df8..6914d791b 100644
--- a/sys-utils/setarch.c
+++ b/sys-utils/setarch.c
@@ -206,6 +206,19 @@ static struct arch_domain *init_arch_domains(void)
 		{PER_LINUX,	"e2k12c",	"e2k"},
 		{PER_LINUX,	"e2k16c",	"e2k"},
 		{PER_LINUX,	"e2k2c3",	"e2k"},
+#endif
+#if defined(__arm__) || defined(__aarch64__)
+# ifdef __BIG_ENDIAN__
+		{PER_LINUX32,	"armv7b",	"arm"},
+		{PER_LINUX32,	"armv8b",	"arm"},
+# else
+		{PER_LINUX32,	"armv7l",	"arm"},
+		{PER_LINUX32,	"armv8l",	"arm"},
+# endif
+		{PER_LINUX32,	"armh",		"arm"},
+		{PER_LINUX32,	"arm",		"arm"},
+		{PER_LINUX,	"arm64",	"aarch64"},
+		{PER_LINUX,	"aarch64",	"aarch64"},
 #endif
 		/* place holder, will be filled up at runtime */
 		{-1,		NULL,		NULL},
@@ -266,7 +279,8 @@ static void verify_arch_domain(struct arch_domain *doms, struct arch_domain *tar
 	if (!strcmp(un.machine, target->result_arch))
 		return;
 
-	if (!strcmp(target->result_arch, "i386")) {
+	if (!strcmp(target->result_arch, "i386") ||
+	    !strcmp(target->result_arch, "arm")) {
 		struct arch_domain *dom;
 		for (dom = doms; dom->target_arch != NULL; dom++) {
 			if (!dom->result_arch || strcmp(dom->result_arch, target->result_arch))
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] setarch: add arm and aarch64 architectures to transition
  2020-06-23 14:56 [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Alexey Gladkov
  2020-06-23 14:56 ` [PATCH 1/2] setarch: make verify_arch_domain extendable Alexey Gladkov
  2020-06-23 14:56 ` [PATCH 2/2] setarch: add arm and aarch64 architectures to transition rules Alexey Gladkov
@ 2020-06-24 13:09 ` Karel Zak
  2 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2020-06-24 13:09 UTC (permalink / raw)
  To: Alexey Gladkov; +Cc: util-linux, Dmitry V. Levin, Gleb Fotengauer-Malinovskiy

On Tue, Jun 23, 2020 at 04:56:18PM +0200, Alexey Gladkov wrote:
> Alexey Gladkov (2):
>   setarch: make verify_arch_domain extendable
>   setarch: add arm and aarch64 architectures to transition rules

Applied, thanks.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-24 13:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23 14:56 [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Alexey Gladkov
2020-06-23 14:56 ` [PATCH 1/2] setarch: make verify_arch_domain extendable Alexey Gladkov
2020-06-23 14:56 ` [PATCH 2/2] setarch: add arm and aarch64 architectures to transition rules Alexey Gladkov
2020-06-24 13:09 ` [PATCH 0/2] setarch: add arm and aarch64 architectures to transition Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.