Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2083541imm; Thu, 27 Sep 2018 07:11:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV63QNl/2g7S2yH+D/+aKSMVUPr2Su7ZiqYk41hNtsukn0TJgdjnzLTBBOz5AoxvzAWGa9QXi X-Received: by 2002:a62:565c:: with SMTP id k89-v6mr11664239pfb.212.1538057513291; Thu, 27 Sep 2018 07:11:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538057513; cv=none; d=google.com; s=arc-20160816; b=C8gdhlAg+6FeS1yTDlZWJKeEBKDk6zHkA6X3KUli2EDRyMKaIu/xAKFbxFN/H1cP4r XRFi7h7IbNxU0VPbf8JR4hPLh7udwtxzX9zW7HJk6qrfIEgmL0FFWyImMpSdXLxTrHip aQfuGsAJk7yUztRkkvp+wSdNZ9MtBEtTQjK7DOAen5CV+ZYEVBnw0GZFg3d1Mcd8gpEg XSHAmemVpyYN//+wstI04z/F/X9JLsuKgY7i6U+l6YnzCiKMHBVbFJ9i0xor8kCNJA3C vxTgiBX+zjc6ztcqdahH0ZzR6DcnvNbyn3PB73N2nLnxpgHx79/QrViVe/iv/zNA2enz 3aUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=znKETi4CpzeAlxkCj1i0UEG2DgOrcMly2eAXYV3CI+k=; b=ghjM+3uH8ilVubcUWyDDtbolCmkl62AihnL1w1ZV/MLxGp77CgvgRzdvi+q9waxVhf Rw4/Lvm6f0KGwb2dslIgKydxL3If85dna3OTOzuYGpDFjcF1xg32Q1r26AZYrCkUa0hg pbsFM756xu07OdQp47kTPq3b0u+teYxKR8qnayaUjwne5sShFRyoy0Qt805ZiUZkR/vZ BIu+mnTDBYbD/CWMODelQHOIGbbAOMYDI4F6jGkfINIr/V5g9hoM5E2BCLDREVeJn5LK zrNbTBSP5JJvy5htpZ8I8TRpUbkuPzyQGVP5n1TDEO4AD0BjMo77+pz8cxFBFD1DEOxG HwWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r2-v6si1997520pgk.452.2018.09.27.07.11.37; Thu, 27 Sep 2018 07:11:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727426AbeI0U3u convert rfc822-to-8bit (ORCPT + 99 others); Thu, 27 Sep 2018 16:29:50 -0400 Received: from mga01.intel.com ([192.55.52.88]:17787 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727262AbeI0U3u (ORCPT ); Thu, 27 Sep 2018 16:29:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 07:11:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,310,1534834800"; d="scan'208";a="266315642" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga005.fm.intel.com with ESMTP; 27 Sep 2018 07:11:11 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 07:11:11 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 07:11:10 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.140]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.27]) with mapi id 14.03.0319.002; Thu, 27 Sep 2018 22:11:08 +0800 From: "Wang, Wei W" To: "Gonglei (Arei)" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "ak@linux.intel.com" CC: "Liang, Kan" , "peterz@infradead.org" , "mingo@redhat.com" , "rkrcmar@redhat.com" , "Xu, Like" , "jannh@google.com" Subject: RE: [PATCH v3 5/5] KVM/x86/lbr: lazy save the guest lbr stack Thread-Topic: [PATCH v3 5/5] KVM/x86/lbr: lazy save the guest lbr stack Thread-Index: AQHUUM3r0paOOfw3cUyiMvfFvyNRYKT4jVyAgAuiBxA= Date: Thu, 27 Sep 2018 14:11:08 +0000 Message-ID: <286AC319A985734F985F78AFA26841F7397FD491@shsmsx102.ccr.corp.intel.com> References: <1537437959-8751-1-git-send-email-wei.w.wang@intel.com> <1537437959-8751-6-git-send-email-wei.w.wang@intel.com> <33183CC9F5247A488A2544077AF19020DB0F7483@dggeml511-mbx.china.huawei.com> In-Reply-To: <33183CC9F5247A488A2544077AF19020DB0F7483@dggeml511-mbx.china.huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODIwNDUwN2EtYzFjMi00ZjA0LWE0MzYtNTYwYjJjNDU2ZjZmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiZ2VCOWo4eVk0Wlk2SXNaN1lJQzNYRmd2YjJQY29walQySVZINGZHZzhSVGhENEJRV2xpMUtUSytGb25HeGd6dyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, September 20, 2018 8:08 PM, Gonglei (Arei) wrote: > > +static bool guest_access_lbr_msr(struct kvm_vcpu *vcpu, > > + struct msr_data *msr_info, > > + bool set) > > +{ > > + bool ret = false; > > + > > + if (!vcpu->kvm->arch.guest_lbr_enabled) > > + return false; > > + > > + if (set) > > + ret = guest_set_lbr_msr(vcpu, msr_info); > > + else > > + ret = guest_get_lbr_msr(vcpu, msr_info); > > + > > + if (ret) { > > + vcpu->arch.lbr_used = true; > > + vmx_set_intercept_for_lbr_msrs(vcpu, false); > > You can use if (!vcpu->arch.lbr_used) as the condition of assign values. > They are need only once. Thanks, I think it would be better to use If (ret && !vcpu->arch.lbr_used) (we need to make sure that the guest is accessing one of the LBR related MSRs via ret=true) Best, Wei