Received: by 10.223.185.116 with SMTP id b49csp927690wrg; Wed, 14 Feb 2018 09:01:15 -0800 (PST) X-Google-Smtp-Source: AH8x226NUdZaq/LNxHVGwUcSIFbraCn38poPZlfaVQO5imAZSaPUyyvPx02oa0aU+6IgTNxCk3Ow X-Received: by 2002:a17:902:6683:: with SMTP id e3-v6mr5048556plk.22.1518627674924; Wed, 14 Feb 2018 09:01:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518627674; cv=none; d=google.com; s=arc-20160816; b=BA+QerLjD/8Ms3ufXu2DINxN+ykzWRYgqNmP5DeqdfSsp4BHsifFnXMdzewUXWhBMS GR1QKIALaShwXYYt+QLve3zH/OpMxOuQmjcBb2r52w8ueUAuts4EsXAskSXywdM2SvnE kme+2CZafPyV8BClRSQBwwOi++kiWZ9JNr8ze6X4cW+Xp8SdfVmlBWjVd25VcBIGIGV6 +HyLo7Ba3pHMafxfNLDxGV6pnVadS0gWoLjp4Qu9YnpOSiKVVdTc/YyZRzINg+ARY7ez DnNtJfBQKZQWGCNt17yGlDz3mg2T0TbmdR1OHRi//xcSfUr2CdDH9g5+bFY4FxCNvZXS w4Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=bFNfaFEnr7QL0DwwlQrflGngwQw3E2X7ky50adg+LWs=; b=ourq9TAsUll5p2pTYUktXrRLsK7DBbFuPDVmY+eb6LzfbXv5wlltUXX2MijfTUS0St ocV9yvj6ySrCD14nTnlReb/HF6gpA7UJz9wIcRLpJvTh4rjUAr22ZNCYYPyTyC8SzC1g 0GrhncrzaRySle3shMBoGC0eW1RuwGURQ/aSKvJfKmf2fGh/exRUw40Mz93TVkao3j4I dNnJ9/UoG7j43XZTIW0Hz8ksk8ubtuPPpoEmREQm6cXwZ+ZdM/GQahCtHSPGROBpPvay ukesjx+OYPzEzfFMPvv+M7K1V2XFvtS47JLMbiFHhB0Mb6SSrqDo/AortoMlsrUnAV0d sN0g== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9-v6si1473203ple.367.2018.02.14.09.00.34; Wed, 14 Feb 2018 09:01:14 -0800 (PST) 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033141AbeBNQ7E (ORCPT + 99 others); Wed, 14 Feb 2018 11:59:04 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032821AbeBNQ7D (ORCPT ); Wed, 14 Feb 2018 11:59:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D5A98182D1E; Wed, 14 Feb 2018 16:59:02 +0000 (UTC) Received: from [10.36.118.14] (unknown [10.36.118.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB287213AEE1; Wed, 14 Feb 2018 16:58:58 +0000 (UTC) Subject: Re: [RFC PATCH 1/2] KVM: x86: Add a framework for supporting MSR-based features To: Borislav Petkov , Tom Lendacky Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Joerg Roedel , Thomas Gleixner , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= References: <20180208225833.22074.25995.stgit@tlendack-t1.amdoffice.net> <20180208225846.22074.70944.stgit@tlendack-t1.amdoffice.net> <20180214164438.GI18349@pd.tnic> From: Paolo Bonzini Message-ID: Date: Wed, 14 Feb 2018 17:58:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180214164438.GI18349@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Feb 2018 16:59:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 14 Feb 2018 16:59:02 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14/02/2018 17:44, Borislav Petkov wrote: > On Thu, Feb 08, 2018 at 04:58:46PM -0600, Tom Lendacky wrote: >> @@ -2681,11 +2731,15 @@ static int __msr_io(struct kvm_vcpu *vcpu, struct kvm_msrs *msrs, >> { >> int i, idx; >> >> - idx = srcu_read_lock(&vcpu->kvm->srcu); >> + if (vcpu) >> + idx = srcu_read_lock(&vcpu->kvm->srcu); >> + >> for (i = 0; i < msrs->nmsrs; ++i) >> if (do_msr(vcpu, entries[i].index, &entries[i].data)) >> break; >> - srcu_read_unlock(&vcpu->kvm->srcu, idx); >> + >> + if (vcpu) >> + srcu_read_unlock(&vcpu->kvm->srcu, idx); > > > ./include/linux/srcu.h:175:2: warning: ‘idx’ may be used uninitialized in this function [-Wmaybe-uninitialized] > __srcu_read_unlock(sp, idx); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > arch/x86/kvm/x86.c:2739:9: note: ‘idx’ was declared here > int i, idx; > ^~~ > > I know, silly gcc. > Nice point---even better, just push srcu_read_lock/unlock to msr_io or even msr_io's callers. Thanks, Paolo