lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Sep 2023 12:26:09 +0200
From:   Ingo Molnar <mingo@...nel.org>
To:     linux-kernel@...r.kernel.org
Cc:     linux-tip-commits@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        "Borislav Petkov (AMD)" <bp@...en8.de>, x86@...nel.org
Subject: Re: [tip: x86/cpu] x86/cpu: Clear SVM feature if disabled by BIOS


* tip-bot2 for Paolo Bonzini <tip-bot2@...utronix.de> wrote:

> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -1031,6 +1031,8 @@ static void zenbleed_check(struct cpuinfo_x86 *c)
>  
>  static void init_amd(struct cpuinfo_x86 *c)
>  {
> +	u64 vm_cr;
> +
>  	early_init_amd(c);
>  
>  	/*
> @@ -1082,6 +1084,14 @@ static void init_amd(struct cpuinfo_x86 *c)
>  
>  	init_amd_cacheinfo(c);
>  
> +	if (cpu_has(c, X86_FEATURE_SVM)) {
> +		rdmsrl(MSR_VM_CR, vm_cr);
> +		if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
> +			pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n");
> +			clear_cpu_cap(c, X86_FEATURE_SVM);
> +		}
> +	}
> +
>  	if (!cpu_has(c, X86_FEATURE_LFENCE_RDTSC) && cpu_has(c, X86_FEATURE_XMM2)) {
>  		/*
>  		 * Use LFENCE for execution serialization.  On families which
> diff --git a/arch/x86/kernel/cpu/hygon.c b/arch/x86/kernel/cpu/hygon.c
> index defdc59..16f3463 100644
> --- a/arch/x86/kernel/cpu/hygon.c
> +++ b/arch/x86/kernel/cpu/hygon.c
> @@ -290,6 +290,8 @@ static void early_init_hygon(struct cpuinfo_x86 *c)
>  
>  static void init_hygon(struct cpuinfo_x86 *c)
>  {
> +	u64 vm_cr;
> +
>  	early_init_hygon(c);
>  
>  	/*
> @@ -320,6 +322,14 @@ static void init_hygon(struct cpuinfo_x86 *c)
>  
>  	init_hygon_cacheinfo(c);
>  
> +	if (cpu_has(c, X86_FEATURE_SVM)) {
> +		rdmsrl(MSR_VM_CR, vm_cr);
> +		if (vm_cr & SVM_VM_CR_SVM_DIS_MASK) {
> +			pr_notice_once("SVM disabled (by BIOS) in MSR_VM_CR\n");
> +			clear_cpu_cap(c, X86_FEATURE_SVM);
> +		}
> +	}
> +

1)

It's a bit sad that we are duplicating identical code.

2)

We are doing it in other cases as well: for example nearby_node() is 
duplicated between arch/x86/kernel/cpu/amd.c and 
arch/x86/kernel/cpu/hygon.c too.

3)

BTW., while look at this code I noticed that the 'Author' copyright
tag in arch/x86/kernel/cpu/hygon.c seems to be inaccurate:

 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Hygon Processor Support for Linux
  *
  * Copyright (C) 2018 Chengdu Haiguang IC Design Co., Ltd.
  *
  * Author: Pu Wen <puwen@...on.cn>
  */     

... as for example the nearby_node() was clearly copied & derived from 
arch/x86/kernel/cpu/amd.c, which does not appear to be accurately reflected 
in this copyright notice?

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ