diff mbox series

KVM: x86/mmu: Warn on nx_huge_pages when initializing kvm

Message ID 20211019121848.245347-1-liyu.yukiteru@bytedance.com (mailing list archive)
State New, archived
Headers show
Series KVM: x86/mmu: Warn on nx_huge_pages when initializing kvm | expand

Commit Message

Yu Li Oct. 19, 2021, 12:18 p.m. UTC
Add warning when `nx_huge_pages` is enabled by kvm mmu for hint that
huge pages may be splited by kernel.

Signed-off-by: Li Yu <liyu.yukiteru@bytedance.com>
---
 arch/x86/kvm/mmu/mmu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Oct. 19, 2021, 12:56 p.m. UTC | #1
On 19/10/21 14:18, Li Yu wrote:
> Add warning when `nx_huge_pages` is enabled by kvm mmu for hint that
> huge pages may be splited by kernel.
> 
> Signed-off-by: Li Yu <liyu.yukiteru@bytedance.com>
> ---
>   arch/x86/kvm/mmu/mmu.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 1a64ba5b9437..b75dbaf29f2d 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -6091,12 +6091,17 @@ static int set_nx_huge_pages(const char *val, const struct kernel_param *kp)
>   	return 0;
>   }
>   
> +#define ITLB_MULTIHIT_MSG "iTLB multi-hit CPU bug present and cpu mitigations enabled, huge pages may be splited by kernel for security. See CVE-2018-12207 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/multihit.html for details.\n"

Shouldn't it warn if mitigations are disabled but the bug is present?

Paolo

>   int kvm_mmu_module_init(void)
>   {
>   	int ret = -ENOMEM;
>   
> -	if (nx_huge_pages == -1)
> +	if (nx_huge_pages == -1) {
>   		__set_nx_huge_pages(get_nx_auto_mode());
> +		if (is_nx_huge_page_enabled())
> +			pr_warn_once(ITLB_MULTIHIT_MSG);
> +	}
>   
>   	/*
>   	 * MMU roles use union aliasing which is, generally speaking, an
>
diff mbox series

Patch

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 1a64ba5b9437..b75dbaf29f2d 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -6091,12 +6091,17 @@  static int set_nx_huge_pages(const char *val, const struct kernel_param *kp)
 	return 0;
 }
 
+#define ITLB_MULTIHIT_MSG "iTLB multi-hit CPU bug present and cpu mitigations enabled, huge pages may be splited by kernel for security. See CVE-2018-12207 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/multihit.html for details.\n"
+
 int kvm_mmu_module_init(void)
 {
 	int ret = -ENOMEM;
 
-	if (nx_huge_pages == -1)
+	if (nx_huge_pages == -1) {
 		__set_nx_huge_pages(get_nx_auto_mode());
+		if (is_nx_huge_page_enabled())
+			pr_warn_once(ITLB_MULTIHIT_MSG);
+	}
 
 	/*
 	 * MMU roles use union aliasing which is, generally speaking, an