Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3010436ybi; Mon, 17 Jun 2019 14:37:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9qtKdMdAa39PGsSS43u2jTuT12G3h+GlEcZ+3MaCpJYrvOXQw9so3mci0HiJrTnqjjGZl X-Received: by 2002:a17:90a:2008:: with SMTP id n8mr1239992pjc.4.1560807440915; Mon, 17 Jun 2019 14:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807440; cv=none; d=google.com; s=arc-20160816; b=0h5Q8DEOt4Oh72mO462pHux7QY2qWC1wg4uJnr2vZ4Rdx5tOpFhQ2CC5tDimgaiCKA kuwQRlwIjUGpqk5c9eMlf34LpTIHPU15X+b//27/NwbEVFeUZztGfp9PWRhrd3N3Y9Tu QKXz5mdZx+aLuOTK5JEmEnmkPYEaDhU9SXNVocauY9S+nj2Z/ophfNmDoIoDESBC2TNh oE0ygDF+XLjadqxk9HDMk/nitJ+EdhMLapi3YAdZ0NIhTcPDQmI0m2rUtodTPMCoxXvP wULV6OnE1ScXfDeFdh4A6GLF6OlzxWBa09pap9eU+UXl6PqW7MMMZDO/cHkUFerkRXvD oh+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/Ca9xLkwrA6MfrK0tHWWenyF/Li9+EkJ4Uzty3+GS9s=; b=NeISigyWJj2EUumQuB3yhI86YV3ciQHqw2aQqd1FaLpv0qy2TWAWHMq75LDgEV3woa sCVv650p0oraP6VYPuua8BYmKi2EwzQbc35PJ1xSYoBfjMhXRCrApeWALoNWsuj45Edj +IIcgRuzM4Z7EqYiwEQxCBgSfX3D2ZVGHlRQpGZHHYrNAaUDlKyO7Y6yl6/eu5ELc55W 3IpP+DJaCayfTayE/qI+Uz9A259ERxRW5Pa/8iBhbS04jDPrtBC0vwQEPOa+azjDHDJE YCznfLqKM/+dNCxxX95eZ0f5+D7S084fp785cBXONigi1IB4L1uqnEEdMm11JeCjKpXh ysQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TWHCoyQ7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j17si11385503pfn.278.2019.06.17.14.37.05; Mon, 17 Jun 2019 14:37:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TWHCoyQ7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729425AbfFQVfr (ORCPT + 99 others); Mon, 17 Jun 2019 17:35:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:47174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729547AbfFQVW3 (ORCPT ); Mon, 17 Jun 2019 17:22:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABC9E20833; Mon, 17 Jun 2019 21:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806548; bh=dvxxn4rysdrsxXAtrKY2Bdb2fzE5Pk706zOzmuoP2eA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWHCoyQ7mpBCTKsXiVzi8fTLOmC0eWobV96SV1n7ECixdn0wDpeZ9CIDBsyfaLBTy 2xmypv6EsdBT+Fr1RpBkjIaPIbxv+VPpyLbfTpzovpJhbpCcb0/z6pXfikwce9LCS/ XH1ZhR9cOORZzUFTVuHeKRvUiF9k6hfophVrb1n8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Sasha Levin Subject: [PATCH 5.1 088/115] KVM: x86: do not spam dmesg with VMCS/VMCB dumps Date: Mon, 17 Jun 2019 23:09:48 +0200 Message-Id: <20190617210804.454133767@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6f2f84532c153d32a5e53b6083b06a3e24368d30 ] Userspace can easily set up invalid processor state in such a way that dmesg will be filled with VMCS or VMCB dumps. Disable this by default using a module parameter. Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 9 ++++++++- arch/x86/kvm/vmx/vmx.c | 26 +++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index ae6e51828a54..aa3b77acfbf9 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -379,6 +379,9 @@ module_param(vgif, int, 0444); static int sev = IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT); module_param(sev, int, 0444); +static bool __read_mostly dump_invalid_vmcb = 0; +module_param(dump_invalid_vmcb, bool, 0644); + static u8 rsm_ins_bytes[] = "\x0f\xaa"; static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); @@ -4834,6 +4837,11 @@ static void dump_vmcb(struct kvm_vcpu *vcpu) struct vmcb_control_area *control = &svm->vmcb->control; struct vmcb_save_area *save = &svm->vmcb->save; + if (!dump_invalid_vmcb) { + pr_warn_ratelimited("set kvm_amd.dump_invalid_vmcb=1 to dump internal KVM state.\n"); + return; + } + pr_err("VMCB Control Area:\n"); pr_err("%-20s%04x\n", "cr_read:", control->intercept_cr & 0xffff); pr_err("%-20s%04x\n", "cr_write:", control->intercept_cr >> 16); @@ -4992,7 +5000,6 @@ static int handle_exit(struct kvm_vcpu *vcpu) kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY; kvm_run->fail_entry.hardware_entry_failure_reason = svm->vmcb->control.exit_code; - pr_err("KVM: FAILED VMRUN WITH VMCB:\n"); dump_vmcb(vcpu); return 0; } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 2b4a3d32c511..cfb8f1ec9a0a 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -114,6 +114,9 @@ static u64 __read_mostly host_xss; bool __read_mostly enable_pml = 1; module_param_named(pml, enable_pml, bool, S_IRUGO); +static bool __read_mostly dump_invalid_vmcs = 0; +module_param(dump_invalid_vmcs, bool, 0644); + #define MSR_BITMAP_MODE_X2APIC 1 #define MSR_BITMAP_MODE_X2APIC_APICV 2 @@ -5605,15 +5608,24 @@ static void vmx_dump_dtsel(char *name, uint32_t limit) void dump_vmcs(void) { - u32 vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS); - u32 vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS); - u32 cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); - u32 pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL); - u32 secondary_exec_control = 0; - unsigned long cr4 = vmcs_readl(GUEST_CR4); - u64 efer = vmcs_read64(GUEST_IA32_EFER); + u32 vmentry_ctl, vmexit_ctl; + u32 cpu_based_exec_ctrl, pin_based_exec_ctrl, secondary_exec_control; + unsigned long cr4; + u64 efer; int i, n; + if (!dump_invalid_vmcs) { + pr_warn_ratelimited("set kvm_intel.dump_invalid_vmcs=1 to dump internal KVM state.\n"); + return; + } + + vmentry_ctl = vmcs_read32(VM_ENTRY_CONTROLS); + vmexit_ctl = vmcs_read32(VM_EXIT_CONTROLS); + cpu_based_exec_ctrl = vmcs_read32(CPU_BASED_VM_EXEC_CONTROL); + pin_based_exec_ctrl = vmcs_read32(PIN_BASED_VM_EXEC_CONTROL); + cr4 = vmcs_readl(GUEST_CR4); + efer = vmcs_read64(GUEST_IA32_EFER); + secondary_exec_control = 0; if (cpu_has_secondary_exec_ctrls()) secondary_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); -- 2.20.1