From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE837C32792 for ; Mon, 30 Sep 2019 15:34:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE15520815 for ; Mon, 30 Sep 2019 15:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732022AbfI3PeA (ORCPT ); Mon, 30 Sep 2019 11:34:00 -0400 Received: from mga11.intel.com ([192.55.52.93]:20924 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730780AbfI3Pd7 (ORCPT ); Mon, 30 Sep 2019 11:33:59 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 08:33:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,567,1559545200"; d="scan'208";a="194214714" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by orsmga003.jf.intel.com with ESMTP; 30 Sep 2019 08:33:58 -0700 Date: Mon, 30 Sep 2019 08:33:58 -0700 From: Sean Christopherson To: Vitaly Kuznetsov Cc: Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Reto Buerki , Liran Alon , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH v2 8/8] KVM: x86: Fold decache_cr3() into cache_reg() Message-ID: <20190930153358.GD14693@linux.intel.com> References: <20190927214523.3376-1-sean.j.christopherson@intel.com> <20190927214523.3376-9-sean.j.christopherson@intel.com> <87a7am3v9u.fsf@vitty.brq.redhat.com> <20190930150430.GA14693@linux.intel.com> <87y2y53itd.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y2y53itd.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Sep 30, 2019 at 05:27:58PM +0200, Vitaly Kuznetsov wrote: > Sean Christopherson writes: > > > On Mon, Sep 30, 2019 at 12:58:53PM +0200, Vitaly Kuznetsov wrote: > >> Sean Christopherson writes: > >> > >> > Handle caching CR3 (from VMX's VMCS) into struct kvm_vcpu via the common > >> > cache_reg() callback and drop the dedicated decache_cr3(). The name > >> > decache_cr3() is somewhat confusing as the caching behavior of CR3 > >> > follows that of GPRs, RFLAGS and PDPTRs, (handled via cache_reg()), and > >> > has nothing in common with the caching behavior of CR0/CR4 (whose > >> > decache_cr{0,4}_guest_bits() likely provided the 'decache' verbiage). > >> > > >> > Note, this effectively adds a BUG() if KVM attempts to cache CR3 on SVM. > >> > Opportunistically add a WARN_ON_ONCE() in VMX to provide an equivalent > >> > check. > >> > >> Just to justify my idea of replacing such occasions with > >> KVM_INTERNAL_ERROR by setting a special 'kill ASAP' bit somewhere: > >> > >> This WARN_ON_ONCE() falls in the same category (IMO). > > > > Maybe something like KVM_BUG_ON? E.g.: > > > > #define KVM_BUG_ON(kvm, cond) \ > > ({ \ > > int r; \ > > \ > > if (r = WARN_ON_ONCE(cond)) \ > > kvm->vm_bugged = true; \ > > r; \ > > )} > > > > Yes, that's more or less what I meant! (to me 'vm_bugged' sounds like > there was a bug in the VM but the bug is actually in KVM so maybe > something like 'kvm_internal_bug' to make it explicit?) Ya, kvm_internal_bug is better.