[PATCH] x86/cpu: Support Hygon architecture CPU during NMI initialization.

banmengtao posted 1 patch 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20250104111109.2726-1-banmengtao@zju.edu.cn
xen/arch/x86/oprofile/nmi_int.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] x86/cpu: Support Hygon architecture CPU during NMI initialization.
Posted by banmengtao 10 months ago
From: banmengtao <jiuxie@outlook.com>

When I installed Xen on Ubuntu 22.04 and rebooted into the kernel, it kept freezing and threw an exception: "Unsupported processor. Unknown vendor 16."
This patch fixes the issue where the Hygon CPU could not be recognized when entering the Xen kernel.

Signed-off-by: banmengtao <jiuxie@outlook.com>
---
 xen/arch/x86/oprofile/nmi_int.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c
index fa3071d977..ef7c7b8f69 100644
--- a/xen/arch/x86/oprofile/nmi_int.c
+++ b/xen/arch/x86/oprofile/nmi_int.c
@@ -398,6 +398,7 @@ static int __init cf_check nmi_init(void)
 
 	switch (vendor) {
 		case X86_VENDOR_AMD:
+		case X86_VENDOR_HYGON:
 			/* Needs to be at least an Athlon (or hammer in 32bit mode) */
 
 			switch (family) {
@@ -435,6 +436,11 @@ static int __init cf_check nmi_init(void)
 				model = &op_athlon_spec;
 				cpu_type = "x86-64/family16h";
 				break;
+			case 0x18:
+				model = &op_athlon_spec;
+				cpu_type = "x86-64/family18h";
+				break;
+
 			}
 			break;
 
-- 
2.34.1
Re: [PATCH] x86/cpu: Support Hygon architecture CPU during NMI initialization.
Posted by Jan Beulich 9 months, 3 weeks ago
On 04.01.2025 12:11, banmengtao wrote:
> From: banmengtao <jiuxie@outlook.com>
> 
> When I installed Xen on Ubuntu 22.04 and rebooted into the kernel, it kept freezing and threw an exception: "Unsupported processor. Unknown vendor 16."

That's no really an exception, though.

> This patch fixes the issue where the Hygon CPU could not be recognized when entering the Xen kernel.

You mention two issues (freezing and the log message). I find it hard to
believe (without better details) that both are addressed by just the
change below. Please clarify. The patch title may also need adjustment,
as more general NMI setup (e.g. for the watchdog) lives elsewhere. The
change here is about oprofile only.

> --- a/xen/arch/x86/oprofile/nmi_int.c
> +++ b/xen/arch/x86/oprofile/nmi_int.c
> @@ -398,6 +398,7 @@ static int __init cf_check nmi_init(void)
>  
>  	switch (vendor) {
>  		case X86_VENDOR_AMD:
> +		case X86_VENDOR_HYGON:
>  			/* Needs to be at least an Athlon (or hammer in 32bit mode) */
>  
>  			switch (family) {
> @@ -435,6 +436,11 @@ static int __init cf_check nmi_init(void)
>  				model = &op_athlon_spec;
>  				cpu_type = "x86-64/family16h";
>  				break;
> +			case 0x18:
> +				model = &op_athlon_spec;
> +				cpu_type = "x86-64/family18h";
> +				break;
> +
>  			}
>  			break;

Note how AMD Fam 17 and 19 aren't present here either. Yet Xen boots fine
there. So (as mentioned above already) quite likely there's more to the
problems you observe on Hygon.

Finally (nit): If already you add a blank line, please add it ahead of the
new case block rather than after it.

Jan