Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp734407ybt; Fri, 26 Jun 2020 10:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY22s1tElhhLrxrVHjJn5TGmTBskSmHtoTNVchEEcHuabIBSx/pe+acGbmqb04zSVVXRWg X-Received: by 2002:a50:d80f:: with SMTP id o15mr4495034edj.156.1593191619597; Fri, 26 Jun 2020 10:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593191619; cv=none; d=google.com; s=arc-20160816; b=mhu9rKo/OReneeHvb5A8aaifNuWxr180OBqj3MRPA7bHXDeYiNxAdrQ4y0qB0+clc7 +Qd6J9r4tSCt0Cw2GF2ExQfssmOkLOMm1u0+6SV1Z+jdQPxFwhQWNyzo4X/8HlGLqNfy rGqGaeMd/yEdN9UO4f0+YX1At1/XqZRTWs7TTvWIcaP8KbzUj7tW31qa7xNZLI+NPTz6 xG38zA6P7lMXfDy5kATMH7lbUfLGDWTCZY3lm+S6jqVcExUXLgkIzAAF3jrCowTfqQ/K swsAJoXPUwUjk81on74LcDQUUQO8tVpBTr/w2Avs8rI0iyyyKwQYdBb31TrwtjcE+VvN +7aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=NPgGRUc9d7yqXL9/blYvjOQXkfSzv4MSzaBKDB7nc/s=; b=hbDcYbfr1ppDrlWx9oqDGZqlDbJGvtVIs6z/+5N6B+qgSOF5cxCct6/mWH3pFIMXL6 0y95QPASAnZfOlNp1EFCwz4Rz2Crwmlugwzc2N/BHmMik/a75zOILGQUoTuIOU8Ik8QR DIpGV8mXKy26udaVLNbm/suf1p6jsOdaBeHo3GT9MS7wIalZHYzDZvuhqsBxK2rCJsli xPSjw5Yr6PoEKW9G2mAb7le9cc0/QMw4Gu5lqMNOyjz5wVFsyEcGWlSiEHVC/HFk79xW AT4xV2WtltFOm31Ej6bQYwm0UjVSOEDN6Xc/3+i1HSr2aQLsVGO4uAfiAQX2NNcbD580 CkKA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d11si11119009edz.263.2020.06.26.10.13.16; Fri, 26 Jun 2020 10:13:39 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730116AbgFZP46 (ORCPT + 99 others); Fri, 26 Jun 2020 11:56:58 -0400 Received: from mga05.intel.com ([192.55.52.43]:24803 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbgFZP46 (ORCPT ); Fri, 26 Jun 2020 11:56:58 -0400 IronPort-SDR: uZQOJbZQHU7FIEjatT2pAbXG+e0xawdGTY1SLzdpGToUcjg487EUGVs4cM9QXBTmRBrAqz3Mu1 g3AvZvTQCkHQ== X-IronPort-AV: E=McAfee;i="6000,8403,9664"; a="230146587" X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="230146587" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 08:56:57 -0700 IronPort-SDR: j+HuT071Nr3F3FGpKOZF8ToqB4YfiJFxn9esIc79m4HAcTKwxP/nrGkykJA7rdjQjkHYdehxx2 Pe6gTsaglh7g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="276400676" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga003.jf.intel.com with ESMTP; 26 Jun 2020 08:56:57 -0700 Date: Fri, 26 Jun 2020 08:56:57 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Peter Xu , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vitaly Kuznetsov Subject: Re: [PATCH 1/2] KVM: X86: Move ignore_msrs handling upper the stack Message-ID: <20200626155657.GC6583@linux.intel.com> References: <20200622220442.21998-1-peterx@redhat.com> <20200622220442.21998-2-peterx@redhat.com> <20200625061544.GC2141@linux.intel.com> <1cebc562-89e9-3806-bb3c-771946fc64f3@redhat.com> <20200625162540.GC3437@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 08:44:16PM +0200, Paolo Bonzini wrote: > On 25/06/20 18:25, Sean Christopherson wrote: > > I get the "what" of the change, and even the "why" to some extent, but I > > dislike the idea of supporting/encouraging blind reads/writes to MSRs. > > Blind writes are just asking for problems, and suppressing warnings on reads > > is almost guaranteed to be suppressing a KVM bug. > > Right, that's why this patch does not just suppress warnings: it adds a > different return value to detect the case. > > > TSC_CTRL aside, if we insist on pointing a gun at our foot at some point, > > this should be a dedicated flavor of MSR access, e.g. msr_data.kvm_initiated, > > so that it at least requires intentionally loading the gun. > > With this patch, __kvm_get_msr does not know about ignore_msrs at all, > that seems to be strictly an improvement; do you agree with that? Not really? It's solving a problem that doesn't exist in the current code base (assuming TSC_CTRL is fixed), and IMO solving it in an ugly fashion. I would much prefer that, _if_ we want to support blind KVM-internal MSR accesses, we end up with code like: if (msr_info->kvm_internal) { return 1; } else if (!ignore_msrs) { vcpu_debug_ratelimited(vcpu, "unhandled wrmsr: 0x%x data 0x%llx\n", msr, data); return 1; } else { if (report_ignored_msrs) vcpu_unimpl(vcpu, "ignored wrmsr: 0x%x data 0x%llx\n", msr, data); break; } But I'm still not convinced that there is a legimiate scenario for setting kvm_internal=true. > What would you think about adding warn_unused_result to __kvm_get_msr? I guess I wouldn't object to it, but that seems like an orthogonal issue.