Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for znver1 and znver1_32 architectures #889

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libdnf/dnf-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static const struct {
{ "arm", { "armv5tejl", "armv5tel", "armv5tl", "armv6l", "armv7l", "armv8l", NULL } },
{ "armhfp", { "armv7hl", "armv7hnl", "armv8hl", "armv8hnl", "armv8hcnl", NULL } },
{ "i386", { "i386", "athlon", "geode", "i386",
"i486", "i586", "i686", NULL } },
"i486", "i586", "i686", "znver1_32", NULL } },
{ "ia64", { "ia64", NULL } },
{ "mips", { "mips", NULL } },
{ "mipsel", { "mipsel", NULL } },
Expand All @@ -109,7 +109,7 @@ static const struct {
{ "sh4", { "sh4", "sh4a", NULL } },
{ "sparc", { "sparc", "sparc64", "sparc64v", "sparcv8",
"sparcv9", "sparcv9v", NULL } },
{ "x86_64", { "x86_64", "amd64", "ia32e", NULL } },
{ "x86_64", { "x86_64", "amd64", "ia32e", "znver1", NULL } },
{ NULL, { NULL } }
};

Expand Down
36 changes: 36 additions & 0 deletions libdnf/hy-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,34 @@
#ifndef HWCAP_ARM_NEON
#define HWCAP_ARM_NEON (1<<12)
#endif
#if defined(__x86_64__) || defined(__i386__)

static inline void cpuid(uint32_t op, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
asm volatile (
"cpuid\n"
: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
: "a" (op));
}

static bool is_ryzen(void) {
uint32_t eax, ebx, ecx, edx;
char vendor[13];
int family;
vendor[12]=0;
cpuid(0, &eax, &ebx, &ecx, &edx);
memcpy(vendor, &ebx, sizeof(ebx));
memcpy(vendor+4, &edx, sizeof(edx));
memcpy(vendor+8, &ecx, sizeof(ecx));
if (strncmp(vendor, "AuthenticAMD", 12))
return false;
cpuid(1, &eax, &ebx, &ecx, &edx);
family = (eax>>8)&0xf;
if(family == 0xf)
family += (eax>>20)&0x7f;
return family >= 0x17;
}
#endif

const char *
hy_chksum_name(int chksum_type)
Expand Down Expand Up @@ -123,6 +151,14 @@ hy_detect_arch(char **arch)
strcpy(un.machine, "mipsel");
else if (!strcmp(un.machine, "mips64"))
strcpy(un.machine, "mips64el");
#endif
#if defined(__x86_64__) || defined(__i386__)
if (is_ryzen()) {
if (!strcmp(un.machine, "x86_64"))
strcpy(un.machine, "znver1");
else
strcpy(un.machine, "znver1_32");
}
#endif
*arch = g_strdup(un.machine);
return 0;
Expand Down