Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4097240pxb; Tue, 10 Nov 2020 07:54:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMgHdvWFVRhuWD6MmG4az4PX4hSGtzoaOw1qTaVRCzvTORQ/rkDGqNhrfVxkMha4DDA5+D X-Received: by 2002:a17:906:1643:: with SMTP id n3mr20451429ejd.459.1605023662071; Tue, 10 Nov 2020 07:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605023662; cv=none; d=google.com; s=arc-20160816; b=F69TpwLi3w+/EXWmEfzBlISkxrbsYCj4i8JJTI2bW0YU74d24CdGBXwFO2KgRex4B0 kUf/W52uz6Y8CYzgHO4AmcIhBrUqYT/jZv7IDG5kbLgz61aQ7EWEhwZ49jpOrtfhwunk JmlOtIFERv8gXHRzBOAZ3v2AOrJJGdPxixYn04pydm5e6nVnc4whT1rR2IZDLciCTmFd 7wsGtXsKEYtEi82Pf/nKhZ6wvj+o3UxT7+/bSmlM0uuixIc2q3e50JCueiQRJfOka/bQ 653IKbNHAk4Z+t6KEIVRVfOHRSDGGmPVuziK1OHPCBGpIB0pxLxKV7FvcA+E3bYpZagU cDNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cI7RO02QCOkBjAuvhcFoxA8dBO+HwAVNuJFq7/77EFY=; b=Iok6aZ+XYuEX0MIIPh4HJcAWnacnWogAeETDkcxdoMB5Jx4jFoN617RCBp0Jm01E9o ph9Vk9uFElhzi5J2W3qWmz+68/O97cr06k7+AD9UpUvgD6L6/uEJin1askQD16M76G1z cu21WbrvhPg//OVjrniJ3NNf/c2xRx8T6Y+wdyrQA7G/NkBwtlat4gvk4kvCAo9VLpKt rOL1RLH928YIn0vZB0W32JgKgdhY0DeH6xOlVgGnRPPm3+m8u5W8t4BIJIZr8CwBwfq4 dk62b2QlZVablHrdrMugC+uwfkwg1Ztvn7LUZNFYiP3lksQf2gcdJIiVMaAHRGH/cmJX FYug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ZO2hbKvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb12si6859941edb.272.2020.11.10.07.53.57; Tue, 10 Nov 2020 07:54:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ZO2hbKvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730865AbgKJPuY (ORCPT + 99 others); Tue, 10 Nov 2020 10:50:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730850AbgKJPuX (ORCPT ); Tue, 10 Nov 2020 10:50:23 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94910C0613CF; Tue, 10 Nov 2020 07:50:23 -0800 (PST) Received: from nazgul.tnic (unknown [78.130.214.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 2C1BE1EC04CB; Tue, 10 Nov 2020 16:50:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1605023421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=cI7RO02QCOkBjAuvhcFoxA8dBO+HwAVNuJFq7/77EFY=; b=ZO2hbKvA/zIGi7eG/eEnoOQoiKSUo1uyGUVvGKFRtG6ArDoEJkJIdpqrk/zav+DOyauYac X1sJwXDJcN5WoVfOj75cVaBMpPIPvO3g5dns+kL5qDPZv2pt6Bh5zJQ+cg9nPBnfbieWxt a0GYnX3lr/LDn8rc8tBRD84P+CkRvi4= Date: Tue, 10 Nov 2020 16:50:13 +0100 From: Borislav Petkov To: Paolo Bonzini Cc: "Luck, Tony" , Jim Mattson , Qian Cai , "linux-kernel@vger.kernel.org" , "linux-tip-commits@vger.kernel.org" , x86 , "kvm@vger.kernel.org" Subject: Re: [PATCH] x86/mce: Check for hypervisor before enabling additional error logging Message-ID: <20201110155013.GE9857@nazgul.tnic> References: <160431588828.397.16468104725047768957.tip-bot2@tip-bot2> <3f863634cd75824907e8ccf8164548c2ef036f20.camel@redhat.com> <20201109232402.GA25492@agluck-desk2.amr.corp.intel.com> <20201110063151.GB7290@nazgul.tnic> <094c2395-b1b3-d908-657c-9bd4144e40ac@redhat.com> <20201110095615.GB9450@nazgul.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 11:40:34AM +0100, Paolo Bonzini wrote: > However, f/m/s mean nothing when running virtualized. First, trying to > derive any non-architectural property from the f/m/s is going to fail. > Second, even the host can be anything as long as it's newer than the f/m/s > that the VM reports (i.e. you can get a Sandy Bridge model and model name > even if running on Skylake). Yah, that's why I said "then comes virt and throws all assumptions out." > See above: how can the hypervisor know a safe value for all MSRs, possibly > including the undocumented ones? Not all - just the ones which belong to a model. I was thinking of having a mapping between f/m/s and a list of MSRs which those models have - even non-architectural ones - but that's a waste of energy. Why? Because using the *msr_safe() variants will give you the same thing without doing any of the MSR lists in KVM and any of that jumping thru hoops. Which means, the kernel MSR accessors should be doing _safe(), i.e., exception handling, by default. And the non-safe ones - rdmsrl, wrmsrl, etc, should all be used only in very seldom cases. Hmm, yeah, that would probably solve this class of problems once and for all. > If it makes sense to emulate certain non-architectural MSRs we can add them. See above - probably not worth the effort. I'll take a look at how ugly it would become to make the majority of MSR accesses safe. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette