From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97CF721A955 for ; Fri, 20 Dec 2024 17:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734714216; cv=none; b=m/ambXy+yc+kESk3jTQ4x4taclMTuRlZd9dX9zOtX/aCA4WHvKVb28hxVNnrC4XM88nSv06+zgtsDErnBpoTc3K7PJpLS+mXujZvx1JjIsGKYOmcch+25bw22ARvb5Nza2JDYKGBLwY9G8Z842/drnlgTbWPPJgNCyktm7mM6/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734714216; c=relaxed/simple; bh=XixWERsnTiJRqts/WwEbYo2pyD7Nc8ZnsgWBeb4RkzE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kZKHvNBCok4kEBjFfkcnL3cBc/SOI44/KXg6vrV4+9WiTtzxbcU0I96l8CucXu1KH+2Ie48HmDt0IDU6IoKNgmNToj1VrYQQyefFr+vNEH5mWOEefjubBiI7GYdTZEp/m32m19LGdnAf9VMkd3Rab4YvxRr0mq2vK5R2kDl1XJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Qsd+TdNe; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Qsd+TdNe" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef775ec883so1955322a91.1 for ; Fri, 20 Dec 2024 09:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734714214; x=1735319014; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=s5yr6t69gOvH70w/wkJRwmL2V9/iNwAhu2xaX5YWKo4=; b=Qsd+TdNeYrVPuOKOxLkXs4kDnGonsGS8BgomM7fysvuO4iWPpaKuGy8fYBXj2Roh2D YcMg8aWVLIK51GCiosmO2yKHvq8ebV9s/uRy6jppE+KWuIYp9GGQ29uC8m5N1jRI5r5x xM2d2oVLuvhNZxFQzSRRAXedxFu6l3BRS+2y3QOtHYbqgXqOmmq0ijckaVe6pYmoKFW1 c/AgiaBNsosKQmyh+MpCCvgj+nb8teH0Z/L4hi29NkwM16nko/qHJJMDTHQBVBNRwJrh jTCb7Xi5QK1Sxx3tT4AenqU/pYbcjCysKwSYo02ejREcwpq527/UcBkerHEZecIxuek3 27JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734714214; x=1735319014; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s5yr6t69gOvH70w/wkJRwmL2V9/iNwAhu2xaX5YWKo4=; b=EOsnsy18Ovr4SQQSvt6zJcTvqXmRjI//cn0+MJTd5lPUmywrk6rmFGRM8Bx9vBJFQ6 9PJMw6DDlEhf1N0i9oTwJ+0wVo00cXAoaiZQK+r+t+zNvqZ+3DHYzeP8FGNFD4nbBUsd dXkWN8zDmcl3WXk6sBpewJ7dXr4wI5sz2/Q6TVHCzy+9keHte1c9HshfOEt5yFzYoHnC 6bD3X09tA06Sce8wU20sneuxaE0n2kf1l68gI6qbCF3V8RaBVV4R/qQIGwwBK1oWS43c Eq5QVLNLVVdl+N9wqFWDOxvAp/Y783l3bG0C2TU8CjIt/nzvBWBazjDkx1L15hNv9PRg udMw== X-Gm-Message-State: AOJu0Yw6h7nWZeDMRNKqM8Ty+AMvYSk1oVFecLOKZIBXL8OAXiOC+Y9I JlXUD7HUbFGTZ4ZtT+eODDW58YaXDZcCUUBI7glTWDGNRAREiWzRA6ok7AfPi49VmAkxn/zUmox 6Mw== X-Google-Smtp-Source: AGHT+IEqBrnezB1GN7pFiCoWOhDUqGVsSUgzaeHOmkxBKF5WRD/GsHalV8OTgJ6lAurNZBX5g4ESY9Ow2K0= X-Received: from pjbsy4.prod.google.com ([2002:a17:90b:2d04:b0:2ef:9b30:69d3]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:da8e:b0:2ee:f80c:688d with SMTP id 98e67ed59e1d1-2f452ec37a0mr5138242a91.25.1734714213969; Fri, 20 Dec 2024 09:03:33 -0800 (PST) Date: Fri, 20 Dec 2024 09:03:32 -0800 In-Reply-To: <20241219124426.325747-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241219124426.325747-1-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH] KVM: x86: let it be known that ignore_msrs is a bad idea From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Dec 19, 2024, Paolo Bonzini wrote: > When running KVM with ignore_msrs=1 and report_ignored_msrs=0, the user has > no clue that that the guest is being lied to. This may cause bug reports > such as https://gitlab.com/qemu-project/qemu/-/issues/2571, where enabling > a CPUID bit in QEMU caused Linux guests to try reading MSR_CU_DEF_ERR; and > being lied about the existence of MSR_CU_DEF_ERR caused the guest to assume > other things about the local APIC which were not true: > > Sep 14 12:02:53 kernel: mce: [Firmware Bug]: Your BIOS is not setting up LVT offset 0x2 for deferred error IRQs correctly. > Sep 14 12:02:53 kernel: unchecked MSR access error: RDMSR from 0x852 at rIP: 0xffffffffb548ffa7 (native_read_msr+0x7/0x40) > Sep 14 12:02:53 kernel: Call Trace: > ... > Sep 14 12:02:53 kernel: native_apic_msr_read+0x20/0x30 > Sep 14 12:02:53 kernel: setup_APIC_eilvt+0x47/0x110 > Sep 14 12:02:53 kernel: mce_amd_feature_init+0x485/0x4e0 > ... > Sep 14 12:02:53 kernel: [Firmware Bug]: cpu 0, try to use APIC520 (LVT offset 2) for vector 0xf4, but the register is already in use for vector 0x0 on this cpu > > Without reported_ignored_msrs=0 at least the host kernel log will contain > enough information to avoid going on a wild goose chase. But if reports > about individual MSR accesses are being silenced too, at least complain > loudly the first time a VM is started. > > Signed-off-by: Paolo Bonzini > --- > arch/x86/kvm/x86.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index c8160baf3838..1b7c8db0cf63 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -12724,6 +12724,13 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) > kvm_hv_init_vm(kvm); > kvm_xen_init_vm(kvm); > > + if (ignore_msrs && !report_ignored_msrs) { > + pr_warn_once("Running KVM with ignore_msrs=1 and report_ignored_msrs=0 is not a\n"); > + pr_warn_once("a supported configuration. Lying to the guest about the existence of MSRs\n"); Back-to-back 'a's. If we're saying this combo is unsupported, should we taint the host kernel with TAINT_USER, e.g. similar to how the force_avic parameter is treated as unsafe? > + pr_warn_once("may cause the guest operating system to hang or produce errors. If a guest\n"); > + pr_warn_once("does not run without ignore_msrs=1, please report it to kvm@vger.kernel.org.\n"); This should be a multi-line string that's printed in a single pr_warn_once(), otherwise the full message could get split quite weirdly if there is other dmesg activity. > + } > + > return 0; > > out_uninit_mmu: > -- > 2.43.5 >