From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755215AbbCLRUV (ORCPT ); Thu, 12 Mar 2015 13:20:21 -0400 Received: from mail-bn1on0143.outbound.protection.outlook.com ([157.56.110.143]:23296 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755184AbbCLRUQ (ORCPT ); Thu, 12 Mar 2015 13:20:16 -0400 X-WSS-ID: 0NL405L-07-3UY-02 X-M-MSG: Message-ID: <5501CAC7.6090306@amd.com> Date: Thu, 12 Mar 2015 12:20:07 -0500 From: Joel Schopp User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: "Luck, Tony" , "jesse.larrew@amd.com" , "x86@kernel.org" CC: Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mce: use safe MSR accesses References: <1426111778-17942-1-git-send-email-jesse.larrew@amd.com> <3908561D78D1C84285E8C5FCA982C28F32A0E42D@ORSMSX113.amr.corp.intel.com> In-Reply-To: <3908561D78D1C84285E8C5FCA982C28F32A0E42D@ORSMSX113.amr.corp.intel.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=Joel.Schopp@amd.com; alien8.de; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:165.204.84.221;CTRY:US;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(428002)(189002)(51704005)(377454003)(199003)(24454002)(479174004)(80316001)(64126003)(83506001)(2501003)(87936001)(77156002)(101416001)(47776003)(65956001)(65806001)(86362001)(77096005)(105586002)(106466001)(23746002)(50466002)(87266999)(76176999)(54356999)(65816999)(62966003)(33656002)(50986999)(92566002)(46102003)(2201001)(2950100001)(36756003);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0201MB0789;H:atltwp01.amd.com;FPR:;SPF:None;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB0789; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5002009)(5005006);SRVR:BY2PR0201MB0789;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0201MB0789; X-Forefront-PRVS: 05134F8B4F X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2015 17:20:11.8295 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.221];Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0201MB0789 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/11/2015 05:47 PM, Luck, Tony wrote: >> When running as a guest under kvm, it's possible that the MSR >> being accessed may not be implemented. All MSR accesses should >> be prepared to handle exceptions. > Isn't that a KVM bug? The code here first checks family/model before accessing the MSR: > > if (c->x86 == 0x15 && > (c->x86_model >= 0x10 && c->x86_model <= 0x1f)) { > > If kvm tells the guest that it is running on one of these models, shouldn't it provide > complete coverage for that model? These MSRs don't make sense in guest mode. The real question is if we fix that in KVM, here, or both. I'm a fan of fixing it in both places. Xen's behavior is to return a value of 0 if the guest tries to access these, that seems like a reasonable thing to do in KVM as well. I am volunteering myself to write that patch for KVM, but I would encourage accepting an updated version of this patch as well. > > If that isn't possible - then you should still do more than just s/rdmsrl/rdmsrl_safe/ ... like > check the return value to see whether you got an exception .. and thus should skip past > code that uses the "val" that you thought you read from the non-existent MSR. Initializing val to 0 where it is declared should have the desired effect.